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

Side by Side Diff: third_party/WebKit/Source/core/dom/DocumentTest.cpp

Issue 2825343003: Clean compositing inputs for location APIs for sticky-affected elements. (Closed)
Patch Set: Add intermediate sticky in StickySubtreesAreTrackedCorrectly test Created 3 years, 7 months 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) 2014, Google Inc. All rights reserved. 2 * Copyright (c) 2014, 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 GetDocument().Loader()->GetApplicationCacheHost(); 790 GetDocument().Loader()->GetApplicationCacheHost();
791 appcache_host->host_ = WTF::MakeUnique<MockWebApplicationCacheHost>(); 791 appcache_host->host_ = WTF::MakeUnique<MockWebApplicationCacheHost>();
792 appcache_host->SelectCacheWithManifest( 792 appcache_host->SelectCacheWithManifest(
793 KURL(KURL(), "https://test.com/foobar/manifest")); 793 KURL(KURL(), "https://test.com/foobar/manifest"));
794 MockWebApplicationCacheHost* mock_web_host = 794 MockWebApplicationCacheHost* mock_web_host =
795 static_cast<MockWebApplicationCacheHost*>(appcache_host->host_.get()); 795 static_cast<MockWebApplicationCacheHost*>(appcache_host->host_.get());
796 EXPECT_FALSE(mock_web_host->with_manifest_was_called_); 796 EXPECT_FALSE(mock_web_host->with_manifest_was_called_);
797 EXPECT_TRUE(mock_web_host->without_manifest_was_called_); 797 EXPECT_TRUE(mock_web_host->without_manifest_was_called_);
798 } 798 }
799 799
800 // Verifies that calling EnsureAuxiliaryLocationDataValidForNode cleans
801 // compositor inputs only when necessary. We generally want to avoid cleaning
802 // the compositing inputs, as it is more expensive than just doing layout.
803 TEST_F(
804 DocumentTest,
805 EnsureAuxiliaryLocationDataValidForNodeCompositingInputsOnlyWhenNecessary) {
806 GetDocument().body()->setInnerHTML(
807 "<div id='ancestor'>"
808 " <div id='sticky' style='position:sticky;'>"
809 " <div id='stickyChild'></div>"
810 " </div>"
811 " <div id='nonSticky'></div>"
812 "</div>");
813 EXPECT_EQ(DocumentLifecycle::kStyleClean,
814 GetDocument().Lifecycle().GetState());
815
816 // Asking for any element that is not affected by a sticky element should only
817 // advance the lifecycle to layout clean.
818 GetDocument().EnsureAuxiliaryLocationDataValidForNode(
819 GetDocument().getElementById("ancestor"));
820 EXPECT_EQ(DocumentLifecycle::kLayoutClean,
821 GetDocument().Lifecycle().GetState());
822
823 GetDocument().EnsureAuxiliaryLocationDataValidForNode(
824 GetDocument().getElementById("nonSticky"));
825 EXPECT_EQ(DocumentLifecycle::kLayoutClean,
826 GetDocument().Lifecycle().GetState());
827
828 // However, asking for either the sticky element or it's descendents should
829 // clean compositing inputs as well.
830 GetDocument().EnsureAuxiliaryLocationDataValidForNode(
831 GetDocument().getElementById("sticky"));
832 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
833 GetDocument().Lifecycle().GetState());
834
835 // Dirty layout.
836 GetDocument().body()->setAttribute("style", "background: red;");
837 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending,
838 GetDocument().Lifecycle().GetState());
839
840 GetDocument().EnsureAuxiliaryLocationDataValidForNode(
841 GetDocument().getElementById("stickyChild"));
842 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
843 GetDocument().Lifecycle().GetState());
844 }
845
800 } // namespace blink 846 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698