Title: [116456] trunk/Source
Revision
116456
Author
[email protected]
Date
2012-05-08 14:57:21 -0700 (Tue, 08 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 James Robinson.

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::willBeDestroyed):
(WebCore::GraphicsLayerChromium::updateNames):
(WebCore::GraphicsLayerChromium::addAnimation):
(WebCore::GraphicsLayerChromium::addLinkHighlight):
(WebCore):
(WebCore::GraphicsLayerChromium::didFinishLinkHighlight):
(WebCore::GraphicsLayerChromium::updateChildList):
(WebCore::GraphicsLayerChromium::mapAnimationNameToId):
* platform/graphics/chromium/GraphicsLayerChromium.h:
(WebCore):
(GraphicsLayerChromium):
* platform/graphics/chromium/LinkHighlight.cpp: Added.
(WebCore):
(WebCore::LinkHighlight::create):
(WebCore::LinkHighlight::LinkHighlight):
(WebCore::LinkHighlight::~LinkHighlight):
(WebCore::LinkHighlight::contentLayer):
(WebCore::LinkHighlight::paintContents):
(WebCore::LinkHighlight::notifyAnimationStarted):
(WebCore::LinkHighlight::notifyAnimationFinished):
* platform/graphics/chromium/LinkHighlight.h: Added.
(WebCore):
(LinkHighlight):

Source/WebKit/chromium:

* WebKit.gypi:
* tests/LinkHighlightTest.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 (116455 => 116456)


--- trunk/Source/WebCore/ChangeLog	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebCore/ChangeLog	2012-05-08 21:57:21 UTC (rev 116456)
@@ -1,3 +1,49 @@
+2012-05-08  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 James Robinson.
+
+        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::willBeDestroyed):
+        (WebCore::GraphicsLayerChromium::updateNames):
+        (WebCore::GraphicsLayerChromium::addAnimation):
+        (WebCore::GraphicsLayerChromium::addLinkHighlight):
+        (WebCore):
+        (WebCore::GraphicsLayerChromium::didFinishLinkHighlight):
+        (WebCore::GraphicsLayerChromium::updateChildList):
+        (WebCore::GraphicsLayerChromium::mapAnimationNameToId):
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        (WebCore):
+        (GraphicsLayerChromium):
+        * platform/graphics/chromium/LinkHighlight.cpp: Added.
+        (WebCore):
+        (WebCore::LinkHighlight::create):
+        (WebCore::LinkHighlight::LinkHighlight):
+        (WebCore::LinkHighlight::~LinkHighlight):
+        (WebCore::LinkHighlight::contentLayer):
+        (WebCore::LinkHighlight::paintContents):
+        (WebCore::LinkHighlight::notifyAnimationStarted):
+        (WebCore::LinkHighlight::notifyAnimationFinished):
+        * platform/graphics/chromium/LinkHighlight.h: Added.
+        (WebCore):
+        (LinkHighlight):
+
 2012-05-08  Raphael Kubo da Costa  <[email protected]>
 
         [CMake] Rewrite FindGStreamer.cmake.

Modified: trunk/Source/WebCore/WebCore.gypi (116455 => 116456)


--- trunk/Source/WebCore/WebCore.gypi	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebCore/WebCore.gypi	2012-05-08 21:57:21 UTC (rev 116456)
@@ -3529,6 +3529,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',
@@ -3578,6 +3580,8 @@
             'platform/graphics/chromium/LayerTextureSubImage.cpp',
             'platform/graphics/chromium/LayerTextureSubImage.h',
             'platform/graphics/chromium/LayerTextureUpdater.h',
+            'platform/graphics/chromium/LinkHighlight.cpp',
+            'platform/graphics/chromium/LinkHighlight.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 => 116456)


--- trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.cpp	2012-05-08 21:57:21 UTC (rev 116456)
@@ -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 => 116456)


--- trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/AnimationIdVendor.h	2012-05-08 21:57:21 UTC (rev 116456)
@@ -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 (116455 => 116456)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-08 21:57:21 UTC (rev 116456)
@@ -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 "LinkHighlight.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)
@@ -111,6 +108,9 @@
         m_transformLayer->setLayerAnimationDelegate(0);
     }
 
+    if (m_linkHighlight)
+        m_linkHighlight.clear();
+
     GraphicsLayer::willBeDestroyed();
 }
 
@@ -130,6 +130,8 @@
         m_transformLayer->setDebugName("TransformLayer for " + m_nameBase);
     if (m_contentsLayer)
         m_contentsLayer->setDebugName("ContentsLayer for " + m_nameBase);
+    if (m_linkHighlight)
+        m_linkHighlight->contentLayer()->setDebugName("LinkHighlight for " + m_nameBase);
 }
 
 bool GraphicsLayerChromium::setChildren(const Vector<GraphicsLayer*>& children)
@@ -407,7 +409,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 +435,20 @@
     primaryLayer()->resumeAnimations(monotonicallyIncreasingTime());
 }
 
+void GraphicsLayerChromium::addLinkHighlight(const Path& path)
+{
+    m_linkHighlight = LinkHighlight::create(this, path, AnimationIdVendor::LinkHighlightAnimationId, AnimationIdVendor::getNextGroupId());
+    updateChildList();
+}
+
+void GraphicsLayerChromium::didFinishLinkHighlight()
+{
+    if (m_linkHighlight)
+        m_linkHighlight->contentLayer()->removeFromParent();
+
+    m_linkHighlight.clear();
+}
+
 void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
 {
     bool childrenChanged = false;
@@ -513,6 +529,9 @@
         newChildren.append(childLayer);
     }
 
+    if (m_linkHighlight)
+        newChildren.append(m_linkHighlight->contentLayer());
+
     for (size_t i = 0; i < newChildren.size(); ++i)
         newChildren[i]->removeFromParent();
 
