blob: a22ed5f2cca3719b6cfd457e982422c2c4e1ce0c [file] [log] [blame]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +00001/*
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)1e202182013-10-18 15:46:42 +010029#include "platform/geometry/FloatPoint.h"
30#include "platform/geometry/IntPoint.h"
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000031#include "platform/graphics/GraphicsLayer.h"
32#include "platform/graphics/Path.h"
Torne (Richard Coles)5267f702013-06-11 10:57:24 +010033#include "public/platform/WebAnimationDelegate.h"
34#include "public/platform/WebContentLayer.h"
35#include "public/platform/WebContentLayerClient.h"
36#include "public/platform/WebLayer.h"
Ben Murdoch591b9582013-07-10 11:41:44 +010037#include "wtf/OwnPtr.h"
Torne (Richard Coles)09380292014-02-21 12:17:33 +000038#include "wtf/Vector.h"
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000039
40namespace WebCore {
41class RenderLayer;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000042class RenderObject;
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000043class Node;
44}
45
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000046namespace blink {
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000047
48struct WebFloatRect;
49struct WebRect;
50class WebViewImpl;
51
Torne (Richard Coles)09380292014-02-21 12:17:33 +000052class LinkHighlight FINAL : public WebContentLayerClient, public WebAnimationDelegate, WebCore::LinkHighlightClient {
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000053public:
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)d5428f32014-03-18 10:21:16 +000066 virtual void notifyAnimationStarted(double monotonicTime, blink::WebAnimation::TargetProperty) OVERRIDE;
67 virtual void notifyAnimationFinished(double monotonicTime, blink::WebAnimation::TargetProperty) OVERRIDE;
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000068
69 // LinkHighlightClient inplementation.
70 virtual void invalidate() OVERRIDE;
71 virtual WebLayer* layer() OVERRIDE;
72 virtual void clearCurrentGraphicsLayer() OVERRIDE;
73
Torne (Richard Coles)5267f702013-06-11 10:57:24 +010074 WebCore::GraphicsLayer* currentGraphicsLayerForTesting() const { return m_currentGraphicsLayer; }
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010075
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000076private:
77 LinkHighlight(WebCore::Node*, WebViewImpl*);
78
79 void releaseResources();
Torne (Richard Coles)09380292014-02-21 12:17:33 +000080 void computeQuads(WebCore::Node*, WTF::Vector<WebCore::FloatQuad>&) const;
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000081
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)5c87bf82012-11-14 11:46:17 +000093 WebViewImpl* m_owningWebViewImpl;
Torne (Richard Coles)5267f702013-06-11 10:57:24 +010094 WebCore::GraphicsLayer* m_currentGraphicsLayer;
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000095
96 bool m_geometryNeedsUpdate;
97 bool m_isAnimating;
Torne (Richard Coles)926b0012013-03-28 15:32:48 +000098 double m_startTime;
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000099};
100
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000101} // namespace blink
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000102
103#endif