[Settings] Convert more settings to be generated
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 04:08:39 +0000 (04:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 04:08:39 +0000 (04:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177766

Patch by Sam Weinig <sam@webkit.org> on 2017-10-18
Reviewed by Dean Jackson.

- Replaces setNeedsStyleRecalcInAllFrames option in Settings.in
  with a more generic, onChange, which allows you to specify a function
  in SettingsBase that will be called when the setting changes.
  setNeedsStyleRecalcInAllFrames is then reimplemented in terms of
  onChange.
- Moves most (all but two) of the remaining non-static settings from
  SettingsBase to Settings.in

* Scripts/GenerateSettings/GenerateSettingsImplementationFile.py:
(printSetterBody):
* Scripts/GenerateSettings/Settings.py:
(Setting.__init__):
(Setting.__str__):
(Setting.typeIsValueType):
(Setting.setterFunctionName):
(Setting.setterChangeFunctionName):
(Setting.hasComplexSetter):
(parseInput):

    Add support for the onChange option.

* page/Settings.in:

    Migrate most of the remaining non-static settings to Settings.in.
    Adopt onChange option.

* page/SettingsBase.cpp:
* page/SettingsBase.h:

    Add helper functions for use by the onChange option.

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

Source/WebCore/ChangeLog
Source/WebCore/Scripts/GenerateSettings/GenerateSettingsImplementationFile.py
Source/WebCore/Scripts/GenerateSettings/Settings.py
Source/WebCore/page/Settings.in
Source/WebCore/page/SettingsBase.cpp
Source/WebCore/page/SettingsBase.h

index 1832627..b466e6a 100644 (file)
@@ -1,3 +1,41 @@
+2017-10-18  Sam Weinig  <sam@webkit.org>
+
+        [Settings] Convert more settings to be generated
+        https://bugs.webkit.org/show_bug.cgi?id=177766
+
+        Reviewed by Dean Jackson.
+
+        - Replaces setNeedsStyleRecalcInAllFrames option in Settings.in
+          with a more generic, onChange, which allows you to specify a function
+          in SettingsBase that will be called when the setting changes. 
+          setNeedsStyleRecalcInAllFrames is then reimplemented in terms of
+          onChange.
+        - Moves most (all but two) of the remaining non-static settings from
+          SettingsBase to Settings.in
+
+        * Scripts/GenerateSettings/GenerateSettingsImplementationFile.py:
+        (printSetterBody):
+        * Scripts/GenerateSettings/Settings.py:
+        (Setting.__init__):
+        (Setting.__str__):
+        (Setting.typeIsValueType):
+        (Setting.setterFunctionName):
+        (Setting.setterChangeFunctionName):
+        (Setting.hasComplexSetter):
+        (parseInput):
+        
+            Add support for the onChange option.
+        
+        * page/Settings.in:
+
+            Migrate most of the remaining non-static settings to Settings.in.
+            Adopt onChange option.
+
+        * page/SettingsBase.cpp:
+        * page/SettingsBase.h:
+
+            Add helper functions for use by the onChange option.
+
 2017-10-18  Chris Dumez  <cdumez@apple.com>
 
         Implement ServiceWorkerRegistration.scope / updateViaCache
 2017-10-18  Chris Dumez  <cdumez@apple.com>
 
         Implement ServiceWorkerRegistration.scope / updateViaCache
index 9c8323e..d6e6093 100755 (executable)
@@ -151,6 +151,7 @@ def printSetterBody(outputFile, setting):
         return
 
     setterFunctionName = setting.setterFunctionName()
         return
 
     setterFunctionName = setting.setterFunctionName()
+    changeFunctionName = setting.setterChangeFunctionName()
 
     if setting.typeIsValueType():
         outputFile.write("void Settings::" + setterFunctionName + "(" + setting.type + " " + setting.name + ")\n")
 
     if setting.typeIsValueType():
         outputFile.write("void Settings::" + setterFunctionName + "(" + setting.type + " " + setting.name + ")\n")
@@ -161,7 +162,7 @@ def printSetterBody(outputFile, setting):
     outputFile.write("    if (m_" + setting.name + " == " + setting.name + ")\n")
     outputFile.write("        return;\n")
     outputFile.write("    m_" + setting.name + " = " + setting.name + ";\n")
     outputFile.write("    if (m_" + setting.name + " == " + setting.name + ")\n")
     outputFile.write("        return;\n")
     outputFile.write("    m_" + setting.name + " = " + setting.name + ";\n")
-    outputFile.write("    m_page->setNeedsRecalcStyleInAllFrames();\n")
+    outputFile.write("    " + changeFunctionName + "();\n")
     outputFile.write("}\n\n")
 
 
     outputFile.write("}\n\n")
 
 
index d2c3a7c..a3c28e1 100755 (executable)
@@ -64,7 +64,7 @@ class Setting:
         self.type = 'bool'
         self.initial = None
         self.conditional = None
         self.type = 'bool'
         self.initial = None
         self.conditional = None
-        self.setNeedsStyleRecalcInAllFrames = None
+        self.onChange = None
         self.getter = None
 
     def __str__(self):
         self.getter = None
 
     def __str__(self):
@@ -73,20 +73,21 @@ class Setting:
             result += ' INIT:' + self.initial
         if (self.conditional):
             result += ' COND:' + self.conditional
             result += ' INIT:' + self.initial
         if (self.conditional):
             result += ' COND:' + self.conditional
-        if (self.setNeedsStyleRecalcInAllFrames):
-            result += ' RECALC:' + self.setNeedsStyleRecalcInAllFrames
+        if (self.onChange):
+            result += ' CHANGE:' + self.onChange
         if (self.getter):
             result += ' GETTER:' + self.getter
         return result
 
         if (self.getter):
             result += ' GETTER:' + self.getter
         return result
 
-    def hasComplexSetter(self):
-        return self.setNeedsStyleRecalcInAllFrames
-
     def typeIsValueType(self):
     def typeIsValueType(self):
-        return self.type != 'String'
+        if self.type == 'String':
+            return False
+        if self.type == 'URL':
+            return False
+        return True
 
     def setterFunctionName(self):
 
     def setterFunctionName(self):
-        for prefix in ['css', 'xss', 'ftp', 'dom']:
+        for prefix in ['css', 'xss', 'ftp', 'dom', 'dns']:
             if self.name.startswith(prefix):
                 return 'set' + uppercaseFirstN(self.name, len(prefix))
         return 'set' + uppercaseFirstN(self.name, 1)
             if self.name.startswith(prefix):
                 return 'set' + uppercaseFirstN(self.name, len(prefix))
         return 'set' + uppercaseFirstN(self.name, 1)
@@ -94,6 +95,12 @@ class Setting:
     def getterFunctionName(self):
         return self.getter or self.name
 
     def getterFunctionName(self):
         return self.getter or self.name
 
+    def setterChangeFunctionName(self):
+        return self.onChange
+
+    def hasComplexSetter(self):
+        return self.onChange != None
+
     def idlType(self):
         # FIXME: Add support for more types including enumerate types.
         if self.type == 'int':
     def idlType(self):
         # FIXME: Add support for more types including enumerate types.
         if self.type == 'int':
@@ -144,8 +151,8 @@ def parseInput(input):
                         setting.initial = value
                     if (name == 'conditional'):
                         setting.conditional = value
                         setting.initial = value
                     if (name == 'conditional'):
                         setting.conditional = value
-                    if (name == 'setNeedsStyleRecalcInAllFrames'):
-                        setting.setNeedsStyleRecalcInAllFrames = value
+                    if (name == 'onChange'):
+                        setting.onChange = value
                     if (name == 'getter'):
                         setting.getter = value
 
                     if (name == 'getter'):
                         setting.getter = value
 
index 3a59158..7c81414 100644 (file)
@@ -35,10 +35,10 @@ deviceHeight type=int, initial=0
 # since the memory used won't be released until the Page is destroyed.
 sessionStorageQuota type=unsigned, initial=StorageMap::noQuota
 
 # since the memory used won't be released until the Page is destroyed.
 sessionStorageQuota type=unsigned, initial=StorageMap::noQuota
 
-minimumFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
-minimumLogicalFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
-defaultFontSize type=int, initial=16, setNeedsStyleRecalcInAllFrames=1
-defaultFixedFontSize type=int, initial=0, setNeedsStyleRecalcInAllFrames=1
+minimumFontSize type=int, initial=0, onChange=setNeedsRecalcStyleInAllFrames
+minimumLogicalFontSize type=int, initial=0, onChange=setNeedsRecalcStyleInAllFrames
+defaultFontSize type=int, initial=16, onChange=setNeedsRecalcStyleInAllFrames
+defaultFixedFontSize type=int, initial=0, onChange=setNeedsRecalcStyleInAllFrames
 
 editingBehaviorType type=EditingBehaviorType, initial=editingBehaviorTypeForPlatform()
 maximumHTMLParserDOMTreeDepth type=unsigned, initial=defaultMaximumHTMLParserDOMTreeDepth
 
 editingBehaviorType type=EditingBehaviorType, initial=editingBehaviorTypeForPlatform()
 maximumHTMLParserDOMTreeDepth type=unsigned, initial=defaultMaximumHTMLParserDOMTreeDepth
@@ -59,14 +59,16 @@ shouldPrintBackgrounds initial=false
 usesDashboardBackwardCompatibilityMode initial=false, conditional=DASHBOARD_SUPPORT
 clipboardAccessPolicy type=ClipboardAccessPolicy, initial=ClipboardAccessPolicy::RequiresUserGesture
 
 usesDashboardBackwardCompatibilityMode initial=false, conditional=DASHBOARD_SUPPORT
 clipboardAccessPolicy type=ClipboardAccessPolicy, initial=ClipboardAccessPolicy::RequiresUserGesture
 
-textAreasAreResizable initial=false, setNeedsStyleRecalcInAllFrames=1
-authorAndUserStylesEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
-acceleratedCompositingEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
-acceleratedCompositedAnimationsEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
-showDebugBorders initial=false, setNeedsStyleRecalcInAllFrames=1
-showRepaintCounter initial=false, setNeedsStyleRecalcInAllFrames=1
+textAreasAreResizable initial=false, onChange=setNeedsRecalcStyleInAllFrames
+authorAndUserStylesEnabled initial=true, onChange=setNeedsRecalcStyleInAllFrames
+userStyleSheetLocation type=URL, onChange=userStyleSheetLocationChanged
+acceleratedCompositingEnabled initial=true, onChange=setNeedsRecalcStyleInAllFrames
+acceleratedCompositedAnimationsEnabled initial=true, onChange=setNeedsRecalcStyleInAllFrames
+showDebugBorders initial=false, onChange=setNeedsRecalcStyleInAllFrames
+showRepaintCounter initial=false, onChange=setNeedsRecalcStyleInAllFrames
 visibleDebugOverlayRegions type=DebugOverlayRegions, initial=0
 showTiledScrollingIndicator initial=false
 visibleDebugOverlayRegions type=DebugOverlayRegions, initial=0
 showTiledScrollingIndicator initial=false
+resourceUsageOverlayVisible initial=false, onChange=resourceUsageOverlayVisibleChanged, condition=RESOURCE_USAGE
 
 # This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
 # making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
 
 # This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
 # making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
@@ -199,13 +201,13 @@ selectTrailingWhitespaceEnabled initial=defaultSelectTrailingWhitespaceEnabled
 useLegacyBackgroundSizeShorthandBehavior initial=false
 fixedBackgroundsPaintRelativeToDocument initial=defaultFixedBackgroundsPaintRelativeToDocument
 
 useLegacyBackgroundSizeShorthandBehavior initial=false
 fixedBackgroundsPaintRelativeToDocument initial=defaultFixedBackgroundsPaintRelativeToDocument
 
-textAutosizingEnabled initial=defaultTextAutosizingEnabled(), setNeedsStyleRecalcInAllFrames=1, conditional=TEXT_AUTOSIZING
-textAutosizingWindowSizeOverride type=IntSize, setNeedsStyleRecalcInAllFrames=1, conditional=TEXT_AUTOSIZING
+textAutosizingEnabled initial=defaultTextAutosizingEnabled(), onChange=setNeedsRecalcStyleInAllFrames, conditional=TEXT_AUTOSIZING
+textAutosizingWindowSizeOverride type=IntSize, onChange=setNeedsRecalcStyleInAllFrames, conditional=TEXT_AUTOSIZING
 minimumZoomFontSize type=float, initial=defaultMinimumZoomFontSize(), conditional=TEXT_AUTOSIZING
 
 minimumZoomFontSize type=float, initial=defaultMinimumZoomFontSize(), conditional=TEXT_AUTOSIZING
 
-subpixelAntialiasedLayerTextEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
-simpleLineLayoutEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
-simpleLineLayoutDebugBordersEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
+subpixelAntialiasedLayerTextEnabled initial=false, onChange=setNeedsRecalcStyleInAllFrames
+simpleLineLayoutEnabled initial=true, onChange=setNeedsRecalcStyleInAllFrames
+simpleLineLayoutDebugBordersEnabled initial=false, onChange=setNeedsRecalcStyleInAllFrames
 
 subpixelCSSOMElementMetricsEnabled initial=false
 
 
 subpixelCSSOMElementMetricsEnabled initial=false
 
@@ -271,7 +273,7 @@ treatIPAddressAsDomain initial=false
 mediaPreloadingEnabled initial=false
 
 # Runtime-enabled features
 mediaPreloadingEnabled initial=false
 
 # Runtime-enabled features
-visualViewportEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
+visualViewportEnabled initial=false, onChange=setNeedsRecalcStyleInAllFrames
 
 inputEventsEnabled initial=true
 
 
 inputEventsEnabled initial=true
 
@@ -308,7 +310,7 @@ storageAccessAPIEnabled initial=false
 
 timeWithoutMouseMovementBeforeHidingControls type=Seconds, initial=3_s 
 
 
 timeWithoutMouseMovementBeforeHidingControls type=Seconds, initial=3_s 
 
-fontFallbackPrefersPictographs initial=false, setNeedsStyleRecalcInAllFrames=1
+fontFallbackPrefersPictographs initial=false, onChange=setNeedsRecalcStyleInAllFrames
 
 fontLoadTimingOverride type=FontLoadTimingOverride, initial=FontLoadTimingOverride::None
 shouldIgnoreFontLoadCompletions initial=false
 
 fontLoadTimingOverride type=FontLoadTimingOverride, initial=FontLoadTimingOverride::None
 shouldIgnoreFontLoadCompletions initial=false
@@ -320,6 +322,31 @@ applePayCapabilityDisclosureAllowed initial=true, conditional=APPLE_PAY
 javaEnabled initial=false, getter=isJavaEnabled
 javaEnabledForLocalFiles initial=true, getter=isJavaEnabledForLocalFiles
 
 javaEnabled initial=false, getter=isJavaEnabled
 javaEnabledForLocalFiles initial=true, getter=isJavaEnabledForLocalFiles
 
+# Unlike the imagesEnabled setting, this only suppresses the network load of
+# the image URL. A cached image will still be rendered if requested.
+loadsImagesAutomatically initial=false, onChange=imagesEnabledChanged
+imagesEnabled initial=true, getter=areImagesEnabled, onChange=imagesEnabledChanged
+scriptEnabled initial=false, getter=isScriptEnabled, onChange=scriptEnabledChanged
+pluginsEnabled initial=false, getter=arePluginsEnabled, onChange=pluginsEnabledChanged
+
+usesPageCache initial=false, onChange=usesPageCacheChanged
+
+dnsPrefetchingEnabled initial=false, onChange=dnsPrefetchingEnabledChanged
+
+backgroundShouldExtendBeyondPage initial=false, onChange=backgroundShouldExtendBeyondPageChanged
+
+scrollingPerformanceLoggingEnabled initial=false, onChange=scrollingPerformanceLoggingEnabledChanged
+
+hiddenPageDOMTimerThrottlingEnabled initial=false, onChange=hiddenPageDOMTimerThrottlingStateChanged
+hiddenPageDOMTimerThrottlingAutoIncreases initial=false, onChange=hiddenPageDOMTimerThrottlingStateChanged
+hiddenPageCSSAnimationSuspensionEnabled initial=false, onChange=hiddenPageCSSAnimationSuspensionEnabledChanged
+
+storageBlockingPolicy type=SecurityOrigin::StorageBlockingPolicy, initial=SecurityOrigin::AllowAllStorage, onChange=storageBlockingPolicyChanged
+
+# Only set by Layout Tests.
+mediaTypeOverride type=String, initial="screen", onChange=mediaTypeOverrideChanged
+
+
 fontRenderingMode type=FontRenderingMode, initial=FontRenderingMode::Normal
 
 preferMIMETypeForImages initial=false
 fontRenderingMode type=FontRenderingMode, initial=FontRenderingMode::Normal
 
 preferMIMETypeForImages initial=false
index 360915e..c16ce26 100644 (file)
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-static void setImageLoadingSettings(Page* page)
-{
-    if (!page)
-        return;
-
-    for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (!frame->document())
-            continue;
-        frame->document()->cachedResourceLoader().setImagesEnabled(page->settings().areImagesEnabled());
-        frame->document()->cachedResourceLoader().setAutoLoadImages(page->settings().loadsImagesAutomatically());
-    }
-}
-
 static void invalidateAfterGenericFamilyChange(Page* page)
 {
     invalidateFontCascadeCache();
 static void invalidateAfterGenericFamilyChange(Page* page)
 {
     invalidateFontCascadeCache();
@@ -146,17 +133,7 @@ SettingsBase::SettingsBase(Page* page)
     , m_fontGenericFamilies(std::make_unique<FontGenericFamilies>())
     , m_layoutInterval(layoutScheduleThreshold)
     , m_minimumDOMTimerInterval(DOMTimer::defaultMinimumInterval())
     , m_fontGenericFamilies(std::make_unique<FontGenericFamilies>())
     , m_layoutInterval(layoutScheduleThreshold)
     , m_minimumDOMTimerInterval(DOMTimer::defaultMinimumInterval())
-    , m_loadsImagesAutomatically(false)
-    , m_areImagesEnabled(true)
-    , m_arePluginsEnabled(false)
-    , m_isScriptEnabled(false)
-    , m_usesPageCache(false)
-    , m_backgroundShouldExtendBeyondPage(false)
-    , m_dnsPrefetchingEnabled(false)
-    , m_scrollingPerformanceLoggingEnabled(false)
     , m_setImageLoadingSettingsTimer(*this, &SettingsBase::imageLoadingSettingsTimerFired)
     , m_setImageLoadingSettingsTimer(*this, &SettingsBase::imageLoadingSettingsTimerFired)
-    , m_hiddenPageDOMTimerThrottlingEnabled(false)
-    , m_hiddenPageCSSAnimationSuspensionEnabled(false)
 {
     // A Frame may not have been created yet, so we initialize the AtomicString
     // hash before trying to use it.
 {
     // A Frame may not have been created yet, so we initialize the AtomicString
     // hash before trying to use it.
@@ -272,85 +249,6 @@ bool SettingsBase::defaultTextAutosizingEnabled()
 }
 #endif
 
 }
 #endif
 
-void SettingsBase::setMediaTypeOverride(const String& mediaTypeOverride)
-{
-    if (m_mediaTypeOverride == mediaTypeOverride)
-        return;
-
-    m_mediaTypeOverride = mediaTypeOverride;
-
-    if (!m_page)
-        return;
-
-    FrameView* view = m_page->mainFrame().view();
-    ASSERT(view);
-
-    view->setMediaType(mediaTypeOverride);
-    m_page->setNeedsRecalcStyleInAllFrames();
-}
-
-void SettingsBase::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
-{
-    m_loadsImagesAutomatically = loadsImagesAutomatically;
-    
-    // Changing this setting to true might immediately start new loads for images that had previously had loading disabled.
-    // If this happens while a WebView is being dealloc'ed, and we don't know the WebView is being dealloc'ed, these new loads
-    // can cause crashes downstream when the WebView memory has actually been free'd.
-    // One example where this can happen is in Mac apps that subclass WebView then do work in their overridden dealloc methods.
-    // Starting these loads synchronously is not important.  By putting it on a 0-delay, properly closing the Page cancels them
-    // before they have a chance to really start.
-    // See http://webkit.org/b/60572 for more discussion.
-    m_setImageLoadingSettingsTimer.startOneShot(0_s);
-}
-
-void SettingsBase::imageLoadingSettingsTimerFired()
-{
-    setImageLoadingSettings(m_page);
-}
-
-void SettingsBase::setScriptEnabled(bool isScriptEnabled)
-{
-    if (m_isScriptEnabled == isScriptEnabled)
-        return;
-
-    m_isScriptEnabled = isScriptEnabled;
-
-    if (!m_page)
-        return;
-
-#if PLATFORM(IOS)
-    m_page->setNeedsRecalcStyleInAllFrames();
-#endif
-}
-
-void SettingsBase::setImagesEnabled(bool areImagesEnabled)
-{
-    m_areImagesEnabled = areImagesEnabled;
-
-    // See comment in setLoadsImagesAutomatically.
-    m_setImageLoadingSettingsTimer.startOneShot(0_s);
-}
-
-void SettingsBase::setPluginsEnabled(bool arePluginsEnabled)
-{
-    if (m_arePluginsEnabled == arePluginsEnabled)
-        return;
-
-    m_arePluginsEnabled = arePluginsEnabled;
-    Page::refreshPlugins(false);
-}
-
-void SettingsBase::setUserStyleSheetLocation(const URL& userStyleSheetLocation)
-{
-    if (m_userStyleSheetLocation == userStyleSheetLocation)
-        return;
-
-    m_userStyleSheetLocation = userStyleSheetLocation;
-
-    if (m_page)
-        m_page->userStyleSheetLocationChanged();
-}
-
 void SettingsBase::setMinimumDOMTimerInterval(Seconds interval)
 {
     auto oldTimerInterval = std::exchange(m_minimumDOMTimerInterval, interval);
 void SettingsBase::setMinimumDOMTimerInterval(Seconds interval)
 {
     auto oldTimerInterval = std::exchange(m_minimumDOMTimerInterval, interval);
@@ -371,42 +269,6 @@ void SettingsBase::setLayoutInterval(Seconds layoutInterval)
     m_layoutInterval = std::max(layoutInterval, layoutScheduleThreshold);
 }
 
     m_layoutInterval = std::max(layoutInterval, layoutScheduleThreshold);
 }
 
-void SettingsBase::setUsesPageCache(bool usesPageCache)
-{
-    if (m_usesPageCache == usesPageCache)
-        return;
-        
-    m_usesPageCache = usesPageCache;
-
-    if (!m_page)
-        return;
-
-    if (!m_usesPageCache)
-        PageCache::singleton().pruneToSizeNow(0, PruningReason::None);
-}
-
-void SettingsBase::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
-{
-    if (m_dnsPrefetchingEnabled == dnsPrefetchingEnabled)
-        return;
-
-    m_dnsPrefetchingEnabled = dnsPrefetchingEnabled;
-    if (m_page)
-        m_page->dnsPrefetchingStateChanged();
-}
-
-#if ENABLE(RESOURCE_USAGE)
-void SettingsBase::setResourceUsageOverlayVisible(bool visible)
-{
-    if (m_resourceUsageOverlayVisible == visible)
-        return;
-
-    m_resourceUsageOverlayVisible = visible;
-    if (m_page)
-        m_page->setResourceUsageOverlayVisible(visible);
-}
-#endif
-
 #if PLATFORM(WIN)
 void SettingsBase::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
 {
 #if PLATFORM(WIN)
 void SettingsBase::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
 {
@@ -414,27 +276,6 @@ void SettingsBase::setShouldUseHighResolutionTimers(bool shouldUseHighResolution
 }
 #endif
 
 }
 #endif
 
-void SettingsBase::setStorageBlockingPolicy(SecurityOrigin::StorageBlockingPolicy enabled)
-{
-    if (m_storageBlockingPolicy == enabled)
-        return;
-
-    m_storageBlockingPolicy = enabled;
-    if (m_page)
-        m_page->storageBlockingStateChanged();
-}
-
-void SettingsBase::setBackgroundShouldExtendBeyondPage(bool shouldExtend)
-{
-    if (m_backgroundShouldExtendBeyondPage == shouldExtend)
-        return;
-
-    m_backgroundShouldExtendBeyondPage = shouldExtend;
-
-    if (m_page)
-        m_page->mainFrame().view()->updateExtendBackgroundIfNecessary();
-}
-
 #if USE(AVFOUNDATION)
 void SettingsBase::setAVFoundationEnabled(bool enabled)
 {
 #if USE(AVFOUNDATION)
 void SettingsBase::setAVFoundationEnabled(bool enabled)
 {
@@ -499,14 +340,6 @@ void SettingsBase::setMediaCaptureRequiresSecureConnection(bool mediaCaptureRequ
 }
 #endif
 
 }
 #endif
 
-void SettingsBase::setScrollingPerformanceLoggingEnabled(bool enabled)
-{
-    m_scrollingPerformanceLoggingEnabled = enabled;
-
-    if (m_page && m_page->mainFrame().view())
-        m_page->mainFrame().view()->setScrollingPerformanceLoggingEnabled(enabled);
-}
-
 // It's very important that this setting doesn't change in the middle of a document's lifetime.
 // The Mac port uses this flag when registering and deregistering platform-dependent scrollbar
 // objects. Therefore, if this changes at an unexpected time, deregistration may not happen
 // It's very important that this setting doesn't change in the middle of a document's lifetime.
 // The Mac port uses this flag when registering and deregistering platform-dependent scrollbar
 // objects. Therefore, if this changes at an unexpected time, deregistration may not happen
@@ -553,33 +386,6 @@ bool SettingsBase::shouldRespectPriorityInCSSAttributeSetters()
     return gShouldRespectPriorityInCSSAttributeSetters;
 }
 
     return gShouldRespectPriorityInCSSAttributeSetters;
 }
 
-void SettingsBase::setHiddenPageDOMTimerThrottlingEnabled(bool flag)
-{
-    if (m_hiddenPageDOMTimerThrottlingEnabled == flag)
-        return;
-    m_hiddenPageDOMTimerThrottlingEnabled = flag;
-    if (m_page)
-        m_page->hiddenPageDOMTimerThrottlingStateChanged();
-}
-
-void SettingsBase::setHiddenPageDOMTimerThrottlingAutoIncreases(bool flag)
-{
-    if (m_hiddenPageDOMTimerThrottlingAutoIncreases == flag)
-        return;
-    m_hiddenPageDOMTimerThrottlingAutoIncreases = flag;
-    if (m_page)
-        m_page->hiddenPageDOMTimerThrottlingStateChanged();
-}
-
-void SettingsBase::setHiddenPageCSSAnimationSuspensionEnabled(bool flag)
-{
-    if (m_hiddenPageCSSAnimationSuspensionEnabled == flag)
-        return;
-    m_hiddenPageCSSAnimationSuspensionEnabled = flag;
-    if (m_page)
-        m_page->hiddenPageCSSAnimationSuspensionStateChanged();
-}
-
 void SettingsBase::setLowPowerVideoAudioBufferSizeEnabled(bool flag)
 {
     gLowPowerVideoAudioBufferSizeEnabled = flag;
 void SettingsBase::setLowPowerVideoAudioBufferSizeEnabled(bool flag)
 {
     gLowPowerVideoAudioBufferSizeEnabled = flag;
@@ -668,4 +474,122 @@ void SettingsBase::setMediaContentTypesRequiringHardwareSupport(const Vector<Con
     m_mediaContentTypesRequiringHardwareSupport = contentTypes;
 }
 
     m_mediaContentTypesRequiringHardwareSupport = contentTypes;
 }
 
+
+
+// MARK - onChange handlers
+
+void SettingsBase::setNeedsRecalcStyleInAllFrames()
+{
+    if (m_page)
+        m_page->setNeedsRecalcStyleInAllFrames();
+}
+
+void SettingsBase::mediaTypeOverrideChanged()
+{
+    if (!m_page)
+        return;
+
+    FrameView* view = m_page->mainFrame().view();
+    if (view)
+        view->setMediaType(m_page->settings().mediaTypeOverride());
+
+    m_page->setNeedsRecalcStyleInAllFrames();
+}
+
+void SettingsBase::imagesEnabledChanged()
+{
+    // Changing this setting to true might immediately start new loads for images that had previously had loading disabled.
+    // If this happens while a WebView is being dealloc'ed, and we don't know the WebView is being dealloc'ed, these new loads
+    // can cause crashes downstream when the WebView memory has actually been free'd.
+    // One example where this can happen is in Mac apps that subclass WebView then do work in their overridden dealloc methods.
+    // Starting these loads synchronously is not important. By putting it on a 0-delay, properly closing the Page cancels them
+    // before they have a chance to really start.
+    // See http://webkit.org/b/60572 for more discussion.
+    m_setImageLoadingSettingsTimer.startOneShot(0_s);
+}
+
+void SettingsBase::imageLoadingSettingsTimerFired()
+{
+    if (!m_page)
+        return;
+
+    for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+        if (!frame->document())
+            continue;
+        frame->document()->cachedResourceLoader().setImagesEnabled(m_page->settings().areImagesEnabled());
+        frame->document()->cachedResourceLoader().setAutoLoadImages(m_page->settings().loadsImagesAutomatically());
+    }
+}
+
+void SettingsBase::scriptEnabledChanged()
+{
+#if PLATFORM(IOS)
+    // FIXME: Why do we only do this on iOS?
+    if (m_page)
+        m_page->setNeedsRecalcStyleInAllFrames();
+#endif
+}
+
+void SettingsBase::pluginsEnabledChanged()
+{
+    Page::refreshPlugins(false);
+}
+
+void SettingsBase::userStyleSheetLocationChanged()
+{
+    if (m_page)
+        m_page->userStyleSheetLocationChanged();
+}
+
+void SettingsBase::usesPageCacheChanged()
+{
+    if (!m_page)
+        return;
+
+    if (!m_page->settings().usesPageCache())
+        PageCache::singleton().pruneToSizeNow(0, PruningReason::None);
+}
+
+void SettingsBase::dnsPrefetchingEnabledChanged()
+{
+    if (m_page)
+        m_page->dnsPrefetchingStateChanged();
+}
+
+void SettingsBase::resourceUsageOverlayVisibleChanged()
+{
+    if (m_page)
+        m_page->setResourceUsageOverlayVisible(m_page->settings().resourceUsageOverlayVisible());
+}
+
+void SettingsBase::storageBlockingPolicyChanged()
+{
+    if (m_page)
+        m_page->storageBlockingStateChanged();
+}
+
+void SettingsBase::backgroundShouldExtendBeyondPageChanged()
+{
+    if (m_page)
+        m_page->mainFrame().view()->updateExtendBackgroundIfNecessary();
+}
+
+void SettingsBase::scrollingPerformanceLoggingEnabledChanged()
+{
+    if (m_page && m_page->mainFrame().view())
+        m_page->mainFrame().view()->setScrollingPerformanceLoggingEnabled(m_page->settings().scrollingPerformanceLoggingEnabled());
+}
+
+void SettingsBase::hiddenPageDOMTimerThrottlingStateChanged()
+{
+    if (m_page)
+        m_page->hiddenPageDOMTimerThrottlingStateChanged();
+}
+
+void SettingsBase::hiddenPageCSSAnimationSuspensionEnabledChanged()
+{
+    if (m_page)
+        m_page->hiddenPageCSSAnimationSuspensionStateChanged();
+}
+
 } // namespace WebCore
 } // namespace WebCore
index 47b7fe5..e17dd6c 100644 (file)
@@ -131,55 +131,15 @@ public:
     WEBCORE_EXPORT void setPictographFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
     WEBCORE_EXPORT const AtomicString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
     WEBCORE_EXPORT void setPictographFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
     WEBCORE_EXPORT const AtomicString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-    WEBCORE_EXPORT static bool defaultTextAutosizingEnabled();
-    WEBCORE_EXPORT static float defaultMinimumZoomFontSize();
-
-    // Only set by Layout Tests.
-    WEBCORE_EXPORT void setMediaTypeOverride(const String&);
-    const String& mediaTypeOverride() const { return m_mediaTypeOverride; }
-
-    // Unlike areImagesEnabled, this only suppresses the network load of
-    // the image URL.  A cached image will still be rendered if requested.
-    WEBCORE_EXPORT void setLoadsImagesAutomatically(bool);
-    bool loadsImagesAutomatically() const { return m_loadsImagesAutomatically; }
-
-    // Clients that execute script should call ScriptController::canExecuteScripts()
-    // instead of this function. ScriptController::canExecuteScripts() checks the
-    // HTML sandbox, plug-in sandboxing, and other important details.
-    bool isScriptEnabled() const { return m_isScriptEnabled; }
-    WEBCORE_EXPORT void setScriptEnabled(bool);
-
-
-    WEBCORE_EXPORT void setImagesEnabled(bool);
-    bool areImagesEnabled() const { return m_areImagesEnabled; }
-
-    WEBCORE_EXPORT void setPluginsEnabled(bool);
-    bool arePluginsEnabled() const { return m_arePluginsEnabled; }
-
-    WEBCORE_EXPORT void setDNSPrefetchingEnabled(bool);
-    bool dnsPrefetchingEnabled() const { return m_dnsPrefetchingEnabled; }
-
-    WEBCORE_EXPORT void setUserStyleSheetLocation(const URL&);
-    const URL& userStyleSheetLocation() const { return m_userStyleSheetLocation; }
-
     WEBCORE_EXPORT void setMinimumDOMTimerInterval(Seconds); // Initialized to DOMTimer::defaultMinimumInterval().
     Seconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; }
 
     WEBCORE_EXPORT void setLayoutInterval(Seconds);
     Seconds layoutInterval() const { return m_layoutInterval; }
 
     WEBCORE_EXPORT void setMinimumDOMTimerInterval(Seconds); // Initialized to DOMTimer::defaultMinimumInterval().
     Seconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; }
 
     WEBCORE_EXPORT void setLayoutInterval(Seconds);
     Seconds layoutInterval() const { return m_layoutInterval; }
 
