Title: [150168] trunk/Source/WebKit/mac
- Revision
- 150168
- Author
- [email protected]
- Date
- 2013-05-15 19:05:38 -0700 (Wed, 15 May 2013)
Log Message
Avoid backing store for the WebFrameView's layer when the WebView is layer-backed
https://bugs.webkit.org/show_bug.cgi?id=116172
Reviewed by Tim Horton.
When the WebView is layer-backed, AppKit will create a layer with backing store for
the WebFrameView because it implements drawRect:. However, this method only paints
when there is no documentView, so this layer’s backing store is wasteful.
We can avoid allocation of this backing store by implementing -wantsUpdateLayer
and -updateLayer, and setting the view’s backgroundColor.
* WebView/WebFrameView.mm:
(-[WebFrameView wantsUpdateLayer]):
(-[WebFrameView updateLayer]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (150167 => 150168)
--- trunk/Source/WebKit/mac/ChangeLog 2013-05-16 01:35:31 UTC (rev 150167)
+++ trunk/Source/WebKit/mac/ChangeLog 2013-05-16 02:05:38 UTC (rev 150168)
@@ -1,3 +1,21 @@
+2013-05-15 Simon Fraser <[email protected]>
+
+ Avoid backing store for the WebFrameView's layer when the WebView is layer-backed
+ https://bugs.webkit.org/show_bug.cgi?id=116172
+
+ Reviewed by Tim Horton.
+
+ When the WebView is layer-backed, AppKit will create a layer with backing store for
+ the WebFrameView because it implements drawRect:. However, this method only paints
+ when there is no documentView, so this layer’s backing store is wasteful.
+
+ We can avoid allocation of this backing store by implementing -wantsUpdateLayer
+ and -updateLayer, and setting the view’s backgroundColor.
+
+ * WebView/WebFrameView.mm:
+ (-[WebFrameView wantsUpdateLayer]):
+ (-[WebFrameView updateLayer]):
+
2013-05-13 Anders Carlsson <[email protected]>
Frame::editor() should return a reference
Modified: trunk/Source/WebKit/mac/WebView/WebFrameView.mm (150167 => 150168)
--- trunk/Source/WebKit/mac/WebView/WebFrameView.mm 2013-05-16 01:35:31 UTC (rev 150167)
+++ trunk/Source/WebKit/mac/WebView/WebFrameView.mm 2013-05-16 02:05:38 UTC (rev 150168)
@@ -79,6 +79,10 @@
- (BOOL)_scrollTo:(const NSPoint *)newOrigin animate:(BOOL)animate; // need the boolean result from this method
@end
+@interface NSView (Details)
+- (void)setBackgroundColor:(NSColor *)color;
+@end
+
enum {
SpaceKey = 0x0020
};
@@ -458,7 +462,7 @@
- (void)drawRect:(NSRect)rect
{
- if ([self documentView] == nil) {
+ if (![self documentView]) {
// Need to paint ourselves if there's no documentView to do it instead.
if ([[self _webView] drawsBackground]) {
[[[self _webView] backgroundColor] set];
@@ -474,6 +478,32 @@
}
}
+- (BOOL)wantsUpdateLayer
+{
+ return YES;
+}
+
+- (void)updateLayer
+{
+ // Do what -drawRect: does but by setting a backgroundColor on the view. This avoids
+ // backing store for this view when the WebView is layer-backed.
+ if (![self documentView]) {
+ if ([[self _webView] drawsBackground]) {
+ [self setBackgroundColor:[[self _webView] backgroundColor]];
+ return;
+ }
+ } else {
+#ifndef NDEBUG
+ if ([[self _scrollView] drawsBackground]) {
+ [self setBackgroundColor:[NSColor cyanColor]];
+ return;
+ }
+#endif
+ }
+
+ [self setBackgroundColor:[NSColor clearColor]];
+}
+
- (NSRect)visibleRect
{
// This method can be called beneath -[NSView dealloc] after we have cleared _private.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes