Changeset 91417 in webkit


Ignore:
Timestamp:
Jul 20, 2011 4:18:27 PM (13 years ago)
Author:
leviw@chromium.org
Message:

Bring Int/Float graphics classes closer to parity
https://bugs.webkit.org/show_bug.cgi?id=64833

Reviewed by James Robinson.

In preparation of switching to Floating point data structures, bringing the
functionality and method names of the Int/Float graphics classes close together.

Also fixing some compiler errors when using Floats for layout units along the way.

No new tests, no functionality change.

  • page/FrameView.cpp:

(WebCore::FrameView::convertFromRenderer):

  • platform/ScrollView.cpp:

(WebCore::ScrollView::wheelEvent):

  • platform/ScrollView.h:

(WebCore::ScrollView::convertChildToSelf):
(WebCore::ScrollView::convertSelfToChild):

  • platform/graphics/FloatPoint.h:

(WebCore::operator-): Adding a single-parameter version.

  • platform/graphics/FloatSize.cpp:

(WebCore::FloatSize::isZero): Adding isZero that uses epsilon for floats.

  • platform/graphics/FloatSize.h:
  • platform/graphics/IntPoint.h:

(WebCore::IntPoint::moveBy): Renaming IntPoint version to moveBy to mirror FloatPoint.

  • platform/graphics/RoundedRect.cpp:

(WebCore::RoundedRect::Radii::expand): Switching to specific templatized max.

  • platform/graphics/filters/FilterEffect.cpp:

(WebCore::FilterEffect::requestedRegionOfInputImageData):

  • rendering/RenderBlock.cpp: Moving outstanding Int* functions to Layout units.

(WebCore::RenderBlock::paintContinuationOutlines):
(WebCore::RenderBlock::logicalRectToPhysicalRect):

  • rendering/RenderBlock.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::positionForPoint):

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::subtractCaptionRect):

  • rendering/RenderTable.h:
  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::styleOrColLogicalWidth):
(WebCore::RenderTableCell::setOverrideSizeFromRowHeight):
(WebCore::RenderTableCell::paintCollapsedBorder):
(WebCore::RenderTableCell::paintBackgroundsBehindCell):

  • rendering/RenderTableCell.h:
  • rendering/RenderView.h:

(WebCore::RenderView::pushLayoutState):
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::paddedLayoutOverflowRect):
(WebCore::setAscentAndDescent):

  • rendering/RootInlineBox.h:
