| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 void set_wcv_resize_insets(const gfx::Size& wcv_resize_insets) { | 276 void set_wcv_resize_insets(const gfx::Size& wcv_resize_insets) { |
| 277 wcv_resize_insets_ = wcv_resize_insets; | 277 wcv_resize_insets_ = wcv_resize_insets; |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Cache the size when RenderViewHost is first created. | 280 // Cache the size when RenderViewHost is first created. |
| 281 void RenderViewCreated(content::RenderViewHost* render_view_host) override { | 281 void RenderViewCreated(content::RenderViewHost* render_view_host) override { |
| 282 render_view_sizes_[render_view_host].rwhv_create_size = | 282 render_view_sizes_[render_view_host].rwhv_create_size = |
| 283 render_view_host->GetWidget()->GetView()->GetViewBounds().size(); | 283 render_view_host->GetWidget()->GetView()->GetViewBounds().size(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void DidStartNavigationToPendingEntry( |
| 287 const GURL& url, |
| 288 content::ReloadType reload_type) override { |
| 289 // TODO: remove this method when PlzNavigate is turned on by default. |
| 290 if (!content::IsBrowserSideNavigationEnabled()) |
| 291 Resize(); |
| 292 } |
| 293 |
| 286 // Enlarge WebContentsView by |wcv_resize_insets_| while the navigation entry | 294 // Enlarge WebContentsView by |wcv_resize_insets_| while the navigation entry |
| 287 // is pending. | 295 // is pending. |
| 288 void DidStartNavigationToPendingEntry( | 296 void DidStartNavigation( |
| 289 const GURL& url, | 297 content::NavigationHandle* navigation_handle) override { |
| 290 content::ReloadType reload_type) override { | 298 if (content::IsBrowserSideNavigationEnabled()) |
| 299 Resize(); |
| 300 } |
| 301 |
| 302 void Resize() { |
| 291 if (wcv_resize_insets_.IsEmpty()) | 303 if (wcv_resize_insets_.IsEmpty()) |
| 292 return; | 304 return; |
| 293 // Resizing the main browser window by |wcv_resize_insets_| will | 305 // Resizing the main browser window by |wcv_resize_insets_| will |
| 294 // automatically resize the WebContentsView by the same amount. | 306 // automatically resize the WebContentsView by the same amount. |
| 295 // Just resizing WebContentsView directly doesn't work on Linux, because the | 307 // Just resizing WebContentsView directly doesn't work on Linux, because the |
| 296 // next automatic layout of the browser window will resize WebContentsView | 308 // next automatic layout of the browser window will resize WebContentsView |
| 297 // back to the previous size. To make it consistent, resize main browser | 309 // back to the previous size. To make it consistent, resize main browser |
| 298 // window on all platforms. | 310 // window on all platforms. |
| 299 gfx::Rect bounds(browser_window_->GetBounds()); | 311 gfx::Rect bounds(browser_window_->GetBounds()); |
| 300 gfx::Size size(bounds.size()); | 312 gfx::Size size(bounds.size()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 320 private: | 332 private: |
| 321 struct Sizes { | 333 struct Sizes { |
| 322 gfx::Size rwhv_create_size; // Size of RenderWidgetHostView when created. | 334 gfx::Size rwhv_create_size; // Size of RenderWidgetHostView when created. |
| 323 gfx::Size rwhv_commit_size; // Size of RenderWidgetHostView when committed. | 335 gfx::Size rwhv_commit_size; // Size of RenderWidgetHostView when committed. |
| 324 gfx::Size wcv_commit_size; // Size of WebContentsView when committed. | 336 gfx::Size wcv_commit_size; // Size of WebContentsView when committed. |
| 325 }; | 337 }; |
| 326 | 338 |
| 327 typedef std::map<content::RenderViewHost*, Sizes> RenderViewSizes; | 339 typedef std::map<content::RenderViewHost*, Sizes> RenderViewSizes; |
| 328 RenderViewSizes render_view_sizes_; | 340 RenderViewSizes render_view_sizes_; |
| 329 // Enlarge WebContentsView by this size insets in | 341 // Enlarge WebContentsView by this size insets in |
| 330 // DidStartNavigationToPendingEntry. | 342 // DidStartNavigation. |
| 331 gfx::Size wcv_resize_insets_; | 343 gfx::Size wcv_resize_insets_; |
| 332 BrowserWindow* browser_window_; // Weak ptr. | 344 BrowserWindow* browser_window_; // Weak ptr. |
| 333 | 345 |
| 334 DISALLOW_COPY_AND_ASSIGN(RenderViewSizeObserver); | 346 DISALLOW_COPY_AND_ASSIGN(RenderViewSizeObserver); |
| 335 }; | 347 }; |
| 336 | 348 |
| 337 // Waits for a failed commit notification. | 349 // Waits for a failed commit notification. |
| 338 class FailedCommitWatcher : public content::WebContentsObserver { | 350 class FailedCommitWatcher : public content::WebContentsObserver { |
| 339 public: | 351 public: |
| 340 explicit FailedCommitWatcher(content::WebContents* wc) | 352 explicit FailedCommitWatcher(content::WebContents* wc) |
| (...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 Browser* browser = new Browser(params); | 2904 Browser* browser = new Browser(params); |
| 2893 gfx::Rect bounds = browser->window()->GetBounds(); | 2905 gfx::Rect bounds = browser->window()->GetBounds(); |
| 2894 | 2906 |
| 2895 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 2907 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
| 2896 // See https://crbug.com/567925. | 2908 // See https://crbug.com/567925. |
| 2897 EXPECT_GE(bounds.width(), 100); | 2909 EXPECT_GE(bounds.width(), 100); |
| 2898 EXPECT_EQ(122, bounds.height()); | 2910 EXPECT_EQ(122, bounds.height()); |
| 2899 browser->window()->Close(); | 2911 browser->window()->Close(); |
| 2900 } | 2912 } |
| 2901 } | 2913 } |
| OLD | NEW |