| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/observer/ResizeObserver.h" | 5 #include "core/observer/ResizeObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
| 8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
| 9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "core/observer/ResizeObservation.h" | 10 #include "core/observer/ResizeObservation.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Element* domTarget = document().getElementById("domTarget"); | 76 Element* domTarget = document().getElementById("domTarget"); |
| 77 Element* svgTarget = document().getElementById("svgTarget"); | 77 Element* svgTarget = document().getElementById("svgTarget"); |
| 78 ResizeObservation* domObservation = new ResizeObservation(domTarget, observe
r); | 78 ResizeObservation* domObservation = new ResizeObservation(domTarget, observe
r); |
| 79 ResizeObservation* svgObservation = new ResizeObservation(svgTarget, observe
r); | 79 ResizeObservation* svgObservation = new ResizeObservation(svgTarget, observe
r); |
| 80 | 80 |
| 81 // Initial observation is out of sync | 81 // Initial observation is out of sync |
| 82 ASSERT_TRUE(domObservation->observationSizeOutOfSync()); | 82 ASSERT_TRUE(domObservation->observationSizeOutOfSync()); |
| 83 ASSERT_TRUE(svgObservation->observationSizeOutOfSync()); | 83 ASSERT_TRUE(svgObservation->observationSizeOutOfSync()); |
| 84 | 84 |
| 85 // Target size is correct | 85 // Target size is correct |
| 86 LayoutSize size = ResizeObservation::getTargetSize(domTarget); | 86 LayoutSize size = domObservation->computeTargetSize(); |
| 87 ASSERT_EQ(size.width(), 100); | 87 ASSERT_EQ(size.width(), 100); |
| 88 ASSERT_EQ(size.height(), 100); | 88 ASSERT_EQ(size.height(), 100); |
| 89 domObservation->setObservationSize(size); | 89 domObservation->setObservationSize(size); |
| 90 | 90 |
| 91 size = ResizeObservation::getTargetSize(svgTarget); | 91 size = svgObservation->computeTargetSize(); |
| 92 ASSERT_EQ(size.width(), 200); | 92 ASSERT_EQ(size.width(), 200); |
| 93 ASSERT_EQ(size.height(), 200); | 93 ASSERT_EQ(size.height(), 200); |
| 94 svgObservation->setObservationSize(size); | 94 svgObservation->setObservationSize(size); |
| 95 | 95 |
| 96 // Target size is in sync | 96 // Target size is in sync |
| 97 ASSERT_FALSE(domObservation->observationSizeOutOfSync()); | 97 ASSERT_FALSE(domObservation->observationSizeOutOfSync()); |
| 98 | 98 |
| 99 // Target depths | 99 // Target depths |
| 100 ASSERT_EQ(svgObservation->targetDepth() - domObservation->targetDepth(), (si
ze_t)1); | 100 ASSERT_EQ(svgObservation->targetDepth() - domObservation->targetDepth(), (si
ze_t)1); |
| 101 } | 101 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ASSERT_EQ(observers.size(), 1U); | 141 ASSERT_EQ(observers.size(), 1U); |
| 142 script.executeScriptInMainWorldAndReturnValue( | 142 script.executeScriptInMainWorldAndReturnValue( |
| 143 ScriptSourceCode("el = undefined;"), | 143 ScriptSourceCode("el = undefined;"), |
| 144 ScriptController::ExecuteScriptWhenScriptsDisabled); | 144 ScriptController::ExecuteScriptWhenScriptsDisabled); |
| 145 V8GCController::collectAllGarbageForTesting(v8::Isolate::GetCurrent()); | 145 V8GCController::collectAllGarbageForTesting(v8::Isolate::GetCurrent()); |
| 146 WebHeap::collectAllGarbageForTesting(); | 146 WebHeap::collectAllGarbageForTesting(); |
| 147 ASSERT_EQ(observers.isEmpty(), true); | 147 ASSERT_EQ(observers.isEmpty(), true); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |