mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
script: Fire scroll
event whenever JS scrolled (#38321)
Implement JS scroll event firing compliant to https://drafts.csswg.org/cssom-view/#scrolling-events. Basically whenever, the an element or the viewport is scrolled, we will fire a scroll event. The changes push a scroll event whenever an API causes a scroll position to change. Testing: New WPT tests for basic APIs. Part of: https://github.com/servo/servo/issues/31665 --------- Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
parent
372e5eae59
commit
a063b5e78a
11 changed files with 407 additions and 74 deletions
|
@ -2476,6 +2476,7 @@ impl Element {
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
|
||||
// TODO(stevennovaryo): Need to update the scroll API to follow the spec since it is quite outdated.
|
||||
pub(crate) fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior, can_gc: CanGc) {
|
||||
// Step 1.2 or 2.3
|
||||
let x = if x_.is_finite() { x_ } else { 0.0f64 };
|
||||
|
@ -2524,7 +2525,7 @@ impl Element {
|
|||
}
|
||||
|
||||
// Step 11
|
||||
win.scroll_node(node, x, y, behavior, can_gc);
|
||||
win.scroll_an_element(self, x, y, behavior, can_gc);
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#fragment-parsing-algorithm-steps>
|
||||
|
@ -3180,6 +3181,7 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrolltop
|
||||
// TODO(stevennovaryo): Need to update the scroll API to follow the spec since it is quite outdated.
|
||||
fn SetScrollTop(&self, y_: f64, can_gc: CanGc) {
|
||||
let behavior = ScrollBehavior::Auto;
|
||||
|
||||
|
@ -3229,7 +3231,7 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
|
|||
}
|
||||
|
||||
// Step 11
|
||||
win.scroll_node(node, self.ScrollLeft(can_gc), y, behavior, can_gc);
|
||||
win.scroll_an_element(self, self.ScrollLeft(can_gc), y, behavior, can_gc);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrolltop
|
||||
|
@ -3329,7 +3331,7 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
|
|||
}
|
||||
|
||||
// Step 11
|
||||
win.scroll_node(node, x, self.ScrollTop(can_gc), behavior, can_gc);
|
||||
win.scroll_an_element(self, x, self.ScrollTop(can_gc), behavior, can_gc);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue