Reimplement scrolling to fragments

This reimplemntation of the feature uses ScrollRootIds to scroll
particular scrollable areas of the page.

Fixes #13736.
Fixes #10753.
This commit is contained in:
Martin Robinson 2016-11-21 09:48:33 +01:00
parent 39845faf26
commit 0b56bb2237
18 changed files with 154 additions and 45 deletions

View file

@ -39,7 +39,7 @@ use util::geometry::ScreenPx;
use util::opts;
use util::prefs::PREFS;
use webrender;
use webrender_traits::{self, ScrollEventPhase};
use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId};
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
#[derive(Debug, PartialEq)]
@ -493,9 +493,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.title_for_main_frame();
}
(Msg::ScrollFragmentPoint(pipeline_id, point, _),
(Msg::ScrollFragmentPoint(pipeline_id, scroll_root_id, point, _),
ShutdownState::NotShuttingDown) => {
self.scroll_fragment_to_point(pipeline_id, point);
self.scroll_fragment_to_point(pipeline_id, scroll_root_id, point);
}
(Msg::MoveTo(point),
@ -761,9 +761,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn scroll_fragment_to_point(&mut self,
_pipeline_id: PipelineId,
_point: Point2D<f32>) {
println!("TODO: Support scroll_fragment_to_point again");
pipeline_id: PipelineId,
scroll_root_id: ScrollRootId,
point: Point2D<f32>) {
self.webrender_api.scroll_layers_with_scroll_root_id(
point,
pipeline_id.to_webrender(),
ServoScrollRootId(scroll_root_id.0));
}
fn handle_window_message(&mut self, event: WindowEvent) {

View file

@ -8,6 +8,7 @@ use SendableFrameTree;
use compositor::CompositingReason;
use euclid::point::Point2D;
use euclid::size::Size2D;
use gfx_traits::ScrollRootId;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use net_traits::image::base::Image;
@ -72,7 +73,7 @@ pub enum Msg {
ShutdownComplete,
/// Scroll a page in a window
ScrollFragmentPoint(PipelineId, Point2D<f32>, bool),
ScrollFragmentPoint(PipelineId, ScrollRootId, Point2D<f32>, bool),
/// Alerts the compositor that the current page has changed its title.
ChangePageTitle(PipelineId, Option<String>),
/// Alerts the compositor that the current page has changed its URL.