Changeset 156618 in webkit for trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
- Timestamp:
- Sep 29, 2013, 1:50:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r156614 r156618 125 125 #endif 126 126 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();127 static inline LayoutUnit borderPaddingMarginStart(const RenderInline& child) 128 { 129 return child.marginStart() + child.paddingStart() + child.borderStart(); 130 } 131 132 static inline LayoutUnit borderPaddingMarginEnd(const RenderInline& child) 133 { 134 return child.marginEnd() + child.paddingEnd() + child.borderEnd(); 135 135 } 136 136 … … 153 153 unsigned lineDepth = 1; 154 154 LayoutUnit extraWidth = 0; 155 Render Object* parent = child->parent();155 RenderElement* parent = child->parent(); 156 156 while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) { 157 RenderInline* parentAsRenderInline = toRenderInline(parent);157 const RenderInline& parentAsRenderInline = toRenderInline(*parent); 158 158 if (!isEmptyInline(parentAsRenderInline)) { 159 159 checkStartEdge = checkStartEdge && shouldAddBorderPaddingMargin(previousInFlowSibling(child)); … … 623 623 }; 624 624 625 static inline const RenderStyle& lineStyle( RenderElement& renderer, const LineInfo& lineInfo)625 static inline const RenderStyle& lineStyle(const RenderElement& renderer, const LineInfo& lineInfo) 626 626 { 627 627 return lineInfo.isFirstLine() ? *renderer.firstLineStyle() : *renderer.style(); … … 2217 2217 } 2218 2218 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);2219 static 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); 2224 2224 const RenderStyle& parentStyle = lineStyle(*parent, lineInfo); 2225 2225 if (flowStyle.lineHeight() != parentStyle.lineHeight() … … 2231 2231 } 2232 2232 2233 static bool hasInlineDirectionBordersPaddingOrMargin( RenderInline*flow)2233 static bool hasInlineDirectionBordersPaddingOrMargin(const RenderInline& flow) 2234 2234 { 2235 2235 // Where an empty inline is split across anonymous blocks we should only give lineboxes to the 'sides' of the 2236 2236 // 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())) 2239 2239 return true; 2240 2240 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 2245 static bool alwaysRequiresLineBox(const RenderInline& flow) 2246 2246 { 2247 2247 // FIXME: Right now, we only allow line boxes for inlines that are truly empty. 2248 2248 // We need to fix this, though, because at the very least, inlines containing only 2249 2249 // ignorable whitespace should should also have line boxes. 2250 return isEmptyInline(flow) && hasInlineDirectionBordersPaddingOrMargin( toRenderInline(flow));2250 return isEmptyInline(flow) && hasInlineDirectionBordersPaddingOrMargin(flow); 2251 2251 } 2252 2252 … … 2259 2259 return true; 2260 2260 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 } 2263 2268 2264 2269 if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition)) … … 2267 2272 UChar current = it.current(); 2268 2273 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; 2270 2275 } 2271 2276 … … 2608 2613 2609 2614 // Avoid breaking before empty inlines. 2610 if (next && isEmptyInline(next))2615 if (next && next->isRenderInline() && isEmptyInline(toRenderInline(*next))) 2611 2616 return false; 2612 2617 … … 2618 2623 return autoWrap; 2619 2624 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) 2622 2630 return autoWrap; 2623 2631 … … 2821 2829 renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter); 2822 2830 } else if (current.m_obj->isRenderInline()) { 2831 RenderInline& flowBox = toRenderInline(*current.m_obj); 2823 2832 // 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)); 2828 2834 // Now that some inline flows have line boxes, if we are already ignoring spaces, we need 2829 2835 // to make sure that we stop to include this object and then start ignoring spaces again. 2830 2836 // If this object is at the start of the line, we need to behave like list markers and 2831 2837 // start ignoring spaces. 2832 bool requiresLineBox = alwaysRequiresLineBox( current.m_obj);2838 bool requiresLineBox = alwaysRequiresLineBox(flowBox); 2833 2839 if (requiresLineBox || requiresLineBoxForContent(flowBox, lineInfo)) { 2834 2840 // An empty inline that only has line-height, vertical-align or font-metrics will only get a … … 2847 2853 ignoringSpaces = true; 2848 2854 } else { 2849 trailingObjects.appendBoxIfNeeded( flowBox);2855 trailingObjects.appendBoxIfNeeded(&flowBox); 2850 2856 } 2851 2857 }
Note:
See TracChangeset
for help on using the changeset viewer.