This is just an informational message to inform everyone of the design
of current scrolling model. I hope this will also be useful to shine the
way toward overflow:scroll. I'm also interested in hearing about
potential improvements to this model, because it would be best to
implement them now, before accumulating more technical debt.

Scrolling is implemented by the compositor. Compositor layers that opt
in to scroll events via the wants_scroll_events flag can scroll their
contents. From now on, I will refer to these as "scrolling roots."
Scrolling roots serve as a viewport into their content, which is stored
in descendant layers. In order for scrolling roots to be able to scroll
their content, they need to be smaller than that content [1].

Since the compositor normally allows layers to exist independently of
their parents, child layers can overflow or fail to intersect their
parents completely. To prevent this, scrolling roots use the
masks_to_bounds flag, which is a signal to the compositor that it should
not paint any part of descendant layers that lies outside the boundaries
of the scrolling root.

Below is an (admittedly terrible) ASCII art diagram showing a scrolling
root with three content layers, scrolled down a few ticks. Everything
above and below the set of "====" bars would be hidden by masks_to_bounds.

+-----------------------+           
|                       |           
=========================           
|                       |  scrolling
|           <---------------+root   
|                       |           
|             +-------+ |           
=========================           
|             |       | |           
++-------+    +--^----+ |           
||       |       |      |           
||       |       |      |    content
++-------+  <----+-----------+layers
|                       |           
|                       |           
|                       |           
+-----------------------+           

Currently, only iframes and the main frame scroll according to this
model [2]. There isn't a lot in the way to extend this model to
overflow:scroll. The layout code would simply need to make a layer for
the content inside the scrolling flow and a layer for the scrolling
root. The two main dependencies for this would be:

a. Adding a way for layers to trigger the masks_to_bounds flag.
b. Adding support for building layer trees, since all layers are now
added as direct children of their frame root layer.


1. If the content was larger than the scrolling root, it would not be
able to move around inside the scrolling root. Imagine a browser window
that is larger than the content that it contains.

2. The main frame's scroll root size is defined by the window size.

--Martin
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to