Changeset 110070 in webkit


Ignore:
Timestamp:
Mar 7, 2012 10:59:46 AM (12 years ago)
Author:
leviw@chromium.org
Message:

Update usage of LayoutUnits in InlineBox and InlineFlowBox
https://bugs.webkit.org/show_bug.cgi?id=80051

Reviewed by Eric Seidel.

Updating LayoutUnit vs Integer usage in InlineBox and InlineFlowBox. While the
line box tree remains floating point, margins are now subpixel, and rects from
the render tree use LayoutUnits. For more information, see the LayoutUnit wiki
page: https://trac.webkit.org/wiki/LayoutUnit

No new tests. No change in behavior.

  • rendering/InlineBox.cpp:

(WebCore::InlineBox::flipForWritingMode): Changing over to LayoutUnits.

  • rendering/InlineBox.h:

(InlineBox):

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::getFlowSpacingLogicalWidth): Returning a LayoutUnit
instead of an integer, as it uses margin which is a LayoutUnit.
(WebCore::InlineFlowBox::placeBoxesInInlineDirection): Using a LayoutUnit for
margin.
(WebCore::InlineFlowBox::placeBoxesInBlockDirection): Build fixes for when
LayoutUnits are subpixel.
(WebCore::InlineFlowBox::paintFillLayer): Ditto.

  • rendering/InlineFlowBox.h:

