Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef LinkHighlight_h |
| 27 | #define LinkHighlight_h |
| 28 | |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 29 | #include "platform/geometry/FloatPoint.h" |
| 30 | #include "platform/geometry/IntPoint.h" |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 31 | #include "platform/graphics/GraphicsLayer.h" |
| 32 | #include "platform/graphics/Path.h" |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 33 | #include "public/platform/WebAnimationDelegate.h" |
| 34 | #include "public/platform/WebContentLayer.h" |
| 35 | #include "public/platform/WebContentLayerClient.h" |
| 36 | #include "public/platform/WebLayer.h" |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 37 | #include "wtf/OwnPtr.h" |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 38 | #include "wtf/Vector.h" |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 39 | |
| 40 | namespace WebCore { |
| 41 | class RenderLayer; |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 42 | class RenderObject; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 43 | class Node; |
| 44 | } |
| 45 | |
Torne (Richard Coles) | 51b2906 | 2013-11-28 11:56:03 +0000 | [diff] [blame] | 46 | namespace blink { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 47 | |
| 48 | struct WebFloatRect; |
| 49 | struct WebRect; |
| 50 | class WebViewImpl; |
| 51 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 52 | class LinkHighlight FINAL : public WebContentLayerClient, public WebAnimationDelegate, WebCore::LinkHighlightClient { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 53 | public: |
| 54 | static PassOwnPtr<LinkHighlight> create(WebCore::Node*, WebViewImpl*); |
| 55 | virtual ~LinkHighlight(); |
| 56 | |
| 57 | WebContentLayer* contentLayer(); |
| 58 | WebLayer* clipLayer(); |
| 59 | void startHighlightAnimationIfNeeded(); |
| 60 | void updateGeometry(); |
| 61 | |
| 62 | // WebContentLayerClient implementation. |
| 63 | virtual void paintContents(WebCanvas*, const WebRect& clipRect, bool canPaintLCDText, WebFloatRect& opaque) OVERRIDE; |
| 64 | |
| 65 | // WebAnimationDelegate implementation. |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 66 | virtual void notifyAnimationStarted(double monotonicTime, blink::WebAnimation::TargetProperty) OVERRIDE; |
| 67 | virtual void notifyAnimationFinished(double monotonicTime, blink::WebAnimation::TargetProperty) OVERRIDE; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 68 | |
| 69 | // LinkHighlightClient inplementation. |
| 70 | virtual void invalidate() OVERRIDE; |
| 71 | virtual WebLayer* layer() OVERRIDE; |
| 72 | virtual void clearCurrentGraphicsLayer() OVERRIDE; |
| 73 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 74 | WebCore::GraphicsLayer* currentGraphicsLayerForTesting() const { return m_currentGraphicsLayer; } |
Torne (Richard Coles) | 81a5157 | 2013-05-13 16:52:28 +0100 | [diff] [blame] | 75 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 76 | private: |
| 77 | LinkHighlight(WebCore::Node*, WebViewImpl*); |
| 78 | |
| 79 | void releaseResources(); |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 80 | void computeQuads(WebCore::Node*, WTF::Vector<WebCore::FloatQuad>&) const; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 81 | |
| 82 | WebCore::RenderLayer* computeEnclosingCompositingLayer(); |
| 83 | void clearGraphicsLayerLinkHighlightPointer(); |
| 84 | // This function computes the highlight path, and returns true if it has changed |
| 85 | // size since the last call to this function. |
| 86 | bool computeHighlightLayerPathAndPosition(WebCore::RenderLayer*); |
| 87 | |
| 88 | OwnPtr<WebContentLayer> m_contentLayer; |
| 89 | OwnPtr<WebLayer> m_clipLayer; |
| 90 | WebCore::Path m_path; |
| 91 | |
| 92 | RefPtr<WebCore::Node> m_node; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 93 | WebViewImpl* m_owningWebViewImpl; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame] | 94 | WebCore::GraphicsLayer* m_currentGraphicsLayer; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 95 | |
| 96 | bool m_geometryNeedsUpdate; |
| 97 | bool m_isAnimating; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 98 | double m_startTime; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
Torne (Richard Coles) | 51b2906 | 2013-11-28 11:56:03 +0000 | [diff] [blame] | 101 | } // namespace blink |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 102 | |
| 103 | #endif |