@@ -21,7 +21,7 @@ use webrender_traits::{AuxiliaryLists, PipelineId, Epoch, ScrollPolicy, ScrollLa
21
21
use webrender_traits:: { ClipRegion , ColorF , DisplayItem , StackingContext , FilterOp , MixBlendMode } ;
22
22
use webrender_traits:: { ScrollEventPhase , ScrollLayerInfo , SpecificDisplayItem , ScrollLayerState } ;
23
23
use webrender_traits:: { LayerRect , LayerPoint , LayerSize } ;
24
- use webrender_traits:: { ScrollLayerRect , as_scroll_parent_rect, ScrollLayerPixel } ;
24
+ use webrender_traits:: { ServoScrollRootId , ScrollLayerRect , as_scroll_parent_rect, ScrollLayerPixel } ;
25
25
use webrender_traits:: WorldPoint4D ;
26
26
use webrender_traits:: { LayerTransform , LayerToScrollTransform , ScrollToWorldTransform } ;
27
27
@@ -52,6 +52,7 @@ pub struct Frame {
52
52
AuxiliaryLists ,
53
53
BuildHasherDefault < FnvHasher > > ,
54
54
pub root_scroll_layer_id : Option < ScrollLayerId > ,
55
+ pending_scroll_offsets : HashMap < ( PipelineId , ServoScrollRootId ) , LayerPoint > ,
55
56
id : FrameId ,
56
57
debug : bool ,
57
58
frame_builder_config : FrameBuilderConfig ,
@@ -210,6 +211,7 @@ impl Frame {
210
211
pipeline_auxiliary_lists : HashMap :: with_hasher ( Default :: default ( ) ) ,
211
212
layers : HashMap :: with_hasher ( Default :: default ( ) ) ,
212
213
root_scroll_layer_id : None ,
214
+ pending_scroll_offsets : HashMap :: new ( ) ,
213
215
id : FrameId ( 0 ) ,
214
216
debug : debug,
215
217
frame_builder : None ,
@@ -295,6 +297,38 @@ impl Frame {
295
297
result
296
298
}
297
299
300
+ /// Returns true if any layers actually changed position or false otherwise.
301
+ pub fn scroll_layers ( & mut self ,
302
+ origin : Point2D < f32 > ,
303
+ pipeline_id : PipelineId ,
304
+ scroll_root_id : ServoScrollRootId )
305
+ -> bool {
306
+ let origin = LayerPoint :: new ( origin. x . max ( 0.0 ) , origin. y . max ( 0.0 ) ) ;
307
+
308
+ let mut scrolled_a_layer = false ;
309
+ let mut found_layer = false ;
310
+ for ( layer_id, layer) in self . layers . iter_mut ( ) {
311
+ if layer_id. pipeline_id != pipeline_id {
312
+ continue ;
313
+ }
314
+
315
+ match layer_id. info {
316
+ ScrollLayerInfo :: Scrollable ( _, id) if id != scroll_root_id => continue ,
317
+ ScrollLayerInfo :: Fixed => continue ,
318
+ _ => { }
319
+ }
320
+
321
+ found_layer = true ;
322
+ scrolled_a_layer |= layer. set_scroll_origin ( & origin) ;
323
+ }
324
+
325
+ if !found_layer {
326
+ self . pending_scroll_offsets . insert ( ( pipeline_id, scroll_root_id) , origin) ;
327
+ }
328
+
329
+ scrolled_a_layer
330
+ }
331
+
298
332
/// Returns true if any layers actually changed position or false otherwise.
299
333
pub fn scroll ( & mut self ,
300
334
mut delta : Point2D < f32 > ,
@@ -480,6 +514,18 @@ impl Frame {
480
514
} ;
481
515
482
516
layer. finalize ( & scrolling_state) ;
517
+
518
+ let scroll_root_id = match scroll_layer_id. info {
519
+ ScrollLayerInfo :: Scrollable ( _, scroll_root_id) => scroll_root_id,
520
+ _ => continue ,
521
+ } ;
522
+
523
+
524
+ let pipeline_id = scroll_layer_id. pipeline_id ;
525
+ if let Some ( pending_offset) =
526
+ self . pending_scroll_offsets . get_mut ( & ( pipeline_id, scroll_root_id) ) {
527
+ layer. set_scroll_origin ( pending_offset) ;
528
+ }
483
529
}
484
530
}
485
531
0 commit comments