Skip to content
Permalink
Browse files
Add a way to flash backing store and view updates
The new WKPageSetDebugPaintFlags SPI can be used to control whether backing store and/or
view updates are flashed. A blueish color is used for view updates, and a purpleish color is
used for backing store updates. The flashing currently only works on Windows.

Fixes <http://webkit.org/b/54303>.

Reviewed by Anders Carlsson.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetDebugPaintFlags):
(WKPageGetDebugPaintFlags):
* UIProcess/API/C/WKPagePrivate.h:
Added. These call through to WebPageProxy.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::flashBackingStoreUpdates):
* UIProcess/API/qt/qwkpage.cpp:
(QWKPagePrivate::flashBackingStoreUpdates):
* UIProcess/API/qt/qwkpage_p.h:
Stubbed out new PageClient functions.

* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::incorporateUpdate): Tell the WebPageProxy to flash the
backing store updates we're performing.

* UIProcess/PageClient.h: Added flashBackingStoreUpdates.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::flashBackingStoreUpdates): Call through to the PageClient.
(WebKit::WebPageProxy::viewUpdatesFlashColor): Return the blueish color used for view
updates.
(WebKit::WebPageProxy::backingStoreUpdatesFlashColor): Return the purpleish color used for
backing store updates.

* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::setDebugPaintFlags):
(WebKit::WebPageProxy::debugPaintFlags):
Added these simple accessors.

* UIProcess/win/WebView.cpp:
(WebKit::flashRects):
(WebKit::createBrush):
New helper functions.

(WebKit::WebView::onPaintEvent): Flash the dirty region if requested.
(WebKit::WebView::flashBackingStoreUpdates): Added. Calls through to flashRects.

* UIProcess/win/WebView.h: Added flashBackingStoreUpdates.

* win/WebKit2Generated.make: Export WKPagePrivate.h so clients can use it.

Canonical link: https://commits.webkit.org/68488@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@78488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aroben committed Feb 14, 2011
1 parent 79069cf commit 6b1bdf80ffdb00f4227a183e7b3d7d97d93670c6
@@ -1,3 +1,59 @@
2011-02-14 Adam Roben <aroben@apple.com>

Add a way to flash backing store and view updates

The new WKPageSetDebugPaintFlags SPI can be used to control whether backing store and/or
view updates are flashed. A blueish color is used for view updates, and a purpleish color is
used for backing store updates. The flashing currently only works on Windows.

Fixes <http://webkit.org/b/54303>.

Reviewed by Anders Carlsson.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetDebugPaintFlags):
(WKPageGetDebugPaintFlags):
* UIProcess/API/C/WKPagePrivate.h:
Added. These call through to WebPageProxy.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::flashBackingStoreUpdates):
* UIProcess/API/qt/qwkpage.cpp:
(QWKPagePrivate::flashBackingStoreUpdates):
* UIProcess/API/qt/qwkpage_p.h:
Stubbed out new PageClient functions.

* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::incorporateUpdate): Tell the WebPageProxy to flash the
backing store updates we're performing.

* UIProcess/PageClient.h: Added flashBackingStoreUpdates.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::flashBackingStoreUpdates): Call through to the PageClient.
(WebKit::WebPageProxy::viewUpdatesFlashColor): Return the blueish color used for view
updates.
(WebKit::WebPageProxy::backingStoreUpdatesFlashColor): Return the purpleish color used for
backing store updates.

* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::setDebugPaintFlags):
(WebKit::WebPageProxy::debugPaintFlags):
Added these simple accessors.

* UIProcess/win/WebView.cpp:
(WebKit::flashRects):
(WebKit::createBrush):
New helper functions.

(WebKit::WebView::onPaintEvent): Flash the dirty region if requested.
(WebKit::WebView::flashBackingStoreUpdates): Added. Calls through to flashRects.

* UIProcess/win/WebView.h: Added flashBackingStoreUpdates.

* win/WebKit2Generated.make: Export WKPagePrivate.h so clients can use it.

2011-02-14 Adam Roben <aroben@apple.com>

Add some .messages.in and script files to WebKit2 projects
@@ -452,3 +452,13 @@ WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)
return 0;
return toCopiedURLAPI(toImpl(pageRef)->pendingAPIRequestURL());
}

void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags)
{
WebPageProxy::setDebugPaintFlags(flags);
}

WKPageDebugPaintFlags WKPageGetDebugPaintFlags()
{
return WebPageProxy::debugPaintFlags();
}
@@ -41,6 +41,15 @@ typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKError
WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block);
#endif

enum {
kWKDebugFlashViewUpdates = 1 << 0,
kWKDebugFlashBackingStoreUpdates = 1 << 1
};
typedef unsigned WKPageDebugPaintFlags;

WK_EXPORT void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags);
WK_EXPORT WKPageDebugPaintFlags WKPageGetDebugPaintFlags(void);

#ifdef __cplusplus
}
#endif
@@ -105,6 +105,8 @@ class PageClientImpl : public PageClient {
virtual double customRepresentationZoomFactor();
virtual void setCustomRepresentationZoomFactor(double);

virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);

WKView* m_wkView;
RetainPtr<WebEditorUndoTargetObjC> m_undoTarget;
};
@@ -29,6 +29,7 @@
#import "DataReference.h"
#import "FindIndicator.h"
#import "NativeWebKeyboardEvent.h"
#import "NotImplemented.h"
#import "WKAPICast.h"
#import "WKStringCF.h"
#import "WKViewInternal.h"
@@ -407,4 +408,9 @@ - (void)redoEditing:(id)sender
[m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
}

void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
{
notImplemented();
}

} // namespace WebKit
@@ -34,6 +34,7 @@
#include "FindIndicator.h"
#include "LocalizedStrings.h"
#include "NativeWebKeyboardEvent.h"
#include "NotImplemented.h"
#include "TiledDrawingAreaProxy.h"
#include "WebContext.h"
#include "WebContextMenuProxyQt.h"
@@ -258,6 +259,11 @@ void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const CoreIPC::
{
}

void QWKPagePrivate::flashBackingStoreUpdates(const Vector<IntRect>&)
{
notImplemented();
}

void QWKPagePrivate::paint(QPainter* painter, QRect area)
{
if (page->isValid() && page->drawingArea())
@@ -92,6 +92,8 @@ class QWKPagePrivate : WebKit::PageClient {
virtual void setCustomRepresentationZoomFactor(double) { }
virtual void didChangeScrollbarsForMainFrame() const { }

virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);

void paint(QPainter* painter, QRect);

void keyPressEvent(QKeyEvent*);
@@ -208,10 +208,13 @@ void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)

if (shouldScroll)
m_webPageProxy->scrollView(updateInfo.scrollRect, updateInfo.scrollOffset);

for (size_t i = 0; i < updateInfo.updateRects.size(); ++i)
m_webPageProxy->setViewNeedsDisplay(updateInfo.updateRects[i]);

if (WebPageProxy::debugPaintFlags() & kWKDebugFlashBackingStoreUpdates)
m_webPageProxy->flashBackingStoreUpdates(updateInfo.updateRects);

if (shouldScroll)
m_webPageProxy->displayView();
}
@@ -142,6 +142,8 @@ class PageClient {
virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&) = 0;
virtual double customRepresentationZoomFactor() = 0;
virtual void setCustomRepresentationZoomFactor(double) = 0;

virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects) = 0;
};

} // namespace WebKit
@@ -92,6 +92,8 @@ using namespace WebCore;

namespace WebKit {

WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0;

#ifndef NDEBUG
static WTF::RefCountedLeakCounter webPageProxyCounter("WebPageProxy");
#endif
@@ -2726,4 +2728,19 @@ void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, uint32_t first, uint32_t
}
#endif

void WebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
{
m_pageClient->flashBackingStoreUpdates(updateRects);
}

Color WebPageProxy::viewUpdatesFlashColor()
{
return Color(0, 200, 255);
}

Color WebPageProxy::backingStoreUpdatesFlashColor()
{
return Color(200, 0, 255);
}

} // namespace WebKit
@@ -35,6 +35,7 @@
#include "SelectionState.h"
#include "SharedMemory.h"
#include "WKBase.h"
#include "WKPagePrivate.h"
#include "WebContextMenuItemData.h"
#include "WebEvent.h"
#include "WebFindClient.h"
@@ -396,6 +397,16 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {

const String& pendingAPIRequestURL() const { return m_pendingAPIRequestURL; }

void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);

static void setDebugPaintFlags(WKPageDebugPaintFlags flags) { s_debugPaintFlags = flags; }
static WKPageDebugPaintFlags debugPaintFlags() { return s_debugPaintFlags; }

// Color to be used with kWKDebugFlashViewUpdates.
static WebCore::Color viewUpdatesFlashColor();
// Color to be used with kWKDebugFlashBackingStoreUpdates.
static WebCore::Color backingStoreUpdatesFlashColor();

private:
WebPageProxy(PageClient*, WebContext*, WebPageGroup*, uint64_t pageID);

@@ -683,6 +694,8 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {

bool m_mainFrameHasHorizontalScrollbar;
bool m_mainFrameHasVerticalScrollbar;

static WKPageDebugPaintFlags s_debugPaintFlags;
};

} // namespace WebKit
@@ -438,11 +438,33 @@ void WebView::paint(HDC hdc, const IntRect& dirtyRect)
}
}

static void flashRects(HDC dc, const IntRect rects[], size_t rectCount, HBRUSH brush)
{
for (size_t i = 0; i < rectCount; ++i) {
RECT winRect = rects[i];
::FillRect(dc, &winRect, brush);
}

::GdiFlush();
::Sleep(50);
}

static OwnPtr<HBRUSH> createBrush(const Color& color)
{
return adoptPtr(::CreateSolidBrush(RGB(color.red(), color.green(), color.blue())));
}

LRESULT WebView::onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
{
PAINTSTRUCT paintStruct;
HDC hdc = ::BeginPaint(m_window, &paintStruct);

if (WebPageProxy::debugPaintFlags() & kWKDebugFlashViewUpdates) {
static HBRUSH brush = createBrush(WebPageProxy::viewUpdatesFlashColor().rgb()).leakPtr();
IntRect rect = paintStruct.rcPaint;
flashRects(hdc, &rect, 1, brush);
}

paint(hdc, paintStruct.rcPaint);

::EndPaint(m_window, &paintStruct);
@@ -650,6 +672,14 @@ void WebView::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
setViewNeedsDisplay(scrollRect);
}

void WebView::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
{
static HBRUSH brush = createBrush(WebPageProxy::backingStoreUpdatesFlashColor().rgb()).leakPtr();
HDC dc = ::GetDC(m_window);
flashRects(dc, updateRects.data(), updateRects.size(), brush);
::ReleaseDC(m_window, dc);
}

WebCore::IntSize WebView::viewSize()
{
RECT clientRect;
@@ -133,6 +133,7 @@ class WebView : public APIObject, public PageClient, WebCore::WindowMessageListe
virtual void setViewNeedsDisplay(const WebCore::IntRect&);
virtual void displayView();
virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);

virtual WebCore::IntSize viewSize();
virtual bool isViewWindowActive();
@@ -60,6 +60,7 @@ all:
xcopy /y /d "..\UIProcess\API\C\WKOpenPanelResultListener.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKPage.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKPageGroup.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKPagePrivate.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKPreferences.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKPreferencesPrivate.h" "%ConfigurationBuildDir%\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\WKProtectionSpace.h" "%ConfigurationBuildDir%\include\WebKit2"

0 comments on commit 6b1bdf8

Please sign in to comment.