-    bool hiddenPageDOMTimerThrottlingEnabled() const { return m_hiddenPageDOMTimerThrottlingEnabled; }
-    WEBCORE_EXPORT void setHiddenPageDOMTimerThrottlingEnabled(bool);
-    bool hiddenPageDOMTimerThrottlingAutoIncreases() const { return m_hiddenPageDOMTimerThrottlingAutoIncreases; }
-    WEBCORE_EXPORT void setHiddenPageDOMTimerThrottlingAutoIncreases(bool);
-
-    WEBCORE_EXPORT void setUsesPageCache(bool);
-    bool usesPageCache() const { return m_usesPageCache; }
-        
-#if ENABLE(RESOURCE_USAGE)
-    bool resourceUsageOverlayVisible() const { return m_resourceUsageOverlayVisible; }
-    WEBCORE_EXPORT void setResourceUsageOverlayVisible(bool);
-#endif
+
+    WEBCORE_EXPORT static bool defaultTextAutosizingEnabled();
+    WEBCORE_EXPORT static float defaultMinimumZoomFontSize();
 
 #if PLATFORM(WIN)
     static void setShouldUseHighResolutionTimers(bool);
 
 #if PLATFORM(WIN)
     static void setShouldUseHighResolutionTimers(bool);
@@ -195,9 +155,6 @@ public:
 
     static bool globalConstRedeclarationShouldThrow();
 
 
     static bool globalConstRedeclarationShouldThrow();
 
