Title: [116334] trunk/Source
Revision
116334
Author
[email protected]
Date
2012-05-07 11:57:46 -0700 (Mon, 07 May 2012)

Log Message

[chromium] Create LinkHighlightLayerChromium class to provide link-highlight preview animations for GraphicsLayerChromium.
https://bugs.webkit.org/show_bug.cgi?id=85084

Reviewed by Adrienne Walker.

Source/WebCore:

Unit test provided.

Creates a layer delegate class to provide link highlight animations for link-preview feature.
These are added to a GraphicsLayerChromium via provided methods. Moves dispensing of animation
ids into a separate class.

* WebCore.gypi:
* platform/graphics/chromium/AnimationIdVendor.cpp: Added.
(WebCore):
(WebCore::AnimationIdVendor::getNextAnimationId):
(WebCore::AnimationIdVendor::getNextGroupId):
* platform/graphics/chromium/AnimationIdVendor.h: Added.
(WebCore):
(AnimationIdVendor):
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::updateNames):
(WebCore::GraphicsLayerChromium::addAnimation):
(WebCore::GraphicsLayerChromium::addLinkHighlightLayer):
(WebCore):
(WebCore::GraphicsLayerChromium::didFinishLinkHighlightLayer):
(WebCore::GraphicsLayerChromium::updateChildList):
(WebCore::GraphicsLayerChromium::mapAnimationNameToId):
* platform/graphics/chromium/GraphicsLayerChromium.h:
(WebCore):
(GraphicsLayerChromium):
* platform/graphics/chromium/LinkHighlightLayerDelegate.cpp: Added.
(WebCore):
(WebCore::LinkHighlightLayerDelegate::create):
(WebCore::LinkHighlightLayerDelegate::LinkHighlightLayerDelegate):
(WebCore::LinkHighlightLayerDelegate::~LinkHighlightLayerDelegate):
(WebCore::LinkHighlightLayerDelegate::getContentLayer):
(WebCore::LinkHighlightLayerDelegate::paintContents):
(WebCore::LinkHighlightLayerDelegate::didScroll):
(WebCore::LinkHighlightLayerDelegate::notifyAnimationStarted):
(WebCore::LinkHighlightLayerDelegate::notifyAnimationFinished):
* platform/graphics/chromium/LinkHighlightLayerDelegate.h: Added.
(WebCore):
(LinkHighlightLayerDelegate):

Source/WebKit/chromium:

* WebKit.gypi:
* tests/LinkHighlightLayerDelegateTest.cpp: Added.
(WebCore):
(MockGraphicsLayerClient):
(WebCore::MockGraphicsLayerClient::notifyAnimationStarted):
(WebCore::MockGraphicsLayerClient::notifySyncRequired):
(WebCore::MockGraphicsLayerClient::paintContents):
(WebCore::MockGraphicsLayerClient::showDebugBorders):
(WebCore::MockGraphicsLayerClient::showRepaintCounter):
(WebCore::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116333 => 116334)


