Diff
Modified: trunk/Source/WebKit2/ChangeLog (148310 => 148311)
--- trunk/Source/WebKit2/ChangeLog 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-12 23:18:50 UTC (rev 148311)
@@ -1,3 +1,69 @@
+2013-04-12 Gavin Barraclough <barraclo...@apple.com>
+
+ Add contentAnchor to WKView
+ http://bugs.webkit.org/show_bug.cgi?id=114469
+
+ Currently if you call setFrameSize: while frame size updates are disabled, or if the geometry
+ update times out, then the previously rendered page content will be rendered anchored to the
+ top left corner of the frame.
+
+ This is appropriate if the frame is being resized from the bottom right corner. In order to
+ achieve a more desirable appearance if the frame is being resized from another corner we
+ should allow the corner at which the content anchors to be specified.
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView setFrameSize:]):
+ - If the content anchor has been set, then updating the frame size moves the origin within the layer.
+ (-[WKView _setDrawingAreaSize:]):
+ - Instruct the drawing area to paint at the correct position within the layer.
+ (-[WKView _setAcceleratedCompositingModeRootLayer:]):
+ - If the root layer is cleared this implicitly resets any origin position we had set within it.
+ (-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
+ - initialize new data members.
+ (-[WKView setContentAnchor:]):
+ (-[WKView contentAnchor]):
+ - Accessor implementation for @property contentAnchor.
+
+ * UIProcess/API/mac/WKViewPrivate.h:
+ (NS_ENUM):
+ - Added WKContentAnchor enum type, and @property contentAnchor.
+
+ * UIProcess/DrawingAreaProxy.cpp:
+ (WebKit::DrawingAreaProxy::setSize):
+ - Don't suppress geometry updates where the layer poistion has changed.
+
+ * UIProcess/DrawingAreaProxy.h:
+ (DrawingAreaProxy):
+ - Added m_layerPosition, layerPosition argument to setSize
+
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+ (TiledCoreAnimationDrawingAreaProxy):
+ - Added m_lastSentLayerPosition
+
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry):
+ - Don't suppress geometry updates where the layer poistion has changed.
+
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::sendUpdateGeometry):
+ - Pass layer position in UpdateGeometry message.
+
+ * WebProcess/WebPage/DrawingArea.h:
+ (WebKit::DrawingArea::updateGeometry):
+ - Added layerPosition argument to updateGeometry
+
+ * WebProcess/WebPage/DrawingArea.messages.in:
+ - Added layerPosition argument to updateGeometry
+
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+ (TiledCoreAnimationDrawingArea):
+ - Added layerPosition argument to updateGeometry
+
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+ (WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
+ - Added layerPosition argument to updateGeometry
+
2013-04-12 Commit Queue <rn...@webkit.org>
Unreviewed, rolling out r148296 and r148297.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-04-12 23:18:50 UTC (rev 148311)
@@ -94,6 +94,16 @@
#import "WKBrowsingContextGroupPrivate.h"
#import "WKProcessGroupPrivate.h"
+inline bool isWKContentAnchorRight(WKContentAnchor x)
+{
+ return x == WKContentAnchorTopRight || x == WKContentAnchorBottomRight;
+}
+
+inline bool isWKContentAnchorBottom(WKContentAnchor x)
+{
+ return x == WKContentAnchorBottomLeft || x == WKContentAnchorBottomRight;
+}
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
static BOOL windowOcclusionNotificationsAreRegistered = NO;
#endif
@@ -224,6 +234,13 @@
String _promisedFilename;
String _promisedURL;
+ // The frame origin can be seen as a position within the layer of painted page content where the
+ // top left corner of the frame will be positioned. This is usually 0,0 - but if the content
+ // anchor is set to a corner other than the top left, the origin will implicitly move as the
+ // the frame size is modified.
+ NSPoint _frameOrigin;
+ WKContentAnchor _contentAnchor;
+
NSSize _intrinsicContentSize;
BOOL _expandsToFitContentViaAutoLayout;
BOOL _isWindowOccluded;
@@ -385,9 +402,35 @@
if (!NSEqualSizes(size, [self frame].size))
_data->_windowHasValidBackingStore = NO;
+ bool frameSizeUpdatesEnabled = ![self frameSizeUpdatesDisabled];
+ NSPoint newFrameOrigin;
+
+ // If frame updates are enabled we'll synchronously wait on the repaint, so we can reposition
+ // the layers back to the origin. If frame updates are disabled then shift the layer position
+ // so that the currently painted contents remain anchored appropriately.
+ if (frameSizeUpdatesEnabled)
+ newFrameOrigin = NSZeroPoint;
+ else {
+ newFrameOrigin = _data->_frameOrigin;
+ if (isWKContentAnchorRight(_data->_contentAnchor))
+ newFrameOrigin.x += [self frame].size.width - size.width;
+ if (isWKContentAnchorBottom(_data->_contentAnchor))
+ newFrameOrigin.y += [self frame].size.height - size.height;
+ }
+
+ // If the frame origin has changed then update the layer position.
+ if (!NSEqualPoints(_data->_frameOrigin, newFrameOrigin)) {
+ _data->_frameOrigin = newFrameOrigin;
+ CALayer *rootLayer = [_data->_layerHostingView layer].sublayers[0];
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ rootLayer.position = NSMakePoint(-newFrameOrigin.x, -newFrameOrigin.y);
+ [CATransaction commit];
+ }
+
[super setFrameSize:size];
- if (![self frameSizeUpdatesDisabled]) {
+ if (frameSizeUpdatesEnabled) {
if (_data->_expandsToFitContentViaAutoLayout)
_data->_page->viewExposedRectChanged([self visibleRect]);
[self _setDrawingAreaSize:size];
@@ -2247,7 +2290,7 @@
if (!_data->_page->drawingArea())
return;
- _data->_page->drawingArea()->setSize(IntSize(size), IntSize(_data->_resizeScrollOffset));
+ _data->_page->drawingArea()->setSize(IntSize(size), IntSize(_data->_frameOrigin.x, _data->_frameOrigin.y), IntSize(_data->_resizeScrollOffset));
_data->_resizeScrollOffset = NSZeroSize;
}
@@ -2716,6 +2759,7 @@
[_data->_layerHostingView setWantsLayer:NO];
_data->_layerHostingView = nullptr;
+ _data->_frameOrigin = NSZeroPoint;
}
}
@@ -3152,6 +3196,9 @@
_data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
_data->_windowOcclusionDetectionEnabled = YES;
+ _data->_frameOrigin = NSZeroPoint;
+ _data->_contentAnchor = WKContentAnchorTopLeft;
+
[self _registerDraggedTypes];
if ([self _shouldUseTiledDrawingArea]) {
@@ -3372,6 +3419,16 @@
[self _disableWindowOcclusionNotifications];
}
+- (void)setContentAnchor:(WKContentAnchor)contentAnchor
+{
+ _data->_contentAnchor = contentAnchor;
+}
+
+- (WKContentAnchor)contentAnchor
+{
+ return _data->_contentAnchor;
+}
+
@end
@implementation WKResponderChainSink
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h 2013-04-12 23:18:50 UTC (rev 148311)
@@ -25,11 +25,19 @@
#import <WebKit2/WKView.h>
+typedef NS_ENUM(NSUInteger, WKContentAnchor) {
+ WKContentAnchorTopLeft,
+ WKContentAnchorTopRight,
+ WKContentAnchorBottomLeft,
+ WKContentAnchorBottomRight,
+};
+
@interface WKView (Private)
/* C SPI support. */
@property(readonly) WKPageRef pageRef;
+@property WKContentAnchor contentAnchor;
- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef relatedToPage:(WKPageRef)relatedPage;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2013-04-12 23:18:50 UTC (rev 148311)
@@ -605,7 +605,7 @@
qWarning("WARNING: The web process has been successfully restarted.");
if (DrawingAreaProxy *drawingArea = webPageProxy->drawingArea()) {
- drawingArea->setSize(viewSize(), IntSize());
+ drawingArea->setSize(viewSize(), IntSize(), IntSize());
updateViewportSize();
updateUserScripts();
@@ -981,7 +981,7 @@
// The fixed layout is handled by the FrameView and the drawing area doesn't behave differently
// whether its fixed or not. We still need to tell the drawing area which part of it
// has to be rendered on tiles, and in desktop mode it's all of it.
- drawingArea->setSize(viewportSize.toSize(), IntSize());
+ drawingArea->setSize(viewportSize.toSize(), IntSize(), IntSize());
// The backing store scale factor should already be set to the device pixel ratio
// of the underlying window, thus we set the effective scale to 1 here.
drawingArea->setVisibleContentsRect(FloatRect(FloatPoint(), FloatSize(viewportSize)), FloatPoint());
Modified: trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp 2013-04-12 23:18:50 UTC (rev 148311)
@@ -339,11 +339,11 @@
return;
if (d->m_webPageProxy->useFixedLayout())
- drawingArea->setSize(size, WebCore::IntSize());
+ drawingArea->setSize(size, WebCore::IntSize(), WebCore::IntSize());
d->m_size = size;
- drawingArea->setSize(d->m_size, WebCore::IntSize());
+ drawingArea->setSize(d->m_size, WebCore::IntSize(), WebCore::IntSize());
drawingArea->setVisibleContentsRect(WebCore::IntRect(WebCore::IntPoint(), d->m_size), WebCore::FloatPoint());
}
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp 2013-04-12 23:18:50 UTC (rev 148311)
@@ -51,12 +51,13 @@
m_webPageProxy->process()->removeMessageReceiver(Messages::DrawingAreaProxy::messageReceiverName(), m_webPageProxy->pageID());
}
-void DrawingAreaProxy::setSize(const IntSize& size, const IntSize& scrollOffset)
+void DrawingAreaProxy::setSize(const IntSize& size, const IntSize& layerPosition, const IntSize& scrollOffset)
{
- if (m_size == size && scrollOffset.isZero())
+ if (m_size == size && m_layerPosition == layerPosition && scrollOffset.isZero())
return;
m_size = size;
+ m_layerPosition = layerPosition;
m_scrollOffset += scrollOffset;
sizeDidChange();
}
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2013-04-12 23:18:50 UTC (rev 148311)
@@ -62,7 +62,7 @@
virtual void waitForBackingStoreUpdateOnNextPaint() { }
const WebCore::IntSize& size() const { return m_size; }
- void setSize(const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
+ void setSize(const WebCore::IntSize&, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
virtual void pageCustomRepresentationChanged() { }
virtual void waitForPossibleGeometryUpdate() { }
@@ -86,6 +86,7 @@
WebPageProxy* m_webPageProxy;
WebCore::IntSize m_size;
+ WebCore::IntSize m_layerPosition;
WebCore::IntSize m_scrollOffset;
#if USE(COORDINATED_GRAPHICS)
Modified: trunk/Source/WebKit2/UIProcess/PageViewportController.cpp (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/PageViewportController.cpp 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/PageViewportController.cpp 2013-04-12 23:18:50 UTC (rev 148311)
@@ -250,7 +250,7 @@
// Let the WebProcess know about the new viewport size, so that
// it can resize the content accordingly.
- m_webPageProxy->drawingArea()->setSize(roundedIntSize(newSize), IntSize());
+ m_webPageProxy->drawingArea()->setSize(roundedIntSize(newSize), IntSize(), IntSize());
}
void PageViewportController::didChangeContentsVisibility(const FloatPoint& position, float scale, const FloatPoint& trajectoryVector)
Modified: trunk/Source/WebKit2/UIProcess/efl/WebView.cpp (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/efl/WebView.cpp 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/efl/WebView.cpp 2013-04-12 23:18:50 UTC (rev 148311)
@@ -272,7 +272,7 @@
{
if (DrawingAreaProxy* drawingArea = page()->drawingArea()) {
// Web Process expects sizes in UI units, and not raw device units.
- drawingArea->setSize(roundedIntSize(dipSize()), IntSize());
+ drawingArea->setSize(roundedIntSize(dipSize()), IntSize(), IntSize());
drawingArea->setVisibleContentsRect(FloatRect(contentPosition(), dipSize()), FloatPoint());
}
}
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2013-04-12 23:18:50 UTC (rev 148311)
@@ -65,6 +65,7 @@
// The last size we sent to the web process.
WebCore::IntSize m_lastSentSize;
+ WebCore::IntSize m_lastSentLayerPosition;
// The last minimum layout width we sent to the web process.
double m_lastSentMinimumLayoutWidth;
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (148310 => 148311)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2013-04-12 23:18:50 UTC (rev 148311)
@@ -143,7 +143,7 @@
// If the WKView was resized while we were waiting for a DidUpdateGeometry reply from the web process,
// we need to resend the new size here.
- if (m_lastSentSize != m_size || m_lastSentMinimumLayoutWidth != minimumLayoutWidth)
+ if (m_lastSentSize != m_size || m_lastSentLayerPosition != m_layerPosition || m_lastSentMinimumLayoutWidth != minimumLayoutWidth)
sendUpdateGeometry();
if (minimumLayoutWidth > 0)
@@ -162,7 +162,8 @@
m_lastSentMinimumLayoutWidth = m_webPageProxy->minimumLayoutWidth();
m_lastSentSize = m_size;
- m_webPageProxy->process()->send(Messages::DrawingArea::UpdateGeometry(m_size), m_webPageProxy->pageID());
+ m_lastSentLayerPosition = m_layerPosition;
+ m_webPageProxy->process()->send(Messages::DrawingArea::UpdateGeometry(m_size, m_layerPosition), m_webPageProxy->pageID());
m_isWaitingForDidUpdateGeometry = true;
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (148310 => 148311)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2013-04-12 23:18:50 UTC (rev 148311)
@@ -120,7 +120,7 @@
#if PLATFORM(MAC)
// Used by TiledCoreAnimationDrawingArea.
- virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
+ virtual void updateGeometry(const WebCore::IntSize& viewSize, const WebCore::IntSize& layerPosition) { }
virtual void setDeviceScaleFactor(float) { }
virtual void setColorSpace(const ColorSpaceData&) { }
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in (148310 => 148311)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2013-04-12 23:18:50 UTC (rev 148311)
@@ -30,7 +30,7 @@
#if PLATFORM(MAC)
// Used by TiledCoreAnimationDrawingArea.
- UpdateGeometry(WebCore::IntSize viewSize)
+ UpdateGeometry(WebCore::IntSize viewSize, WebCore::IntSize layerPosition)
SetDeviceScaleFactor(float deviceScaleFactor)
SetColorSpace(WebKit::ColorSpaceData colorSpace)
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (148310 => 148311)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2013-04-12 23:18:50 UTC (rev 148311)
@@ -95,7 +95,7 @@
// Message handlers.
virtual void suspendPainting() OVERRIDE;
virtual void resumePainting() OVERRIDE;
- virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
+ virtual void updateGeometry(const WebCore::IntSize& viewSize, const WebCore::IntSize& layerPosition) OVERRIDE;
virtual void setDeviceScaleFactor(float) OVERRIDE;
virtual void setLayerHostingMode(uint32_t) OVERRIDE;
virtual void setColorSpace(const ColorSpaceData&) OVERRIDE;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (148310 => 148311)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2013-04-12 23:11:29 UTC (rev 148310)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2013-04-12 23:18:50 UTC (rev 148311)
@@ -413,7 +413,7 @@
tiledBacking->setClipsToExposedRect(!isScrollable);
}
-void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize)
+void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize, const IntSize& layerPosition)
{
m_inUpdateGeometry = true;
@@ -444,7 +444,7 @@
[CATransaction begin];
[CATransaction setDisableActions:YES];
- m_rootLayer.get().frame = CGRectMake(0, 0, viewSize.width(), viewSize.height());
+ m_rootLayer.get().frame = CGRectMake(layerPosition.width(), layerPosition.height(), viewSize.width(), viewSize.height());
[CATransaction commit];