Title: [206945] trunk/Source/WebKit/mac
- Revision
- 206945
- Author
- simon.fra...@apple.com
- Date
- 2016-10-07 17:20:05 -0700 (Fri, 07 Oct 2016)
Log Message
[WK1 Mac] Fix repaints of fixed-background elements in layer-backed WebViews
https://bugs.webkit.org/show_bug.cgi?id=163154
rdar://problem/28674216
Reviewed by Tim Horton.
r55159 added code to counteract AppKit's adjustment of dirty regions during scrolling,
by offsetting the dirty rect in -setNeedsDisplayInRect: if the call happens during
the NSViewBoundsDidChangeNotification handling.
However, AppKit only does dirty region adjustment in the code path that blits ("copy
on scroll"), so r55159 produces incorrect behavior in, for example, layer-backed views.
Fix by overriding -[NSClipView _canCopyOnScrollForDeltaX:deltaY:] to know if a single
scroll is going to blit, and only do adjustments in -setNeedsDisplayInRect: if it is.
* WebView/WebClipView.h:
* WebView/WebClipView.mm:
(-[WebClipView _immediateScrollToPoint:]):
(-[WebClipView _canCopyOnScrollForDeltaX:deltaY:]):
(-[WebClipView currentScrollIsBlit]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView setNeedsDisplayInRect:]):
(-[WebHTMLView drawRect:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (206944 => 206945)
--- trunk/Source/WebKit/mac/ChangeLog 2016-10-07 23:47:18 UTC (rev 206944)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-10-08 00:20:05 UTC (rev 206945)
@@ -1,3 +1,30 @@
+2016-10-07 Simon Fraser <simon.fra...@apple.com>
+
+ [WK1 Mac] Fix repaints of fixed-background elements in layer-backed WebViews
+ https://bugs.webkit.org/show_bug.cgi?id=163154
+ rdar://problem/28674216
+
+ Reviewed by Tim Horton.
+
+ r55159 added code to counteract AppKit's adjustment of dirty regions during scrolling,
+ by offsetting the dirty rect in -setNeedsDisplayInRect: if the call happens during
+ the NSViewBoundsDidChangeNotification handling.
+
+ However, AppKit only does dirty region adjustment in the code path that blits ("copy
+ on scroll"), so r55159 produces incorrect behavior in, for example, layer-backed views.
+
+ Fix by overriding -[NSClipView _canCopyOnScrollForDeltaX:deltaY:] to know if a single
+ scroll is going to blit, and only do adjustments in -setNeedsDisplayInRect: if it is.
+
+ * WebView/WebClipView.h:
+ * WebView/WebClipView.mm:
+ (-[WebClipView _immediateScrollToPoint:]):
+ (-[WebClipView _canCopyOnScrollForDeltaX:deltaY:]):
+ (-[WebClipView currentScrollIsBlit]):
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView setNeedsDisplayInRect:]):
+ (-[WebHTMLView drawRect:]):
+
2016-10-06 Youenn Fablet <you...@apple.com>
CachedResource client handling methods should take reference
Modified: trunk/Source/WebKit/mac/WebView/WebClipView.h (206944 => 206945)
--- trunk/Source/WebKit/mac/WebView/WebClipView.h 2016-10-07 23:47:18 UTC (rev 206944)
+++ trunk/Source/WebKit/mac/WebView/WebClipView.h 2016-10-08 00:20:05 UTC (rev 206945)
@@ -34,9 +34,11 @@
{
BOOL _haveAdditionalClip;
BOOL _isScrolling;
+ BOOL _currentScrollIsBlit;
NSRect _additionalClip;
}
+- (BOOL)currentScrollIsBlit;
- (void)setAdditionalClip:(NSRect)additionalClip;
- (void)resetAdditionalClip;
- (BOOL)hasAdditionalClip;
Modified: trunk/Source/WebKit/mac/WebView/WebClipView.mm (206944 => 206945)
--- trunk/Source/WebKit/mac/WebView/WebClipView.mm 2016-10-07 23:47:18 UTC (rev 206944)
+++ trunk/Source/WebKit/mac/WebView/WebClipView.mm 2016-10-08 00:20:05 UTC (rev 206945)
@@ -50,6 +50,7 @@
@interface NSClipView (WebNSClipViewDetails)
- (void)_immediateScrollToPoint:(NSPoint)newOrigin;
+- (BOOL)_canCopyOnScrollForDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY;
@end
@interface NSWindow (WebNSWindowDetails)
@@ -104,6 +105,7 @@
- (void)_immediateScrollToPoint:(NSPoint)newOrigin
{
_isScrolling = YES;
+ _currentScrollIsBlit = NO;
[[self window] _disableDelayedWindowDisplay];
@@ -126,6 +128,17 @@
_isScrolling = NO;
}
+- (BOOL)_canCopyOnScrollForDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY
+{
+ _currentScrollIsBlit = [super _canCopyOnScrollForDeltaX:deltaX deltaY:deltaY];
+ return _currentScrollIsBlit;
+}
+
+- (BOOL)currentScrollIsBlit
+{
+ return _currentScrollIsBlit;
+}
+
- (void)resetAdditionalClip
{
ASSERT(_haveAdditionalClip);
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (206944 => 206945)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-10-07 23:47:18 UTC (rev 206944)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-10-08 00:20:05 UTC (rev 206945)
@@ -4110,9 +4110,19 @@
}
#endif
+static BOOL currentScrollIsBlit(NSView *clipView)
+{
+#if PLATFORM(MAC)
+ return [clipView isKindOfClass:[WebClipView class]] && [(WebClipView *)clipView currentScrollIsBlit];
+#else
+ return NO;
+#endif
+}
+
+// FIXME: this entire function could be #ifdeffed out on iOS. The below workaround is AppKit-specific.
- (void)setNeedsDisplayInRect:(NSRect)invalidRect
{
- if (_private->inScrollPositionChanged) {
+ if (_private->inScrollPositionChanged && currentScrollIsBlit([self superview])) {
// When scrolling, the dirty regions are adjusted for the scroll only
// after NSViewBoundsDidChangeNotification is sent. Translate the invalid
// rect to pre-scrolled coordinates in order to get the right dirty region
@@ -4227,7 +4237,7 @@
const int cRectThreshold = 10;
const float cWastedSpaceThreshold = 0.75f;
BOOL useUnionedRect = (count <= 1) || (count > cRectThreshold);
- if (!useUnionedRect) {
+ if (!useUnionedRect) {
// Attempt to guess whether or not we should use the unioned rect or the individual rects.
// We do this by computing the percentage of "wasted space" in the union. If that wasted space
// is too large, then we will do individual rect painting instead.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes