- Revision
- 148331
- Author
- barraclo...@apple.com
- Date
- 2013-04-12 18:37:57 -0700 (Fri, 12 Apr 2013)
Log Message
Add private interface to WKView to asynchronously update the drawing area size
https://bugs.webkit.org/show_bug.cgi?id=114549
Reviewed by Simon Fraser.
This will allow a client using the WKView to resize the contents without blocking waiting for the web process to repaint.
* UIProcess/API/mac/WKView.mm:
(-[WKView _setDrawingAreaSize:]):
- if the new size of teh drawing area does not match the frame size, position it according to the contentAnchor.
(-[WKView updateLayer]):
- Don't let a subsequent frame size change block on a prior async resize.
(-[WKView forceAsyncDrawingAreaSizeUpdate:]):
- resize the drawing area asynchronously, even if frame size udpates are disabled.
(-[WKView waitForAsyncDrawingAreaSizeUpdate]):
- wait for asynchronous updates to complete.
* UIProcess/API/mac/WKViewPrivate.h:
- declare new methods.
* UIProcess/DrawingAreaProxy.cpp:
(WebKit):
* UIProcess/DrawingAreaProxy.h:
(DrawingAreaProxy):
(WebKit::DrawingAreaProxy::waitForPossibleGeometryUpdate):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
(TiledCoreAnimationDrawingAreaProxy):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate):
- pass timeout for waitForPossibleGeometryUpdate as a parameter.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (148330 => 148331)
--- trunk/Source/WebKit2/ChangeLog 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-13 01:37:57 UTC (rev 148331)
@@ -1,3 +1,36 @@
+2013-04-12 Gavin Barraclough <barraclo...@apple.com>
+
+ Add private interface to WKView to asynchronously update the drawing area size
+ https://bugs.webkit.org/show_bug.cgi?id=114549
+
+ Reviewed by Simon Fraser.
+
+ This will allow a client using the WKView to resize the contents without blocking waiting for the web process to repaint.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _setDrawingAreaSize:]):
+ - if the new size of teh drawing area does not match the frame size, position it according to the contentAnchor.
+ (-[WKView updateLayer]):
+ - Don't let a subsequent frame size change block on a prior async resize.
+ (-[WKView forceAsyncDrawingAreaSizeUpdate:]):
+ - resize the drawing area asynchronously, even if frame size udpates are disabled.
+ (-[WKView waitForAsyncDrawingAreaSizeUpdate]):
+ - wait for asynchronous updates to complete.
+
+ * UIProcess/API/mac/WKViewPrivate.h:
+ - declare new methods.
+
+ * UIProcess/DrawingAreaProxy.cpp:
+ (WebKit):
+ * UIProcess/DrawingAreaProxy.h:
+ (DrawingAreaProxy):
+ (WebKit::DrawingAreaProxy::waitForPossibleGeometryUpdate):
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+ (TiledCoreAnimationDrawingAreaProxy):
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate):
+ - pass timeout for waitForPossibleGeometryUpdate as a parameter.
+
2013-04-12 Jessie Berlin <jber...@apple.com>
32-bit build fix.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-04-13 01:37:57 UTC (rev 148331)
@@ -2290,7 +2290,13 @@
if (!_data->_page->drawingArea())
return;
- _data->_page->drawingArea()->setSize(IntSize(size), IntSize(_data->_frameOrigin.x, _data->_frameOrigin.y), IntSize(_data->_resizeScrollOffset));
+ NSSize layerOffset = NSMakeSize(_data->_frameOrigin.x, _data->_frameOrigin.y);
+ if (isWKContentAnchorRight(_data->_contentAnchor))
+ layerOffset.width += [self frame].size.width - size.width;
+ if (isWKContentAnchorBottom(_data->_contentAnchor))
+ layerOffset.height += [self frame].size.height - size.height;
+
+ _data->_page->drawingArea()->setSize(IntSize(size), IntSize(layerOffset), IntSize(_data->_resizeScrollOffset));
_data->_resizeScrollOffset = NSZeroSize;
}
@@ -3231,6 +3237,12 @@
else
self.layer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
+ // If asynchronous geometry updates have been sent by forceAsyncDrawingAreaSizeUpdate,
+ // then subsequent calls to setFrameSize should not result in us waiting for the did
+ // udpate response if setFrameSize is called.
+ if ([self frameSizeUpdatesDisabled])
+ return;
+
if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
drawingArea->waitForPossibleGeometryUpdate();
}
@@ -3429,6 +3441,34 @@
return _data->_contentAnchor;
}
+// This method forces a drawing area geometry update, even if frame size updates are disabled.
+// The updated is performed asynchronously; we don't wait for the geometry update before returning.
+// The area drawn need not match the current frame size - if it differs it will be anchored to the
+// frame according to the current contentAnchor.
+- (void)forceAsyncDrawingAreaSizeUpdate:(NSSize)size
+{
+ if (_data->_expandsToFitContentViaAutoLayout)
+ _data->_page->viewExposedRectChanged([self visibleRect]);
+ [self _setDrawingAreaSize:size];
+
+ // If a geometry update is pending the new update won't be sent. Poll without waiting for any
+ // pending did-update message now, such that the new update can be sent. We do so after setting
+ // the drawing area size such that the latest update is sent.
+ if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
+ drawingArea->waitForPossibleGeometryUpdate(0);
+}
+
+- (void)waitForAsyncDrawingAreaSizeUpdate
+{
+ if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea()) {
+ // If a geometry update is still pending then the action of recieving the
+ // first geometry update may result in another update being scheduled -
+ // we should wait for this to complete too.
+ drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout * 0.5);
+ drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout * 0.5);
+ }
+}
+
@end
@implementation WKResponderChainSink
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h 2013-04-13 01:37:57 UTC (rev 148331)
@@ -72,4 +72,7 @@
- (BOOL)windowOcclusionDetectionEnabled;
- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag;
+- (void)forceAsyncDrawingAreaSizeUpdate:(NSSize)size;
+- (void)waitForAsyncDrawingAreaSizeUpdate;
+
@end
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp 2013-04-13 01:37:57 UTC (rev 148331)
@@ -38,6 +38,8 @@
namespace WebKit {
+const double DrawingAreaProxy::didUpdateBackingStoreStateTimeout = 0.5;
+
DrawingAreaProxy::DrawingAreaProxy(DrawingAreaType type, WebPageProxy* webPageProxy)
: m_type(type)
, m_webPageProxy(webPageProxy)
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2013-04-13 01:37:57 UTC (rev 148331)
@@ -64,8 +64,11 @@
const WebCore::IntSize& size() const { return m_size; }
void setSize(const WebCore::IntSize&, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
+ // The timeout, in seconds, we use when waiting for a DidUpdateGeometry message.
+ static const double didUpdateBackingStoreStateTimeout;
+
virtual void pageCustomRepresentationChanged() { }
- virtual void waitForPossibleGeometryUpdate() { }
+ virtual void waitForPossibleGeometryUpdate(double timeout = didUpdateBackingStoreStateTimeout) { }
virtual void colorSpaceDidChange() { }
virtual void minimumLayoutWidthDidChange() { }
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2013-04-13 01:37:57 UTC (rev 148331)
@@ -46,7 +46,7 @@
virtual void layerHostingModeDidChange() OVERRIDE;
virtual void visibilityDidChange() OVERRIDE;
virtual void sizeDidChange() OVERRIDE;
- virtual void waitForPossibleGeometryUpdate() OVERRIDE;
+ virtual void waitForPossibleGeometryUpdate(double timeout = didUpdateBackingStoreStateTimeout) OVERRIDE;
virtual void colorSpaceDidChange() OVERRIDE;
virtual void minimumLayoutWidthDidChange() OVERRIDE;
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (148330 => 148331)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2013-04-13 01:25:25 UTC (rev 148330)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2013-04-13 01:37:57 UTC (rev 148331)
@@ -86,7 +86,7 @@
sendUpdateGeometry();
}
-void TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate()
+void TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate(double timeout)
{
if (!m_isWaitingForDidUpdateGeometry)
return;
@@ -94,9 +94,7 @@
if (m_webPageProxy->process()->isLaunching())
return;
- // The timeout, in seconds, we use when waiting for a DidUpdateGeometry message.
- static const double didUpdateBackingStoreStateTimeout = 0.5;
- m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), didUpdateBackingStoreStateTimeout);
+ m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), timeout);
}
void TiledCoreAnimationDrawingAreaProxy::colorSpaceDidChange()