Flaky Test: platform/mac/fonts/han-disunification.html
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Sep 2013 23:51:46 +0000 (23:51 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Sep 2013 23:51:46 +0000 (23:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114207

Reviewed by Anders Carlsson.

This test was affected by preceding tests changing font settings.

Save original font if it's changed, and restore it in Backup::restoreTo().

* WebCore.exp.in:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setStandardFontFamily):
(WebCore::InternalSettings::setSerifFontFamily):
(WebCore::InternalSettings::setSansSerifFontFamily):
(WebCore::InternalSettings::setFixedFontFamily):
(WebCore::InternalSettings::setCursiveFontFamily):
(WebCore::InternalSettings::setFantasyFontFamily):
(WebCore::InternalSettings::setPictographFontFamily):
* testing/InternalSettings.h:

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h

index 2acf15f..89dea63 100644 (file)
@@ -1,3 +1,26 @@
+2013-09-25  Alexey Proskuryakov  <ap@apple.com>
+
+        Flaky Test: platform/mac/fonts/han-disunification.html
+        https://bugs.webkit.org/show_bug.cgi?id=114207
+
+        Reviewed by Anders Carlsson.
+
+        This test was affected by preceding tests changing font settings.
+
+        Save original font if it's changed, and restore it in Backup::restoreTo().
+
+        * WebCore.exp.in:
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::Backup::restoreTo):
+        (WebCore::InternalSettings::setStandardFontFamily):
+        (WebCore::InternalSettings::setSerifFontFamily):
+        (WebCore::InternalSettings::setSansSerifFontFamily):
+        (WebCore::InternalSettings::setFixedFontFamily):
+        (WebCore::InternalSettings::setCursiveFontFamily):
+        (WebCore::InternalSettings::setFantasyFontFamily):
+        (WebCore::InternalSettings::setPictographFontFamily):
+        * testing/InternalSettings.h:
+
 2013-09-25  Brady Eidson  <beidson@apple.com>
 
         Enable the IndexedDB build on Mac, but leave the feature non-functional
index c4b8eb2..6b2ce0b 100644 (file)
@@ -1669,6 +1669,13 @@ __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb
 __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb
 __ZNK7WebCore8Position28offsetForPositionAfterAnchorEv
 __ZNK7WebCore8Position8upstreamENS_27EditingBoundaryCrossingRuleE
+__ZNK7WebCore8Settings15fixedFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings15serifFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings17cursiveFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings17fantasyFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings18standardFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings19sansSerifFontFamilyE11UScriptCode
+__ZNK7WebCore8Settings20pictographFontFamilyE11UScriptCode
 __ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv
 __ZNK7WebCore9FloatQuad11boundingBoxEv
 __ZNK7WebCore9FloatRect10intersectsERKS0_
index 2ab4f72..ce02372 100644 (file)
@@ -113,6 +113,35 @@ void InternalSettings::Backup::restoreTo(Settings& settings)
     RuntimeEnabledFeatures::sharedFeatures().setStyleScopedEnabled(m_originalStyleScoped);
 #endif
     settings.setEditingBehaviorType(m_originalEditingBehavior);
+
+    for (auto iter = m_standardFontFamilies.begin(); iter != m_standardFontFamilies.end(); ++iter)
+        settings.setStandardFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_standardFontFamilies.clear();
+
+    for (auto iter = m_fixedFontFamilies.begin(); iter != m_fixedFontFamilies.end(); ++iter)
+        settings.setFixedFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_fixedFontFamilies.clear();
+
+    for (auto iter = m_serifFontFamilies.begin(); iter != m_serifFontFamilies.end(); ++iter)
+        settings.setSerifFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_serifFontFamilies.clear();
+
+    for (auto iter = m_sansSerifFontFamilies.begin(); iter != m_sansSerifFontFamilies.end(); ++iter)
+        settings.setSansSerifFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_sansSerifFontFamilies.clear();
+
+    for (auto iter = m_cursiveFontFamilies.begin(); iter != m_cursiveFontFamilies.end(); ++iter)
+        settings.setCursiveFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_cursiveFontFamilies.clear();
+
+    for (auto iter = m_fantasyFontFamilies.begin(); iter != m_fantasyFontFamilies.end(); ++iter)
+        settings.setFantasyFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_fantasyFontFamilies.clear();
+
+    for (auto iter = m_pictographFontFamilies.begin(); iter != m_pictographFontFamilies.end(); ++iter)
+        settings.setPictographFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
+    m_pictographFontFamilies.clear();
+
 #if ENABLE(TEXT_AUTOSIZING)
     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
@@ -253,54 +282,74 @@ void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode
 #endif
 }
 
-typedef void (Settings::*SetFontFamilyFunction)(const AtomicString&, UScriptCode);
-static void setFontFamily(Settings* settings, const String& family, const String& script, SetFontFamilyFunction setter)
-{
-    UScriptCode code = scriptNameToCode(script);
-    if (code != USCRIPT_INVALID_CODE)
-        (settings->*setter)(family, code);
-}
-
 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setStandardFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
+    settings()->setStandardFontFamily(family, code);
 }
 
 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setSerifFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
+    settings()->setSerifFontFamily(family, code);
 }
 
 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setSansSerifFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
+    settings()->setSansSerifFontFamily(family, code);
 }
 
 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setFixedFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
+    settings()->setFixedFontFamily(family, code);
 }
 
 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setCursiveFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
+    settings()->setCursiveFontFamily(family, code);
 }
 
 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setFantasyFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
+    settings()->setFantasyFontFamily(family, code);
 }
 
 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setPictographFontFamily);
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return;
+    m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
+    settings()->setPictographFontFamily(family, code);
 }
 
 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
index 81a4f82..25eea58 100644 (file)
 #ifndef InternalSettings_h
 #define InternalSettings_h
 
+// FIXME (121927): This include should not be needed.
+#include <wtf/text/AtomicStringHash.h>
+
 #include "EditingBehaviorTypes.h"
+#include "FontGenericFamilies.h"
 #include "IntSize.h"
 #include "InternalSettingsGenerated.h"
 #include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -61,6 +63,16 @@ public:
         bool m_originalStyleScoped;
 #endif
         EditingBehaviorType m_originalEditingBehavior;
+
+        // Initially empty, only used if changed by a test.
+        ScriptFontFamilyMap m_standardFontFamilies;
+        ScriptFontFamilyMap m_fixedFontFamilies;
+        ScriptFontFamilyMap m_serifFontFamilies;
+        ScriptFontFamilyMap m_sansSerifFontFamilies;
+        ScriptFontFamilyMap m_cursiveFontFamilies;
+        ScriptFontFamilyMap m_fantasyFontFamilies;
+        ScriptFontFamilyMap m_pictographFontFamilies;
+
 #if ENABLE(TEXT_AUTOSIZING)
         bool m_originalTextAutosizingEnabled;
         IntSize m_originalTextAutosizingWindowSizeOverride;