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