Methods to temporarily disable size updates to the page drawing area in WKView.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:34:54 +0000 (01:34 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:34:54 +0000 (01:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=53206
Part of <rdar://problem/8818585>

Patch by Jing Jin <jjin@apple.com> on 2011-01-26
Reviewed by Darin Adler.

* UIProcess/API/mac/WKView.h: Added _frameSizeUpdateDisabledCount.
* UIProcess/API/mac/WKView.mm:
(-[WKView setFrameSize:]): Only update page size if frame size updates are enabled.
(-[WKView _setDrawingAreaSize:]): Helper method to set the page's drawing area's size.
(-[WKView disableFrameSizeUpdates]): Increment _frameSizeUpdateDisabledCount
(-[WKView enableFrameSizeUpdates]): Decrement _frameSizeUpdateDisabledCount, and if the count is 0, meaning
that no one is disabling frame size updates anymore, update the drawing area's size to match the current frame.
(-[WKView frameSizeUpdatesDisabled]): Returns YES if at least one caller is disabling frame size updates.
* UIProcess/API/mac/WKViewInternal.h: Declared -disableFrameSizeUpdates, -enableFrameSizeUpdates, and -frameSizeUpdatesDisabled.
* UIProcess/API/mac/WKViewPrivate.h: Added.
* WebKit2.xcodeproj/project.pbxproj: Added WKViewPrivate.h

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76742 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

index 1c4e9f7..7f10b60 100644 (file)
@@ -1,5 +1,25 @@
 2011-01-26  Jing Jin  <jjin@apple.com>
 
+        Reviewed by Darin Adler.
+
+        Methods to temporarily disable size updates to the page drawing area in WKView.
+        https://bugs.webkit.org/show_bug.cgi?id=53206
+        Part of <rdar://problem/8818585>
+
+        * UIProcess/API/mac/WKView.h: Added _frameSizeUpdateDisabledCount.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView setFrameSize:]): Only update page size if frame size updates are enabled.
+        (-[WKView _setDrawingAreaSize:]): Helper method to set the page's drawing area's size.
+        (-[WKView disableFrameSizeUpdates]): Increment _frameSizeUpdateDisabledCount
+        (-[WKView enableFrameSizeUpdates]): Decrement _frameSizeUpdateDisabledCount, and if the count is 0, meaning
+        that no one is disabling frame size updates anymore, update the drawing area's size to match the current frame.
+        (-[WKView frameSizeUpdatesDisabled]): Returns YES if at least one caller is disabling frame size updates.
+        * UIProcess/API/mac/WKViewInternal.h: Declared -disableFrameSizeUpdates, -enableFrameSizeUpdates, and -frameSizeUpdatesDisabled.
+        * UIProcess/API/mac/WKViewPrivate.h: Added.
+        * WebKit2.xcodeproj/project.pbxproj: Added WKViewPrivate.h
+
+2011-01-26  Jing Jin  <jjin@apple.com>
+
         Rubber-stamped by Dan Bernstein.
         
         Several WKView Internal category methods are implemented in the main category.
index 618bbc4..5fb0d46 100644 (file)
@@ -31,6 +31,7 @@
 WK_EXPORT
 @interface WKView : NSView <NSTextInput> {
     WKViewData *_data;
+    unsigned _frameSizeUpdatesDisabledCount;
 }
 
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef;
index 98701d5..c7a8d9a 100644 (file)
@@ -44,6 +44,8 @@
 #import "WKPrintingView.h"
 #import "WKStringCF.h"
 #import "WKTextInputWindowController.h"
+#import "WKViewInternal.h"
+#import "WKViewPrivate.h"
 #import "WebContext.h"
 #import "WebEventFactory.h"
 #import "WebPage.h"
@@ -287,11 +289,9 @@ static bool useNewDrawingArea()
 - (void)setFrameSize:(NSSize)size
 {
     [super setFrameSize:size];
-
-    if (!_data->_page->drawingArea())
-        return;
     
-    _data->_page->drawingArea()->setSize(IntSize(size));
+    if (![self frameSizeUpdatesDisabled])
+        [self _setDrawingAreaSize:size];
 }
 
 - (void)_updateWindowAndViewFrames
@@ -1758,4 +1758,36 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     _data->_dragHasStarted = NO;
 }
 
+- (void)_setDrawingAreaSize:(NSSize)size
+{
+    if (!_data->_page->drawingArea())
+        return;
+    
+    _data->_page->drawingArea()->setSize(IntSize(size));
+}    
+
 @end
+
+@implementation WKView (Private)
+
+- (void)disableFrameSizeUpdates
+{
+    _frameSizeUpdatesDisabledCount++;
+}
+
+- (void)enableFrameSizeUpdates
+{
+    if (!_frameSizeUpdatesDisabledCount)
+        return;
+    
+    if (!(--_frameSizeUpdatesDisabledCount))
+        [self _setDrawingAreaSize:[self frame].size];
+}
+
+- (BOOL)frameSizeUpdatesDisabled
+{
+    return _frameSizeUpdatesDisabledCount > 0;
+}
+
+@end
+
index 655100d..922fbf3 100644 (file)
@@ -65,4 +65,5 @@ namespace WebKit {
 - (void)_setCustomRepresentationZoomFactor:(double)zoomFactor;
 - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
 
+- (void)_setDrawingAreaSize:(NSSize)size;
 @end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
new file mode 100644 (file)
index 0000000..5d6125e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+@interface WKView (Private)
+
+// Stops updating the size of the page as the WKView frame size updates.
+// This should always be followed by enableFrameSizeUpdates. Calls can be nested.
+- (void)disableFrameSizeUpdates;
+// Immediately updates the size of the page to match WKView's frame size
+// and allows subsequent updates as the frame size is set. Calls can be nested.
+- (void)enableFrameSizeUpdates;
+- (BOOL)frameSizeUpdatesDisabled;
+
+@end
index 93f22c4..37d5355 100644 (file)
                BCF69FA31176D01400471A52 /* WebNavigationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF69FA11176D01400471A52 /* WebNavigationData.cpp */; };
                BCF69FA91176D1CB00471A52 /* WKNavigationData.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF69FA71176D1CB00471A52 /* WKNavigationData.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BCF69FAA1176D1CB00471A52 /* WKNavigationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF69FA81176D1CB00471A52 /* WKNavigationData.cpp */; };
+               BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BFA6179E12F0B99D0033E0CA /* WKViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C01A260112662F2100C9ED55 /* ShareableBitmapCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C01A260012662F2100C9ED55 /* ShareableBitmapCG.cpp */; };
                C02BFF1E1251502E009CCBEA /* NativeWebKeyboardEventMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */; };
                C0337DAE127A24FE008FF4F4 /* WebEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0337DAD127A24FE008FF4F4 /* WebEvent.cpp */; };
                BCF69FA11176D01400471A52 /* WebNavigationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNavigationData.cpp; sourceTree = "<group>"; };
                BCF69FA71176D1CB00471A52 /* WKNavigationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationData.h; sourceTree = "<group>"; };
                BCF69FA81176D1CB00471A52 /* WKNavigationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationData.cpp; sourceTree = "<group>"; };
+               BFA6179E12F0B99D0033E0CA /* WKViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKViewPrivate.h; sourceTree = "<group>"; };
                C01A260012662F2100C9ED55 /* ShareableBitmapCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShareableBitmapCG.cpp; sourceTree = "<group>"; };
                C02BFF1512514FD8009CCBEA /* NativeWebKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebKeyboardEvent.h; sourceTree = "<group>"; };
                C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebKeyboardEventMac.mm; sourceTree = "<group>"; };
                                BC8699B2116AADAA002A925B /* WKView.h */,
                                BC8699B3116AADAA002A925B /* WKView.mm */,
                                BC8699B4116AADAA002A925B /* WKViewInternal.h */,
+                               BFA6179E12F0B99D0033E0CA /* WKViewPrivate.h */,
                        );
                        path = mac;
                        sourceTree = "<group>";
                                C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */,
                                E134F01712EA5D33004EC58D /* WKPrintingView.h in Headers */,
                                1A186EEA12EF7618008E5F37 /* LayerTreeHost.h in Headers */,
+                               BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };