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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp

Issue 1846633002: Move SVGTextPositioningElement::elementFromLayoutObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGTextPositioningElement.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) Research In Motion Limited 2010-2011. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) { 91 for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) {
92 UChar currentCharacter = text->characterAt(textPosition); 92 UChar currentCharacter = text->characterAt(textPosition);
93 if (currentCharacter == ' ' && lastCharacter == ' ') 93 if (currentCharacter == ' ' && lastCharacter == ' ')
94 continue; 94 continue;
95 95
96 lastCharacter = currentCharacter; 96 lastCharacter = currentCharacter;
97 ++atCharacter; 97 ++atCharacter;
98 } 98 }
99 } 99 }
100 100
101 static SVGTextPositioningElement* positioningElementFromLayoutObject(LayoutObjec t& layoutObject)
102 {
103 ASSERT(layoutObject.isSVGText() || layoutObject.isSVGInline());
104
105 Node* node = layoutObject.node();
106 ASSERT(node);
107 ASSERT(node->isSVGElement());
108
109 return isSVGTextPositioningElement(*node) ? toSVGTextPositioningElement(node ) : nullptr;
110 }
111
101 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxMod elObject& start, UChar& lastCharacter) 112 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxMod elObject& start, UChar& lastCharacter)
102 { 113 {
103 ASSERT(!start.isSVGText() || m_textPositions.isEmpty()); 114 ASSERT(!start.isSVGText() || m_textPositions.isEmpty());
104 115
105 for (LayoutObject* child = start.slowFirstChild(); child; child = child->nex tSibling()) { 116 for (LayoutObject* child = start.slowFirstChild(); child; child = child->nex tSibling()) {
106 if (child->isSVGInlineText()) { 117 if (child->isSVGInlineText()) {
107 processLayoutSVGInlineText(toLayoutSVGInlineText(child), m_textLengt h, lastCharacter); 118 processLayoutSVGInlineText(toLayoutSVGInlineText(child), m_textLengt h, lastCharacter);
108 continue; 119 continue;
109 } 120 }
110 121
111 if (!child->isSVGInline()) 122 if (!child->isSVGInline())
112 continue; 123 continue;
113 124
114 LayoutSVGInline& inlineChild = toLayoutSVGInline(*child); 125 LayoutSVGInline& inlineChild = toLayoutSVGInline(*child);
115 SVGTextPositioningElement* element = SVGTextPositioningElement::elementF romLayoutObject(inlineChild); 126 SVGTextPositioningElement* element = positioningElementFromLayoutObject( inlineChild);
116 unsigned atPosition = m_textPositions.size(); 127 unsigned atPosition = m_textPositions.size();
117 if (element) 128 if (element)
118 m_textPositions.append(TextPosition(element, m_textLength)); 129 m_textPositions.append(TextPosition(element, m_textLength));
119 130
120 collectTextPositioningElements(inlineChild, lastCharacter); 131 collectTextPositioningElements(inlineChild, lastCharacter);
121 132
122 if (!element) 133 if (!element)
123 continue; 134 continue;
124 135
125 // Update text position, after we're back from recursion. 136 // Update text position, after we're back from recursion.
126 TextPosition& position = m_textPositions[atPosition]; 137 TextPosition& position = m_textPositions[atPosition];
127 ASSERT(!position.length); 138 ASSERT(!position.length);
128 position.length = m_textLength - position.start; 139 position.length = m_textLength - position.start;
129 } 140 }
130 } 141 }
131 142
132 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRo ot) 143 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRo ot)
133 { 144 {
134 SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement: :elementFromLayoutObject(textRoot); 145 SVGTextPositioningElement* outermostTextElement = positioningElementFromLayo utObject(textRoot);
135 ASSERT(outermostTextElement); 146 ASSERT(outermostTextElement);
136 147
137 // Grab outermost <text> element value lists and insert them in the characte r data map. 148 // Grab outermost <text> element value lists and insert them in the characte r data map.
138 TextPosition wholeTextPosition(outermostTextElement, 0, m_textLength); 149 TextPosition wholeTextPosition(outermostTextElement, 0, m_textLength);
139 fillCharacterDataMap(wholeTextPosition); 150 fillCharacterDataMap(wholeTextPosition);
140 151
141 // Handle x/y default attributes. 152 // Handle x/y default attributes.
142 SVGCharacterDataMap::iterator it = m_characterDataMap.find(1); 153 SVGCharacterDataMap::iterator it = m_characterDataMap.find(1);
143 if (it == m_characterDataMap.end()) { 154 if (it == m_characterDataMap.end()) {
144 SVGCharacterData data; 155 SVGCharacterData data;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 it->value.rotate = lastRotation; 240 it->value.rotate = lastRotation;
230 } 241 }
231 } 242 }
232 243
233 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) 244 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition)
234 { 245 {
235 visitor->trace(element); 246 visitor->trace(element);
236 } 247 }
237 248
238 } // namespace blink 249 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGTextPositioningElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698