Title: [118805] trunk/Source/WebKit/blackberry
Revision
118805
Author
[email protected]
Date
2012-05-29 10:50:56 -0700 (Tue, 29 May 2012)

Log Message

[BlackBerry] Make DefaultTapHighlight use the new WebOverlay API
https://bugs.webkit.org/show_bug.cgi?id=87604

Patch by Arvid Nilsson <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h (118804 => 118805)


--- trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h	2012-05-29 17:50:03 UTC (rev 118804)
+++ trunk/Source/WebKit/blackberry/Api/WebTapHighlight.h	2012-05-29 17:50:56 UTC (rev 118805)
@@ -32,6 +32,8 @@
 
     virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0;
     virtual void hide() = 0;
+
+    virtual bool shouldHideAfterScroll() const = 0;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/blackberry/ChangeLog (118804 => 118805)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-29 17:50:03 UTC (rev 118804)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-29 17:50:56 UTC (rev 118805)
@@ -1,5 +1,28 @@
 2012-05-29  Arvid Nilsson  <[email protected]>
 
+        [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  <[email protected]>
+
         [BlackBerry] WebKit-side implementation of SelectionOverlay
         https://bugs.webkit.org/show_bug.cgi?id=87605
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp (118804 => 118805)


--- trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp	2012-05-29 17:50:03 UTC (rev 118804)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp	2012-05-29 17:50:56 UTC (rev 118805)
@@ -23,18 +23,12 @@
 #include "DefaultTapHighlight.h"
 
 #include "GraphicsContext.h"
-#include "GraphicsLayer.h"
-#include "LayerCompositingThread.h"
-#include "LayerWebKitThread.h"
 #include "Path.h"
 #include "PlatformContextSkia.h"
-#include "ScaleTransformOperation.h"
-#include "WebPageCompositorClient.h"
-#include "WebPageCompositor_p.h"
+#include "WebAnimation.h"
 #include "WebPage_p.h"
 
 #include <BlackBerryPlatformMessageClient.h>
-#include <SkCornerPathEffect.h>
 
 using namespace WebCore;
 
@@ -48,6 +42,7 @@
 DefaultTapHighlight::DefaultTapHighlight(WebPagePrivate* page)
     : m_page(page)
     , m_visible(false)
+    , m_shouldHideAfterScroll(false)
 {
 }
 
@@ -61,37 +56,35 @@
 
     m_region = region;
     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())
         return;
 
     m_visible = true;
 
-    if (!m_layer) {
-        m_layer = GraphicsLayer::create(this);
-        m_page->overlayLayer()->addChild(m_layer.get());
+    if (!m_overlay) {
+        m_overlay = adoptPtr(new WebOverlay(this));
+        m_page->m_webPage->addOverlay(m_overlay.get());
     }
 
-    m_layer->setPosition(rect.location());
-    m_layer->setSize(rect.size());
-    m_layer->setDrawsContent(true);
-    m_layer->removeAnimation(fadeAnimationName());
-    m_layer->setOpacity(1.0);
-    m_layer->setNeedsDisplay();
+    m_overlay->resetOverrides();
+    m_overlay->setPosition(rect.location());
+    m_overlay->setSize(rect.size());
+    m_overlay->setDrawsContent(true);
+    m_overlay->removeAnimation(fadeAnimationName());
+    m_overlay->setOpacity(1.0);
+    m_overlay->invalidate();
 }
 
 void DefaultTapHighlight::hide()
 {
-    if (!m_layer)
+    if (!m_overlay)
         return;
 
-    // This animation needs to be created anew each time, since
-    // the method may be called on differend threads.
-    RefPtr<Animation> fadeAnimation = Animation::create();
-    fadeAnimation->setDuration(ActiveTextFadeAnimationDuration);
-    KeyframeValueList keyframes(AnimatedPropertyOpacity);
-    keyframes.insert(new FloatAnimationValue(0, 1.0));
-    keyframes.insert(new FloatAnimationValue(1.0, 0));
+    // Since WebAnimation is not thread safe, we create a new one each time instead of reusing the same object on different
+    // threads (that would introduce race conditions).
+    WebAnimation fadeAnimation = WebAnimation::fadeAnimation(fadeAnimationName(), 1.0, 0.0, ActiveTextFadeAnimationDuration);
 
     // Normally, this method is called on the WebKit thread, but it can also be
     // called from the compositing thread.
@@ -99,18 +92,9 @@
         if (!m_visible)
             return;
         m_visible = false;
-        m_layer->addAnimation(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0);
-    } else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
-        RefPtr<LayerAnimation> animation = LayerAnimation::create(keyframes, m_region.extents().size(), fadeAnimation.get(), fadeAnimationName(), 0.0);
-        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());
-    }
+        m_overlay->addAnimation(fadeAnimation);
+    } else if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
+        m_overlay->override()->addAnimation(fadeAnimation);
 }
 
 void DefaultTapHighlight::notifySyncRequired(const GraphicsLayer*)
@@ -122,7 +106,7 @@
 {
     std::vector<Platform::IntRect> rects = m_region.rects();
     Platform::IntRect rect = m_region.extents();
-    SkRegion windowRegion;
+    SkRegion overlayRegion;
 
     unsigned rectCount = m_region.numRects();
     if (!rectCount)
@@ -131,11 +115,11 @@
     for (unsigned i = 0; i < rectCount; ++i) {
         Platform::IntRect rectToPaint = rects[i];
         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;
-    windowRegion.getBoundaryPath(&pathToPaint);
+    overlayRegion.getBoundaryPath(&pathToPaint);
 
     Path path(pathToPaint);
     c.save();

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h (118804 => 118805)


--- trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h	2012-05-29 17:50:03 UTC (rev 118804)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h	2012-05-29 17:50:56 UTC (rev 118805)
@@ -24,10 +24,12 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "Color.h"
-#include "GraphicsLayer.h"
 #include "GraphicsLayerClient.h"
+#include "WebOverlay.h"
 #include "WebTapHighlight.h"
+
 #include <BlackBerryPlatformIntRectRegion.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 namespace BlackBerry {
@@ -47,26 +49,26 @@
     virtual void draw(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll);
     virtual void hide();
 
+    virtual bool shouldHideAfterScroll() const { return m_shouldHideAfterScroll; }
+
     // 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; }
-
-#if PLATFORM(BLACKBERRY)
     virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
-#endif
 
 
 private:
     DefaultTapHighlight(WebPagePrivate*);
 
     WebPagePrivate* m_page;
-    OwnPtr<WebCore::GraphicsLayer> m_layer;
+    OwnPtr<WebOverlay> m_overlay;
     BlackBerry::Platform::IntRectRegion m_region;
     WebCore::Color m_color;
     bool m_visible;
+    bool m_shouldHideAfterScroll;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to