(WebCore::InlineFlowBox::marginBorderPaddingLogicalLeft): Returning a LayoutUnit
instead of an integer since margin is a LayoutUnit.
(WebCore::InlineFlowBox::marginBorderPaddingLogicalRight): Ditto.
(InlineFlowBox):
(WebCore::InlineFlowBox::logicalLeftLayoutOverflow): Adding a static_cast that's
redundant now, but required when we switch to subpixel LayoutUnits.
(WebCore::InlineFlowBox::logicalRightLayoutOverflow): Ditto.
(WebCore::InlineFlowBox::logicalLeftVisualOverflow): Ditto.
(WebCore::InlineFlowBox::logicalRightVisualOverflow): Ditto.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110067 r110070  
     12012-03-07  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update usage of LayoutUnits in InlineBox and InlineFlowBox
     4        https://bugs.webkit.org/show_bug.cgi?id=80051
     5
     6        Reviewed by Eric Seidel.
     7
     8        Updating LayoutUnit vs Integer usage in InlineBox and InlineFlowBox. While the
     9        line box tree remains floating point, margins are now subpixel, and rects from
     10        the render tree use LayoutUnits. For more information, see the LayoutUnit wiki
     11        page: https://trac.webkit.org/wiki/LayoutUnit
     12
     13        No new tests. No change in behavior.
     14
     15        * rendering/InlineBox.cpp:
     16        (WebCore::InlineBox::flipForWritingMode): Changing over to LayoutUnits.
     17        * rendering/InlineBox.h:
     18        (InlineBox):
     19        * rendering/InlineFlowBox.cpp:
     20        (WebCore::InlineFlowBox::getFlowSpacingLogicalWidth): Returning a LayoutUnit
     21        instead of an integer, as it uses margin which is a LayoutUnit.
     22        (WebCore::InlineFlowBox::placeBoxesInInlineDirection): Using a LayoutUnit for
     23        margin.
     24        (WebCore::InlineFlowBox::placeBoxesInBlockDirection): Build fixes for when
     25        LayoutUnits are subpixel.
     26        (WebCore::InlineFlowBox::paintFillLayer): Ditto.
     27        * rendering/InlineFlowBox.h:
     28        (WebCore::InlineFlowBox::marginBorderPaddingLogicalLeft): Returning a LayoutUnit
     29        instead of an integer since margin is a LayoutUnit.
     30        (WebCore::InlineFlowBox::marginBorderPaddingLogicalRight): Ditto.
     31        (InlineFlowBox):
     32        (WebCore::InlineFlowBox::logicalLeftLayoutOverflow): Adding a static_cast that's
     33        redundant now, but required when we switch to subpixel LayoutUnits.
     34        (WebCore::InlineFlowBox::logicalRightLayoutOverflow): Ditto.
     35        (WebCore::InlineFlowBox::logicalLeftVisualOverflow): Ditto.
     36        (WebCore::InlineFlowBox::logicalRightVisualOverflow): Ditto.
     37
    1382012-03-07  Qi Zhang  <qi.2.zhang@nokia.com>
    239
  • trunk/Source/WebCore/rendering/InlineBox.cpp

    r109593 r110070  
    366366}
    367367
    368 void InlineBox::flipForWritingMode(IntRect& rect)
     368void InlineBox::flipForWritingMode(LayoutRect& rect)
    369369{
    370370    if (!renderer()->style()->isFlippedBlocksWritingMode())
     
    373373}
    374374
    375 IntPoint InlineBox::flipForWritingMode(const IntPoint& point)
     375LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point)
    376376{
    377377    if (!renderer()->style()->isFlippedBlocksWritingMode())
  • trunk/Source/WebCore/rendering/InlineBox.h

    r109593 r110070  
    318318    void flipForWritingMode(FloatRect&);
    319319    FloatPoint flipForWritingMode(const FloatPoint&);
    320     void flipForWritingMode(IntRect&);
    321     IntPoint flipForWritingMode(const IntPoint&);
     320    void flipForWritingMode(LayoutRect&);
     321    LayoutPoint flipForWritingMode(const LayoutPoint&);
    322322
    323323    bool knownToHaveNoOverflow() const { return m_knownToHaveNoOverflow; }
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r107880 r110070  
    5757#endif
    5858
    59 int InlineFlowBox::getFlowSpacingLogicalWidth()
    60 {
    61     int totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
     59LayoutUnit InlineFlowBox::getFlowSpacingLogicalWidth()
     60{
     61    LayoutUnit totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
    6262    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
    6363        if (curr->isInlineFlowBox())
     
    398398                // The box can have a different writing-mode than the overall line, so this is a bit complicated.
    399399                // Just get all the physical margin and overflow values by hand based off |isVertical|.
    400                 int logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
    401                 int logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom();
     400                LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
     401                LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom();
    402402               
    403403                logicalLeft += logicalLeftMargin;
     
    701701                lineTopIncludingMargins = lineTop;
    702702            } else {
    703                 lineTop = min(lineTop, pixelSnappedLogicalTop());
     703                lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop());
    704704                lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins);
    705705            }
    706             lineBottom = max(lineBottom, pixelSnappedLogicalBottom());
     706            lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom());
    707707            lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMargins);
    708708        }
     
    11191119        LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : zeroLayoutUnit);
    11201120        LayoutUnit stripY = rect.y() - (isHorizontal() ? zeroLayoutUnit : logicalOffsetOnLine);
    1121         LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : width();
    1122         LayoutUnit stripHeight = isHorizontal() ? height() : totalLogicalWidth;
     1121        LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast<LayoutUnit>(width());
     1122        LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height()) : totalLogicalWidth;
    11231123
    11241124        GraphicsContextStateSaver stateSaver(*paintInfo.context);
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r107874 r110070  
    120120
    121121    // logicalLeft = left in a horizontal line and top in a vertical line.
    122     int marginBorderPaddingLogicalLeft() const { return marginLogicalLeft() + borderLogicalLeft() + paddingLogicalLeft(); }
    123     int marginBorderPaddingLogicalRight() const { return marginLogicalRight() + borderLogicalRight() + paddingLogicalRight(); }
     122    LayoutUnit marginBorderPaddingLogicalLeft() const { return marginLogicalLeft() + borderLogicalLeft() + paddingLogicalLeft(); }
     123    LayoutUnit marginBorderPaddingLogicalRight() const { return marginLogicalRight() + borderLogicalRight() + paddingLogicalRight(); }
    124124    LayoutUnit marginLogicalLeft() const
    125125    {
     
    169169    // Helper functions used during line construction and placement.
    170170    void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrapped, RenderObject* logicallyLastRunRenderer);
    171     int getFlowSpacingLogicalWidth();
     171    LayoutUnit getFlowSpacingLogicalWidth();
    172172    float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&);
    173173    void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom,
     
    208208        return m_overflow ? m_overflow->layoutOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
    209209    }
    210     LayoutUnit logicalLeftLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXLayoutOverflow() : m_overflow->minYLayoutOverflow()) : logicalLeft(); }
    211     LayoutUnit logicalRightLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXLayoutOverflow() : m_overflow->maxYLayoutOverflow()) : ceilf(logicalRight()); }
     210    LayoutUnit logicalLeftLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXLayoutOverflow() : m_overflow->minYLayoutOverflow()) : static_cast<LayoutUnit>(logicalLeft()); }
     211    LayoutUnit logicalRightLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXLayoutOverflow() : m_overflow->maxYLayoutOverflow()) : static_cast<LayoutUnit>(ceilf(logicalRight())); }
    212212    LayoutUnit logicalTopLayoutOverflow(LayoutUnit lineTop) const
    213213    {
     
    234234        return m_overflow ? m_overflow->visualOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
    235235    }
    236     LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXVisualOverflow() : m_overflow->minYVisualOverflow()) : logicalLeft(); }
    237     LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXVisualOverflow() : m_overflow->maxYVisualOverflow()) : ceilf(logicalRight()); }
     236    LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXVisualOverflow() : m_overflow->minYVisualOverflow()) : static_cast<LayoutUnit>(logicalLeft()); }
     237    LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXVisualOverflow() : m_overflow->maxYVisualOverflow()) : static_cast<LayoutUnit>(ceilf(logicalRight())); }
    238238    LayoutUnit logicalTopVisualOverflow(LayoutUnit lineTop) const
    239239    {
Note: See TracChangeset for help on using the changeset viewer.