When we set word-wrap: break-word and xml:space="preserve" to svg text element, the...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 14:32:54 +0000 (14:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 14:32:54 +0000 (14:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111675

Patch by Yuki Sekiguchi <yuki.sekiguchi@access-company.com> on 2013-03-08
Reviewed by Stephen Chenney.

Source/WebCore:

RenderSVGText define its size when it laid out its first line at SVGRootInlineBox::computePerCharacterLayoutInformation().

In the following spec, SVG don't perform automatic line break or word wrapping.
http://www.w3.org/TR/SVG/text.html#Introduction
> SVG performs no automatic line breaking or word wrapping.
However, when we set word-wrap: break-word and xml:space="preserve" to svg text element, RenderBlock::LineBreaker::nextLineBreak() breaks the text.
This make single character lines and make RenderSVGText narrow.

We must ignore word-wrap property to make the text a single line.

We always disable break words and break all in nextLineBreak() when the object is SVGInlineText.

Test: svg/text/preserve-break-word.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak): Disable break words and break all when we process SVG Text.

LayoutTests:

Test combination of xml:space="preserve" and word-wrap: break-word to SVG Text.
These text should not be collapsed.

* svg/text/preserve-break-word-expected.html: Added.
* svg/text/preserve-break-word.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@145215 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/text/preserve-break-word-expected.html [new file with mode: 0644]
LayoutTests/svg/text/preserve-break-word.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 22a59c0..8d5597a 100644 (file)
@@ -1,3 +1,16 @@
+2013-03-08  Yuki Sekiguchi  <yuki.sekiguchi@access-company.com>
+
+        When we set word-wrap: break-word and xml:space="preserve" to svg text element, the text is collapsed.
+        https://bugs.webkit.org/show_bug.cgi?id=111675
+
+        Reviewed by Stephen Chenney.
+
+        Test combination of xml:space="preserve" and word-wrap: break-word to SVG Text.
+        These text should not be collapsed.
+
+        * svg/text/preserve-break-word-expected.html: Added.
+        * svg/text/preserve-break-word.html: Added.
+
 2013-03-08  Kent Tamura  <tkent@chromium.org>
 
         Allow platform-dependent strings for validationMessage property
diff --git a/LayoutTests/svg/text/preserve-break-word-expected.html b/LayoutTests/svg/text/preserve-break-word-expected.html
new file mode 100644 (file)
index 0000000..6ff4c34
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<body>\r
+The above SVG texts should not be collapsed.\r
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="400">\r
+<text x="100" y="100">abcdef</text>\r
+<text x="100" y="200" ><tspan xml:space="preserve">abc</tspan>def</text>\r
+<text x="100" y="300"><tspan xml:space="preserve">abc</tspan>def</text>\r
+</svg>\r
+</body>\r
+</html>\r
diff --git a/LayoutTests/svg/text/preserve-break-word.html b/LayoutTests/svg/text/preserve-break-word.html
new file mode 100644 (file)
index 0000000..4062fcb
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<body>\r
+The above SVG texts should not be collapsed.\r
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="400">\r
+<text x="100" y="100" style="word-wrap: break-word">abcdef</text>\r
+<text x="100" y="200" ><tspan xml:space="preserve">abc</tspan>def</text>\r
+<text x="100" y="300" style="word-wrap: break-word"><tspan xml:space="preserve">abc</tspan>def</text>\r
+</svg>\r
+</body>\r
+</html>\r
index e8f6862..48f3915 100644 (file)
@@ -1,3 +1,27 @@
+2013-03-08  Yuki Sekiguchi  <yuki.sekiguchi@access-company.com>
+
+        When we set word-wrap: break-word and xml:space="preserve" to svg text element, the text is collapsed.
+        https://bugs.webkit.org/show_bug.cgi?id=111675
+
+        Reviewed by Stephen Chenney.
+
+        RenderSVGText define its size when it laid out its first line at SVGRootInlineBox::computePerCharacterLayoutInformation().
+
+        In the following spec, SVG don't perform automatic line break or word wrapping.
+        http://www.w3.org/TR/SVG/text.html#Introduction
+        > SVG performs no automatic line breaking or word wrapping.
+        However, when we set word-wrap: break-word and xml:space="preserve" to svg text element, RenderBlock::LineBreaker::nextLineBreak() breaks the text.
+        This make single character lines and make RenderSVGText narrow.
+
+        We must ignore word-wrap property to make the text a single line.
+
+        We always disable break words and break all in nextLineBreak() when the object is SVGInlineText.
+
+        Test: svg/text/preserve-break-word.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::LineBreaker::nextSegmentBreak): Disable break words and break all when we process SVG Text.
+
 2013-03-08  Allan Sandfeld Jensen  <allan.jensen@digia.com>
 
         [Qt] HTML5 video - sound volume bar out of widget
index 8951535..a99263d 100644 (file)
@@ -2836,6 +2836,12 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
             bool midWordBreak = false;
             bool breakAll = currentStyle->wordBreak() == BreakAllWordBreak && autoWrap;
             float hyphenWidth = 0;
+#if ENABLE(SVG)
+            if (isSVGText) {
+                breakWords = false;
+                breakAll = false;
+            }
+#endif
 
             if (t->isWordBreak()) {
                 width.commit();