Title: [118785] trunk/Source/WebKit
Revision
118785
Author
[email protected]
Date
2012-05-29 09:06:16 -0700 (Tue, 29 May 2012)

Log Message

[BlackBerry] WebKit-side implementation of SelectionOverlay
https://bugs.webkit.org/show_bug.cgi?id=87605

Patch by Arvid Nilsson <[email protected]> on 2012-05-29
Reviewed by Rob Buis.

Source/WebKit:

Add SelectionOverlay to the build system.

PR #160263

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

Leverage the new WebOverlay API to move SelectionOverlay to the WebKit
library, so we always draw selection regardless of which embedder is
integrating WebKit.

PR #160263

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::init):
(BlackBerry::WebKit::WebPage::selectionOverlay):
(WebKit):
* Api/WebPage.h:
(WebKit):
* Api/WebPage_p.h:
(WebPagePrivate):
* Api/WebSelectionOverlay.h: Added.
(WebKit):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
* WebKitSupport/SelectionOverlay.cpp: Added.
(WebKit):
(BlackBerry::WebKit::SelectionOverlay::SelectionOverlay):
(BlackBerry::WebKit::SelectionOverlay::~SelectionOverlay):
(BlackBerry::WebKit::SelectionOverlay::draw):
(BlackBerry::WebKit::SelectionOverlay::hide):
(BlackBerry::WebKit::SelectionOverlay::notifySyncRequired):
(BlackBerry::WebKit::SelectionOverlay::paintContents):
* WebKitSupport/SelectionOverlay.h: Added.
(WebKit):
(SelectionOverlay):
(BlackBerry::WebKit::SelectionOverlay::create):
(BlackBerry::WebKit::SelectionOverlay::notifyAnimationStarted):
(BlackBerry::WebKit::SelectionOverlay::showDebugBorders):
(BlackBerry::WebKit::SelectionOverlay::showRepaintCounter):
(BlackBerry::WebKit::SelectionOverlay::contentsVisible):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (118784 => 118785)


--- trunk/Source/WebKit/ChangeLog	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/ChangeLog	2012-05-29 16:06:16 UTC (rev 118785)
@@ -1,5 +1,18 @@
 2012-05-29  Arvid Nilsson  <[email protected]>
 
+        [BlackBerry] WebKit-side implementation of SelectionOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=87605
+
+        Reviewed by Rob Buis.
+
+        Add SelectionOverlay to the build system.
+
+        PR #160263
+
+        * PlatformBlackBerry.cmake:
+
+2012-05-29  Arvid Nilsson  <[email protected]>
+
         [BlackBerry] WebOverlay API
         https://bugs.webkit.org/show_bug.cgi?id=87603
 

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (118784 => 118785)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-29 16:06:16 UTC (rev 118785)
@@ -90,6 +90,7 @@
     blackberry/WebKitSupport/InputHandler.cpp
     blackberry/WebKitSupport/RenderQueue.cpp
     blackberry/WebKitSupport/SelectionHandler.cpp
+    blackberry/WebKitSupport/SelectionOverlay.cpp
     blackberry/WebKitSupport/SurfacePool.cpp
     blackberry/WebKitSupport/TouchEventHandler.cpp
     blackberry/WebKitSupport/FatFingers.cpp

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (118784 => 118785)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-29 16:06:16 UTC (rev 118785)
@@ -42,6 +42,7 @@
 #include "Database.h"
 #include "DatabaseSync.h"
 #include "DatabaseTracker.h"
+#include "DefaultTapHighlight.h"
 #include "DeviceMotionClientBlackBerry.h"
 #include "DeviceOrientationClientBlackBerry.h"
 #include "DragClientBlackBerry.h"
@@ -100,6 +101,7 @@
 #include "ScriptValue.h"
 #include "ScrollTypes.h"
 #include "SelectionHandler.h"
+#include "SelectionOverlay.h"
 #include "Settings.h"
 #include "Storage.h"
 #include "StorageNamespace.h"
@@ -134,7 +136,6 @@
 #endif
 
 #if USE(ACCELERATED_COMPOSITING)
-#include "DefaultTapHighlight.h"
 #include "FrameLayers.h"
 #include "WebPageCompositor_p.h"
 #endif
@@ -509,6 +510,7 @@
 
 #if USE(ACCELERATED_COMPOSITING)
     m_tapHighlight = DefaultTapHighlight::create(this);
+    m_selectionOverlay = SelectionOverlay::create(this);
 #endif
 
     // FIXME: We explicitly call setDelegate() instead of passing ourself in createFromStandardSettings()
