diff options
Diffstat (limited to 'content/browser/renderer_host')
3 files changed, 6 insertions, 316 deletions
diff --git a/content/browser/renderer_host/native_web_keyboard_event_aura.cc b/content/browser/renderer_host/native_web_keyboard_event_aura.cc index 4c3b172..fa3d0d6 100644 --- a/content/browser/renderer_host/native_web_keyboard_event_aura.cc +++ b/content/browser/renderer_host/native_web_keyboard_event_aura.cc @@ -4,24 +4,10 @@ #include "content/public/browser/native_web_keyboard_event.h" -#include "base/logging.h" #include "content/browser/renderer_host/web_input_event_aura.h" -#include "ui/base/events.h" using WebKit::WebKeyboardEvent; -namespace { - -int EventFlagsToWebInputEventModifiers(int flags) { - return - (flags & ui::EF_SHIFT_DOWN ? WebKit::WebInputEvent::ShiftKey : 0) | - (flags & ui::EF_CONTROL_DOWN ? WebKit::WebInputEvent::ControlKey : 0) | - (flags & ui::EF_CAPS_LOCK_DOWN ? WebKit::WebInputEvent::CapsLockOn : 0) | - (flags & ui::EF_ALT_DOWN ? WebKit::WebInputEvent::AltKey : 0); -} - -} // namespace - NativeWebKeyboardEvent::NativeWebKeyboardEvent() : os_event(NULL), skip_in_browser(false) { @@ -41,35 +27,6 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent( skip_in_browser(other.skip_in_browser) { } -NativeWebKeyboardEvent::NativeWebKeyboardEvent( - ui::EventType key_event_type, - bool is_char, - wchar_t character, - int state, - double time_stamp_seconds) - : os_event(NULL), - skip_in_browser(true /* already handled by the input method */) { - switch (key_event_type) { - case ui::ET_KEY_PRESSED: - type = is_char ? WebKit::WebInputEvent::Char : - WebKit::WebInputEvent::RawKeyDown; - break; - case ui::ET_KEY_RELEASED: - type = WebKit::WebInputEvent::KeyUp; - break; - default: - NOTREACHED(); - } - - modifiers = EventFlagsToWebInputEventModifiers(state); - timeStampSeconds = time_stamp_seconds; - windowsKeyCode = character; - nativeKeyCode = character; - text[0] = character; - unmodifiedText[0] = character; - isSystemKey = (state & ui::EF_ALT_DOWN) != 0; -} - NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( const NativeWebKeyboardEvent& other) { WebKeyboardEvent::operator=(other); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 160ac61..9978862 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -10,7 +10,6 @@ #include "content/browser/renderer_host/web_input_event_aura.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/common/gpu/gpu_messages.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" #include "ui/aura/client/aura_constants.h" @@ -20,7 +19,6 @@ #include "ui/aura/window.h" #include "ui/aura/window_types.h" #include "ui/base/hit_test.h" -#include "ui/base/ime/input_method.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/canvas.h" #include "ui/gfx/compositor/layer.h" @@ -96,8 +94,6 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) is_fullscreen_(false), popup_parent_host_view_(NULL), is_loading_(false), - text_input_type_(ui::TEXT_INPUT_TYPE_NONE), - has_composition_text_(false), #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) current_surface_(gfx::kNullPluginWindow), #endif @@ -238,27 +234,13 @@ void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { void RenderWidgetHostViewAura::TextInputStateChanged( ui::TextInputType type, bool can_compose_inline) { - // TODO(kinaba): currently, can_compose_inline is ignored and always treated - // as true. We need to support "can_compose_inline=false" for PPAPI plugins - // that may want to avoid drawing composition-text by themselves and pass - // the responsibility to the browser. - if (text_input_type_ != type) { - text_input_type_ = type; - GetInputMethod()->OnTextInputTypeChanged(this); - } + // http://crbug.com/102569 + NOTIMPLEMENTED(); } void RenderWidgetHostViewAura::ImeCancelComposition() { - GetInputMethod()->CancelComposition(this); - has_composition_text_ = false; -} - -void RenderWidgetHostViewAura::FinishImeCompositionSession() { - if (!has_composition_text_) - return; - if (host_) - host_->ImeConfirmComposition(); - ImeCancelComposition(); + // http://crbug.com/102569 + NOTIMPLEMENTED(); } void RenderWidgetHostViewAura::DidUpdateBackingStore( @@ -299,18 +281,6 @@ void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { } } -void RenderWidgetHostViewAura::SelectionBoundsChanged( - const gfx::Rect& start_rect, - const gfx::Rect& end_rect) { - if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) - return; - - selection_start_rect_ = start_rect; - selection_end_rect_ = end_rect; - - GetInputMethod()->OnCaretBoundsChanged(this); -} - BackingStore* RenderWidgetHostViewAura::AllocBackingStore( const gfx::Size& size) { return new BackingStoreSkia(host_, size); @@ -485,164 +455,6 @@ void RenderWidgetHostViewAura::UnlockMouse() { } //////////////////////////////////////////////////////////////////////////////// -// RenderWidgetHostViewAura, ui::TextInputClient implementation: -void RenderWidgetHostViewAura::SetCompositionText( - const ui::CompositionText& composition) { - if (!host_) - return; - - // ui::CompositionUnderline should be identical to - // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. - COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == - sizeof(WebKit::WebCompositionUnderline), - ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); - - // TODO(suzhe): convert both renderer_host and renderer to use - // ui::CompositionText. - const std::vector<WebKit::WebCompositionUnderline>& underlines = - reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( - composition.underlines); - - // TODO(suzhe): due to a bug of webkit, we can't use selection range with - // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 - host_->ImeSetComposition(composition.text, underlines, - composition.selection.end(), - composition.selection.end()); - - has_composition_text_ = !composition.text.empty(); -} - -void RenderWidgetHostViewAura::ConfirmCompositionText() { - if (host_ && has_composition_text_) - host_->ImeConfirmComposition(); - has_composition_text_ = false; -} - -void RenderWidgetHostViewAura::ClearCompositionText() { - if (host_ && has_composition_text_) - host_->ImeCancelComposition(); - has_composition_text_ = false; -} - -void RenderWidgetHostViewAura::InsertText(const string16& text) { - DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); - if (host_) - host_->ImeConfirmComposition(text); - has_composition_text_ = false; -} - -void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { - if (host_) { - // Send a WebKit::WebInputEvent::Char event to |host_|. - NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, - true /* is_char */, - ch, - flags, - base::Time::Now().ToDoubleT()); - host_->ForwardKeyboardEvent(webkit_event); - } -} - -ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { - return text_input_type_; -} - -gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { - const gfx::Rect rect = selection_start_rect_.Union(selection_end_rect_); - gfx::Point origin = rect.origin(); - gfx::Point end = gfx::Point(rect.right(), rect.bottom()); - - aura::Desktop* desktop = aura::Desktop::GetInstance(); - aura::Window::ConvertPointToWindow(window_, desktop, &origin); - aura::Window::ConvertPointToWindow(window_, desktop, &end); - // TODO(yusukes): Unlike Chrome OS, |desktop| origin might not be the same as - // the system screen origin on Windows and Linux. Probably we should - // (implement and) use something like ConvertPointToScreen(). - - return gfx::Rect(origin.x(), - origin.y(), - end.x() - origin.x(), - end.y() - origin.y()); -} - -bool RenderWidgetHostViewAura::HasCompositionText() { - return has_composition_text_; -} - -bool RenderWidgetHostViewAura::GetTextRange(ui::Range* range) { - range->set_start(selection_text_offset_); - range->set_end(selection_text_offset_ + selection_text_.length()); - return true; -} - -bool RenderWidgetHostViewAura::GetCompositionTextRange(ui::Range* range) { - // TODO(suzhe): implement this method when fixing http://crbug.com/55130. - NOTIMPLEMENTED(); - return false; -} - -bool RenderWidgetHostViewAura::GetSelectionRange(ui::Range* range) { - range->set_start(selection_range_.start()); - range->set_end(selection_range_.end()); - return true; -} - -bool RenderWidgetHostViewAura::SetSelectionRange(const ui::Range& range) { - // TODO(suzhe): implement this method when fixing http://crbug.com/55130. - NOTIMPLEMENTED(); - return false; -} - -bool RenderWidgetHostViewAura::DeleteRange(const ui::Range& range) { - // TODO(suzhe): implement this method when fixing http://crbug.com/55130. - NOTIMPLEMENTED(); - return false; -} - -bool RenderWidgetHostViewAura::GetTextFromRange( - const ui::Range& range, - string16* text) { - ui::Range selection_text_range(selection_text_offset_, - selection_text_offset_ + selection_text_.length()); - - if (!selection_text_range.Contains(range)) { - text->clear(); - return false; - } - if (selection_text_range.EqualsIgnoringDirection(range)) { - // Avoid calling substr whose performance is low. - *text = selection_text_; - } else { - *text = selection_text_.substr( - range.GetMin() - selection_text_offset_, - range.length()); - } - return true; -} - -void RenderWidgetHostViewAura::OnInputMethodChanged() { - if (!host_) - return; - - host_->SetInputMethodActive(GetInputMethod()->IsActive()); - - // TODO(suzhe): implement the newly added “locale” property of HTML DOM - // TextEvent. -} - -bool RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment( - base::i18n::TextDirection direction) { - if (!host_) - return false; - host_->UpdateTextDirection( - direction == base::i18n::RIGHT_TO_LEFT ? - WebKit::WebTextDirectionRightToLeft : - WebKit::WebTextDirectionLeftToRight); - host_->NotifyTextDirection(); - return true; -} - -//////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewAura, aura::WindowDelegate implementation: gfx::Size RenderWidgetHostViewAura::GetMinimumSize() const { @@ -657,22 +469,10 @@ void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, void RenderWidgetHostViewAura::OnFocus() { host_->GotFocus(); - - ui::InputMethod* input_method = GetInputMethod(); - // Ask the system-wide IME to send all TextInputClient messages to |this| - // object. - input_method->SetFocusedTextInputClient(this); - - host_->SetInputMethodActive(input_method->IsActive()); } void RenderWidgetHostViewAura::OnBlur() { host_->Blur(); - - ui::InputMethod* input_method = GetInputMethod(); - if (input_method->GetTextInputClient() == this) - input_method->SetFocusedTextInputClient(NULL); - host_->SetInputMethodActive(false); } bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { @@ -680,23 +480,8 @@ bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { host_->Shutdown(); } else { - // We don't have to communicate with an input method here. It has already - // been done by ui/aura/desktop_host_<platform>.cc. -#if defined(USE_X11) - if (!event->native_event()) { - // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event. - NativeWebKeyboardEvent webkit_event(event->type(), - false /* is_char */, - event->GetCharacter(), - event->flags(), - base::Time::Now().ToDoubleT()); - host_->ForwardKeyboardEvent(webkit_event); - } else -#endif - { - NativeWebKeyboardEvent webkit_event(event); - host_->ForwardKeyboardEvent(webkit_event); - } + NativeWebKeyboardEvent webkit_event(event); + host_->ForwardKeyboardEvent(webkit_event); } return true; } @@ -719,9 +504,6 @@ bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { switch (event->type()) { case ui::ET_MOUSE_PRESSED: window_->SetCapture(); - // Confirm existing composition text on mouse click events, to make sure - // the input caret won't be moved with an ongoing composition text. - FinishImeCompositionSession(); break; case ui::ET_MOUSE_RELEASED: window_->ReleaseCapture(); @@ -837,8 +619,3 @@ void RenderWidgetHostView::GetDefaultScreenInfo( results->depth = 24; results->depthPerComponent = 8; } - -ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() { - aura::Desktop* desktop = aura::Desktop::GetInstance(); - return desktop->GetInputMethod(); -} diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 52d758c..2cf607d 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -11,7 +11,6 @@ #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/common/content_export.h" #include "ui/aura/window_delegate.h" -#include "ui/base/ime/text_input_client.h" #include "ui/gfx/compositor/compositor_observer.h" #include "webkit/glue/webcursor.h" @@ -20,10 +19,6 @@ #include "base/memory/ref_counted.h" #endif -namespace ui { -class InputMethod; -} - namespace WebKit { class WebTouchEvent; } @@ -37,7 +32,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) public ui::CompositorObserver, #endif - public ui::TextInputClient, public aura::WindowDelegate { public: explicit RenderWidgetHostViewAura(RenderWidgetHost* host); @@ -80,8 +74,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; - virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, - const gfx::Rect& end_rect) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; virtual void AcceleratedSurfaceBuffersSwapped( @@ -111,27 +103,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura virtual bool LockMouse() OVERRIDE; virtual void UnlockMouse() OVERRIDE; - // Overridden from ui::TextInputClient: - virtual void SetCompositionText( - const ui::CompositionText& composition) OVERRIDE; - virtual void ConfirmCompositionText() OVERRIDE; - virtual void ClearCompositionText() OVERRIDE; - virtual void InsertText(const string16& text) OVERRIDE; - virtual void InsertChar(char16 ch, int flags) OVERRIDE; - virtual ui::TextInputType GetTextInputType() const OVERRIDE; - virtual gfx::Rect GetCaretBounds() OVERRIDE; - virtual bool HasCompositionText() OVERRIDE; - virtual bool GetTextRange(ui::Range* range) OVERRIDE; - virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; - virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; - virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; - virtual bool DeleteRange(const ui::Range& range) OVERRIDE; - virtual bool GetTextFromRange(const ui::Range& range, - string16* text) OVERRIDE; - virtual void OnInputMethodChanged() OVERRIDE; - virtual bool ChangeTextDirectionAndLayoutAlignment( - base::i18n::TextDirection direction) OVERRIDE; - // Overridden from aura::WindowDelegate: virtual gfx::Size GetMinimumSize() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds, @@ -161,11 +132,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura void UpdateCursorIfOverSelf(); void UpdateExternalTexture(); - ui::InputMethod* GetInputMethod(); - - // Confirm existing composition text in the webpage and ask the input method - // to cancel its ongoing composition session. - void FinishImeCompositionSession(); // The model object. RenderWidgetHost* host_; @@ -189,16 +155,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura // removed from the list on an ET_TOUCH_RELEASED event. WebKit::WebTouchEvent touch_event_; - // The current text input type. - ui::TextInputType text_input_type_; - - // Rectangles before and after the selection. - gfx::Rect selection_start_rect_; - gfx::Rect selection_end_rect_; - - // Indicates if there is onging composition text. - bool has_composition_text_; - // Current tooltip text. string16 tooltip_; |