Changeset 182702 in webkit


Ignore:
Timestamp:
Apr 13, 2015, 3:34:45 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r182235 - Lots of time spent querying table cell borders, when there are none.
https://bugs.webkit.org/show_bug.cgi?id=143277

Reviewed by Simon Fraser.

This patch speeds up collapsed border queries by using existing collapsed border
cache to calculate repaint rects and by introducing a fast path for zero width collapsed borders.

It reduces the number of calls to recompute collapsed borders from 36 000 to 1 600, while loading a page with a table of 400 rows (1 cell per row).
When scrolling the same page all the way down to the bottom, the number of calls to recompute collapsed borders falls from 290 000 to 0.

Covered by existing tests.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::styleDidChange): This moves invalidation time from RenderTable::layout() to styleDidChange().
(WebCore::RenderTable::invalidateCollapsedBorders):
(WebCore::RenderTable::recalcCollapsedBorders):

  • rendering/RenderTable.h:

(WebCore::RenderTable::collapsedBordersAreValid):
(WebCore::RenderTable::invalidateCollapsedBorders): Deleted.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::RenderTableCell):
(WebCore::RenderTableCell::willBeRemovedFromTree): Invalidate caches so that when repaint rect is calculated, we don't end up using stale values.
(WebCore::RenderTableCell::styleDidChange): Same as willBeRemovedFromTree.
(WebCore::RenderTableCell::collapsedStartBorder): Check if collapsed border is zero -also query cache.
(WebCore::RenderTableCell::collapsedEndBorder):
(WebCore::RenderTableCell::collapsedBeforeBorder):
(WebCore::RenderTableCell::collapsedAfterBorder):
(WebCore::RenderTableCell::cachedCollapsedLeftBorder):
(WebCore::RenderTableCell::cachedCollapsedRightBorder):
(WebCore::RenderTableCell::cachedCollapsedTopBorder):
(WebCore::RenderTableCell::cachedCollapsedBottomBorder):
(WebCore::RenderTableCell::paintCollapsedBorders):
(WebCore::RenderTableCell::cellAtLeft): Deleted.
(WebCore::RenderTableCell::cellAtRight): Deleted.
(WebCore::RenderTableCell::cellAtTop): Deleted.
(WebCore::RenderTableCell::cellAtBottom): Deleted.

  • rendering/RenderTableCell.h:

(WebCore::RenderTableCell::invalidateHasEmptyCollapsedBorders):

  • rendering/RenderTableCol.cpp:

(WebCore::RenderTableCol::styleDidChange):

  • rendering/RenderTableRow.cpp:

(WebCore::RenderTableRow::styleDidChange):
(WebCore::RenderTableRow::addChild):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::styleDidChange):
(WebCore::RenderTableSection::clearCachedCollapsedBorders): This is just an extra safety to invalidate collapsed border cache. This is always
called together with RenderTable::invalidateCollapsedBorders() -and that should prevent the RenderCells to use the cache.
(WebCore::RenderTableSection::removeCachedCollapsedBorders):
(WebCore::RenderTableSection::setCachedCollapsedBorder):
(WebCore::RenderTableSection::cachedCollapsedBorder):

  • rendering/RenderTableSection.h:
Location:
releases/WebKitGTK/webkit-2.8/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog

    r182701 r182702  
     12015-04-01  Zalan Bujtas  <zalan@apple.com>
     2
     3        Lots of time spent querying table cell borders, when there are none.
     4        https://bugs.webkit.org/show_bug.cgi?id=143277
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch speeds up collapsed border queries by using existing collapsed border
     9        cache to calculate repaint rects and by introducing a fast path for zero width collapsed borders.
     10
     11        It reduces the number of calls to recompute collapsed borders from 36 000 to 1 600, while loading a page with a table of 400 rows (1 cell per row).
     12        When scrolling the same page all the way down to the bottom, the number of calls to recompute collapsed borders falls from 290 000 to 0.
     13
     14        Covered by existing tests.
     15
     16        * rendering/RenderTable.cpp:
     17        (WebCore::RenderTable::styleDidChange): This moves invalidation time from RenderTable::layout() to styleDidChange().
     18        (WebCore::RenderTable::invalidateCollapsedBorders):
     19        (WebCore::RenderTable::recalcCollapsedBorders):
     20        * rendering/RenderTable.h:
     21        (WebCore::RenderTable::collapsedBordersAreValid):
     22        (WebCore::RenderTable::invalidateCollapsedBorders): Deleted.
     23        * rendering/RenderTableCell.cpp:
     24        (WebCore::RenderTableCell::RenderTableCell):
     25        (WebCore::RenderTableCell::willBeRemovedFromTree): Invalidate caches so that when repaint rect is calculated, we don't end up using stale values.
     26        (WebCore::RenderTableCell::styleDidChange): Same as willBeRemovedFromTree.
     27        (WebCore::RenderTableCell::collapsedStartBorder): Check if collapsed border is zero -also query cache.
     28        (WebCore::RenderTableCell::collapsedEndBorder):
     29        (WebCore::RenderTableCell::collapsedBeforeBorder):
     30        (WebCore::RenderTableCell::collapsedAfterBorder):
     31        (WebCore::RenderTableCell::cachedCollapsedLeftBorder):
     32        (WebCore::RenderTableCell::cachedCollapsedRightBorder):
     33        (WebCore::RenderTableCell::cachedCollapsedTopBorder):
     34        (WebCore::RenderTableCell::cachedCollapsedBottomBorder):
     35        (WebCore::RenderTableCell::paintCollapsedBorders):
     36        (WebCore::RenderTableCell::cellAtLeft): Deleted.
     37        (WebCore::RenderTableCell::cellAtRight): Deleted.
     38        (WebCore::RenderTableCell::cellAtTop): Deleted.
     39        (WebCore::RenderTableCell::cellAtBottom): Deleted.
     40        * rendering/RenderTableCell.h:
     41        (WebCore::RenderTableCell::invalidateHasEmptyCollapsedBorders):
     42        * rendering/RenderTableCol.cpp:
     43        (WebCore::RenderTableCol::styleDidChange):
     44        * rendering/RenderTableRow.cpp:
     45        (WebCore::RenderTableRow::styleDidChange):
     46        (WebCore::RenderTableRow::addChild):
     47        * rendering/RenderTableSection.cpp:
     48        (WebCore::RenderTableSection::styleDidChange):
     49        (WebCore::RenderTableSection::clearCachedCollapsedBorders): This is just an extra safety to invalidate collapsed border cache. This is always
     50        called together with RenderTable::invalidateCollapsedBorders() -and that should prevent the RenderCells to use the cache. 
     51        (WebCore::RenderTableSection::removeCachedCollapsedBorders):
     52        (WebCore::RenderTableSection::setCachedCollapsedBorder):
     53        (WebCore::RenderTableSection::cachedCollapsedBorder):
     54        * rendering/RenderTableSection.h:
     55
    1562015-02-17  Zalan Bujtas  <zalan@apple.com>
    257
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTable.cpp

    r182696 r182702  
    5858    , m_currentBorder(nullptr)
    5959    , m_collapsedBordersValid(false)
     60    , m_collapsedEmptyBorderIsPresent(false)
    6061    , m_hasColElements(false)
    6162    , m_needsSectionRecalc(false)
     
    8182    , m_currentBorder(nullptr)
    8283    , m_collapsedBordersValid(false)
     84    , m_collapsedEmptyBorderIsPresent(false)
    8385    , m_hasColElements(false)
    8486    , m_needsSectionRecalc(false)
     
    121123
    122124    // If border was changed, invalidate collapsed borders cache.
    123     if (!needsLayout() && oldStyle && oldStyle->border() != style().border())
     125    if (oldStyle && oldStyle->border() != style().border())
    124126        invalidateCollapsedBorders();
    125127}
     
    587589}
    588590
     591void RenderTable::invalidateCollapsedBorders()
     592{
     593    m_collapsedBordersValid = false;
     594    m_collapsedBorders.clear();
     595    for (auto& section : childrenOfType<RenderTableSection>(*this)) {
     596        section.clearCachedCollapsedBorders();
     597        if (!m_collapsedEmptyBorderIsPresent)
     598            continue;
     599        for (auto* row = section.firstRow(); row; row = row->nextRow()) {
     600            for (auto* cell = row->firstCell(); cell; cell = cell->nextCell()) {
     601                ASSERT(cell->table() == this);
     602                cell->invalidateHasEmptyCollapsedBorders();
     603            }
     604        }
     605    }
     606    m_collapsedEmptyBorderIsPresent = false;
     607}
     608
    589609// Collect all the unique border values that we want to paint in a sorted list.
    590610void RenderTable::recalcCollapsedBorders()
     
    592612    if (m_collapsedBordersValid)
    593613        return;
    594     m_collapsedBordersValid = true;
    595614    m_collapsedBorders.clear();
    596 
    597615    for (auto& section : childrenOfType<RenderTableSection>(*this)) {
    598616        for (RenderTableRow* row = section.firstRow(); row; row = row->nextRow()) {
     
    604622    }
    605623    RenderTableCell::sortBorderValues(m_collapsedBorders);
    606 }
    607 
     624    m_collapsedBordersValid = true;
     625}
    608626
    609627void RenderTable::addOverflowFromChildren()
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTable.h

    r179627 r182702  
    243243 
    244244    typedef Vector<CollapsedBorderValue> CollapsedBorderValues;
    245     void invalidateCollapsedBorders()
    246     {
    247         m_collapsedBordersValid = false;
    248         m_collapsedBorders.clear();
    249     }
     245    bool collapsedBordersAreValid() const { return m_collapsedBordersValid; }
     246    void invalidateCollapsedBorders();
     247    void collapsedEmptyBorderIsPresent() { m_collapsedEmptyBorderIsPresent = true; }
    250248    const CollapsedBorderValue* currentBorderValue() const { return m_currentBorder; }
    251249   
     
    349347    const CollapsedBorderValue* m_currentBorder;
    350348    bool m_collapsedBordersValid : 1;
     349    bool m_collapsedEmptyBorderIsPresent : 1;
    351350
    352351    mutable bool m_hasColElements : 1;
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableCell.cpp

    r182701 r182702  
    6161    , m_hasColSpan(false)
    6262    , m_hasRowSpan(false)
     63    , m_hasEmptyCollapsedBeforeBorder(false)
     64    , m_hasEmptyCollapsedAfterBorder(false)
     65    , m_hasEmptyCollapsedStartBorder(false)
     66    , m_hasEmptyCollapsedEndBorder(false)
    6367{
    6468    // We only update the flags when notified of DOM changes in colSpanOrRowSpanChanged()
     
    7377    , m_hasColSpan(false)
    7478    , m_hasRowSpan(false)
     79    , m_hasEmptyCollapsedBeforeBorder(false)
     80    , m_hasEmptyCollapsedAfterBorder(false)
     81    , m_hasEmptyCollapsedStartBorder(false)
     82    , m_hasEmptyCollapsedEndBorder(false)
    7583{
    7684}
     
    7987{
    8088    RenderBlockFlow::willBeRemovedFromTree();
    81 
    82     section()->setNeedsCellRecalc();
    83     section()->removeCachedCollapsedBorders(this);
     89    if (!table() || !section())
     90        return;
     91    RenderTableSection* section = this->section();
     92    table()->invalidateCollapsedBorders();
     93    section->setNeedsCellRecalc();
    8494}
    8595
     
    266276        layoutBlock(cellWidthChanged());
    267277    }
    268 
     278    invalidateHasEmptyCollapsedBorders();
    269279    setCellWidthChanged(false);
    270280}
     
    417427
    418428    // If border was changed, notify table.
    419     if (parent()) {
    420         RenderTable* table = this->table();
    421         if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout()&& oldStyle && oldStyle->border() != style().border())
    422             table->invalidateCollapsedBorders();
    423     }
     429    RenderTable* table = this->table();
     430    if (table && oldStyle && oldStyle->border() != style().border())
     431        table->invalidateCollapsedBorders();
    424432}
    425433
     
    508516}
    509517
     518static CollapsedBorderValue emptyBorder()
     519{
     520    return CollapsedBorderValue(BorderValue(), Color(), BCELL);
     521}
     522
    510523CollapsedBorderValue RenderTableCell::collapsedStartBorder(IncludeBorderColorOrNot includeColor) const
    511524{
     525    if (!table() || !section())
     526        return emptyBorder();
     527
     528    if (m_hasEmptyCollapsedStartBorder)
     529        return emptyBorder();
     530
     531    if (table()->collapsedBordersAreValid())
     532        return section()->cachedCollapsedBorder(*this, CBSStart);
     533
    512534    CollapsedBorderValue result = computeCollapsedStartBorder(includeColor);
    513     if (includeColor)
    514         section()->setCachedCollapsedBorder(this, CBSStart, result);
     535    setHasEmptyCollapsedBorder(CBSStart, !result.width());
     536    if (includeColor && !m_hasEmptyCollapsedStartBorder)
     537        section()->setCachedCollapsedBorder(*this, CBSStart, result);
    515538    return result;
    516539}
     
    610633CollapsedBorderValue RenderTableCell::collapsedEndBorder(IncludeBorderColorOrNot includeColor) const
    611634{
     635    if (!table() || !section())
     636        return emptyBorder();
     637
     638    if (m_hasEmptyCollapsedEndBorder)
     639        return emptyBorder();
     640
     641    if (table()->collapsedBordersAreValid())
     642        return section()->cachedCollapsedBorder(*this, CBSEnd);
     643
    612644    CollapsedBorderValue result = computeCollapsedEndBorder(includeColor);
    613     if (includeColor)
    614         section()->setCachedCollapsedBorder(this, CBSEnd, result);
     645    setHasEmptyCollapsedBorder(CBSEnd, !result.width());
     646    if (includeColor && !m_hasEmptyCollapsedEndBorder)
     647        section()->setCachedCollapsedBorder(*this, CBSEnd, result);
    615648    return result;
    616649}
     
    712745CollapsedBorderValue RenderTableCell::collapsedBeforeBorder(IncludeBorderColorOrNot includeColor) const
    713746{
     747    if (!table() || !section())
     748        return emptyBorder();
     749
     750    if (m_hasEmptyCollapsedBeforeBorder)
     751        return emptyBorder();
     752
     753    if (table()->collapsedBordersAreValid())
     754        return section()->cachedCollapsedBorder(*this, CBSBefore);
     755
    714756    CollapsedBorderValue result = computeCollapsedBeforeBorder(includeColor);
    715     if (includeColor)
    716         section()->setCachedCollapsedBorder(this, CBSBefore, result);
     757    setHasEmptyCollapsedBorder(CBSBefore, !result.width());
     758    if (includeColor && !m_hasEmptyCollapsedBeforeBorder)
     759        section()->setCachedCollapsedBorder(*this, CBSBefore, result);
    717760    return result;
    718761}
     
    798841CollapsedBorderValue RenderTableCell::collapsedAfterBorder(IncludeBorderColorOrNot includeColor) const
    799842{
     843    if (!table() || !section())
     844        return emptyBorder();
     845
     846    if (m_hasEmptyCollapsedAfterBorder)
     847        return emptyBorder();
     848
     849    if (table()->collapsedBordersAreValid())
     850        return section()->cachedCollapsedBorder(*this, CBSAfter);
     851
    800852    CollapsedBorderValue result = computeCollapsedAfterBorder(includeColor);
    801     if (includeColor)
    802         section()->setCachedCollapsedBorder(this, CBSAfter, result);
     853    setHasEmptyCollapsedBorder(CBSAfter, !result.width());
     854    if (includeColor && !m_hasEmptyCollapsedAfterBorder)
     855        section()->setCachedCollapsedBorder(*this, CBSAfter, result);
    803856    return result;
    804857}
     
    873926}
    874927
    875 inline CollapsedBorderValue RenderTableCell::cachedCollapsedLeftBorder(const RenderStyle* styleForCellFlow) const
    876 {
    877     if (styleForCellFlow->isHorizontalWritingMode())
    878         return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollapsedBorder(this, CBSStart) : section()->cachedCollapsedBorder(this, CBSEnd);
    879     return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(this, CBSAfter) : section()->cachedCollapsedBorder(this, CBSBefore);
    880 }
    881 
    882 inline CollapsedBorderValue RenderTableCell::cachedCollapsedRightBorder(const RenderStyle* styleForCellFlow) const
    883 {
    884     if (styleForCellFlow->isHorizontalWritingMode())
    885         return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollapsedBorder(this, CBSEnd) : section()->cachedCollapsedBorder(this, CBSStart);
    886     return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(this, CBSBefore) : section()->cachedCollapsedBorder(this, CBSAfter);
    887 }
    888 
    889 inline CollapsedBorderValue RenderTableCell::cachedCollapsedTopBorder(const RenderStyle* styleForCellFlow) const
    890 {
    891     if (styleForCellFlow->isHorizontalWritingMode())
    892         return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(this, CBSAfter) : section()->cachedCollapsedBorder(this, CBSBefore);
    893     return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollapsedBorder(this, CBSStart) : section()->cachedCollapsedBorder(this, CBSEnd);
    894 }
    895 
    896 inline CollapsedBorderValue RenderTableCell::cachedCollapsedBottomBorder(const RenderStyle* styleForCellFlow) const
    897 {
    898     if (styleForCellFlow->isHorizontalWritingMode())
    899         return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(this, CBSBefore) : section()->cachedCollapsedBorder(this, CBSAfter);
    900     return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollapsedBorder(this, CBSEnd) : section()->cachedCollapsedBorder(this, CBSStart);
    901 }
    902 
    903 inline RenderTableCell* RenderTableCell::cellAtLeft(const RenderStyle* styleForCellFlow) const
    904 {
    905     if (styleForCellFlow->isHorizontalWritingMode())
    906         return styleForCellFlow->isLeftToRightDirection() ? table()->cellBefore(this) : table()->cellAfter(this);
    907     return styleForCellFlow->isFlippedBlocksWritingMode() ? table()->cellBelow(this) : table()->cellAbove(this);
    908 }
    909 
    910 inline RenderTableCell* RenderTableCell::cellAtRight(const RenderStyle* styleForCellFlow) const
    911 {
    912     if (styleForCellFlow->isHorizontalWritingMode())
    913         return styleForCellFlow->isLeftToRightDirection() ? table()->cellAfter(this) : table()->cellBefore(this);
    914     return styleForCellFlow->isFlippedBlocksWritingMode() ? table()->cellAbove(this) : table()->cellBelow(this);
    915 }
    916 
    917 inline RenderTableCell* RenderTableCell::cellAtTop(const RenderStyle* styleForCellFlow) const
    918 {
    919     if (styleForCellFlow->isHorizontalWritingMode())
    920         return styleForCellFlow->isFlippedBlocksWritingMode() ? table()->cellBelow(this) : table()->cellAbove(this);
    921     return styleForCellFlow->isLeftToRightDirection() ? table()->cellBefore(this) : table()->cellAfter(this);
    922 }
    923 
    924 inline RenderTableCell* RenderTableCell::cellAtBottom(const RenderStyle* styleForCellFlow) const
    925 {
    926     if (styleForCellFlow->isHorizontalWritingMode())
    927         return styleForCellFlow->isFlippedBlocksWritingMode() ? table()->cellAbove(this) : table()->cellBelow(this);
    928     return styleForCellFlow->isLeftToRightDirection() ? table()->cellAfter(this) : table()->cellBefore(this);
     928inline CollapsedBorderValue RenderTableCell::cachedCollapsedLeftBorder(const RenderStyle& styleForCellFlow) const
     929{
     930    if (styleForCellFlow.isHorizontalWritingMode())
     931        return styleForCellFlow.isLeftToRightDirection() ? section()->cachedCollapsedBorder(*this, CBSStart) : section()->cachedCollapsedBorder(*this, CBSEnd);
     932    return styleForCellFlow.isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(*this, CBSAfter) : section()->cachedCollapsedBorder(*this, CBSBefore);
     933}
     934
     935inline CollapsedBorderValue RenderTableCell::cachedCollapsedRightBorder(const RenderStyle& styleForCellFlow) const
     936{
     937    if (styleForCellFlow.isHorizontalWritingMode())
     938        return styleForCellFlow.isLeftToRightDirection() ? section()->cachedCollapsedBorder(*this, CBSEnd) : section()->cachedCollapsedBorder(*this, CBSStart);
     939    return styleForCellFlow.isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(*this, CBSBefore) : section()->cachedCollapsedBorder(*this, CBSAfter);
     940}
     941
     942inline CollapsedBorderValue RenderTableCell::cachedCollapsedTopBorder(const RenderStyle& styleForCellFlow) const
     943{
     944    if (styleForCellFlow.isHorizontalWritingMode())
     945        return styleForCellFlow.isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(*this, CBSAfter) : section()->cachedCollapsedBorder(*this, CBSBefore);
     946    return styleForCellFlow.isLeftToRightDirection() ? section()->cachedCollapsedBorder(*this, CBSStart) : section()->cachedCollapsedBorder(*this, CBSEnd);
     947}
     948
     949inline CollapsedBorderValue RenderTableCell::cachedCollapsedBottomBorder(const RenderStyle& styleForCellFlow) const
     950{
     951    if (styleForCellFlow.isHorizontalWritingMode())
     952        return styleForCellFlow.isFlippedBlocksWritingMode() ? section()->cachedCollapsedBorder(*this, CBSBefore) : section()->cachedCollapsedBorder(*this, CBSAfter);
     953    return styleForCellFlow.isLeftToRightDirection() ? section()->cachedCollapsedBorder(*this, CBSEnd) : section()->cachedCollapsedBorder(*this, CBSStart);
    929954}
    930955
     
    11811206
    11821207    const RenderStyle& styleForCellFlow = this->styleForCellFlow();
    1183     CollapsedBorderValue leftVal = cachedCollapsedLeftBorder(&styleForCellFlow);
    1184     CollapsedBorderValue rightVal = cachedCollapsedRightBorder(&styleForCellFlow);
    1185     CollapsedBorderValue topVal = cachedCollapsedTopBorder(&styleForCellFlow);
    1186     CollapsedBorderValue bottomVal = cachedCollapsedBottomBorder(&styleForCellFlow);
     1208    CollapsedBorderValue leftVal = cachedCollapsedLeftBorder(styleForCellFlow);
     1209    CollapsedBorderValue rightVal = cachedCollapsedRightBorder(styleForCellFlow);
     1210    CollapsedBorderValue topVal = cachedCollapsedTopBorder(styleForCellFlow);
     1211    CollapsedBorderValue bottomVal = cachedCollapsedBottomBorder(styleForCellFlow);
    11871212     
    11881213    // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location.
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableCell.h

    r182701 r182702  
    3232namespace WebCore {
    3333
    34 static const unsigned unsetColumnIndex = 0x1FFFFFFF;
    35 static const unsigned maxColumnIndex = 0x1FFFFFFE; // 536,870,910
     34// These is limited by the size of RenderTableCell::m_column bitfield.
     35static const unsigned unsetColumnIndex = 0x1FFFFFF;
     36static const unsigned maxColumnIndex = 0x1FFFFFE; // 33554430
    3637
    3738enum IncludeBorderColorOrNot { DoNotIncludeBorderColor, IncludeBorderColor };
     
    131132    virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override;
    132133
     134    void invalidateHasEmptyCollapsedBorders();
     135    void setHasEmptyCollapsedBorder(CollapsedBorderSide, bool empty) const;
     136
    133137protected:
    134138    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
     
    174178    CollapsedBorderValue collapsedAfterBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
    175179
    176     CollapsedBorderValue cachedCollapsedLeftBorder(const RenderStyle*) const;
    177     CollapsedBorderValue cachedCollapsedRightBorder(const RenderStyle*) const;
    178     CollapsedBorderValue cachedCollapsedTopBorder(const RenderStyle*) const;
    179     CollapsedBorderValue cachedCollapsedBottomBorder(const RenderStyle*) const;
     180    CollapsedBorderValue cachedCollapsedLeftBorder(const RenderStyle&) const;
     181    CollapsedBorderValue cachedCollapsedRightBorder(const RenderStyle&) const;
     182    CollapsedBorderValue cachedCollapsedTopBorder(const RenderStyle&) const;
     183    CollapsedBorderValue cachedCollapsedBottomBorder(const RenderStyle&) const;
    180184
    181185    CollapsedBorderValue computeCollapsedStartBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
     
    184188    CollapsedBorderValue computeCollapsedAfterBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
    185189
    186     RenderTableCell* cellAtLeft(const RenderStyle*) const;
    187     RenderTableCell* cellAtRight(const RenderStyle*) const;
    188     RenderTableCell* cellAtTop(const RenderStyle*) const;
    189     RenderTableCell* cellAtBottom(const RenderStyle*) const;
    190 
    191190    Length logicalWidthFromColumns(RenderTableCol* firstColForThisCell, Length widthFromStyle) const;
    192191
     
    200199
    201200    // Note MSVC will only pack members if they have identical types, hence we use unsigned instead of bool here.
    202     unsigned m_column : 29;
     201    unsigned m_column : 25;
    203202    unsigned m_cellWidthChanged : 1;
    204203    unsigned m_hasColSpan: 1;
    205204    unsigned m_hasRowSpan: 1;
     205    mutable unsigned m_hasEmptyCollapsedBeforeBorder: 1;
     206    mutable unsigned m_hasEmptyCollapsedAfterBorder: 1;
     207    mutable unsigned m_hasEmptyCollapsedStartBorder: 1;
     208    mutable unsigned m_hasEmptyCollapsedEndBorder: 1;
    206209    int m_intrinsicPaddingBefore { 0 };
    207210    int m_intrinsicPaddingAfter { 0 };
     
    338341}
    339342
     343inline void RenderTableCell::setHasEmptyCollapsedBorder(CollapsedBorderSide side, bool empty) const
     344{
     345    switch (side) {
     346    case CBSAfter: {
     347        m_hasEmptyCollapsedAfterBorder = empty;
     348        break;
     349    }
     350    case CBSBefore: {
     351        m_hasEmptyCollapsedBeforeBorder = empty;
     352        break;
     353    }
     354    case CBSStart: {
     355        m_hasEmptyCollapsedStartBorder = empty;
     356        break;
     357    }
     358    case CBSEnd: {
     359        m_hasEmptyCollapsedEndBorder = empty;
     360        break;
     361    }
     362    }
     363    if (empty)
     364        table()->collapsedEmptyBorderIsPresent();
     365}
     366
     367inline void RenderTableCell::invalidateHasEmptyCollapsedBorders()
     368{
     369    m_hasEmptyCollapsedBeforeBorder = false;
     370    m_hasEmptyCollapsedAfterBorder = false;
     371    m_hasEmptyCollapsedStartBorder = false;
     372    m_hasEmptyCollapsedEndBorder = false;
     373}
     374
    340375} // namespace WebCore
    341376
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableCol.cpp

    r182701 r182702  
    4949{
    5050    RenderBox::styleDidChange(diff, oldStyle);
    51 
     51    RenderTable* table = this->table();
     52    if (!table)
     53        return;
    5254    // If border was changed, notify table.
    53     if (parent()) {
    54         RenderTable* table = this->table();
    55         if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style().border())
    56             table->invalidateCollapsedBorders();
    57         else if (oldStyle->width() != style().width()) {
    58             table->recalcSectionsIfNeeded();
    59             for (auto& section : childrenOfType<RenderTableSection>(*table)) {
    60                 unsigned nEffCols = table->numEffCols();
    61                 for (unsigned j = 0; j < nEffCols; j++) {
    62                     unsigned rowCount = section.numRows();
    63                     for (unsigned i = 0; i < rowCount; i++) {
    64                         RenderTableCell* cell = section.primaryCellAt(i, j);
    65                         if (!cell)
    66                             continue;
    67                         cell->setPreferredLogicalWidthsDirty(true);
    68                     }
     55    if (oldStyle && oldStyle->border() != style().border())
     56        table->invalidateCollapsedBorders();
     57    else if (oldStyle->width() != style().width()) {
     58        table->recalcSectionsIfNeeded();
     59        for (auto& section : childrenOfType<RenderTableSection>(*table)) {
     60            unsigned nEffCols = table->numEffCols();
     61            for (unsigned j = 0; j < nEffCols; j++) {
     62                unsigned rowCount = section.numRows();
     63                for (unsigned i = 0; i < rowCount; i++) {
     64                    RenderTableCell* cell = section.primaryCellAt(i, j);
     65                    if (!cell)
     66                        continue;
     67                    cell->setPreferredLogicalWidthsDirty(true);
    6968                }
    7069            }
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableRow.cpp

    r180190 r182702  
    8080    // If border was changed, notify table.
    8181    if (RenderTable* table = this->table()) {
    82         if (!table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style().border())
     82        if (oldStyle && oldStyle->border() != style().border())
    8383            table->invalidateCollapsedBorders();
    84        
     84
    8585        if (oldStyle && diff == StyleDifferenceLayout && needsLayout() && table->collapseBorders() && borderWidthChanged(oldStyle, &style())) {
    8686            // If the border width changes on a row, we need to make sure the cells in the row know to lay out again.
     
    155155    if (beforeChild || nextRow())
    156156        section()->setNeedsCellRecalc();
     157    if (RenderTable* table = this->table())
     158        table->invalidateCollapsedBorders();
    157159}
    158160
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableSection.cpp

    r182701 r182702  
    106106    // If border was changed, notify table.
    107107    RenderTable* table = this->table();
    108     if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style().border())
     108    if (table && oldStyle && oldStyle->border() != style().border())
    109109        table->invalidateCollapsedBorders();
    110110}
     
    15471547}
    15481548
    1549 void RenderTableSection::removeCachedCollapsedBorders(const RenderTableCell* cell)
     1549void RenderTableSection::clearCachedCollapsedBorders()
     1550{
     1551    if (!table()->collapseBorders())
     1552        return;
     1553    m_cellsCollapsedBorders.clear();
     1554}
     1555
     1556void RenderTableSection::removeCachedCollapsedBorders(const RenderTableCell& cell)
    15501557{
    15511558    if (!table()->collapseBorders())
     
    15531560   
    15541561    for (int side = CBSBefore; side <= CBSEnd; ++side)
    1555         m_cellsCollapsedBorders.remove(std::make_pair(cell, side));
    1556 }
    1557 
    1558 void RenderTableSection::setCachedCollapsedBorder(const RenderTableCell* cell, CollapsedBorderSide side, CollapsedBorderValue border)
     1562        m_cellsCollapsedBorders.remove(std::make_pair(&cell, side));
     1563}
     1564
     1565void RenderTableSection::setCachedCollapsedBorder(const RenderTableCell& cell, CollapsedBorderSide side, CollapsedBorderValue border)
    15591566{
    15601567    ASSERT(table()->collapseBorders());
    1561     m_cellsCollapsedBorders.set(std::make_pair(cell, side), border);
    1562 }
    1563 
    1564 CollapsedBorderValue& RenderTableSection::cachedCollapsedBorder(const RenderTableCell* cell, CollapsedBorderSide side)
    1565 {
    1566     ASSERT(table()->collapseBorders());
    1567     HashMap<std::pair<const RenderTableCell*, int>, CollapsedBorderValue>::iterator it = m_cellsCollapsedBorders.find(std::make_pair(cell, side));
    1568     ASSERT(it != m_cellsCollapsedBorders.end());
     1568    ASSERT(border.width());
     1569    m_cellsCollapsedBorders.set(std::make_pair(&cell, side), border);
     1570}
     1571
     1572CollapsedBorderValue RenderTableSection::cachedCollapsedBorder(const RenderTableCell& cell, CollapsedBorderSide side)
     1573{
     1574    ASSERT(table()->collapseBorders() && table()->collapsedBordersAreValid());
     1575    auto it = m_cellsCollapsedBorders.find(std::make_pair(&cell, side));
     1576    // Only non-empty collapsed borders are in the hashmap.
     1577    if (it == m_cellsCollapsedBorders.end())
     1578        return CollapsedBorderValue(BorderValue(), Color(), BCELL);
    15691579    return it->value;
    15701580}
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderTableSection.h

    r182701 r182702  
    135135    void rowLogicalHeightChanged(unsigned rowIndex);
    136136
    137     void removeCachedCollapsedBorders(const RenderTableCell*);
    138     void setCachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide, CollapsedBorderValue);
    139     CollapsedBorderValue& cachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide);
     137    void clearCachedCollapsedBorders();
     138    void removeCachedCollapsedBorders(const RenderTableCell&);
     139    void setCachedCollapsedBorder(const RenderTableCell&, CollapsedBorderSide, CollapsedBorderValue);
     140    CollapsedBorderValue cachedCollapsedBorder(const RenderTableCell&, CollapsedBorderSide);
    140141
    141142    // distributeExtraLogicalHeightToRows methods return the *consumed* extra logical height.
Note: See TracChangeset for help on using the changeset viewer.