Changeset 70330 in webkit


Ignore:
Timestamp:
Oct 22, 2010 1:29:21 PM (14 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=48149

Reviewed by Sam Weinig.

Update block direction line overflow computation to be writing-mode-aware.

  • rendering/InlineBox.h:

(WebCore::InlineBox::logicalBottom):

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::computeBlockDirectionOverflow):

  • rendering/InlineFlowBox.h:

(WebCore::InlineFlowBox::setInlineDirectionOverflowPositions):
(WebCore::InlineFlowBox::setBlockDirectionOverflowPositions):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::layoutInlineChildren):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::blockDirectionOverflow):

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

(WebCore::RootInlineBox::addHighlightOverflow):

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::getTextShadowBlockDirectionExtent):
(WebCore::InheritedFlags::getBoxShadowBlockDirectionExtent):
(WebCore::InheritedFlags::getShadowBlockDirectionExtent):

Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70327 r70330  
     12010-10-22  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48149
     6       
     7        Update block direction line overflow computation to be writing-mode-aware.
     8
     9        * rendering/InlineBox.h:
     10        (WebCore::InlineBox::logicalBottom):
     11        * rendering/InlineFlowBox.cpp:
     12        (WebCore::InlineFlowBox::computeBlockDirectionOverflow):
     13        * rendering/InlineFlowBox.h:
     14        (WebCore::InlineFlowBox::setInlineDirectionOverflowPositions):
     15        (WebCore::InlineFlowBox::setBlockDirectionOverflowPositions):
     16        * rendering/RenderBlockLineLayout.cpp:
     17        (WebCore::RenderBlock::layoutInlineChildren):
     18        * rendering/RenderBox.cpp:
     19        (WebCore::RenderBox::blockDirectionOverflow):
     20        * rendering/RenderBox.h:
     21        * rendering/RootInlineBox.cpp:
     22        (WebCore::RootInlineBox::addHighlightOverflow):
     23        * rendering/style/RenderStyle.h:
     24        (WebCore::InheritedFlags::getTextShadowBlockDirectionExtent):
     25        (WebCore::InheritedFlags::getBoxShadowBlockDirectionExtent):
     26        (WebCore::InheritedFlags::getShadowBlockDirectionExtent):
     27
    1282010-10-22  Adam Barth  <abarth@webkit.org>
    229
  • trunk/WebCore/rendering/InlineBox.h

    r70072 r70330  
    230230    // The logicalTop[ position is the top edge of the line box in a horizontal line and the left edge in a vertical line.
    231231    int logicalTop() const { return !m_isVertical ? m_y : m_x; }
     232    int logicalBottom() const { return logicalTop() + logicalHeight(); }
    232233    void setLogicalTop(int top)
    233234    {
  • trunk/WebCore/rendering/InlineFlowBox.cpp

    r70263 r70330  
    563563void InlineFlowBox::computeBlockDirectionOverflow(int lineTop, int lineBottom, bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap)
    564564{
     565    bool isFlippedLine = renderer()->style(m_firstLine)->isFlippedLinesWritingMode();
     566
    565567    int boxHeight = logicalHeight();
    566568
    567569    // Any spillage outside of the line top and bottom is not considered overflow.  We just ignore this, since it only happens
    568570    // from the "your ascent/descent don't affect the line" quirk.
    569     int topOverflow = max(y(), lineTop);
    570     int bottomOverflow = min(y() + boxHeight, lineBottom);
     571    int topOverflow = max(logicalTop(), lineTop);
     572    int bottomOverflow = min(logicalTop() + boxHeight, lineBottom);
    571573   
    572574    int topLayoutOverflow = topOverflow;
     
    580582        int boxShadowTop;
    581583        int boxShadowBottom;
    582         renderer()->style(m_firstLine)->getBoxShadowVerticalExtent(boxShadowTop, boxShadowBottom);
     584        renderer()->style(m_firstLine)->getBoxShadowBlockDirectionExtent(boxShadowTop, boxShadowBottom);
    583585       
    584         topVisualOverflow = min(y() + boxShadowTop, topVisualOverflow);
    585         bottomVisualOverflow = max(y() + boxHeight + boxShadowBottom, bottomVisualOverflow);
     586        topVisualOverflow = min(logicalTop() + boxShadowTop, topVisualOverflow);
     587        bottomVisualOverflow = max(logicalTop() + boxHeight + boxShadowBottom, bottomVisualOverflow);
    586588    }
    587589
     
    601603            GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second;
    602604
    603             int topGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->top : 0);
    604             int bottomGlyphOverflow = strokeOverflow + (glyphOverflow ? glyphOverflow->bottom : 0);
    605 
    606             int childOverflowTop = topGlyphOverflow;
    607             int childOverflowBottom = bottomGlyphOverflow;
    608             for (const ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next()) {
    609                 childOverflowTop = min(childOverflowTop, shadow->y() - shadow->blur() + topGlyphOverflow);
    610                 childOverflowBottom = max(childOverflowBottom, shadow->y() + shadow->blur() + bottomGlyphOverflow);
    611             }
    612            
    613             topVisualOverflow = min(curr->y() + childOverflowTop, topVisualOverflow);
    614             bottomVisualOverflow = max(curr->y() + text->logicalHeight() + childOverflowBottom, bottomVisualOverflow);
     605            int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom : glyphOverflow->top) : 0;
     606            int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top : glyphOverflow->bottom) : 0;
     607
     608            int topGlyphOverflow = -strokeOverflow - topGlyphEdge;
     609            int bottomGlyphOverflow = strokeOverflow + bottomGlyphEdge;
     610
     611            int textShadowTop;
     612            int textShadowBottom;
     613            curr->renderer()->style(m_firstLine)->getTextShadowBlockDirectionExtent(textShadowTop, textShadowBottom);
     614       
     615            int childOverflowTop = min(textShadowTop, topGlyphOverflow);
     616            int childOverflowBottom = max(textShadowBottom, bottomGlyphOverflow);
     617   
     618            topVisualOverflow = min(curr->logicalTop() + childOverflowTop, topVisualOverflow);
     619            bottomVisualOverflow = max(curr->logicalTop() + text->logicalHeight() + childOverflowBottom, bottomVisualOverflow);
    615620        } else  if (curr->renderer()->isRenderInline()) {
    616621            InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
     
    622627        } else if (!curr->boxModelObject()->hasSelfPaintingLayer()){
    623628            // Only include overflow from replaced inlines if they do not paint themselves.
     629            int boxLogicalTop = curr->logicalTop();
     630            int childTopLayoutOverflow;
     631            int childBottomLayoutOverflow;
     632            int childTopVisualOverflow;
     633            int childBottomVisualOverflow;
     634           
    624635            RenderBox* box = toRenderBox(curr->renderer());
    625             int boxY = curr->y();
    626             int childTopOverflow = box->hasOverflowClip() ? 0 : box->topLayoutOverflow();
    627             int childBottomOverflow = box->hasOverflowClip() ? curr->logicalHeight() : box->bottomLayoutOverflow();
    628             topLayoutOverflow = min(boxY + childTopOverflow, topLayoutOverflow);
    629             bottomLayoutOverflow = max(boxY + childBottomOverflow, bottomLayoutOverflow);
    630             topVisualOverflow = min(boxY + box->topVisualOverflow(), topVisualOverflow);
    631             bottomVisualOverflow = max(boxY + box->bottomVisualOverflow(), bottomVisualOverflow);
    632         }
    633     }
    634    
    635     setBlockDirectionOverflowPositions(topLayoutOverflow, bottomLayoutOverflow, topVisualOverflow, bottomVisualOverflow, boxHeight);
     636            box->blockDirectionOverflow(isVertical(), isFlippedLine, childTopLayoutOverflow, childBottomLayoutOverflow,
     637                                        childTopVisualOverflow, childBottomVisualOverflow);
     638           
     639            topLayoutOverflow = min(boxLogicalTop + childTopLayoutOverflow, topLayoutOverflow);
     640            bottomLayoutOverflow = max(boxLogicalTop + childBottomLayoutOverflow, bottomLayoutOverflow);
     641            topVisualOverflow = min(boxLogicalTop + childTopVisualOverflow, topVisualOverflow);
     642            bottomVisualOverflow = max(boxLogicalTop + childBottomVisualOverflow, bottomVisualOverflow);
     643        }
     644    }
     645   
     646    setBlockDirectionOverflowPositions(topLayoutOverflow, bottomLayoutOverflow, topVisualOverflow, bottomVisualOverflow);
    636647}
    637648
  • trunk/WebCore/rendering/InlineFlowBox.h

    r70263 r70330  
    200200                                             int logicalLeftVisualOverflow, int logicalRightVisualOverflow);
    201201    void setBlockDirectionOverflowPositions(int logicalTopLayoutOverflow, int logicalBottomLayoutOverflow,
    202                                             int logicalTopVisualOverflow, int logicalBottomVisualOverflow, int boxLogicalHeight);
     202                                            int logicalTopVisualOverflow, int logicalBottomVisualOverflow);
    203203
    204204protected:
     
    230230            return;
    231231       
    232         int width = isVertical() ? m_renderer->style(m_firstLine)->font().height() : logicalWidth();
    233         int height = isVertical() ? logicalWidth() : m_renderer->style(m_firstLine)->font().height();
     232        int width = isVertical() ? logicalHeight() : logicalWidth();
     233        int height = isVertical() ? logicalWidth() : logicalHeight();
    234234       
    235235        m_overflow = adoptPtr(new RenderOverflow(IntRect(m_x, m_y, width, height)));   
     
    249249}
    250250
    251 inline void InlineFlowBox::setBlockDirectionOverflowPositions(int topLayoutOverflow, int bottomLayoutOverflow, int topVisualOverflow, int bottomVisualOverflow, int boxHeight)
     251inline void InlineFlowBox::setBlockDirectionOverflowPositions(int logicalTopLayoutOverflow, int logicalBottomLayoutOverflow,
     252                                                              int logicalTopVisualOverflow, int logicalBottomVisualOverflow)
    252253{
    253254    if (!m_overflow) {
    254         if (topLayoutOverflow == m_y && bottomLayoutOverflow == m_y + boxHeight && topVisualOverflow == m_y && bottomVisualOverflow == m_y + boxHeight)
     255        if (logicalTopLayoutOverflow == logicalTop() && logicalBottomLayoutOverflow == logicalBottom()
     256            && logicalTopVisualOverflow == logicalTop() && logicalBottomVisualOverflow == logicalBottom())
    255257            return;
    256         m_overflow = adoptPtr(new RenderOverflow(IntRect(m_x, m_y, m_logicalWidth, boxHeight)));
    257     }
    258 
    259     m_overflow->setTopLayoutOverflow(topLayoutOverflow);
    260     m_overflow->setBottomLayoutOverflow(bottomLayoutOverflow);
    261     m_overflow->setTopVisualOverflow(topVisualOverflow);
    262     m_overflow->setBottomVisualOverflow(bottomVisualOverflow); 
     258           
     259        int width = isVertical() ? logicalHeight() : logicalWidth();
     260        int height = isVertical() ? logicalWidth() : logicalHeight();
     261       
     262        m_overflow = adoptPtr(new RenderOverflow(IntRect(m_x, m_y, width, height)));
     263    }
     264
     265    if (!isVertical()) {
     266        m_overflow->setTopLayoutOverflow(logicalTopLayoutOverflow);
     267        m_overflow->setBottomLayoutOverflow(logicalBottomLayoutOverflow);
     268        m_overflow->setTopVisualOverflow(logicalTopVisualOverflow);
     269        m_overflow->setBottomVisualOverflow(logicalBottomVisualOverflow); 
     270    } else {
     271        m_overflow->setLeftLayoutOverflow(logicalTopLayoutOverflow);
     272        m_overflow->setRightLayoutOverflow(logicalBottomLayoutOverflow);
     273        m_overflow->setLeftVisualOverflow(logicalTopVisualOverflow);
     274        m_overflow->setRightVisualOverflow(logicalBottomVisualOverflow);
     275    }
    263276}
    264277
  • trunk/WebCore/rendering/RenderBlockLineLayout.cpp

    r70158 r70330  
    879879                GlyphOverflowAndFallbackFontsMap textBoxDataMap;
    880880                trailingFloatsLineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap);
    881                 trailingFloatsLineBox->setBlockDirectionOverflowPositions(logicalHeight(), bottomLayoutOverflow, logicalHeight(), bottomVisualOverflow, 0);
     881                trailingFloatsLineBox->setBlockDirectionOverflowPositions(logicalHeight(), bottomLayoutOverflow, logicalHeight(), bottomVisualOverflow);
    882882                trailingFloatsLineBox->setBlockLogicalHeight(logicalHeight());
    883883            }
  • trunk/WebCore/rendering/RenderBox.cpp

    r70170 r70330  
    31733173}
    31743174
     3175void RenderBox::blockDirectionOverflow(bool isLineVertical, bool isFlippedLine, int& logicalTopLayoutOverflow, int& logicalBottomLayoutOverflow,
     3176                                       int& logicalTopVisualOverflow, int& logicalBottomVisualOverflow)
     3177{
     3178    if (isLineVertical) {
     3179        if (isFlippedLine) {
     3180            logicalTopLayoutOverflow = leftLayoutOverflow();
     3181            logicalBottomLayoutOverflow = rightLayoutOverflow();
     3182            logicalTopVisualOverflow = leftVisualOverflow();
     3183            logicalBottomVisualOverflow = rightVisualOverflow();
     3184        } else {
     3185            logicalTopLayoutOverflow = rightLayoutOverflow();
     3186            logicalBottomLayoutOverflow = leftLayoutOverflow();
     3187            logicalTopVisualOverflow = rightVisualOverflow();
     3188            logicalBottomVisualOverflow = leftVisualOverflow();
     3189        }
     3190    } else {
     3191        if (isFlippedLine) {
     3192            logicalTopLayoutOverflow = bottomLayoutOverflow();
     3193            logicalBottomLayoutOverflow = topLayoutOverflow();
     3194            logicalTopVisualOverflow = bottomVisualOverflow();
     3195            logicalBottomVisualOverflow = topVisualOverflow();
     3196        } else {
     3197            logicalTopLayoutOverflow = topLayoutOverflow();
     3198            logicalBottomLayoutOverflow = bottomLayoutOverflow();
     3199            logicalTopVisualOverflow = topVisualOverflow();
     3200            logicalBottomVisualOverflow = bottomVisualOverflow();
     3201        }
     3202    }
     3203}
     3204
    31753205} // namespace WebCore
  • trunk/WebCore/rendering/RenderBox.h

    r70170 r70330  
    156156    void clearLayoutOverflow();
    157157
     158    void blockDirectionOverflow(bool isLineVertical, bool isFlippedLine, int& logicalTopLayoutOverflow, int& logicalBottomLayoutOverflow,
     159                                int& logicalTopVisualOverflow, int& logicalBottomVisualOverflow);
     160
    158161    int contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
    159162    int contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
  • trunk/WebCore/rendering/RootInlineBox.cpp

    r69801 r70330  
    150150    IntRect inflatedRect = enclosingIntRect(page->chrome()->client()->customHighlightRect(renderer()->node(), renderer()->style()->highlight(), rootRect));
    151151    setInlineDirectionOverflowPositions(leftLayoutOverflow(), rightLayoutOverflow(), min(leftVisualOverflow(), inflatedRect.x()), max(rightVisualOverflow(), inflatedRect.right()));
    152     setBlockDirectionOverflowPositions(topLayoutOverflow(), bottomLayoutOverflow(), min(topVisualOverflow(), inflatedRect.y()), max(bottomVisualOverflow(), inflatedRect.bottom()), logicalHeight());
     152    setBlockDirectionOverflowPositions(topLayoutOverflow(), bottomLayoutOverflow(), min(topVisualOverflow(), inflatedRect.y()), max(bottomVisualOverflow(), inflatedRect.bottom()));
    153153}
    154154
  • trunk/WebCore/rendering/style/RenderStyle.h

    r70172 r70330  
    642642    void getTextShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(textShadow(), top, bottom); }
    643643    void getTextShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(textShadow(), logicalLeft, logicalRight); }
     644    void getTextShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(textShadow(), logicalTop, logicalBottom); }
    644645
    645646    float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
     
    661662    void getBoxShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(boxShadow(), top, bottom); }
    662663    void getBoxShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(boxShadow(), logicalLeft, logicalRight); }
     664    void getBoxShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(boxShadow(), logicalTop, logicalBottom); }
    663665
    664666    StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
     
    12781280        return isHorizontalWritingMode() ? getShadowHorizontalExtent(shadow, logicalLeft, logicalRight) : getShadowVerticalExtent(shadow, logicalLeft, logicalRight);
    12791281    }
     1282    void getShadowBlockDirectionExtent(const ShadowData* shadow, int& logicalTop, int& logicalBottom) const
     1283    {
     1284        return isHorizontalWritingMode() ? getShadowVerticalExtent(shadow, logicalTop, logicalBottom) : getShadowHorizontalExtent(shadow, logicalTop, logicalBottom);
     1285    }
    12801286
    12811287    // Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
Note: See TracChangeset for help on using the changeset viewer.