| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   396   const WebColor kTranslucentPutty = 0x80BFB196; |   396   const WebColor kTranslucentPutty = 0x80BFB196; | 
|   397   const WebColor kTransparent = 0x00000000; |   397   const WebColor kTransparent = 0x00000000; | 
|   398  |   398  | 
|   399   WebViewBase* web_view = web_view_helper_.Initialize(); |   399   WebViewBase* web_view = web_view_helper_.Initialize(); | 
|   400   EXPECT_EQ(kWhite, web_view->BackgroundColor()); |   400   EXPECT_EQ(kWhite, web_view->BackgroundColor()); | 
|   401  |   401  | 
|   402   web_view->SetBaseBackgroundColor(kBlue); |   402   web_view->SetBaseBackgroundColor(kBlue); | 
|   403   EXPECT_EQ(kBlue, web_view->BackgroundColor()); |   403   EXPECT_EQ(kBlue, web_view->BackgroundColor()); | 
|   404  |   404  | 
|   405   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |   405   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|   406   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |   406   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|   407                                    "<html><head><style>body " |   407                                    "<html><head><style>body " | 
|   408                                    "{background-color:#227788}</style></head></" |   408                                    "{background-color:#227788}</style></head></" | 
|   409                                    "html>", |   409                                    "html>", | 
|   410                                    base_url); |   410                                    base_url); | 
|   411   EXPECT_EQ(kDarkCyan, web_view->BackgroundColor()); |   411   EXPECT_EQ(kDarkCyan, web_view->BackgroundColor()); | 
|   412  |   412  | 
|   413   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |   413   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|   414                                    "<html><head><style>body " |   414                                    "<html><head><style>body " | 
|   415                                    "{background-color:rgba(255,0,0,0.5)}</" |   415                                    "{background-color:rgba(255,0,0,0.5)}</" | 
|   416                                    "style></head></html>", |   416                                    "style></head></html>", | 
|   417                                    base_url); |   417                                    base_url); | 
|   418   // Expected: red (50% alpha) blended atop base of kBlue. |   418   // Expected: red (50% alpha) blended atop base of kBlue. | 
|   419   EXPECT_EQ(0xFF80007F, web_view->BackgroundColor()); |   419   EXPECT_EQ(0xFF80007F, web_view->BackgroundColor()); | 
|   420  |   420  | 
|   421   web_view->SetBaseBackgroundColor(kTranslucentPutty); |   421   web_view->SetBaseBackgroundColor(kTranslucentPutty); | 
|   422   // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. |   422   // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. | 
|   423   EXPECT_EQ(0xBFE93A31, web_view->BackgroundColor()); |   423   EXPECT_EQ(0xBFE93A31, web_view->BackgroundColor()); | 
|   424  |   424  | 
|   425   web_view->SetBaseBackgroundColor(kTransparent); |   425   web_view->SetBaseBackgroundColor(kTransparent); | 
|   426   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |   426   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|   427                                    "<html><head><style>body " |   427                                    "<html><head><style>body " | 
|   428                                    "{background-color:transparent}</style></" |   428                                    "{background-color:transparent}</style></" | 
|   429                                    "head></html>", |   429                                    "head></html>", | 
|   430                                    base_url); |   430                                    base_url); | 
|   431   // Expected: transparent on top of kTransparent will still be transparent. |   431   // Expected: transparent on top of kTransparent will still be transparent. | 
|   432   EXPECT_EQ(kTransparent, web_view->BackgroundColor()); |   432   EXPECT_EQ(kTransparent, web_view->BackgroundColor()); | 
|   433  |   433  | 
|   434   LocalFrame* frame = web_view->MainFrameImpl()->GetFrame(); |   434   LocalFrame* frame = web_view->MainFrameImpl()->GetFrame(); | 
|   435   // The shutdown() calls are a hack to prevent this test |   435   // The shutdown() calls are a hack to prevent this test | 
|   436   // from violating invariants about frame state during navigation/detach. |   436   // from violating invariants about frame state during navigation/detach. | 
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   809   WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); |   809   WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); | 
|   810  |   810  | 
|   811   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |   811   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|   812   // Here, we need to construct a document that has a special property: |   812   // Here, we need to construct a document that has a special property: | 
|   813   // Adding id="foo" to the <path> element will trigger creation of an SVG |   813   // Adding id="foo" to the <path> element will trigger creation of an SVG | 
|   814   // instance tree for the use <use> element. |   814   // instance tree for the use <use> element. | 
|   815   // This is significant, because SVG instance trees are actually created lazily |   815   // This is significant, because SVG instance trees are actually created lazily | 
|   816   // during Document::updateStyleAndLayout code, thus incrementing the DOM tree |   816   // during Document::updateStyleAndLayout code, thus incrementing the DOM tree | 
|   817   // version and freaking out the EphemeralRange (invalidating it). |   817   // version and freaking out the EphemeralRange (invalidating it). | 
|   818   FrameTestHelpers::LoadHTMLString( |   818   FrameTestHelpers::LoadHTMLString( | 
|   819       web_view_impl->MainFrame(), |   819       web_view_impl->MainFrameImpl(), | 
|   820       "<svg height='100%' version='1.1' viewBox='0 0 14 14' width='100%'>" |   820       "<svg height='100%' version='1.1' viewBox='0 0 14 14' width='100%'>" | 
|   821       "<use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#foo'></use>" |   821       "<use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#foo'></use>" | 
|   822       "<path d='M 100 100 L 300 100 L 200 300 z' fill='#000'></path>" |   822       "<path d='M 100 100 L 300 100 L 200 300 z' fill='#000'></path>" | 
|   823       "</svg>" |   823       "</svg>" | 
|   824       "<input>", |   824       "<input>", | 
|   825       base_url); |   825       base_url); | 
|   826   web_view_impl->SetInitialFocus(false); |   826   web_view_impl->SetInitialFocus(false); | 
|   827  |   827  | 
|   828   // Add id="foo" to <path>, thus triggering the condition described above. |   828   // Add id="foo" to <path>, thus triggering the condition described above. | 
|   829   Document* document = |   829   Document* document = | 
| (...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2589   WebViewBase* web_view_impl = web_view_helper.Initialize( |  2589   WebViewBase* web_view_impl = web_view_helper.Initialize( | 
|  2590       true, nullptr, fake_compositing_web_view_client.get(), nullptr, |  2590       true, nullptr, fake_compositing_web_view_client.get(), nullptr, | 
|  2591       &ConfigueCompositingWebView); |  2591       &ConfigueCompositingWebView); | 
|  2592  |  2592  | 
|  2593   int page_width = 640; |  2593   int page_width = 640; | 
|  2594   int page_height = 480; |  2594   int page_height = 480; | 
|  2595   web_view_impl->Resize(WebSize(page_width, page_height)); |  2595   web_view_impl->Resize(WebSize(page_width, page_height)); | 
|  2596  |  2596  | 
|  2597   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  2597   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  2598   FrameTestHelpers::LoadHTMLString( |  2598   FrameTestHelpers::LoadHTMLString( | 
|  2599       web_view_impl->MainFrame(), |  2599       web_view_impl->MainFrameImpl(), | 
|  2600       "<a href='http://www.test.com' style='position: absolute; left: 20px; " |  2600       "<a href='http://www.test.com' style='position: absolute; left: 20px; " | 
|  2601       "top: 20px; width: 200px; transform:translateZ(0);'>A link to " |  2601       "top: 20px; width: 200px; transform:translateZ(0);'>A link to " | 
|  2602       "highlight</a>", |  2602       "highlight</a>", | 
|  2603       base_url); |  2603       base_url); | 
|  2604  |  2604  | 
|  2605   WebGestureEvent event(WebInputEvent::kGestureShowPress, |  2605   WebGestureEvent event(WebInputEvent::kGestureShowPress, | 
|  2606                         WebInputEvent::kNoModifiers, |  2606                         WebInputEvent::kNoModifiers, | 
|  2607                         WebInputEvent::kTimeStampForTesting); |  2607                         WebInputEvent::kTimeStampForTesting); | 
|  2608   event.source_device = kWebGestureDeviceTouchscreen; |  2608   event.source_device = kWebGestureDeviceTouchscreen; | 
|  2609   event.x = 20; |  2609   event.x = 20; | 
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2828   bool did_focus_called_; |  2828   bool did_focus_called_; | 
|  2829 }; |  2829 }; | 
|  2830  |  2830  | 
|  2831 TEST_P(WebViewTest, DoNotFocusCurrentFrameOnNavigateFromLocalFrame) { |  2831 TEST_P(WebViewTest, DoNotFocusCurrentFrameOnNavigateFromLocalFrame) { | 
|  2832   ViewCreatingWebViewClient client; |  2832   ViewCreatingWebViewClient client; | 
|  2833   FrameTestHelpers::WebViewHelper web_view_helper; |  2833   FrameTestHelpers::WebViewHelper web_view_helper; | 
|  2834   WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); |  2834   WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); | 
|  2835  |  2835  | 
|  2836   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  2836   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  2837   FrameTestHelpers::LoadHTMLString( |  2837   FrameTestHelpers::LoadHTMLString( | 
|  2838       web_view_impl->MainFrame(), |  2838       web_view_impl->MainFrameImpl(), | 
|  2839       "<html><body><iframe src=\"about:blank\"></iframe></body></html>", |  2839       "<html><body><iframe src=\"about:blank\"></iframe></body></html>", | 
|  2840       base_url); |  2840       base_url); | 
|  2841  |  2841  | 
|  2842   // Make a request from a local frame. |  2842   // Make a request from a local frame. | 
|  2843   WebURLRequest web_url_request_with_target_start; |  2843   WebURLRequest web_url_request_with_target_start; | 
|  2844   LocalFrame* local_frame = |  2844   LocalFrame* local_frame = | 
|  2845       ToWebLocalFrameBase(web_view_impl->MainFrame()->FirstChild())->GetFrame(); |  2845       ToWebLocalFrameBase(web_view_impl->MainFrame()->FirstChild())->GetFrame(); | 
|  2846   FrameLoadRequest request_with_target_start( |  2846   FrameLoadRequest request_with_target_start( | 
|  2847       local_frame->GetDocument(), |  2847       local_frame->GetDocument(), | 
|  2848       web_url_request_with_target_start.ToResourceRequest(), "_top"); |  2848       web_url_request_with_target_start.ToResourceRequest(), "_top"); | 
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4176   // visibleContentRect doesn't change. |  4176   // visibleContentRect doesn't change. | 
|  4177   EXPECT_EQ(IntRect(50, 55, 50, 75), |  4177   EXPECT_EQ(IntRect(50, 55, 50, 75), | 
|  4178             *dev_tools_emulator->VisibleContentRectForPainting()); |  4178             *dev_tools_emulator->VisibleContentRectForPainting()); | 
|  4179 } |  4179 } | 
|  4180  |  4180  | 
|  4181 TEST_P(WebViewTest, ResizeForPrintingViewportUnits) { |  4181 TEST_P(WebViewTest, ResizeForPrintingViewportUnits) { | 
|  4182   WebViewBase* web_view = web_view_helper_.Initialize(); |  4182   WebViewBase* web_view = web_view_helper_.Initialize(); | 
|  4183   web_view->Resize(WebSize(800, 600)); |  4183   web_view->Resize(WebSize(800, 600)); | 
|  4184  |  4184  | 
|  4185   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  4185   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  4186   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |  4186   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|  4187                                    "<style>" |  4187                                    "<style>" | 
|  4188                                    "  body { margin: 0px; }" |  4188                                    "  body { margin: 0px; }" | 
|  4189                                    "  #vw { width: 100vw; height: 100vh; }" |  4189                                    "  #vw { width: 100vw; height: 100vh; }" | 
|  4190                                    "</style>" |  4190                                    "</style>" | 
|  4191                                    "<div id=vw></div>", |  4191                                    "<div id=vw></div>", | 
|  4192                                    base_url); |  4192                                    base_url); | 
|  4193  |  4193  | 
|  4194   WebLocalFrameBase* frame = web_view->MainFrameImpl(); |  4194   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
|  4195   Document* document = frame->GetFrame()->GetDocument(); |  4195   Document* document = frame->GetFrame()->GetDocument(); | 
|  4196   Element* vw_element = document->getElementById("vw"); |  4196   Element* vw_element = document->getElementById("vw"); | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|  4220  |  4220  | 
|  4221   EXPECT_EQ(800, vw_element->OffsetWidth()); |  4221   EXPECT_EQ(800, vw_element->OffsetWidth()); | 
|  4222 } |  4222 } | 
|  4223  |  4223  | 
|  4224 TEST_P(WebViewTest, WidthMediaQueryWithPageZoomAfterPrinting) { |  4224 TEST_P(WebViewTest, WidthMediaQueryWithPageZoomAfterPrinting) { | 
|  4225   WebViewBase* web_view = web_view_helper_.Initialize(); |  4225   WebViewBase* web_view = web_view_helper_.Initialize(); | 
|  4226   web_view->Resize(WebSize(800, 600)); |  4226   web_view->Resize(WebSize(800, 600)); | 
|  4227   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); |  4227   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); | 
|  4228  |  4228  | 
|  4229   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  4229   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  4230   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |  4230   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|  4231                                    "<style>" |  4231                                    "<style>" | 
|  4232                                    "  @media (max-width: 600px) {" |  4232                                    "  @media (max-width: 600px) {" | 
|  4233                                    "    div { color: green }" |  4233                                    "    div { color: green }" | 
|  4234                                    "  }" |  4234                                    "  }" | 
|  4235                                    "</style>" |  4235                                    "</style>" | 
|  4236                                    "<div id=d></div>", |  4236                                    "<div id=d></div>", | 
|  4237                                    base_url); |  4237                                    base_url); | 
|  4238  |  4238  | 
|  4239   WebLocalFrameBase* frame = web_view->MainFrameImpl(); |  4239   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
|  4240   Document* document = frame->GetFrame()->GetDocument(); |  4240   Document* document = frame->GetFrame()->GetDocument(); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  4255   EXPECT_EQ(MakeRGB(0, 128, 0), |  4255   EXPECT_EQ(MakeRGB(0, 128, 0), | 
|  4256             div->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor)); |  4256             div->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor)); | 
|  4257 } |  4257 } | 
|  4258  |  4258  | 
|  4259 TEST_P(WebViewTest, ViewportUnitsPrintingWithPageZoom) { |  4259 TEST_P(WebViewTest, ViewportUnitsPrintingWithPageZoom) { | 
|  4260   WebViewBase* web_view = web_view_helper_.Initialize(); |  4260   WebViewBase* web_view = web_view_helper_.Initialize(); | 
|  4261   web_view->Resize(WebSize(800, 600)); |  4261   web_view->Resize(WebSize(800, 600)); | 
|  4262   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); |  4262   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); | 
|  4263  |  4263  | 
|  4264   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  4264   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  4265   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |  4265   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|  4266                                    "<style>" |  4266                                    "<style>" | 
|  4267                                    "  body { margin: 0 }" |  4267                                    "  body { margin: 0 }" | 
|  4268                                    "  #t1 { width: 100% }" |  4268                                    "  #t1 { width: 100% }" | 
|  4269                                    "  #t2 { width: 100vw }" |  4269                                    "  #t2 { width: 100vw }" | 
|  4270                                    "</style>" |  4270                                    "</style>" | 
|  4271                                    "<div id=t1></div>" |  4271                                    "<div id=t1></div>" | 
|  4272                                    "<div id=t2></div>", |  4272                                    "<div id=t2></div>", | 
|  4273                                    base_url); |  4273                                    base_url); | 
|  4274  |  4274  | 
|  4275   WebLocalFrameBase* frame = web_view->MainFrameImpl(); |  4275   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  4293   EXPECT_EQ(expected_width, t2->OffsetWidth()); |  4293   EXPECT_EQ(expected_width, t2->OffsetWidth()); | 
|  4294  |  4294  | 
|  4295   frame->PrintEnd(); |  4295   frame->PrintEnd(); | 
|  4296 } |  4296 } | 
|  4297  |  4297  | 
|  4298 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { |  4298 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { | 
|  4299   WebViewBase* web_view = web_view_helper_.Initialize(); |  4299   WebViewBase* web_view = web_view_helper_.Initialize(); | 
|  4300   web_view->Resize(WebSize(800, 600)); |  4300   web_view->Resize(WebSize(800, 600)); | 
|  4301  |  4301  | 
|  4302   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |  4302   WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 
|  4303   FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |  4303   FrameTestHelpers::LoadHTMLString(web_view->MainFrameImpl(), | 
|  4304                                    "<!doctype html>" |  4304                                    "<!doctype html>" | 
|  4305                                    "<meta name='viewport'" |  4305                                    "<meta name='viewport'" | 
|  4306                                    "    content='width=device-width'>" |  4306                                    "    content='width=device-width'>" | 
|  4307                                    "<style>" |  4307                                    "<style>" | 
|  4308                                    "  body {margin: 0px; height:3000px;}" |  4308                                    "  body {margin: 0px; height:3000px;}" | 
|  4309                                    "</style>", |  4309                                    "</style>", | 
|  4310                                    base_url); |  4310                                    base_url); | 
|  4311  |  4311  | 
|  4312   WebLocalFrameBase* frame = web_view->MainFrameImpl(); |  4312   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
|  4313   auto* frame_view = frame->GetFrameView(); |  4313   auto* frame_view = frame->GetFrameView(); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|  4338   EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |  4338   EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 
|  4339   if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |  4339   if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 
|  4340     EXPECT_NE(nullptr, |  4340     EXPECT_NE(nullptr, | 
|  4341               frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |  4341               frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 
|  4342   } else { |  4342   } else { | 
|  4343     EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |  4343     EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 
|  4344   } |  4344   } | 
|  4345 } |  4345 } | 
|  4346  |  4346  | 
|  4347 }  // namespace blink |  4347 }  // namespace blink | 
| OLD | NEW |