-    WEBCORE_EXPORT void setBackgroundShouldExtendBeyondPage(bool);
-    bool backgroundShouldExtendBeyondPage() const { return m_backgroundShouldExtendBeyondPage; }
-
 #if USE(AVFOUNDATION)
     WEBCORE_EXPORT static void setAVFoundationEnabled(bool flag);
     static bool isAVFoundationEnabled() { return gAVFoundationEnabled; }
 #if USE(AVFOUNDATION)
     WEBCORE_EXPORT static void setAVFoundationEnabled(bool flag);
     static bool isAVFoundationEnabled() { return gAVFoundationEnabled; }
@@ -229,18 +186,9 @@ public:
     WEBCORE_EXPORT static void setUsesMockScrollAnimator(bool);
     static bool usesMockScrollAnimator();
 
     WEBCORE_EXPORT static void setUsesMockScrollAnimator(bool);
     static bool usesMockScrollAnimator();
 
-    WEBCORE_EXPORT void setStorageBlockingPolicy(SecurityOrigin::StorageBlockingPolicy);
-    SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy() const { return m_storageBlockingPolicy; }
-
-    WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool);
-    bool scrollingPerformanceLoggingEnabled() { return m_scrollingPerformanceLoggingEnabled; }
-
     WEBCORE_EXPORT static void setShouldRespectPriorityInCSSAttributeSetters(bool);
     static bool shouldRespectPriorityInCSSAttributeSetters();
 
     WEBCORE_EXPORT static void setShouldRespectPriorityInCSSAttributeSetters(bool);
     static bool shouldRespectPriorityInCSSAttributeSetters();
 
