[BlackBerry] Let WebKit manage the SelectionOverlay
authoranilsson@rim.com <anilsson@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2012 14:52:17 +0000 (14:52 +0000)
committeranilsson@rim.com <anilsson@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2012 14:52:17 +0000 (14:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99585

Reviewed by Rob Buis.

The SelectionOverlay was exposed to clients of the BlackBerry::WebKit
API. However, all the information and notifications necessary to manage
the SelectionOverlay are available within WebKit, so the client does
not have to shoulder this responsibility.

Remove WebSelection and all the related plumbing. Now that nobody is
using the class from the user interface thread, remove the message
related code in SelectionOverlay.

Add two calls to SelectionOverlay::hide() that are necessary now that
the client is no longer responsible for hiding it.

RIM PR: 225789

Reviewed internally by Mike Fenton.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::~WebPagePrivate):
* Api/WebPage.h:
(WebKit):
* Api/WebPage_p.h:
(WebPagePrivate):
* Api/WebSelectionOverlay.h: Removed.
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::cancelSelection): Hide the overlay here, because state is reset and selection mode is no longer active
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged): Also hide overlay here, to go with the call to cancelSelectionVisuals
* WebKitSupport/SelectionOverlay.cpp:
(BlackBerry::WebKit::SelectionOverlay::SelectionOverlay):
* WebKitSupport/SelectionOverlay.h:
(BlackBerry::WebKit::SelectionOverlay::create):
(SelectionOverlay):

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

Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/Api/WebPage.h
Source/WebKit/blackberry/Api/WebPage_p.h
Source/WebKit/blackberry/Api/WebSelectionOverlay.h [deleted file]
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h

index d008c02..651a0aa 100644 (file)
@@ -493,11 +493,6 @@ WebPagePrivate::~WebPagePrivate()
     delete m_dumpRenderTree;
     m_dumpRenderTree = 0;
 #endif
-
-#if USE(ACCELERATED_COMPOSITING)
-    deleteGuardedObject(m_selectionOverlay);
-    m_selectionOverlay = 0;
-#endif
 }
 
 WebPage::~WebPage()
@@ -6199,16 +6194,6 @@ WebTapHighlight* WebPage::tapHighlight() const
     return d->m_tapHighlight.get();
 }
 
-void WebPage::setTapHighlight(WebTapHighlight* tapHighlight)
-{
-    d->m_tapHighlight = adoptPtr(tapHighlight);
-}
-
-WebSelectionOverlay* WebPage::selectionOverlay() const
-{
-    return d->m_selectionOverlay;
-}
-
 void WebPage::addOverlay(WebOverlay* overlay)
 {
 #if USE(ACCELERATED_COMPOSITING)
index 3d7b6c2..a262927 100644 (file)
@@ -73,7 +73,6 @@ class WebPageClient;
 class WebPageCompositor;
 class WebPageGroupLoadDeferrer;
 class WebPagePrivate;
-class WebSelectionOverlay;
 class WebSettings;
 class WebTapHighlight;
 class WebViewportArguments;
@@ -365,9 +364,6 @@ public:
     void resetUserViewportArguments();
 
     WebTapHighlight* tapHighlight() const;
-    void setTapHighlight(WebTapHighlight*);
-
-    WebSelectionOverlay* selectionOverlay() const;
 
     // Adds an overlay that can be modified on the WebKit thread, and
     // whose attributes can be overridden on the compositing thread.
index eeb7775..c78cd8a 100644 (file)
@@ -33,6 +33,7 @@
 #include "PageClientBlackBerry.h"
 #include "PlatformMouseEvent.h"
 #include "ScriptSourceCode.h"
+#include "SelectionOverlay.h"
 #include "Timer.h"
 #include "ViewportArguments.h"
 #include "WebPage.h"
@@ -470,7 +471,7 @@ public:
     WebSettings* m_webSettings;
     WebCookieJar* m_cookieJar;
     OwnPtr<WebTapHighlight> m_tapHighlight;
-    WebSelectionOverlay* m_selectionOverlay;
+    OwnPtr<SelectionOverlay> m_selectionOverlay;
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     OwnPtr<WebCore::JavaScriptDebuggerBlackBerry> m_scriptDebugger;
diff --git a/Source/WebKit/blackberry/Api/WebSelectionOverlay.h b/Source/WebKit/blackberry/Api/WebSelectionOverlay.h
deleted file mode 100644 (file)
index 6deec35..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef WebSelectionOverlay_h
-#define WebSelectionOverlay_h
-
-#include "BlackBerryGlobal.h"
-
-#include <BlackBerryPlatformGuardedPointer.h>
-#include <BlackBerryPlatformIntRectRegion.h>
-
-namespace BlackBerry {
-namespace WebKit {
-
-class BLACKBERRY_EXPORT WebSelectionOverlay : public BlackBerry::Platform::GuardedPointerBase {
-public:
-    virtual ~WebSelectionOverlay() { }
-
-    virtual void draw(const Platform::IntRectRegion&) = 0;
-    virtual void hide() = 0;
-};
-
-} // namespace WebKit
-} // namespace BlackBerry
-
-#endif // WebSelectionOverlay_h
index 3555fea..c955144 100644 (file)
@@ -1,3 +1,42 @@
+2012-10-23  Arvid Nilsson  <anilsson@rim.com>
+
+        [BlackBerry] Let WebKit manage the SelectionOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=99585
+
+        Reviewed by Rob Buis.
+
+        The SelectionOverlay was exposed to clients of the BlackBerry::WebKit
+        API. However, all the information and notifications necessary to manage
+        the SelectionOverlay are available within WebKit, so the client does
+        not have to shoulder this responsibility.
+
+        Remove WebSelection and all the related plumbing. Now that nobody is
+        using the class from the user interface thread, remove the message
+        related code in SelectionOverlay.
+
+        Add two calls to SelectionOverlay::hide() that are necessary now that
+        the client is no longer responsible for hiding it.
+
+        RIM PR: 225789
+
+        Reviewed internally by Mike Fenton.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::~WebPagePrivate):
+        * Api/WebPage.h:
+        (WebKit):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * Api/WebSelectionOverlay.h: Removed.
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::cancelSelection): Hide the overlay here, because state is reset and selection mode is no longer active
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged): Also hide overlay here, to go with the call to cancelSelectionVisuals
+        * WebKitSupport/SelectionOverlay.cpp:
+        (BlackBerry::WebKit::SelectionOverlay::SelectionOverlay):
+        * WebKitSupport/SelectionOverlay.h:
+        (BlackBerry::WebKit::SelectionOverlay::create):
+        (SelectionOverlay):
+
 2012-10-22  Mike Fenton  <mifenton@rim.com>
 
         [BlackBerry] Remove specialized handling for isIndex fields.
