| OLD | NEW | 
|     1 // Copyright 2015 The Chromium Authors. All rights reserved. |     1 // Copyright 2015 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/html/HTMLIFrameElement.h" | 
|     5 #include "core/layout/LayoutTestHelper.h" |     6 #include "core/layout/LayoutTestHelper.h" | 
|     6 #include "core/layout/LayoutTreeAsText.h" |     7 #include "core/layout/LayoutTreeAsText.h" | 
|     7 #include "core/layout/api/LayoutViewItem.h" |     8 #include "core/layout/api/LayoutViewItem.h" | 
|     8 #include "core/paint/ObjectPaintProperties.h" |     9 #include "core/paint/ObjectPaintProperties.h" | 
|     9 #include "core/paint/PaintPropertyTreePrinter.h" |    10 #include "core/paint/PaintPropertyTreePrinter.h" | 
|    10 #include "platform/graphics/paint/GeometryMapper.h" |    11 #include "platform/graphics/paint/GeometryMapper.h" | 
|    11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |    12 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 
|    12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |    13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 
|    13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |    14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 
|    14 #include "platform/testing/UnitTestHelpers.h" |    15 #include "platform/testing/UnitTestHelpers.h" | 
| (...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2922   EXPECT_TRUE(childLayoutView->descendantNeedsPaintPropertyUpdate()); |  2923   EXPECT_TRUE(childLayoutView->descendantNeedsPaintPropertyUpdate()); | 
|  2923   EXPECT_TRUE(innerDivWithTransform->needsPaintPropertyUpdate()); |  2924   EXPECT_TRUE(innerDivWithTransform->needsPaintPropertyUpdate()); | 
|  2924   EXPECT_FALSE(innerDivWithTransform->descendantNeedsPaintPropertyUpdate()); |  2925   EXPECT_FALSE(innerDivWithTransform->descendantNeedsPaintPropertyUpdate()); | 
|  2925  |  2926  | 
|  2926   // After a lifecycle update, no nodes should need a descendant update. |  2927   // After a lifecycle update, no nodes should need a descendant update. | 
|  2927   frameView->updateAllLifecyclePhases(); |  2928   frameView->updateAllLifecyclePhases(); | 
|  2928   EXPECT_FALSE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); |  2929   EXPECT_FALSE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
|  2929   EXPECT_FALSE(divWithTransform->descendantNeedsPaintPropertyUpdate()); |  2930   EXPECT_FALSE(divWithTransform->descendantNeedsPaintPropertyUpdate()); | 
|  2930   EXPECT_FALSE(childLayoutView->descendantNeedsPaintPropertyUpdate()); |  2931   EXPECT_FALSE(childLayoutView->descendantNeedsPaintPropertyUpdate()); | 
|  2931   EXPECT_FALSE(innerDivWithTransform->descendantNeedsPaintPropertyUpdate()); |  2932   EXPECT_FALSE(innerDivWithTransform->descendantNeedsPaintPropertyUpdate()); | 
 |  2933  | 
 |  2934   // A child frame marked as needing a paint property update should not be | 
 |  2935   // skipped if the owning layout tree does not need an update. | 
 |  2936   FrameView* childFrameView = childDocument().view(); | 
 |  2937   childFrameView->setNeedsPaintPropertyUpdate(); | 
 |  2938   EXPECT_TRUE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
 |  2939   frameView->updateAllLifecyclePhases(); | 
 |  2940   EXPECT_FALSE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
 |  2941   EXPECT_FALSE(frameView->needsPaintPropertyUpdate()); | 
 |  2942   EXPECT_FALSE(childFrameView->needsPaintPropertyUpdate()); | 
