ViewportConfiguration functions should return a bool to say if anything changed
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Dec 2015 03:48:34 +0000 (03:48 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Dec 2015 03:48:34 +0000 (03:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152353

Reviewed by Tim Horton.

Rather than callers all checking whether setting ViewportConfiguration values
changes state, have its functions return a bool if the values change.

Source/WebCore:

* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::setContentsSize):
(WebCore::ViewportConfiguration::setMinimumLayoutSize):
(WebCore::ViewportConfiguration::setViewportArguments):
(WebCore::ViewportConfiguration::setCanIgnoreScalingConstraints):
* page/ViewportConfiguration.h:
(WebCore::ViewportConfiguration::setCanIgnoreScalingConstraints): Deleted.

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mainFrameDidLayout):
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::viewportPropertiesDidChange):
(WebKit::WebPage::setViewportConfigurationMinimumLayoutSize):

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

Source/WebCore/ChangeLog
Source/WebCore/page/ViewportConfiguration.cpp
Source/WebCore/page/ViewportConfiguration.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 9afe930..ed6416a 100644 (file)
@@ -1,3 +1,21 @@
+2015-12-16  Simon Fraser  <simon.fraser@apple.com>
+
+        ViewportConfiguration functions should return a bool to say if anything changed
+        https://bugs.webkit.org/show_bug.cgi?id=152353
+
+        Reviewed by Tim Horton.
+
+        Rather than callers all checking whether setting ViewportConfiguration values
+        changes state, have its functions return a bool if the values change.
+
+        * page/ViewportConfiguration.cpp:
+        (WebCore::ViewportConfiguration::setContentsSize):
+        (WebCore::ViewportConfiguration::setMinimumLayoutSize):
+        (WebCore::ViewportConfiguration::setViewportArguments):
+        (WebCore::ViewportConfiguration::setCanIgnoreScalingConstraints):
+        * page/ViewportConfiguration.h:
+        (WebCore::ViewportConfiguration::setCanIgnoreScalingConstraints): Deleted.
+
 2015-12-16  Andreas Kling  <akling@apple.com>
 
         Give kernel VM some hints about non-live memory-cached resources.
index 483412c..a3b4c6c 100644 (file)
@@ -66,31 +66,44 @@ void ViewportConfiguration::setDefaultConfiguration(const ViewportConfiguration:
     updateConfiguration();
 }
 
-void ViewportConfiguration::setContentsSize(const IntSize& contentSize)
+bool ViewportConfiguration::setContentsSize(const IntSize& contentSize)
 {
     if (m_contentSize == contentSize)
-        return;
+        return false;
 
     m_contentSize = contentSize;
     updateConfiguration();
+    return true;
 }
 
-void ViewportConfiguration::setMinimumLayoutSize(const FloatSize& minimumLayoutSize)
+bool ViewportConfiguration::setMinimumLayoutSize(const FloatSize& minimumLayoutSize)
 {
     if (m_minimumLayoutSize == minimumLayoutSize)
-        return;
+        return false;
 
     m_minimumLayoutSize = minimumLayoutSize;
     updateConfiguration();
+    return true;
 }
 
-void ViewportConfiguration::setViewportArguments(const ViewportArguments& viewportArguments)
+bool ViewportConfiguration::setViewportArguments(const ViewportArguments& viewportArguments)
 {
     if (m_viewportArguments == viewportArguments)
-        return;
+        return false;
 
     m_viewportArguments = viewportArguments;
     updateConfiguration();
+    return true;
+}
+
+bool ViewportConfiguration::setCanIgnoreScalingConstraints(bool canIgnoreScalingConstraints)
+{
+    if (canIgnoreScalingConstraints == m_canIgnoreScalingConstraints)
+        return false;
+    
+    m_canIgnoreScalingConstraints = canIgnoreScalingConstraints;
+    updateConfiguration();
+    return true;
 }
 
 IntSize ViewportConfiguration::layoutSize() const
index dc29834..a0fbdc3 100644 (file)
@@ -73,15 +73,15 @@ public:
     WEBCORE_EXPORT void setDefaultConfiguration(const Parameters&);
 
     const IntSize& contentsSize() const { return m_contentSize; }
-    WEBCORE_EXPORT void setContentsSize(const IntSize&);
+    WEBCORE_EXPORT bool setContentsSize(const IntSize&);
 
     const FloatSize& minimumLayoutSize() const { return m_minimumLayoutSize; }
-    WEBCORE_EXPORT void setMinimumLayoutSize(const FloatSize&);
+    WEBCORE_EXPORT bool setMinimumLayoutSize(const FloatSize&);
 
     const ViewportArguments& viewportArguments() const { return m_viewportArguments; }
-    WEBCORE_EXPORT void setViewportArguments(const ViewportArguments&);
+    WEBCORE_EXPORT bool setViewportArguments(const ViewportArguments&);
 
-    void setCanIgnoreScalingConstraints(bool canIgnoreScalingConstraints) { m_canIgnoreScalingConstraints = canIgnoreScalingConstraints; }
+    WEBCORE_EXPORT bool setCanIgnoreScalingConstraints(bool);
     void setForceAlwaysUserScalable(bool forceAlwaysUserScalable) { m_forceAlwaysUserScalable = forceAlwaysUserScalable; }
 
     WEBCORE_EXPORT IntSize layoutSize() const;
index 01a907e..8dbed6d 100644 (file)
@@ -1,3 +1,20 @@
+2015-12-16  Simon Fraser  <simon.fraser@apple.com>
+
+        ViewportConfiguration functions should return a bool to say if anything changed
+        https://bugs.webkit.org/show_bug.cgi?id=152353
+
+        Reviewed by Tim Horton.
+
+        Rather than callers all checking whether setting ViewportConfiguration values
+        changes state, have its functions return a bool if the values change.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::mainFrameDidLayout):
+        (WebKit::WebPage::didCommitLoad):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::viewportPropertiesDidChange):
+        (WebKit::WebPage::setViewportConfigurationMinimumLayoutSize):
+
 2015-12-16  Tim Horton  <timothy_horton@apple.com>
 
         REGRESSION (r191299): Zoom gestures are enabled even if allowsMagnification=NO
index e14275d..edd1eca 100644 (file)
@@ -3536,10 +3536,8 @@ void WebPage::mainFrameDidLayout()
 #if PLATFORM(IOS)
     if (FrameView* frameView = mainFrameView()) {
         IntSize newContentSize = frameView->contentsSizeRespectingOverflow();
-        if (m_viewportConfiguration.contentsSize() != newContentSize) {
-            m_viewportConfiguration.setContentsSize(newContentSize);
+        if (m_viewportConfiguration.setContentsSize(newContentSize))
             viewportConfigurationChanged();
-        }
     }
     m_findController.redraw();
 #endif
@@ -4685,9 +4683,16 @@ void WebPage::didCommitLoad(WebFrame* frame)
 
     resetViewportDefaultConfiguration(frame);
     const Frame* coreFrame = frame->coreFrame();
-    m_viewportConfiguration.setContentsSize(coreFrame->view()->contentsSize());
-    m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments());
-    viewportConfigurationChanged();
+    
+    bool viewportChanged = false;
+    if (m_viewportConfiguration.setContentsSize(coreFrame->view()->contentsSize()))
+        viewportChanged = true;
+
+    if (m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments()))
+        viewportChanged = true;
+
+    if (viewportChanged)
+        viewportConfigurationChanged();
 #endif
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
index 5cbf570..9df5d09 100644 (file)
@@ -228,11 +228,8 @@ FloatSize WebPage::availableScreenSize() const
 
 void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArguments)
 {
-    if (m_viewportConfiguration.viewportArguments() == viewportArguments)
-        return;
-
-    m_viewportConfiguration.setViewportArguments(viewportArguments);
-    viewportConfigurationChanged();
+    if (m_viewportConfiguration.setViewportArguments(viewportArguments))
+        viewportConfigurationChanged();
 }
 
 void WebPage::didReceiveMobileDocType(bool isMobileDoctype)
@@ -2539,8 +2536,9 @@ void WebPage::elementDidBlur(WebCore::Node* node)
 void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size)
 {
     resetTextAutosizingBeforeLayoutIfNeeded(m_viewportConfiguration.minimumLayoutSize(), size);
-    m_viewportConfiguration.setMinimumLayoutSize(size);
-    viewportConfigurationChanged();
+    
+    if (m_viewportConfiguration.setMinimumLayoutSize(size))
+        viewportConfigurationChanged();
 }
 
 void WebPage::setMaximumUnobscuredSize(const FloatSize& maximumUnobscuredSize)