-    bool hiddenPageCSSAnimationSuspensionEnabled() const { return m_hiddenPageCSSAnimationSuspensionEnabled; }
-    WEBCORE_EXPORT void setHiddenPageCSSAnimationSuspensionEnabled(bool);
-
     static bool lowPowerVideoAudioBufferSizeEnabled() { return gLowPowerVideoAudioBufferSizeEnabled; }
     WEBCORE_EXPORT static void setLowPowerVideoAudioBufferSizeEnabled(bool);
 
     static bool lowPowerVideoAudioBufferSizeEnabled() { return gLowPowerVideoAudioBufferSizeEnabled; }
     WEBCORE_EXPORT static void setLowPowerVideoAudioBufferSizeEnabled(bool);
 
@@ -296,36 +244,33 @@ protected:
 
     void initializeDefaultFontFamilies();
 
 
     void initializeDefaultFontFamilies();
 
+    void imageLoadingSettingsTimerFired();
+
+    // Helpers used by generated Settings.cpp.
+    void setNeedsRecalcStyleInAllFrames();
+    void mediaTypeOverrideChanged();
+    void imagesEnabledChanged();
+    void scriptEnabledChanged();
+    void pluginsEnabledChanged();
+    void userStyleSheetLocationChanged();
+    void usesPageCacheChanged();
+    void dnsPrefetchingEnabledChanged();
+    void resourceUsageOverlayVisibleChanged();
+    void storageBlockingPolicyChanged();
+    void backgroundShouldExtendBeyondPageChanged();
+    void scrollingPerformanceLoggingEnabledChanged();
+    void hiddenPageDOMTimerThrottlingStateChanged();
+    void hiddenPageCSSAnimationSuspensionEnabledChanged();
+
     Page* m_page;
 
     Page* m_page;
 
