| OLD | NEW |
| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/layout/svg/line/SVGInlineTextBox.h" | 33 #include "core/layout/svg/line/SVGInlineTextBox.h" |
| 34 #include "platform/fonts/CharacterRange.h" | 34 #include "platform/fonts/CharacterRange.h" |
| 35 #include "platform/text/BidiCharacterRun.h" | 35 #include "platform/text/BidiCharacterRun.h" |
| 36 #include "platform/text/BidiResolver.h" | 36 #include "platform/text/BidiResolver.h" |
| 37 #include "platform/text/TextDirection.h" | 37 #include "platform/text/TextDirection.h" |
| 38 #include "platform/text/TextRun.h" | 38 #include "platform/text/TextRun.h" |
| 39 #include "platform/text/TextRunIterator.h" | 39 #include "platform/text/TextRunIterator.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 static PassRefPtr<StringImpl> applySVGWhitespaceRules(PassRefPtr<StringImpl> str
ing, bool preserveWhiteSpace) | 43 // Turn tabs, newlines and carriage returns into spaces. In the future this |
| 44 // should be removed in favor of letting the generic white-space code handle |
| 45 // this. |
| 46 static PassRefPtr<StringImpl> normalizeWhitespace(PassRefPtr<StringImpl> string) |
| 44 { | 47 { |
| 45 if (preserveWhiteSpace) { | 48 RefPtr<StringImpl> newString = string->replace('\t', ' '); |
| 46 // Spec: When xml:space="preserve", the SVG user agent will do the follo
wing using a | 49 newString = newString->replace('\n', ' '); |
| 47 // copy of the original character data content. It will convert all newl
ine and tab | 50 newString = newString->replace('\r', ' '); |
| 48 // characters into space characters. Then, it will draw all space charac
ters, including | |
| 49 // leading, trailing and multiple contiguous space characters. | |
| 50 RefPtr<StringImpl> newString = string->replace('\t', ' '); | |
| 51 newString = newString->replace('\n', ' '); | |
| 52 newString = newString->replace('\r', ' '); | |
| 53 return newString.release(); | |
| 54 } | |
| 55 | |
| 56 // Spec: When xml:space="default", the SVG user agent will do the following
using a | |
| 57 // copy of the original character data content. First, it will remove all ne
wline | |
| 58 // characters. Then it will convert all tab characters into space characters
. | |
| 59 // Then, it will strip off all leading and trailing space characters. | |
| 60 // Then, all contiguous space characters will be consolidated. | |
| 61 RefPtr<StringImpl> newString = string->replace('\n', StringImpl::empty()); | |
| 62 newString = newString->replace('\r', StringImpl::empty()); | |
| 63 newString = newString->replace('\t', ' '); | |
| 64 return newString.release(); | 51 return newString.release(); |
| 65 } | 52 } |
| 66 | 53 |
| 67 LayoutSVGInlineText::LayoutSVGInlineText(Node* n, PassRefPtr<StringImpl> string) | 54 LayoutSVGInlineText::LayoutSVGInlineText(Node* n, PassRefPtr<StringImpl> string) |
| 68 : LayoutText(n, applySVGWhitespaceRules(string, false)) | 55 : LayoutText(n, normalizeWhitespace(string)) |
| 69 , m_scalingFactor(1) | 56 , m_scalingFactor(1) |
| 70 , m_layoutAttributes(this) | 57 , m_layoutAttributes(this) |
| 71 { | 58 { |
| 72 } | 59 } |
| 73 | 60 |
| 74 void LayoutSVGInlineText::setTextInternal(PassRefPtr<StringImpl> text) | 61 void LayoutSVGInlineText::setTextInternal(PassRefPtr<StringImpl> text) |
| 75 { | 62 { |
| 76 LayoutText::setTextInternal(text); | 63 LayoutText::setTextInternal(text); |
| 77 if (LayoutSVGText* textLayoutObject = LayoutSVGText::locateLayoutSVGTextAnce
stor(this)) | 64 if (LayoutSVGText* textLayoutObject = LayoutSVGText::locateLayoutSVGTextAnce
stor(this)) |
| 78 textLayoutObject->subtreeTextDidChange(); | 65 textLayoutObject->subtreeTextDidChange(); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 FloatRect LayoutSVGInlineText::paintInvalidationRectInLocalSVGCoordinates() cons
t | 459 FloatRect LayoutSVGInlineText::paintInvalidationRectInLocalSVGCoordinates() cons
t |
| 473 { | 460 { |
| 474 return parent()->paintInvalidationRectInLocalSVGCoordinates(); | 461 return parent()->paintInvalidationRectInLocalSVGCoordinates(); |
| 475 } | 462 } |
| 476 | 463 |
| 477 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const | 464 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const |
| 478 { | 465 { |
| 479 RefPtr<StringImpl> result = LayoutText::originalText(); | 466 RefPtr<StringImpl> result = LayoutText::originalText(); |
| 480 if (!result) | 467 if (!result) |
| 481 return nullptr; | 468 return nullptr; |
| 482 return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == P
RE); | 469 return normalizeWhitespace(result); |
| 483 } | 470 } |
| 484 | 471 |
| 485 } // namespace blink | 472 } // namespace blink |
| OLD | NEW |