Modified: trunk/Source/WebKit2/ChangeLog (166187 => 166188)
--- trunk/Source/WebKit2/ChangeLog 2014-03-24 20:29:54 UTC (rev 166187)
+++ trunk/Source/WebKit2/ChangeLog 2014-03-24 20:51:02 UTC (rev 166188)
@@ -1,3 +1,24 @@
+2014-03-24 Benjamin Poulain <[email protected]>
+
+ [iOS][WK2] Micro-optimize view state updates on the UIProcess side
+ https://bugs.webkit.org/show_bug.cgi?id=130631
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (contentZoomScale):
+ [UIScrollView zoomScale] is not fast enough for -[WKWebView _updateVisibleContentRects]. Since we know what the zoom view is,
+ make a fast version hardcoding that.
+
+ (-[WKWebView _updateScrollViewBackground]):
+ (-[WKWebView _zoomToPoint:WebCore::atScale:]):
+ (-[WKWebView _scrollToRect:WebCore::origin:WebCore::minimumScrollDistance:]):
+ (-[WKWebView _zoomToRect:WebCore::withOrigin:WebCore::fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
+ (-[WKWebView _updateVisibleContentRects]):
+ * UIProcess/ios/WKContentView.mm:
+ (fixedPositionRectFromExposedRect):
+ (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
+
2014-03-24 Dean Jackson <[email protected]>
Remove WebGL asset entitlement
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (166187 => 166188)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2014-03-24 20:29:54 UTC (rev 166187)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2014-03-24 20:51:02 UTC (rev 166188)
@@ -385,13 +385,28 @@
return [UIColor colorWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)];
}
+static CGFloat contentZoomScale(WKWebView* webView)
+{
+ UIView *zoomView;
+ if (webView->_customContentView)
+ zoomView = webView->_customContentView.get();
+ else
+ zoomView = webView->_contentView.get();
+
+ CGFloat scale = [[zoomView layer] affineTransform].a;
+ ASSERT(scale == [webView->_scrollView zoomScale]);
+ return scale;
+}
+
- (void)_updateScrollViewBackground
{
UIColor *pageExtendedBackgroundColor = [self pageExtendedBackgroundColor];
- if ([_scrollView zoomScale] < [_scrollView minimumZoomScale]) {
+ CGFloat zoomScale = contentZoomScale(self);
+ CGFloat minimumZoomScale = [_scrollView minimumZoomScale];
+ if (zoomScale < minimumZoomScale) {
CGFloat slope = 12;
- CGFloat opacity = std::max(1 - slope * ([_scrollView minimumZoomScale] - [_scrollView zoomScale]), static_cast<CGFloat>(0));
+ CGFloat opacity = std::max(1 - slope * (minimumZoomScale - zoomScale), static_cast<CGFloat>(0));
pageExtendedBackgroundColor = [pageExtendedBackgroundColor colorWithAlphaComponent:opacity];
}
@@ -438,9 +453,10 @@
double minimumZoomDuration = 0.1;
double zoomDurationFactor = 0.3;
- CFTimeInterval duration = std::min(fabs(log([_scrollView zoomScale]) - log(scale)) * zoomDurationFactor + minimumZoomDuration, maximumZoomDuration);
+ CGFloat zoomScale = contentZoomScale(self);
+ CFTimeInterval duration = std::min(fabs(log(zoomScale) - log(scale)) * zoomDurationFactor + minimumZoomDuration, maximumZoomDuration);
- if (scale != [_scrollView zoomScale])
+ if (scale != zoomScale)
[_contentView willStartUserTriggeredZoom];
[_scrollView _zoomToCenter:point scale:scale duration:duration];
@@ -500,7 +516,7 @@
}
WebCore::FloatSize scrollViewOffsetDelta = newUnobscuredContentOffset - unobscuredContentOffset;
- scrollViewOffsetDelta.scale([_scrollView zoomScale]);
+ scrollViewOffsetDelta.scale(contentZoomScale(self));
float scrollDistance = scrollViewOffsetDelta.diagonalLength();
if (scrollDistance < minimumScrollDistance)
@@ -519,7 +535,7 @@
{
const float maximumScaleFactorDeltaForPanScroll = 0.02;
- double currentScale = [_scrollView zoomScale];
+ double currentScale = contentZoomScale(self);
WebCore::FloatSize unobscuredContentSize([self _contentRectForUserInteraction].size);
double horizontalScale = unobscuredContentSize.width() * currentScale / targetRect.width();
@@ -654,7 +670,7 @@
CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);
CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
- CGFloat scaleFactor = [_scrollView zoomScale];
+ CGFloat scaleFactor = contentZoomScale(self);
BOOL isStableState = !(_isChangingObscuredInsetsInteractively || [_scrollView isDragging] || [_scrollView isDecelerating] || [_scrollView isZooming] || [_scrollView isZoomBouncing] || [_scrollView _isAnimatingZoom]);
[_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor inStableState:isStableState];
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (166187 => 166188)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-03-24 20:29:54 UTC (rev 166187)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-03-24 20:51:02 UTC (rev 166188)
@@ -235,6 +235,11 @@
return [self isEditable];
}
+static inline FloatRect fixedPositionRectFromExposedRect(CGRect unobscuredRect, CGSize documentSize, CGFloat scale)
+{
+ return FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(unobscuredRect), roundedLayoutSize(FloatSize(documentSize)), scale, false, StickToViewportBounds);
+}
+
- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)zoomScale inStableState:(BOOL)isStableState
{
double timestamp = monotonicallyIncreasingTime();
@@ -252,7 +257,7 @@
filteredScale = _page->displayedContentScale();
}
- CGRect customFixedPositionRect = [self fixedPositionRectFromExposedRect:unobscuredRect scale:zoomScale];
+ FloatRect customFixedPositionRect = fixedPositionRectFromExposedRect(unobscuredRect, [self bounds].size, zoomScale);
_page->updateVisibleContentRects(VisibleContentRectUpdateInfo(_page->nextVisibleContentRectUpdateID(), visibleRect, unobscuredRect, customFixedPositionRect, filteredScale, isStableState, timestamp, velocity.width, velocity.height));
RemoteScrollingCoordinatorProxy* scrollingCoordinator = _page->scrollingCoordinatorProxy();
@@ -267,11 +272,6 @@
_page->drawingArea()->setSize(IntSize(size), IntSize(), IntSize());
}
-- (CGRect)fixedPositionRectFromExposedRect:(CGRect)unobscuredRect scale:(CGFloat)scale
-{
- return (FloatRect)FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(unobscuredRect), roundedLayoutSize(FloatSize([self bounds].size)), scale, false, StickToViewportBounds);
-}
-
- (void)setMinimumLayoutSize:(CGSize)size
{
_page->setViewportConfigurationMinimumLayoutSize(IntSize(CGCeiling(size.width), CGCeiling(size.height)));