| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 } | 983 } |
| 984 | 984 |
| 985 void RenderWidgetHostViewAura::Destroy() { | 985 void RenderWidgetHostViewAura::Destroy() { |
| 986 // Beware, this function is not called on all destruction paths. It will | 986 // Beware, this function is not called on all destruction paths. It will |
| 987 // implicitly end up calling ~RenderWidgetHostViewAura though, so all | 987 // implicitly end up calling ~RenderWidgetHostViewAura though, so all |
| 988 // destruction/cleanup code should happen there, not here. | 988 // destruction/cleanup code should happen there, not here. |
| 989 in_shutdown_ = true; | 989 in_shutdown_ = true; |
| 990 delete window_; | 990 delete window_; |
| 991 } | 991 } |
| 992 | 992 |
| 993 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { | 993 void RenderWidgetHostViewAura::SetTooltipText( |
| 994 const base::string16& tooltip_text) { |
| 994 tooltip_ = tooltip_text; | 995 tooltip_ = tooltip_text; |
| 995 aura::Window* root_window = window_->GetRootWindow(); | 996 aura::Window* root_window = window_->GetRootWindow(); |
| 996 aura::client::TooltipClient* tooltip_client = | 997 aura::client::TooltipClient* tooltip_client = |
| 997 aura::client::GetTooltipClient(root_window); | 998 aura::client::GetTooltipClient(root_window); |
| 998 if (tooltip_client) { | 999 if (tooltip_client) { |
| 999 tooltip_client->UpdateTooltip(window_); | 1000 tooltip_client->UpdateTooltip(window_); |
| 1000 // Content tooltips should be visible indefinitely. | 1001 // Content tooltips should be visible indefinitely. |
| 1001 tooltip_client->SetTooltipShownTimeout(window_, 0); | 1002 tooltip_client->SetTooltipShownTimeout(window_, 0); |
| 1002 } | 1003 } |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1005 void RenderWidgetHostViewAura::SelectionChanged(const string16& text, | 1006 void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text, |
| 1006 size_t offset, | 1007 size_t offset, |
| 1007 const gfx::Range& range) { | 1008 const gfx::Range& range) { |
| 1008 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 1009 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 1009 | 1010 |
| 1010 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 1011 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 1011 if (text.empty() || range.is_empty()) | 1012 if (text.empty() || range.is_empty()) |
| 1012 return; | 1013 return; |
| 1013 | 1014 |
| 1014 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 1015 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
| 1015 ui::ScopedClipboardWriter clipboard_writer( | 1016 ui::ScopedClipboardWriter clipboard_writer( |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 // TODO(suzhe): due to a bug of webkit, we can't use selection range with | 2174 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
| 2174 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 | 2175 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
| 2175 host_->ImeSetComposition(composition.text, underlines, | 2176 host_->ImeSetComposition(composition.text, underlines, |
| 2176 composition.selection.end(), | 2177 composition.selection.end(), |
| 2177 composition.selection.end()); | 2178 composition.selection.end()); |
| 2178 | 2179 |
| 2179 has_composition_text_ = !composition.text.empty(); | 2180 has_composition_text_ = !composition.text.empty(); |
| 2180 } | 2181 } |
| 2181 | 2182 |
| 2182 void RenderWidgetHostViewAura::ConfirmCompositionText() { | 2183 void RenderWidgetHostViewAura::ConfirmCompositionText() { |
| 2183 if (host_ && has_composition_text_) | 2184 if (host_ && has_composition_text_) { |
| 2184 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false); | 2185 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
| 2186 false); |
| 2187 } |
| 2185 has_composition_text_ = false; | 2188 has_composition_text_ = false; |
| 2186 } | 2189 } |
| 2187 | 2190 |
| 2188 void RenderWidgetHostViewAura::ClearCompositionText() { | 2191 void RenderWidgetHostViewAura::ClearCompositionText() { |
| 2189 if (host_ && has_composition_text_) | 2192 if (host_ && has_composition_text_) |
| 2190 host_->ImeCancelComposition(); | 2193 host_->ImeCancelComposition(); |
| 2191 has_composition_text_ = false; | 2194 has_composition_text_ = false; |
| 2192 } | 2195 } |
| 2193 | 2196 |
| 2194 void RenderWidgetHostViewAura::InsertText(const string16& text) { | 2197 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { |
| 2195 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); | 2198 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); |
| 2196 if (host_) | 2199 if (host_) |
| 2197 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); | 2200 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
| 2198 has_composition_text_ = false; | 2201 has_composition_text_ = false; |
| 2199 } | 2202 } |
| 2200 | 2203 |
| 2201 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { | 2204 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { |
| 2202 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 2205 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
| 2203 popup_child_host_view_->InsertChar(ch, flags); | 2206 popup_child_host_view_->InsertChar(ch, flags); |
| 2204 return; | 2207 return; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 } | 2322 } |
| 2320 | 2323 |
| 2321 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) { | 2324 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) { |
| 2322 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 2325 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 2323 NOTIMPLEMENTED(); | 2326 NOTIMPLEMENTED(); |
| 2324 return false; | 2327 return false; |
| 2325 } | 2328 } |
| 2326 | 2329 |
| 2327 bool RenderWidgetHostViewAura::GetTextFromRange( | 2330 bool RenderWidgetHostViewAura::GetTextFromRange( |
| 2328 const gfx::Range& range, | 2331 const gfx::Range& range, |
| 2329 string16* text) const { | 2332 base::string16* text) const { |
| 2330 gfx::Range selection_text_range(selection_text_offset_, | 2333 gfx::Range selection_text_range(selection_text_offset_, |
| 2331 selection_text_offset_ + selection_text_.length()); | 2334 selection_text_offset_ + selection_text_.length()); |
| 2332 | 2335 |
| 2333 if (!selection_text_range.Contains(range)) { | 2336 if (!selection_text_range.Contains(range)) { |
| 2334 text->clear(); | 2337 text->clear(); |
| 2335 return false; | 2338 return false; |
| 2336 } | 2339 } |
| 2337 if (selection_text_range.EqualsIgnoringDirection(range)) { | 2340 if (selection_text_range.EqualsIgnoringDirection(range)) { |
| 2338 // Avoid calling substr whose performance is low. | 2341 // Avoid calling substr whose performance is low. |
| 2339 *text = selection_text_; | 2342 *text = selection_text_; |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3234 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 3237 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
| 3235 } | 3238 } |
| 3236 | 3239 |
| 3237 bool RenderWidgetHostViewAura::NeedsInputGrab() { | 3240 bool RenderWidgetHostViewAura::NeedsInputGrab() { |
| 3238 return popup_type_ == blink::WebPopupTypeSelect; | 3241 return popup_type_ == blink::WebPopupTypeSelect; |
| 3239 } | 3242 } |
| 3240 | 3243 |
| 3241 void RenderWidgetHostViewAura::FinishImeCompositionSession() { | 3244 void RenderWidgetHostViewAura::FinishImeCompositionSession() { |
| 3242 if (!has_composition_text_) | 3245 if (!has_composition_text_) |
| 3243 return; | 3246 return; |
| 3244 if (host_) | 3247 if (host_) { |
| 3245 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false); | 3248 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
| 3249 false); |
| 3250 } |
| 3246 ImeCancelComposition(); | 3251 ImeCancelComposition(); |
| 3247 } | 3252 } |
| 3248 | 3253 |
| 3249 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( | 3254 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( |
| 3250 blink::WebMouseEvent* event) { | 3255 blink::WebMouseEvent* event) { |
| 3251 // If the mouse has just entered, we must report zero movementX/Y. Hence we | 3256 // If the mouse has just entered, we must report zero movementX/Y. Hence we |
| 3252 // reset any global_mouse_position set previously. | 3257 // reset any global_mouse_position set previously. |
| 3253 if (event->type == blink::WebInputEvent::MouseEnter || | 3258 if (event->type == blink::WebInputEvent::MouseEnter || |
| 3254 event->type == blink::WebInputEvent::MouseLeave) | 3259 event->type == blink::WebInputEvent::MouseLeave) |
| 3255 global_mouse_position_.SetPoint(event->globalX, event->globalY); | 3260 global_mouse_position_.SetPoint(event->globalX, event->globalY); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 RenderWidgetHost* widget) { | 3404 RenderWidgetHost* widget) { |
| 3400 return new RenderWidgetHostViewAura(widget); | 3405 return new RenderWidgetHostViewAura(widget); |
| 3401 } | 3406 } |
| 3402 | 3407 |
| 3403 // static | 3408 // static |
| 3404 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3409 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3405 GetScreenInfoForWindow(results, NULL); | 3410 GetScreenInfoForWindow(results, NULL); |
| 3406 } | 3411 } |
| 3407 | 3412 |
| 3408 } // namespace content | 3413 } // namespace content |
| OLD | NEW |