[BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.

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

Source/WebKit:

Patch by Konrad Piascik <kpiascik@rim.com> on 2012-05-30
Reviewed by Antonio Gomes

Added new InspectorOverlay class

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

Patch by Konrad Piascik <kpiascik@rim.com> on 2012-05-30
Reviewed by Antonio Gomes.

Implemented InspectorOverlay using WebOverlayAPI.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::renderContents):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
(BlackBerry::WebKit::WebPagePrivate::commitRootLayerIfNeeded):
(BlackBerry::WebKit::WebPagePrivate::setInspectorOverlayClient):
(WebKit):
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):
* WebCoreSupport/InspectorClientBlackBerry.cpp:
(WebCore::InspectorClientBlackBerry::highlight):
(WebCore::InspectorClientBlackBerry::hideHighlight):
(WebCore::InspectorClientBlackBerry::paintInspectorOverlay):
(WebCore):
* WebCoreSupport/InspectorClientBlackBerry.h:
(InspectorClientBlackBerry):
* WebCoreSupport/InspectorOverlay.cpp: Added.
(WebCore):
(WebCore::InspectorOverlay::create):
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::notifySyncRequired):
(WebCore::InspectorOverlay::paintContents):
(WebCore::InspectorOverlay::showDebugBorders):
(WebCore::InspectorOverlay::showRepaintCounter):
(WebCore::InspectorOverlay::contentsVisible):
(WebCore::InspectorOverlay::~InspectorOverlay):
(WebCore::InspectorOverlay::clear):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::paintWebFrame):
(WebCore::InspectorOverlay::invalidateWebFrame):
* WebCoreSupport/InspectorOverlay.h: Added.
(WebKit):
(WebCore):
(InspectorOverlay):
(InspectorOverlayClient):
(WebCore::InspectorOverlay::setClient):
(WebCore::InspectorOverlay::notifyAnimationStarted):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8829ae01
2012-05-30 Konrad Piascik <kpiascik@rim.com>
[BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.
https://bugs.webkit.org/show_bug.cgi?id=81001
Reviewed by Antonio Gomes
Added new InspectorOverlay class
* PlatformBlackBerry.cmake:
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebKit-side implementation of SelectionOverlay
......
......@@ -75,6 +75,7 @@ LIST(APPEND WebKit_SOURCES
blackberry/WebCoreSupport/GeolocationControllerClientBlackBerry.cpp
blackberry/WebCoreSupport/IconDatabaseClientBlackBerry.cpp
blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp
blackberry/WebCoreSupport/InspectorOverlay.cpp
blackberry/WebCoreSupport/JavaScriptDebuggerBlackBerry.cpp
blackberry/WebCoreSupport/NotificationPresenterImpl.cpp
blackberry/WebCoreSupport/VibrationClientBlackBerry.cpp
......
......@@ -2443,7 +2443,8 @@ void BackingStorePrivate::renderContents(BlackBerry::Platform::Graphics::Buffer*
if (m_webPage->d->m_page->inspectorController()->enabled()) {
WebCore::IntPoint scrollPosition = m_client->frame()->view()->scrollPosition();
graphicsContext.translate(scrollPosition.x(), scrollPosition.y());
m_webPage->d->m_page->inspectorController()->drawHighlight(graphicsContext);
if (m_webPage->d->m_inspectorOverlay)
m_webPage->d->m_inspectorOverlay->paintWebFrame(graphicsContext);
}
#endif
......
......@@ -75,6 +75,7 @@
#include "InspectorBackendDispatcher.h"
#include "InspectorClientBlackBerry.h"
#include "InspectorController.h"
#include "InspectorOverlay.h"
#include "JavaScriptDebuggerBlackBerry.h"
#include "LayerWebKitThread.h"
#include "NetworkManager.h"
......@@ -3217,6 +3218,8 @@ void WebPagePrivate::updateDelegatedOverlays(bool dispatched)
// Must be called on the WebKit thread.
if (m_selectionHandler->isSelectionActive())
m_selectionHandler->selectionPositionChanged(true /* visualChangeOnly */);
if (m_inspectorOverlay)
m_inspectorOverlay->update();
} else if (m_selectionHandler->isSelectionActive()) {
// Don't bother dispatching to webkit thread if selection and tap highlight are not active.
......@@ -5759,6 +5762,7 @@ bool WebPagePrivate::commitRootLayerIfNeeded()
double scale = currentScale();
if (m_frameLayers && m_frameLayers->hasLayer())
m_frameLayers->commitOnWebKitThread(scale);
updateDelegatedOverlays();
if (m_overlayLayer)
m_overlayLayer->platformLayer()->commitOnWebKitThread(scale);
......@@ -6284,5 +6288,23 @@ void WebPagePrivate::setParentPopup(PagePopupBlackBerry* webPopup)
m_parentPopup = webPopup;
}
void WebPagePrivate::setInspectorOverlayClient(WebCore::InspectorOverlay::InspectorOverlayClient* inspectorOverlayClient)
{
if (inspectorOverlayClient) {
if (!m_inspectorOverlay)
m_inspectorOverlay = WebCore::InspectorOverlay::create(this, inspectorOverlayClient);
else
m_inspectorOverlay->setClient(inspectorOverlayClient);
m_inspectorOverlay->update();
scheduleRootLayerCommit();
} else {
if (m_inspectorOverlay) {
m_inspectorOverlay->clear();
m_inspectorOverlay = nullptr;
scheduleRootLayerCommit();
}
}
}
}
}
......@@ -20,6 +20,7 @@
#define WebPage_p_h
#include "ChromeClient.h"
#include "InspectorOverlay.h"
#if USE(ACCELERATED_COMPOSITING)
#include "GLES2Context.h"
#include "LayerRenderer.h"
......@@ -42,6 +43,7 @@ class DOMWrapperWorld;
class Document;
class Frame;
class GeolocationControllerClientBlackBerry;
class GraphicsLayerBlackBerry;
class JavaScriptDebuggerBlackBerry;
class LayerWebKitThread;
class Node;
......@@ -425,6 +427,8 @@ public:
void deferredTasksTimerFired(WebCore::Timer<WebPagePrivate>*);
void setInspectorOverlayClient(WebCore::InspectorOverlay::InspectorOverlayClient*);
WebPage* m_webPage;
WebPageClient* m_client;
WebCore::Page* m_page;
......@@ -548,6 +552,7 @@ public:
RefPtr<WebCore::DOMWrapperWorld> m_isolatedWorld;
bool m_hasInRegionScrollableAreas;
bool m_updateDelegatedOverlaysDispatched;
OwnPtr<WebCore::InspectorOverlay> m_inspectorOverlay;
// There is no need to initialize the following members in WebPagePrivate's constructor,
// because they are only used by WebPageTasks and the tasks will initialize them when
......
2012-05-30 Konrad Piascik <kpiascik@rim.com>
[BlackBerry] Add an Accelerated Compositing layer for Web Inspector DOM highlight.
https://bugs.webkit.org/show_bug.cgi?id=81001
Reviewed by Antonio Gomes.
Implemented InspectorOverlay using WebOverlayAPI.
* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::renderContents):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::updateDelegatedOverlays):
(BlackBerry::WebKit::WebPagePrivate::commitRootLayerIfNeeded):
(BlackBerry::WebKit::WebPagePrivate::setInspectorOverlayClient):
(WebKit):
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):
* WebCoreSupport/InspectorClientBlackBerry.cpp:
(WebCore::InspectorClientBlackBerry::highlight):
(WebCore::InspectorClientBlackBerry::hideHighlight):
(WebCore::InspectorClientBlackBerry::paintInspectorOverlay):
(WebCore):
* WebCoreSupport/InspectorClientBlackBerry.h:
(InspectorClientBlackBerry):
* WebCoreSupport/InspectorOverlay.cpp: Added.
(WebCore):
(WebCore::InspectorOverlay::create):
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::notifySyncRequired):
(WebCore::InspectorOverlay::paintContents):
(WebCore::InspectorOverlay::showDebugBorders):
(WebCore::InspectorOverlay::showRepaintCounter):
(WebCore::InspectorOverlay::contentsVisible):
(WebCore::InspectorOverlay::~InspectorOverlay):
(WebCore::InspectorOverlay::clear):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::paintWebFrame):
(WebCore::InspectorOverlay::invalidateWebFrame):
* WebCoreSupport/InspectorOverlay.h: Added.
(WebKit):
(WebCore):
(InspectorOverlay):
(InspectorOverlayClient):
(WebCore::InspectorOverlay::setClient):
(WebCore::InspectorOverlay::notifyAnimationStarted):
2012-05-30 Sean Wang <Xuewen.Wang@torchmobile.com.cn>
[BlackBerry] Browser crashed when selecting in textarea
......
......@@ -22,7 +22,10 @@
#include "BackingStore.h"
#include "Frame.h"
#include "GraphicsContext.h"
#include "InspectorController.h"
#include "NotImplemented.h"
#include "Page.h"
#include "RenderObject.h"
#include "WebPageClient.h"
#include "WebPage_p.h"
......@@ -42,17 +45,16 @@ void InspectorClientBlackBerry::inspectorDestroyed()
void InspectorClientBlackBerry::highlight()
{
hideHighlight();
m_webPagePrivate->setInspectorOverlayClient(this);
if (!m_webPagePrivate->isAcceleratedCompositingActive())
m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
}
void InspectorClientBlackBerry::hideHighlight()
{
if (!m_webPagePrivate->mainFrame() || !m_webPagePrivate->mainFrame()->document() || !m_webPagePrivate->mainFrame()->document()->documentElement()
|| !m_webPagePrivate->mainFrame()->document()->documentElement()->renderer())
return;
// FIXME: Potentially slow hack, but invalidating everything should work since the actual highlight is drawn by BackingStorePrivate::renderContents().
m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
m_webPagePrivate->setInspectorOverlayClient(0);
if (!m_webPagePrivate->isAcceleratedCompositingActive())
m_webPagePrivate->mainFrame()->document()->documentElement()->renderer()->repaint(true);
}
void InspectorClientBlackBerry::openInspectorFrontend(InspectorController*)
......@@ -92,4 +94,11 @@ void InspectorClientBlackBerry::updateInspectorStateCookie(const String& cookie)
notImplemented();
};
void InspectorClientBlackBerry::paintInspectorOverlay(GraphicsContext& gc)
{
InspectorController* inspectorController = m_webPagePrivate->m_page->inspectorController();
if (inspectorController)
inspectorController->drawHighlight(gc);
}
} // namespace WebCore
......@@ -21,6 +21,7 @@
#define InspectorClientBlackBerry_h
#include "InspectorClient.h"
#include "InspectorOverlay.h"
#include "PlatformString.h"
#include <wtf/HashMap.h>
......@@ -32,7 +33,7 @@ class WebPagePrivate;
namespace WebCore {
class InspectorClientBlackBerry : public InspectorClient {
class InspectorClientBlackBerry : public InspectorClient, public InspectorOverlay::InspectorOverlayClient {
public:
InspectorClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
virtual void inspectorDestroyed();
......@@ -50,6 +51,7 @@ public:
virtual bool canClearBrowserCache() { return true; }
virtual void clearBrowserCookies();
virtual bool canClearBrowserCookies() { return true; }
virtual void paintInspectorOverlay(WebCore::GraphicsContext&);
virtual void updateInspectorStateCookie(const String&);
......
/*
* 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"
#include "InspectorOverlay.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "GraphicsLayer.h"
#include "Page.h"
#include "Settings.h"
#include "WebPage_p.h"
namespace WebCore {
PassOwnPtr<InspectorOverlay> InspectorOverlay::create(BlackBerry::WebKit::WebPagePrivate* page, InspectorOverlayClient* client)
{
return adoptPtr(new InspectorOverlay(page, client));
}
InspectorOverlay::InspectorOverlay(BlackBerry::WebKit::WebPagePrivate* page, InspectorOverlayClient* client)
: m_webPage(page)
, m_client(client)
{
}
#if USE(ACCELERATED_COMPOSITING)
void InspectorOverlay::notifySyncRequired(const GraphicsLayer*)
{
m_webPage->scheduleRootLayerCommit();
}
void InspectorOverlay::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& inClip)
{
context.save();
IntPoint scrollPosition = m_webPage->focusedOrMainFrame()->view()->scrollPosition();
context.translate(scrollPosition.x(), scrollPosition.y());
m_client->paintInspectorOverlay(context);
context.restore();
}
bool InspectorOverlay::showDebugBorders(const GraphicsLayer*) const
{
return m_webPage->m_page->settings()->showDebugBorders();
}
bool InspectorOverlay::showRepaintCounter(const GraphicsLayer*) const
{
return m_webPage->m_page->settings()->showRepaintCounter();
}
bool InspectorOverlay::contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const
{
return true;
}
#endif
InspectorOverlay::~InspectorOverlay() { }
void InspectorOverlay::clear()
{
invalidateWebFrame();
#if USE(ACCELERATED_COMPOSITING)
if (m_overlay) {
m_overlay->removeFromParent();
m_overlay = nullptr;
}
#endif
}
void InspectorOverlay::update()
{
invalidateWebFrame();
#if USE(ACCELERATED_COMPOSITING)
if (!m_overlay) {
m_overlay = adoptPtr(new BlackBerry::WebKit::WebOverlay(this));
const IntSize size = m_webPage->viewportSize();
m_overlay->setSize(FloatSize(size.width(), size.height()));
m_webPage->m_webPage->addOverlay(m_overlay.get());
}
m_overlay->setDrawsContent(true);
m_overlay->setOpacity(1.0);
m_overlay->invalidate();
#endif
}
void InspectorOverlay::paintWebFrame(GraphicsContext& gc)
{
if (!m_webPage->isAcceleratedCompositingActive())
m_client->paintInspectorOverlay(gc);
}
void InspectorOverlay::invalidateWebFrame()
{
// InspectorOverlayClient does the actual painting of the overlay.
// Here we just make sure to invalidate.
if (!m_webPage->isAcceleratedCompositingActive()) {
// FIXME: able to invalidate a smaller rect.
// FIXME: Is it important to just invalidate a smaller rect given that
// this is not on a critical codepath? In order to do so, we'd
// have to take scrolling into account.
const IntSize size = m_webPage->viewportSize();
IntRect damagedRect(0, 0, size.width(), size.height());
}
}
}
/*
* 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 InspectorOverlay_h
#define InspectorOverlay_h
#include "WebOverlay.h"
#include <GraphicsLayerClient.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace BlackBerry {
namespace WebKit {
class WebPagePrivate;
}
}
namespace WebCore {
class GraphicsContext;
class GraphicsLayer;
class InspectorOverlay : public WebCore::GraphicsLayerClient {
public:
class InspectorOverlayClient {
public:
virtual void paintInspectorOverlay(GraphicsContext&) = 0;
};
static PassOwnPtr<InspectorOverlay> create(BlackBerry::WebKit::WebPagePrivate*, InspectorOverlayClient*);
~InspectorOverlay();
void setClient(InspectorOverlayClient* client) { m_client = client; }
void clear();
void update();
void paintWebFrame(GraphicsContext&);
#if USE(ACCELERATED_COMPOSITING)
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
virtual void notifySyncRequired(const GraphicsLayer*);
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
virtual bool showDebugBorders(const GraphicsLayer*) const;
virtual bool showRepaintCounter(const GraphicsLayer*) const;
virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const;
#endif
private:
InspectorOverlay(BlackBerry::WebKit::WebPagePrivate*, InspectorOverlayClient*);
void invalidateWebFrame();
BlackBerry::WebKit::WebPagePrivate* m_webPage;
InspectorOverlayClient* m_client;
OwnPtr<BlackBerry::WebKit::WebOverlay> m_overlay;
};
} // namespace WebCore
#endif /* InspectorOverlay_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