index 2cd4ee3..10e0735 100644 (file)
 #include "HitTestResult.h"
 #include "InputHandler.h"
 #include "IntRect.h"
+#include "SelectionOverlay.h"
 #include "TouchEventHandler.h"
 #include "WebPageClient.h"
 #include "WebPage_p.h"
-#include "WebSelectionOverlay.h"
 
 #include "htmlediting.h"
 #include "visible_units.h"
@@ -83,6 +83,9 @@ void SelectionHandler::cancelSelection()
     m_selectionActive = false;
     m_lastSelectionRegion = IntRectRegion();
 
+    if (m_webPage->m_selectionOverlay)
+        m_webPage->m_selectionOverlay->hide();
+
     SelectionLog(LogLevelInfo, "SelectionHandler::cancelSelection");
 
     if (m_webPage->m_inputHandler->isInputMode())
@@ -859,6 +862,8 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
         return;
 
     if (m_webPage->m_inputHandler->isInputMode() && m_webPage->m_inputHandler->processingChange()) {
+        if (m_webPage->m_selectionOverlay)
+            m_webPage->m_selectionOverlay->hide();
         m_webPage->m_client->cancelSelectionVisuals();
 
         // Since we're not calling notifyCaretPositionChangedIfNeeded now, we have to do so at the end of processing
index e1f4701..e06f7df 100644 (file)
@@ -38,7 +38,6 @@ namespace WebKit {
 
 SelectionOverlay::SelectionOverlay(WebPagePrivate* page)
     : m_page(page)
-    , m_hideDispatched(false)
 {
 }
 
@@ -71,21 +70,6 @@ void SelectionOverlay::draw(const Platform::IntRectRegion& region)
 
 void SelectionOverlay::hide()
 {
-    // Track a dispatched message, we don't want to flood the webkit thread.
-    // There can be as many as one more message enqued as needed but never less.
-    if (isWebKitThread())
-        m_hideDispatched = false;
-    else if (m_hideDispatched) {
-        // Early return if there is message already pending on the webkit thread.
-        return;
-    }
-    if (!isWebKitThread()) {
-        m_hideDispatched = true;
-        // Normally, this method is called on the WebKit thread, but it can also be
-        // called from the compositing thread.
-        dispatchWebKitMessage(BlackBerry::Platform::createMethodCallMessage(&SelectionOverlay::hide, this));
-        return;
-    }
     ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
 
     if (!m_overlay)
index c1a0f86..5762b5a 100644 (file)
 #include "Color.h"
 #include "GraphicsLayerClient.h"
 #include "WebOverlay.h"
-#include "WebSelectionOverlay.h"
 
 #include <BlackBerryPlatformIntRectRegion.h>
 #include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 
 namespace BlackBerry {
 namespace WebKit {
 
 class WebPagePrivate;
 
-class SelectionOverlay : public WebSelectionOverlay, public WebCore::GraphicsLayerClient {
+class SelectionOverlay : public WebCore::GraphicsLayerClient {
 public:
-    static SelectionOverlay* create(WebPagePrivate* page)
+    static PassOwnPtr<SelectionOverlay> create(WebPagePrivate* page)
     {
-        return new SelectionOverlay(page);
+        return adoptPtr(new SelectionOverlay(page));
     }
 
     virtual ~SelectionOverlay();
@@ -61,7 +61,6 @@ private:
     WebPagePrivate* m_page;
     OwnPtr<WebOverlay> m_overlay;
     BlackBerry::Platform::IntRectRegion m_region;
-    bool m_hideDispatched;
 };
 
 } // namespace WebKit