| 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/dom/ClientRect.h" |
| 5 #include "core/dom/Document.h" | 6 #include "core/dom/Document.h" |
| 6 #include "core/dom/FrameRequestCallback.h" | 7 #include "core/dom/FrameRequestCallback.h" |
| 7 #include "core/html/HTMLIFrameElement.h" | 8 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "core/layout/api/LayoutViewItem.h" | 9 #include "core/layout/api/LayoutViewItem.h" |
| 9 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "web/tests/sim/SimCompositor.h" | 12 #include "web/tests/sim/SimCompositor.h" |
| 12 #include "web/tests/sim/SimDisplayItemList.h" | 13 #include "web/tests/sim/SimDisplayItemList.h" |
| 13 #include "web/tests/sim/SimRequest.h" | 14 #include "web/tests/sim/SimRequest.h" |
| 14 #include "web/tests/sim/SimTest.h" | 15 #include "web/tests/sim/SimTest.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 374 |
| 374 // Finish loading the CSS resource (no change to painting). | 375 // Finish loading the CSS resource (no change to painting). |
| 375 cssBodyResource.complete("a { color: red; }"); | 376 cssBodyResource.complete("a { color: red; }"); |
| 376 EXPECT_TRUE(document().isRenderingReady()); | 377 EXPECT_TRUE(document().isRenderingReady()); |
| 377 | 378 |
| 378 // Finish the load, painting should stay enabled. | 379 // Finish the load, painting should stay enabled. |
| 379 mainResource.finish(); | 380 mainResource.finish(); |
| 380 EXPECT_TRUE(document().isRenderingReady()); | 381 EXPECT_TRUE(document().isRenderingReady()); |
| 381 } | 382 } |
| 382 | 383 |
| 384 TEST_F(DocumentLoadingRenderingTest, |
| 385 returnBoundingClientRectCorrectlyWhileLoadingImport) { |
| 386 SimRequest mainResource("https://example.com/test.html", "text/html"); |
| 387 SimRequest importResource("https://example.com/import.css", "text/css"); |
| 388 |
| 389 loadURL("https://example.com/test.html"); |
| 390 |
| 391 webView().resize(WebSize(800, 600)); |
| 392 |
| 393 mainResource.start(); |
| 394 |
| 395 mainResource.write( |
| 396 "<html><body>" |
| 397 " <div id='test' style='font-size: 16px'>test</div>" |
| 398 " <script>" |
| 399 " var link = document.createElement('link');" |
| 400 " link.rel = 'import';" |
| 401 " link.href = 'import.css';" |
| 402 " document.head.appendChild(link);" |
| 403 " </script>"); |
| 404 importResource.start(); |
| 405 |
| 406 // Import loader isn't finish, shoudn't paint. |
| 407 EXPECT_FALSE(document().isRenderingReady()); |
| 408 |
| 409 // If ignoringPendingStylesheets==true, element should get non-empty rect. |
| 410 Element* element = document().getElementById("test"); |
| 411 ClientRect* rect = element->getBoundingClientRect(); |
| 412 EXPECT_TRUE(rect->width() > 0.f); |
| 413 EXPECT_TRUE(rect->height() > 0.f); |
| 414 |
| 415 // After reset ignoringPendingStylesheets, we should block rendering again. |
| 416 EXPECT_FALSE(document().isRenderingReady()); |
| 417 |
| 418 importResource.write("div { color: red; }"); |
| 419 importResource.finish(); |
| 420 mainResource.finish(); |
| 421 } |
| 422 |
| 383 } // namespace blink | 423 } // namespace blink |
| OLD | NEW |