Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # `Source/core/layout` | 1 # `Source/core/layout` |
| 2 | 2 |
| 3 This directory contains implementation of layout objects. It covers the | 3 This directory contains implementation of layout objects. It covers the |
| 4 following document lifecycle states: | 4 following document lifecycle states: |
| 5 | 5 |
| 6 * LayoutSubtreeChange (`InLayoutSubtreeChange` and `LayoutSubtreeChangeClean`) | 6 * LayoutSubtreeChange (`InLayoutSubtreeChange` and `LayoutSubtreeChangeClean`) |
| 7 * PreLayout (`InPreLayout`) | 7 * PreLayout (`InPreLayout`) |
| 8 * PerformLayout (`InPerformLayout`) | 8 * PerformLayout (`InPerformLayout`) |
| 9 * AfterPerformLayout (`AfterPerformLayout` and `LayoutClean`) | 9 * AfterPerformLayout (`AfterPerformLayout` and `LayoutClean`) |
| 10 | 10 |
| 11 Note that a new Blink layout system is under development. See the | 11 Note that a new Blink layout system is under development. See the |
| 12 [LayoutNG design document](https://docs.google.com/document/d/1uxbDh4uONFQOiGuiu mlJBLGgO4KDWB8ZEkp7Rd47fw4/preview). | 12 [LayoutNG design document](https://docs.google.com/document/d/1uxbDh4uONFQOiGuiu mlJBLGgO4KDWB8ZEkp7Rd47fw4/preview). |
| 13 | 13 |
| 14 ## Overflow rects and scroll offsets | 14 ## Overflow and scrolling |
| 15 | 15 |
| 16 PaintLayerScrollableArea uses a "scroll origin" to conceptually represent the di stance between | 16 When a LayoutBox has scrollable overflow, it is associated with a PaintLayerScro llableArea. |
| 17 the top-left corner of the box'es content rect and the top-left corner of its ov erflow rect | 17 PaintLayerScrollableArea uses a "scroll origin" to represent the location of the top/left |
| 18 when the box is scrolled to the logical beginning of its content (e.g. all the w ay to the left for | 18 corner of the content rect (the visible part of the content) in the coordinate s ystem |
| 19 LTR, all the way to the right for RTL). For left-to-right and top-to-bottom flo ws, the scroll | 19 defined by the top/left corner of the overflow rect, when the box is scrolled al l the way |
| 20 origin is zero, i.e., the top/left of the overflow rect is at the same position as the top/left of | 20 to the beginning of its content. |
| 21 the box'es content rect when scrolled to the beginning of flow. For right-to-le ft and bottom-to-top | |
| 22 flows, the overflow rect extends to the top/left of the client rect. | |
| 23 | 21 |
| 24 The default calculation for scroll origin is the distance between the top-left c orner of the content | 22 For content which flows left-to-right and top-to-bottom, the scroll origin will be (0, 0), |
| 25 rect and the top-left corner of the overflow rect. To illustrate, here is a box with left overflow and | 23 i.e., the top/left of the content rect is coincident with the top/left of the ov erflow rect |
| 26 no vertical scrollbar: | 24 when the box is scrolled all the way to the beginning of content. |
| 27 | 25 |
| 28 content | 26 For content which flows right-to-left (including direction:ltr, writing-mode:ver tical-rl, |
| 29 rect | 27 and flex-direction:row-reverse), the x-coordinate of the scroll origin will be p ositive; |
| 30 |<-------->| | 28 and for content which flows bottom-to-top (e.g., flex-direction:column-reverse a nd |
| 31 scroll | 29 vertical writing-mode with direction:ltr), the y-coordinate of the scroll origin will be |
| 32 origin | 30 positive. |
| 33 |<-------->| | |
| 34 _____________________ | |
| 35 | | | | |
| 36 | | | | |
| 37 | | | | |
| 38 direction:rtl | | box | | |
| 39 | | | | |
| 40 | | | | |
| 41 |__________|__________| | |
| 42 | 31 |
| 43 overflow rect | 32 In all cases, the term 'scrollOffset' (or just 'offset') is used to represent th e distance |
| 44 |<--------------------->| | 33 of the scrolling viewport from its location when scrolled to the beginning of co ntent, and |
| 34 it uses type ScrollOffset. The term 'scrollPosition' (or just 'position') repres ents a | |
| 35 point in the coordinate space defined by the overflow rect, and it uses type Flo atPoint. | |
| 45 | 36 |
| 37 For illustrations of these concepts, see these files: | |
| 46 | 38 |
| 47 However, if the box has a scrollbar for the orthogonal direction (e.g., a vertic al scrollbar | 39 doc/ltr-tb-scroll.png |
| 48 in a direction:rtl block), the size of the scrollbar must be added to the scroll origin calculation. | 40 doc/rtl-bt-scroll.png |
| 49 Here are two examples -- note that it doesn't matter whether the vertical scroll bar is placed on | 41 doc/rtl-tb-scroll.png |
| 50 the right or left of the box (the vertical scrollbar is the `|/|` part): | 42 |
| 43 Unfortunately, the geometric abstraction of origin, offset, and position breaks down slighlty | |
|
skobes
2016/10/06 20:06:53
"slightly"
szager1
2016/10/06 21:07:03
Done.
| |
| 44 when computing the scroll origin if the box has a scrollbar for the orthogonal d irection | |
| 45 (e.g., a vertical scrollbar in a direction:rtl block): the size of the scrollbar must be added | |
| 46 to the scroll origin calculation. Here are two examples -- note that it doesn't matter whether | |
| 47 the vertical scrollbar is placed on the right or left of the box (the vertical s crollbar is the | |
| 48 `|/|` part): | |
| 49 | |
| 51 | 50 |
| 52 content | 51 content |
| 53 rect | 52 rect |
| 54 |<-------->| | 53 |<-------->| |
| 55 scroll | 54 scroll |
| 56 origin | 55 origin |
| 57 |<---------->| | 56 |----------->| |
| 58 _______________________ | 57 _______________________ |
| 59 | |/| | | 58 | |/| | |
| 60 | |/| | | 59 | |/| | |
| 61 | |/| | | 60 | |/| | |
| 62 direction:rtl | |/| box | | 61 direction:rtl | |/| box | |
| 63 | |/| | | 62 | |/| | |
| 64 | |/| | | 63 | |/| | |
| 65 |__________|/|__________| | 64 |__________|/|__________| |
| 66 | 65 |
| 67 overflow rect | 66 overflow rect |
| 68 |<--------------------->| | 67 |<--------------------->| |
| 69 | 68 |
| 70 content | 69 content |
| 71 rect | 70 rect |
| 72 |<-------->| | 71 |<-------->| |
| 73 scroll | 72 scroll |
| 74 origin | 73 origin |
| 75 |<---------->| | 74 |----------->| |
| 76 _______________________ | 75 _______________________ |
|
skobes
2016/10/06 20:06:53
I still can't wrap my head around this picture.
W
szager1
2016/10/06 21:07:03
The overflow rect is determined independently of w
| |
| 77 | | |/| | 76 | | |/| |
| 78 | | |/| | 77 | | |/| |
| 79 | | |/| | 78 | | |/| |
| 80 writing-mode: | | |/| | 79 writing-mode: | | box |/| |
| 81 vertical-rl | | |/| | 80 vertical-rl | | |/| |
| 82 | | |/| | 81 | | |/| |
| 83 | | |/| | 82 |__________|__________|/| |
| 84 | | |/| | 83 |
| 85 |__________|__________|/| | 84 overflow rect |
| 85 |<--------------------->| | |
| 86 | 86 |
| 87 overflow rect | |
| 88 |<--------------------->| | |
| 89 | 87 |
| 90 ## Coordinate Spaces | 88 ## Coordinate Spaces |
| 91 | 89 |
| 92 Layout and Paint work with and frequently refer to three main coordinate spaces | 90 Layout and Paint work with and frequently refer to three main coordinate spaces |
| 93 (really two, with one variant): | 91 (really two, with one variant): |
| 94 | 92 |
| 95 * Physical coordinates: Corresponds to physical direction of the output per the | 93 * Physical coordinates: Corresponds to physical direction of the output per the |
| 96 physical display (screen, printed page). Generally used for painting, thus | 94 physical display (screen, printed page). Generally used for painting, thus |
| 97 layout logic that feeds into paint may produce values in this space. CSS | 95 layout logic that feeds into paint may produce values in this space. CSS |
| 98 properties such as `top`, `right`, `bottom`, and `left` are in this space. See | 96 properties such as `top`, `right`, `bottom`, and `left` are in this space. See |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 left-to-right or right-to-left block flow. Geometry is transposed for vertical | 297 left-to-right or right-to-left block flow. Geometry is transposed for vertical |
| 300 writing mode. See calls to `transposed{Rect,Point,Size}()`. | 298 writing mode. See calls to `transposed{Rect,Point,Size}()`. |
| 301 * `direction`/`dir`: "inline base direction" of a box. One of `ltr` or | 299 * `direction`/`dir`: "inline base direction" of a box. One of `ltr` or |
| 302 `rtl`. See calls to `isLeftToRightDirection()`. | 300 `rtl`. See calls to `isLeftToRightDirection()`. |
| 303 * `text-orientation`: orientation of text in a line. Only relevant for vertical | 301 * `text-orientation`: orientation of text in a line. Only relevant for vertical |
| 304 modes. | 302 modes. |
| 305 * orthogonal flow: when a box has a writing mode perpendicular to its containing | 303 * orthogonal flow: when a box has a writing mode perpendicular to its containing |
| 306 block. This can lead to complex cases. See | 304 block. This can lead to complex cases. See |
| 307 [specification](https://www.w3.org/TR/css-writing-modes-3/#orthogonal-flows) | 305 [specification](https://www.w3.org/TR/css-writing-modes-3/#orthogonal-flows) |
| 308 for more. | 306 for more. |
| OLD | NEW |