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

Side by Side Diff: Source/core/svg/SVGTextContentElement.cpp

Issue 678163002: Oilpan: move SVG property hierarchy to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased upto r185213 Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGTextContentElement.h ('k') | Source/core/svg/SVGTextPathElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 entries.append(std::make_pair(SVGLengthAdjustSpacing, "spacing")); 42 entries.append(std::make_pair(SVGLengthAdjustSpacing, "spacing"));
43 entries.append(std::make_pair(SVGLengthAdjustSpacingAndGlyphs, "spacingA ndGlyphs")); 43 entries.append(std::make_pair(SVGLengthAdjustSpacingAndGlyphs, "spacingA ndGlyphs"));
44 } 44 }
45 return entries; 45 return entries;
46 } 46 }
47 47
48 // SVGTextContentElement's 'textLength' attribute needs special handling. 48 // SVGTextContentElement's 'textLength' attribute needs special handling.
49 // It should return getComputedTextLength() when textLength is not specified man ually. 49 // It should return getComputedTextLength() when textLength is not specified man ually.
50 class SVGAnimatedTextLength final : public SVGAnimatedLength { 50 class SVGAnimatedTextLength final : public SVGAnimatedLength {
51 public: 51 public:
52 static PassRefPtr<SVGAnimatedTextLength> create(SVGTextContentElement* conte xtElement) 52 static PassRefPtrWillBeRawPtr<SVGAnimatedTextLength> create(SVGTextContentEl ement* contextElement)
53 { 53 {
54 return adoptRef(new SVGAnimatedTextLength(contextElement)); 54 return adoptRefWillBeNoop(new SVGAnimatedTextLength(contextElement));
55 } 55 }
56 56
57 virtual SVGLengthTearOff* baseVal() override 57 virtual SVGLengthTearOff* baseVal() override
58 { 58 {
59 SVGTextContentElement* textContentElement = toSVGTextContentElement(cont extElement()); 59 SVGTextContentElement* textContentElement = toSVGTextContentElement(cont extElement());
60 if (!textContentElement->textLengthIsSpecifiedByUser()) 60 if (!textContentElement->textLengthIsSpecifiedByUser())
61 baseValue()->newValueSpecifiedUnits(LengthTypeNumber, textContentEle ment->getComputedTextLength()); 61 baseValue()->newValueSpecifiedUnits(LengthTypeNumber, textContentEle ment->getComputedTextLength());
62 62
63 return SVGAnimatedLength::baseVal(); 63 return SVGAnimatedLength::baseVal();
64 } 64 }
65 65
66 private: 66 private:
67 SVGAnimatedTextLength(SVGTextContentElement* contextElement) 67 SVGAnimatedTextLength(SVGTextContentElement* contextElement)
68 : SVGAnimatedLength(contextElement, SVGNames::textLengthAttr, SVGLength: :create(LengthModeOther), ForbidNegativeLengths) 68 : SVGAnimatedLength(contextElement, SVGNames::textLengthAttr, SVGLength: :create(LengthModeOther), ForbidNegativeLengths)
69 { 69 {
70 } 70 }
71 }; 71 };
72 72
73 73
74 SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Docum ent& document) 74 SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Docum ent& document)
75 : SVGGraphicsElement(tagName, document) 75 : SVGGraphicsElement(tagName, document)
76 , m_textLength(SVGAnimatedTextLength::create(this)) 76 , m_textLength(SVGAnimatedTextLength::create(this))
77 , m_textLengthIsSpecifiedByUser(false) 77 , m_textLengthIsSpecifiedByUser(false)
78 , m_lengthAdjust(SVGAnimatedEnumeration<SVGLengthAdjustType>::create(this, S VGNames::lengthAdjustAttr, SVGLengthAdjustSpacing)) 78 , m_lengthAdjust(SVGAnimatedEnumeration<SVGLengthAdjustType>::create(this, S VGNames::lengthAdjustAttr, SVGLengthAdjustSpacing))
79 { 79 {
80 addToPropertyMap(m_textLength); 80 addToPropertyMap(m_textLength);
81 addToPropertyMap(m_lengthAdjust); 81 addToPropertyMap(m_lengthAdjust);
82 } 82 }
83 83
84 void SVGTextContentElement::trace(Visitor* visitor)
85 {
86 visitor->trace(m_textLength);
87 visitor->trace(m_lengthAdjust);
88 SVGGraphicsElement::trace(visitor);
89 }
90
84 unsigned SVGTextContentElement::getNumberOfChars() 91 unsigned SVGTextContentElement::getNumberOfChars()
85 { 92 {
86 document().updateLayoutIgnorePendingStylesheets(); 93 document().updateLayoutIgnorePendingStylesheets();
87 return SVGTextQuery(renderer()).numberOfCharacters(); 94 return SVGTextQuery(renderer()).numberOfCharacters();
88 } 95 }
89 96
90 float SVGTextContentElement::getComputedTextLength() 97 float SVGTextContentElement::getComputedTextLength()
91 { 98 {
92 document().updateLayoutIgnorePendingStylesheets(); 99 document().updateLayoutIgnorePendingStylesheets();
93 return SVGTextQuery(renderer()).textLength(); 100 return SVGTextQuery(renderer()).textLength();
94 } 101 }
95 102
96 float SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchar s, ExceptionState& exceptionState) 103 float SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchar s, ExceptionState& exceptionState)
97 { 104 {
98 document().updateLayoutIgnorePendingStylesheets(); 105 document().updateLayoutIgnorePendingStylesheets();
99 106
100 unsigned numberOfChars = getNumberOfChars(); 107 unsigned numberOfChars = getNumberOfChars();
101 if (charnum >= numberOfChars) { 108 if (charnum >= numberOfChars) {
102 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 109 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
103 return 0.0f; 110 return 0.0f;
104 } 111 }
105 112
106 if (nchars > numberOfChars - charnum) 113 if (nchars > numberOfChars - charnum)
107 nchars = numberOfChars - charnum; 114 nchars = numberOfChars - charnum;
108 115
109 return SVGTextQuery(renderer()).subStringLength(charnum, nchars); 116 return SVGTextQuery(renderer()).subStringLength(charnum, nchars);
110 } 117 }
111 118
112 PassRefPtr<SVGPointTearOff> SVGTextContentElement::getStartPositionOfChar(unsign ed charnum, ExceptionState& exceptionState) 119 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getStartPositionO fChar(unsigned charnum, ExceptionState& exceptionState)
113 { 120 {
114 document().updateLayoutIgnorePendingStylesheets(); 121 document().updateLayoutIgnorePendingStylesheets();
115 122
116 if (charnum > getNumberOfChars()) { 123 if (charnum > getNumberOfChars()) {
117 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 124 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
118 return nullptr; 125 return nullptr;
119 } 126 }
120 127
121 FloatPoint point = SVGTextQuery(renderer()).startPositionOfCharacter(charnum ); 128 FloatPoint point = SVGTextQuery(renderer()).startPositionOfCharacter(charnum );
122 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); 129 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val);
123 } 130 }
124 131
125 PassRefPtr<SVGPointTearOff> SVGTextContentElement::getEndPositionOfChar(unsigned charnum, ExceptionState& exceptionState) 132 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getEndPositionOfC har(unsigned charnum, ExceptionState& exceptionState)
126 { 133 {
127 document().updateLayoutIgnorePendingStylesheets(); 134 document().updateLayoutIgnorePendingStylesheets();
128 135
129 if (charnum > getNumberOfChars()) { 136 if (charnum > getNumberOfChars()) {
130 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 137 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
131 return nullptr; 138 return nullptr;
132 } 139 }
133 140
134 FloatPoint point = SVGTextQuery(renderer()).endPositionOfCharacter(charnum); 141 FloatPoint point = SVGTextQuery(renderer()).endPositionOfCharacter(charnum);
135 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); 142 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val);
136 } 143 }
137 144
138 PassRefPtr<SVGRectTearOff> SVGTextContentElement::getExtentOfChar(unsigned charn um, ExceptionState& exceptionState) 145 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGTextContentElement::getExtentOfChar(un signed charnum, ExceptionState& exceptionState)
139 { 146 {
140 document().updateLayoutIgnorePendingStylesheets(); 147 document().updateLayoutIgnorePendingStylesheets();
141 148
142 if (charnum > getNumberOfChars()) { 149 if (charnum > getNumberOfChars()) {
143 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 150 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
144 return nullptr; 151 return nullptr;
145 } 152 }
146 153
147 FloatRect rect = SVGTextQuery(renderer()).extentOfCharacter(charnum); 154 FloatRect rect = SVGTextQuery(renderer()).extentOfCharacter(charnum);
148 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal ); 155 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal );
149 } 156 }
150 157
151 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState& exceptionState) 158 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState& exceptionState)
152 { 159 {
153 document().updateLayoutIgnorePendingStylesheets(); 160 document().updateLayoutIgnorePendingStylesheets();
154 161
155 if (charnum > getNumberOfChars()) { 162 if (charnum > getNumberOfChars()) {
156 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 163 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
157 return 0.0f; 164 return 0.0f;
158 } 165 }
159 166
160 return SVGTextQuery(renderer()).rotationOfCharacter(charnum); 167 return SVGTextQuery(renderer()).rotationOfCharacter(charnum);
161 } 168 }
162 169
163 int SVGTextContentElement::getCharNumAtPosition(PassRefPtr<SVGPointTearOff> poin t, ExceptionState& exceptionState) 170 int SVGTextContentElement::getCharNumAtPosition(PassRefPtrWillBeRawPtr<SVGPointT earOff> point, ExceptionState& exceptionState)
164 { 171 {
165 document().updateLayoutIgnorePendingStylesheets(); 172 document().updateLayoutIgnorePendingStylesheets();
166 return SVGTextQuery(renderer()).characterNumberAtPosition(point->target()->v alue()); 173 return SVGTextQuery(renderer()).characterNumberAtPosition(point->target()->v alue());
167 } 174 }
168 175
169 void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E xceptionState& exceptionState) 176 void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E xceptionState& exceptionState)
170 { 177 {
171 unsigned numberOfChars = getNumberOfChars(); 178 unsigned numberOfChars = getNumberOfChars();
172 if (charnum >= numberOfChars) { 179 if (charnum >= numberOfChars) {
173 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 180 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 267
261 if (!renderer->isSVGText() && !renderer->isSVGInline()) 268 if (!renderer->isSVGText() && !renderer->isSVGInline())
262 return 0; 269 return 0;
263 270
264 SVGElement* element = toSVGElement(renderer->node()); 271 SVGElement* element = toSVGElement(renderer->node());
265 ASSERT(element); 272 ASSERT(element);
266 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0; 273 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0;
267 } 274 }
268 275
269 } 276 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGTextContentElement.h ('k') | Source/core/svg/SVGTextPathElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698