Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp

Issue 2531603003: Only scroll on main if the targeted frames need to scroll on main (Closed)
Patch Set: Fix compiling error due to using backslash at the end of a commenting line" Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "core/page/scrolling/ScrollingCoordinator.h" 25 #include "core/page/scrolling/ScrollingCoordinator.h"
26 26
27 #include "core/css/CSSStyleSheet.h" 27 #include "core/css/CSSStyleSheet.h"
28 #include "core/css/StyleSheetList.h" 28 #include "core/css/StyleSheetList.h"
29 #include "core/frame/FrameHost.h" 29 #include "core/frame/FrameHost.h"
30 #include "core/frame/FrameView.h" 30 #include "core/frame/FrameView.h"
31 #include "core/frame/VisualViewport.h" 31 #include "core/frame/VisualViewport.h"
32 #include "core/html/HTMLIFrameElement.h"
32 #include "core/layout/LayoutPart.h" 33 #include "core/layout/LayoutPart.h"
33 #include "core/layout/api/LayoutViewItem.h" 34 #include "core/layout/api/LayoutViewItem.h"
34 #include "core/layout/compositing/CompositedLayerMapping.h" 35 #include "core/layout/compositing/CompositedLayerMapping.h"
35 #include "core/layout/compositing/PaintLayerCompositor.h" 36 #include "core/layout/compositing/PaintLayerCompositor.h"
36 #include "core/page/Page.h" 37 #include "core/page/Page.h"
37 #include "platform/geometry/IntPoint.h" 38 #include "platform/geometry/IntPoint.h"
38 #include "platform/geometry/IntRect.h" 39 #include "platform/geometry/IntRect.h"
39 #include "platform/graphics/GraphicsLayer.h" 40 #include "platform/graphics/GraphicsLayer.h"
40 #include "platform/testing/URLTestHelpers.h" 41 #include "platform/testing/URLTestHelpers.h"
41 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 container->removeAttribute("class"); 843 container->removeAttribute("class");
843 forceFullCompositingUpdate(); 844 forceFullCompositingUpdate();
844 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); 845 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar();
845 ASSERT_FALSE( 846 ASSERT_FALSE(
846 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); 847 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread());
847 ASSERT_FALSE( 848 ASSERT_FALSE(
848 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & 849 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() &
849 MainThreadScrollingReason::kCustomScrollbarScrolling); 850 MainThreadScrollingReason::kCustomScrollbarScrolling);
850 } 851 }
851 852
853 TEST_F(ScrollingCoordinatorTest,
854 BackgroundAttachmentFixedShouldTriggerMainThreadScroll) {
855 registerMockedHttpURLLoad("iframe-background-attachment-fixed.html");
856 registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html");
857 registerMockedHttpURLLoad("white-1x1.png");
858 navigateTo(m_baseURL + "iframe-background-attachment-fixed.html");
859 forceFullCompositingUpdate();
860
861 Element* iframe = frame()->document()->getElementById("iframe");
862 ASSERT_TRUE(iframe);
863
864 LayoutObject* layoutObject = iframe->layoutObject();
865 ASSERT_TRUE(layoutObject);
866 ASSERT_TRUE(layoutObject->isLayoutPart());
867
868 LayoutPart* layoutPart = toLayoutPart(layoutObject);
869 ASSERT_TRUE(layoutPart);
870 ASSERT_TRUE(layoutPart->widget());
871 ASSERT_TRUE(layoutPart->widget()->isFrameView());
872
873 FrameView* innerFrameView = toFrameView(layoutPart->widget());
874 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem();
875 ASSERT_FALSE(innerLayoutViewItem.isNull());
876
877 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor();
878 ASSERT_TRUE(innerCompositor->inCompositingMode());
879 ASSERT_TRUE(innerCompositor->scrollLayer());
880
881 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer();
882 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea());
883
884 WebLayer* webScrollLayer = scrollLayer->platformLayer();
885 ASSERT_TRUE(webScrollLayer->scrollable());
886 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() &
887 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
888
889 // Remove fixed background-attachment should make the iframe
890 // scroll on cc.
891 auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument();
892 iframe = iframeDoc->getElementById("scrollable");
893 ASSERT_TRUE(iframe);
894
895 iframe->removeAttribute("class");
896 forceFullCompositingUpdate();
897
898 layoutObject = iframe->layoutObject();
899 ASSERT_TRUE(layoutObject);
900
901 scrollLayer = layoutObject->frameView()->layerForScrolling();
902 ASSERT_TRUE(scrollLayer);
903
904 webScrollLayer = scrollLayer->platformLayer();
905 ASSERT_TRUE(webScrollLayer->scrollable());
906 ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() &
907 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
908
909 // Force main frame to scroll on main thread. All its descendants
910 // should scroll on main thread as well.
911 Element* element = frame()->document()->getElementById("scrollable");
912 element->setAttribute(
913 "style",
914 "background-image: url('white-1x1.png'); background-attachment: fixed;;",
pdr. 2016/12/19 04:04:28 Nit: extra semicolon
yigu 2016/12/20 00:48:34 Done.
915 ASSERT_NO_EXCEPTION);
916
917 forceFullCompositingUpdate();
918
919 layoutObject = iframe->layoutObject();
920 ASSERT_TRUE(layoutObject);
921
922 scrollLayer = layoutObject->frameView()->layerForScrolling();
923 ASSERT_TRUE(scrollLayer);
924
925 webScrollLayer = scrollLayer->platformLayer();
926 ASSERT_TRUE(webScrollLayer->scrollable());
927 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() &
928 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
929 }
852 } // namespace blink 930 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698