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