Ignore:
Timestamp:
Sep 29, 2013, 1:50:01 PM (12 years ago)
Author:
Antti Koivisto
Message:

Tighten typing in inline rendering
https://bugs.webkit.org/show_bug.cgi?id=122076

Reviewed by Andreas Kling.

More RenderElement, const, &, etc.

  • dom/Position.cpp:

(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):

  • rendering/InlineFlowBox.cpp:

(WebCore::isLastChildForRenderer):
(WebCore::isAncestorAndWithinBlock):
(WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
(WebCore::InlineFlowBox::nodeAtPoint):

  • rendering/InlineIterator.h:

(WebCore::InlineIterator::InlineIterator):
(WebCore::InlineIterator::root):
(WebCore::isEmptyInline):
(WebCore::bidiNextShared):
(WebCore::bidiNextSkippingEmptyInlines):
(WebCore::bidiNextIncludingEmptyInlines):
(WebCore::bidiFirstSkippingEmptyInlines):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::inlineLogicalWidth):
(WebCore::alwaysRequiresLineBox):
(WebCore::requiresLineBox):
(WebCore::canBreakAtThisPosition):
(WebCore::LineBreaker::nextSegmentBreak):

  • rendering/shapes/ShapeInsideInfo.h:

(WebCore::LineSegmentIterator::LineSegmentIterator):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r156614 r156618  
    125125#endif
    126126
    127 static inline LayoutUnit borderPaddingMarginStart(RenderInline* child)
    128 {
    129     return child->marginStart() + child->paddingStart() + child->borderStart();
    130 }
    131 
    132 static inline LayoutUnit borderPaddingMarginEnd(RenderInline* child)
    133 {
    134     return child->marginEnd() + child->paddingEnd() + child->borderEnd();
     127static inline LayoutUnit borderPaddingMarginStart(const RenderInline& child)
     128{
     129    return child.marginStart() + child.paddingStart() + child.borderStart();
     130}
     131
     132static inline LayoutUnit borderPaddingMarginEnd(const RenderInline& child)
     133{
     134    return child.marginEnd() + child.paddingEnd() + child.borderEnd();
    135135}
    136136
     
    153153    unsigned lineDepth = 1;
    154154    LayoutUnit extraWidth = 0;
    155     RenderObject* parent = child->parent();
     155    RenderElement* parent = child->parent();
    156156    while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) {
    157         RenderInline* parentAsRenderInline = toRenderInline(parent);
     157        const RenderInline& parentAsRenderInline = toRenderInline(*parent);
    158158        if (!isEmptyInline(parentAsRenderInline)) {
    159159            checkStartEdge = checkStartEdge && shouldAddBorderPaddingMargin(previousInFlowSibling(child));
     
    623623};
    624624
    625 static inline const RenderStyle& lineStyle(RenderElement& renderer, const LineInfo& lineInfo)
     625static inline const RenderStyle& lineStyle(const RenderElement& renderer, const LineInfo& lineInfo)
    626626{
    627627    return lineInfo.isFirstLine() ? *renderer.firstLineStyle() : *renderer.style();
     
    22172217}
    22182218
    2219 static bool requiresLineBoxForContent(RenderInline* flow, const LineInfo& lineInfo)
    2220 {
    2221     RenderElement* parent = flow->parent();
    2222     if (flow->document().inNoQuirksMode()) {
    2223         const RenderStyle& flowStyle = lineStyle(*flow, lineInfo);
     2219static bool requiresLineBoxForContent(const RenderInline& flow, const LineInfo& lineInfo)
     2220{
     2221    RenderElement* parent = flow.parent();
     2222    if (flow.document().inNoQuirksMode()) {
     2223        const RenderStyle& flowStyle = lineStyle(flow, lineInfo);
    22242224        const RenderStyle& parentStyle = lineStyle(*parent, lineInfo);
    22252225        if (flowStyle.lineHeight() != parentStyle.lineHeight()
     
    22312231}
    22322232
    2233 static bool hasInlineDirectionBordersPaddingOrMargin(RenderInline* flow)
     2233static bool hasInlineDirectionBordersPaddingOrMargin(const RenderInline& flow)
    22342234{
    22352235    // Where an empty inline is split across anonymous blocks we should only give lineboxes to the 'sides' of the
    22362236    // inline that have borders, padding or margin.
    2237     bool shouldApplyStartBorderPaddingOrMargin = !flow->parent()->isAnonymousBlock() || !flow->isInlineElementContinuation();
    2238     if (shouldApplyStartBorderPaddingOrMargin && (flow->borderStart() || flow->marginStart() || flow->paddingStart()))
     2237    bool shouldApplyStartBorderPaddingOrMargin = !flow.parent()->isAnonymousBlock() || !flow.isInlineElementContinuation();
     2238    if (shouldApplyStartBorderPaddingOrMargin && (flow.borderStart() || flow.marginStart() || flow.paddingStart()))
    22392239        return true;
    22402240
    2241     bool shouldApplyEndBorderPaddingOrMargin = !flow->parent()->isAnonymousBlock() || flow->isInlineElementContinuation() || !flow->inlineElementContinuation();
    2242     return shouldApplyEndBorderPaddingOrMargin && (flow->borderEnd() || flow->marginEnd() || flow->paddingEnd());
    2243 }
    2244 
    2245 static bool alwaysRequiresLineBox(RenderObject* flow)
     2241    bool shouldApplyEndBorderPaddingOrMargin = !flow.parent()->isAnonymousBlock() || flow.isInlineElementContinuation() || !flow.inlineElementContinuation();
     2242    return shouldApplyEndBorderPaddingOrMargin && (flow.borderEnd() || flow.marginEnd() || flow.paddingEnd());
     2243}
     2244
     2245static bool alwaysRequiresLineBox(const RenderInline& flow)
    22462246{
    22472247    // FIXME: Right now, we only allow line boxes for inlines that are truly empty.
    22482248    // We need to fix this, though, because at the very least, inlines containing only
    22492249    // ignorable whitespace should should also have line boxes.
    2250     return isEmptyInline(flow) && hasInlineDirectionBordersPaddingOrMargin(toRenderInline(flow));
     2250    return isEmptyInline(flow) && hasInlineDirectionBordersPaddingOrMargin(flow);
    22512251}
    22522252
     
    22592259        return true;
    22602260
    2261     if (it.m_obj->isRenderInline() && !alwaysRequiresLineBox(it.m_obj) && !requiresLineBoxForContent(toRenderInline(it.m_obj), lineInfo))
    2262         return false;
     2261    bool rendererIsEmptyInline = false;
     2262    if (it.m_obj->isRenderInline()) {
     2263        const RenderInline& inlineRenderer = toRenderInline(*it.m_obj);
     2264        if (!alwaysRequiresLineBox(inlineRenderer) && !requiresLineBoxForContent(inlineRenderer, lineInfo))
     2265            return false;
     2266        rendererIsEmptyInline = isEmptyInline(inlineRenderer);
     2267    }
    22632268
    22642269    if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition))
     
    22672272    UChar current = it.current();
    22682273    bool notJustWhitespace = current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline()) && !skipNonBreakingSpace(it, lineInfo);
    2269     return notJustWhitespace || isEmptyInline(it.m_obj);
     2274    return notJustWhitespace || rendererIsEmptyInline;
    22702275}
    22712276
     
    26082613
    26092614    // Avoid breaking before empty inlines.
    2610     if (next && isEmptyInline(next))
     2615    if (next && next->isRenderInline() && isEmptyInline(toRenderInline(*next)))
    26112616        return false;
    26122617
     
    26182623        return autoWrap;
    26192624
    2620     bool nextIsText = (next && (current.m_obj->isText() || isEmptyInline(current.m_obj)) && next->isText() && (autoWrap || next->style()->autoWrap()));
    2621     if (!nextIsText)
     2625    bool nextIsAutoWrappingText = (next && next->isText() && (autoWrap || next->style()->autoWrap()));
     2626    if (!nextIsAutoWrappingText)
     2627        return autoWrap;
     2628    bool currentIsTextOrEmptyInline = current.m_obj->isText() || (current.m_obj->isRenderInline() && isEmptyInline(toRenderInline(*current.m_obj)));
     2629    if (!currentIsTextOrEmptyInline)
    26222630        return autoWrap;
    26232631
     
    28212829            renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter);
    28222830        } else if (current.m_obj->isRenderInline()) {
     2831            RenderInline& flowBox = toRenderInline(*current.m_obj);
    28232832            // Right now, we should only encounter empty inlines here.
    2824             ASSERT(isEmptyInline(current.m_obj));
    2825 
    2826             RenderInline* flowBox = toRenderInline(current.m_obj);
    2827 
     2833            ASSERT(isEmptyInline(flowBox));
    28282834            // Now that some inline flows have line boxes, if we are already ignoring spaces, we need
    28292835            // to make sure that we stop to include this object and then start ignoring spaces again.
    28302836            // If this object is at the start of the line, we need to behave like list markers and
    28312837            // start ignoring spaces.
    2832             bool requiresLineBox = alwaysRequiresLineBox(current.m_obj);
     2838            bool requiresLineBox = alwaysRequiresLineBox(flowBox);
    28332839            if (requiresLineBox || requiresLineBoxForContent(flowBox, lineInfo)) {
    28342840                // An empty inline that only has line-height, vertical-align or font-metrics will only get a
     
    28472853                    ignoringSpaces = true;
    28482854                } else {
    2849                     trailingObjects.appendBoxIfNeeded(flowBox);
     2855                    trailingObjects.appendBoxIfNeeded(&flowBox);
    28502856                }
    28512857            }
Note: See TracChangeset for help on using the changeset viewer.