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

Unified Diff: chrome/renderer/chrome_render_view_observer.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: Removed unnecsssary changes in build/common.gypi Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/common.gypi ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_render_view_observer.cc
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index 55b3ddad597430a0fecc7289d7e2a316f4912cdc..360fc5518779227003505579357db58eaf6986ac 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -22,6 +22,7 @@
#include "chrome/renderer/chrome_render_process_observer.h"
#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/extensions/extension_dispatcher.h"
+#include "chrome/renderer/extensions/extension_helper.h"
#include "chrome/renderer/external_host_bindings.h"
#include "chrome/renderer/frame_sniffer.h"
#include "chrome/renderer/prerender/prerender_helper.h"
@@ -29,6 +30,7 @@
#include "chrome/renderer/translate_helper.h"
#include "chrome/renderer/webview_color_overlay.h"
#include "content/public/common/bindings_policy.h"
+#include "content/public/common/view_type.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/content_renderer_client.h"
#include "net/base/data_url.h"
@@ -93,6 +95,10 @@ static const size_t kMaxIndexChars = 65535;
static const int kThumbnailWidth = 212;
static const int kThumbnailHeight = 132;
+// The default layout width for pages when fixed layout is enabled.
+static const int kDefaultLayoutWidth = 980;
+static const int kDefaultLayoutHeight = 640;
+
// Constants for UMA statistic collection.
static const char kWWWDotGoogleDotCom[] = "www.google.com";
static const char kMailDotGoogleDotCom[] = "mail.google.com";
@@ -372,6 +378,27 @@ void ChromeRenderViewObserver::OnSetAsInterstitial() {
}
void ChromeRenderViewObserver::Navigate(const GURL& url) {
+ ExtensionHelper* extension_helper = ExtensionHelper::Get(render_view());
Aaron Boodman 2012/01/20 18:49:23 What are you trying to do here? It looks to me lik
+ bool is_tab_contents = extension_helper &&
+ extension_helper->view_type() == content::VIEW_TYPE_TAB_CONTENTS;
darin (slow to review) 2012/01/20 19:10:20 it seems a little hacky to be using something from
Fady Samuel 2012/01/20 21:05:04 I don't know what the answer to that question is..
jam 2012/01/20 21:08:05 code in the renderer doesn't generally know about
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ // Only use fixed layout on tab contents.
+ if (is_tab_contents && cmd_line->HasSwitch(switches::kEnableFixedLayout)) {
+ WebSize viewSize = render_view()->GetWebView()->size();
darin (slow to review) 2012/01/20 19:10:20 nit: view_size
Fady Samuel 2012/01/20 21:05:04 Done.
+ int layoutHeight =
darin (slow to review) 2012/01/20 19:10:20 nit: layout_height
Fady Samuel 2012/01/20 21:05:04 Done.
+ viewSize.height ?
+ viewSize.height * kDefaultLayoutWidth / viewSize.width :
+ kDefaultLayoutHeight;
+ WebSize layout_size(kDefaultLayoutWidth, layoutHeight);
+ render_view()->GetWebView()->enableFixedLayoutMode(true);
+ render_view()->GetWebView()->setFixedLayoutSize(layout_size);
+ render_view()->GetWebView()->
+ setShouldLayoutFixedElementsRelativeToFrame(true);
darin (slow to review) 2012/01/20 19:10:20 isn't this done through WebSettings now?
Fady Samuel 2012/01/20 21:05:04 Patch hasn't landed yet. Will fix now. But once i
+ } else {
+ render_view()->GetWebView()->enableFixedLayoutMode(false);
+ render_view()->GetWebView()->
+ setShouldLayoutFixedElementsRelativeToFrame(false);
+ }
// Execute cache clear operations that were postponed until a navigation
// event (including tab reload).
if (chrome_render_process_observer_)
« no previous file with comments | « build/common.gypi ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698