Location:
trunk/Source/WebCore
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91416 r91417  
     12011-07-20  Levi Weintraub  <leviw@chromium.org>
     2
     3        Bring Int/Float graphics classes closer to parity
     4        https://bugs.webkit.org/show_bug.cgi?id=64833
     5
     6        Reviewed by James Robinson.
     7
     8        In preparation of switching to Floating point data structures, bringing the
     9        functionality and method names of the Int/Float graphics classes close together.
     10
     11        Also fixing some compiler errors when using Floats for layout units along the way.
     12
     13        No new tests, no functionality change.
     14
     15        * page/FrameView.cpp:
     16        (WebCore::FrameView::convertFromRenderer):
     17        * platform/ScrollView.cpp:
     18        (WebCore::ScrollView::wheelEvent):
     19        * platform/ScrollView.h:
     20        (WebCore::ScrollView::convertChildToSelf):
     21        (WebCore::ScrollView::convertSelfToChild):
     22        * platform/graphics/FloatPoint.h:
     23        (WebCore::operator-): Adding a single-parameter version.
     24        * platform/graphics/FloatSize.cpp:
     25        (WebCore::FloatSize::isZero): Adding isZero that uses epsilon for floats.
     26        * platform/graphics/FloatSize.h:
     27        * platform/graphics/IntPoint.h:
     28        (WebCore::IntPoint::moveBy): Renaming IntPoint version to moveBy to mirror FloatPoint.
     29        * platform/graphics/RoundedRect.cpp:
     30        (WebCore::RoundedRect::Radii::expand): Switching to specific templatized max.
     31        * platform/graphics/filters/FilterEffect.cpp:
     32        (WebCore::FilterEffect::requestedRegionOfInputImageData):
     33        * rendering/RenderBlock.cpp: Moving outstanding Int* functions to Layout units.
     34        (WebCore::RenderBlock::paintContinuationOutlines):
     35        (WebCore::RenderBlock::logicalRectToPhysicalRect):
     36        * rendering/RenderBlock.h:
     37        * rendering/RenderBox.cpp:
     38        (WebCore::RenderBox::positionForPoint):
     39        * rendering/RenderTable.cpp:
     40        (WebCore::RenderTable::subtractCaptionRect):
     41        * rendering/RenderTable.h:
     42        * rendering/RenderTableCell.cpp:
     43        (WebCore::RenderTableCell::styleOrColLogicalWidth):
     44        (WebCore::RenderTableCell::setOverrideSizeFromRowHeight):
     45        (WebCore::RenderTableCell::paintCollapsedBorder):
     46        (WebCore::RenderTableCell::paintBackgroundsBehindCell):
     47        * rendering/RenderTableCell.h:
     48        * rendering/RenderView.h:
     49        (WebCore::RenderView::pushLayoutState):
     50        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
     51        (WebCore::LayoutStateMaintainer::push):
     52        * rendering/RootInlineBox.cpp:
     53        (WebCore::RootInlineBox::paddedLayoutOverflowRect):
     54        (WebCore::setAscentAndDescent):
     55        * rendering/RootInlineBox.h:
     56
    1572011-07-20  Scott Graham  <scottmg@chromium.org>
    258
  • trunk/Source/WebCore/page/FrameView.cpp

    r91314 r91417  
    27042704
    27052705    // Convert from page ("absolute") to FrameView coordinates.
    2706     point.move(-scrollPosition());
     2706    point.moveBy(-scrollPosition());
    27072707    return point;
    27082708}
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r91146 r91417  
    11431143    // Scrollbars won't be transformed within us
    11441144    IntPoint newPoint = localPoint;
    1145     newPoint.move(scrollbar->location());
     1145    newPoint.moveBy(scrollbar->location());
    11461146    return newPoint;
    11471147}
     
    11511151    IntPoint newPoint = parentPoint;
    11521152    // Scrollbars won't be transformed within us
    1153     newPoint.move(-scrollbar->location());
     1153    newPoint.moveBy(-scrollbar->location());
    11541154    return newPoint;
    11551155}
  • trunk/Source/WebCore/platform/ScrollView.h

    r91064 r91417  
    244244        if (!isScrollViewScrollbar(child))
    245245            newPoint = point - scrollOffset();
    246         newPoint.move(child->location());
     246        newPoint.moveBy(child->location());
    247247        return newPoint;
    248248    }
     
    253253        if (!isScrollViewScrollbar(child))
    254254            newPoint = point + scrollOffset();
    255         newPoint.move(-child->location());
     255        newPoint.moveBy(-child->location());
    256256        return newPoint;
    257257    }
  • trunk/Source/WebCore/platform/graphics/FloatPoint.h

    r90517 r91417  
    213213}
    214214
     215inline FloatPoint operator-(const FloatPoint& a)
     216{
     217    return FloatPoint(-a.x(), -a.y());
     218}
     219
    215220inline bool operator==(const FloatPoint& a, const FloatPoint& b)
    216221{
  • trunk/Source/WebCore/platform/graphics/FloatSize.cpp

    r66560 r91417  
    3030#include "FloatConversion.h"
    3131#include "IntSize.h"
     32#include <limits>
    3233#include <math.h>
     34
     35using namespace std;
    3336
    3437namespace WebCore {
     
    4346}
    4447
     48bool FloatSize::isZero() const
     49{
     50    return fabs(m_width) < numeric_limits<float>::epsilon() && fabs(m_height) < numeric_limits<float>::epsilon();
     51}
     52
    4553FloatSize FloatSize::narrowPrecision(double width, double height)
    4654{
  • trunk/Source/WebCore/platform/graphics/FloatSize.h

    r90167 r91417  
    6363
    6464    bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
     65    bool isZero() const;
    6566
    6667    float aspectRatio() const { return m_width / m_height; }
  • trunk/Source/WebCore/platform/graphics/IntPoint.h

    r90167 r91417  
    9292
    9393    void move(const IntSize& s) { move(s.width(), s.height()); }
    94     void move(const IntPoint& offset) { move(offset.x(), offset.y()); }
     94    void moveBy(const IntPoint& offset) { move(offset.x(), offset.y()); }
    9595    void move(int dx, int dy) { m_x += dx; m_y += dy; }
    9696    void scale(float sx, float sy)
  • trunk/Source/WebCore/platform/graphics/RoundedRect.cpp

    r90832 r91417  
    6262void RoundedRect::Radii::expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth)
    6363{
    64     m_topLeft.setWidth(max(0, m_topLeft.width() + leftWidth));
    65     m_topLeft.setHeight(max(0, m_topLeft.height() + topWidth));
     64    m_topLeft.setWidth(max<LayoutUnit>(0, m_topLeft.width() + leftWidth));
     65    m_topLeft.setHeight(max<LayoutUnit>(0, m_topLeft.height() + topWidth));
    6666
    67     m_topRight.setWidth(max(0, m_topRight.width() + rightWidth));
    68     m_topRight.setHeight(max(0, m_topRight.height() + topWidth));
     67    m_topRight.setWidth(max<LayoutUnit>(0, m_topRight.width() + rightWidth));
     68    m_topRight.setHeight(max<LayoutUnit>(0, m_topRight.height() + topWidth));
    6969
    70     m_bottomLeft.setWidth(max(0, m_bottomLeft.width() + leftWidth));
    71     m_bottomLeft.setHeight(max(0, m_bottomLeft.height() + bottomWidth));
     70    m_bottomLeft.setWidth(max<LayoutUnit>(0, m_bottomLeft.width() + leftWidth));
     71    m_bottomLeft.setHeight(max<LayoutUnit>(0, m_bottomLeft.height() + bottomWidth));
    7272
    73     m_bottomRight.setWidth(max(0, m_bottomRight.width() + rightWidth));
    74     m_bottomRight.setHeight(max(0, m_bottomRight.height() + bottomWidth));
     73    m_bottomRight.setWidth(max<LayoutUnit>(0, m_bottomRight.width() + rightWidth));
     74    m_bottomRight.setHeight(max<LayoutUnit>(0, m_bottomRight.height() + bottomWidth));
    7575}
    7676
  • trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp

    r87303 r91417  
    7070    ASSERT(hasResult());
    7171    IntPoint location = m_absolutePaintRect.location();
    72     location.move(-effectRect.location());
     72    location.moveBy(-effectRect.location());
    7373    return IntRect(location, m_absolutePaintRect.size());
    7474}
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r90869 r91417  
    27022702        RenderBlock* block = flow->containingBlock();
    27032703        for ( ; block && block != this; block = block->containingBlock())
    2704             accumulatedPaintOffset.move(block->location());
     2704            accumulatedPaintOffset.moveBy(block->location());
    27052705        ASSERT(block);   
    27062706        flow->paintOutline(info.context, accumulatedPaintOffset);
     
    28082808}
    28092809
    2810 IntRect RenderBlock::logicalRectToPhysicalRect(const IntPoint& rootBlockPhysicalPosition, const IntRect& logicalRect)
    2811 {
    2812     IntRect result;
     2810LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPhysicalPosition, const LayoutRect& logicalRect)
     2811{
     2812    LayoutRect result;
    28132813    if (isHorizontalWritingMode())
    28142814        result = logicalRect;
    28152815    else
    2816         result = IntRect(logicalRect.y(), logicalRect.x(), logicalRect.height(), logicalRect.width());
     2816        result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height(), logicalRect.width());
    28172817    flipForWritingMode(result);
    28182818    result.moveBy(rootBlockPhysicalPosition);
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r91057 r91417  
    142142                                        RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*);
    143143    void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);
    144     IntRect logicalRectToPhysicalRect(const IntPoint& physicalPosition, const IntRect& logicalRect);
     144    LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect);
    145145       
    146146    // Helper methods for computing line counts and heights for line counts.
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r91386 r91417  
    31213121    LayoutPoint adjustedPoint = point;
    31223122    if (isTableRow())
    3123         adjustedPoint.move(location());
     3123        adjustedPoint.moveBy(location());
    31243124
    31253125    for (RenderObject* renderObject = firstChild(); renderObject; renderObject = renderObject->nextSibling()) {
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r91090 r91417  
    532532}
    533533
    534 void RenderTable::subtractCaptionRect(IntRect& rect) const
     534void RenderTable::subtractCaptionRect(LayoutRect& rect) const
    535535{
    536536    if (!m_caption)
    537537        return;
    538538
    539     int captionLogicalHeight = m_caption->logicalHeight() + m_caption->marginBefore() + m_caption->marginAfter();
     539    LayoutUnit captionLogicalHeight = m_caption->logicalHeight() + m_caption->marginBefore() + m_caption->marginAfter();
    540540    bool captionIsBefore = (m_caption->style()->captionSide() != CAPBOTTOM) ^ style()->isFlippedBlocksWritingMode();
    541541    if (style()->isHorizontalWritingMode()) {
  • trunk/Source/WebCore/rendering/RenderTable.h

    r90955 r91417  
    217217    virtual void paint(PaintInfo&, const LayoutPoint&);
    218218    virtual void paintObject(PaintInfo&, const LayoutPoint&);
    219     virtual void paintBoxDecorations(PaintInfo&, const IntPoint&);
    220     virtual void paintMask(PaintInfo&, const IntPoint&);
     219    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
     220    virtual void paintMask(PaintInfo&, const LayoutPoint&);
    221221    virtual void layout();
    222222    virtual void computePreferredLogicalWidths();
     
    236236    virtual void addOverflowFromChildren();
    237237
    238     void subtractCaptionRect(IntRect&) const;
     238    void subtractCaptionRect(LayoutRect&) const;
    239239
    240240    void recalcCaption(RenderBlock*) const;
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r91090 r91417  
    116116        // See Bugzilla bug 8126 for details.
    117117        if (colWidthSum.isFixed() && colWidthSum.value() > 0)
    118             colWidthSum = Length(max(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
     118            colWidthSum = Length(max<LayoutUnit>(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
    119119        return colWidthSum;
    120120    }
     
    216216{
    217217    clearIntrinsicPadding();
    218     RenderBlock::setOverrideSize(LayoutSize(0, max(0, rowHeight - borderBefore() - paddingBefore() - borderAfter() - paddingAfter())));
     218    RenderBlock::setOverrideSize(LayoutSize(0, max<LayoutUnit>(0, rowHeight - borderBefore() - paddingBefore() - borderAfter() - paddingAfter())));
    219219}
    220220
     
    913913}
    914914
    915 void RenderTableCell::paintCollapsedBorder(GraphicsContext* graphicsContext, const IntRect& paintRect)
     915void RenderTableCell::paintCollapsedBorder(GraphicsContext* graphicsContext, const LayoutRect& paintRect)
    916916{
    917917    if (!table()->currentBorderStyle() || graphicsContext->paintingDisabled())
     
    979979    LayoutPoint adjustedPaintOffset = paintOffset;
    980980    if (backgroundObject != this)
    981         adjustedPaintOffset.move(location());
     981        adjustedPaintOffset.moveBy(location());
    982982
    983983    Color c = backgroundObject->style()->visitedDependentColor(CSSPropertyBackgroundColor);
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r90955 r91417  
    9797    virtual void paint(PaintInfo&, const LayoutPoint&);
    9898
    99     void paintBackgroundsBehindCell(PaintInfo&, const IntPoint&, RenderObject* backgroundObject);
     99    void paintBackgroundsBehindCell(PaintInfo&, const LayoutPoint&, RenderObject* backgroundObject);
    100100
    101101    int cellBaselinePosition() const;
     
    151151    virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
    152152
    153     void paintCollapsedBorder(GraphicsContext*, const IntRect&);
     153    void paintCollapsedBorder(GraphicsContext*, const LayoutRect&);
    154154
    155155    int m_row;
  • trunk/Source/WebCore/rendering/RenderView.h

    r90882 r91417  
    174174
    175175    // These functions may only be accessed by LayoutStateMaintainer.
    176     bool pushLayoutState(RenderBox* renderer, const IntSize& offset, int pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
     176    bool pushLayoutState(RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
    177177    {
    178178        // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
     
    267267public:
    268268    // ctor to push now
    269     LayoutStateMaintainer(RenderView* view, RenderBox* root, IntSize offset, bool disableState = false, int pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
     269    LayoutStateMaintainer(RenderView* view, RenderBox* root, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
    270270        : m_view(view)
    271271        , m_disabled(disableState)
     
    292292    }
    293293
    294     void push(RenderBox* root, IntSize offset, int pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
     294    void push(RenderBox* root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
    295295    {
    296296        ASSERT(!m_didStart);
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r90869 r91417  
    533533}
    534534
    535 IntRect RootInlineBox::paddedLayoutOverflowRect(int endPadding) const
    536 {
    537     IntRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom());
     535LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const
     536{
     537    LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom());
    538538    if (!endPadding)
    539539        return lineLayoutOverflow;
    540540   
     541    // FIXME: Audit whether to use pixel snapped values when not using integers for layout: https://bugs.webkit.org/show_bug.cgi?id=63656
    541542    if (isHorizontal()) {
    542543        if (isLeftToRightDirection())
    543             lineLayoutOverflow.shiftMaxXEdgeTo(max(lineLayoutOverflow.maxX(), pixelSnappedLogicalRight() + endPadding));
     544            lineLayoutOverflow.shiftMaxXEdgeTo(max<LayoutUnit>(lineLayoutOverflow.maxX(), pixelSnappedLogicalRight() + endPadding));
    544545        else
    545             lineLayoutOverflow.shiftXEdgeTo(min(lineLayoutOverflow.x(), pixelSnappedLogicalLeft() - endPadding));
     546            lineLayoutOverflow.shiftXEdgeTo(min<LayoutUnit>(lineLayoutOverflow.x(), pixelSnappedLogicalLeft() - endPadding));
    546547    } else {
    547548        if (isLeftToRightDirection())
    548             lineLayoutOverflow.shiftMaxYEdgeTo(max(lineLayoutOverflow.maxY(), pixelSnappedLogicalRight() + endPadding));
     549            lineLayoutOverflow.shiftMaxYEdgeTo(max<LayoutUnit>(lineLayoutOverflow.maxY(), pixelSnappedLogicalRight() + endPadding));
    549550        else
    550             lineLayoutOverflow.shiftYEdgeTo(min(lineLayoutOverflow.y(), pixelSnappedLogicalLeft() - endPadding));
     551            lineLayoutOverflow.shiftYEdgeTo(min<LayoutUnit>(lineLayoutOverflow.y(), pixelSnappedLogicalLeft() - endPadding));
    551552    }
    552553   
     
    554555}
    555556
    556 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int newDescent, bool& ascentDescentSet)
     557static void setAscentAndDescent(LayoutUnit& ascent, LayoutUnit& descent, LayoutUnit newAscent, LayoutUnit newDescent, bool& ascentDescentSet)
    557558{
    558559    if (!ascentDescentSet) {
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r90869 r91417  
    139139    bool hasAnnotationsAfter() const { return m_hasAnnotationsAfter; }
    140140
    141     IntRect paddedLayoutOverflowRect(int endPadding) const;
     141    LayoutRect paddedLayoutOverflowRect(LayoutUnit endPadding) const;
    142142
    143143    void ascentAndDescentForBox(InlineBox*, GlyphOverflowAndFallbackFontsMap&, LayoutUnit& ascent, LayoutUnit& descent, bool& affectsAscent, bool& affectsDescent) const;
Note: See TracChangeset for help on using the changeset viewer.