--- trunk/Source/WebCore/ChangeLog	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebCore/ChangeLog	2012-05-07 18:57:46 UTC (rev 116334)
@@ -1,3 +1,49 @@
+2012-05-07  W. James MacLean  <[email protected]>
+
+        [chromium] Create LinkHighlightLayerChromium class to provide link-highlight preview animations for GraphicsLayerChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=85084
+
+        Reviewed by Adrienne Walker.
+
+        Unit test provided.
+
+        Creates a layer delegate class to provide link highlight animations for link-preview feature.
+        These are added to a GraphicsLayerChromium via provided methods. Moves dispensing of animation
+        ids into a separate class.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/AnimationIdVendor.cpp: Added.
+        (WebCore):
+        (WebCore::AnimationIdVendor::getNextAnimationId):
+        (WebCore::AnimationIdVendor::getNextGroupId):
+        * platform/graphics/chromium/AnimationIdVendor.h: Added.
+        (WebCore):
+        (AnimationIdVendor):
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::updateNames):
+        (WebCore::GraphicsLayerChromium::addAnimation):
+        (WebCore::GraphicsLayerChromium::addLinkHighlightLayer):
+        (WebCore):
+        (WebCore::GraphicsLayerChromium::didFinishLinkHighlightLayer):
+        (WebCore::GraphicsLayerChromium::updateChildList):
+        (WebCore::GraphicsLayerChromium::mapAnimationNameToId):
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        (WebCore):
+        (GraphicsLayerChromium):
+        * platform/graphics/chromium/LinkHighlightLayerDelegate.cpp: Added.
+        (WebCore):
+        (WebCore::LinkHighlightLayerDelegate::create):
+        (WebCore::LinkHighlightLayerDelegate::LinkHighlightLayerDelegate):
+        (WebCore::LinkHighlightLayerDelegate::~LinkHighlightLayerDelegate):
+        (WebCore::LinkHighlightLayerDelegate::getContentLayer):
+        (WebCore::LinkHighlightLayerDelegate::paintContents):
+        (WebCore::LinkHighlightLayerDelegate::didScroll):
+        (WebCore::LinkHighlightLayerDelegate::notifyAnimationStarted):
+        (WebCore::LinkHighlightLayerDelegate::notifyAnimationFinished):
+        * platform/graphics/chromium/LinkHighlightLayerDelegate.h: Added.
+        (WebCore):
+        (LinkHighlightLayerDelegate):
+
 2012-05-07  Joshua Bell  <[email protected]>
 
         IndexedDB: LevelDB coding for bools is broken

Modified: trunk/Source/WebCore/WebCore.gypi (116333 => 116334)


--- trunk/Source/WebCore/WebCore.gypi	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebCore/WebCore.gypi	2012-05-07 18:57:46 UTC (rev 116334)
@@ -3524,6 +3524,8 @@
             'platform/graphics/cg/PathCG.cpp',
             'platform/graphics/cg/PatternCG.cpp',
             'platform/graphics/cg/TransformationMatrixCG.cpp',
+            'platform/graphics/chromium/AnimationIdVendor.cpp',
+            'platform/graphics/chromium/AnimationIdVendor.h',
             'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp',
             'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h',
             'platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp',
@@ -3573,6 +3575,8 @@
             'platform/graphics/chromium/LayerTextureSubImage.cpp',
             'platform/graphics/chromium/LayerTextureSubImage.h',
             'platform/graphics/chromium/LayerTextureUpdater.h',
+            'platform/graphics/chromium/LinkHighlightLayerDelegate.cpp',
+            'platform/graphics/chromium/LinkHighlightLayerDelegate.h',
             'platform/graphics/chromium/ManagedTexture.cpp',
             'platform/graphics/chromium/ManagedTexture.h',
             'platform/graphics/chromium/MediaPlayerPrivateChromium.h',

Added: trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.cpp (0 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.cpp	2012-05-07 18:57:46 UTC (rev 116334)
@@ -0,0 +1,53 @@
+/*
+* Copyright (C) 2012 Google Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1.  Redistributions of source code must retain the above copyright
+*     notice, this list of conditions and the following disclaimer.
+* 2.  Redistributions in binary form must reproduce the above copyright
+*     notice, this list of conditions and the following disclaimer in the
+*     documentation and/or other materials provided with the distribution.
+*  
+* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+
+#include "AnimationIdVendor.h"
+
+namespace WebCore {
+
+int AnimationIdVendor::s_nextAnimationId = FirstAvailableAnimationId;
+int AnimationIdVendor::s_nextGroupId = FirstAvailableGroupId;
+
+int AnimationIdVendor::getNextAnimationId()
+{
+    int id = s_nextAnimationId++;
+    if (s_nextAnimationId == DontUseAnimationId)
+        s_nextAnimationId = FirstAvailableAnimationId;
+
+    return id;
+}
+
+int AnimationIdVendor::getNextGroupId()
+{
+    int id = s_nextGroupId++;
+    if (s_nextGroupId == DontUseGroupId)
+        s_nextGroupId = FirstAvailableGroupId;
+
+    return id;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.h (0 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.h	2012-05-07 18:57:46 UTC (rev 116334)
@@ -0,0 +1,46 @@
+/*
+  2  * Copyright (C) 2012 Google Inc. All rights reserved.
+  3  *
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1.  Redistributions of source code must retain the above copyright
+*     notice, this list of conditions and the following disclaimer.
+* 2.  Redistributions in binary form must reproduce the above copyright
+*     notice, this list of conditions and the following disclaimer in the
+*     documentation and/or other materials provided with the distribution.
+*  
+* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef AnimationIdVendor_h
+#define AnimationIdVendor_h
+
+namespace WebCore {
+
+class AnimationIdVendor {
+public:
+    enum AnimationIdSequence { DontUseAnimationId = 0, LinkHighlightAnimationId, FirstAvailableAnimationId };
+    enum GroupIdSequence { DontUseGroupId = 0, FirstAvailableGroupId };
+
+    static int getNextAnimationId();
+    static int getNextGroupId();
+
+private:
+    static int s_nextAnimationId;
+    static int s_nextGroupId;
+};
+
+} // namespace WebCore
+
+#endif

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (116333 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-07 18:57:46 UTC (rev 116334)
@@ -45,6 +45,7 @@
 
 #include "GraphicsLayerChromium.h"
 
+#include "AnimationIdVendor.h"
 #include "Canvas2DLayerChromium.h"
 #include "ContentLayerChromium.h"
 #include "FloatConversion.h"
@@ -52,6 +53,7 @@
 #include "Image.h"
 #include "ImageLayerChromium.h"
 #include "LayerChromium.h"
+#include "LinkHighlightLayerDelegate.h"
 #include "PlatformString.h"
 #include "SystemTime.h"
 
@@ -61,11 +63,6 @@
 
 using namespace std;
 
-namespace {
-static int s_nextGroupId = 1;
-static int s_nextAnimationId = 1;
-}
-
 namespace WebCore {
 
 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
@@ -130,6 +127,8 @@
         m_transformLayer->setDebugName("TransformLayer for " + m_nameBase);
     if (m_contentsLayer)
         m_contentsLayer->setDebugName("ContentsLayer for " + m_nameBase);
+    if (m_linkHighlightLayerDelegate)
+        m_linkHighlightLayerDelegate->getContentLayer()->setDebugName("LinkHighlightLayer for " + m_nameBase);
 }
 
 bool GraphicsLayerChromium::setChildren(const Vector<GraphicsLayer*>& children)
@@ -407,7 +406,7 @@
 bool GraphicsLayerChromium::addAnimation(const KeyframeValueList& values, const IntSize& boxSize, const Animation* animation, const String& animationName, double timeOffset)
 {
     primaryLayer()->setLayerAnimationDelegate(this);
-    return primaryLayer()->addAnimation(values, boxSize, animation, mapAnimationNameToId(animationName), s_nextGroupId++, timeOffset);
+    return primaryLayer()->addAnimation(values, boxSize, animation, mapAnimationNameToId(animationName), AnimationIdVendor::getNextGroupId(), timeOffset);
 }
 
 void GraphicsLayerChromium::pauseAnimation(const String& animationName, double timeOffset)
@@ -433,6 +432,20 @@
     primaryLayer()->resumeAnimations(monotonicallyIncreasingTime());
 }
 
+void GraphicsLayerChromium::addLinkHighlightLayer(const Path& path)
+{
+    m_linkHighlightLayerDelegate = LinkHighlightLayerDelegate::create(this, path, AnimationIdVendor::LinkHighlightAnimationId, AnimationIdVendor::getNextGroupId());
+    updateChildList();
+}
+
+void GraphicsLayerChromium::didFinishLinkHighlightLayer()
+{
+    if (m_linkHighlightLayerDelegate)
+        m_linkHighlightLayerDelegate->getContentLayer()->removeFromParent();
+
+    m_linkHighlightLayerDelegate.clear();
+}
+
 void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
 {
     bool childrenChanged = false;
@@ -513,6 +526,9 @@
         newChildren.append(childLayer);
     }
 
+    if (m_linkHighlightLayerDelegate)
+        newChildren.append(m_linkHighlightLayerDelegate->getContentLayer());
+
     for (size_t i = 0; i < newChildren.size(); ++i)
         newChildren[i]->removeFromParent();
 
@@ -749,7 +765,7 @@
         return 0;
 
     if (!m_animationIdMap.contains(animationName))
-        m_animationIdMap.add(animationName, s_nextAnimationId++);
+        m_animationIdMap.add(animationName, AnimationIdVendor::getNextAnimationId());
 
     return m_animationIdMap.find(animationName)->second;
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h (116333 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h	2012-05-07 18:57:46 UTC (rev 116334)
@@ -44,6 +44,7 @@
 namespace WebCore {
 
 class LayerChromium;
+class LinkHighlightLayerDelegate;
 
 class GraphicsLayerChromium : public GraphicsLayer, public ContentLayerDelegate, public CCLayerAnimationDelegate {
 public:
@@ -105,6 +106,9 @@
     virtual void suspendAnimations(double wallClockTime);
     virtual void resumeAnimations();
 
+    virtual void addLinkHighlightLayer(const Path&);
+    virtual void didFinishLinkHighlightLayer();
+
     virtual PlatformLayer* platformLayer() const;
 
     virtual void setDebugBackgroundColor(const Color&);
@@ -157,6 +161,7 @@
     RefPtr<ContentLayerChromium> m_layer;
     RefPtr<LayerChromium> m_transformLayer;
     RefPtr<LayerChromium> m_contentsLayer;
+    RefPtr<LinkHighlightLayerDelegate> m_linkHighlightLayerDelegate;
 
     enum ContentsLayerPurpose {
         NoContentsLayer = 0,

Added: trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.cpp (0 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.cpp	2012-05-07 18:57:46 UTC (rev 116334)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "LinkHighlightLayerDelegate.h"
+
+#include "GraphicsLayerChromium.h"
+#include "cc/CCKeyframedAnimationCurve.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/OwnPtr.h>
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+PassRefPtr<LinkHighlightLayerDelegate> LinkHighlightLayerDelegate::create(GraphicsLayerChromium* parent, const Path& path, int animationId, int groupId)
+{
+    return adoptRef(new LinkHighlightLayerDelegate(parent, path, animationId, groupId));
+}
+
+LinkHighlightLayerDelegate::LinkHighlightLayerDelegate(GraphicsLayerChromium* parent, const Path& path, int animationId, int groupId)
+    : m_contentLayer(ContentLayerChromium::create(this))
+    , m_parent(parent)
+    , m_path(path)
+{
+    m_contentLayer->setIsDrawable(true);
+
+    IntRect rect = enclosingIntRect(path.boundingRect());
+
+    m_contentLayer->setBounds(rect.size());
+
+    TransformationMatrix transform;
+    transform.translate(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2);
+    m_contentLayer->setTransform(transform);
+
+    m_path.translate(FloatSize(-rect.x(), -rect.y()));
+
+    m_contentLayer->setLayerAnimationDelegate(this);
+
+    // FIXME: Should these be configurable?
+    const float startOpacity = 0.25;
+    const float duration = 2;
+
+    m_contentLayer->setOpacity(startOpacity);
+
+    OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
+    curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, nullptr));
+    curve->addKeyframe(CCFloatKeyframe::create(duration / 2, startOpacity, nullptr));
+    curve->addKeyframe(CCFloatKeyframe::create(duration, 0, nullptr));
+
+    // animationId = 1 is reserved for us.
+    OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), animationId, groupId, CCActiveAnimation::Opacity));
+    animation->setNeedsSynchronizedStartTime(true);
+    m_contentLayer->layerAnimationController()->add(animation.release());
+}
+
+LinkHighlightLayerDelegate::~LinkHighlightLayerDelegate()
+{
+    m_contentLayer->removeFromParent();
+    m_contentLayer->clearDelegate();
+}
+
+ContentLayerChromium* LinkHighlightLayerDelegate::getContentLayer()
+{
+    return m_contentLayer.get();
+}
+
+void LinkHighlightLayerDelegate::paintContents(GraphicsContext& gc, const IntRect& clipRect)
+{
+    // FIXME: make colour configurable?
+    gc.setStrokeColor(Color(0, 0, 255, 255), ColorSpaceDeviceRGB);
+    gc.setStrokeThickness(2);
+    gc.strokePath(m_path);
+    gc.setFillColor(Color(255, 0, 255, 255), ColorSpaceDeviceRGB);
+    gc.fillPath(m_path);
+}
+
+void LinkHighlightLayerDelegate::didScroll(const IntSize&)
+{
+}
+
+void LinkHighlightLayerDelegate::notifyAnimationStarted(double time)
+{
+}
+
+void LinkHighlightLayerDelegate::notifyAnimationFinished(double time)
+{
+    // Allow null parent pointer to facilitate testing.
+    if (m_parent)
+        m_parent->didFinishLinkHighlightLayer();
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)

Added: trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.h (0 => 116334)


--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlightLayerDelegate.h	2012-05-07 18:57:46 UTC (rev 116334)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LinkHighlightLayerDelegate_h
+#define LinkHighlightLayerDelegate_h
+
+#include "ContentLayerChromium.h"
+#include "Path.h"
+#include "cc/CCLayerAnimationDelegate.h"
+#include <wtf/RefPtr.h>
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+class GraphicsLayerChromium;
+
+class LinkHighlightLayerDelegate : public RefCounted<LinkHighlightLayerDelegate>, public ContentLayerDelegate, public CCLayerAnimationDelegate {
+public:
+    static PassRefPtr<LinkHighlightLayerDelegate> create(GraphicsLayerChromium* parent, const Path&, int animationId, int groupId);
+    virtual  ~LinkHighlightLayerDelegate();
+
+    ContentLayerChromium* getContentLayer();
+
+    // ContentLayerDelegate implementation.
+    virtual void paintContents(GraphicsContext&, const IntRect& clipRect);
+    virtual void didScroll(const IntSize&) OVERRIDE;
+
+    // CCLayerAnimationDelegate implementation.
+    virtual void notifyAnimationStarted(double time);
+    virtual void notifyAnimationFinished(double time);
+
+private:
+    LinkHighlightLayerDelegate(GraphicsLayerChromium* parent, const Path&, int animationId, int groupId);
+
+    RefPtr<ContentLayerChromium> m_contentLayer;
+    GraphicsLayerChromium* m_parent;
+    Path m_path;
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif

Modified: trunk/Source/WebKit/chromium/ChangeLog (116333 => 116334)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-07 18:57:46 UTC (rev 116334)
@@ -1,3 +1,21 @@
+2012-05-07  W. James MacLean  <[email protected]>
+
+        [chromium] Create LinkHighlightLayerChromium class to provide link-highlight preview animations for GraphicsLayerChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=85084
+
+        Reviewed by Adrienne Walker.
+
+        * WebKit.gypi:
+        * tests/LinkHighlightLayerDelegateTest.cpp: Added.
+        (WebCore):
+        (MockGraphicsLayerClient):
+        (WebCore::MockGraphicsLayerClient::notifyAnimationStarted):
+        (WebCore::MockGraphicsLayerClient::notifySyncRequired):
+        (WebCore::MockGraphicsLayerClient::paintContents):
+        (WebCore::MockGraphicsLayerClient::showDebugBorders):
+        (WebCore::MockGraphicsLayerClient::showRepaintCounter):
+        (WebCore::TEST):
+
 2012-05-07  Joshua Bell  <[email protected]>
 
         IndexedDB: LevelDB coding for bools is broken

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (116333 => 116334)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-07 18:54:48 UTC (rev 116333)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-07 18:57:46 UTC (rev 116334)
@@ -113,6 +113,7 @@
             'tests/LayerRendererChromiumTest.cpp',
             'tests/LayerTextureUpdaterTest.cpp',
             'tests/LevelDBTest.cpp',
+            'tests/LinkHighlightLayerDelegateTest.cpp',
             'tests/LocalizedNumberICUTest.cpp',
             'tests/MockCCQuadCuller.h',
             'tests/PaintAggregatorTest.cpp',

Added: trunk/Source/WebKit/chromium/tests/LinkHighlightLayerDelegateTest.cpp (0 => 116334)


--- trunk/Source/WebKit/chromium/tests/LinkHighlightLayerDelegateTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/LinkHighlightLayerDelegateTest.cpp	2012-05-07 18:57:46 UTC (rev 116334)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "LinkHighlightLayerDelegate.h"
+
+#include "AnimationIdVendor.h"
+#include "GraphicsLayerChromium.h"
+#include "GraphicsLayerClient.h"
+#include "IntRect.h"
+#include "Path.h"
+#include "TransformationMatrix.h"
+#include <gtest/gtest.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebCore;
+
+namespace {
+
+class MockGraphicsLayerClient : public GraphicsLayerClient {
+public:
+
+    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 { return false; }
+    virtual bool showRepaintCounter(const GraphicsLayer*) const { return false; }
+};
+
+TEST(LinkHighlightLayerTest, verifyLinkHighlightLayer)
+{
+    Path highlightPath;
+    highlightPath.addRect(FloatRect(5, 6, 12, 8));
+    IntRect pathBoundingRect = enclosingIntRect(highlightPath.boundingRect());
+
+    RefPtr<LinkHighlightLayerDelegate> highlightLayerDelegate = LinkHighlightLayerDelegate::create(0, highlightPath, AnimationIdVendor::LinkHighlightAnimationId, AnimationIdVendor::getNextGroupId());
+    ASSERT_TRUE(highlightLayerDelegate.get());
+    ContentLayerChromium* contentLayer = highlightLayerDelegate->getContentLayer();
+    ASSERT_TRUE(contentLayer);
+
+    EXPECT_EQ(pathBoundingRect.size(), contentLayer->bounds());
+    EXPECT_TRUE(contentLayer->transform().isIdentityOrTranslation());
+    EXPECT_TRUE(contentLayer->transform().isIntegerTranslation());
+
+    TransformationMatrix::DecomposedType decomposition;
+    EXPECT_TRUE(contentLayer->transform().decompose(decomposition));
+
+    FloatPoint expectedTranslation(pathBoundingRect.x() + pathBoundingRect.width() / 2, pathBoundingRect.y() + pathBoundingRect.height() / 2);
+    EXPECT_EQ(FloatPoint(decomposition.translateX, decomposition.translateY), expectedTranslation);
+}
+
+TEST(LinkHighlightLayerTest, verifyGraphicsLayerChromiumEmbedding)
+{
+    MockGraphicsLayerClient client;
+    OwnPtr<GraphicsLayerChromium> graphicsLayer = static_pointer_cast<GraphicsLayerChromium>(GraphicsLayer::create(&client));
+    ASSERT_TRUE(graphicsLayer.get());
+
+    Path highlightPath;
+    highlightPath.addRect(FloatRect(5, 5, 10, 8));
+
+    // Neither of the following operations should crash.
+    graphicsLayer->addLinkHighlightLayer(highlightPath);
+    graphicsLayer->didFinishLinkHighlightLayer();
+}
+
+} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to