| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/animation/ElementAnimation.h" | 5 #include "core/animation/ElementAnimation.h" |
| 6 #include "core/css/PropertyDescriptor.h" | 6 #include "core/css/PropertyDescriptor.h" |
| 7 #include "core/css/PropertyRegistration.h" | 7 #include "core/css/PropertyRegistration.h" |
| 8 #include "core/frame/WebLocalFrameBase.h" | 8 #include "core/frame/WebLocalFrameBase.h" |
| 9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
| 10 #include "core/testing/sim/SimCompositor.h" | 10 #include "core/testing/sim/SimCompositor.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // target.style.setProperty('--x', '100%'); | 59 // target.style.setProperty('--x', '100%'); |
| 60 target->style()->setProperty("--x", "100%", g_empty_string, exception_state); | 60 target->style()->setProperty("--x", "100%", g_empty_string, exception_state); |
| 61 EXPECT_FALSE(exception_state.HadException()); | 61 EXPECT_FALSE(exception_state.HadException()); |
| 62 | 62 |
| 63 // target.animate({'--x': '100%'}, 1000); | 63 // target.animate({'--x': '100%'}, 1000); |
| 64 RefPtr<StringKeyframe> keyframe = StringKeyframe::Create(); | 64 RefPtr<StringKeyframe> keyframe = StringKeyframe::Create(); |
| 65 keyframe->SetCSSPropertyValue("--x", GetDocument().GetPropertyRegistry(), | 65 keyframe->SetCSSPropertyValue("--x", GetDocument().GetPropertyRegistry(), |
| 66 "100%", | 66 "100%", |
| 67 GetDocument().ElementSheet().Contents()); | 67 GetDocument().ElementSheet().Contents()); |
| 68 StringKeyframeVector keyframes; | 68 StringKeyframeVector keyframes; |
| 69 keyframes.push_back(keyframe.Release()); | 69 keyframes.push_back(std::move(keyframe)); |
| 70 Timing timing; | 70 Timing timing; |
| 71 timing.iteration_duration = 1; // Seconds. | 71 timing.iteration_duration = 1; // Seconds. |
| 72 ElementAnimation::animateInternal( | 72 ElementAnimation::animateInternal( |
| 73 *target, StringKeyframeEffectModel::Create(keyframes), timing); | 73 *target, StringKeyframeEffectModel::Create(keyframes), timing); |
| 74 | 74 |
| 75 // This sets the baseComputedStyle on the animation exit frame. | 75 // This sets the baseComputedStyle on the animation exit frame. |
| 76 Compositor().BeginFrame(1); | 76 Compositor().BeginFrame(1); |
| 77 Compositor().BeginFrame(1); | 77 Compositor().BeginFrame(1); |
| 78 | 78 |
| 79 // target.style.setProperty('--x', '0%'); | 79 // target.style.setProperty('--x', '0%'); |
| 80 target->style()->setProperty("--x", "0%", g_empty_string, exception_state); | 80 target->style()->setProperty("--x", "0%", g_empty_string, exception_state); |
| 81 EXPECT_FALSE(exception_state.HadException()); | 81 EXPECT_FALSE(exception_state.HadException()); |
| 82 | 82 |
| 83 // target.animate({'--x': '100%'}, 1000); | 83 // target.animate({'--x': '100%'}, 1000); |
| 84 keyframe = StringKeyframe::Create(); | 84 keyframe = StringKeyframe::Create(); |
| 85 keyframe->SetCSSPropertyValue("--x", GetDocument().GetPropertyRegistry(), | 85 keyframe->SetCSSPropertyValue("--x", GetDocument().GetPropertyRegistry(), |
| 86 "100%", | 86 "100%", |
| 87 GetDocument().ElementSheet().Contents()); | 87 GetDocument().ElementSheet().Contents()); |
| 88 keyframes.clear(); | 88 keyframes.clear(); |
| 89 keyframes.push_back(keyframe.Release()); | 89 keyframes.push_back(std::move(keyframe)); |
| 90 timing = Timing::Defaults(); | 90 timing = Timing::Defaults(); |
| 91 timing.iteration_duration = 1; // Seconds. | 91 timing.iteration_duration = 1; // Seconds. |
| 92 ElementAnimation::animateInternal( | 92 ElementAnimation::animateInternal( |
| 93 *target, StringKeyframeEffectModel::Create(keyframes), timing); | 93 *target, StringKeyframeEffectModel::Create(keyframes), timing); |
| 94 | 94 |
| 95 // This (previously) would not clear the existing baseComputedStyle and would | 95 // This (previously) would not clear the existing baseComputedStyle and would |
| 96 // crash on the equality assertion in the exit frame when it tried to update | 96 // crash on the equality assertion in the exit frame when it tried to update |
| 97 // it. | 97 // it. |
| 98 Compositor().BeginFrame(1); | 98 Compositor().BeginFrame(1); |
| 99 Compositor().BeginFrame(1); | 99 Compositor().BeginFrame(1); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |