Fallback to common script when per-script font setting is the empty string
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 06:58:19 +0000 (06:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 06:58:19 +0000 (06:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81329

Patch by Matt Falkenhagen <falken@chromium.org> on 2012-03-18
Reviewed by Kent Tamura.

Source/WebCore:

Tests: fast/text/international/font-fallback-to-common-script.html

* page/Settings.cpp:
(WebCore::setGenericFontFamilyForScript): Remove the setting when the per-script font family is the empty string.

LayoutTests:

* fast/text/international/font-fallback-to-common-script-expected.html: Added.
* fast/text/international/font-fallback-to-common-script.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html [new file with mode: 0644]
LayoutTests/fast/text/international/font-fallback-to-common-script.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp

index e0d7a8253dfc19b2c0d83af49c0488aabddee4ca..57f0e9d362b005d01e96498e950f8892487a5cae 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-18  Matt Falkenhagen  <falken@chromium.org>
+
+        Fallback to common script when per-script font setting is the empty string
+        https://bugs.webkit.org/show_bug.cgi?id=81329
+
+        Reviewed by Kent Tamura.
+
+        * fast/text/international/font-fallback-to-common-script-expected.html: Added.
+        * fast/text/international/font-fallback-to-common-script.html: Added.
+
 2012-03-18  Luke Macpherson   <macpherson@chromium.org>
 
         Remove remnants of code that assume Lengths are 28 bit integers.
diff --git a/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html b/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html
new file mode 100644 (file)
index 0000000..02e21c4
--- /dev/null
@@ -0,0 +1,8 @@
+<html>
+<body>
+<div style="font-size: 20px">
+<div style="font-family: 'Ahem'">this is ahem font</div>
+<div style="font-family: 'Ahem'">this is ahem font</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/international/font-fallback-to-common-script.html b/LayoutTests/fast/text/international/font-fallback-to-common-script.html
new file mode 100644 (file)
index 0000000..e1a4061
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+    window.internals.settings.setStandardFontFamily("Times", "Hans");
+    window.internals.settings.setStandardFontFamily("", "Hans");
+    window.internals.settings.setStandardFontFamily("Ahem", "Zyyy");
+
+    window.internals.settings.setSansSerifFontFamily("Ahem", "Zyyy");
+}
+</script>
+</head>
+<body>
+<!-- Test for font fallback to the common script when the per-script font setting is missing or the empty string.
+Bug 81329 <https://bugs.webkit.org/show_bug.cgi?id=81329> -->
+<div style="font-size: 20px">
+<div lang="zh-CN">this is ahem font</div>
+<div lang="zh-CN" style="font-family: sans-serif;">this is ahem font</div>
+</div>
+</body>
+</html>
index 3cde050c3a639e5c665e4dbcb151704a7a86adfd..979b3d4475b8c1f650f4a08f593a0f65447a149c 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-18  Matt Falkenhagen  <falken@chromium.org>
+
+        Fallback to common script when per-script font setting is the empty string
+        https://bugs.webkit.org/show_bug.cgi?id=81329
+
+        Reviewed by Kent Tamura.
+
+        Tests: fast/text/international/font-fallback-to-common-script.html
+
+        * page/Settings.cpp:
+        (WebCore::setGenericFontFamilyForScript): Remove the setting when the per-script font family is the empty string.
+
 2012-03-18  Luke Macpherson   <macpherson@chromium.org>
 
         Remove remnants of code that assume Lengths are 28 bit integers.
index 323bc837d27dcdedf81078bc702df2906933d36b..63a49dde8cd4724147413d3defc9010404c44bcf 100644 (file)
@@ -52,12 +52,18 @@ static void setLoadsImagesAutomaticallyInAllFrames(Page* page)
         frame->document()->cachedResourceLoader()->setAutoLoadImages(page->settings()->loadsImagesAutomatically());
 }
 
+// Sets the entry in the font map for the given script. If family is the empty string, removes the entry instead.
 static inline void setGenericFontFamilyMap(ScriptFontFamilyMap& fontMap, const AtomicString& family, UScriptCode script, Page* page)
 {
     ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script));
-    if (it != fontMap.end() && it->second == family)
+    if (family.isEmpty()) {
+        if (it == fontMap.end())
+            return;
+        fontMap.remove(it);
+    } else if (it != fontMap.end() && it->second == family)
         return;
-    fontMap.set(static_cast<int>(script), family);
+    else
+        fontMap.set(static_cast<int>(script), family);
     page->setNeedsRecalcStyleInAllFrames();
 }