Changeset 90833 in webkit


Ignore:
Timestamp:
Jul 12, 2011 11:42:18 AM (13 years ago)
Author:
eae@chromium.org
Message:

Switch preferred width/height and columns to to new layout types
https://bugs.webkit.org/show_bug.cgi?id=64329

Reviewed by Eric Seidel.

No new tests, no new functionality.

  • rendering/LayoutTypes.h:

(WebCore::ceiledLayoutUnit):
Add ceiledLayoutUnit to go with the floored version.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::adjustRectForColumns):
(WebCore::RenderBlock::flipForWritingModeIncludingColumns):
(WebCore::RenderBlock::adjustStartEdgeForWritingModeIncludingColumns):
Rename rect version of flipForWritingModeIncludingColumns to
adjustStartEdgeForWritingModeIncludingColumns as it adjust the start edge
and does not flip the rect.

(WebCore::RenderBlock::adjustForColumns):
(WebCore::updatePreferredWidth):

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

(WebCore::RenderBox::minPreferredLogicalWidth):
(WebCore::RenderBox::maxPreferredLogicalWidth):
(WebCore::RenderBox::offsetFromContainer):
(WebCore::RenderBox::computePercentageLogicalHeight):
(WebCore::RenderBox::flipForWritingMode):
(WebCore::RenderBox::flipForWritingModeIncludingColumns):

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

(WebCore::RenderListBox::itemBoundingBoxRect):

  • rendering/RenderListBox.h:
  • rendering/RenderObject.h:

