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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "public/platform/WebSize.h" 51 #include "public/platform/WebSize.h"
52 #include "public/web/WebKit.h" 52 #include "public/web/WebKit.h"
53 #include "third_party/skia/include/core/SkCanvas.h" 53 #include "third_party/skia/include/core/SkCanvas.h"
54 #include "third_party/skia/include/core/SkMatrix44.h" 54 #include "third_party/skia/include/core/SkMatrix44.h"
55 #include "third_party/skia/include/core/SkPictureRecorder.h" 55 #include "third_party/skia/include/core/SkPictureRecorder.h"
56 #include "ui/gfx/geometry/rect.h" 56 #include "ui/gfx/geometry/rect.h"
57 #include "web/WebLocalFrameImpl.h" 57 #include "web/WebLocalFrameImpl.h"
58 #include "web/WebSettingsImpl.h" 58 #include "web/WebSettingsImpl.h"
59 #include "web/WebViewImpl.h" 59 #include "web/WebViewImpl.h"
60 #include "wtf/CurrentTime.h" 60 #include "wtf/CurrentTime.h"
61 #include "wtf/PtrUtil.h"
61 #include "wtf/Vector.h" 62 #include "wtf/Vector.h"
63 #include <memory>
62 64
63 namespace blink { 65 namespace blink {
64 66
65 PassOwnPtr<LinkHighlightImpl> LinkHighlightImpl::create(Node* node, WebViewImpl* owningWebViewImpl) 67 std::unique_ptr<LinkHighlightImpl> LinkHighlightImpl::create(Node* node, WebView Impl* owningWebViewImpl)
66 { 68 {
67 return adoptPtr(new LinkHighlightImpl(node, owningWebViewImpl)); 69 return wrapUnique(new LinkHighlightImpl(node, owningWebViewImpl));
68 } 70 }
69 71
70 LinkHighlightImpl::LinkHighlightImpl(Node* node, WebViewImpl* owningWebViewImpl) 72 LinkHighlightImpl::LinkHighlightImpl(Node* node, WebViewImpl* owningWebViewImpl)
71 : m_node(node) 73 : m_node(node)
72 , m_owningWebViewImpl(owningWebViewImpl) 74 , m_owningWebViewImpl(owningWebViewImpl)
73 , m_currentGraphicsLayer(0) 75 , m_currentGraphicsLayer(0)
74 , m_isScrollingGraphicsLayer(false) 76 , m_isScrollingGraphicsLayer(false)
75 , m_geometryNeedsUpdate(false) 77 , m_geometryNeedsUpdate(false)
76 , m_isAnimating(false) 78 , m_isAnimating(false)
77 , m_startTime(monotonicallyIncreasingTime()) 79 , m_startTime(monotonicallyIncreasingTime())
78 { 80 {
79 DCHECK(m_node); 81 DCHECK(m_node);
80 DCHECK(owningWebViewImpl); 82 DCHECK(owningWebViewImpl);
81 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup port(); 83 WebCompositorSupport* compositorSupport = Platform::current()->compositorSup port();
82 DCHECK(compositorSupport); 84 DCHECK(compositorSupport);
83 m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this)); 85 m_contentLayer = wrapUnique(compositorSupport->createContentLayer(this));
84 m_clipLayer = adoptPtr(compositorSupport->createLayer()); 86 m_clipLayer = wrapUnique(compositorSupport->createLayer());
85 m_clipLayer->setTransformOrigin(WebFloatPoint3D()); 87 m_clipLayer->setTransformOrigin(WebFloatPoint3D());
86 m_clipLayer->addChild(m_contentLayer->layer()); 88 m_clipLayer->addChild(m_contentLayer->layer());
87 89
88 m_compositorPlayer = adoptPtr(CompositorFactory::current().createAnimationPl ayer()); 90 m_compositorPlayer = wrapUnique(CompositorFactory::current().createAnimation Player());
89 DCHECK(m_compositorPlayer); 91 DCHECK(m_compositorPlayer);
90 m_compositorPlayer->setAnimationDelegate(this); 92 m_compositorPlayer->setAnimationDelegate(this);
91 if (m_owningWebViewImpl->linkHighlightsTimeline()) 93 if (m_owningWebViewImpl->linkHighlightsTimeline())
92 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this); 94 m_owningWebViewImpl->linkHighlightsTimeline()->playerAttached(*this);
93 m_compositorPlayer->attachLayer(m_contentLayer->layer()); 95 m_compositorPlayer->attachLayer(m_contentLayer->layer());
94 96
95 m_contentLayer->layer()->setDrawsContent(true); 97 m_contentLayer->layer()->setDrawsContent(true);
96 m_contentLayer->layer()->setOpacity(1); 98 m_contentLayer->layer()->setOpacity(1);
97 m_geometryNeedsUpdate = true; 99 m_geometryNeedsUpdate = true;
98 } 100 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return; 296 return;
295 297
296 m_isAnimating = true; 298 m_isAnimating = true;
297 const float startOpacity = 1; 299 const float startOpacity = 1;
298 // FIXME: Should duration be configurable? 300 // FIXME: Should duration be configurable?
299 const float fadeDuration = 0.1f; 301 const float fadeDuration = 0.1f;
300 const float minPreFadeDuration = 0.1f; 302 const float minPreFadeDuration = 0.1f;
301 303
302 m_contentLayer->layer()->setOpacity(startOpacity); 304 m_contentLayer->layer()->setOpacity(startOpacity);
303 305
304 OwnPtr<CompositorFloatAnimationCurve> curve = adoptPtr(CompositorFactory::cu rrent().createFloatAnimationCurve()); 306 std::unique_ptr<CompositorFloatAnimationCurve> curve = wrapUnique(Compositor Factory::current().createFloatAnimationCurve());
305 307
306 const auto easeType = CubicBezierTimingFunction::EaseType::EASE; 308 const auto easeType = CubicBezierTimingFunction::EaseType::EASE;
307 309
308 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, startOpacity), ease Type); 310 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, startOpacity), ease Type);
309 // Make sure we have displayed for at least minPreFadeDuration before starti ng to fade out. 311 // Make sure we have displayed for at least minPreFadeDuration before starti ng to fade out.
310 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast <float>(monotonicallyIncreasingTime() - m_startTime)); 312 float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast <float>(monotonicallyIncreasingTime() - m_startTime));
311 if (extraDurationRequired) 313 if (extraDurationRequired)
312 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(extraDurationRequi red, startOpacity), easeType); 314 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(extraDurationRequi red, startOpacity), easeType);
313 // For layout tests we don't fade out. 315 // For layout tests we don't fade out.
314 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(fadeDuration + extraDu rationRequired, layoutTestMode() ? startOpacity : 0), easeType); 316 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(fadeDuration + extraDu rationRequired, layoutTestMode() ? startOpacity : 0), easeType);
315 317
316 OwnPtr<CompositorAnimation> animation = adoptPtr(CompositorFactory::current( ).createAnimation(*curve, CompositorTargetProperty::OPACITY)); 318 std::unique_ptr<CompositorAnimation> animation = wrapUnique(CompositorFactor y::current().createAnimation(*curve, CompositorTargetProperty::OPACITY));
317 319
318 m_contentLayer->layer()->setDrawsContent(true); 320 m_contentLayer->layer()->setDrawsContent(true);
319 m_compositorPlayer->addAnimation(animation.leakPtr()); 321 m_compositorPlayer->addAnimation(animation.release());
320 322
321 invalidate(); 323 invalidate();
322 m_owningWebViewImpl->scheduleAnimation(); 324 m_owningWebViewImpl->scheduleAnimation();
323 } 325 }
324 326
325 void LinkHighlightImpl::clearGraphicsLayerLinkHighlightPointer() 327 void LinkHighlightImpl::clearGraphicsLayerLinkHighlightPointer()
326 { 328 {
327 if (m_currentGraphicsLayer) { 329 if (m_currentGraphicsLayer) {
328 m_currentGraphicsLayer->removeLinkHighlight(this); 330 m_currentGraphicsLayer->removeLinkHighlight(this);
329 m_currentGraphicsLayer = 0; 331 m_currentGraphicsLayer = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 { 393 {
392 return clipLayer(); 394 return clipLayer();
393 } 395 }
394 396
395 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const 397 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const
396 { 398 {
397 return m_compositorPlayer.get(); 399 return m_compositorPlayer.get();
398 } 400 }
399 401
400 } // namespace blink 402 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698