[BlackBerry] WebKit-side implementation of SelectionOverlay

https://bugs.webkit.org/show_bug.cgi?id=87605

Patch by Arvid Nilsson <anilsson@rim.com> 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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118785 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 327ff313
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[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 <anilsson@rim.com>
[BlackBerry] WebOverlay API
......
......@@ -90,6 +90,7 @@ LIST(APPEND WebKit_SOURCES
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
......
......@@ -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 @@ void WebPagePrivate::init(const WebString& pageGroupName)
#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 @@ void WebPage::setTapHighlight(WebTapHighlight* tapHighlight)
d->m_tapHighlight = adoptPtr(tapHighlight);
}
WebSelectionOverlay* WebPage::selectionOverlay() const
{
return d->m_selectionOverlay.get();
}
void WebPage::addOverlay(WebOverlay* overlay)
{
#if USE(ACCELERATED_COMPOSITING)
......
......@@ -67,6 +67,7 @@ class WebPageClient;
class WebPageCompositor;
class WebPageGroupLoadDeferrer;
class WebPagePrivate;
class WebSelectionOverlay;
class WebSettings;
class WebTapHighlight;
class WebViewportArguments;
......@@ -339,6 +340,8 @@ public:
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*);
......
......@@ -432,6 +432,7 @@ public:
RefPtr<WebCore::Node> m_currentContextNode;
WebSettings* m_webSettings;
OwnPtr<WebTapHighlight> m_tapHighlight;
OwnPtr<WebSelectionOverlay> m_selectionOverlay;
#if ENABLE(JAVASCRIPT_DEBUGGER)
OwnPtr<WebCore::JavaScriptDebuggerBlackBerry> m_scriptDebugger;
......
/*
* 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
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[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 <anilsson@rim.com>
[BlackBerry] WebOverlay API
......
......@@ -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 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly)
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());
}
......
/*
* 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)
/*
* 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment