Skip to content

Commit

Permalink
Merge r184719 - SVG as image uses very tiny default font-size
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=68090

Patch by Said Abou-Hallawa <sabouhallawa@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.
  • Loading branch information
Said Abou-Hallawa authored and carlosgcampos committed Jul 6, 2015
1 parent bcc5b65 commit b6aa572
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2015-05-21 Said Abou-Hallawa <sabouhallawa@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-20 Antti Koivisto <antti@apple.com>

REGRESSION (r172591): Can no longer style <optgroup> with colors (LayoutTests/fast/forms/select/optgroup-rendering.html)
Expand Down
26 changes: 26 additions & 0 deletions LayoutTests/svg/text/text-default-font-size-expected.html
@@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<body>
<img src="data:image/svg+xml,
<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>


40 changes: 40 additions & 0 deletions LayoutTests/svg/text/text-default-font-size.html
@@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<body>
<img src="data:image/svg+xml,
<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='data:image/svg+xml;base64,
PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRw
Oi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJz4NCiAgICA8cmVjdCB3aWR0aD0nMTAwJScgaGVpZ2h0
PScxMDAlJyBmaWxsPSdvcmFuZ2UnLz4NCiAgICA8dGV4dCB4PScxMCcgeT0nMjUnPnN2Zy1pbWFn
ZS10ZXh0PC90ZXh0Pg0KICAgIDxzdmcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3Zn
JyB4bWxuczp4bGluaz0naHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluaycgeD0nNDAnIHk9JzQw
Jz4NCiAgICAgIDxyZWN0IHdpZHRoPScxMDAlJyBoZWlnaHQ9JzEwMCUnIGZpbGw9J3JlZCcvPg0K
ICAgICAgPHRleHQgeD0nMTAnIHk9JzI1Jz5zdmctaW1hZ2Utc3ZnLXRleHQ8L3RleHQ+DQogICAg
PC9zdmc+ICANCjwvc3ZnPg=='>
</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>


30 changes: 30 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,33 @@
2015-05-21 Said Abou-Hallawa <sabouhallawa@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-20 Antti Koivisto <antti@apple.com>

REGRESSION (r172591): Can no longer style <optgroup> with colors (LayoutTests/fast/forms/select/optgroup-rendering.html)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/Settings.in
Expand Up @@ -34,7 +34,7 @@ sessionStorageQuota type=unsigned, initial=StorageMap::noQuota

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()
Expand Down

0 comments on commit b6aa572

Please sign in to comment.