|  2932 } |  2943 } | 
|  2933  |  2944  | 
|  2934 TEST_P(PaintPropertyTreeBuilderTest, UpdatingFrameViewContentClip) { |  2945 TEST_P(PaintPropertyTreeBuilderTest, UpdatingFrameViewContentClip) { | 
|  2935   setBodyInnerHTML("hello world."); |  2946   setBodyInnerHTML("hello world."); | 
|  2936   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |  2947   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); | 
|  2937   document().view()->resize(800, 599); |  2948   document().view()->resize(800, 599); | 
|  2938   document().view()->updateAllLifecyclePhases(); |  2949   document().view()->updateAllLifecyclePhases(); | 
|  2939   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 599), frameContentClip()->clipRect()); |  2950   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 599), frameContentClip()->clipRect()); | 
|  2940   document().view()->resize(800, 600); |  2951   document().view()->resize(800, 600); | 
|  2941   document().view()->updateAllLifecyclePhases(); |  2952   document().view()->updateAllLifecyclePhases(); | 
|  2942   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |  2953   EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); | 
|  2943   document().view()->resize(5, 5); |  2954   document().view()->resize(5, 5); | 
|  2944   document().view()->updateAllLifecyclePhases(); |  2955   document().view()->updateAllLifecyclePhases(); | 
|  2945   EXPECT_EQ(FloatRoundedRect(0, 0, 5, 5), frameContentClip()->clipRect()); |  2956   EXPECT_EQ(FloatRoundedRect(0, 0, 5, 5), frameContentClip()->clipRect()); | 
|  2946 } |  2957 } | 
|  2947  |  2958  | 
 |  2959 TEST_P(PaintPropertyTreeBuilderTest, BuildingStopsAtThrottledFrames) { | 
 |  2960   setBodyInnerHTML( | 
 |  2961       "<style>body { margin: 0; }</style>" | 
 |  2962       "<div id='transform' style='transform: translate3d(4px, 5px, 6px);'>" | 
 |  2963       "</div>" | 
 |  2964       "<iframe id='iframe' sandbox></iframe>"); | 
 |  2965   setChildFrameHTML( | 
 |  2966       "<style>body { margin: 0; }</style>" | 
 |  2967       "<div id='iframeTransform'" | 
 |  2968       "  style='transform: translate3d(4px, 5px, 6px);'/>"); | 
 |  2969  | 
 |  2970   // Move the child frame offscreen so it becomes available for throttling. | 
 |  2971   auto* iframe = toHTMLIFrameElement(document().getElementById("iframe")); | 
 |  2972   iframe->setAttribute(HTMLNames::styleAttr, "transform: translateY(5555px)"); | 
 |  2973   document().view()->updateAllLifecyclePhases(); | 
 |  2974   // Ensure intersection observer notifications get delivered. | 
 |  2975   testing::runPendingTasks(); | 
 |  2976   EXPECT_FALSE(document().view()->isHiddenForThrottling()); | 
 |  2977   EXPECT_TRUE(childDocument().view()->isHiddenForThrottling()); | 
 |  2978  | 
 |  2979   auto* transform = document().getElementById("transform")->layoutObject(); | 
 |  2980   auto* iframeLayoutView = childDocument().layoutView(); | 
 |  2981   auto* iframeTransform = | 
 |  2982       childDocument().getElementById("iframeTransform")->layoutObject(); | 
 |  2983  | 
 |  2984   // Invalidate properties in the iframe and ensure ancestors are marked. | 
 |  2985   iframeTransform->setNeedsPaintPropertyUpdate(); | 
 |  2986   EXPECT_FALSE(document().layoutView()->needsPaintPropertyUpdate()); | 
 |  2987   EXPECT_TRUE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
 |  2988   EXPECT_FALSE(transform->needsPaintPropertyUpdate()); | 
 |  2989   EXPECT_FALSE(transform->descendantNeedsPaintPropertyUpdate()); | 
 |  2990   EXPECT_FALSE(iframeLayoutView->needsPaintPropertyUpdate()); | 
 |  2991   EXPECT_TRUE(iframeLayoutView->descendantNeedsPaintPropertyUpdate()); | 
 |  2992   EXPECT_TRUE(iframeTransform->needsPaintPropertyUpdate()); | 
 |  2993   EXPECT_FALSE(iframeTransform->descendantNeedsPaintPropertyUpdate()); | 
 |  2994  | 
 |  2995   transform->setNeedsPaintPropertyUpdate(); | 
 |  2996   EXPECT_TRUE(transform->needsPaintPropertyUpdate()); | 
 |  2997   EXPECT_FALSE(transform->descendantNeedsPaintPropertyUpdate()); | 
 |  2998  | 
 |  2999   { | 
 |  3000     DocumentLifecycle::AllowThrottlingScope throttlingScope( | 
 |  3001         document().lifecycle()); | 
 |  3002     EXPECT_FALSE(document().view()->shouldThrottleRendering()); | 
 |  3003     EXPECT_TRUE(childDocument().view()->shouldThrottleRendering()); | 
 |  3004  | 
 |  3005     // A lifecycle update should update all properties except those with | 
 |  3006     // actively throttled descendants. | 
 |  3007     document().view()->updateAllLifecyclePhases(); | 
 |  3008     EXPECT_FALSE(document().layoutView()->needsPaintPropertyUpdate()); | 
 |  3009     EXPECT_TRUE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
 |  3010     EXPECT_FALSE(transform->needsPaintPropertyUpdate()); | 
 |  3011     EXPECT_FALSE(transform->descendantNeedsPaintPropertyUpdate()); | 
 |  3012     EXPECT_FALSE(iframeLayoutView->needsPaintPropertyUpdate()); | 
 |  3013     EXPECT_TRUE(iframeLayoutView->descendantNeedsPaintPropertyUpdate()); | 
 |  3014     EXPECT_TRUE(iframeTransform->needsPaintPropertyUpdate()); | 
 |  3015     EXPECT_FALSE(iframeTransform->descendantNeedsPaintPropertyUpdate()); | 
 |  3016   } | 
 |  3017  | 
 |  3018   EXPECT_FALSE(document().view()->shouldThrottleRendering()); | 
 |  3019   EXPECT_FALSE(childDocument().view()->shouldThrottleRendering()); | 
 |  3020   // Once unthrottled, a lifecycel update should update all properties. | 
 |  3021   document().view()->updateAllLifecyclePhases(); | 
 |  3022   EXPECT_FALSE(document().layoutView()->needsPaintPropertyUpdate()); | 
 |  3023   EXPECT_FALSE(document().layoutView()->descendantNeedsPaintPropertyUpdate()); | 
 |  3024   EXPECT_FALSE(transform->needsPaintPropertyUpdate()); | 
 |  3025   EXPECT_FALSE(transform->descendantNeedsPaintPropertyUpdate()); | 
 |  3026   EXPECT_FALSE(iframeLayoutView->needsPaintPropertyUpdate()); | 
 |  3027   EXPECT_FALSE(iframeLayoutView->descendantNeedsPaintPropertyUpdate()); | 
 |  3028   EXPECT_FALSE(iframeTransform->needsPaintPropertyUpdate()); | 
 |  3029   EXPECT_FALSE(iframeTransform->descendantNeedsPaintPropertyUpdate()); | 
 |  3030 } | 
 |  3031  | 
|  2948 }  // namespace blink |  3032 }  // namespace blink | 
| OLD | NEW |