haikuwebkit/LayoutTests/svg/text/text-default-font-size.html

41 lines
1.6 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/163281@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-21 17:36:32 +00:00
<!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>