Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge r184719 - SVG as image uses very tiny default font-size
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
1 parent
bcc5b65
commit b6aa572
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters