Changeset 157960 in webkit
- Timestamp:
- Oct 24, 2013, 4:35:26 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/FontFastPath.cpp (modified) (2 diffs)
-
platform/graphics/TextRun.h (modified) (1 diff)
-
platform/graphics/WidthIterator.cpp (modified) (1 diff)
-
rendering/InlineTextBox.cpp (modified) (1 diff)
-
rendering/RenderBlock.cpp (modified) (2 diffs)
-
rendering/svg/SVGInlineTextBox.cpp (modified) (1 diff)
-
rendering/svg/SVGTextMetrics.cpp (modified) (1 diff)
-
rendering/svg/SVGTextRunRenderingContext.cpp (modified) (7 diffs)
-
rendering/svg/SVGTextRunRenderingContext.h (modified) (3 diffs)
-
svg/SVGFontData.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r157959 r157960 1 2013-10-24 Andreas Kling <akling@apple.com> 2 3 Uncomplicate some of SVGTextRunRenderingContext. 4 <https://webkit.org/b/123294> 5 6 This class was weird about a few things, so I've taken these steps 7 to clear things up: 8 9 - FINAL and OVERRIDE all the things. 10 - Constructor now takes a RenderObject&. 11 - renderer() now returns a RenderObject&. 12 - drawSVGGlyphs() no longer takes a TextRun. 13 - glyphDataForCharacter() no longer takes a TextRun. 14 15 To expand on the last two, there was also some awkward hoop-jumping 16 where we'd go through the TextRun passed by argument to find its 17 rendering context, which was really just |this| all along. 18 19 Reviewed by Antti Koivisto. 20 1 21 2013-10-24 Roger Fong <roger_fong@apple.com> 2 22 -
trunk/Source/WebCore/platform/graphics/FontFastPath.cpp
r154674 r157960 209 209 #if ENABLE(SVG_FONTS) 210 210 if (renderingContext && fontData->isSVGFont()) 211 renderingContext->drawSVGGlyphs(context, run,fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);211 renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); 212 212 else 213 213 #endif … … 227 227 #if ENABLE(SVG_FONTS) 228 228 if (renderingContext && fontData->isSVGFont()) 229 renderingContext->drawSVGGlyphs(context, run,fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);229 renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); 230 230 else 231 231 #endif -
trunk/Source/WebCore/platform/graphics/TextRun.h
r157341 r157960 213 213 214 214 #if ENABLE(SVG_FONTS) 215 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&,WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) = 0;216 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, constSimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0;215 virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) = 0; 216 virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; 217 217 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const = 0; 218 218 virtual bool applySVGKerning(const SimpleFontData*, WidthIterator&, GlyphBuffer*, int from) const = 0; -
trunk/Source/WebCore/platform/graphics/WidthIterator.cpp
r157330 r157960 78 78 #if ENABLE(SVG_FONTS) 79 79 if (TextRun::RenderingContext* renderingContext = m_run.renderingContext()) 80 return renderingContext->glyphDataForCharacter(*m_font, m_run,*this, character, mirror, currentCharacter, advanceLength);80 return renderingContext->glyphDataForCharacter(*m_font, *this, character, mirror, currentCharacter, advanceLength); 81 81 #else 82 82 UNUSED_PARAM(currentCharacter); -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r157948 r157960 1488 1488 run.setTabSize(!style.collapseWhiteSpace(), style.tabSize()); 1489 1489 if (textRunNeedsRenderingContext(font)) 1490 run.setRenderingContext(SVGTextRunRenderingContext::create( &renderer()));1490 run.setRenderingContext(SVGTextRunRenderingContext::create(renderer())); 1491 1491 1492 1492 // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r157950 r157960 5433 5433 5434 5434 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride); 5435 if (textRunNeedsRenderingContext(font)) 5436 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); 5435 if (textRunNeedsRenderingContext(font)) { 5436 ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything. 5437 run.setRenderingContext(SVGTextRunRenderingContext::create(*context)); 5438 } 5437 5439 5438 5440 return run; … … 5451 5453 } 5452 5454 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride); 5453 if (textRunNeedsRenderingContext(font)) 5454 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); 5455 if (textRunNeedsRenderingContext(font)) { 5456 ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything. 5457 run.setRenderingContext(SVGTextRunRenderingContext::create(*context)); 5458 } 5455 5459 5456 5460 return run; -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r157919 r157960 418 418 419 419 if (textRunNeedsRenderingContext(style->font())) 420 run.setRenderingContext(SVGTextRunRenderingContext::create( &renderer()));420 run.setRenderingContext(SVGTextRunRenderingContext::create(renderer())); 421 421 422 422 run.disableRoundingHacks(); -
trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
r127801 r157960 78 78 79 79 if (textRunNeedsRenderingContext(style->font())) 80 run.setRenderingContext(SVGTextRunRenderingContext::create( text));80 run.setRenderingContext(SVGTextRunRenderingContext::create(*text)); 81 81 82 82 run.disableRoundingHacks(); -
trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
r156393 r157960 54 54 } 55 55 56 static inline RenderObject* firstParentRendererForNonTextNode(RenderObject* renderer)57 {58 ASSERT(renderer);59 return renderer->isText() ? renderer->parent() : renderer;60 }61 62 static inline RenderObject* renderObjectFromRun(const TextRun& run)63 {64 if (TextRun::RenderingContext* renderingContext = run.renderingContext())65 return static_cast<SVGTextRunRenderingContext*>(renderingContext)->renderer();66 return 0;67 }68 69 static inline RenderSVGResource* activePaintingResourceFromRun(const TextRun& run)70 {71 if (TextRun::RenderingContext* renderingContext = run.renderingContext())72 return static_cast<SVGTextRunRenderingContext*>(renderingContext)->activePaintingResource();73 return 0;74 }75 76 56 float SVGTextRunRenderingContext::floatWidthUsingSVGFont(const Font& font, const TextRun& run, int& charsConsumed, String& glyphName) const 77 57 { … … 123 103 } 124 104 125 void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const TextRun& run, constSimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const105 void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const 126 106 { 127 107 SVGFontElement* fontElement = 0; … … 132 112 return; 133 113 134 // We can only paint SVGFonts if a context is available. 135 RenderSVGResource* activePaintingResource = activePaintingResourceFromRun(run); 136 RenderObject* renderObject = renderObjectFromRun(run); 137 RenderObject* parentRenderObject = firstParentRendererForNonTextNode(renderObject); 138 RenderStyle* parentRenderObjectStyle = 0; 139 140 ASSERT(renderObject); 114 auto activePaintingResource = this->activePaintingResource(); 141 115 if (!activePaintingResource) { 142 116 // TODO: We're only supporting simple filled HTML text so far. … … 145 119 activePaintingResource = solidPaintingResource; 146 120 } 147 148 bool isVerticalText = false; 149 if (parentRenderObject) { 150 parentRenderObjectStyle = parentRenderObject->style(); 151 ASSERT(parentRenderObjectStyle); 152 isVerticalText = parentRenderObjectStyle->svgStyle()->isVerticalWritingMode(); 153 } 121 122 auto& elementRenderer = renderer().isRenderElement() ? toRenderElement(renderer()) : *renderer().parent(); 123 RenderStyle& style = *elementRenderer.style(); 124 bool isVerticalText = style.svgStyle()->isVerticalWritingMode(); 154 125 155 126 float scale = scaleEmToUnits(fontData->platformData().size(), fontFaceElement->unitsPerEm()); … … 195 166 glyphPath.transform(glyphPathTransform); 196 167 197 if (activePaintingResource->applyResource( parentRenderObject, parentRenderObjectStyle, context, resourceMode)) {168 if (activePaintingResource->applyResource(&elementRenderer, &style, context, resourceMode)) { 198 169 float strokeThickness = context->strokeThickness(); 199 if (render Object && renderObject->isSVGInlineText())200 context->setStrokeThickness(strokeThickness * toRenderSVGInlineText(render Object)->scalingFactor());201 activePaintingResource->postApplyResource( parentRenderObject, context, resourceMode, &glyphPath, 0);170 if (renderer().isSVGInlineText()) 171 context->setStrokeThickness(strokeThickness * toRenderSVGInlineText(renderer()).scalingFactor()); 172 activePaintingResource->postApplyResource(&elementRenderer, context, resourceMode, &glyphPath, 0); 202 173 context->setStrokeThickness(strokeThickness); 203 174 } … … 210 181 } 211 182 212 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, const TextRun& run,WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength)183 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) 213 184 { 214 185 const SimpleFontData* primaryFont = font.primaryFont(); … … 234 205 const SimpleFontData* originalFontData = glyphData.fontData; 235 206 if (glyphData.fontData && !glyphData.fontData->isSVGFont()) { 236 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) { 237 RenderObject* renderObject = static_cast<SVGTextRunRenderingContext*>(renderingContext)->renderer(); 238 RenderObject* parentRenderObject = renderObject->isText() ? renderObject->parent() : renderObject; 239 ASSERT(parentRenderObject); 240 if (Element* parentRenderObjectElement = toElement(parentRenderObject->node())) { 241 if (parentRenderObjectElement->hasTagName(SVGNames::altGlyphTag)) 242 glyphData.fontData = primaryFont; 243 } 207 auto& elementRenderer = renderer().isRenderElement() ? toRenderElement(renderer()) : *renderer().parent(); 208 if (Element* parentRendererElement = elementRenderer.element()) { 209 if (parentRendererElement->hasTagName(SVGNames::altGlyphTag)) 210 glyphData.fontData = primaryFont; 244 211 } 245 212 } -
trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h
r156393 r157960 30 30 class RenderSVGResource; 31 31 32 class SVGTextRunRenderingContext : public TextRun::RenderingContext {32 class SVGTextRunRenderingContext FINAL : public TextRun::RenderingContext { 33 33 public: 34 static PassRef Ptr<SVGTextRunRenderingContext> create(RenderObject*renderer)34 static PassRef<SVGTextRunRenderingContext> create(RenderObject& renderer) 35 35 { 36 return adoptRef( new SVGTextRunRenderingContext(renderer));36 return adoptRef(*new SVGTextRunRenderingContext(renderer)); 37 37 } 38 38 39 RenderObject *renderer() const { return m_renderer; }39 RenderObject& renderer() const { return m_renderer; } 40 40 41 41 #if ENABLE(SVG_FONTS) … … 43 43 void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; } 44 44 45 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength);46 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;47 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const ;48 virtual bool applySVGKerning(const SimpleFontData*, WidthIterator&, GlyphBuffer*, int from) const ;45 virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) OVERRIDE; 46 virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const OVERRIDE; 47 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const OVERRIDE; 48 virtual bool applySVGKerning(const SimpleFontData*, WidthIterator&, GlyphBuffer*, int from) const OVERRIDE; 49 49 #endif 50 50 51 51 private: 52 SVGTextRunRenderingContext(RenderObject *renderer)52 SVGTextRunRenderingContext(RenderObject& renderer) 53 53 : m_renderer(renderer) 54 54 #if ENABLE(SVG_FONTS) … … 60 60 virtual ~SVGTextRunRenderingContext() { } 61 61 62 RenderObject *m_renderer;62 RenderObject& m_renderer; 63 63 64 64 #if ENABLE(SVG_FONTS) -
trunk/Source/WebCore/svg/SVGFontData.cpp
r157330 r157960 160 160 RenderObject* renderObject = 0; 161 161 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 162 renderObject = static_cast<SVGTextRunRenderingContext*>(renderingContext)->renderer();162 renderObject = &static_cast<SVGTextRunRenderingContext*>(renderingContext)->renderer(); 163 163 164 164 String language;
Note:
See TracChangeset
for help on using the changeset viewer.