mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Fix bug
Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
parent
3bced9535e
commit
4c1b69421a
10 changed files with 42 additions and 32 deletions
|
@ -257,7 +257,7 @@ impl PipelineDetails {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYNOTES: we also do this in the display list now
|
/// Install a new scroll tree, but maintaining the scroll offsets it has from the old ones.
|
||||||
fn install_new_scroll_tree(&mut self, new_scroll_tree: ScrollTree) {
|
fn install_new_scroll_tree(&mut self, new_scroll_tree: ScrollTree) {
|
||||||
let old_scroll_offsets: FnvHashMap<ExternalScrollId, LayoutVector2D> = self
|
let old_scroll_offsets: FnvHashMap<ExternalScrollId, LayoutVector2D> = self
|
||||||
.scroll_tree
|
.scroll_tree
|
||||||
|
@ -744,7 +744,7 @@ impl IOCompositor {
|
||||||
txn.set_scroll_offsets(
|
txn.set_scroll_offsets(
|
||||||
external_scroll_id,
|
external_scroll_id,
|
||||||
vec![SampledScrollOffset {
|
vec![SampledScrollOffset {
|
||||||
offset,
|
offset: -offset,
|
||||||
generation: 0,
|
generation: 0,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
|
|
|
@ -183,7 +183,6 @@ impl WebViewRenderer {
|
||||||
self.pipelines.remove(&pipeline_id);
|
self.pipelines.remove(&pipeline_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYNOTES: I suppose this is not needed now? If changing composition's frame tree does trigger reflow?
|
|
||||||
pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
|
pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
|
||||||
let pipeline_id = frame_tree.pipeline.id;
|
let pipeline_id = frame_tree.pipeline.id;
|
||||||
let old_pipeline_id = std::mem::replace(&mut self.root_pipeline_id, Some(pipeline_id));
|
let old_pipeline_id = std::mem::replace(&mut self.root_pipeline_id, Some(pipeline_id));
|
||||||
|
@ -876,6 +875,8 @@ impl WebViewRenderer {
|
||||||
combined_event.scroll_location,
|
combined_event.scroll_location,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
// If something is scrolled, we are sending the scroll information to layout in
|
||||||
|
// order to sync the scroll offsets for queries and scripts.
|
||||||
if let Some(scroll_result) = scroll_result {
|
if let Some(scroll_result) = scroll_result {
|
||||||
self.send_scroll_result_to_layout(scroll_result);
|
self.send_scroll_result_to_layout(scroll_result);
|
||||||
}
|
}
|
||||||
|
@ -894,7 +895,6 @@ impl WebViewRenderer {
|
||||||
/// scrolling to the applicable scroll node under that point. If a scroll was
|
/// scrolling to the applicable scroll node under that point. If a scroll was
|
||||||
/// performed, returns the [`PipelineId`] of the node scrolled, the id, and the final
|
/// performed, returns the [`PipelineId`] of the node scrolled, the id, and the final
|
||||||
/// scroll delta.
|
/// scroll delta.
|
||||||
// MYNOTES: this could be changed to we only store the diff
|
|
||||||
fn scroll_node_at_device_point(
|
fn scroll_node_at_device_point(
|
||||||
&mut self,
|
&mut self,
|
||||||
cursor: DevicePoint,
|
cursor: DevicePoint,
|
||||||
|
|
|
@ -6022,14 +6022,13 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYNOTES: this shouldn't be necessary anymore since, we have scroll offsets tree at layout impl
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
|
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
|
||||||
)]
|
)]
|
||||||
fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec<ScrollState>) {
|
fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec<ScrollState>) {
|
||||||
let Some(pipeline) = self.pipelines.get(&pipeline_id) else {
|
let Some(pipeline) = self.pipelines.get(&pipeline_id) else {
|
||||||
warn!("Discarding scroll offset update for unknown pipeline");
|
warn!("Discarding scroll offsets update for unknown pipeline");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if let Err(error) = pipeline
|
if let Err(error) = pipeline
|
||||||
|
@ -6049,7 +6048,7 @@ where
|
||||||
)]
|
)]
|
||||||
fn handle_update_scroll_state(&self, pipeline_id: PipelineId, scroll_state: ScrollState) {
|
fn handle_update_scroll_state(&self, pipeline_id: PipelineId, scroll_state: ScrollState) {
|
||||||
let Some(pipeline) = self.pipelines.get(&pipeline_id) else {
|
let Some(pipeline) = self.pipelines.get(&pipeline_id) else {
|
||||||
warn!("Discarding scroll offset update for unknown pipeline");
|
warn!("Discarding a scroll result update for unknown pipeline");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if let Err(error) = pipeline
|
if let Err(error) = pipeline
|
||||||
|
@ -6059,7 +6058,7 @@ where
|
||||||
scroll_state,
|
scroll_state,
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
warn!("Could not send scroll offsets to pipeline: {pipeline_id:?}: {error:?}");
|
warn!("Could not send scroll result update to pipeline: {pipeline_id:?}: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ pub(crate) struct StackingContextTree {
|
||||||
impl StackingContextTree {
|
impl StackingContextTree {
|
||||||
/// Create a new [DisplayList] given the dimensions of the layout and the WebRender
|
/// Create a new [DisplayList] given the dimensions of the layout and the WebRender
|
||||||
/// pipeline id.
|
/// pipeline id.
|
||||||
// MYNOTES: fix this
|
// FIXME(stevennovaryo): refactor the stacking context parameters
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
fragment_tree: &FragmentTree,
|
fragment_tree: &FragmentTree,
|
||||||
|
@ -979,6 +979,8 @@ impl BoxFragment {
|
||||||
StackingContextSection::DescendantBackgroundsAndBorders
|
StackingContextSection::DescendantBackgroundsAndBorders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(stevennovaryo): refactor the stacking context parameters
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_stacking_context_tree(
|
fn build_stacking_context_tree(
|
||||||
&self,
|
&self,
|
||||||
fragment: Fragment,
|
fragment: Fragment,
|
||||||
|
@ -1000,6 +1002,8 @@ impl BoxFragment {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(stevennovaryo): refactor the stacking context parameters
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_stacking_context_tree_maybe_creating_reference_frame(
|
fn build_stacking_context_tree_maybe_creating_reference_frame(
|
||||||
&self,
|
&self,
|
||||||
fragment: Fragment,
|
fragment: Fragment,
|
||||||
|
@ -1076,7 +1080,7 @@ impl BoxFragment {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYNOTES: fix this
|
// FIXME(stevennovaryo): refactor the stacking context parameters
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_stacking_context_tree_maybe_creating_stacking_context(
|
fn build_stacking_context_tree_maybe_creating_stacking_context(
|
||||||
&self,
|
&self,
|
||||||
|
@ -1172,7 +1176,7 @@ impl BoxFragment {
|
||||||
.append(&mut stolen_children);
|
.append(&mut stolen_children);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MYNOTES: fix this
|
// FIXME(stevennovaryo): refactor the stacking context parameters
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_stacking_context_tree_for_children(
|
fn build_stacking_context_tree_for_children(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -496,6 +496,9 @@ impl Layout for LayoutThread {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the scroll offsets of the cached [`ScrollTree`] based on the scroll states.
|
||||||
|
///
|
||||||
|
/// This is done whenever the embedder ask layout to do so.
|
||||||
fn set_scroll_offsets(&mut self, scroll_states: &[ScrollState]) {
|
fn set_scroll_offsets(&mut self, scroll_states: &[ScrollState]) {
|
||||||
if let Some(mut tree) = self.cached_scroll_tree_mut() {
|
if let Some(mut tree) = self.cached_scroll_tree_mut() {
|
||||||
for ScrollState {
|
for ScrollState {
|
||||||
|
@ -508,7 +511,9 @@ impl Layout for LayoutThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/// Update a node's scroll offsets in the cached [`ScrollTree`].
|
||||||
|
///
|
||||||
|
/// This is done whenever the embedder ask layout to do so.
|
||||||
fn update_scroll_offset(&self, scroll_id: ExternalScrollId, scroll_offset: LayoutVector2D) {
|
fn update_scroll_offset(&self, scroll_id: ExternalScrollId, scroll_offset: LayoutVector2D) {
|
||||||
if let Some(mut scroll_tree) = self.cached_scroll_tree_mut() {
|
if let Some(mut scroll_tree) = self.cached_scroll_tree_mut() {
|
||||||
scroll_tree
|
scroll_tree
|
||||||
|
@ -773,10 +778,10 @@ impl LayoutThread {
|
||||||
.flush(guards, Some(root_element), Some(snapshot_map));
|
.flush(guards, Some(root_element), Some(snapshot_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg_attr(
|
#[cfg_attr(
|
||||||
// feature = "tracing",
|
feature = "tracing",
|
||||||
// tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
|
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
|
||||||
// )]
|
)]
|
||||||
fn restyle_and_build_trees(
|
fn restyle_and_build_trees(
|
||||||
&self,
|
&self,
|
||||||
reflow_request: &ReflowRequest,
|
reflow_request: &ReflowRequest,
|
||||||
|
@ -848,7 +853,8 @@ impl LayoutThread {
|
||||||
*self.fragment_tree.borrow_mut() = Some(fragment_tree);
|
*self.fragment_tree.borrow_mut() = Some(fragment_tree);
|
||||||
|
|
||||||
// The FragmentTree has been updated, so any existing StackingContext tree that layout
|
// The FragmentTree has been updated, so any existing StackingContext tree that layout
|
||||||
// had is now out of date and should be rebuilt.
|
// had is now out of date and should be rebuilt. We could still uses some information
|
||||||
|
// from the previous StackingContext tree though.
|
||||||
let old_stacking_context_tree = self.stacking_context_tree.borrow_mut().take();
|
let old_stacking_context_tree = self.stacking_context_tree.borrow_mut().take();
|
||||||
|
|
||||||
if self.debug.dump_style_tree {
|
if self.debug.dump_style_tree {
|
||||||
|
|
|
@ -77,7 +77,6 @@ use servo_arc::Arc as ServoArc;
|
||||||
use servo_config::{opts, pref};
|
use servo_config::{opts, pref};
|
||||||
use servo_geometry::{DeviceIndependentIntRect, MaxRect, f32_rect_to_au_rect};
|
use servo_geometry::{DeviceIndependentIntRect, MaxRect, f32_rect_to_au_rect};
|
||||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
use style::dom::OpaqueNode;
|
|
||||||
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||||
use style::properties::PropertyId;
|
use style::properties::PropertyId;
|
||||||
use style::properties::style_structs::Font;
|
use style::properties::style_structs::Font;
|
||||||
|
@ -2552,7 +2551,7 @@ impl Window {
|
||||||
self.pipeline_id().into(),
|
self.pipeline_id().into(),
|
||||||
);
|
);
|
||||||
self.layout()
|
self.layout()
|
||||||
.update_scroll_offset(scroll_id, Vector2D::new(x, y));
|
.update_scroll_offset(scroll_id, Vector2D::new(-x, -y));
|
||||||
|
|
||||||
// Step 6
|
// Step 6
|
||||||
// > Perform a scroll of box to position, element as the associated
|
// > Perform a scroll of box to position, element as the associated
|
||||||
|
|
|
@ -83,16 +83,13 @@ use percent_encoding::percent_decode;
|
||||||
use profile_traits::mem::{ProcessReports, ReportsChan, perform_memory_report};
|
use profile_traits::mem::{ProcessReports, ReportsChan, perform_memory_report};
|
||||||
use profile_traits::time::ProfilerCategory;
|
use profile_traits::time::ProfilerCategory;
|
||||||
use profile_traits::time_profile;
|
use profile_traits::time_profile;
|
||||||
use script_layout_interface::{
|
use script_layout_interface::{LayoutConfig, LayoutFactory, ReflowGoal, ScriptThreadFactory};
|
||||||
LayoutConfig, LayoutFactory, ReflowGoal, ScriptThreadFactory, node_id_from_scroll_id,
|
|
||||||
};
|
|
||||||
use script_traits::{
|
use script_traits::{
|
||||||
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
|
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
|
||||||
NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason,
|
NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason,
|
||||||
};
|
};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
use style::dom::OpaqueNode;
|
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
use stylo_atoms::Atom;
|
use stylo_atoms::Atom;
|
||||||
use timers::{TimerEventRequest, TimerScheduler};
|
use timers::{TimerEventRequest, TimerScheduler};
|
||||||
|
@ -1928,7 +1925,6 @@ impl ScriptThread {
|
||||||
ScriptThreadEventCategory::SetScrollState,
|
ScriptThreadEventCategory::SetScrollState,
|
||||||
Some(pipeline_id),
|
Some(pipeline_id),
|
||||||
|| {
|
|| {
|
||||||
// MYNOTES: FIXME
|
|
||||||
window.layout_mut().set_scroll_offsets(&scroll_states);
|
window.layout_mut().set_scroll_offsets(&scroll_states);
|
||||||
|
|
||||||
for scroll_state in scroll_states.into_iter() {
|
for scroll_state in scroll_states.into_iter() {
|
||||||
|
@ -1949,7 +1945,15 @@ impl ScriptThread {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.layout_mut().update_scroll_offset(scroll_state.scroll_id, scroll_state.scroll_offset);
|
if scroll_state.scroll_id.is_root() {
|
||||||
|
window.update_viewport_for_scroll(
|
||||||
|
-scroll_state.scroll_offset.x,
|
||||||
|
-scroll_state.scroll_offset.y,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
window
|
||||||
|
.layout_mut()
|
||||||
|
.update_scroll_offset(scroll_state.scroll_id, scroll_state.scroll_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl ScrollTreeNode {
|
||||||
|
|
||||||
/// Set the offset for this node, returns false if this was a
|
/// Set the offset for this node, returns false if this was a
|
||||||
/// non-scrolling node for which you cannot set the offset.
|
/// non-scrolling node for which you cannot set the offset.
|
||||||
// MYNOTES: should i make this &mut so it will modify the new_offset
|
// TODO(stevennovaryo): We should consider writing mode as well.
|
||||||
pub fn set_offset(&mut self, new_offset: LayoutVector2D) -> bool {
|
pub fn set_offset(&mut self, new_offset: LayoutVector2D) -> bool {
|
||||||
match self.info {
|
match self.info {
|
||||||
SpatialTreeNodeInfo::Scroll(ref mut info) => {
|
SpatialTreeNodeInfo::Scroll(ref mut info) => {
|
||||||
|
@ -361,12 +361,11 @@ impl ScrollTree {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Some(node) = self.get_node_by_external_scroll_id_mut(external_scroll_id) {
|
if let Some(node) = self.get_node_by_external_scroll_id_mut(external_scroll_id) {
|
||||||
node.set_offset(offset);
|
node.set_offset(offset);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update this stacking context
|
|
||||||
pub fn persevere_old_stacking_context_tree_scroll() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A data structure which stores compositor-side information about
|
/// A data structure which stores compositor-side information about
|
||||||
|
|
|
@ -90,7 +90,6 @@ pub enum EmbedderToConstellationMessage {
|
||||||
SetWebViewThrottled(WebViewId, bool),
|
SetWebViewThrottled(WebViewId, bool),
|
||||||
/// The Servo renderer scrolled and is updating the scroll states of the nodes in the
|
/// The Servo renderer scrolled and is updating the scroll states of the nodes in the
|
||||||
/// given pipeline via the constellation.
|
/// given pipeline via the constellation.
|
||||||
// MYNOTES: Do we still need this?
|
|
||||||
SetScrollStates(PipelineId, Vec<ScrollState>),
|
SetScrollStates(PipelineId, Vec<ScrollState>),
|
||||||
/// The Servo renderer scrolled and is updating the scroll states of the nodes in the
|
/// The Servo renderer scrolled and is updating the scroll states of the nodes in the
|
||||||
/// given pipeline via the constellation.
|
/// given pipeline via the constellation.
|
||||||
|
|
|
@ -48,8 +48,8 @@ use style::properties::PropertyId;
|
||||||
use style::properties::style_structs::Font;
|
use style::properties::style_structs::Font;
|
||||||
use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
|
use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
|
||||||
use style::stylesheets::Stylesheet;
|
use style::stylesheets::Stylesheet;
|
||||||
use webrender_api::{ExternalScrollId, ImageKey};
|
|
||||||
use webrender_api::units::{DeviceIntSize, LayoutVector2D};
|
use webrender_api::units::{DeviceIntSize, LayoutVector2D};
|
||||||
|
use webrender_api::{ExternalScrollId, ImageKey};
|
||||||
|
|
||||||
pub trait GenericLayoutDataTrait: Any + MallocSizeOfTrait {
|
pub trait GenericLayoutDataTrait: Any + MallocSizeOfTrait {
|
||||||
fn as_any(&self) -> &dyn Any;
|
fn as_any(&self) -> &dyn Any;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue