| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 // process to cancel the input method's ongoing composition session, to make | 1836 // process to cancel the input method's ongoing composition session, to make |
| 1837 // sure we are in a consistent state. | 1837 // sure we are in a consistent state. |
| 1838 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); | 1838 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 1839 } | 1839 } |
| 1840 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 1840 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
| 1841 UpdateCompositionInfo(true); | 1841 UpdateCompositionInfo(true); |
| 1842 #endif | 1842 #endif |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 void RenderWidget::OnImeConfirmComposition(const string16& text, | 1845 void RenderWidget::OnImeConfirmComposition(const string16& text, |
| 1846 const ui::Range& replacement_range, | 1846 const gfx::Range& replacement_range, |
| 1847 bool keep_selection) { | 1847 bool keep_selection) { |
| 1848 if (!ShouldHandleImeEvent()) | 1848 if (!ShouldHandleImeEvent()) |
| 1849 return; | 1849 return; |
| 1850 ImeEventGuard guard(this); | 1850 ImeEventGuard guard(this); |
| 1851 handling_input_event_ = true; | 1851 handling_input_event_ = true; |
| 1852 if (text.length()) | 1852 if (text.length()) |
| 1853 webwidget_->confirmComposition(text); | 1853 webwidget_->confirmComposition(text); |
| 1854 else if (keep_selection) | 1854 else if (keep_selection) |
| 1855 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1855 webwidget_->confirmComposition(WebWidget::KeepSelection); |
| 1856 else | 1856 else |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2310 } | 2310 } |
| 2311 | 2311 |
| 2312 ui::TextInputType RenderWidget::GetTextInputType() { | 2312 ui::TextInputType RenderWidget::GetTextInputType() { |
| 2313 if (webwidget_) | 2313 if (webwidget_) |
| 2314 return WebKitToUiTextInputType(webwidget_->textInputInfo().type); | 2314 return WebKitToUiTextInputType(webwidget_->textInputInfo().type); |
| 2315 return ui::TEXT_INPUT_TYPE_NONE; | 2315 return ui::TEXT_INPUT_TYPE_NONE; |
| 2316 } | 2316 } |
| 2317 | 2317 |
| 2318 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 2318 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
| 2319 void RenderWidget::UpdateCompositionInfo(bool should_update_range) { | 2319 void RenderWidget::UpdateCompositionInfo(bool should_update_range) { |
| 2320 ui::Range range = ui::Range(); | 2320 gfx::Range range = gfx::Range(); |
| 2321 if (should_update_range) { | 2321 if (should_update_range) { |
| 2322 GetCompositionRange(&range); | 2322 GetCompositionRange(&range); |
| 2323 } else { | 2323 } else { |
| 2324 range = composition_range_; | 2324 range = composition_range_; |
| 2325 } | 2325 } |
| 2326 std::vector<gfx::Rect> character_bounds; | 2326 std::vector<gfx::Rect> character_bounds; |
| 2327 GetCompositionCharacterBounds(&character_bounds); | 2327 GetCompositionCharacterBounds(&character_bounds); |
| 2328 | 2328 |
| 2329 if (!ShouldUpdateCompositionInfo(range, character_bounds)) | 2329 if (!ShouldUpdateCompositionInfo(range, character_bounds)) |
| 2330 return; | 2330 return; |
| 2331 composition_character_bounds_ = character_bounds; | 2331 composition_character_bounds_ = character_bounds; |
| 2332 composition_range_ = range; | 2332 composition_range_ = range; |
| 2333 Send(new ViewHostMsg_ImeCompositionRangeChanged( | 2333 Send(new ViewHostMsg_ImeCompositionRangeChanged( |
| 2334 routing_id(), composition_range_, composition_character_bounds_)); | 2334 routing_id(), composition_range_, composition_character_bounds_)); |
| 2335 } | 2335 } |
| 2336 | 2336 |
| 2337 void RenderWidget::GetCompositionCharacterBounds( | 2337 void RenderWidget::GetCompositionCharacterBounds( |
| 2338 std::vector<gfx::Rect>* bounds) { | 2338 std::vector<gfx::Rect>* bounds) { |
| 2339 DCHECK(bounds); | 2339 DCHECK(bounds); |
| 2340 bounds->clear(); | 2340 bounds->clear(); |
| 2341 } | 2341 } |
| 2342 | 2342 |
| 2343 void RenderWidget::GetCompositionRange(ui::Range* range) { | 2343 void RenderWidget::GetCompositionRange(gfx::Range* range) { |
| 2344 size_t location, length; | 2344 size_t location, length; |
| 2345 if (webwidget_->compositionRange(&location, &length)) { | 2345 if (webwidget_->compositionRange(&location, &length)) { |
| 2346 range->set_start(location); | 2346 range->set_start(location); |
| 2347 range->set_end(location + length); | 2347 range->set_end(location + length); |
| 2348 } else if (webwidget_->caretOrSelectionRange(&location, &length)) { | 2348 } else if (webwidget_->caretOrSelectionRange(&location, &length)) { |
| 2349 range->set_start(location); | 2349 range->set_start(location); |
| 2350 range->set_end(location + length); | 2350 range->set_end(location + length); |
| 2351 } else { | 2351 } else { |
| 2352 *range = ui::Range::InvalidRange(); | 2352 *range = gfx::Range::InvalidRange(); |
| 2353 } | 2353 } |
| 2354 } | 2354 } |
| 2355 | 2355 |
| 2356 bool RenderWidget::ShouldUpdateCompositionInfo( | 2356 bool RenderWidget::ShouldUpdateCompositionInfo( |
| 2357 const ui::Range& range, | 2357 const gfx::Range& range, |
| 2358 const std::vector<gfx::Rect>& bounds) { | 2358 const std::vector<gfx::Rect>& bounds) { |
| 2359 if (composition_range_ != range) | 2359 if (composition_range_ != range) |
| 2360 return true; | 2360 return true; |
| 2361 if (bounds.size() != composition_character_bounds_.size()) | 2361 if (bounds.size() != composition_character_bounds_.size()) |
| 2362 return true; | 2362 return true; |
| 2363 for (size_t i = 0; i < bounds.size(); ++i) { | 2363 for (size_t i = 0; i < bounds.size(); ++i) { |
| 2364 if (bounds[i] != composition_character_bounds_[i]) | 2364 if (bounds[i] != composition_character_bounds_[i]) |
| 2365 return true; | 2365 return true; |
| 2366 } | 2366 } |
| 2367 return false; | 2367 return false; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 | 2525 |
| 2526 if (!context->InitializeWithDefaultBufferSizes( | 2526 if (!context->InitializeWithDefaultBufferSizes( |
| 2527 attributes, | 2527 attributes, |
| 2528 false /* bind generates resources */, | 2528 false /* bind generates resources */, |
| 2529 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2529 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
| 2530 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2530 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| 2531 return context.Pass(); | 2531 return context.Pass(); |
| 2532 } | 2532 } |
| 2533 | 2533 |
| 2534 } // namespace content | 2534 } // namespace content |
| OLD | NEW |