Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Side by Side Diff: Source/WebCore/rendering/svg/RenderSVGInlineText.cpp

Issue 10443073: Merge 117225 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Computer Inc. 3 * Copyright (C) 2006 Apple Computer Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2008 Rob Buis <buis@kde.org> 5 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return newString.release(); 65 return newString.release();
66 } 66 }
67 67
68 RenderSVGInlineText::RenderSVGInlineText(Node* n, PassRefPtr<StringImpl> string) 68 RenderSVGInlineText::RenderSVGInlineText(Node* n, PassRefPtr<StringImpl> string)
69 : RenderText(n, applySVGWhitespaceRules(string, false)) 69 : RenderText(n, applySVGWhitespaceRules(string, false))
70 , m_scalingFactor(1) 70 , m_scalingFactor(1)
71 , m_layoutAttributes(this) 71 , m_layoutAttributes(this)
72 { 72 {
73 } 73 }
74 74
75 void RenderSVGInlineText::willBeDestroyed()
76 {
77 RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(thi s);
78 if (!textRenderer) {
79 RenderText::willBeDestroyed();
80 return;
81 }
82
83 Vector<SVGTextLayoutAttributes*> affectedAttributes;
84 textRenderer->layoutAttributesWillBeDestroyed(this, affectedAttributes);
85
86 RenderText::willBeDestroyed();
87 if (affectedAttributes.isEmpty())
88 return;
89
90 if (!documentBeingDestroyed())
91 textRenderer->rebuildLayoutAttributes(affectedAttributes);
92 }
93
94 void RenderSVGInlineText::setTextInternal(PassRefPtr<StringImpl> text) 75 void RenderSVGInlineText::setTextInternal(PassRefPtr<StringImpl> text)
95 { 76 {
96 RenderText::setTextInternal(text); 77 RenderText::setTextInternal(text);
97 78 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor (this))
98 // When the underlying text content changes, call both textDOMChanged() & la youtAttributesChanged() 79 textRenderer->subtreeTextDidChange(this);
99 // The former will clear the SVGTextPositioningElement cache, which depends on the textLength() of
100 // the RenderSVGInlineText objects, and thus needs to be rebuild. The latter will assure that the
101 // SVGTextLayoutAttributes associated with the RenderSVGInlineText will be u pdated.
102 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor (this)) {
103 textRenderer->invalidateTextPositioningElements();
104 textRenderer->layoutAttributesChanged(this);
105 }
106 } 80 }
107 81
108 void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle * oldStyle) 82 void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle * oldStyle)
109 { 83 {
110 RenderText::styleDidChange(diff, oldStyle); 84 RenderText::styleDidChange(diff, oldStyle);
111 updateScaledFont(); 85 updateScaledFont();
112 86
113 bool newPreserves = style() ? style()->whiteSpace() == PRE : false; 87 bool newPreserves = style() ? style()->whiteSpace() == PRE : false;
114 bool oldPreserves = oldStyle ? oldStyle->whiteSpace() == PRE : false; 88 bool oldPreserves = oldStyle ? oldStyle->whiteSpace() == PRE : false;
115 if (oldPreserves && !newPreserves) { 89 if (oldPreserves && !newPreserves) {
116 setText(applySVGWhitespaceRules(originalText(), false), true); 90 setText(applySVGWhitespaceRules(originalText(), false), true);
117 return; 91 return;
118 } 92 }
119 93
120 if (!oldPreserves && newPreserves) { 94 if (!oldPreserves && newPreserves) {
121 setText(applySVGWhitespaceRules(originalText(), true), true); 95 setText(applySVGWhitespaceRules(originalText(), true), true);
122 return; 96 return;
123 } 97 }
124 98
125 if (diff != StyleDifferenceLayout) 99 if (diff != StyleDifferenceLayout)
126 return; 100 return;
127 101
128 // The text metrics may be influenced by style changes. 102 // The text metrics may be influenced by style changes.
129 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor (this)) 103 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor (this))
130 textRenderer->layoutAttributesChanged(this); 104 textRenderer->subtreeStyleDidChange(this);
131 } 105 }
132 106
133 InlineTextBox* RenderSVGInlineText::createTextBox() 107 InlineTextBox* RenderSVGInlineText::createTextBox()
134 { 108 {
135 InlineTextBox* box = new (renderArena()) SVGInlineTextBox(this); 109 InlineTextBox* box = new (renderArena()) SVGInlineTextBox(this);
136 box->setHasVirtualLogicalHeight(); 110 box->setHasVirtualLogicalHeight();
137 return box; 111 return box;
138 } 112 }
139 113
140 LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit*) 114 LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit*)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // FIXME: We need to better handle the case when we compute very small fonts below (below 1pt). 246 // FIXME: We need to better handle the case when we compute very small fonts below (below 1pt).
273 fontDescription.setComputedSize(StyleResolver::getComputedSizeFromSpecifiedS ize(document, scalingFactor, fontDescription.isAbsoluteSize(), fontDescription.c omputedSize(), DoNotUseSmartMinimumForFontSize)); 247 fontDescription.setComputedSize(StyleResolver::getComputedSizeFromSpecifiedS ize(document, scalingFactor, fontDescription.isAbsoluteSize(), fontDescription.c omputedSize(), DoNotUseSmartMinimumForFontSize));
274 248
275 scaledFont = Font(fontDescription, 0, 0); 249 scaledFont = Font(fontDescription, 0, 0);
276 scaledFont.update(styleResolver->fontSelector()); 250 scaledFont.update(styleResolver->fontSelector());
277 } 251 }
278 252
279 } 253 }
280 254
281 #endif // ENABLE(SVG) 255 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/rendering/svg/RenderSVGInlineText.h ('k') | Source/WebCore/rendering/svg/RenderSVGText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698