-    String m_mediaTypeOverride { "screen" };
-    URL m_userStyleSheetLocation;
     const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies;
     const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies;
-    SecurityOrigin::StorageBlockingPolicy m_storageBlockingPolicy { SecurityOrigin::AllowAllStorage };
     Seconds m_layoutInterval;
     Seconds m_minimumDOMTimerInterval;
 
     Seconds m_layoutInterval;
     Seconds m_minimumDOMTimerInterval;
 
-    bool m_loadsImagesAutomatically : 1;
-    bool m_areImagesEnabled : 1;
-    bool m_arePluginsEnabled : 1;
-    bool m_isScriptEnabled : 1;
-    bool m_usesPageCache : 1;
-    bool m_showTiledScrollingIndicator : 1;
-    bool m_backgroundShouldExtendBeyondPage : 1;
-    bool m_dnsPrefetchingEnabled : 1;
-    bool m_scrollingPerformanceLoggingEnabled : 1;
-
     Timer m_setImageLoadingSettingsTimer;
     Timer m_setImageLoadingSettingsTimer;
-    void imageLoadingSettingsTimerFired();
-
-    bool m_hiddenPageDOMTimerThrottlingEnabled : 1;
-    bool m_hiddenPageCSSAnimationSuspensionEnabled : 1;
-
-#if ENABLE(RESOURCE_USAGE)
-    bool m_resourceUsageOverlayVisible { false };
-#endif
 
 
-    bool m_hiddenPageDOMTimerThrottlingAutoIncreases { false };
+    Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport;
 
 #if USE(AVFOUNDATION)
     WEBCORE_EXPORT static bool gAVFoundationEnabled;
 
 #if USE(AVFOUNDATION)
     WEBCORE_EXPORT static bool gAVFoundationEnabled;
@@ -364,8 +309,6 @@ protected:
     static bool gLowPowerVideoAudioBufferSizeEnabled;
     static bool gResourceLoadStatisticsEnabledEnabled;
     static bool gAllowsAnySSLCertificate;
     static bool gLowPowerVideoAudioBufferSizeEnabled;
     static bool gResourceLoadStatisticsEnabledEnabled;
     static bool gAllowsAnySSLCertificate;
-
-    Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport;
 };
 
 inline bool SettingsBase::isPostLoadCPUUsageMeasurementEnabled()
 };
 
 inline bool SettingsBase::isPostLoadCPUUsageMeasurementEnabled()