Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add WebKit2 API to force a repaint with an invalidation
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.



Canonical link: https://commits.webkit.org/69311@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Feb 23, 2011
1 parent cf9d6db commit 49a9815
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 9 deletions.
29 changes: 29 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -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.
Expand Down
38 changes: 38 additions & 0 deletions Source/WebKit2/Shared/ForceRepaintFlags.h
@@ -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
11 changes: 10 additions & 1 deletion Source/WebKit2/UIProcess/API/C/WKPage.cpp
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit2/UIProcess/API/C/WKPage.h
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit2/UIProcess/WebPageProxy.cpp
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit2/UIProcess/WebPageProxy.h
Expand Up @@ -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"
Expand Down Expand Up @@ -300,7 +301,7 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
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*);
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/WebKit2.pro
Expand Up @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Expand Up @@ -457,6 +457,7 @@
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 */; };
Expand Down Expand Up @@ -1269,6 +1270,7 @@
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>"; };
Expand Down Expand Up @@ -1877,6 +1879,7 @@
C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
BC3C8C7E1314AC8700585C8C /* ForceRepaintFlags.h */,
BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
BC64696D11DBE603006455B0 /* ImmutableArray.cpp */,
BC64696E11DBE603006455B0 /* ImmutableArray.h */,
Expand Down Expand Up @@ -3299,6 +3302,7 @@
33367656130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h in Headers */,
33367658130C9ECB006C9DE2 /* WebResourceCacheManagerProxyMessages.h in Headers */,
33152976130D0CB200ED2483 /* SecurityOriginData.h in Headers */,
BC3C8C7F1314AC8700585C8C /* ForceRepaintFlags.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.h
Expand Up @@ -406,7 +406,7 @@ class WebPage : public APIObject, public CoreIPC::MessageSender<WebPage> {
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&);
Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit2/win/WebKit2.vcproj
Expand Up @@ -426,6 +426,10 @@
RelativePath="..\Shared\FontSmoothingLevel.h"
>
</File>
<File
RelativePath="..\Shared\ForceRepaintFlags.h"
>
</File>
<File
RelativePath="..\Shared\ImmutableArray.cpp"
>
Expand Down

0 comments on commit 49a9815

Please sign in to comment.