| OLD | NEW |
| 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 Loading... |
| 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 EnsurePaintLocationDataValidForNode cleans compositor |
| 801 // inputs only when necessary. We generally want to avoid cleaning the inputs, |
| 802 // as it is more expensive than just doing layout. |
| 803 TEST_F(DocumentTest, |
| 804 EnsurePaintLocationDataValidForNodeCompositingInputsOnlyWhenNecessary) { |
| 805 GetDocument().body()->setInnerHTML( |
| 806 "<div id='ancestor'>" |
| 807 " <div id='sticky' style='position:sticky;'>" |
| 808 " <div id='stickyChild'></div>" |
| 809 " </div>" |
| 810 " <div id='nonSticky'></div>" |
| 811 "</div>"); |
| 812 EXPECT_EQ(DocumentLifecycle::kStyleClean, |
| 813 GetDocument().Lifecycle().GetState()); |
| 814 |
| 815 // Asking for any element that is not affected by a sticky element should only |
| 816 // advance the lifecycle to layout clean. |
| 817 GetDocument().EnsurePaintLocationDataValidForNode( |
| 818 GetDocument().getElementById("ancestor")); |
| 819 EXPECT_EQ(DocumentLifecycle::kLayoutClean, |
| 820 GetDocument().Lifecycle().GetState()); |
| 821 |
| 822 GetDocument().EnsurePaintLocationDataValidForNode( |
| 823 GetDocument().getElementById("nonSticky")); |
| 824 EXPECT_EQ(DocumentLifecycle::kLayoutClean, |
| 825 GetDocument().Lifecycle().GetState()); |
| 826 |
| 827 // However, asking for either the sticky element or it's descendents should |
| 828 // clean compositing inputs as well. |
| 829 GetDocument().EnsurePaintLocationDataValidForNode( |
| 830 GetDocument().getElementById("sticky")); |
| 831 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean, |
| 832 GetDocument().Lifecycle().GetState()); |
| 833 |
| 834 // Dirty layout. |
| 835 GetDocument().body()->setAttribute("style", "background: red;"); |
| 836 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending, |
| 837 GetDocument().Lifecycle().GetState()); |
| 838 |
| 839 GetDocument().EnsurePaintLocationDataValidForNode( |
| 840 GetDocument().getElementById("stickyChild")); |
| 841 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean, |
| 842 GetDocument().Lifecycle().GetState()); |
| 843 } |
| 844 |
| 800 } // namespace blink | 845 } // namespace blink |
| OLD | NEW |