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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 7831028: Compute pageScaleFactor on page so that fixed layout page fits width of window. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed some comments according to rjkroege Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/json/json_value_serializer.h" 16 #include "base/json/json_value_serializer.h"
17 #include "base/json/json_writer.h" 17 #include "base/json/json_writer.h"
18 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/string_piece.h" 22 #include "base/string_piece.h"
23 #include "base/string_number_conversions.h"
23 #include "base/string_split.h" 24 #include "base/string_split.h"
24 #include "base/string_util.h" 25 #include "base/string_util.h"
25 #include "base/sys_string_conversions.h" 26 #include "base/sys_string_conversions.h"
26 #include "base/time.h" 27 #include "base/time.h"
27 #include "base/utf_string_conversions.h" 28 #include "base/utf_string_conversions.h"
28 #include "content/common/appcache/appcache_dispatcher.h" 29 #include "content/common/appcache/appcache_dispatcher.h"
29 #include "content/common/clipboard_messages.h" 30 #include "content/common/clipboard_messages.h"
30 #include "content/common/database_messages.h" 31 #include "content/common/database_messages.h"
31 #include "content/common/drag_messages.h" 32 #include "content/common/drag_messages.h"
32 #include "content/common/file_system/file_system_dispatcher.h" 33 #include "content/common/file_system/file_system_dispatcher.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 renderer_accessibility_ = new RendererAccessibility(this); 521 renderer_accessibility_ = new RendererAccessibility(this);
521 mouse_lock_dispatcher_ = new MouseLockDispatcher(this); 522 mouse_lock_dispatcher_ = new MouseLockDispatcher(this);
522 intents_host_ = new WebIntentsHost(this); 523 intents_host_ = new WebIntentsHost(this);
523 524
524 new IdleUserDetector(this); 525 new IdleUserDetector(this);
525 526
526 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 527 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
527 if (command_line.HasSwitch(switches::kDomAutomationController)) 528 if (command_line.HasSwitch(switches::kDomAutomationController))
528 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; 529 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION;
529 530
531 bool enable_fixed_layout =
532 command_line.HasSwitch(switches::kEnableFixedLayout);
533 webview()->enableFixedLayoutMode(enable_fixed_layout);
534 if (enable_fixed_layout)
535 webview()->settings()->setFixedElementsLayoutRelativeToFrame(true);
536 base::StringToInt(command_line.GetSwitchValueASCII(
537 switches::kDefaultDeviceScaleFactor),
538 &default_device_scale_factor_);
539
530 content::GetContentClient()->renderer()->RenderViewCreated(this); 540 content::GetContentClient()->renderer()->RenderViewCreated(this);
531 } 541 }
532 542
533 RenderViewImpl::~RenderViewImpl() { 543 RenderViewImpl::~RenderViewImpl() {
534 history_page_ids_.clear(); 544 history_page_ids_.clear();
535 545
536 if (decrement_shared_popup_at_destruction_) 546 if (decrement_shared_popup_at_destruction_)
537 shared_popup_counter_->data--; 547 shared_popup_counter_->data--;
538 548
539 // If file chooser is still waiting for answer, dispatch empty answer. 549 // If file chooser is still waiting for answer, dispatch empty answer.
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 } 3380 }
3371 3381
3372 gfx::NativeViewId RenderViewImpl::GetHostWindow() { 3382 gfx::NativeViewId RenderViewImpl::GetHostWindow() {
3373 return host_window(); 3383 return host_window();
3374 } 3384 }
3375 3385
3376 WebPreferences& RenderViewImpl::GetWebkitPreferences() { 3386 WebPreferences& RenderViewImpl::GetWebkitPreferences() {
3377 return webkit_preferences_; 3387 return webkit_preferences_;
3378 } 3388 }
3379 3389
3390 int RenderViewImpl::GetDefaultDeviceScaleFactor() const {
darin (slow to review) 2012/02/17 00:47:41 until we have a consumer for this method, how abou
3391 return default_device_scale_factor_;
3392 }
3393
3380 WebKit::WebView* RenderViewImpl::GetWebView() { 3394 WebKit::WebView* RenderViewImpl::GetWebView() {
3381 return webview(); 3395 return webview();
3382 } 3396 }
3383 3397
3384 WebKit::WebNode RenderViewImpl::GetFocusedNode() const { 3398 WebKit::WebNode RenderViewImpl::GetFocusedNode() const {
3385 if (!webview()) 3399 if (!webview())
3386 return WebNode(); 3400 return WebNode();
3387 WebFrame* focused_frame = webview()->focusedFrame(); 3401 WebFrame* focused_frame = webview()->focusedFrame();
3388 if (focused_frame) { 3402 if (focused_frame) {
3389 WebDocument doc = focused_frame->document(); 3403 WebDocument doc = focused_frame->document();
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 4374
4361 void RenderViewImpl::OnMoveOrResizeStarted() { 4375 void RenderViewImpl::OnMoveOrResizeStarted() {
4362 if (webview()) 4376 if (webview())
4363 webview()->hidePopups(); 4377 webview()->hidePopups();
4364 } 4378 }
4365 4379
4366 void RenderViewImpl::OnResize(const gfx::Size& new_size, 4380 void RenderViewImpl::OnResize(const gfx::Size& new_size,
4367 const gfx::Rect& resizer_rect, 4381 const gfx::Rect& resizer_rect,
4368 bool is_fullscreen) { 4382 bool is_fullscreen) {
4369 if (webview()) { 4383 if (webview()) {
4384 // This setting has no effect if fixed layout is not enabled.
4385 if (default_device_scale_factor_)
4386 webview()->settings()->setLayoutFallbackWidth(
4387 new_size.width() / default_device_scale_factor_);
4370 webview()->hidePopups(); 4388 webview()->hidePopups();
4371 if (send_preferred_size_changes_) { 4389 if (send_preferred_size_changes_) {
4372 webview()->mainFrame()->setCanHaveScrollbars( 4390 webview()->mainFrame()->setCanHaveScrollbars(
4373 ShouldDisplayScrollbars(new_size.width(), new_size.height())); 4391 ShouldDisplayScrollbars(new_size.width(), new_size.height()));
4374 } 4392 }
4375 UpdateScrollState(webview()->mainFrame()); 4393 UpdateScrollState(webview()->mainFrame());
4376 } 4394 }
4377 4395
4378 RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); 4396 RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen);
4379 } 4397 }
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5063 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5046 return !!RenderThreadImpl::current()->compositor_thread(); 5064 return !!RenderThreadImpl::current()->compositor_thread();
5047 } 5065 }
5048 5066
5049 void RenderViewImpl::OnJavaBridgeInit() { 5067 void RenderViewImpl::OnJavaBridgeInit() {
5050 DCHECK(!java_bridge_dispatcher_.get()); 5068 DCHECK(!java_bridge_dispatcher_.get());
5051 #if defined(ENABLE_JAVA_BRIDGE) 5069 #if defined(ENABLE_JAVA_BRIDGE)
5052 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5070 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5053 #endif 5071 #endif
5054 } 5072 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698