Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: third_party/WebKit/Source/web/LinkHighlightImpl.cpp

Issue 2848513002: Introduce the abstract class WebViewBase, to decouple WebViewImpl. (Closed)
Patch Set: Fix typo. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 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. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "web/LinkHighlightImpl.h" 26 #include "web/LinkHighlightImpl.h"
27 27
28 #include <memory> 28 #include <memory>
29 #include "core/dom/DOMNodeIds.h" 29 #include "core/dom/DOMNodeIds.h"
30 #include "core/dom/LayoutTreeBuilderTraversal.h" 30 #include "core/dom/LayoutTreeBuilderTraversal.h"
31 #include "core/dom/Node.h" 31 #include "core/dom/Node.h"
32 #include "core/exported/WebViewBase.h"
32 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
33 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
34 #include "core/layout/LayoutBoxModelObject.h" 35 #include "core/layout/LayoutBoxModelObject.h"
35 #include "core/layout/LayoutObject.h" 36 #include "core/layout/LayoutObject.h"
36 #include "core/layout/compositing/CompositedLayerMapping.h" 37 #include "core/layout/compositing/CompositedLayerMapping.h"
37 #include "core/paint/PaintLayer.h" 38 #include "core/paint/PaintLayer.h"
38 #include "platform/RuntimeEnabledFeatures.h" 39 #include "platform/RuntimeEnabledFeatures.h"
39 #include "platform/animation/CompositorAnimation.h" 40 #include "platform/animation/CompositorAnimation.h"
40 #include "platform/animation/CompositorAnimationCurve.h" 41 #include "platform/animation/CompositorAnimationCurve.h"
41 #include "platform/animation/CompositorFloatAnimationCurve.h" 42 #include "platform/animation/CompositorFloatAnimationCurve.h"
(...skipping 15 matching lines...) Expand all
57 #include "public/platform/WebDisplayItemList.h" 58 #include "public/platform/WebDisplayItemList.h"
58 #include "public/platform/WebFloatPoint.h" 59 #include "public/platform/WebFloatPoint.h"
59 #include "public/platform/WebLayer.h" 60 #include "public/platform/WebLayer.h"
60 #include "public/platform/WebRect.h" 61 #include "public/platform/WebRect.h"
61 #include "public/platform/WebSize.h" 62 #include "public/platform/WebSize.h"
62 #include "public/web/WebKit.h" 63 #include "public/web/WebKit.h"
63 #include "third_party/skia/include/core/SkMatrix44.h" 64 #include "third_party/skia/include/core/SkMatrix44.h"
64 #include "ui/gfx/geometry/rect.h" 65 #include "ui/gfx/geometry/rect.h"
65 #include "web/WebLocalFrameImpl.h" 66 #include "web/WebLocalFrameImpl.h"
66 #include "web/WebSettingsImpl.h" 67 #include "web/WebSettingsImpl.h"
67 #include "web/WebViewImpl.h"
68 68
69 namespace blink { 69 namespace blink {
70 70
71 std::unique_ptr<LinkHighlightImpl> LinkHighlightImpl::Create( 71 std::unique_ptr<LinkHighlightImpl> LinkHighlightImpl::Create(
72 Node* node, 72 Node* node,
73 WebViewImpl* owning_web_view_impl) { 73 WebViewBase* owning_web_view) {
74 return WTF::WrapUnique(new LinkHighlightImpl(node, owning_web_view_impl)); 74 return WTF::WrapUnique(new LinkHighlightImpl(node, owning_web_view));
75 } 75 }
76 76
77 LinkHighlightImpl::LinkHighlightImpl(Node* node, 77 LinkHighlightImpl::LinkHighlightImpl(Node* node, WebViewBase* owning_web_view)
78 WebViewImpl* owning_web_view_impl)
79 : node_(node), 78 : node_(node),
80 owning_web_view_impl_(owning_web_view_impl), 79 owning_web_view_(owning_web_view),
81 current_graphics_layer_(0), 80 current_graphics_layer_(0),
82 is_scrolling_graphics_layer_(false), 81 is_scrolling_graphics_layer_(false),
83 geometry_needs_update_(false), 82 geometry_needs_update_(false),
84 is_animating_(false), 83 is_animating_(false),
85 start_time_(MonotonicallyIncreasingTime()) { 84 start_time_(MonotonicallyIncreasingTime()) {
86 DCHECK(node_); 85 DCHECK(node_);
87 DCHECK(owning_web_view_impl); 86 DCHECK(owning_web_view);
88 WebCompositorSupport* compositor_support = 87 WebCompositorSupport* compositor_support =
89 Platform::Current()->CompositorSupport(); 88 Platform::Current()->CompositorSupport();
90 DCHECK(compositor_support); 89 DCHECK(compositor_support);
91 content_layer_ = compositor_support->CreateContentLayer(this); 90 content_layer_ = compositor_support->CreateContentLayer(this);
92 clip_layer_ = compositor_support->CreateLayer(); 91 clip_layer_ = compositor_support->CreateLayer();
93 clip_layer_->SetTransformOrigin(WebFloatPoint3D()); 92 clip_layer_->SetTransformOrigin(WebFloatPoint3D());
94 clip_layer_->AddChild(content_layer_->Layer()); 93 clip_layer_->AddChild(content_layer_->Layer());
95 94
96 compositor_player_ = CompositorAnimationPlayer::Create(); 95 compositor_player_ = CompositorAnimationPlayer::Create();
97 DCHECK(compositor_player_); 96 DCHECK(compositor_player_);
98 compositor_player_->SetAnimationDelegate(this); 97 compositor_player_->SetAnimationDelegate(this);
99 if (owning_web_view_impl_->LinkHighlightsTimeline()) 98 if (owning_web_view_->LinkHighlightsTimeline())
100 owning_web_view_impl_->LinkHighlightsTimeline()->PlayerAttached(*this); 99 owning_web_view_->LinkHighlightsTimeline()->PlayerAttached(*this);
101 100
102 CompositorElementId element_id = CreateCompositorElementId( 101 CompositorElementId element_id = CreateCompositorElementId(
103 DOMNodeIds::IdForNode(node), CompositorSubElementId::kLinkHighlight); 102 DOMNodeIds::IdForNode(node), CompositorSubElementId::kLinkHighlight);
104 compositor_player_->AttachElement(element_id); 103 compositor_player_->AttachElement(element_id);
105 content_layer_->Layer()->SetDrawsContent(true); 104 content_layer_->Layer()->SetDrawsContent(true);
106 content_layer_->Layer()->SetOpacity(1); 105 content_layer_->Layer()->SetOpacity(1);
107 content_layer_->Layer()->SetElementId(element_id); 106 content_layer_->Layer()->SetElementId(element_id);
108 geometry_needs_update_ = true; 107 geometry_needs_update_ = true;
109 } 108 }
110 109
111 LinkHighlightImpl::~LinkHighlightImpl() { 110 LinkHighlightImpl::~LinkHighlightImpl() {
112 if (compositor_player_->IsElementAttached()) 111 if (compositor_player_->IsElementAttached())
113 compositor_player_->DetachElement(); 112 compositor_player_->DetachElement();
114 if (owning_web_view_impl_->LinkHighlightsTimeline()) 113 if (owning_web_view_->LinkHighlightsTimeline())
115 owning_web_view_impl_->LinkHighlightsTimeline()->PlayerDestroyed(*this); 114 owning_web_view_->LinkHighlightsTimeline()->PlayerDestroyed(*this);
116 compositor_player_->SetAnimationDelegate(nullptr); 115 compositor_player_->SetAnimationDelegate(nullptr);
117 compositor_player_.reset(); 116 compositor_player_.reset();
118 117
119 ClearGraphicsLayerLinkHighlightPointer(); 118 ClearGraphicsLayerLinkHighlightPointer();
120 ReleaseResources(); 119 ReleaseResources();
121 } 120 }
122 121
123 WebContentLayer* LinkHighlightImpl::ContentLayer() { 122 WebContentLayer* LinkHighlightImpl::ContentLayer() {
124 return content_layer_.get(); 123 return content_layer_.get();
125 } 124 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 offset_to_backing.Move(-current_graphics_layer_->OffsetFromLayoutObject()); 235 offset_to_backing.Move(-current_graphics_layer_->OffsetFromLayoutObject());
237 236
238 transformed_quad.Move(ToFloatSize(offset_to_backing)); 237 transformed_quad.Move(ToFloatSize(offset_to_backing));
239 238
240 // FIXME: for now, we'll only use rounded paths if we have a single node 239 // FIXME: for now, we'll only use rounded paths if we have a single node
241 // quad. The reason for this is that we may sometimes get a chain of 240 // quad. The reason for this is that we may sometimes get a chain of
242 // adjacent boxes (e.g. for text nodes) which end up looking like sausage 241 // adjacent boxes (e.g. for text nodes) which end up looking like sausage
243 // links: these should ideally be merged into a single rect before creating 242 // links: these should ideally be merged into a single rect before creating
244 // the path, but that's another CL. 243 // the path, but that's another CL.
245 if (quads.size() == 1 && transformed_quad.IsRectilinear() && 244 if (quads.size() == 1 && transformed_quad.IsRectilinear() &&
246 !owning_web_view_impl_->SettingsImpl() 245 !owning_web_view_->SettingsImpl()->MockGestureTapHighlightsEnabled()) {
247 ->MockGestureTapHighlightsEnabled()) {
248 FloatSize rect_rounding_radii(3, 3); 246 FloatSize rect_rounding_radii(3, 3);
249 new_path.AddRoundedRect(transformed_quad.BoundingBox(), 247 new_path.AddRoundedRect(transformed_quad.BoundingBox(),
250 rect_rounding_radii); 248 rect_rounding_radii);
251 } else { 249 } else {
252 AddQuadToPath(transformed_quad, new_path); 250 AddQuadToPath(transformed_quad, new_path);
253 } 251 }
254 } 252 }
255 253
256 FloatRect bounding_rect = new_path.BoundingRect(); 254 FloatRect bounding_rect = new_path.BoundingRect();
257 new_path.Translate(-ToFloatSize(bounding_rect.Location())); 255 new_path.Translate(-ToFloatSize(bounding_rect.Location()));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 kFadeDuration + extra_duration_required, 326 kFadeDuration + extra_duration_required,
329 LayoutTestMode() ? kStartOpacity : 0, timing_function)); 327 LayoutTestMode() ? kStartOpacity : 0, timing_function));
330 328
331 std::unique_ptr<CompositorAnimation> animation = CompositorAnimation::Create( 329 std::unique_ptr<CompositorAnimation> animation = CompositorAnimation::Create(
332 *curve, CompositorTargetProperty::OPACITY, 0, 0); 330 *curve, CompositorTargetProperty::OPACITY, 0, 0);
333 331
334 content_layer_->Layer()->SetDrawsContent(true); 332 content_layer_->Layer()->SetDrawsContent(true);
335 compositor_player_->AddAnimation(std::move(animation)); 333 compositor_player_->AddAnimation(std::move(animation));
336 334
337 Invalidate(); 335 Invalidate();
338 owning_web_view_impl_->MainFrameImpl()->FrameWidget()->ScheduleAnimation(); 336 owning_web_view_->MainFrameImpl()->FrameWidget()->ScheduleAnimation();
339 } 337 }
340 338
341 void LinkHighlightImpl::ClearGraphicsLayerLinkHighlightPointer() { 339 void LinkHighlightImpl::ClearGraphicsLayerLinkHighlightPointer() {
342 if (current_graphics_layer_) { 340 if (current_graphics_layer_) {
343 current_graphics_layer_->RemoveLinkHighlight(this); 341 current_graphics_layer_->RemoveLinkHighlight(this);
344 current_graphics_layer_ = 0; 342 current_graphics_layer_ = 0;
345 } 343 }
346 } 344 }
347 345
348 void LinkHighlightImpl::NotifyAnimationStarted(double, int) {} 346 void LinkHighlightImpl::NotifyAnimationStarted(double, int) {}
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 403
406 WebLayer* LinkHighlightImpl::Layer() { 404 WebLayer* LinkHighlightImpl::Layer() {
407 return ClipLayer(); 405 return ClipLayer();
408 } 406 }
409 407
410 CompositorAnimationPlayer* LinkHighlightImpl::CompositorPlayer() const { 408 CompositorAnimationPlayer* LinkHighlightImpl::CompositorPlayer() const {
411 return compositor_player_.get(); 409 return compositor_player_.get();
412 } 410 }
413 411
414 } // namespace blink 412 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/LinkHighlightImpl.h ('k') | third_party/WebKit/Source/web/LinkHighlightImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698