Changes between Initial Version and Version 1 of LayoutUnit


Ignore:
Timestamp:
Feb 6, 2012 2:16:35 PM (10 years ago)
Author:
eae@chromium.org
Comment:

Added initial draft of wiki page explaining LayoutUnits.

Legend:

Unmodified
Added
Removed
Modified
  • LayoutUnit

    v1 v1  
     1LayoutUnit^1^ is an abstraction used to represent the location or size of a render object in fractions of a logical pixel, it is used primarily for layout and hit testing. The current implementation represents values as multiples of 1/60th pixel^2^. This allows us to use integer math and avoids floating point imprecision.
     2
     3Even though layout calculations are done using LayoutUnits the values are aligned to integer pixel values at paint time to line up with device pixels. While most modern graphics libraries support painting with subpixel precision, this results in unwanted anti-aliasing.
     4When aligning to device pixels the edges are aligned to the nearest pixel and then the size is adjusted accordingly. This ensures that the bottom/right edge and the total width/height is at most off-by-one.
     5
     6Certain cases require us to snap LayoutUnits to whole-pixel values, including:
     7 * scroll offsets - scrolling by subpixel values would cause off-by-one errors when pixel snapping, and would expose the embedding application to LayoutUnits.
     8 * border widths - to ensure that all borders are the same width as specified.
     9 * tables - to ensure even distribution of available space across columns.
     10 * size/position of widgets, plugins, video, and foreign objects - these are either rendered outside of WebCore, or pass through an intermediary embedding layer. We need to use integers so the contents are painted at whole-pixel values.
     11 * positioning of InlineBoxes in a RenderBlock - we lose the ability to pixel snap in sync with containing block because the line box tree paints with floats.
     12 * painting - to avoid unwanted anti-aliasing.
     13
     14
     15
     161: LayoutUnit is currently a typedef that maps to int. Once the subpixel branch has been merged this will map to AppUnit which is the underlying fixed point implementation. The eventual plan is to rename AppUnit to LayoutUnit and remove the typedef.
     17
     182: Based on Mozilla’s implementation. See the proposal [http://www.google.com/url?q=https%3A%2F%2Fwiki.mozilla.org%2FMozilla2%3AUnits%23Proposal&sa=D&sntz=1&usg=AFQjCNGVDYUBqn0EzB2VuU-H0-J60qXN4Q here] which was landed in [http://www.google.com/url?q=https%3A%2F%2Fbugzilla.mozilla.org%2Fshow_bug.cgi%3Fid%3D177805&sa=D&sntz=1&usg=AFQjCNHg7MMC3xFFILcRRYHxPrzzHK0peQ this bug].