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

Side by Side Diff: content/renderer/render_view.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: Created 9 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/renderer/render_view.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>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // current content state during tab closing we use a shorter timeout for the 255 // current content state during tab closing we use a shorter timeout for the
256 // foreground renderer. This means there is a small window of time from which 256 // foreground renderer. This means there is a small window of time from which
257 // content state is modified and not sent to session restore, but this is 257 // content state is modified and not sent to session restore, but this is
258 // better than having to wake up all renderers during shutdown. 258 // better than having to wake up all renderers during shutdown.
259 static const int kDelaySecondsForContentStateSyncHidden = 5; 259 static const int kDelaySecondsForContentStateSyncHidden = 5;
260 static const int kDelaySecondsForContentStateSync = 1; 260 static const int kDelaySecondsForContentStateSync = 1;
261 261
262 // The maximum number of popups that can be spawned from one page. 262 // The maximum number of popups that can be spawned from one page.
263 static const int kMaximumNumberOfUnacknowledgedPopups = 25; 263 static const int kMaximumNumberOfUnacknowledgedPopups = 25;
264 264
265 // The default layout width and height for pages when fixed layout is enabled.
266 static const int kDefaultLayoutWidth = 980;
267 static const int kDefaultLayoutHeight = 640;
268
265 static const float kScalingIncrement = 0.1f; 269 static const float kScalingIncrement = 0.1f;
266 270
267 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 271 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
268 WebVector<WebURL> urls; 272 WebVector<WebURL> urls;
269 ds->redirectChain(urls); 273 ds->redirectChain(urls);
270 result->reserve(urls.size()); 274 result->reserve(urls.size());
271 for (size_t i = 0; i < urls.size(); ++i) 275 for (size_t i = 0; i < urls.size(); ++i)
272 result->push_back(urls[i]); 276 result->push_back(urls[i]);
273 } 277 }
274 278
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 cached_has_main_frame_vertical_scrollbar_(false), 364 cached_has_main_frame_vertical_scrollbar_(false),
361 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 365 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
362 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), 366 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)),
363 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 367 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
364 geolocation_dispatcher_(NULL), 368 geolocation_dispatcher_(NULL),
365 speech_input_dispatcher_(NULL), 369 speech_input_dispatcher_(NULL),
366 device_orientation_dispatcher_(NULL), 370 device_orientation_dispatcher_(NULL),
367 accessibility_ack_pending_(false), 371 accessibility_ack_pending_(false),
368 p2p_socket_dispatcher_(NULL), 372 p2p_socket_dispatcher_(NULL),
369 devtools_agent_(NULL), 373 devtools_agent_(NULL),
374 user_scalable_(true),
375 minimum_scale_(content::kMinPageScaleFactor),
376 maximum_scale_(content::kMaxPageScaleFactor),
370 session_storage_namespace_id_(session_storage_namespace_id), 377 session_storage_namespace_id_(session_storage_namespace_id),
371 handling_select_range_(false) { 378 handling_select_range_(false) {
372 routing_id_ = routing_id; 379 routing_id_ = routing_id;
373 if (opener_id != MSG_ROUTING_NONE) 380 if (opener_id != MSG_ROUTING_NONE)
374 opener_id_ = opener_id; 381 opener_id_ = opener_id;
375 382
376 webwidget_ = WebView::create(this); 383 webwidget_ = WebView::create(this);
377 384
378 if (counter) { 385 if (counter) {
379 shared_popup_counter_ = counter; 386 shared_popup_counter_ = counter;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 // If we end up reusing this WebRequest (for example, due to a #ref click), 1226 // If we end up reusing this WebRequest (for example, due to a #ref click),
1220 // we don't want the transition type to persist. Just clear it. 1227 // we don't want the transition type to persist. Just clear it.
1221 navigation_state->set_transition_type(PageTransition::LINK); 1228 navigation_state->set_transition_type(PageTransition::LINK);
1222 1229
1223 // Check if the navigation was within the same page, in which case we don't 1230 // Check if the navigation was within the same page, in which case we don't
1224 // want to clear the accessibility cache. 1231 // want to clear the accessibility cache.
1225 if (accessibility_.get() && !navigation_state->was_within_same_page()) { 1232 if (accessibility_.get() && !navigation_state->was_within_same_page()) {
1226 accessibility_.reset(); 1233 accessibility_.reset();
1227 pending_accessibility_notifications_.clear(); 1234 pending_accessibility_notifications_.clear();
1228 } 1235 }
1236 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
1237 if (cmd_line->HasSwitch(switches::kEnableFixedLayout)) {
1238 // Only enable fixed layout for normal web content.
1239 GURL frame_url = GURL(request.url());
1240 if (frame_url.SchemeIs(chrome::kHttpScheme) ||
1241 frame_url.SchemeIs(chrome::kHttpsScheme)) {
jamesr 2011/09/02 17:43:09 I really doubt this is the best way to test for we
Fady Samuel 2011/09/08 23:46:39 This is intentional. WebUI is broken with fixed la
jamesr 2011/09/09 00:11:40 Good grief! That is horrible. What is wrong with
1242 webview()->enableFixedLayoutMode(true);
1243 webview()->setFixedLayoutSize(
1244 WebSize(kDefaultLayoutWidth, kDefaultLayoutHeight));
1245 }
1246 }
1229 } 1247 }
1230 1248
1231 // Tell the embedding application that the title of the active page has changed 1249 // Tell the embedding application that the title of the active page has changed
1232 void RenderView::UpdateTitle(WebFrame* frame, 1250 void RenderView::UpdateTitle(WebFrame* frame,
1233 const string16& title, 1251 const string16& title,
1234 WebTextDirection title_direction) { 1252 WebTextDirection title_direction) {
1235 // Ignore all but top level navigations. 1253 // Ignore all but top level navigations.
1236 if (frame->parent()) 1254 if (frame->parent())
1237 return; 1255 return;
1238 1256
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1449
1432 WebExternalPopupMenu* RenderView::createExternalPopupMenu( 1450 WebExternalPopupMenu* RenderView::createExternalPopupMenu(
1433 const WebPopupMenuInfo& popup_menu_info, 1451 const WebPopupMenuInfo& popup_menu_info,
1434 WebExternalPopupMenuClient* popup_menu_client) { 1452 WebExternalPopupMenuClient* popup_menu_client) {
1435 DCHECK(!external_popup_menu_.get()); 1453 DCHECK(!external_popup_menu_.get());
1436 external_popup_menu_.reset( 1454 external_popup_menu_.reset(
1437 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); 1455 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client));
1438 return external_popup_menu_.get(); 1456 return external_popup_menu_.get();
1439 } 1457 }
1440 1458
1459 WebRect RenderView::getDeviceRect() const {
1460 return WebRect(0, 0, size().width(), size().height());
1461 }
1462
1441 RenderWidgetFullscreenPepper* RenderView::CreatePepperFullscreenContainer( 1463 RenderWidgetFullscreenPepper* RenderView::CreatePepperFullscreenContainer(
1442 webkit::ppapi::PluginInstance* plugin) { 1464 webkit::ppapi::PluginInstance* plugin) {
1443 GURL active_url; 1465 GURL active_url;
1444 if (webview() && webview()->mainFrame()) 1466 if (webview() && webview()->mainFrame())
1445 active_url = GURL(webview()->mainFrame()->document().url()); 1467 active_url = GURL(webview()->mainFrame()->document().url());
1446 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( 1468 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create(
1447 routing_id_, render_thread_, plugin, active_url); 1469 routing_id_, render_thread_, plugin, active_url);
1448 widget->show(WebKit::WebNavigationPolicyIgnore); 1470 widget->show(WebKit::WebNavigationPolicyIgnore);
1449 return widget; 1471 return widget;
1450 } 1472 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 page_id_ = next_page_id_++; 2527 page_id_ = next_page_id_++;
2506 2528
2507 // Advance our offset in session history, applying the length limit. There 2529 // Advance our offset in session history, applying the length limit. There
2508 // is now no forward history. 2530 // is now no forward history.
2509 history_list_offset_++; 2531 history_list_offset_++;
2510 if (history_list_offset_ >= content::kMaxSessionHistoryEntries) 2532 if (history_list_offset_ >= content::kMaxSessionHistoryEntries)
2511 history_list_offset_ = content::kMaxSessionHistoryEntries - 1; 2533 history_list_offset_ = content::kMaxSessionHistoryEntries - 1;
2512 history_list_length_ = history_list_offset_ + 1; 2534 history_list_length_ = history_list_offset_ + 1;
2513 history_page_ids_.resize(history_list_length_, -1); 2535 history_page_ids_.resize(history_list_length_, -1);
2514 history_page_ids_[history_list_offset_] = page_id_; 2536 history_page_ids_[history_list_offset_] = page_id_;
2537
2538 // Prepare for initialization to overview when content size becomes
2539 // available.
2540 page_scale_factor_set_ = false;
2515 } else { 2541 } else {
2516 // Inspect the navigation_state on this frame to see if the navigation 2542 // Inspect the navigation_state on this frame to see if the navigation
2517 // corresponds to a session history navigation... Note: |frame| may or 2543 // corresponds to a session history navigation... Note: |frame| may or
2518 // may not be the toplevel frame, but for the case of capturing session 2544 // may not be the toplevel frame, but for the case of capturing session
2519 // history, the first committed frame suffices. We keep track of whether 2545 // history, the first committed frame suffices. We keep track of whether
2520 // we've seen this commit before so that only capture session history once 2546 // we've seen this commit before so that only capture session history once
2521 // per navigation. 2547 // per navigation.
2522 // 2548 //
2523 // Note that we need to check if the page ID changed. In the case of a 2549 // Note that we need to check if the page ID changed. In the case of a
2524 // reload, the page ID doesn't change, and UpdateSessionHistory gets the 2550 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 content::GetContentClient()->renderer()->DidDestroyScriptContext(frame); 2852 content::GetContentClient()->renderer()->DidDestroyScriptContext(frame);
2827 } 2853 }
2828 2854
2829 void RenderView::didCreateIsolatedScriptContext( 2855 void RenderView::didCreateIsolatedScriptContext(
2830 WebFrame* frame, int world_id, v8::Handle<v8::Context> context) { 2856 WebFrame* frame, int world_id, v8::Handle<v8::Context> context) {
2831 content::GetContentClient()->renderer()->DidCreateIsolatedScriptContext( 2857 content::GetContentClient()->renderer()->DidCreateIsolatedScriptContext(
2832 frame, world_id, context); 2858 frame, world_id, context);
2833 } 2859 }
2834 2860
2835 void RenderView::didUpdateLayout(WebFrame* frame) { 2861 void RenderView::didUpdateLayout(WebFrame* frame) {
2862 if (webview() && webview()->isFixedLayoutModeEnabled() &&
2863 webview()->mainFrame() == frame)
2864 TryInitializeScale();
2836 // We don't always want to set up a timer, only if we've been put in that 2865 // We don't always want to set up a timer, only if we've been put in that
2837 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 2866 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2838 // message. 2867 // message.
2839 if (!send_preferred_size_changes_ || !webview()) 2868 if (!send_preferred_size_changes_ || !webview())
2840 return; 2869 return;
2841 2870
2842 if (check_preferred_size_timer_.IsRunning()) 2871 if (check_preferred_size_timer_.IsRunning())
2843 return; 2872 return;
2844 check_preferred_size_timer_.Start(TimeDelta::FromMilliseconds(0), this, 2873 check_preferred_size_timer_.Start(TimeDelta::FromMilliseconds(0), this,
2845 &RenderView::CheckPreferredSize); 2874 &RenderView::CheckPreferredSize);
(...skipping 16 matching lines...) Expand all
2862 size.set_height(static_cast<int>(size.height() * zoom_factor)); 2891 size.set_height(static_cast<int>(size.height() * zoom_factor));
2863 2892
2864 if (size == preferred_size_) 2893 if (size == preferred_size_)
2865 return; 2894 return;
2866 2895
2867 preferred_size_ = size; 2896 preferred_size_ = size;
2868 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, 2897 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_,
2869 preferred_size_)); 2898 preferred_size_));
2870 } 2899 }
2871 2900
2901 gfx::Point RenderView::ClampOffsetAtScale(const gfx::Point& offset,
2902 float scale) {
2903 gfx::Point pt = offset;
2904 float delta_scale = scale / GetPageScaleFactor();
2905 int doc_width = GetContentSize().width() * delta_scale;
2906 int doc_height = GetContentSize().height() * delta_scale;
2907 pt.set_x(std::min(doc_width - size_.width(), pt.x()));
2908 pt.set_y(std::min(doc_height - size_.height(), pt.y()));
2909 pt.set_x(std::max(0, pt.x()));
2910 pt.set_y(std::max(0, pt.y()));
2911 return pt;
2912 }
2913
2914 float RenderView::ComputeOverviewScale(gfx::Size content_size) {
2915 if (content_size.IsEmpty() || size_.IsEmpty())
2916 return 0.0f;
2917 return ComputeScaleWithinLimits(0.0f);
2918 }
2919
2920 float RenderView::ComputeScaleWithinLimits(float scale) {
2921 // TODO(fsamuel): Need to take into account dpi scale.
2922 float min_scale = minimum_scale_;
2923 float max_scale = maximum_scale_;
2924
2925 gfx::Size content_size = GetContentSize();
2926 if (!content_size.IsEmpty() && !size_.IsEmpty()) {
2927 min_scale = std::max(min_scale, (float) size_.width() /
2928 (content_size.width() / GetPageScaleFactor()));
2929 }
2930 return std::min(std::max(scale, min_scale), max_scale);
2931 }
2932
2872 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { 2933 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) {
2873 if (webview()->mainFrame() != frame) 2934 if (webview()->mainFrame() != frame)
2874 return; 2935 return;
2936
2875 WebView* frameView = frame->view(); 2937 WebView* frameView = frame->view();
2876 if (!frameView) 2938 if (!frameView)
2877 return; 2939 return;
2878 2940
2879 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); 2941 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar();
2880 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); 2942 bool has_vertical_scrollbar = frame->hasVerticalScrollbar();
2881 2943
2882 if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || 2944 if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ ||
2883 has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { 2945 has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) {
2884 Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( 2946 Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame(
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 // the selection hasn't actually changed. We don't want to report these 3172 // the selection hasn't actually changed. We don't want to report these
3111 // because it will cause us to continually claim the X clipboard. 3173 // because it will cause us to continually claim the X clipboard.
3112 if (this_selection.Equals(last_selection_)) 3174 if (this_selection.Equals(last_selection_))
3113 return; 3175 return;
3114 last_selection_ = this_selection; 3176 last_selection_ = this_selection;
3115 3177
3116 Send(new ViewHostMsg_SelectionChanged(routing_id_, text, range, 3178 Send(new ViewHostMsg_SelectionChanged(routing_id_, text, range,
3117 start, end)); 3179 start, end));
3118 } 3180 }
3119 3181
3182 bool RenderView::TryInitializeScale() {
3183 // Make the page to fit the new size of the window if it wasn't set by
3184 // the page or user yet.
3185 if (page_scale_factor_set_)
3186 return false;
3187 float overview_scale = ComputeOverviewScale(GetContentSize());
3188 if (overview_scale == 0.0f)
3189 return false;
3190 SetPageScaleFactor(overview_scale);
3191 return true;
3192 }
3193
3194 void RenderView::UpdatePageScale(gfx::Size new_content_size) {
3195 float overview_scale = ComputeOverviewScale(new_content_size);
3196 if (overview_scale == 0.0f)
3197 return;
3198 SetPageScaleFactor(overview_scale);
3199 }
3200
3120 GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url, 3201 GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url,
3121 ErrorPageType error_type) { 3202 ErrorPageType error_type) {
3122 3203
3123 if (failed_url.SchemeIsSecure()) { 3204 if (failed_url.SchemeIsSecure()) {
3124 // If the URL that failed was secure, then the embedding web page was not 3205 // If the URL that failed was secure, then the embedding web page was not
3125 // expecting a network attacker to be able to manipulate its contents. As 3206 // expecting a network attacker to be able to manipulate its contents. As
3126 // we fetch alternate error pages over HTTP, we would be allowing a network 3207 // we fetch alternate error pages over HTTP, we would be allowing a network
3127 // attacker to manipulate the contents of the response if we tried to use 3208 // attacker to manipulate the contents of the response if we tried to use
3128 // the link doctor here. 3209 // the link doctor here.
3129 return GURL(); 3210 return GURL();
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 // navigation occurs, the fetcher will get destroyed. 4002 // navigation occurs, the fetcher will get destroyed.
3922 NavigationState* navigation_state = 4003 NavigationState* navigation_state =
3923 NavigationState::FromDataSource(frame->provisionalDataSource()); 4004 NavigationState::FromDataSource(frame->provisionalDataSource());
3924 navigation_state->set_alt_error_page_fetcher( 4005 navigation_state->set_alt_error_page_fetcher(
3925 new AltErrorPageResourceFetcher( 4006 new AltErrorPageResourceFetcher(
3926 error_page_url, frame, error, 4007 error_page_url, frame, error,
3927 NewCallback(this, &RenderView::AltErrorPageFinished))); 4008 NewCallback(this, &RenderView::AltErrorPageFinished)));
3928 return true; 4009 return true;
3929 } 4010 }
3930 4011
4012 void RenderView::SetPageScaleFactor(float scale) {
4013 scale = ComputeScaleWithinLimits(scale);
4014 SetPageScaleFactorAndScroll(scale,
4015 gfx::Point(GetScrollOffset().x() / GetPageScaleFactor() * scale,
4016 GetScrollOffset().y() / GetPageScaleFactor() * scale));
4017 }
4018
4019 void RenderView::SetPageScaleFactorAndScroll(float scale,
4020 const gfx::Point& offset) {
4021 scale = ComputeScaleWithinLimits(scale);
4022 gfx::Point pt = ClampOffsetAtScale(offset, scale);
4023
4024 if (scale != GetPageScaleFactor() || pt.x() != GetScrollOffset().x() ||
4025 pt.y() != GetScrollOffset().y()) {
4026 webview()->scalePage(scale, WebPoint(pt.x(), pt.y()));
4027 }
4028 page_scale_factor_set_ = true;
4029 }
4030
4031 void RenderView::SetPageScaleFactorWithAnchor(float scale,
4032 const gfx::Point& window_anchor) {
4033 scale = ComputeScaleWithinLimits(scale);
4034 gfx::Point old_offset = GetScrollOffset();
4035 float old_scale = GetPageScaleFactor();
4036 int anchor_x = window_anchor.x();
4037 int anchor_y = window_anchor.y();
4038 SetPageScaleFactorAndScroll(scale,
4039 gfx::Point((anchor_x + old_offset.x()) * scale / old_scale - anchor_x,
4040 (anchor_y + old_offset.y()) * scale / old_scale - anchor_y));
4041 }
4042
3931 void RenderView::AltErrorPageFinished(WebFrame* frame, 4043 void RenderView::AltErrorPageFinished(WebFrame* frame,
3932 const WebURLError& original_error, 4044 const WebURLError& original_error,
3933 const std::string& html) { 4045 const std::string& html) {
3934 // Here, we replace the blank page we loaded previously. 4046 // Here, we replace the blank page we loaded previously.
3935 // If we failed to download the alternate error page, LoadNavigationErrorPage 4047 // If we failed to download the alternate error page, LoadNavigationErrorPage
3936 // will simply display a default error page. 4048 // will simply display a default error page.
3937 LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); 4049 LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true);
3938 } 4050 }
3939 4051
3940 void RenderView::OnMoveOrResizeStarted() { 4052 void RenderView::OnMoveOrResizeStarted() {
3941 if (webview()) 4053 if (webview())
3942 webview()->hidePopups(); 4054 webview()->hidePopups();
3943 } 4055 }
3944 4056
3945 void RenderView::OnResize(const gfx::Size& new_size, 4057 void RenderView::OnResize(const gfx::Size& new_size,
3946 const gfx::Rect& resizer_rect) { 4058 const gfx::Rect& resizer_rect) {
3947 if (webview()) { 4059 if (webview()) {
4060
jam 2011/09/02 17:11:41 ?
3948 webview()->hidePopups(); 4061 webview()->hidePopups();
3949 if (send_preferred_size_changes_) { 4062 if (send_preferred_size_changes_) {
3950 webview()->mainFrame()->setCanHaveScrollbars( 4063 webview()->mainFrame()->setCanHaveScrollbars(
3951 should_display_scrollbars(new_size.width(), new_size.height())); 4064 should_display_scrollbars(new_size.width(), new_size.height()));
3952 } 4065 }
3953 UpdateScrollState(webview()->mainFrame()); 4066 UpdateScrollState(webview()->mainFrame());
3954 } 4067 }
3955 4068
3956 RenderWidget::OnResize(new_size, resizer_rect); 4069 RenderWidget::OnResize(new_size, resizer_rect);
4070 if (webview()) {
4071 // TODO(fsamuel): Need to detect case where the user set pageScaleFactor
4072 // and adjust it appropriately on resize.
4073 if (webview()->isFixedLayoutModeEnabled()) {
4074 UpdatePageScale(new_size);
4075 }
4076 }
3957 } 4077 }
3958 4078
3959 void RenderView::DidInitiatePaint() { 4079 void RenderView::DidInitiatePaint() {
3960 // Notify the pepper plugins that we started painting. 4080 // Notify the pepper plugins that we started painting.
3961 pepper_delegate_.ViewInitiatedPaint(); 4081 pepper_delegate_.ViewInitiatedPaint();
3962 } 4082 }
3963 4083
3964 void RenderView::DidFlushPaint() { 4084 void RenderView::DidFlushPaint() {
3965 // Notify any pepper plugins that we painted. This will call into the plugin, 4085 // Notify any pepper plugins that we painted. This will call into the plugin,
3966 // and we it may ask to close itself as a result. This will, in turn, modify 4086 // and we it may ask to close itself as a result. This will, in turn, modify
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 4128
4009 webkit::ppapi::PluginInstance* RenderView::GetBitmapForOptimizedPluginPaint( 4129 webkit::ppapi::PluginInstance* RenderView::GetBitmapForOptimizedPluginPaint(
4010 const gfx::Rect& paint_bounds, 4130 const gfx::Rect& paint_bounds,
4011 TransportDIB** dib, 4131 TransportDIB** dib,
4012 gfx::Rect* location, 4132 gfx::Rect* location,
4013 gfx::Rect* clip) { 4133 gfx::Rect* clip) {
4014 return pepper_delegate_.GetBitmapForOptimizedPluginPaint( 4134 return pepper_delegate_.GetBitmapForOptimizedPluginPaint(
4015 paint_bounds, dib, location, clip); 4135 paint_bounds, dib, location, clip);
4016 } 4136 }
4017 4137
4138 gfx::Size RenderView::GetContentSize() {
4139 WebKit::WebSize size = webview()->mainFrame()->contentsSize();
4140 return gfx::Size(size.width, size.height);
4141 }
4142
4143 float RenderView::GetPageScaleFactor() {
4144 if (!webview())
4145 return 1.0f;
4146 return webview()->pageScaleFactor();
4147 }
4148
4018 gfx::Point RenderView::GetScrollOffset() { 4149 gfx::Point RenderView::GetScrollOffset() {
4019 WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); 4150 WebSize scroll_offset = webview()->mainFrame()->scrollOffset();
4020 return gfx::Point(scroll_offset.width, scroll_offset.height); 4151 return gfx::Point(scroll_offset.width, scroll_offset.height);
4021 } 4152 }
4022 4153
4023 void RenderView::OnClearFocusedNode() { 4154 void RenderView::OnClearFocusedNode() {
4024 if (webview()) 4155 if (webview())
4025 webview()->clearFocusedNode(); 4156 webview()->clearFocusedNode();
4026 } 4157 }
4027 4158
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
4585 } 4716 }
4586 4717
4587 void RenderView::OnEnableViewSourceMode() { 4718 void RenderView::OnEnableViewSourceMode() {
4588 if (!webview()) 4719 if (!webview())
4589 return; 4720 return;
4590 WebFrame* main_frame = webview()->mainFrame(); 4721 WebFrame* main_frame = webview()->mainFrame();
4591 if (!main_frame) 4722 if (!main_frame)
4592 return; 4723 return;
4593 main_frame->enableViewSourceMode(true); 4724 main_frame->enableViewSourceMode(true);
4594 } 4725 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698