Title: [184719] trunk
Revision
184719
Author
commit-qu...@webkit.org
Date
2015-05-21 10:36:32 -0700 (Thu, 21 May 2015)

Log Message

SVG as image uses very tiny default font-size
https://bugs.webkit.org/show_bug.cgi?id=68090

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2015-05-21
Reviewed by Darin Adler.

Source/WebCore:

When loading a document, WebKit creates a Page object and then changes its setting
from the browser's preferences. This is true for interactive resources also, such as a
stand-alone SVG or an SVG embedded in an <object> tag for example. For non-interactive
resources, like an SVG embedded in an <img> tag for example, this function is called
after loading the resource is finished. This function creates an artificial page and
fabricates a scoped settings for it. This turns out to be problematic for cases like
the default font size because its initial value is zero. We cannot go from WebCore to
WebKit to ask for the global settings. But we can inherit the global settings from the
the master page. This is not the best solution because of two reasons. (1) Once the
resource is cached and the styles for the text elements are calculated, nothing can
change the values of styles except removing the resource itself from the cache if the
browser's preferences change. Also there is no mechanism to notify this artificial
page if the browser's preferences change. (2) An image like a non-interactive SVG,
should be displayed the same way regardless of the browser's preferences. A user may
be able to change the default font size for other text. But this should not affect
images even if they are vector images like SVG. An easy and more agreeable solution
is to hard-code the default font size for this case and do not depend on the global
settings at all.

Test: svg/text/text-default-font-size.html

* page/Settings.in: Set the initial value of the setting defaultFontSize to be 16.

LayoutTests:

* svg/text/text-default-font-size-expected.html: Added.
* svg/text/text-default-font-size.html: Added.
Ensure the default font size for non-interactive SVG images is not zero.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (184718 => 184719)


--- trunk/LayoutTests/ChangeLog	2015-05-21 17:34:09 UTC (rev 184718)
+++ trunk/LayoutTests/ChangeLog	2015-05-21 17:36:32 UTC (rev 184719)
@@ -1,3 +1,14 @@
+2015-05-21  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVG as image uses very tiny default font-size
+        https://bugs.webkit.org/show_bug.cgi?id=68090
+
+        Reviewed by Darin Adler.
+
+        * svg/text/text-default-font-size-expected.html: Added.
+        * svg/text/text-default-font-size.html: Added.
+        Ensure the default font size for non-interactive SVG images is not zero.
+
 2015-05-21  Youenn Fablet  <youenn.fab...@crf.canon.fr>
 
         streams/reference-implementation/readable-stream.html should now pass

Added: trunk/LayoutTests/svg/text/text-default-font-size-expected.html (0 => 184719)


--- trunk/LayoutTests/svg/text/text-default-font-size-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/text/text-default-font-size-expected.html	2015-05-21 17:36:32 UTC (rev 184719)
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+  <img src=""
+  <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
+    <g>
+      <rect width='100%' height='100%' fill='Lime'/>
+      <text x='10' y='25' font-size='16px'>svg-text</text>
+    </g>
+    <g transform='translate(40,40)'>
+      <rect width='100%' height='100%' fill='yellow'/>
+      <text x='10' y='25' font-size='16px'>svg-svg-text</text>
+    </g>
+    <g transform='translate(80,80)'>
+      <rect width='100%' height='100%' fill='orange'/>
+      <text x='10' y='25' font-size='16px'>svg-image-text</text>
+    </g>
+    <g transform='translate(120,120)'>
+      <rect width='100%' height='100%' fill='red'/>
+      <text x='10' y='25' font-size='16px'>svg-image-svg-text</text>
+    </g>
+  </svg>">
+</body>
+</html>
+
+

Added: trunk/LayoutTests/svg/text/text-default-font-size.html (0 => 184719)


--- trunk/LayoutTests/svg/text/text-default-font-size.html	                        (rev 0)
+++ trunk/LayoutTests/svg/text/text-default-font-size.html	2015-05-21 17:36:32 UTC (rev 184719)
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+  <img src=""
+  <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
+    <rect width='100%' height='100%' fill='Lime'/>
+    <text x='10' y='25'>svg-text</text>
+    <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='40' y='40'>
+      <rect width='100%' height='100%' fill='yellow'/>
+      <text x='10' y='25'>svg-svg-text</text>
+    </svg>  
+    <image x='80' y='80' width='100%' height='100%'
+      xlink:href=''>
+    </image>
+  </svg>">
+  <script>
+    if (window.testRunner) {
+      testRunner.waitUntilDone();
+      // window load event fires when the the page and its resources are loaded.
+      // However it does not wait till the sub-resources are loaded. And this is
+      // why we need to wait a little bit before we call notifyDone().
+      window.addEventListener("load", function() {
+        setTimeout(function () {
+          testRunner.notifyDone();
+        }, 200);
+      });
+    }
+  </script>
+</body>
+</html>
+
+

Modified: trunk/Source/WebCore/ChangeLog (184718 => 184719)


--- trunk/Source/WebCore/ChangeLog	2015-05-21 17:34:09 UTC (rev 184718)
+++ trunk/Source/WebCore/ChangeLog	2015-05-21 17:36:32 UTC (rev 184719)
@@ -1,3 +1,33 @@
+2015-05-21  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVG as image uses very tiny default font-size
+        https://bugs.webkit.org/show_bug.cgi?id=68090
+
+        Reviewed by Darin Adler.
+
+        When loading a document, WebKit creates a Page object and then changes its setting
+        from the browser's preferences. This is true for interactive resources also, such as a
+        stand-alone SVG or an SVG embedded in an <object> tag for example. For non-interactive
+        resources, like an SVG embedded in an <img> tag for example, this function is called
+        after loading the resource is finished. This function creates an artificial page and
+        fabricates a scoped settings for it. This turns out to be problematic for cases like
+        the default font size because its initial value is zero. We cannot go from WebCore to
+        WebKit to ask for the global settings. But we can inherit the global settings from the
+        the master page. This is not the best solution because of two reasons. (1) Once the
+        resource is cached and the styles for the text elements are calculated, nothing can
+        change the values of styles except removing the resource itself from the cache if the
+        browser's preferences change. Also there is no mechanism to notify this artificial
+        page if the browser's preferences change. (2) An image like a non-interactive SVG,
+        should be displayed the same way regardless of the browser's preferences. A user may
+        be able to change the default font size for other text. But this should not affect
+        images even if they are vector images like SVG. An easy and more agreeable solution
+        is to hard-code the default font size for this case and do not depend on the global
+        settings at all.
+
+        Test: svg/text/text-default-font-size.html
+
+        * page/Settings.in: Set the initial value of the setting defaultFontSize to be 16.
+        
 2015-05-21  Hunseop Jeong  <hs85.je...@samsung.com>
 
         Use modern for-loops in WebCore/svg.

Modified: trunk/Source/WebCore/page/Settings.in (184718 => 184719)


--- trunk/Source/WebCore/page/Settings.in	2015-05-21 17:34:09 UTC (rev 184718)
+++ trunk/Source/WebCore/page/Settings.in	2015-05-21 17:36:32 UTC (rev 184719)
@@ -34,7 +34,7 @@
 
 minimumFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
 minimumLogicalFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
-defaultFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
+defaultFontSize type=int, initial=16, setNeedsStyleRecalcInAllFrames=1
 defaultFixedFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
 
 editingBehaviorType type=EditingBehaviorType, initial=editingBehaviorTypeForPlatform()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to