| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "config.h" | 20 #include "config.h" |
| 21 | 21 |
| 22 #include "core/rendering/svg/SVGTextMetricsBuilder.h" | 22 #include "core/rendering/svg/SVGTextMetricsBuilder.h" |
| 23 | 23 |
| 24 #include "core/rendering/svg/RenderSVGInline.h" |
| 24 #include "core/rendering/svg/RenderSVGInlineText.h" | 25 #include "core/rendering/svg/RenderSVGInlineText.h" |
| 25 #include "core/rendering/svg/RenderSVGText.h" | 26 #include "core/rendering/svg/RenderSVGText.h" |
| 26 #include "core/rendering/svg/SVGTextMetrics.h" | 27 #include "core/rendering/svg/SVGTextMetrics.h" |
| 27 #include "platform/fonts/WidthIterator.h" | 28 #include "platform/fonts/WidthIterator.h" |
| 28 #include "platform/text/BidiCharacterRun.h" | 29 #include "platform/text/BidiCharacterRun.h" |
| 29 #include "platform/text/BidiResolver.h" | 30 #include "platform/text/BidiResolver.h" |
| 30 #include "platform/text/TextDirection.h" | 31 #include "platform/text/TextDirection.h" |
| 31 #include "platform/text/TextPath.h" | 32 #include "platform/text/TextPath.h" |
| 32 #include "platform/text/TextRun.h" | 33 #include "platform/text/TextRun.h" |
| 33 #include "platform/text/TextRunIterator.h" | 34 #include "platform/text/TextRunIterator.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 228 |
| 228 data->lastCharacterWasWhiteSpace = characterIsWhiteSpace; | 229 data->lastCharacterWasWhiteSpace = characterIsWhiteSpace; |
| 229 } | 230 } |
| 230 | 231 |
| 231 if (!data->allCharactersMap) | 232 if (!data->allCharactersMap) |
| 232 return; | 233 return; |
| 233 | 234 |
| 234 data->valueListPosition += textPosition - skippedCharacters; | 235 data->valueListPosition += textPosition - skippedCharacters; |
| 235 } | 236 } |
| 236 | 237 |
| 237 static void walkTree(RenderObject* start, RenderSVGInlineText* stopAtLeaf, Measu
reTextData* data) | 238 static void walkTree(RenderSVGText* start, RenderSVGInlineText* stopAtLeaf, Meas
ureTextData* data) |
| 238 { | 239 { |
| 239 RenderObject* child = start->firstChild(); | 240 RenderObject* child = start->firstChild(); |
| 240 while (child) { | 241 while (child) { |
| 241 if (child->isSVGInlineText()) { | 242 if (child->isSVGInlineText()) { |
| 242 RenderSVGInlineText* text = toRenderSVGInlineText(child); | 243 RenderSVGInlineText* text = toRenderSVGInlineText(child); |
| 243 measureTextRenderer(text, data, !stopAtLeaf || stopAtLeaf == text); | 244 measureTextRenderer(text, data, !stopAtLeaf || stopAtLeaf == text); |
| 244 if (stopAtLeaf && stopAtLeaf == text) | 245 if (stopAtLeaf && stopAtLeaf == text) |
| 245 return; | 246 return; |
| 246 } else if (child->isSVGInline()) { | 247 } else if (child->isSVGInline()) { |
| 247 // Visit children of text content elements. | 248 // Visit children of text content elements. |
| 248 if (RenderObject* inlineChild = child->firstChild()) { | 249 if (RenderObject* inlineChild = toRenderSVGInline(child)->firstChild
()) { |
| 249 child = inlineChild; | 250 child = inlineChild; |
| 250 continue; | 251 continue; |
| 251 } | 252 } |
| 252 } | 253 } |
| 253 child = child->nextInPreOrderAfterChildren(start); | 254 child = child->nextInPreOrderAfterChildren(start); |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 257 void SVGTextMetricsBuilder::measureTextRenderer(RenderSVGInlineText* text) | 258 void SVGTextMetricsBuilder::measureTextRenderer(RenderSVGInlineText* text) |
| 258 { | 259 { |
| 259 ASSERT(text); | 260 ASSERT(text); |
| 260 | 261 |
| 261 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text); | 262 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text); |
| 262 if (!textRoot) | 263 if (!textRoot) |
| 263 return; | 264 return; |
| 264 | 265 |
| 265 MeasureTextData data(0); | 266 MeasureTextData data(0); |
| 266 walkTree(textRoot, text, &data); | 267 walkTree(textRoot, text, &data); |
| 267 } | 268 } |
| 268 | 269 |
| 269 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(RenderSVGText* textR
oot, RenderSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap) | 270 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(RenderSVGText* textR
oot, RenderSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap) |
| 270 { | 271 { |
| 271 ASSERT(textRoot); | 272 ASSERT(textRoot); |
| 272 MeasureTextData data(&allCharactersMap); | 273 MeasureTextData data(&allCharactersMap); |
| 273 walkTree(textRoot, stopAtLeaf, &data); | 274 walkTree(textRoot, stopAtLeaf, &data); |
| 274 } | 275 } |
| 275 | 276 |
| 276 } | 277 } |
| OLD | NEW |