Changeset 163285 in webkit
- Timestamp:
- Feb 2, 2014 9:04:57 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r163283 r163285 1 2014-02-02 Andreas Kling <akling@apple.com> 2 3 Modernize RenderSVGText::locateRenderSVGTextAncestor(). 4 <https://webkit.org/b/128093> 5 6 Make locateRenderSVGTextAncestor() take a reference, and simplify it 7 internally with lineageOfType. 8 9 Switched callers to use 'auto' for the return type so we get some 10 devirtualization freebies. 11 12 Reviewed by Anders Carlsson. 13 14 * rendering/svg/RenderSVGInline.cpp: 15 (WebCore::RenderSVGInline::objectBoundingBox): 16 (WebCore::RenderSVGInline::strokeBoundingBox): 17 (WebCore::RenderSVGInline::repaintRectInLocalCoordinates): 18 (WebCore::RenderSVGInline::absoluteQuads): 19 (WebCore::RenderSVGInline::addChild): 20 (WebCore::RenderSVGInline::removeChild): 21 * rendering/svg/RenderSVGInlineText.cpp: 22 (WebCore::RenderSVGInlineText::setTextInternal): 23 (WebCore::RenderSVGInlineText::styleDidChange): 24 * rendering/svg/RenderSVGResourceGradient.cpp: 25 (WebCore::createMaskAndSwapContextForTextGradient): 26 (WebCore::clipToTextMask): 27 * rendering/svg/RenderSVGText.cpp: 28 (WebCore::RenderSVGText::locateRenderSVGTextAncestor): 29 * rendering/svg/RenderSVGText.h: 30 (WebCore::RenderSVGText>): 31 * rendering/svg/SVGTextLayoutAttributesBuilder.cpp: 32 (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer): 33 * rendering/svg/SVGTextMetricsBuilder.cpp: 34 (WebCore::SVGTextMetricsBuilder::measureTextRenderer): 35 * svg/SVGTextPositioningElement.cpp: 36 (WebCore::SVGTextPositioningElement::svgAttributeChanged): 37 1 38 2014-02-02 Andreas Kling <akling@apple.com> 2 39 -
trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp
r158999 r163285 48 48 FloatRect RenderSVGInline::objectBoundingBox() const 49 49 { 50 if ( const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))51 return object->objectBoundingBox();50 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 51 return textAncestor->objectBoundingBox(); 52 52 53 53 return FloatRect(); … … 56 56 FloatRect RenderSVGInline::strokeBoundingBox() const 57 57 { 58 if ( const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))59 return object->strokeBoundingBox();58 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 59 return textAncestor->strokeBoundingBox(); 60 60 61 61 return FloatRect(); … … 64 64 FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const 65 65 { 66 if ( const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))67 return object->repaintRectInLocalCoordinates();66 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 67 return textAncestor->repaintRectInLocalCoordinates(); 68 68 69 69 return FloatRect(); … … 92 92 void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const 93 93 { 94 const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this);95 if (! object)94 auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this); 95 if (!textAncestor) 96 96 return; 97 97 98 FloatRect textBoundingBox = object->strokeBoundingBox();98 FloatRect textBoundingBox = textAncestor->strokeBoundingBox(); 99 99 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 100 100 quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight()), false, wasFixed)); … … 120 120 SVGResourcesCache::clientWasAddedToTree(*child); 121 121 122 if ( RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))123 text Renderer->subtreeChildWasAdded(child);122 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 123 textAncestor->subtreeChildWasAdded(child); 124 124 } 125 125 … … 128 128 SVGResourcesCache::clientWillBeRemovedFromTree(child); 129 129 130 RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this);131 if (!text Renderer) {130 auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this); 131 if (!textAncestor) { 132 132 RenderInline::removeChild(child); 133 133 return; 134 134 } 135 135 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; 136 text Renderer->subtreeChildWillBeRemoved(&child, affectedAttributes);136 textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes); 137 137 RenderInline::removeChild(child); 138 text Renderer->subtreeChildWasRemoved(affectedAttributes);138 textAncestor->subtreeChildWasRemoved(affectedAttributes); 139 139 } 140 140 -
trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
r163276 r163285 83 83 { 84 84 RenderText::setTextInternal(text); 85 if ( RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))86 text Renderer->subtreeTextDidChange(this);85 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 86 textAncestor->subtreeTextDidChange(this); 87 87 } 88 88 … … 108 108 109 109 // The text metrics may be influenced by style changes. 110 if ( RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))111 text Renderer->subtreeStyleDidChange(this);110 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) 111 textAncestor->subtreeStyleDidChange(this); 112 112 } 113 113 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
r163276 r163285 58 58 static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context, GraphicsContext*& savedContext, std::unique_ptr<ImageBuffer>& imageBuffer, RenderObject* object) 59 59 { 60 RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);60 auto* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(*object); 61 61 ASSERT(textRootBlock); 62 62 … … 80 80 static inline AffineTransform clipToTextMask(GraphicsContext* context, std::unique_ptr<ImageBuffer>& imageBuffer, FloatRect& targetRect, RenderObject* object, bool boundingBoxMode, const AffineTransform& gradientTransform) 81 81 { 82 RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);82 auto* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(*object); 83 83 ASSERT(textRootBlock); 84 84 -
trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp
r161630 r163285 37 37 #include "LayoutRepainter.h" 38 38 #include "PointerEventsHitRules.h" 39 #include "RenderIterator.h" 39 40 #include "RenderSVGInlineText.h" 40 41 #include "RenderSVGResource.h" … … 78 79 } 79 80 80 RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject* start) 81 { 82 ASSERT(start); 83 while (start && !start->isSVGText()) 84 start = start->parent(); 85 if (!start || !start->isSVGText()) 86 return 0; 87 return toRenderSVGText(start); 88 } 89 90 const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const RenderObject* start) 91 { 92 ASSERT(start); 93 while (start && !start->isSVGText()) 94 start = start->parent(); 95 if (!start || !start->isSVGText()) 96 return 0; 97 return toRenderSVGText(start); 81 RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject& start) 82 { 83 return lineageOfType<RenderSVGText>(start).first(); 84 } 85 86 const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const RenderObject& start) 87 { 88 return lineageOfType<RenderSVGText>(start).first(); 98 89 } 99 90 -
trunk/Source/WebCore/rendering/svg/RenderSVGText.h
r162198 r163285 48 48 virtual FloatRect repaintRectInLocalCoordinates() const; 49 49 50 static RenderSVGText* locateRenderSVGTextAncestor(RenderObject *);51 static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject *);50 static RenderSVGText* locateRenderSVGTextAncestor(RenderObject&); 51 static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject&); 52 52 53 53 bool needsReordering() const { return m_needsReordering; } … … 59 59 void subtreeStyleDidChange(RenderSVGInlineText*); 60 60 void subtreeTextDidChange(RenderSVGInlineText*); 61 62 virtual FloatRect objectBoundingBox() const override { return frameRect(); } 63 virtual FloatRect strokeBoundingBox() const override; 61 64 62 65 private: … … 86 89 virtual void willBeDestroyed() override; 87 90 88 virtual FloatRect objectBoundingBox() const { return frameRect(); }89 virtual FloatRect strokeBoundingBox() const;90 91 91 virtual const AffineTransform& localToParentTransform() const { return m_localTransform; } 92 92 virtual AffineTransform localTransform() const { return m_localTransform; } … … 107 107 }; 108 108 109 template<> inline bool isRendererOfType<const RenderSVGText>(const RenderObject& renderer) { return renderer.isSVGText(); } 109 110 RENDER_OBJECT_TYPE_CASTS(RenderSVGText, isSVGText()) 110 111 -
trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
r163248 r163285 36 36 void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(RenderSVGInlineText& text) 37 37 { 38 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(&text);38 auto* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text); 39 39 if (!textRoot) 40 40 return; -
trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp
r161851 r163285 208 208 ASSERT(text); 209 209 210 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);210 auto* textRoot = RenderSVGText::locateRenderSVGTextAncestor(*text); 211 211 if (!textRoot) 212 212 return; -
trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp
r160651 r163285 141 141 142 142 if (updateRelativeLengths || attrName == SVGNames::rotateAttr) { 143 if ( RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(renderer))144 text Renderer->setNeedsPositioningValuesUpdate();143 if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*renderer)) 144 textAncestor->setNeedsPositioningValuesUpdate(); 145 145 RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); 146 146 return;
Note: See TracChangeset
for help on using the changeset viewer.