Add WebKit2 API to force a repaint with an invalidation
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 03:35:58 +0000 (03:35 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 03:35:58 +0000 (03:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=55015

Reviewed by Anders Carlsson.

* Shared/ForceRepaintFlags.h: Added.
* UIProcess/API/C/WKPage.cpp:
(WKPageForceRepaint):
(WKPageForceRepaintWithInvalidation):
* UIProcess/API/C/WKPage.h:
Add WKPageForceRepaintWithInvalidation which does the same thing WKPageForceRepaint
but also calls setNeedsDisplay on the entire bounds of the page.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::forceRepaint):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::forceRepaint):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Pipe the flag down to the WebProcess.

* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
Add ForceRepaintFlags.h.

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

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/ForceRepaintFlags.h [new file with mode: 0644]
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/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/win/WebKit2.vcproj

index 10f4e72..6f1a868 100644 (file)
@@ -1,3 +1,32 @@
+2011-02-22  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Add WebKit2 API to force a repaint with an invalidation
+        https://bugs.webkit.org/show_bug.cgi?id=55015
+
+        * Shared/ForceRepaintFlags.h: Added.
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageForceRepaint):
+        (WKPageForceRepaintWithInvalidation):
+        * UIProcess/API/C/WKPage.h:
+        Add WKPageForceRepaintWithInvalidation which does the same thing WKPageForceRepaint
+        but also calls setNeedsDisplay on the entire bounds of the page.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::forceRepaint):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::forceRepaint):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Pipe the flag down to the WebProcess.
+
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add ForceRepaintFlags.h.
+
 2011-02-22  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/Source/WebKit2/Shared/ForceRepaintFlags.h b/Source/WebKit2/Shared/ForceRepaintFlags.h
new file mode 100644 (file)
index 0000000..f0b1aab
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ForceRepaintFlags_h
+#define ForceRepaintFlags_h
+
+namespace WebKit {
+
+enum ForceRepaintFlags {
+    ForceRepaintFlagsNone = 0,
+    ForceRepaintFlagsInvalidatePage = 1 << 0,
+};
+
+} // namespace WebKit
+
+#endif // ForceRepaintFlags_h
index b6c44aa..63a080f 100644 (file)
@@ -458,7 +458,16 @@ void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock
 
 void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
 {
-    toImpl(pageRef)->forceRepaint(VoidCallback::create(context, callback));
+    toImpl(pageRef)->forceRepaint(ForceRepaintFlagsNone, VoidCallback::create(context, callback));
+}
+
+static void voidForceRepaintFunction(WKErrorRef, void*)
+{
+}
+
+void WKPageForceRepaintWithInvalidation(WKPageRef pageRef)
+{
+    toImpl(pageRef)->forceRepaint(ForceRepaintFlagsInvalidatePage, VoidCallback::create(0, voidForceRepaintFunction));
 }
 
 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)
index 5a674fa..9a091c1 100644 (file)
@@ -269,6 +269,8 @@ WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
 
 WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
 
+WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
+
 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
 WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
 WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
@@ -357,7 +359,7 @@ WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsSt
 typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
 WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
 
-WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
+WK_EXPORT void WKPageForceRepaintWithInvalidation(WKPageRef page);
 
 #ifdef __cplusplus
 }
index 7db4c13..51d4660 100644 (file)
@@ -1163,7 +1163,7 @@ void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCal
     process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
 }
 
-void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
+void WebPageProxy::forceRepaint(ForceRepaintFlags flags, PassRefPtr<VoidCallback> prpCallback)
 {
     RefPtr<VoidCallback> callback = prpCallback;
 
@@ -1174,7 +1174,7 @@ void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
 
     uint64_t callbackID = callback->callbackID();
     m_voidCallbacks.set(callbackID, callback.get());
-    process()->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID); 
+    process()->send(Messages::WebPage::ForceRepaint(static_cast<unsigned>(flags), callbackID), m_pageID); 
 }
 
 #if PLATFORM(MAC)
index 2a9aaf8..33cc063 100644 (file)
@@ -30,6 +30,7 @@
 #include "ContextMenuState.h"
 #include "DragControllerAction.h"
 #include "DrawingAreaProxy.h"
+#include "ForceRepaintFlags.h"
 #include "GeolocationPermissionRequestManagerProxy.h"
 #include "SandboxExtension.h"
 #include "SelectionState.h"
@@ -300,7 +301,7 @@ public:
     void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>);
     void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>);
     void runJavaScriptInMainFrame(const String&, PassRefPtr<StringCallback>);
-    void forceRepaint(PassRefPtr<VoidCallback>);
+    void forceRepaint(ForceRepaintFlags, PassRefPtr<VoidCallback>);
 
     float headerHeight(WebFrameProxy*);
     float footerHeight(WebFrameProxy*);
index ee52b3c..581f1b6 100644 (file)
@@ -95,6 +95,7 @@ HEADERS += \
     Shared/ShareableBitmap.h \
     Shared/CacheModel.h \
     Shared/ChildProcess.h \
+    Shared/ForceRepaintFlags.h \
     Shared/CoreIPCSupport/DrawingAreaMessageKinds.h \
     Shared/CoreIPCSupport/DrawingAreaProxyMessageKinds.h \
     Shared/ImageOptions.h \
index f22c4f9..90a9d17 100644 (file)
                BC33DD681238464600360F3F /* WebNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = BC33DD671238464600360F3F /* WebNumber.h */; };
                BC33E0D112408E8600360F3F /* InjectedBundleRangeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC33E0CF12408E8600360F3F /* InjectedBundleRangeHandle.h */; };
                BC33E0D212408E8600360F3F /* InjectedBundleRangeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */; };
+               BC3C8C7F1314AC8700585C8C /* ForceRepaintFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C8C7E1314AC8700585C8C /* ForceRepaintFlags.h */; };
                BC4075F3124FF0270068F20A /* WKArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4075D7124FF0270068F20A /* WKArray.cpp */; };
                BC4075F4124FF0270068F20A /* WKArray.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4075D8124FF0270068F20A /* WKArray.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BC4075F5124FF0270068F20A /* WKCertificateInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4075D9124FF0270068F20A /* WKCertificateInfo.cpp */; };
                BC33DD671238464600360F3F /* WebNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNumber.h; sourceTree = "<group>"; };
                BC33E0CF12408E8600360F3F /* InjectedBundleRangeHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleRangeHandle.h; sourceTree = "<group>"; };
                BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleRangeHandle.cpp; sourceTree = "<group>"; };
+               BC3C8C7E1314AC8700585C8C /* ForceRepaintFlags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForceRepaintFlags.h; sourceTree = "<group>"; };
                BC4075D7124FF0270068F20A /* WKArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKArray.cpp; sourceTree = "<group>"; };
                BC4075D8124FF0270068F20A /* WKArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKArray.h; sourceTree = "<group>"; };
                BC4075D9124FF0270068F20A /* WKCertificateInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKCertificateInfo.cpp; sourceTree = "<group>"; };
                                C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
                                0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
                                762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
+                               BC3C8C7E1314AC8700585C8C /* ForceRepaintFlags.h */,
                                BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
                                BC64696D11DBE603006455B0 /* ImmutableArray.cpp */,
                                BC64696E11DBE603006455B0 /* ImmutableArray.h */,
                                33367656130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h in Headers */,
                                33367658130C9ECB006C9DE2 /* WebResourceCacheManagerProxyMessages.h in Headers */,
                                33152976130D0CB200ED2483 /* SecurityOriginData.h in Headers */,
+                               BC3C8C7F1314AC8700585C8C /* ForceRepaintFlags.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index e491230..3c9d486 100644 (file)
@@ -30,6 +30,7 @@
 #include "DataReference.h"
 #include "DecoderAdapter.h"
 #include "DrawingArea.h"
+#include "ForceRepaintFlags.h"
 #include "InjectedBundle.h"
 #include "InjectedBundleBackForwardList.h"
 #include "MessageID.h"
@@ -1315,8 +1316,12 @@ void WebPage::getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID)
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
 
-void WebPage::forceRepaint(uint64_t callbackID)
+void WebPage::forceRepaint(uint32_t opaqueRepaintFlags, uint64_t callbackID)
 {
+    ForceRepaintFlags repaintFlags = static_cast<ForceRepaintFlags>(opaqueRepaintFlags);
+    if (repaintFlags & ForceRepaintFlagsInvalidatePage)
+        m_drawingArea->setNeedsDisplay(bounds());
+
     m_drawingArea->forceRepaint();
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
index 774d164..20b0977 100644 (file)
@@ -406,7 +406,7 @@ private:
     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
-    void forceRepaint(uint64_t callbackID);
+    void forceRepaint(uint32_t repaintFlags, uint64_t callbackID);
 
     void preferencesDidChange(const WebPreferencesStore&);
     void platformPreferencesDidChange(const WebPreferencesStore&);
index 55ec8bc..66eebea 100644 (file)
@@ -71,8 +71,7 @@ messages -> WebPage {
     GetWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID)
     RunJavaScriptInMainFrame(WTF::String script, uint64_t callbackID)
 
-    # FIXME: This should be a drawing area message.
-    ForceRepaint(uint64_t callbackID)
+    ForceRepaint(uint32_t repaintFlags, uint64_t callbackID)
 
 #if PLATFORM(MAC)
     # Dictionary support.
index cbb9031..ff1d932 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\Shared\ForceRepaintFlags.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\Shared\ImmutableArray.cpp"
                                >
                        </File>