Chromium Code Reviews| Index: Source/core/svg/SVGFontData.cpp |
| diff --git a/Source/core/svg/SVGFontData.cpp b/Source/core/svg/SVGFontData.cpp |
| index a62697455da50d047415d5422b9f577545ca2094..10273e3db212a5d13c8ea84b1482ea5e59a79971 100644 |
| --- a/Source/core/svg/SVGFontData.cpp |
| +++ b/Source/core/svg/SVGFontData.cpp |
| @@ -46,7 +46,7 @@ namespace WebCore { |
| SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement) |
| : CustomFontData() |
| - , m_svgFontFaceElement(fontFaceElement) |
| + , m_svgFontFaceElement(fontFaceElement->createWeakRef()) |
| , m_horizontalOriginX(fontFaceElement->horizontalOriginX()) |
| , m_horizontalOriginY(fontFaceElement->horizontalOriginY()) |
| , m_horizontalAdvanceX(fontFaceElement->horizontalAdvanceX()) |
| @@ -57,12 +57,15 @@ SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement) |
| ASSERT_ARG(fontFaceElement, fontFaceElement); |
| } |
| +SVGFontData::~SVGFontData() |
| +{ |
| +} |
| + |
| void SVGFontData::initializeFontData(SimpleFontData* fontData, float fontSize) |
| { |
| ASSERT(fontData); |
| SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| - ASSERT(svgFontFaceElement && svgFontFaceElement->inDocument()); |
| SVGFontElement* svgFontElement = svgFontFaceElement->associatedFontElement(); |
| ASSERT(svgFontElement); |
| @@ -121,8 +124,13 @@ void SVGFontData::initializeFontData(SimpleFontData* fontData, float fontSize) |
| float SVGFontData::widthForSVGGlyph(Glyph glyph, float fontSize) const |
| { |
| + // FIXME: (http://crbug.com/359380) Width calculation may be triggered after removeNode from the current editing impl. |
| + // The retrieved width is not being used, so here we return a dummy value. |
| + if (shouldSkipDrawing()) |
| + return 0.0; |
| + |
| SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| - ASSERT(svgFontFaceElement); |
| + |
| // RenderView::clearSelection is invoked while removing some element, e.g. |
| // Document::nodeWillBeRemoved => FrameSelection::nodeWillBeRemoved => RenderView::clearSelection. |
| // Since recalc style has not been executed yet, RenderStyle might have some reference to |
| @@ -162,8 +170,6 @@ bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& gly |
| arabicForms = charactersWithArabicForm(remainingTextInRun, mirror); |
| SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| - ASSERT(svgFontFaceElement && svgFontFaceElement->inDocument()); |
| - |
| SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement(); |
| ASSERT(associatedFontElement); |
| @@ -233,8 +239,6 @@ bool SVGFontData::fillSVGGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig |
| ASSERT(fontData->isSVGFont()); |
| SVGFontFaceElement* fontFaceElement = this->svgFontFaceElement(); |
| - ASSERT(fontFaceElement && fontFaceElement->inDocument()); |
| - |
| SVGFontElement* fontElement = fontFaceElement->associatedFontElement(); |
| ASSERT(fontElement); |
| @@ -321,6 +325,18 @@ String SVGFontData::createStringWithMirroredCharacters(const String& string) con |
| return mirroredCharacters.toString(); |
| } |
| +SVGFontFaceElement* SVGFontData::svgFontFaceElement() const |
| +{ |
| + // FIXME: SVGFontData should be only used from the document with the SVGFontFaceElement. |
| + RELEASE_ASSERT(m_svgFontFaceElement && m_svgFontFaceElement->inDocument()); |
| + return m_svgFontFaceElement.get(); |
| +} |
| + |
| +bool SVGFontData::shouldSkipDrawing() const |
| +{ |
| + return !m_svgFontFaceElement || !m_svgFontFaceElement->inDocument(); |
|
Kunihiko Sakamoto
2014/04/03 03:17:08
This is workaround for crbug.com/359380, right?
If
kouhei (in TOK)
2014/04/03 09:17:59
Done.
|
| +} |
| + |
| } // namespace WebCore |
| #endif |