(WebCore::RenderObject::minPreferredLogicalWidth):
(WebCore::RenderObject::maxPreferredLogicalWidth):
(WebCore::RenderObject::adjustForColumns):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalWidth):
(WebCore::RenderReplaced::computeReplacedLogicalHeight):

  • rendering/TableLayout.h:
Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90832 r90833  
     12011-07-12  Emil A Eklund  <eae@chromium.org>
     2
     3        Switch preferred width/height and columns to to new layout types
     4        https://bugs.webkit.org/show_bug.cgi?id=64329
     5
     6        Reviewed by Eric Seidel.
     7
     8        No new tests, no new functionality.
     9
     10        * rendering/LayoutTypes.h:
     11        (WebCore::ceiledLayoutUnit):
     12        Add ceiledLayoutUnit to go with the floored version.
     13       
     14        * rendering/RenderBlock.cpp:
     15        (WebCore::RenderBlock::adjustRectForColumns):
     16        (WebCore::RenderBlock::flipForWritingModeIncludingColumns):
     17        (WebCore::RenderBlock::adjustStartEdgeForWritingModeIncludingColumns):
     18        Rename rect version of flipForWritingModeIncludingColumns to
     19        adjustStartEdgeForWritingModeIncludingColumns as it adjust the start edge
     20        and does not flip the rect.
     21       
     22        (WebCore::RenderBlock::adjustForColumns):
     23        (WebCore::updatePreferredWidth):
     24        * rendering/RenderBlock.h:
     25        * rendering/RenderBox.cpp:
     26        (WebCore::RenderBox::minPreferredLogicalWidth):
     27        (WebCore::RenderBox::maxPreferredLogicalWidth):
     28        (WebCore::RenderBox::offsetFromContainer):
     29        (WebCore::RenderBox::computePercentageLogicalHeight):
     30        (WebCore::RenderBox::flipForWritingMode):
     31        (WebCore::RenderBox::flipForWritingModeIncludingColumns):
     32        * rendering/RenderBox.h:
     33        * rendering/RenderListBox.cpp:
     34        (WebCore::RenderListBox::itemBoundingBoxRect):
     35        * rendering/RenderListBox.h:
     36        * rendering/RenderObject.h:
     37        (WebCore::RenderObject::minPreferredLogicalWidth):
     38        (WebCore::RenderObject::maxPreferredLogicalWidth):
     39        (WebCore::RenderObject::adjustForColumns):
     40        * rendering/RenderReplaced.cpp:
     41        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
     42        (WebCore::RenderReplaced::computeReplacedLogicalHeight):
     43        * rendering/TableLayout.h:
     44
    1452011-07-12  Levi Weintraub  <leviw@chromium.org>
    246
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r90600 r90833  
    7272}
    7373
     74inline LayoutUnit ceiledLayoutUnit(float value)
     75{
     76    return ceilf(value);
     77}
     78
    7479inline LayoutSize toLayoutSize(const LayoutPoint& p)
    7580{
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r90800 r90833  
    44954495}
    44964496
    4497 void RenderBlock::adjustRectForColumns(IntRect& r) const
     4497void RenderBlock::adjustRectForColumns(LayoutRect& r) const
    44984498{
    44994499    // Just bail if we have no columns.
     
    45044504
    45054505    // Begin with a result rect that is empty.
    4506     IntRect result;
     4506    LayoutRect result;
    45074507   
    45084508    // Determine which columns we intersect.
     
    45114511        return;
    45124512   
    4513     int logicalLeft = logicalLeftOffsetForContent();
    4514     int currLogicalOffset = 0;
     4513    LayoutUnit logicalLeft = logicalLeftOffsetForContent();
     4514    LayoutUnit currLogicalOffset = 0;
    45154515
    45164516    for (unsigned i = 0; i < colCount; i++) {
    4517         IntRect colRect = columnRectAt(colInfo, i);
    4518         IntRect repaintRect = r;
     4517        LayoutRect colRect = columnRectAt(colInfo, i);
     4518        LayoutRect repaintRect = r;
    45194519        if (isHorizontalWritingMode()) {
    4520             int currXOffset = colRect.x() - logicalLeft;
     4520            LayoutUnit currXOffset = colRect.x() - logicalLeft;
    45214521            repaintRect.move(currXOffset, currLogicalOffset);
    45224522            currLogicalOffset -= colRect.height();
    45234523        } else {
    4524             int currYOffset = colRect.y() - logicalLeft;
     4524            LayoutUnit currYOffset = colRect.y() - logicalLeft;
    45254525            repaintRect.move(currLogicalOffset, currYOffset);
    45264526            currLogicalOffset -= colRect.width();
     
    45334533}
    45344534
    4535 IntPoint RenderBlock::flipForWritingModeIncludingColumns(const IntPoint& point) const
     4535LayoutPoint RenderBlock::flipForWritingModeIncludingColumns(const LayoutPoint& point) const
    45364536{
    45374537    ASSERT(hasColumns());
     
    45394539        return point;
    45404540    ColumnInfo* colInfo = columnInfo();
    4541     int columnLogicalHeight = colInfo->columnHeight();
    4542     int expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
     4541    LayoutUnit columnLogicalHeight = colInfo->columnHeight();
     4542    LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
    45434543    if (isHorizontalWritingMode())
    4544         return IntPoint(point.x(), expandedLogicalHeight - point.y());
    4545     return IntPoint(expandedLogicalHeight - point.x(), point.y());
    4546 }
    4547 
    4548 void RenderBlock::flipForWritingModeIncludingColumns(IntRect& rect) const
     4544        return LayoutPoint(point.x(), expandedLogicalHeight - point.y());
     4545    return LayoutPoint(expandedLogicalHeight - point.x(), point.y());
     4546}
     4547
     4548void RenderBlock::adjustStartEdgeForWritingModeIncludingColumns(LayoutRect& rect) const
    45494549{
    45504550    ASSERT(hasColumns());
     
    45534553   
    45544554    ColumnInfo* colInfo = columnInfo();
    4555     int columnLogicalHeight = colInfo->columnHeight();
    4556     int expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
     4555    LayoutUnit columnLogicalHeight = colInfo->columnHeight();
     4556    LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
     4557   
    45574558    if (isHorizontalWritingMode())
    45584559        rect.setY(expandedLogicalHeight - rect.maxY());
     
    45614562}
    45624563
    4563 void RenderBlock::adjustForColumns(IntSize& offset, const IntPoint& point) const
     4564void RenderBlock::adjustForColumns(LayoutSize& offset, const LayoutPoint& point) const
    45644565{
    45654566    if (!hasColumns())
     
    45684569    ColumnInfo* colInfo = columnInfo();
    45694570
    4570     int logicalLeft = logicalLeftOffsetForContent();
     4571    LayoutUnit logicalLeft = logicalLeftOffsetForContent();
    45714572    size_t colCount = columnCount(colInfo);
    4572     int colLogicalWidth = colInfo->desiredColumnWidth();
    4573     int colLogicalHeight = colInfo->columnHeight();
     4573    LayoutUnit colLogicalWidth = colInfo->desiredColumnWidth();
     4574    LayoutUnit colLogicalHeight = colInfo->columnHeight();
    45744575
    45754576    for (size_t i = 0; i < colCount; ++i) {
    45764577        // Compute the edges for a given column in the block progression direction.
    4577         IntRect sliceRect = IntRect(logicalLeft, borderBefore() + paddingBefore() + i * colLogicalHeight, colLogicalWidth, colLogicalHeight);
     4578        LayoutRect sliceRect = LayoutRect(logicalLeft, borderBefore() + paddingBefore() + i * colLogicalHeight, colLogicalWidth, colLogicalHeight);
    45784579        if (!isHorizontalWritingMode())
    45794580            sliceRect = sliceRect.transposedRect();
    45804581       
    45814582        // If we have a flipped blocks writing mode, then convert the column so that it's coming from the after edge (either top or left edge).
    4582         flipForWritingModeIncludingColumns(sliceRect);
     4583        adjustStartEdgeForWritingModeIncludingColumns(sliceRect);
    45834584       
    4584         int logicalOffset = style()->isFlippedBlocksWritingMode() ? (colCount - 1 - i) * colLogicalHeight : i * colLogicalHeight;
     4585        LayoutUnit logicalOffset = style()->isFlippedBlocksWritingMode() ? (colCount - 1 - i) * colLogicalHeight : i * colLogicalHeight;
    45854586
    45864587        // Now we're in the same coordinate space as the point.  See if it is inside the rectangle.
     
    47594760}
    47604761
    4761 static inline void updatePreferredWidth(int& preferredWidth, float& result)
    4762 {
    4763     int snappedResult = ceilf(result);
     4762static inline void updatePreferredWidth(LayoutUnit& preferredWidth, float& result)
     4763{
     4764    LayoutUnit snappedResult = ceiledLayoutUnit(result);
    47644765    preferredWidth = max(snappedResult, preferredWidth);
    47654766}
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r90698 r90833  
    128128    virtual LayoutUnit availableLogicalWidth() const;
    129129
    130     IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
    131     void flipForWritingModeIncludingColumns(IntRect&) const;
     130    LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
     131    void adjustStartEdgeForWritingModeIncludingColumns(LayoutRect&) const;
    132132
    133133    RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
     
    150150    void clearTruncation();
    151151
    152     void adjustRectForColumns(IntRect&) const;
    153     virtual void adjustForColumns(IntSize&, const IntPoint&) const;
     152    void adjustRectForColumns(LayoutRect&) const;
     153    virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const;
    154154
    155155    void addContinuationWithOutline(RenderInline*);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r90832 r90833  
    668668}
    669669
    670 int RenderBox::minPreferredLogicalWidth() const
     670LayoutUnit RenderBox::minPreferredLogicalWidth() const
    671671{
    672672    if (preferredLogicalWidthsDirty())
     
    676676}
    677677
    678 int RenderBox::maxPreferredLogicalWidth() const
     678LayoutUnit RenderBox::maxPreferredLogicalWidth() const
    679679{
    680680    if (preferredLogicalWidthsDirty())
     
    12991299            if (o->hasColumns()) {
    13001300                LayoutRect columnRect(frameRect());
    1301                 toRenderBlock(o)->flipForWritingModeIncludingColumns(columnRect);
     1301                toRenderBlock(o)->adjustStartEdgeForWritingModeIncludingColumns(columnRect);
    13021302                offset += LayoutSize(columnRect.location().x(), columnRect.location().y());
    13031303                columnRect.moveBy(point);
     
    19281928            // table cells using percentage heights.
    19291929            result -= borderAndPaddingLogicalHeight();
    1930             result = max(0, result);
     1930            result = max<LayoutUnit>(0, result);
    19311931        }
    19321932    }
     
    33943394}
    33953395
    3396 IntPoint RenderBox::flipForWritingMode(const RenderBox* child, const IntPoint& point, FlippingAdjustment adjustment) const
     3396LayoutPoint RenderBox::flipForWritingMode(const RenderBox* child, const LayoutPoint& point, FlippingAdjustment adjustment) const
    33973397{
    33983398    if (!style()->isFlippedBlocksWritingMode())
     
    34023402    // the right place.
    34033403    if (isHorizontalWritingMode())
    3404         return IntPoint(point.x(), point.y() + height() - child->height() - child->y() - (adjustment == ParentToChildFlippingAdjustment ? child->y() : 0));
    3405     return IntPoint(point.x() + width() - child->width() - child->x() - (adjustment == ParentToChildFlippingAdjustment ? child->x() : 0), point.y());
     3404        return LayoutPoint(point.x(), point.y() + height() - child->height() - child->y() - (adjustment == ParentToChildFlippingAdjustment ? child->y() : 0));
     3405    return LayoutPoint(point.x() + width() - child->width() - child->x() - (adjustment == ParentToChildFlippingAdjustment ? child->x() : 0), point.y());
    34063406}
    34073407
     
    34313431}
    34323432
    3433 IntPoint RenderBox::flipForWritingModeIncludingColumns(const IntPoint& point) const
     3433LayoutPoint RenderBox::flipForWritingModeIncludingColumns(const LayoutPoint& point) const
    34343434{
    34353435    if (!hasColumns() || !style()->isFlippedBlocksWritingMode())
  • trunk/Source/WebCore/rendering/RenderBox.h

    r90734 r90833  
    240240    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
    241241
    242     virtual int minPreferredLogicalWidth() const;
    243     virtual int maxPreferredLogicalWidth() const;
     242    virtual LayoutUnit minPreferredLogicalWidth() const;
     243    virtual LayoutUnit maxPreferredLogicalWidth() const;
    244244
    245245    LayoutSize overrideSize() const;
     
    389389
    390390    enum FlippingAdjustment { ChildToParentFlippingAdjustment, ParentToChildFlippingAdjustment };
    391     IntPoint flipForWritingMode(const RenderBox* child, const IntPoint&, FlippingAdjustment) const;
     391    LayoutPoint flipForWritingMode(const RenderBox* child, const LayoutPoint&, FlippingAdjustment) const;
    392392    int flipForWritingMode(int position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
    393393    IntPoint flipForWritingMode(const IntPoint&) const;
    394     IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
     394    LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
    395395    IntSize flipForWritingMode(const IntSize&) const;
    396396    void flipForWritingMode(IntRect&) const;
     
    475475
    476476    // The preferred logical width of the element if it were to break its lines at every possible opportunity.
    477     int m_minPreferredLogicalWidth;
     477    LayoutUnit m_minPreferredLogicalWidth;
    478478   
    479479    // The preferred logical width of the element if it never breaks any lines at all.
    480     int m_maxPreferredLogicalWidth;
     480    LayoutUnit m_maxPreferredLogicalWidth;
    481481
    482482    // For inline replaced elements, the inline box that owns us.
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r90667 r90833  
    255255}
    256256
    257 IntRect RenderListBox::itemBoundingBoxRect(const IntPoint& additionalOffset, int index)
     257IntRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffset, int index)
    258258{
    259259    return IntRect(additionalOffset.x() + borderLeft() + paddingLeft(),
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r90667 r90833  
    4747
    4848    int listIndexAtOffset(int x, int y);
    49     IntRect itemBoundingBoxRect(const IntPoint&, int index);
     49    IntRect itemBoundingBoxRect(const LayoutPoint&, int index);
    5050
    5151    bool scrollToRevealElementAtListIndex(int index);
  • trunk/Source/WebCore/rendering/RenderObject.h

    r90773 r90833  
    605605    LayoutRect paintingRootRect(LayoutRect& topLevelRect);
    606606
    607     virtual int minPreferredLogicalWidth() const { return 0; }
    608     virtual int maxPreferredLogicalWidth() const { return 0; }
     607    virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
     608    virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
    609609
    610610    RenderStyle* style() const { return m_style.get(); }
     
    670670    // If multiple-column layout results in applying an offset to the given point, add the same
    671671    // offset to the given size.
    672     virtual void adjustForColumns(IntSize&, const IntPoint&) const { }
     672    virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { }
    673673
    674674    virtual unsigned int length() const { return 1; }
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r90675 r90833  
    220220}
    221221
    222 int RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
     222LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
    223223{
    224224    if (style()->logicalWidth().isSpecified())
     
    305305}
    306306
    307 int RenderReplaced::computeReplacedLogicalHeight() const
     307LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
    308308{
    309309    // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
  • trunk/Source/WebCore/rendering/TableLayout.h

    r76248 r90833  
    3939    virtual ~TableLayout() { }
    4040
    41     virtual void computePreferredLogicalWidths(int& minWidth, int& maxWidth) = 0;
     41    virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
    4242    virtual void layout() = 0;
    4343
Note: See TracChangeset for help on using the changeset viewer.