diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 23:25:04 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 23:25:04 +0000 |
commit | 11ed4bef9a8a74c8fb44a76d8a1c1326c885bb57 (patch) | |
tree | 5421a45c1c94996710693f11f2fb11b67447ca80 /content | |
parent | eb077d4778c129584f337ac58db41b9d4062990c (diff) | |
download | chromium_src-11ed4bef9a8a74c8fb44a76d8a1c1326c885bb57.zip chromium_src-11ed4bef9a8a74c8fb44a76d8a1c1326c885bb57.tar.gz chromium_src-11ed4bef9a8a74c8fb44a76d8a1c1326c885bb57.tar.bz2 |
Expose contextual menu state.
BUG=93804, 95573
TEST=no change
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=120237
Reverted: https://src.chromium.org/viewvc/chrome?view=rev&revision=120239
Review URL: https://chromiumcodereview.appspot.com/9316073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
6 files changed, 19 insertions, 27 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view.cc b/content/browser/renderer_host/render_widget_host_view.cc index 4edba28..53768f2 100644 --- a/content/browser/renderer_host/render_widget_host_view.cc +++ b/content/browser/renderer_host/render_widget_host_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ RenderWidgetHostView::RenderWidgetHostView() : popup_type_(WebKit::WebPopupTypeNone), mouse_locked_(false), + showing_context_menu_(false), selection_text_offset_(0), selection_range_(ui::Range::InvalidRange()) { } @@ -48,3 +49,8 @@ void RenderWidgetHostView::SelectionChanged(const string16& text, selection_range_.set_start(range.start()); selection_range_.set_end(range.end()); } + +void RenderWidgetHostView::SetShowingContextMenu(bool showing) { + DCHECK_NE(showing_context_menu_, showing); + showing_context_menu_ = showing; +} diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index f3e9b8b..3874bd4 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -201,11 +201,10 @@ class RenderWidgetHostView { virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, const gfx::Rect& end_rect) {} - // Tells the View whether the context menu is showing. This is used on Linux - // to suppress updates to webkit focus for the duration of the show. - virtual void ShowingContextMenu(bool showing) {} + // Tells the View whether the context menu is showing. + CONTENT_EXPORT virtual void SetShowingContextMenu(bool showing); - // Allocate a backing store for this view + // Allocate a backing store for this view. virtual BackingStore* AllocBackingStore(const gfx::Size& size) = 0; // Called when accelerated compositing state changes. @@ -346,6 +345,7 @@ class RenderWidgetHostView { void SetBrowserAccessibilityManager(BrowserAccessibilityManager* manager); bool mouse_locked() const { return mouse_locked_; } + bool showing_context_menu() const { return showing_context_menu_; } protected: // Interface class only, do not construct. @@ -366,6 +366,9 @@ class RenderWidgetHostView { // locked. bool mouse_locked_; + // Whether we are showing a context menu. + bool showing_context_menu_; + // A buffer containing the text inside and around the current selection range. string16 selection_text_; diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 863dc3e..72d71a8 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -244,7 +244,7 @@ class RenderWidgetHostViewGtkWidget { gdk_window_set_cursor(gtk_widget_get_window(widget), NULL); // If we are showing a context menu, maintain the illusion that webkit has // focus. - if (!host_view->is_showing_context_menu_) { + if (!host_view->showing_context_menu()) { host_view->GetRenderWidgetHost()->SetActive(false); host_view->GetRenderWidgetHost()->Blur(); } @@ -566,7 +566,6 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) about_to_validate_and_paint_(false), is_hidden_(false), is_loading_(false), - is_showing_context_menu_(false), parent_(NULL), is_popup_first_mouse_release_(true), was_imcontext_focused_before_grab_(false), @@ -933,10 +932,6 @@ void RenderWidgetHostViewGtk::SelectionBoundsChanged( im_context_->UpdateCaretBounds(start_rect.Union(end_rect)); } -void RenderWidgetHostViewGtk::ShowingContextMenu(bool showing) { - is_showing_context_menu_ = showing; -} - #if !defined(TOOLKIT_VIEWS) GtkWidget* RenderWidgetHostViewGtk::BuildInputMethodsGtkMenu() { return im_context_->BuildInputMethodsGtkMenu(); diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 3601164..b66dc88 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -89,7 +89,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { const ui::Range& range) OVERRIDE; virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, const gfx::Rect& end_rect) OVERRIDE; - virtual void ShowingContextMenu(bool showing) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; virtual void AcceleratedSurfaceBuffersSwapped( @@ -210,9 +209,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { // The cursor for the page. This is passed up from the renderer. WebCursor current_cursor_; - // Whether we are showing a context menu. - bool is_showing_context_menu_; - // The time at which this view started displaying white pixels as a result of // not having anything to paint (empty backing store from renderer). This // value returns true for is_null() if we are not recording whiteout times. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 94b1598..bd5a23b 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -211,7 +211,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void SelectionChanged(const string16& text, size_t offset, const ui::Range& range) OVERRIDE; - virtual void ShowingContextMenu(bool showing) OVERRIDE; + virtual void SetShowingContextMenu(bool showing) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; @@ -269,9 +269,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual gfx::Rect GetRootWindowBounds() OVERRIDE; virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE; - // Returns |true| if a context menu is currently being shown. - bool is_showing_context_menu() const { return is_showing_context_menu_; } - void DrawAcceleratedSurfaceInstance( CGLContextObj context, gfx::PluginWindowHandle plugin_handle, @@ -380,9 +377,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // true if the View is not visible. bool is_hidden_; - // Whether we are showing a context menu. - bool is_showing_context_menu_; - // The text to be shown in the tooltip, supplied by the renderer. string16 tooltip_text_; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 0ca290c..e14fab9 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -235,7 +235,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) text_input_type_(ui::TEXT_INPUT_TYPE_NONE), is_loading_(false), is_hidden_(false), - is_showing_context_menu_(false), weak_factory_(this), accelerated_compositing_active_(false), needs_gpu_visibility_update_after_repaint_(false), @@ -497,7 +496,7 @@ void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { // a page? TODO(avi): decide // Don't update the cursor if a context menu is being shown. - if (is_showing_context_menu_) + if (showing_context_menu()) return; // Can we synchronize to the event stream? Switch to -[NSWindow @@ -694,9 +693,8 @@ void RenderWidgetHostViewMac::SelectionChanged(const string16& text, } } -void RenderWidgetHostViewMac::ShowingContextMenu(bool showing) { - DCHECK_NE(is_showing_context_menu_, showing); - is_showing_context_menu_ = showing; +void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { + RenderWidgetHostView::SetShowingContextMenu(showing); // If the menu was closed, restore the cursor to the saved version initially, // as the renderer will not re-send it if there was no change. |