Changeset 156618 in webkit
- Timestamp:
- Sep 29, 2013, 1:50:01 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156615 r156618 1 2013-09-29 Antti Koivisto <antti@apple.com> 2 3 Tighten typing in inline rendering 4 https://bugs.webkit.org/show_bug.cgi?id=122076 5 6 Reviewed by Andreas Kling. 7 8 More RenderElement, const, &, etc. 9 10 * dom/Position.cpp: 11 (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight): 12 * rendering/InlineFlowBox.cpp: 13 (WebCore::isLastChildForRenderer): 14 (WebCore::isAncestorAndWithinBlock): 15 (WebCore::InlineFlowBox::determineSpacingForFlowBoxes): 16 (WebCore::InlineFlowBox::nodeAtPoint): 17 * rendering/InlineIterator.h: 18 (WebCore::InlineIterator::InlineIterator): 19 (WebCore::InlineIterator::root): 20 (WebCore::isEmptyInline): 21 (WebCore::bidiNextShared): 22 (WebCore::bidiNextSkippingEmptyInlines): 23 (WebCore::bidiNextIncludingEmptyInlines): 24 (WebCore::bidiFirstSkippingEmptyInlines): 25 * rendering/RenderBlockLineLayout.cpp: 26 (WebCore::inlineLogicalWidth): 27 (WebCore::alwaysRequiresLineBox): 28 (WebCore::requiresLineBox): 29 (WebCore::canBreakAtThisPosition): 30 (WebCore::LineBreaker::nextSegmentBreak): 31 * rendering/shapes/ShapeInsideInfo.h: 32 (WebCore::LineSegmentIterator::LineSegmentIterator): 33 1 34 2013-09-28 Sam Weinig <sam@webkit.org> 2 35 -
trunk/Source/WebCore/dom/Position.cpp
r156424 r156618 855 855 { 856 856 RenderObject* stop = renderer.nextInPreOrderAfterChildren(); 857 for (RenderObject* o = renderer.firstChild(); o && o != stop; o = o->nextInPreOrder()) 858 if (o->nonPseudoNode()) { 859 if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox())) 860 || (o->isLineBreak() && boundingBoxLogicalHeight(o, toRenderLineBreak(o)->linesBoundingBox())) 861 || (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight()) 862 || (o->isRenderInline() && isEmptyInline(o) && boundingBoxLogicalHeight(o, toRenderInline(o)->linesBoundingBox()))) 857 for (RenderObject* o = renderer.firstChild(); o && o != stop; o = o->nextInPreOrder()) { 858 if (!o->nonPseudoNode()) 859 continue; 860 if (o->isText()) { 861 if (boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox())) 863 862 return true; 864 } 863 continue; 864 } 865 if (o->isLineBreak()) { 866 if (boundingBoxLogicalHeight(o, toRenderLineBreak(o)->linesBoundingBox())) 867 return true; 868 continue; 869 } 870 if (o->isBox()) { 871 if (toRenderBox(o)->pixelSnappedLogicalHeight()) 872 return true; 873 continue; 874 } 875 if (o->isRenderInline()) { 876 const RenderInline& renderInline = toRenderInline(*o); 877 if (isEmptyInline(renderInline) && boundingBoxLogicalHeight(o, renderInline.linesBoundingBox())) 878 return true; 879 continue; 880 } 881 } 865 882 return false; 866 883 } -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r156613 r156618 270 270 } 271 271 272 static inline bool isLastChildForRenderer( RenderElement* ancestor,RenderObject* child)272 static inline bool isLastChildForRenderer(const RenderElement& ancestor, const RenderObject* child) 273 273 { 274 274 if (!child) 275 275 return false; 276 276 277 if (child == ancestor)277 if (child == &ancestor) 278 278 return true; 279 279 280 RenderObject* curr = child;281 RenderElement* parent = curr->parent();280 const RenderObject* curr = child; 281 const RenderElement* parent = curr->parent(); 282 282 while (parent && (!parent->isRenderBlock() || parent->isInline())) { 283 283 if (parent->lastChild() != curr) 284 284 return false; 285 if (parent == ancestor)285 if (parent == &ancestor) 286 286 return true; 287 287 … … 293 293 } 294 294 295 static bool isAncestorAndWithinBlock( RenderObject& ancestor,RenderObject* child)296 { 297 RenderObject* object = child;295 static bool isAncestorAndWithinBlock(const RenderInline& ancestor, const RenderObject* child) 296 { 297 const RenderObject* object = child; 298 298 while (object && (!object->isRenderBlock() || object->isInline())) { 299 299 if (object == &ancestor) … … 332 332 if (!lineBoxList.lastLineBox()->isConstructed()) { 333 333 RenderInline& inlineFlow = toRenderInline(renderer()); 334 bool isLastObjectOnLine = !isAncestorAndWithinBlock( renderer(), logicallyLastRunRenderer) || (isLastChildForRenderer(&renderer(), logicallyLastRunRenderer) && !isLogicallyLastRunWrapped);334 bool isLastObjectOnLine = !isAncestorAndWithinBlock(inlineFlow, logicallyLastRunRenderer) || (isLastChildForRenderer(renderer(), logicallyLastRunRenderer) && !isLogicallyLastRunWrapped); 335 335 336 336 // We include the border under these conditions: … … 1019 1019 // Check children first. 1020 1020 // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests. 1021 Render Object* culledParent = 0;1021 RenderElement* culledParent = 0; 1022 1022 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { 1023 1023 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer()) { 1024 Render Object* newParent = 0;1024 RenderElement* newParent = 0; 1025 1025 // Culled parents are only relevant for area-based hit-tests, so ignore it in point-based ones. 1026 1026 if (locationInContainer.isRectBasedTest()) { -
trunk/Source/WebCore/rendering/InlineIterator.h
r156285 r156618 26 26 #include "BidiRun.h" 27 27 #include "RenderBlock.h" 28 #include "RenderInline.h" 28 29 #include "RenderText.h" 29 30 #include <wtf/StdLibExtras.h> … … 44 45 } 45 46 46 InlineIterator(Render Object* root, RenderObject* o, unsigned p)47 InlineIterator(RenderElement* root, RenderObject* o, unsigned p) 47 48 : m_root(root) 48 49 , m_obj(o) … … 68 69 RenderObject* object() const { return m_obj; } 69 70 unsigned offset() const { return m_pos; } 70 Render Object* root() const { return m_root; }71 RenderElement* root() const { return m_root; } 71 72 72 73 void fastIncrementInTextNode(); … … 91 92 92 93 private: 93 Render Object* m_root;94 RenderElement* m_root; 94 95 95 96 // FIXME: These should be private. … … 176 177 }; 177 178 178 static bool isEmptyInline(RenderObject* object) 179 { 180 if (!object->isRenderInline()) 181 return false; 182 183 for (RenderObject* curr = toRenderElement(object)->firstChild(); curr; curr = curr->nextSibling()) { 179 static bool isEmptyInline(const RenderInline& renderer) 180 { 181 for (RenderObject* curr = renderer.firstChild(); curr; curr = curr->nextSibling()) { 184 182 if (curr->isFloatingOrOutOfFlowPositioned()) 185 183 continue; 186 if (curr->isText() && toRenderText(curr)->isAllCollapsibleWhitespace()) 184 if (curr->isText()) { 185 if (!toRenderText(curr)->isAllCollapsibleWhitespace()) 186 return false; 187 187 continue; 188 189 if (! isEmptyInline(curr))188 } 189 if (!curr->isRenderInline() || !isEmptyInline(toRenderInline(*curr))) 190 190 return false; 191 191 } … … 197 197 // a bidi resolver as it enters/exits inlines (so it can push/pop embedding levels). 198 198 template <class Observer> 199 static inline RenderObject* bidiNextShared(Render Object* root, RenderObject* current, Observer* observer = 0, EmptyInlineBehavior emptyInlineBehavior = SkipEmptyInlines, bool* endOfInlinePtr = 0)199 static inline RenderObject* bidiNextShared(RenderElement* root, RenderObject* current, Observer* observer = 0, EmptyInlineBehavior emptyInlineBehavior = SkipEmptyInlines, bool* endOfInlinePtr = 0) 200 200 { 201 201 RenderObject* next = 0; … … 242 242 243 243 if (isIteratorTarget(next) 244 || ((emptyInlineBehavior == IncludeEmptyInlines || isEmptyInline(next)) // Always return EMPTY inlines. 245 && next->isRenderInline())) 244 || (next->isRenderInline() && (emptyInlineBehavior == IncludeEmptyInlines || isEmptyInline(toRenderInline(*next))))) 246 245 break; 247 246 current = next; … … 255 254 256 255 template <class Observer> 257 static inline RenderObject* bidiNextSkippingEmptyInlines(Render Object* root, RenderObject* current, Observer* observer)256 static inline RenderObject* bidiNextSkippingEmptyInlines(RenderElement* root, RenderObject* current, Observer* observer) 258 257 { 259 258 // The SkipEmptyInlines callers never care about endOfInlinePtr. … … 262 261 263 262 // This makes callers cleaner as they don't have to specify a type for the observer when not providing one. 264 static inline RenderObject* bidiNextSkippingEmptyInlines(Render Object* root, RenderObject* current)263 static inline RenderObject* bidiNextSkippingEmptyInlines(RenderElement* root, RenderObject* current) 265 264 { 266 265 InlineBidiResolver* observer = 0; … … 268 267 } 269 268 270 static inline RenderObject* bidiNextIncludingEmptyInlines(Render Object* root, RenderObject* current, bool* endOfInlinePtr = 0)269 static inline RenderObject* bidiNextIncludingEmptyInlines(RenderElement* root, RenderObject* current, bool* endOfInlinePtr = 0) 271 270 { 272 271 InlineBidiResolver* observer = 0; // Callers who include empty inlines, never use an observer. … … 282 281 if (o->isRenderInline()) { 283 282 notifyObserverEnteredObject(resolver, o); 284 if (!isEmptyInline( o))283 if (!isEmptyInline(toRenderInline(*o))) 285 284 o = bidiNextSkippingEmptyInlines(root, o, resolver); 286 285 else { -
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 } -
trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.h
r156176 r156618 41 41 class InlineIterator; 42 42 class RenderBlock; 43 class RenderElement; 43 44 class RenderObject; 44 45 45 46 struct LineSegmentIterator { 46 Render Object* root;47 RenderElement* root; 47 48 RenderObject* object; 48 49 unsigned offset; 49 LineSegmentIterator(Render Object* root, RenderObject* object, unsigned offset)50 LineSegmentIterator(RenderElement* root, RenderObject* object, unsigned offset) 50 51 : root(root) 51 52 , object(object)
Note:
See TracChangeset
for help on using the changeset viewer.