@@ -749,7 +768,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 (116455 => 116456)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h	2012-05-08 21:57:21 UTC (rev 116456)
@@ -44,6 +44,7 @@
 namespace WebCore {
 
 class LayerChromium;
+class LinkHighlight;
 
 class GraphicsLayerChromium : public GraphicsLayer, public ContentLayerDelegate, public CCLayerAnimationDelegate {
 public:
@@ -105,6 +106,9 @@
     virtual void suspendAnimations(double wallClockTime);
     virtual void resumeAnimations();
 
+    virtual void addLinkHighlight(const Path&);
+    virtual void didFinishLinkHighlight();
+
     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<LinkHighlight> m_linkHighlight;
 
     enum ContentsLayerPurpose {
         NoContentsLayer = 0,

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


--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.cpp	2012-05-08 21:57:21 UTC (rev 116456)
@@ -0,0 +1,115 @@
+/*
+ * 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 "LinkHighlight.h"
+
+#include "GraphicsLayerChromium.h"
+#include "cc/CCKeyframedAnimationCurve.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/OwnPtr.h>
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+PassRefPtr<LinkHighlight> LinkHighlight::create(GraphicsLayerChromium* parent, const Path& path, int animationId, int groupId)
+{
+    return adoptRef(new LinkHighlight(parent, path, animationId, groupId));
+}
+
+LinkHighlight::LinkHighlight(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());
+}
+
+LinkHighlight::~LinkHighlight()
+{
+    m_contentLayer->removeFromParent();
+    m_contentLayer->clearDelegate();
+    m_contentLayer->setLayerAnimationDelegate(0);
+}
+
+ContentLayerChromium* LinkHighlight::contentLayer()
+{
+    return m_contentLayer.get();
+}
+
+void LinkHighlight::paintContents(GraphicsContext& gc, const IntRect&)
+{
+    // 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 LinkHighlight::notifyAnimationStarted(double)
+{
+}
+
+void LinkHighlight::notifyAnimationFinished(double)
+{
+    // Allow null parent pointer to facilitate testing.
+    if (m_parent)
+        m_parent->didFinishLinkHighlight();
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)

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


--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.h	2012-05-08 21:57:21 UTC (rev 116456)
@@ -0,0 +1,66 @@
+/*
+ * 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 LinkHighlight_h
+#define LinkHighlight_h
+
+#include "ContentLayerChromium.h"
+#include "Path.h"
+#include "cc/CCLayerAnimationDelegate.h"
+#include <wtf/RefPtr.h>
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+class GraphicsLayerChromium;
+
+class LinkHighlight : public RefCounted<LinkHighlight>, public ContentLayerDelegate, public CCLayerAnimationDelegate {
+public:
+    static PassRefPtr<LinkHighlight> create(GraphicsLayerChromium* parent, const Path&, int animationId, int groupId);
+    virtual ~LinkHighlight();
+
+    ContentLayerChromium* contentLayer();
+
+    // ContentLayerDelegate implementation.
+    virtual void paintContents(GraphicsContext&, const IntRect& clipRect) OVERRIDE;
+
+    // CCLayerAnimationDelegate implementation.
+    virtual void notifyAnimationStarted(double time) OVERRIDE;
+    virtual void notifyAnimationFinished(double time) OVERRIDE;
+
+private:
+    LinkHighlight(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 (116455 => 116456)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-08 21:57:21 UTC (rev 116456)
@@ -1,3 +1,21 @@
+2012-05-08  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 James Robinson.
+
+        * WebKit.gypi:
+        * tests/LinkHighlightTest.cpp: Added.
+        (WebCore):
+        (MockGraphicsLayerClient):
+        (WebCore::MockGraphicsLayerClient::notifyAnimationStarted):
+        (WebCore::MockGraphicsLayerClient::notifySyncRequired):
+        (WebCore::MockGraphicsLayerClient::paintContents):
+        (WebCore::MockGraphicsLayerClient::showDebugBorders):
+        (WebCore::MockGraphicsLayerClient::showRepaintCounter):
+        (WebCore::TEST):
+
 2012-05-08  Tony Chang  <[email protected]>
 
         [chromium] move event_listener_unittest to webkit_unit_tests

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (116455 => 116456)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-08 21:52:11 UTC (rev 116455)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-08 21:57:21 UTC (rev 116456)
@@ -114,6 +114,7 @@
             'tests/LayerRendererChromiumTest.cpp',
             'tests/LayerTextureUpdaterTest.cpp',
             'tests/LevelDBTest.cpp',
+            'tests/LinkHighlightTest.cpp',
             'tests/LocalizedNumberICUTest.cpp',
             'tests/MockCCQuadCuller.h',
             'tests/PaintAggregatorTest.cpp',

Added: trunk/Source/WebKit/chromium/tests/LinkHighlightTest.cpp (0 => 116456)


--- trunk/Source/WebKit/chromium/tests/LinkHighlightTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/LinkHighlightTest.cpp	2012-05-08 21:57:21 UTC (rev 116456)
@@ -0,0 +1,87 @@
+/*
+ * 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 "LinkHighlight.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) OVERRIDE { }
+    virtual void notifySyncRequired(const GraphicsLayer*) OVERRIDE { }
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) OVERRIDE { }
+    virtual bool showDebugBorders(const GraphicsLayer*) const OVERRIDE { return false; }
+    virtual bool showRepaintCounter(const GraphicsLayer*) const OVERRIDE { return false; }
+};
+
+TEST(LinkHighlightTest, verifyLinkHighlightLayer)
+{
+    Path highlightPath;
+    highlightPath.addRect(FloatRect(5, 6, 12, 8));
+    IntRect pathBoundingRect = enclosingIntRect(highlightPath.boundingRect());
+
+    RefPtr<LinkHighlight> highlight = LinkHighlight::create(0, highlightPath, AnimationIdVendor::LinkHighlightAnimationId, AnimationIdVendor::getNextGroupId());
+    ASSERT_TRUE(highlight.get());
+    ContentLayerChromium* contentLayer = highlight->contentLayer();
+    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(LinkHighlightTest, 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->addLinkHighlight(highlightPath);
+    graphicsLayer->didFinishLinkHighlight();
+}
+
+} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to