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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 190973007: Reland "Avoid layout/full-repaint on view height change if possible" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: computeOverflow, etc. Created 6 years, 9 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 using WebCore::HitTestRequest; 98 using WebCore::HitTestRequest;
99 using WebCore::Range; 99 using WebCore::Range;
100 using blink::URLTestHelpers::toKURL; 100 using blink::URLTestHelpers::toKURL;
101 using blink::FrameTestHelpers::runPendingTasks; 101 using blink::FrameTestHelpers::runPendingTasks;
102 102
103 namespace { 103 namespace {
104 104
105 const int touchPointPadding = 32; 105 const int touchPointPadding = 32;
106 106
107 #define EXPECT_EQ_RECT(a, b) \ 107 #define EXPECT_EQ_RECT(a, b) \
108 EXPECT_EQ(a.x(), b.x()); \ 108 do { \
109 EXPECT_EQ(a.y(), b.y()); \ 109 EXPECT_EQ(a.x(), b.x()); \
110 EXPECT_EQ(a.width(), b.width()); \ 110 EXPECT_EQ(a.y(), b.y()); \
111 EXPECT_EQ(a.height(), b.height()); 111 EXPECT_EQ(a.width(), b.width()); \
112 EXPECT_EQ(a.height(), b.height()); \
113 } while (false)
112 114
113 class FakeCompositingWebViewClient : public WebViewClient { 115 class FakeCompositingWebViewClient : public WebViewClient {
114 public: 116 public:
115 virtual ~FakeCompositingWebViewClient() 117 virtual ~FakeCompositingWebViewClient()
116 { 118 {
117 } 119 }
118 120
119 virtual void initializeLayerTreeView() OVERRIDE 121 virtual void initializeLayerTreeView() OVERRIDE
120 { 122 {
121 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest)); 123 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest));
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after
5187 TEST_F(WebFrameTest, CreateChildFrameFailure) 5189 TEST_F(WebFrameTest, CreateChildFrameFailure)
5188 { 5190 {
5189 registerMockedHttpURLLoad("create_child_frame_fail.html"); 5191 registerMockedHttpURLLoad("create_child_frame_fail.html");
5190 FailCreateChildFrame client; 5192 FailCreateChildFrame client;
5191 FrameTestHelpers::WebViewHelper webViewHelper; 5193 FrameTestHelpers::WebViewHelper webViewHelper;
5192 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html", true, &client); 5194 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html", true, &client);
5193 5195
5194 EXPECT_EQ(1, client.callCount()); 5196 EXPECT_EQ(1, client.callCount());
5195 } 5197 }
5196 5198
5199 TEST_F(WebFrameTest, heightChangeRepaint)
5200 {
5201 const char* kTests[] = {
5202 "repaint/height-change-no-full-repaint1.html",
5203 "repaint/height-change-no-full-repaint2.html",
5204 "repaint/height-change-no-full-repaint3.html",
5205
5206 // The following tests need full repaint on height change for now,
5207 // but may be optimized not to need full repaint in the future and need
5208 // to be updated.
5209 "repaint/height-change-repaint1.html", // vertical writing mode
5210 "repaint/height-change-repaint2.html", // frameset
5211 "repaint/height-change-repaint3.html", // percentage height
5212 "repaint/height-change-repaint4.html", // positioned percentage height
5213 "repaint/height-change-repaint5.html", // percentage top
5214 "repaint/height-change-repaint6.html", // bottom
5215 "repaint/height-change-repaint7.html", // viewport related media query
5216 "repaint/height-change-repaint8.html", // viewport percentage length
5217 };
5218
5219 UseMockScrollbarSettings mockScrollbarSettings;
5220
5221 FrameTestHelpers::WebViewHelper webViewHelper;
5222 WebViewImpl* webView = webViewHelper.initialize(true);
5223
5224 for (size_t i = 0; i < arraysize(kTests); ++i) {
5225 SCOPED_TRACE(kTests[i]);
5226 registerMockedHttpURLLoad(kTests[i]);
5227 FrameTestHelpers::loadFrame(webView->mainFrame(), m_baseURL + kTests[i]) ;
5228 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
5229
5230 webView->resize(WebSize(200, 200));
5231 webView->layout();
5232
5233 // Change height.
5234 WebCore::FrameView* frameView = webView->mainFrameImpl()->frameView();
5235 frameView->setTracksRepaints(true);
5236 webView->resize(WebSize(200, 300));
5237 webView->layout();
5238 if (strstr(kTests[i], "no-full-repaint"))
5239 EXPECT_EQ_RECT(WebCore::IntRect(0, 200, 200, 100), WebCore::unionRec t(frameView->trackedRepaintRects()));
5240 else
5241 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::unionRect( frameView->trackedRepaintRects()));
5242 frameView->setTracksRepaints(false);
5243
5244 // Change width, ensure optimized logic for height change doesn't break repaint on width change.
5245 frameView->setTracksRepaints(true);
5246 webView->resize(WebSize(300, 300));
5247 webView->layout();
5248 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 300, 300), WebCore::unionRect(fram eView->trackedRepaintRects()));
5249 frameView->setTracksRepaints(false);
5250 }
5251 }
5252
5253 TEST_F(WebFrameTest, heightChangeNoFullRepaintOverflowChange)
5254 {
5255 UseMockScrollbarSettings mockScrollbarSettings;
5256
5257 registerMockedHttpURLLoad("repaint/height-change-no-full-repaint-overflow-ch ange.html");
5258 FrameTestHelpers::WebViewHelper webViewHelper;
5259 webViewHelper.initializeAndLoad(m_baseURL + "repaint/height-change-no-full-r epaint-overflow-change.html");
5260 WebView* webView = webViewHelper.webView();
5261 webView->resize(WebSize(200, 200));
5262 webView->layout();
5263
5264 WebCore::FrameView* frameView = toWebFrameImpl(webView->mainFrame())->frameV iew();
5265 WebCore::RenderView* renderView = frameView->renderView();
5266 EXPECT_TRUE(renderView->hasRenderOverflow());
5267 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), WebCore::enclosingIntRect(r enderView->visualOverflowRect()));
5268 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 250), WebCore::enclosingIntRect(r enderView->layoutOverflowRect()));
5269
5270 frameView->setTracksRepaints(true);
5271 webView->resize(WebSize(200, 300));
5272 webView->layout();
5273 EXPECT_EQ_RECT(WebCore::IntRect(0, 200, 200, 100), WebCore::unionRect(frameV iew->trackedRepaintRects()));
5274 frameView->setTracksRepaints(false);
5275
5276 EXPECT_FALSE(renderView->hasRenderOverflow());
5277 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::enclosingIntRect(r enderView->visualOverflowRect()));
5278 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::enclosingIntRect(r enderView->layoutOverflowRect()));
5279
5280 webView->resize(WebSize(200, 200));
5281 webView->layout();
5282 EXPECT_TRUE(renderView->hasRenderOverflow());
5283 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), WebCore::enclosingIntRect(r enderView->visualOverflowRect()));
5284 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 250), WebCore::enclosingIntRect(r enderView->layoutOverflowRect()));
5285 }
5286
5197 TEST_F(WebFrameTest, fixedPositionInFixedViewport) 5287 TEST_F(WebFrameTest, fixedPositionInFixedViewport)
5198 { 5288 {
5199 UseMockScrollbarSettings mockScrollbarSettings; 5289 UseMockScrollbarSettings mockScrollbarSettings;
5200 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); 5290 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html");
5201 FrameTestHelpers::WebViewHelper webViewHelper; 5291 FrameTestHelpers::WebViewHelper webViewHelper;
5202 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor t.html", true, 0, 0, enableViewportSettings); 5292 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor t.html", true, 0, 0, enableViewportSettings);
5203 5293
5204 WebView* webView = webViewHelper.webView(); 5294 WebView* webView = webViewHelper.webView();
5205 webView->resize(WebSize(100, 100)); 5295 webView->resize(WebSize(100, 100));
5206 webView->layout(); 5296 webView->layout();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5238 webViewHelper.initializeAndLoad("about:blank"); 5328 webViewHelper.initializeAndLoad("about:blank");
5239 5329
5240 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView(); 5330 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView();
5241 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); 5331 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200));
5242 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); 5332 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect());
5243 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); 5333 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200));
5244 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ; 5334 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ;
5245 } 5335 }
5246 5336
5247 } // namespace 5337 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698