1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_LINK_HIGHLIGHT_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_LINK_HIGHLIGHT_H_
7 
8 #include <memory>
9 
10 #include "third_party/blink/renderer/core/core_export.h"
11 #include "third_party/blink/renderer/platform/graphics/compositor_element_id.h"
12 #include "third_party/blink/renderer/platform/heap/handle.h"
13 
14 namespace cc {
15 class AnimationHost;
16 }
17 
18 namespace blink {
19 class GraphicsContext;
20 class Page;
21 class LinkHighlightImpl;
22 class CompositorAnimationTimeline;
23 class LocalFrame;
24 class LayoutObject;
25 
26 class CORE_EXPORT LinkHighlight final : public GarbageCollected<LinkHighlight> {
27  public:
28   explicit LinkHighlight(Page&);
29   virtual ~LinkHighlight();
30 
31   virtual void Trace(Visitor*) const;
32 
33   void ResetForPageNavigation();
34 
35   void SetTapHighlight(Node*);
36 
37   void StartHighlightAnimationIfNeeded();
38 
39   void AnimationHostInitialized(cc::AnimationHost&);
40   void WillCloseAnimationHost();
41 
NeedsHighlightEffect(const LayoutObject & object)42   bool NeedsHighlightEffect(const LayoutObject& object) const {
43     return impl_ && NeedsHighlightEffectInternal(object);
44   }
45 
46   void UpdateBeforePrePaint();
47   void UpdateAfterPrePaint();
48   void Paint(GraphicsContext&) const;
49 
50  private:
51   friend class LinkHighlightImplTest;
52 
53   void RemoveHighlight();
54 
55   LocalFrame* MainFrame() const;
56 
GetPage()57   Page& GetPage() const {
58     DCHECK(page_);
59     return *page_;
60   }
61 
62   bool NeedsHighlightEffectInternal(const LayoutObject& object) const;
63 
64   Member<Page> page_;
65   std::unique_ptr<LinkHighlightImpl> impl_;
66   cc::AnimationHost* animation_host_ = nullptr;
67   std::unique_ptr<CompositorAnimationTimeline> timeline_;
68 };
69 
70 }  // namespace blink
71 
72 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_LINK_HIGHLIGHT_H_
73