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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } 1045 }
1046 } 1046 }
1047 1047
1048 void RenderWidgetHostViewAura::ImeCancelComposition() { 1048 void RenderWidgetHostViewAura::ImeCancelComposition() {
1049 if (GetInputMethod()) 1049 if (GetInputMethod())
1050 GetInputMethod()->CancelComposition(this); 1050 GetInputMethod()->CancelComposition(this);
1051 has_composition_text_ = false; 1051 has_composition_text_ = false;
1052 } 1052 }
1053 1053
1054 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( 1054 void RenderWidgetHostViewAura::ImeCompositionRangeChanged(
1055 const ui::Range& range, 1055 const gfx::Range& range,
1056 const std::vector<gfx::Rect>& character_bounds) { 1056 const std::vector<gfx::Rect>& character_bounds) {
1057 composition_character_bounds_ = character_bounds; 1057 composition_character_bounds_ = character_bounds;
1058 } 1058 }
1059 1059
1060 void RenderWidgetHostViewAura::DidUpdateBackingStore( 1060 void RenderWidgetHostViewAura::DidUpdateBackingStore(
1061 const gfx::Rect& scroll_rect, 1061 const gfx::Rect& scroll_rect,
1062 const gfx::Vector2d& scroll_delta, 1062 const gfx::Vector2d& scroll_delta,
1063 const std::vector<gfx::Rect>& copy_rects, 1063 const std::vector<gfx::Rect>& copy_rects,
1064 const ui::LatencyInfo& latency_info) { 1064 const ui::LatencyInfo& latency_info) {
1065 if (accelerated_compositing_state_changed_) 1065 if (accelerated_compositing_state_changed_)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 aura::client::GetTooltipClient(root_window); 1130 aura::client::GetTooltipClient(root_window);
1131 if (tooltip_client) { 1131 if (tooltip_client) {
1132 tooltip_client->UpdateTooltip(window_); 1132 tooltip_client->UpdateTooltip(window_);
1133 // Content tooltips should be visible indefinitely. 1133 // Content tooltips should be visible indefinitely.
1134 tooltip_client->SetTooltipShownTimeout(window_, 0); 1134 tooltip_client->SetTooltipShownTimeout(window_, 0);
1135 } 1135 }
1136 } 1136 }
1137 1137
1138 void RenderWidgetHostViewAura::SelectionChanged(const string16& text, 1138 void RenderWidgetHostViewAura::SelectionChanged(const string16& text,
1139 size_t offset, 1139 size_t offset,
1140 const ui::Range& range) { 1140 const gfx::Range& range) {
1141 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); 1141 RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
1142 1142
1143 #if defined(USE_X11) && !defined(OS_CHROMEOS) 1143 #if defined(USE_X11) && !defined(OS_CHROMEOS)
1144 if (text.empty() || range.is_empty()) 1144 if (text.empty() || range.is_empty())
1145 return; 1145 return;
1146 1146
1147 // Set the BUFFER_SELECTION to the ui::Clipboard. 1147 // Set the BUFFER_SELECTION to the ui::Clipboard.
1148 ui::ScopedClipboardWriter clipboard_writer( 1148 ui::ScopedClipboardWriter clipboard_writer(
1149 ui::Clipboard::GetForCurrentThread(), 1149 ui::Clipboard::GetForCurrentThread(),
1150 ui::Clipboard::BUFFER_SELECTION); 1150 ui::Clipboard::BUFFER_SELECTION);
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 2136 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788
2137 host_->ImeSetComposition(composition.text, underlines, 2137 host_->ImeSetComposition(composition.text, underlines,
2138 composition.selection.end(), 2138 composition.selection.end(),
2139 composition.selection.end()); 2139 composition.selection.end());
2140 2140
2141 has_composition_text_ = !composition.text.empty(); 2141 has_composition_text_ = !composition.text.empty();
2142 } 2142 }
2143 2143
2144 void RenderWidgetHostViewAura::ConfirmCompositionText() { 2144 void RenderWidgetHostViewAura::ConfirmCompositionText() {
2145 if (host_ && has_composition_text_) 2145 if (host_ && has_composition_text_)
2146 host_->ImeConfirmComposition(string16(), ui::Range::InvalidRange(), false); 2146 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false);
2147 has_composition_text_ = false; 2147 has_composition_text_ = false;
2148 } 2148 }
2149 2149
2150 void RenderWidgetHostViewAura::ClearCompositionText() { 2150 void RenderWidgetHostViewAura::ClearCompositionText() {
2151 if (host_ && has_composition_text_) 2151 if (host_ && has_composition_text_)
2152 host_->ImeCancelComposition(); 2152 host_->ImeCancelComposition();
2153 has_composition_text_ = false; 2153 has_composition_text_ = false;
2154 } 2154 }
2155 2155
2156 void RenderWidgetHostViewAura::InsertText(const string16& text) { 2156 void RenderWidgetHostViewAura::InsertText(const string16& text) {
2157 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); 2157 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE);
2158 if (host_) 2158 if (host_)
2159 host_->ImeConfirmComposition(text, ui::Range::InvalidRange(), false); 2159 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false);
2160 has_composition_text_ = false; 2160 has_composition_text_ = false;
2161 } 2161 }
2162 2162
2163 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { 2163 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) {
2164 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 2164 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
2165 popup_child_host_view_->InsertChar(ch, flags); 2165 popup_child_host_view_->InsertChar(ch, flags);
2166 return; 2166 return;
2167 } 2167 }
2168 2168
2169 if (host_) { 2169 if (host_) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 if (index >= composition_character_bounds_.size()) 2245 if (index >= composition_character_bounds_.size())
2246 return false; 2246 return false;
2247 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 2247 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
2248 return true; 2248 return true;
2249 } 2249 }
2250 2250
2251 bool RenderWidgetHostViewAura::HasCompositionText() { 2251 bool RenderWidgetHostViewAura::HasCompositionText() {
2252 return has_composition_text_; 2252 return has_composition_text_;
2253 } 2253 }
2254 2254
2255 bool RenderWidgetHostViewAura::GetTextRange(ui::Range* range) { 2255 bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) {
2256 range->set_start(selection_text_offset_); 2256 range->set_start(selection_text_offset_);
2257 range->set_end(selection_text_offset_ + selection_text_.length()); 2257 range->set_end(selection_text_offset_ + selection_text_.length());
2258 return true; 2258 return true;
2259 } 2259 }
2260 2260
2261 bool RenderWidgetHostViewAura::GetCompositionTextRange(ui::Range* range) { 2261 bool RenderWidgetHostViewAura::GetCompositionTextRange(gfx::Range* range) {
2262 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 2262 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
2263 NOTIMPLEMENTED(); 2263 NOTIMPLEMENTED();
2264 return false; 2264 return false;
2265 } 2265 }
2266 2266
2267 bool RenderWidgetHostViewAura::GetSelectionRange(ui::Range* range) { 2267 bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) {
2268 range->set_start(selection_range_.start()); 2268 range->set_start(selection_range_.start());
2269 range->set_end(selection_range_.end()); 2269 range->set_end(selection_range_.end());
2270 return true; 2270 return true;
2271 } 2271 }
2272 2272
2273 bool RenderWidgetHostViewAura::SetSelectionRange(const ui::Range& range) { 2273 bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) {
2274 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 2274 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
2275 NOTIMPLEMENTED(); 2275 NOTIMPLEMENTED();
2276 return false; 2276 return false;
2277 } 2277 }
2278 2278
2279 bool RenderWidgetHostViewAura::DeleteRange(const ui::Range& range) { 2279 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) {
2280 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 2280 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
2281 NOTIMPLEMENTED(); 2281 NOTIMPLEMENTED();
2282 return false; 2282 return false;
2283 } 2283 }
2284 2284
2285 bool RenderWidgetHostViewAura::GetTextFromRange( 2285 bool RenderWidgetHostViewAura::GetTextFromRange(
2286 const ui::Range& range, 2286 const gfx::Range& range,
2287 string16* text) { 2287 string16* text) {
2288 ui::Range selection_text_range(selection_text_offset_, 2288 gfx::Range selection_text_range(selection_text_offset_,
2289 selection_text_offset_ + selection_text_.length()); 2289 selection_text_offset_ + selection_text_.length());
2290 2290
2291 if (!selection_text_range.Contains(range)) { 2291 if (!selection_text_range.Contains(range)) {
2292 text->clear(); 2292 text->clear();
2293 return false; 2293 return false;
2294 } 2294 }
2295 if (selection_text_range.EqualsIgnoringDirection(range)) { 2295 if (selection_text_range.EqualsIgnoringDirection(range)) {
2296 // Avoid calling substr whose performance is low. 2296 // Avoid calling substr whose performance is low.
2297 *text = selection_text_; 2297 *text = selection_text_;
2298 } else { 2298 } else {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 } 3111 }
3112 3112
3113 bool RenderWidgetHostViewAura::NeedsInputGrab() { 3113 bool RenderWidgetHostViewAura::NeedsInputGrab() {
3114 return popup_type_ == WebKit::WebPopupTypeSelect; 3114 return popup_type_ == WebKit::WebPopupTypeSelect;
3115 } 3115 }
3116 3116
3117 void RenderWidgetHostViewAura::FinishImeCompositionSession() { 3117 void RenderWidgetHostViewAura::FinishImeCompositionSession() {
3118 if (!has_composition_text_) 3118 if (!has_composition_text_)
3119 return; 3119 return;
3120 if (host_) 3120 if (host_)
3121 host_->ImeConfirmComposition(string16(), ui::Range::InvalidRange(), false); 3121 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false);
3122 ImeCancelComposition(); 3122 ImeCancelComposition();
3123 } 3123 }
3124 3124
3125 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( 3125 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords(
3126 WebKit::WebMouseEvent* event) { 3126 WebKit::WebMouseEvent* event) {
3127 // If the mouse has just entered, we must report zero movementX/Y. Hence we 3127 // If the mouse has just entered, we must report zero movementX/Y. Hence we
3128 // reset any global_mouse_position set previously. 3128 // reset any global_mouse_position set previously.
3129 if (event->type == WebKit::WebInputEvent::MouseEnter || 3129 if (event->type == WebKit::WebInputEvent::MouseEnter ||
3130 event->type == WebKit::WebInputEvent::MouseLeave) 3130 event->type == WebKit::WebInputEvent::MouseLeave)
3131 global_mouse_position_.SetPoint(event->globalX, event->globalY); 3131 global_mouse_position_.SetPoint(event->globalX, event->globalY);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3269 RenderWidgetHost* widget) { 3269 RenderWidgetHost* widget) {
3270 return new RenderWidgetHostViewAura(widget); 3270 return new RenderWidgetHostViewAura(widget);
3271 } 3271 }
3272 3272
3273 // static 3273 // static
3274 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3274 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3275 GetScreenInfoForWindow(results, NULL); 3275 GetScreenInfoForWindow(results, NULL);
3276 } 3276 }
3277 3277
3278 } // namespace content 3278 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698