[BlackBerry] Make DefaultTapHighlight use the new WebOverlay API

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

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-05-29
Reviewed by Antonio Gomes.

Also add a new method to allow the embedder to use the default tap
highlight instead of replacing it with a custom one just to keep track
of the "shouldHideAfterScroll" flag.

PR #160262.

* Api/WebTapHighlight.h:
* WebKitSupport/DefaultTapHighlight.cpp:
(BlackBerry::WebKit::DefaultTapHighlight::DefaultTapHighlight):
(BlackBerry::WebKit::DefaultTapHighlight::draw):
(BlackBerry::WebKit::DefaultTapHighlight::hide):
(BlackBerry::WebKit::DefaultTapHighlight::paintContents):
* WebKitSupport/DefaultTapHighlight.h:
(BlackBerry::WebKit::DefaultTapHighlight::shouldHideAfterScroll):
(DefaultTapHighlight):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1613ae76
...@@ -32,6 +32,8 @@ public: ...@@ -32,6 +32,8 @@ public:
virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0; virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0;
virtual void hide() = 0; virtual void hide() = 0;
virtual bool shouldHideAfterScroll() const = 0;
}; };
} // namespace WebKit } // namespace WebKit
......
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Make DefaultTapHighlight use the new WebOverlay API
https://bugs.webkit.org/show_bug.cgi?id=87604
Reviewed by Antonio Gomes.
Also add a new method to allow the embedder to use the default tap
highlight instead of replacing it with a custom one just to keep track
of the "shouldHideAfterScroll" flag.
PR #160262.
* Api/WebTapHighlight.h:
* WebKitSupport/DefaultTapHighlight.cpp:
(BlackBerry::WebKit::DefaultTapHighlight::DefaultTapHighlight):
(BlackBerry::WebKit::DefaultTapHighlight::draw):
(BlackBerry::WebKit::DefaultTapHighlight::hide):
(BlackBerry::WebKit::DefaultTapHighlight::paintContents):
* WebKitSupport/DefaultTapHighlight.h:
(BlackBerry::WebKit::DefaultTapHighlight::shouldHideAfterScroll):
(DefaultTapHighlight):
2012-05-29 Arvid Nilsson <anilsson@rim.com> 2012-05-29 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebKit-side implementation of SelectionOverlay [BlackBerry] WebKit-side implementation of SelectionOverlay
......
...@@ -23,18 +23,12 @@ ...@@ -23,18 +23,12 @@
#include "DefaultTapHighlight.h" #include "DefaultTapHighlight.h"
#include "GraphicsContext.h" #include "GraphicsContext.h"
#include "GraphicsLayer.h"
#include "LayerCompositingThread.h"
#include "LayerWebKitThread.h"
#include "Path.h" #include "Path.h"
#include "PlatformContextSkia.h" #include "PlatformContextSkia.h"
#include "ScaleTransformOperation.h" #include "WebAnimation.h"
#include "WebPageCompositorClient.h"
#include "WebPageCompositor_p.h"
#include "WebPage_p.h" #include "WebPage_p.h"
#include <BlackBerryPlatformMessageClient.h> #include <BlackBerryPlatformMessageClient.h>
#include <SkCornerPathEffect.h>
using namespace WebCore; using namespace WebCore;
...@@ -48,6 +42,7 @@ static const char* fadeAnimationName() { return "fade"; } ...@@ -48,6 +42,7 @@ static const char* fadeAnimationName() { return "fade"; }
DefaultTapHighlight::DefaultTapHighlight(WebPagePrivate* page) DefaultTapHighlight::DefaultTapHighlight(WebPagePrivate* page)
: m_page(page) : m_page(page)
, m_visible(false) , m_visible(false)
, m_shouldHideAfterScroll(false)
{ {
} }
...@@ -61,37 +56,35 @@ void DefaultTapHighlight::draw(const Platform::IntRectRegion& region, int red, i ...@@ -61,37 +56,35 @@ void DefaultTapHighlight::draw(const Platform::IntRectRegion& region, int red, i
m_region = region; m_region = region;
m_color = Color(red, green, blue, std::min(128, alpha)); m_color = Color(red, green, blue, std::min(128, alpha));
IntRect rect = m_region.extents(); m_shouldHideAfterScroll = hideAfterScroll;
FloatRect rect = IntRect(m_region.extents());
if (rect.isEmpty()) if (rect.isEmpty())
return; return;
m_visible = true; m_visible = true;
if (!m_layer) { if (!m_overlay) {
m_layer = GraphicsLayer::create(this); m_overlay = adoptPtr(new WebOverlay(this));
m_page->overlayLayer()->addChild(m_layer.get()); m_page->m_webPage->addOverlay(m_overlay.get());
} }
m_layer->setPosition(rect.location()); m_overlay->resetOverrides();
m_layer->setSize(rect.size()); m_overlay->setPosition(rect.location());
m_layer->setDrawsContent(true); m_overlay->setSize(rect.size());
m_layer->removeAnimation(fadeAnimationName()); m_overlay->setDrawsContent(true);
m_layer->setOpacity(1.0); m_overlay->removeAnimation(fadeAnimationName());
m_layer->setNeedsDisplay(); m_overlay->setOpacity(1.0);
m_overlay->invalidate();
} }
void DefaultTapHighlight::hide() void DefaultTapHighlight::hide()
{ {
if (!m_layer) if (!m_overlay)
return; return;
// This animation needs to be created anew each time, since // Since WebAnimation is not thread safe, we create a new one each time instead of reusing the same object on different
// the method may be called on differend threads. // threads (that would introduce race conditions).
RefPtr<Animation> fadeAnimation = Animation::create(); WebAnimation fadeAnimation = WebAnimation::fadeAnimation(fadeAnimationName(), 1.0, 0.0, ActiveTextFadeAnimationDuration);
fadeAnimation->setDuration(ActiveTextFadeAnimationDuration);
KeyframeValueList keyframes(AnimatedPropertyOpacity);
keyframes.insert(new FloatAnimationValue(0, 1.0));
keyframes.insert(new FloatAnimationValue(1.0, 0));
// Normally, this method is called on the WebKit thread, but it can also be // Normally, this method is called on the WebKit thread, but it can also be
// called from the compositing thread. // called from the compositing thread.
...@@ -99,18 +92,9 @@ void DefaultTapHighlight::hide() ...@@ -99,18 +92,9 @@ void DefaultTapHighlight::hide()
if (!m_visible) if (!m_visible)
return; return;
m_visible = false; m_visible = false;
m_layer->addAnimation(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0); m_overlay->addAnimation(fadeAnimation);
} else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) { } else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
RefPtr<LayerAnimation> animation = LayerAnimation::create(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0); m_overlay->override()->addAnimation(fadeAnimation);
if (WebPageCompositorClient* compositorClient = m_page->compositor()->client()) {
double animationTime = compositorClient->requestAnimationFrame();
compositorClient->invalidate(animationTime);
}
// FIXME: Unfortunately WebPageCompositorClient::requestAnimationFrame uses a different time coordinate system
// than accelerated animations, so we can't use the time returned by RAF for starttime.
animation->setStartTime(currentTime());
m_layer->platformLayer()->layerCompositingThread()->addAnimation(animation.get());
}
} }
void DefaultTapHighlight::notifySyncRequired(const GraphicsLayer*) void DefaultTapHighlight::notifySyncRequired(const GraphicsLayer*)
...@@ -122,7 +106,7 @@ void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c ...@@ -122,7 +106,7 @@ void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c
{ {
std::vector<Platform::IntRect> rects = m_region.rects(); std::vector<Platform::IntRect> rects = m_region.rects();
Platform::IntRect rect = m_region.extents(); Platform::IntRect rect = m_region.extents();
SkRegion windowRegion; SkRegion overlayRegion;
unsigned rectCount = m_region.numRects(); unsigned rectCount = m_region.numRects();
if (!rectCount) if (!rectCount)
...@@ -131,11 +115,11 @@ void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c ...@@ -131,11 +115,11 @@ void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c
for (unsigned i = 0; i < rectCount; ++i) { for (unsigned i = 0; i < rectCount; ++i) {
Platform::IntRect rectToPaint = rects[i]; Platform::IntRect rectToPaint = rects[i];
SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height()); SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
windowRegion.op(r, SkRegion::kUnion_Op); overlayRegion.op(r, SkRegion::kUnion_Op);
} }
SkPath pathToPaint; SkPath pathToPaint;
windowRegion.getBoundaryPath(&pathToPaint); overlayRegion.getBoundaryPath(&pathToPaint);
Path path(pathToPaint); Path path(pathToPaint);
c.save(); c.save();
......
...@@ -24,10 +24,12 @@ ...@@ -24,10 +24,12 @@
#if USE(ACCELERATED_COMPOSITING) #if USE(ACCELERATED_COMPOSITING)
#include "Color.h" #include "Color.h"
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h" #include "GraphicsLayerClient.h"
#include "WebOverlay.h"
#include "WebTapHighlight.h" #include "WebTapHighlight.h"
#include <BlackBerryPlatformIntRectRegion.h> #include <BlackBerryPlatformIntRectRegion.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h> #include <wtf/PassOwnPtr.h>
namespace BlackBerry { namespace BlackBerry {
...@@ -47,26 +49,26 @@ public: ...@@ -47,26 +49,26 @@ public:
virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll); virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll);
virtual void hide(); virtual void hide();
virtual bool shouldHideAfterScroll() const { return m_shouldHideAfterScroll; }
// GraphicsLayerClient // GraphicsLayerClient
virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { } virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { }
virtual void notifySyncRequired(const WebCore::GraphicsLayer*); virtual void notifySyncRequired(const WebCore::GraphicsLayer*);
virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip); 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 showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; } virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
#if PLATFORM(BLACKBERRY)
virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; } virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
#endif
private: private:
DefaultTapHighlight(WebPagePrivate*); DefaultTapHighlight(WebPagePrivate*);
WebPagePrivate* m_page; WebPagePrivate* m_page;
OwnPtr<WebCore::GraphicsLayer> m_layer; OwnPtr<WebOverlay> m_overlay;
BlackBerry::Platform::IntRectRegion m_region; BlackBerry::Platform::IntRectRegion m_region;
WebCore::Color m_color; WebCore::Color m_color;
bool m_visible; bool m_visible;
bool m_shouldHideAfterScroll;
}; };
} // namespace WebKit } // namespace WebKit
......
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