@@ -6208,6 +6210,11 @@
     d->m_tapHighlight = adoptPtr(tapHighlight);
 }
 
+WebSelectionOverlay* WebPage::selectionOverlay() const
+{
+    return d->m_selectionOverlay.get();
+}
+
 void WebPage::addOverlay(WebOverlay* overlay)
 {
 #if USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (118784 => 118785)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-05-29 16:06:16 UTC (rev 118785)
@@ -67,6 +67,7 @@
 class WebPageCompositor;
 class WebPageGroupLoadDeferrer;
 class WebPagePrivate;
+class WebSelectionOverlay;
 class WebSettings;
 class WebTapHighlight;
 class WebViewportArguments;
@@ -339,6 +340,8 @@
     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.
     void addOverlay(WebOverlay*);

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (118784 => 118785)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-29 16:06:16 UTC (rev 118785)
@@ -432,6 +432,7 @@
     RefPtr<WebCore::Node> m_currentContextNode;
     WebSettings* m_webSettings;
     OwnPtr<WebTapHighlight> m_tapHighlight;
+    OwnPtr<WebSelectionOverlay> m_selectionOverlay;
 
 #if ENABLE(_javascript__DEBUGGER)
     OwnPtr<WebCore::_javascript_DebuggerBlackBerry> m_scriptDebugger;

Added: trunk/Source/WebKit/blackberry/Api/WebSelectionOverlay.h (0 => 118785)


--- trunk/Source/WebKit/blackberry/Api/WebSelectionOverlay.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/Api/WebSelectionOverlay.h	2012-05-29 16:06:16 UTC (rev 118785)
@@ -0,0 +1,40 @@
+/*
+ * 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 <BlackBerryPlatformIntRectRegion.h>
+
+namespace BlackBerry {
+namespace WebKit {
+
+class BLACKBERRY_EXPORT WebSelectionOverlay {
+public:
+    virtual ~WebSelectionOverlay() { }
+
+    virtual void draw(const Platform::IntRectRegion&) = 0;
+    virtual void hide() = 0;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // WebSelectionOverlay_h

Modified: trunk/Source/WebKit/blackberry/ChangeLog (118784 => 118785)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-29 16:06:16 UTC (rev 118785)
@@ -1,5 +1,47 @@
 2012-05-29  Arvid Nilsson  <[email protected]>
 
+        [BlackBerry] WebKit-side implementation of SelectionOverlay
+        https://bugs.webkit.org/show_bug.cgi?id=87605
+
+        Reviewed by Rob Buis.
+
+        Leverage the new WebOverlay API to move SelectionOverlay to the WebKit
+        library, so we always draw selection regardless of which embedder is
+        integrating WebKit.
+
+        PR #160263
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::init):
+        (BlackBerry::WebKit::WebPage::selectionOverlay):
+        (WebKit):
+        * Api/WebPage.h:
+        (WebKit):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * Api/WebSelectionOverlay.h: Added.
+        (WebKit):
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
+        * WebKitSupport/SelectionOverlay.cpp: Added.
+        (WebKit):
+        (BlackBerry::WebKit::SelectionOverlay::SelectionOverlay):
+        (BlackBerry::WebKit::SelectionOverlay::~SelectionOverlay):
+        (BlackBerry::WebKit::SelectionOverlay::draw):
+        (BlackBerry::WebKit::SelectionOverlay::hide):
+        (BlackBerry::WebKit::SelectionOverlay::notifySyncRequired):
+        (BlackBerry::WebKit::SelectionOverlay::paintContents):
+        * WebKitSupport/SelectionOverlay.h: Added.
+        (WebKit):
+        (SelectionOverlay):
+        (BlackBerry::WebKit::SelectionOverlay::create):
+        (BlackBerry::WebKit::SelectionOverlay::notifyAnimationStarted):
+        (BlackBerry::WebKit::SelectionOverlay::showDebugBorders):
+        (BlackBerry::WebKit::SelectionOverlay::showRepaintCounter):
+        (BlackBerry::WebKit::SelectionOverlay::contentsVisible):
+
+2012-05-29  Arvid Nilsson  <[email protected]>
+
         [BlackBerry] WebOverlay API
         https://bugs.webkit.org/show_bug.cgi?id=87603
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp (118784 => 118785)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-05-29 16:02:00 UTC (rev 118784)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-05-29 16:06:16 UTC (rev 118785)
@@ -32,6 +32,7 @@
 #include "TouchEventHandler.h"
 #include "WebPageClient.h"
 #include "WebPage_p.h"
+#include "WebSelectionOverlay.h"
 
 #include "htmlediting.h"
 #include "visible_units.h"
@@ -924,6 +925,8 @@
     DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::selectionPositionChanged Start Rect=(%d, %d) (%d x %d) End Rect=(%d, %d) (%d x %d)",
                     startCaret.x(), startCaret.y(), startCaret.width(), startCaret.height(), endCaret.x(), endCaret.y(), endCaret.width(), endCaret.height());
 
+    if (m_webPage->m_selectionOverlay)
+        m_webPage->m_selectionOverlay->draw(visibleSelectionRegion);
 
     m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch());
 }

Added: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.cpp (0 => 118785)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.cpp	2012-05-29 16:06:16 UTC (rev 118785)
@@ -0,0 +1,125 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "SelectionOverlay.h"
+
+#include "GraphicsContext.h"
+#include "Path.h"
+#include "PlatformContextSkia.h"
+#include "RenderTheme.h"
+#include "WebPage_p.h"
+
+#include <BlackBerryPlatformMessageClient.h>
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+SelectionOverlay::SelectionOverlay(WebPagePrivate* page)
+    : m_page(page)
+{
+}
+
+SelectionOverlay::~SelectionOverlay()
+{
+}
+
+void SelectionOverlay::draw(const Platform::IntRectRegion& region)
+{
+    ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
+    m_region = region;
+    FloatRect rect = IntRect(m_region.extents());
+    if (rect.isEmpty()) {
+        hide();
+        return;
+    }
+
+    if (!m_overlay)
+        m_overlay = adoptPtr(new WebOverlay(this));
+
+    m_page->m_webPage->addOverlay(m_overlay.get());
+    m_overlay->resetOverrides();
+    m_overlay->setPosition(rect.location());
+    m_overlay->setSize(rect.size());
+    m_overlay->setDrawsContent(true);
+    m_overlay->setOpacity(1.0);
+    m_overlay->invalidate();
+}
+
+void SelectionOverlay::hide()
+{
+    if (!m_overlay)
+        return;
+
+    // Normally, this method is called on the WebKit thread, but it can also be
+    // called from the compositing thread.
+    if (BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread())
+        m_page->m_webPage->removeOverlay(m_overlay.get());
+    else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
+        m_overlay->override()->setOpacity(0);
+}
+
+void SelectionOverlay::notifySyncRequired(const GraphicsLayer*)
+{
+    m_page->scheduleRootLayerCommit();
+}
+
+void SelectionOverlay::paintContents(const GraphicsLayer*, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& inClip)
+{
+    std::vector<Platform::IntRect> rects = m_region.rects();
+    Platform::IntRect rect = m_region.extents();
+    SkRegion windowRegion;
+
+    unsigned rectCount = m_region.numRects();
+    if (!rectCount)
+        return;
+
+    IntRect clip(inClip);
+    clip.move(rect.x(), rect.y());
+    for (unsigned i = 0; i < rectCount; ++i) {
+        IntRect rectToPaint = rects[i];
+        rectToPaint.intersect(clip);
+        SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
+        windowRegion.op(r, SkRegion::kUnion_Op);
+    }
+
+    SkPath pathToPaint;
+    windowRegion.getBoundaryPath(&pathToPaint);
+
+    Path path(pathToPaint);
+    c.save();
+    c.translate(-rect.x(), -rect.y());
+
+    // Draw selection overlay
+    Color color = RenderTheme::defaultTheme()->activeSelectionBackgroundColor();
+    c.setFillColor(color, ColorSpaceDeviceRGB);
+    c.fillPath(path);
+
+    c.restore();
+}
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)

Added: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h (0 => 118785)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h	2012-05-29 16:06:16 UTC (rev 118785)
@@ -0,0 +1,74 @@
+/*
+ * 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 SelectionOverlay_h
+#define SelectionOverlay_h
+
+#include "BlackBerryGlobal.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#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 {
+public:
+    static PassOwnPtr<SelectionOverlay> create(WebPagePrivate* page)
+    {
+        return adoptPtr(new SelectionOverlay(page));
+    }
+
+    virtual ~SelectionOverlay();
+
+    virtual void draw(const Platform::IntRectRegion&);
+    virtual void hide();
+
+    // GraphicsLayerClient
+    virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { }
+    virtual void notifySyncRequired(const WebCore::GraphicsLayer*);
+    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
+    virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
+    virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
+    virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
+
+
+private:
+    SelectionOverlay(WebPagePrivate*);
+
+    WebPagePrivate* m_page;
+    OwnPtr<WebOverlay> m_overlay;
+    BlackBerry::Platform::IntRectRegion m_region;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // SelectionOverlay_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to