Inform the UIProcess when main frame scrollbars change
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2011 22:32:14 +0000 (22:32 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2011 22:32:14 +0000 (22:32 +0000)
<rdar://problem/8967496>
https://bugs.webkit.org/show_bug.cgi?id=53941

Reviewed by Anders Carlsson.

* UIProcess/API/C/WKPage.cpp:
(WKPageHasHorizontalScrollbar):
(WKPageHasVerticalScrollbar):
* UIProcess/API/C/WKPage.h:
Add API to query whether the main frame has scrollbars.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::processDidCrash):
(WebKit::WebPageProxy::didChangeScrollbarsForMainFrame):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::hasHorizontalScrollbar):
(WebKit::WebPageProxy::hasVerticalScrollbar):
Store/update main frame scrollbar state.

* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::contentsSizeChanged):
* WebProcess/WebCoreSupport/WebChromeClient.h:
(WebKit::WebChromeClient::WebChromeClient):
Post message when main frame scrollbar state changes.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index 55f2d5ca94d058a73f979654117393e3c5567250..42d7a94ad44e9cb9dffbf98a8f68977009ced515 100644 (file)
@@ -1,3 +1,34 @@
+2011-02-07  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Inform the UIProcess when main frame scrollbars change
+        <rdar://problem/8967496>
+        https://bugs.webkit.org/show_bug.cgi?id=53941
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageHasHorizontalScrollbar):
+        (WKPageHasVerticalScrollbar):
+        * UIProcess/API/C/WKPage.h:
+        Add API to query whether the main frame has scrollbars.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::close):
+        (WebKit::WebPageProxy::processDidCrash):
+        (WebKit::WebPageProxy::didChangeScrollbarsForMainFrame):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::hasHorizontalScrollbar):
+        (WebKit::WebPageProxy::hasVerticalScrollbar):
+        Store/update main frame scrollbar state.
+
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::contentsSizeChanged):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        (WebKit::WebChromeClient::WebChromeClient):
+        Post message when main frame scrollbar state changes.
+
 2011-02-07  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index 8227ce58e448fdf47bc80a8e0ba4a598ce087903..1d5763f22c13b141b1f91c24238de550eb543a9a 100644 (file)
@@ -291,6 +291,16 @@ WKSize WKPageFixedLayoutSize(WKPageRef pageRef)
     return toAPI(toImpl(pageRef)->fixedLayoutSize());
 }
 
+bool WKPageHasHorizontalScrollbar(WKPageRef pageRef)
+{
+    return toImpl(pageRef)->hasHorizontalScrollbar();
+}
+
+bool WKPageHasVerticalScrollbar(WKPageRef pageRef)
+{
+    return toImpl(pageRef)->hasVerticalScrollbar();
+}
+
 void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
 {
     toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
index 64b623b38e0314f5b8dc6f9b1d31aca18561245e..a571572ec1166966c4f01f16920f95bfce02f66f 100644 (file)
@@ -307,8 +307,11 @@ WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
 
 WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
 WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
-WK_EXPORT bool WKPageUseFixedLayout(WKPageRef pageRef);
-WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef pageRef);
+WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
+WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
+
+WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
+WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
 
 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
 WK_EXPORT void WKPageHideFindUI(WKPageRef page);
index 142e2f3bac01b0024af6cd2d47279a3ae25d6752..efd2994fe7e40fc013828bc735c018f0933deb51 100644 (file)
@@ -132,6 +132,8 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, WebContext* context, WebPageG
     , m_pendingLearnOrIgnoreWordMessageCount(0)
     , m_mainFrameHasCustomRepresentation(false)
     , m_currentDragOperation(DragOperationNone)
+    , m_mainFrameHasHorizontalScrollbar(false)
+    , m_mainFrameHasVerticalScrollbar(false)
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -279,6 +281,9 @@ void WebPageProxy::close()
 
     m_toolTip = String();
 
+    m_mainFrameHasHorizontalScrollbar = false;
+    m_mainFrameHasVerticalScrollbar = false;
+
     invalidateCallbackMap(m_voidCallbacks);
     invalidateCallbackMap(m_dataCallbacks);
     invalidateCallbackMap(m_stringCallbacks);
@@ -2379,6 +2384,9 @@ void WebPageProxy::processDidCrash()
 
     m_toolTip = String();
 
+    m_mainFrameHasHorizontalScrollbar = false;
+    m_mainFrameHasVerticalScrollbar = false;
+
     invalidateCallbackMap(m_voidCallbacks);
     invalidateCallbackMap(m_dataCallbacks);
     invalidateCallbackMap(m_stringCallbacks);
@@ -2528,6 +2536,12 @@ void WebPageProxy::didCompleteRubberBandForMainFrame(const IntSize& initialOverh
     m_uiClient.didCompleteRubberBandForMainFrame(this, initialOverhang);
 }
 
+void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVecticalScrollbar)
+{
+    m_mainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
+    m_mainFrameHasVerticalScrollbar = hasVecticalScrollbar;
+}
+
 void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference)
 {
     m_pageClient->didFinishLoadingDataForCustomRepresentation(dataReference);
index 6c8532de602ada7bb8aab56e2d704d5e6af2e481..f33517caeeeaa8813d5f46eb9615c38c3060699d 100644 (file)
@@ -266,6 +266,9 @@ public:
     bool useFixedLayout() const { return m_useFixedLayout; };
     const WebCore::IntSize& fixedLayoutSize() const { return m_fixedLayoutSize; };
 
+    bool hasHorizontalScrollbar() const { return m_mainFrameHasHorizontalScrollbar; }
+    bool hasVerticalScrollbar() const { return m_mainFrameHasVerticalScrollbar; }
+
 #if PLATFORM(MAC)
     void sendAccessibilityPresenterToken(const CoreIPC::DataReference&);
 #endif
@@ -468,6 +471,7 @@ private:
     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
     void runModal() { m_uiClient.runModal(this); }
     void didCompleteRubberBandForMainFrame(const WebCore::IntSize&);
+    void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVecticalScrollbar);
 
     void reattachToWebProcess();
     void reattachToWebProcessWithItem(WebBackForwardListItem*);
@@ -667,6 +671,9 @@ private:
     WebCore::DragOperation m_currentDragOperation;
 
     String m_pendingAPIRequestURL;
+
+    bool m_mainFrameHasHorizontalScrollbar;
+    bool m_mainFrameHasVerticalScrollbar;
 };
 
 } // namespace WebKit
index 0d792f2cade5cfea6dcb2e7944d9e8c3ad42a93f..f97f3a8e7eb846b5d28697ee1101ee266717619f 100644 (file)
@@ -56,6 +56,7 @@ messages -> WebPageProxy {
     PrintFrame(uint64_t frameID) -> ()
     RunModal()
     DidCompleteRubberBandForMainFrame(WebCore::IntSize initialOverhang)
+    DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
 
 #if ENABLE(TILED_BACKING_STORE)
     PageDidRequestScroll(WebCore::IntSize delta)
index e5830222c7c972b1b057305ad823a809568b3940..1a6a575eb7f042c983ebdd563749fa505c0cd34b 100644 (file)
@@ -50,6 +50,7 @@
 #include <WebCore/FileChooser.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
+#include <WebCore/FrameView.h>
 #include <WebCore/HTMLNames.h>
 #include <WebCore/HTMLPlugInImageElement.h>
 #include <WebCore/Page.h>
@@ -418,7 +419,21 @@ void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) con
     WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
     if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
         m_cachedFrameSetLargestFrame = largestFrame;
-        WebProcess::shared().connection()->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0), m_page->pageID());
+        m_page->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
+    }
+
+    FrameView* frameView = frame->view();
+    if (!frameView)
+        return;
+
+    bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
+    bool hasVecticalScrollbar = frameView->verticalScrollbar();
+
+    if (hasHorizontalScrollbar != m_cachedHasHorizontalScrollbar || hasVecticalScrollbar != m_cachedHasVerticalScrollbar) {
+        m_page->send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVecticalScrollbar));
+        
+        m_cachedHasHorizontalScrollbar = hasHorizontalScrollbar;
+        m_cachedHasVerticalScrollbar = hasVecticalScrollbar;
     }
 }
 
index a5046ff549aec394a9465d09b8eced8c76d14b71..df32951875eff8d57e31e51b1e3a037845ae8550 100644 (file)
@@ -39,11 +39,14 @@ class WebPage;
 class WebChromeClient : public WebCore::ChromeClient {
 public:
     WebChromeClient(WebPage* page)
-        : m_page(page)
+        : m_cachedHasHorizontalScrollbar(false)
+        , m_cachedHasVerticalScrollbar(false)
+        , m_page(page)
     {
     }
     
     WebPage* page() const { return m_page; }
+
 private:
     virtual void chromeDestroyed();
     
@@ -209,6 +212,9 @@ private:
 
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
+    mutable bool m_cachedHasHorizontalScrollbar;
+    mutable bool m_cachedHasVerticalScrollbar;
+
     WebPage* m_page;
 };