OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // Set canvas background to red with alpha. | 486 // Set canvas background to red with alpha. |
487 SkBitmap bitmap; | 487 SkBitmap bitmap; |
488 bitmap.allocN32Pixels(kWidth, kHeight); | 488 bitmap.allocN32Pixels(kWidth, kHeight); |
489 SkCanvas canvas(bitmap); | 489 SkCanvas canvas(bitmap); |
490 canvas.clear(kAlphaRed); | 490 canvas.clear(kAlphaRed); |
491 | 491 |
492 PaintRecordBuilder builder(FloatRect(0, 0, kWidth, kHeight)); | 492 PaintRecordBuilder builder(FloatRect(0, 0, kWidth, kHeight)); |
493 | 493 |
494 // Paint the root of the main frame in the way that CompositedLayerMapping | 494 // Paint the root of the main frame in the way that CompositedLayerMapping |
495 // would. | 495 // would. |
496 LocalFrameView* view = | 496 LocalFrameView* view = web_view_helper_.LocalMainFrame()->GetFrameView(); |
497 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); | |
498 PaintLayer* root_layer = view->GetLayoutViewItem().Layer(); | 497 PaintLayer* root_layer = view->GetLayoutViewItem().Layer(); |
499 LayoutRect paint_rect(0, 0, kWidth, kHeight); | 498 LayoutRect paint_rect(0, 0, kWidth, kHeight); |
500 PaintLayerPaintingInfo painting_info(root_layer, paint_rect, | 499 PaintLayerPaintingInfo painting_info(root_layer, paint_rect, |
501 kGlobalPaintNormalPhase, LayoutSize()); | 500 kGlobalPaintNormalPhase, LayoutSize()); |
502 PaintLayerPainter(*root_layer) | 501 PaintLayerPainter(*root_layer) |
503 .PaintLayerContents(builder.Context(), painting_info, | 502 .PaintLayerContents(builder.Context(), painting_info, |
504 kPaintLayerPaintingCompositingAllPhases); | 503 kPaintLayerPaintingCompositingAllPhases); |
505 builder.EndRecording()->Playback(&canvas); | 504 builder.EndRecording()->Playback(&canvas); |
506 | 505 |
507 // The result should be a blend of red and green. | 506 // The result should be a blend of red and green. |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 | 2003 |
2005 web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event)); | 2004 web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event)); |
2006 RunPendingTasks(); | 2005 RunPendingTasks(); |
2007 return true; | 2006 return true; |
2008 } | 2007 } |
2009 | 2008 |
2010 bool WebViewTest::TapElementById(WebInputEvent::Type type, | 2009 bool WebViewTest::TapElementById(WebInputEvent::Type type, |
2011 const WebString& id) { | 2010 const WebString& id) { |
2012 DCHECK(web_view_helper_.WebView()); | 2011 DCHECK(web_view_helper_.WebView()); |
2013 Element* element = static_cast<Element*>( | 2012 Element* element = static_cast<Element*>( |
2014 web_view_helper_.WebView()->MainFrameImpl()->GetDocument().GetElementById( | 2013 web_view_helper_.LocalMainFrame()->GetDocument().GetElementById(id)); |
2015 id)); | |
2016 return TapElement(type, element); | 2014 return TapElement(type, element); |
2017 } | 2015 } |
2018 | 2016 |
2019 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) { | 2017 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) { |
2020 // The expected layout size comes from the calculation done in | 2018 // The expected layout size comes from the calculation done in |
2021 // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to | 2019 // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to |
2022 // scale the page size. | 2020 // scale the page size. |
2023 const float ratio = page_size.Height() / (float)page_size.Width(); | 2021 const float ratio = page_size.Height() / (float)page_size.Width(); |
2024 const int icb_width = | 2022 const int icb_width = |
2025 floor(page_size.Width() * PrintContext::kPrintingMinimumShrinkFactor); | 2023 floor(page_size.Width() * PrintContext::kPrintingMinimumShrinkFactor); |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3185 &frame_client); | 3183 &frame_client); |
3186 web_view_helper_.Reset(); | 3184 web_view_helper_.Reset(); |
3187 EXPECT_EQ(0, frame_client.Count()); | 3185 EXPECT_EQ(0, frame_client.Count()); |
3188 } | 3186 } |
3189 | 3187 |
3190 TEST_P(WebViewTest, AddFrameInCloseURLUnload) { | 3188 TEST_P(WebViewTest, AddFrameInCloseURLUnload) { |
3191 CreateChildCounterFrameClient frame_client; | 3189 CreateChildCounterFrameClient frame_client; |
3192 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3190 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3193 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", | 3191 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", |
3194 &frame_client); | 3192 &frame_client); |
3195 web_view_helper_.WebView()->MainFrameImpl()->DispatchUnloadEvent(); | 3193 web_view_helper_.LocalMainFrame()->DispatchUnloadEvent(); |
3196 EXPECT_EQ(0, frame_client.Count()); | 3194 EXPECT_EQ(0, frame_client.Count()); |
3197 web_view_helper_.Reset(); | 3195 web_view_helper_.Reset(); |
3198 } | 3196 } |
3199 | 3197 |
3200 TEST_P(WebViewTest, AddFrameInNavigateUnload) { | 3198 TEST_P(WebViewTest, AddFrameInNavigateUnload) { |
3201 CreateChildCounterFrameClient frame_client; | 3199 CreateChildCounterFrameClient frame_client; |
3202 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3200 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3203 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", | 3201 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", |
3204 &frame_client); | 3202 &frame_client); |
3205 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), | 3203 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 } | 3547 } |
3550 | 3548 |
3551 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { | 3549 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { |
3552 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); | 3550 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); |
3553 WebViewBase* web_view = web_view_helper_.Initialize(); | 3551 WebViewBase* web_view = web_view_helper_.Initialize(); |
3554 | 3552 |
3555 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); | 3553 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); |
3556 LoadFrame(web_view->MainFrameImpl(), url); | 3554 LoadFrame(web_view->MainFrameImpl(), url); |
3557 | 3555 |
3558 LocalFrameView* frame_view = | 3556 LocalFrameView* frame_view = |
3559 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); | 3557 web_view_helper_.LocalMainFrame()->GetFrameView(); |
3560 | 3558 |
3561 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. | 3559 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. |
3562 // This EXPECT is merely a dummy. The real test is that we don't trigger | 3560 // This EXPECT is merely a dummy. The real test is that we don't trigger |
3563 // asserts in debug builds. | 3561 // asserts in debug builds. |
3564 EXPECT_FALSE(frame_view->NeedsLayout()); | 3562 EXPECT_FALSE(frame_view->NeedsLayout()); |
3565 }; | 3563 }; |
3566 | 3564 |
3567 TEST_P(WebViewTest, PreferredSize) { | 3565 TEST_P(WebViewTest, PreferredSize) { |
3568 std::string url = base_url_ + "specify_size.html?100px:100px"; | 3566 std::string url = base_url_ + "specify_size.html?100px:100px"; |
3569 URLTestHelpers::RegisterMockedURLLoad( | 3567 URLTestHelpers::RegisterMockedURLLoad( |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3953 } | 3951 } |
3954 | 3952 |
3955 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe | 3953 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe |
3956 // unloads. crbug.com/635029. | 3954 // unloads. crbug.com/635029. |
3957 TEST_P(WebViewTest, SubframeBeforeUnloadUseCounter) { | 3955 TEST_P(WebViewTest, SubframeBeforeUnloadUseCounter) { |
3958 RegisterMockedHttpURLLoad("visible_iframe.html"); | 3956 RegisterMockedHttpURLLoad("visible_iframe.html"); |
3959 RegisterMockedHttpURLLoad("single_iframe.html"); | 3957 RegisterMockedHttpURLLoad("single_iframe.html"); |
3960 WebViewBase* web_view = | 3958 WebViewBase* web_view = |
3961 web_view_helper_.InitializeAndLoad(base_url_ + "single_iframe.html"); | 3959 web_view_helper_.InitializeAndLoad(base_url_ + "single_iframe.html"); |
3962 | 3960 |
3963 WebLocalFrame* frame = web_view_helper_.WebView()->MainFrameImpl(); | 3961 WebLocalFrame* frame = web_view_helper_.LocalMainFrame(); |
3964 Document* document = | 3962 Document* document = |
3965 ToLocalFrame(web_view_helper_.WebView()->GetPage()->MainFrame()) | 3963 ToLocalFrame(web_view_helper_.WebView()->GetPage()->MainFrame()) |
3966 ->GetDocument(); | 3964 ->GetDocument(); |
3967 | 3965 |
3968 // Add a beforeunload handler in the main frame. Make sure firing | 3966 // Add a beforeunload handler in the main frame. Make sure firing |
3969 // beforeunload doesn't increment the subframe use counter. | 3967 // beforeunload doesn't increment the subframe use counter. |
3970 { | 3968 { |
3971 frame->ExecuteScript( | 3969 frame->ExecuteScript( |
3972 WebScriptSource("addEventListener('beforeunload', function() {});")); | 3970 WebScriptSource("addEventListener('beforeunload', function() {});")); |
3973 web_view->MainFrame()->ToWebLocalFrame()->DispatchBeforeUnloadEvent(false); | 3971 web_view->MainFrame()->ToWebLocalFrame()->DispatchBeforeUnloadEvent(false); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4338 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4336 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
4339 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4337 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { |
4340 EXPECT_NE(nullptr, | 4338 EXPECT_NE(nullptr, |
4341 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4339 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
4342 } else { | 4340 } else { |
4343 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4341 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
4344 } | 4342 } |
4345 } | 4343 } |
4346 | 4344 |
4347 } // namespace blink | 4345 } // namespace blink |
OLD | NEW |