summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 19:48:08 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 19:48:08 +0000
commit0666aef37e02188ef4b4c8890c08c5665970d54e (patch)
treeecc6f3d21eccb33040849c37d15b28a8d65f8fa1 /chrome/renderer
parent0582493ed8a6aa530c16acffb2cf2bae4bfd955f (diff)
downloadchromium_src-0666aef37e02188ef4b4c8890c08c5665970d54e.zip
chromium_src-0666aef37e02188ef4b4c8890c08c5665970d54e.tar.gz
chromium_src-0666aef37e02188ef4b4c8890c08c5665970d54e.tar.bz2
Propagate intrinsic width notification over IPC in all cases (not just extensions) to the TabContentsView. Enable the zoom button on Mac to utilize it. Ensure we only send the IPC notification when the value changes, as WebCore tends to over-report that it has changed. Fix const-ness in delegate API where it's not necessary.
Review URL: http://codereview.chromium.org/115138 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc32
-rw-r--r--chrome/renderer/render_view.h8
2 files changed, 33 insertions, 7 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e4669ca..a38a710 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -200,7 +200,9 @@ RenderView::RenderView(RenderThreadBase* render_thread)
decrement_shared_popup_at_destruction_(false),
form_field_autofill_request_id_(0),
popup_notification_visible_(false),
- delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync) {
+ delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync),
+ preferred_width_(0),
+ send_preferred_width_changes_(false) {
}
RenderView::~RenderView() {
@@ -431,6 +433,8 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse)
IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode)
IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground)
+ IPC_MESSAGE_HANDLER(ViewMsg_EnableIntrinsicWidthChangedMode,
+ OnEnableIntrinsicWidthChangedMode)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
@@ -1926,13 +1930,23 @@ void RenderView::OpenURL(WebView* webview, const GURL& url,
void RenderView::DidContentsSizeChange(WebWidget* webwidget,
int new_width,
int new_height) {
- // TODO(rafaelw): This is a temporary solution. Only the ExtensionView wants
- // this notification at the moment. It isn't clean to test for ExtensionView
- // by examining the enabled_bindings. This needs to be generalized as it
- // becomes clear what extension toolbars need.
- if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
+ // We don't always want to send the change messages over IPC, only if we've
+ // be put in that mode by getting a |ViewMsg_EnableIntrinsicWidthChangedMode|
+ // message.
+ // TODO(rafaelw): Figure out where the best place to set this for extensions
+ // is. It isn't clean to test for ExtensionView by examining the
+ // enabled_bindings. This needs to be generalized as it becomes clear what
+ // extension toolbars need.
+ if (BindingsPolicy::is_extension_enabled(enabled_bindings_) ||
+ send_preferred_width_changes_) {
+ // WebCore likes to tell us things have changed even when they haven't, so
+ // cache the width and only send the IPC message when we're sure the
+ // width is different.
int width = webview()->GetMainFrame()->GetContentsPreferredWidth();
- Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width));
+ if (width != preferred_width_) {
+ Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width));
+ preferred_width_ = width;
+ }
}
}
@@ -2720,6 +2734,10 @@ void RenderView::OnEnableViewSourceMode() {
main_frame->SetInViewSourceMode(true);
}
+void RenderView::OnEnableIntrinsicWidthChangedMode() {
+ send_preferred_width_changes_ = true;
+}
+
void RenderView::OnUpdateBackForwardListCount(int back_list_count,
int forward_list_count) {
history_back_list_count_ = back_list_count;
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 678dbb5..e58a641 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -541,6 +541,7 @@ class RenderView : public RenderWidget,
void OnInstallMissingPlugin();
void OnFileChooserResponse(const std::vector<FilePath>& file_names);
void OnEnableViewSourceMode();
+ void OnEnableIntrinsicWidthChangedMode();
void OnUpdateBackForwardListCount(int back_list_count,
int forward_list_count);
void OnGetAccessibilityInfo(
@@ -799,6 +800,13 @@ class RenderView : public RenderWidget,
// it's for the selection clipboard.
std::string selection_text_;
+ // Cache the preferred width of the page in order to prevent sending the IPC
+ // when layout() recomputes it but it doesn't actually change.
+ int preferred_width_;
+
+ // If true, we send IPC messages when the preferred width changes.
+ bool send_preferred_width_changes_;
+
DISALLOW_COPY_AND_ASSIGN(RenderView);
};