mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #14367 - mrobinson:scroll-fragment-point, r=pcwalton
Reimplement scrolling to fragments <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13736, #10753 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> This reimplemntation of the feature uses ScrollRootIds to scroll particular scrollable areas of the page. Fixes #13736. Fixes #10753. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14367) <!-- Reviewable:end -->
This commit is contained in:
commit
a0619688a6
18 changed files with 154 additions and 45 deletions
|
@ -87,6 +87,7 @@ use dom::window::{ReflowReason, Window};
|
|||
use encoding::EncodingRef;
|
||||
use encoding::all::UTF_8;
|
||||
use euclid::point::Point2D;
|
||||
use gfx_traits::ScrollRootId;
|
||||
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
|
||||
use html5ever_atoms::{LocalName, QualName};
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
|
@ -619,7 +620,10 @@ impl Document {
|
|||
|
||||
if let Some((x, y)) = point {
|
||||
// Step 3
|
||||
self.window.perform_a_scroll(x, y, ScrollBehavior::Instant,
|
||||
self.window.perform_a_scroll(x,
|
||||
y,
|
||||
ScrollRootId::root(),
|
||||
ScrollBehavior::Instant,
|
||||
target.r());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ use dom::storage::Storage;
|
|||
use dom::testrunner::TestRunner;
|
||||
use euclid::{Point2D, Rect, Size2D};
|
||||
use fetch;
|
||||
use gfx_traits::ScrollRootId;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{HandleObject, HandleValue, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JS_GC, JS_GetRuntime, SetWindowProxy};
|
||||
|
@ -67,7 +68,8 @@ use script_layout_interface::TrustedNodeAddress;
|
|||
use script_layout_interface::message::{Msg, Reflow, ReflowQueryType, ScriptReflow};
|
||||
use script_layout_interface::reporter::CSSErrorReporter;
|
||||
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
|
||||
use script_layout_interface::rpc::{MarginStyleResponse, ResolvedStyleResponse};
|
||||
use script_layout_interface::rpc::{MarginStyleResponse, NodeScrollRootIdResponse};
|
||||
use script_layout_interface::rpc::ResolvedStyleResponse;
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventCategory};
|
||||
use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, Runnable, RunnableWrapper};
|
||||
use script_thread::SendableMainThreadScriptChan;
|
||||
|
@ -967,13 +969,20 @@ impl Window {
|
|||
//TODO Step 11
|
||||
//let document = self.Document();
|
||||
// Step 12
|
||||
self.perform_a_scroll(x.to_f32().unwrap_or(0.0f32), y.to_f32().unwrap_or(0.0f32),
|
||||
behavior, None);
|
||||
self.perform_a_scroll(x.to_f32().unwrap_or(0.0f32),
|
||||
y.to_f32().unwrap_or(0.0f32),
|
||||
ScrollRootId::root(),
|
||||
behavior,
|
||||
None);
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/cssom-view/#perform-a-scroll
|
||||
pub fn perform_a_scroll(&self, x: f32, y: f32,
|
||||
behavior: ScrollBehavior, element: Option<&Element>) {
|
||||
pub fn perform_a_scroll(&self,
|
||||
x: f32,
|
||||
y: f32,
|
||||
scroll_root_id: ScrollRootId,
|
||||
behavior: ScrollBehavior,
|
||||
element: Option<&Element>) {
|
||||
//TODO Step 1
|
||||
let point = Point2D::new(x, y);
|
||||
let smooth = match behavior {
|
||||
|
@ -992,7 +1001,7 @@ impl Window {
|
|||
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
let message = ConstellationMsg::ScrollFragmentPoint(
|
||||
global_scope.pipeline_id(), point, smooth);
|
||||
global_scope.pipeline_id(), scroll_root_id, point, smooth);
|
||||
global_scope.constellation_chan().send(message).unwrap();
|
||||
}
|
||||
|
||||
|
@ -1272,11 +1281,24 @@ impl Window {
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
|
||||
pub fn scroll_node(&self, _node: TrustedNodeAddress,
|
||||
x_: f64, y_: f64, behavior: ScrollBehavior) {
|
||||
pub fn scroll_node(&self,
|
||||
node: TrustedNodeAddress,
|
||||
x_: f64,
|
||||
y_: f64,
|
||||
behavior: ScrollBehavior) {
|
||||
if !self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::NodeScrollRootIdQuery(node),
|
||||
ReflowReason::Query) {
|
||||
return;
|
||||
}
|
||||
let NodeScrollRootIdResponse(scroll_root_id) = self.layout_rpc.node_scroll_root_id();
|
||||
|
||||
// Step 12
|
||||
self.perform_a_scroll(x_.to_f32().unwrap_or(0.0f32), y_.to_f32().unwrap_or(0.0f32),
|
||||
behavior, None);
|
||||
self.perform_a_scroll(x_.to_f32().unwrap_or(0.0f32),
|
||||
y_.to_f32().unwrap_or(0.0f32),
|
||||
scroll_root_id,
|
||||
behavior,
|
||||
None);
|
||||
}
|
||||
|
||||
pub fn resolved_style_query(&self,
|
||||
|
@ -1648,6 +1670,7 @@ fn debug_reflow_events(id: PipelineId, goal: &ReflowGoal, query_type: &ReflowQue
|
|||
ReflowQueryType::NodeGeometryQuery(_n) => "\tNodeGeometryQuery",
|
||||
ReflowQueryType::NodeOverflowQuery(_n) => "\tNodeOverFlowQuery",
|
||||
ReflowQueryType::NodeScrollGeometryQuery(_n) => "\tNodeScrollGeometryQuery",
|
||||
ReflowQueryType::NodeScrollRootIdQuery(_n) => "\tNodeScrollRootIdQuery",
|
||||
ReflowQueryType::ResolvedStyleQuery(_, _, _) => "\tResolvedStyleQuery",
|
||||
ReflowQueryType::OffsetParentQuery(_n) => "\tOffsetParentQuery",
|
||||
ReflowQueryType::MarginStyleQuery(_n) => "\tMarginStyleQuery",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue