Resizing Cappuccino is very laggy on WebKit since Safari 5.1
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 02:24:34 +0000 (02:24 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 02:24:34 +0000 (02:24 +0000)
<http://webkit.org/b/71354>
<rdar://problem/10565998>

Reviewed by Anders Carlsson.

Source/WebCore:

* WebCore.exp.in: Export FloatPoint(const NSPoint&)

Source/WebKit2:

On Mac, we already cache the window rect through the WindowAndViewFramesChanged
message, so simply return that in WebChromeClient::windowRect() instead of
sending a synchronous query to the UIProcess.

If a programmatic resize is requested, we bypass the cache until we've received
a new WindowAndViewFramesChanged message. This compromise allows us to return
cached rects in the common case, and handles creating a new window and immediately
resizing it gracefully.

Changed WindowAndViewFramesChanged to pass FloatRect/FloatPoint rather than
IntRect/IntPoint to match the ChromeClient::windowRect() return type.

* UIProcess/API/mac/WKView.mm:
(-[WKView _updateWindowAndViewFrames]):
* UIProcess/WebPageProxy.h:
(WebPageProxy):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::windowAndViewFramesChanged):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::windowAndViewFramesChanged):
* WebProcess/Plugins/PluginView.h:
(PluginView):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::setWindowRect):
(WebKit::WebChromeClient::windowRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::sendSetWindowFrame):
(WebKit::WebPage::windowAndViewFramesChanged):
* WebProcess/WebPage/WebPage.h:
(WebPage):
(WebKit::WebPage::windowFrameInScreenCoordinates):
(WebKit::WebPage::viewFrameInWindowCoordinates):
(WebKit::WebPage::hasCachedWindowFrame):
(WebKit::WebPage::accessibilityPosition):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm

index 520d99c..d8cde1b 100644 (file)
@@ -1,5 +1,15 @@
 2013-03-07  Andreas Kling  <akling@apple.com>
 
+        Resizing Cappuccino is very laggy on WebKit since Safari 5.1
+        <http://webkit.org/b/71354>
+        <rdar://problem/10565998>
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in: Export FloatPoint(const NSPoint&)
+
+2013-03-07  Andreas Kling  <akling@apple.com>
+
         Remove desktop version of -webkit-text-size-adjust property.
         <http://webkit.org/b/56543>
         <rdar://problem/9150203>
index 545d60b..99de1c4 100644 (file)
@@ -70,6 +70,7 @@ __ZN7WebCore10ClientRectC1ERKNS_7IntRectE
 __ZN7WebCore10ClientRectC1Ev
 __ZN7WebCore10CredentialC1ERKN3WTF6StringES4_NS_21CredentialPersistenceE
 __ZN7WebCore10CredentialC1Ev
+__ZN7WebCore10FloatPointC1ERK8_NSPoint
 __ZN7WebCore10FloatPointC1ERKNS_8IntPointE
 __ZN7WebCore10JSDocument6s_infoE
 __ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringENS1_10PassRefPtrINS_9DOMWindowEEERKNS_18PlatformMouseEventEiNS5_INS_4NodeEEE
index c33031e..d226ccb 100644 (file)
@@ -1,3 +1,50 @@
+2013-03-07  Andreas Kling  <akling@apple.com>
+
+        Resizing Cappuccino is very laggy on WebKit since Safari 5.1
+        <http://webkit.org/b/71354>
+        <rdar://problem/10565998>
+
+        Reviewed by Anders Carlsson.
+
+        On Mac, we already cache the window rect through the WindowAndViewFramesChanged
+        message, so simply return that in WebChromeClient::windowRect() instead of
+        sending a synchronous query to the UIProcess.
+
+        If a programmatic resize is requested, we bypass the cache until we've received
+        a new WindowAndViewFramesChanged message. This compromise allows us to return
+        cached rects in the common case, and handles creating a new window and immediately
+        resizing it gracefully.
+
+        Changed WindowAndViewFramesChanged to pass FloatRect/FloatPoint rather than
+        IntRect/IntPoint to match the ChromeClient::windowRect() return type.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _updateWindowAndViewFrames]):
+        * UIProcess/WebPageProxy.h:
+        (WebPageProxy):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::windowAndViewFramesChanged):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::windowAndViewFramesChanged):
+        * WebProcess/Plugins/PluginView.h:
+        (PluginView):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::setWindowRect):
+        (WebKit::WebChromeClient::windowRect):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::sendSetWindowFrame):
+        (WebKit::WebPage::windowAndViewFramesChanged):
+        * WebProcess/WebPage/WebPage.h:
+        (WebPage):
+        (WebKit::WebPage::windowFrameInScreenCoordinates):
+        (WebKit::WebPage::viewFrameInWindowCoordinates):
+        (WebKit::WebPage::hasCachedWindowFrame):
+        (WebKit::WebPage::accessibilityPosition):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
+        (-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):
+
 2013-03-07  Alexey Proskuryakov  <ap@apple.com>
 
         Don't try to create a sandbox extension when path is empty
index 94e9945..dcaffff 100644 (file)
@@ -400,7 +400,7 @@ struct WKViewInterpretKeyEventsParameters {
     NSRect viewFrameInWindowCoordinates = [self convertRect:[self frame] toView:nil];
     NSPoint accessibilityPosition = [[self accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue];
     
-    _data->_page->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates), IntPoint(accessibilityPosition));
+    _data->_page->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityPosition);
     if (_data->_expandsToFitContentViaAutoLayout)
         _data->_page->viewExposedRectChanged([self visibleRect]);
 }
index 7b7db44..5923d75 100644 (file)
@@ -385,7 +385,7 @@ public:
 
 #if PLATFORM(MAC)
     void updateWindowIsVisible(bool windowIsVisible);
-    void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
+    void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
     void viewExposedRectChanged(const WebCore::FloatRect& exposedRect);
     void setMainFrameIsScrollable(bool);
 
index 6057308..cf41f64 100644 (file)
@@ -129,7 +129,7 @@ void WebPageProxy::updateWindowIsVisible(bool windowIsVisible)
     process()->send(Messages::WebPage::SetWindowIsVisible(windowIsVisible), m_pageID);
 }
 
-void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates, const IntPoint& accessibilityViewCoordinates)
+void WebPageProxy::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
 {
     if (!isValid())
         return;
index 364b0e1..6417fb3 100644 (file)
@@ -482,12 +482,12 @@ void PluginView::setDeviceScaleFactor(float scaleFactor)
     m_plugin->contentsScaleFactorChanged(scaleFactor);
 }
 
-void PluginView::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
+void PluginView::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates)
 {
     if (!m_isInitialized || !m_plugin)
         return;
 
-    m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
+    m_plugin->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates));
 }
 
 bool PluginView::sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
index 9941943..2b14234 100644 (file)
@@ -72,7 +72,7 @@ public:
     void setWindowIsVisible(bool);
     void setWindowIsFocused(bool);
     void setDeviceScaleFactor(float);
-    void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
+    void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates);
     bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
     void setLayerHostingMode(LayerHostingMode);
     RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); }
index 394937a..29fcc3f 100644 (file)
@@ -107,11 +107,16 @@ void WebChromeClient::chromeDestroyed()
 
 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
 {
-    m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
+    m_page->sendSetWindowFrame(windowFrame);
 }
 
 FloatRect WebChromeClient::windowRect()
 {
+#if PLATFORM(MAC)
+    if (m_page->hasCachedWindowFrame())
+        return m_page->windowFrameInScreenCoordinates();
+#endif
+
     FloatRect newWindowFrame;
 
     if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID()))
index 20e8e92..4af1464 100644 (file)
@@ -237,6 +237,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_mainFrameIsScrollable(true)
 #if PLATFORM(MAC)
     , m_pdfPluginEnabled(false)
+    , m_hasCachedWindowFrame(false)
     , m_windowIsVisible(false)
     , m_layerHostingMode(parameters.layerHostingMode)
     , m_keyboardEventBeingInterpreted(0)
@@ -2905,6 +2906,14 @@ void WebPage::removePluginView(PluginView* pluginView)
     m_pluginViews.remove(pluginView);
 }
 
+void WebPage::sendSetWindowFrame(const FloatRect& windowFrame)
+{
+#if PLATFORM(MAC)
+    m_hasCachedWindowFrame = false;
+#endif
+    send(Messages::WebPageProxy::SetWindowFrame(windowFrame));
+}
+
 #if PLATFORM(MAC)
 void WebPage::setWindowIsVisible(bool windowIsVisible)
 {
@@ -2917,7 +2926,7 @@ void WebPage::setWindowIsVisible(bool windowIsVisible)
         (*it)->setWindowIsVisible(windowIsVisible);
 }
 
-void WebPage::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates, const IntPoint& accessibilityViewCoordinates)
+void WebPage::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
 {
     m_windowFrameInScreenCoordinates = windowFrameInScreenCoordinates;
     m_viewFrameInWindowCoordinates = viewFrameInWindowCoordinates;
@@ -2925,7 +2934,9 @@ void WebPage::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoord
     
     // Tell all our plug-in views that the window and view frames have changed.
     for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
-        (*it)->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
+        (*it)->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates));
+
+    m_hasCachedWindowFrame = true;
 }
 #endif
 
index d2c8752..a674a96 100644 (file)
@@ -299,6 +299,8 @@ public:
     void clearMainFrameName();
     void sendClose();
 
+    void sendSetWindowFrame(const WebCore::FloatRect&);
+
     double textZoomFactor() const;
     void setTextZoomFactor(double);
     double pageZoomFactor() const;
@@ -352,8 +354,10 @@ public:
 
     bool windowIsVisible() const { return m_windowIsVisible; }
     void updatePluginsActiveAndFocusedState();
-    const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
-    const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
+    const WebCore::FloatRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
+    const WebCore::FloatRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
+
+    bool hasCachedWindowFrame() const { return m_hasCachedWindowFrame; }
 
     void setTopOverhangImage(PassRefPtr<WebImage>);
     void setBottomOverhangImage(PassRefPtr<WebImage>);
@@ -441,7 +445,7 @@ public:
 #if PLATFORM(MAC)
     void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
     WKAccessibilityWebPageObject* accessibilityRemoteObject();
-    WebCore::IntPoint accessibilityPosition() const { return m_accessibilityPosition; }    
+    const WebCore::FloatPoint& accessibilityPosition() const { return m_accessibilityPosition; }
     
     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
 
@@ -732,7 +736,7 @@ private:
     void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options);
 
     void setWindowIsVisible(bool windowIsVisible);
-    void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
+    void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
 
     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
@@ -841,17 +845,19 @@ private:
 #if PLATFORM(MAC)
     bool m_pdfPluginEnabled;
 
+    bool m_hasCachedWindowFrame;
+
     // Whether the containing window is visible or not.
     bool m_windowIsVisible;
 
     // The frame of the containing window in screen coordinates.
-    WebCore::IntRect m_windowFrameInScreenCoordinates;
+    WebCore::FloatRect m_windowFrameInScreenCoordinates;
 
     // The frame of the view in window coordinates.
-    WebCore::IntRect m_viewFrameInWindowCoordinates;
+    WebCore::FloatRect m_viewFrameInWindowCoordinates;
 
     // The accessibility position of the view.
-    WebCore::IntPoint m_accessibilityPosition;
+    WebCore::FloatPoint m_accessibilityPosition;
     
     // The layer hosting mode.
     LayerHostingMode m_layerHostingMode;
index 0775ded..f2e6552 100644 (file)
@@ -260,7 +260,7 @@ messages -> WebPage LegacyReceiver {
     SendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, String textInput)
 
     SetWindowIsVisible(bool windowIsVisible)
-    WindowAndViewFramesChanged(WebCore::IntRect windowFrameInScreenCoordinates, WebCore::IntRect viewFrameInWindowCoordinates, WebCore::IntPoint accessibilityViewCoordinates)
+    WindowAndViewFramesChanged(WebCore::FloatRect windowFrameInScreenCoordinates, WebCore::FloatRect viewFrameInWindowCoordinates, WebCore::FloatPoint accessibilityViewCoordinates)
     ViewExposedRectChanged(WebCore::FloatRect exposedRect)
     SetMainFrameIsScrollable(bool isScrollable)
     RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken)
index c7229a9..6721b41 100644 (file)
@@ -145,7 +145,7 @@ using namespace WebKit;
         return nil;
 
     if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
-        WebCore::IntPoint point = m_page->accessibilityPosition();
+        const WebCore::FloatPoint& point = m_page->accessibilityPosition();
         return [NSValue valueWithPoint:NSMakePoint(point.x(), point.y())];
     }
     if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {