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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp

Issue 1888823002: Replace CR/NL by space - don't remove altogether when xml:space=default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more TE 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
index 3154e73ea24311e011b1b2f6700a7d9c2506d582..b2e2f126ce6626793bdaa07754b13c90dd7db0bd 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -40,32 +40,19 @@
namespace blink {
-static PassRefPtr<StringImpl> applySVGWhitespaceRules(PassRefPtr<StringImpl> string, bool preserveWhiteSpace)
+// Turn tabs, newlines and carriage returns into spaces. In the future this
+// should be removed in favor of letting the generic white-space code handle
+// this.
+static PassRefPtr<StringImpl> normalizeWhitespace(PassRefPtr<StringImpl> string)
{
- if (preserveWhiteSpace) {
- // Spec: When xml:space="preserve", the SVG user agent will do the following using a
- // copy of the original character data content. It will convert all newline and tab
- // characters into space characters. Then, it will draw all space characters, including
- // leading, trailing and multiple contiguous space characters.
- RefPtr<StringImpl> newString = string->replace('\t', ' ');
- newString = newString->replace('\n', ' ');
- newString = newString->replace('\r', ' ');
- return newString.release();
- }
-
- // Spec: When xml:space="default", the SVG user agent will do the following using a
- // copy of the original character data content. First, it will remove all newline
- // characters. Then it will convert all tab characters into space characters.
- // Then, it will strip off all leading and trailing space characters.
- // Then, all contiguous space characters will be consolidated.
- RefPtr<StringImpl> newString = string->replace('\n', StringImpl::empty());
- newString = newString->replace('\r', StringImpl::empty());
- newString = newString->replace('\t', ' ');
+ RefPtr<StringImpl> newString = string->replace('\t', ' ');
+ newString = newString->replace('\n', ' ');
+ newString = newString->replace('\r', ' ');
return newString.release();
}
LayoutSVGInlineText::LayoutSVGInlineText(Node* n, PassRefPtr<StringImpl> string)
- : LayoutText(n, applySVGWhitespaceRules(string, false))
+ : LayoutText(n, normalizeWhitespace(string))
, m_scalingFactor(1)
, m_layoutAttributes(this)
{
@@ -479,7 +466,7 @@ PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const
RefPtr<StringImpl> result = LayoutText::originalText();
if (!result)
return nullptr;
- return applySVGWhitespaceRules(result, style() && style()->whiteSpace() == PRE);
+ return normalizeWhitespace(result);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698