| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/renderer_host/backing_store_skia.h" | 8 #include "content/browser/renderer_host/backing_store_skia.h" |
| 9 #include "content/browser/renderer_host/render_widget_host.h" | 9 #include "content/browser/renderer_host/render_widget_host.h" |
| 10 #include "content/browser/renderer_host/web_input_event_aura.h" | 10 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 11 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
| 12 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/client/tooltip_client.h" | 17 #include "ui/aura/client/tooltip_client.h" |
| 17 #include "ui/aura/client/window_types.h" | 18 #include "ui/aura/client/window_types.h" |
| 18 #include "ui/aura/event.h" | 19 #include "ui/aura/event.h" |
| 19 #include "ui/aura/root_window.h" | 20 #include "ui/aura/root_window.h" |
| 20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 21 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
| 23 #include "ui/base/ime/input_method.h" |
| 22 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
| 23 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/compositor/layer.h" | 26 #include "ui/gfx/compositor/layer.h" |
| 25 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 26 | 28 |
| 27 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 29 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 28 #include "base/bind.h" | 30 #include "base/bind.h" |
| 29 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" | 31 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" |
| 30 #include "ui/gfx/gl/gl_bindings.h" | 32 #include "ui/gfx/gl/gl_bindings.h" |
| 31 #endif | 33 #endif |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 89 |
| 88 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 89 // RenderWidgetHostViewAura, public: | 91 // RenderWidgetHostViewAura, public: |
| 90 | 92 |
| 91 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 93 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| 92 : host_(host), | 94 : host_(host), |
| 93 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 95 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 94 is_fullscreen_(false), | 96 is_fullscreen_(false), |
| 95 popup_parent_host_view_(NULL), | 97 popup_parent_host_view_(NULL), |
| 96 is_loading_(false), | 98 is_loading_(false), |
| 99 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 100 has_composition_text_(false), |
| 97 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 101 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 98 current_surface_(gfx::kNullPluginWindow), | 102 current_surface_(gfx::kNullPluginWindow), |
| 99 #endif | 103 #endif |
| 100 skip_schedule_paint_(false) { | 104 skip_schedule_paint_(false) { |
| 101 host_->SetView(this); | 105 host_->SetView(this); |
| 102 window_->SetProperty(aura::client::kTooltipTextKey, &tooltip_); | 106 window_->SetProperty(aura::client::kTooltipTextKey, &tooltip_); |
| 103 aura::client::SetActivationDelegate(window_, this); | 107 aura::client::SetActivationDelegate(window_, this); |
| 104 } | 108 } |
| 105 | 109 |
| 106 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 110 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 233 } |
| 230 | 234 |
| 231 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { | 235 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { |
| 232 is_loading_ = is_loading; | 236 is_loading_ = is_loading; |
| 233 UpdateCursorIfOverSelf(); | 237 UpdateCursorIfOverSelf(); |
| 234 } | 238 } |
| 235 | 239 |
| 236 void RenderWidgetHostViewAura::TextInputStateChanged( | 240 void RenderWidgetHostViewAura::TextInputStateChanged( |
| 237 ui::TextInputType type, | 241 ui::TextInputType type, |
| 238 bool can_compose_inline) { | 242 bool can_compose_inline) { |
| 239 // http://crbug.com/102569 | 243 // TODO(kinaba): currently, can_compose_inline is ignored and always treated |
| 240 NOTIMPLEMENTED(); | 244 // as true. We need to support "can_compose_inline=false" for PPAPI plugins |
| 245 // that may want to avoid drawing composition-text by themselves and pass |
| 246 // the responsibility to the browser. |
| 247 if (text_input_type_ != type) { |
| 248 text_input_type_ = type; |
| 249 GetInputMethod()->OnTextInputTypeChanged(this); |
| 250 } |
| 241 } | 251 } |
| 242 | 252 |
| 243 void RenderWidgetHostViewAura::ImeCancelComposition() { | 253 void RenderWidgetHostViewAura::ImeCancelComposition() { |
| 244 // http://crbug.com/102569 | 254 GetInputMethod()->CancelComposition(this); |
| 245 NOTIMPLEMENTED(); | 255 has_composition_text_ = false; |
| 246 } | 256 } |
| 247 | 257 |
| 248 void RenderWidgetHostViewAura::DidUpdateBackingStore( | 258 void RenderWidgetHostViewAura::DidUpdateBackingStore( |
| 249 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, | 259 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, |
| 250 const std::vector<gfx::Rect>& copy_rects) { | 260 const std::vector<gfx::Rect>& copy_rects) { |
| 251 if (!window_->IsVisible() || skip_schedule_paint_) | 261 if (!window_->IsVisible() || skip_schedule_paint_) |
| 252 return; | 262 return; |
| 253 | 263 |
| 254 if (!scroll_rect.IsEmpty()) | 264 if (!scroll_rect.IsEmpty()) |
| 255 window_->SchedulePaintInRect(scroll_rect); | 265 window_->SchedulePaintInRect(scroll_rect); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 272 void RenderWidgetHostViewAura::Destroy() { | 282 void RenderWidgetHostViewAura::Destroy() { |
| 273 delete window_; | 283 delete window_; |
| 274 } | 284 } |
| 275 | 285 |
| 276 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { | 286 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { |
| 277 tooltip_ = tooltip_text; | 287 tooltip_ = tooltip_text; |
| 278 if (aura::client::GetTooltipClient()) | 288 if (aura::client::GetTooltipClient()) |
| 279 aura::client::GetTooltipClient()->UpdateTooltip(window_); | 289 aura::client::GetTooltipClient()->UpdateTooltip(window_); |
| 280 } | 290 } |
| 281 | 291 |
| 292 void RenderWidgetHostViewAura::SelectionBoundsChanged( |
| 293 const gfx::Rect& start_rect, |
| 294 const gfx::Rect& end_rect) { |
| 295 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) |
| 296 return; |
| 297 |
| 298 selection_start_rect_ = start_rect; |
| 299 selection_end_rect_ = end_rect; |
| 300 |
| 301 GetInputMethod()->OnCaretBoundsChanged(this); |
| 302 } |
| 303 |
| 282 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( | 304 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( |
| 283 const gfx::Size& size) { | 305 const gfx::Size& size) { |
| 284 return new BackingStoreSkia(host_, size); | 306 return new BackingStoreSkia(host_, size); |
| 285 } | 307 } |
| 286 | 308 |
| 287 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 309 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
| 288 UpdateExternalTexture(); | 310 UpdateExternalTexture(); |
| 289 } | 311 } |
| 290 | 312 |
| 291 void RenderWidgetHostViewAura::UpdateExternalTexture() { | 313 void RenderWidgetHostViewAura::UpdateExternalTexture() { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return false; | 475 return false; |
| 454 } | 476 } |
| 455 | 477 |
| 456 void RenderWidgetHostViewAura::UnlockMouse() { | 478 void RenderWidgetHostViewAura::UnlockMouse() { |
| 457 // http://crbug.com/102563 | 479 // http://crbug.com/102563 |
| 458 NOTIMPLEMENTED(); | 480 NOTIMPLEMENTED(); |
| 459 host_->LostMouseLock(); | 481 host_->LostMouseLock(); |
| 460 } | 482 } |
| 461 | 483 |
| 462 //////////////////////////////////////////////////////////////////////////////// | 484 //////////////////////////////////////////////////////////////////////////////// |
| 485 // RenderWidgetHostViewAura, ui::TextInputClient implementation: |
| 486 void RenderWidgetHostViewAura::SetCompositionText( |
| 487 const ui::CompositionText& composition) { |
| 488 if (!host_) |
| 489 return; |
| 490 |
| 491 // ui::CompositionUnderline should be identical to |
| 492 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. |
| 493 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == |
| 494 sizeof(WebKit::WebCompositionUnderline), |
| 495 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); |
| 496 |
| 497 // TODO(suzhe): convert both renderer_host and renderer to use |
| 498 // ui::CompositionText. |
| 499 const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| 500 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
| 501 composition.underlines); |
| 502 |
| 503 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
| 504 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
| 505 host_->ImeSetComposition(composition.text, underlines, |
| 506 composition.selection.end(), |
| 507 composition.selection.end()); |
| 508 |
| 509 has_composition_text_ = !composition.text.empty(); |
| 510 } |
| 511 |
| 512 void RenderWidgetHostViewAura::ConfirmCompositionText() { |
| 513 if (host_ && has_composition_text_) |
| 514 host_->ImeConfirmComposition(); |
| 515 has_composition_text_ = false; |
| 516 } |
| 517 |
| 518 void RenderWidgetHostViewAura::ClearCompositionText() { |
| 519 if (host_ && has_composition_text_) |
| 520 host_->ImeCancelComposition(); |
| 521 has_composition_text_ = false; |
| 522 } |
| 523 |
| 524 void RenderWidgetHostViewAura::InsertText(const string16& text) { |
| 525 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); |
| 526 if (host_) |
| 527 host_->ImeConfirmComposition(text); |
| 528 has_composition_text_ = false; |
| 529 } |
| 530 |
| 531 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { |
| 532 if (host_) { |
| 533 // Send a WebKit::WebInputEvent::Char event to |host_|. |
| 534 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, |
| 535 true /* is_char */, |
| 536 ch, |
| 537 flags, |
| 538 base::Time::Now().ToDoubleT()); |
| 539 host_->ForwardKeyboardEvent(webkit_event); |
| 540 } |
| 541 } |
| 542 |
| 543 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { |
| 544 return text_input_type_; |
| 545 } |
| 546 |
| 547 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { |
| 548 const gfx::Rect rect = selection_start_rect_.Union(selection_end_rect_); |
| 549 gfx::Point origin = rect.origin(); |
| 550 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); |
| 551 |
| 552 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
| 553 aura::Window::ConvertPointToWindow(window_, root_window, &origin); |
| 554 aura::Window::ConvertPointToWindow(window_, root_window, &end); |
| 555 // TODO(yusukes): Unlike Chrome OS, |root_window| origin might not be the |
| 556 // same as the system screen origin on Windows and Linux. Probably we should |
| 557 // (implement and) use something like ConvertPointToScreen(). |
| 558 |
| 559 return gfx::Rect(origin.x(), |
| 560 origin.y(), |
| 561 end.x() - origin.x(), |
| 562 end.y() - origin.y()); |
| 563 } |
| 564 |
| 565 bool RenderWidgetHostViewAura::HasCompositionText() { |
| 566 return has_composition_text_; |
| 567 } |
| 568 |
| 569 bool RenderWidgetHostViewAura::GetTextRange(ui::Range* range) { |
| 570 range->set_start(selection_text_offset_); |
| 571 range->set_end(selection_text_offset_ + selection_text_.length()); |
| 572 return true; |
| 573 } |
| 574 |
| 575 bool RenderWidgetHostViewAura::GetCompositionTextRange(ui::Range* range) { |
| 576 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 577 NOTIMPLEMENTED(); |
| 578 return false; |
| 579 } |
| 580 |
| 581 bool RenderWidgetHostViewAura::GetSelectionRange(ui::Range* range) { |
| 582 range->set_start(selection_range_.start()); |
| 583 range->set_end(selection_range_.end()); |
| 584 return true; |
| 585 } |
| 586 |
| 587 bool RenderWidgetHostViewAura::SetSelectionRange(const ui::Range& range) { |
| 588 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 589 NOTIMPLEMENTED(); |
| 590 return false; |
| 591 } |
| 592 |
| 593 bool RenderWidgetHostViewAura::DeleteRange(const ui::Range& range) { |
| 594 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 595 NOTIMPLEMENTED(); |
| 596 return false; |
| 597 } |
| 598 |
| 599 bool RenderWidgetHostViewAura::GetTextFromRange( |
| 600 const ui::Range& range, |
| 601 string16* text) { |
| 602 ui::Range selection_text_range(selection_text_offset_, |
| 603 selection_text_offset_ + selection_text_.length()); |
| 604 |
| 605 if (!selection_text_range.Contains(range)) { |
| 606 text->clear(); |
| 607 return false; |
| 608 } |
| 609 if (selection_text_range.EqualsIgnoringDirection(range)) { |
| 610 // Avoid calling substr whose performance is low. |
| 611 *text = selection_text_; |
| 612 } else { |
| 613 *text = selection_text_.substr( |
| 614 range.GetMin() - selection_text_offset_, |
| 615 range.length()); |
| 616 } |
| 617 return true; |
| 618 } |
| 619 |
| 620 void RenderWidgetHostViewAura::OnInputMethodChanged() { |
| 621 if (!host_) |
| 622 return; |
| 623 |
| 624 host_->SetInputMethodActive(GetInputMethod()->IsActive()); |
| 625 |
| 626 // TODO(suzhe): implement the newly added “locale” property of HTML DOM |
| 627 // TextEvent. |
| 628 } |
| 629 |
| 630 bool RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment( |
| 631 base::i18n::TextDirection direction) { |
| 632 if (!host_) |
| 633 return false; |
| 634 host_->UpdateTextDirection( |
| 635 direction == base::i18n::RIGHT_TO_LEFT ? |
| 636 WebKit::WebTextDirectionRightToLeft : |
| 637 WebKit::WebTextDirectionLeftToRight); |
| 638 host_->NotifyTextDirection(); |
| 639 return true; |
| 640 } |
| 641 |
| 642 //////////////////////////////////////////////////////////////////////////////// |
| 463 // RenderWidgetHostViewAura, aura::WindowDelegate implementation: | 643 // RenderWidgetHostViewAura, aura::WindowDelegate implementation: |
| 464 | 644 |
| 465 gfx::Size RenderWidgetHostViewAura::GetMinimumSize() const { | 645 gfx::Size RenderWidgetHostViewAura::GetMinimumSize() const { |
| 466 return gfx::Size(); | 646 return gfx::Size(); |
| 467 } | 647 } |
| 468 | 648 |
| 469 void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, | 649 void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
| 470 const gfx::Rect& new_bounds) { | 650 const gfx::Rect& new_bounds) { |
| 471 // We don't care about this one, we are always sized via SetSize() or | 651 // We don't care about this one, we are always sized via SetSize() or |
| 472 // SetBounds(). | 652 // SetBounds(). |
| 473 } | 653 } |
| 474 | 654 |
| 475 void RenderWidgetHostViewAura::OnFocus() { | 655 void RenderWidgetHostViewAura::OnFocus() { |
| 476 host_->GotFocus(); | 656 host_->GotFocus(); |
| 477 host_->SetActive(true); | 657 host_->SetActive(true); |
| 658 |
| 659 ui::InputMethod* input_method = GetInputMethod(); |
| 660 if (input_method) { |
| 661 // Ask the system-wide IME to send all TextInputClient messages to |this| |
| 662 // object. |
| 663 input_method->SetFocusedTextInputClient(this); |
| 664 host_->SetInputMethodActive(input_method->IsActive()); |
| 665 } else { |
| 666 host_->SetInputMethodActive(false); |
| 667 } |
| 478 } | 668 } |
| 479 | 669 |
| 480 void RenderWidgetHostViewAura::OnBlur() { | 670 void RenderWidgetHostViewAura::OnBlur() { |
| 481 host_->SetActive(false); | 671 host_->SetActive(false); |
| 482 host_->Blur(); | 672 host_->Blur(); |
| 673 |
| 674 ui::InputMethod* input_method = GetInputMethod(); |
| 675 if (input_method) { |
| 676 if (input_method->GetTextInputClient() == this) |
| 677 input_method->SetFocusedTextInputClient(NULL); |
| 678 } |
| 679 host_->SetInputMethodActive(false); |
| 483 } | 680 } |
| 484 | 681 |
| 485 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { | 682 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { |
| 486 // We need to handle the Escape key for Pepper Flash. | 683 // We need to handle the Escape key for Pepper Flash. |
| 487 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { | 684 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
| 488 host_->Shutdown(); | 685 host_->Shutdown(); |
| 489 } else { | 686 } else { |
| 490 NativeWebKeyboardEvent webkit_event(event); | 687 // We don't have to communicate with an input method here. |
| 491 host_->ForwardKeyboardEvent(webkit_event); | 688 if (!event->HasNativeEvent()) { |
| 689 // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event. |
| 690 NativeWebKeyboardEvent webkit_event(event->type(), |
| 691 false /* is_char */, |
| 692 event->GetCharacter(), |
| 693 event->flags(), |
| 694 base::Time::Now().ToDoubleT()); |
| 695 host_->ForwardKeyboardEvent(webkit_event); |
| 696 } else { |
| 697 NativeWebKeyboardEvent webkit_event(event); |
| 698 host_->ForwardKeyboardEvent(webkit_event); |
| 699 } |
| 492 } | 700 } |
| 493 return true; | 701 return true; |
| 494 } | 702 } |
| 495 | 703 |
| 496 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { | 704 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { |
| 497 return current_cursor_.GetNativeCursor(); | 705 return current_cursor_.GetNativeCursor(); |
| 498 } | 706 } |
| 499 | 707 |
| 500 int RenderWidgetHostViewAura::GetNonClientComponent( | 708 int RenderWidgetHostViewAura::GetNonClientComponent( |
| 501 const gfx::Point& point) const { | 709 const gfx::Point& point) const { |
| 502 return HTCLIENT; | 710 return HTCLIENT; |
| 503 } | 711 } |
| 504 | 712 |
| 505 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { | 713 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { |
| 506 if (event->type() == ui::ET_MOUSEWHEEL) | 714 if (event->type() == ui::ET_MOUSEWHEEL) |
| 507 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event)); | 715 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event)); |
| 508 else if (event->type() == ui::ET_SCROLL) | 716 else if (event->type() == ui::ET_SCROLL) |
| 509 host_->ForwardWheelEvent( | 717 host_->ForwardWheelEvent( |
| 510 content::MakeWebMouseWheelEvent( | 718 content::MakeWebMouseWheelEvent( |
| 511 static_cast<aura::ScrollEvent*>(event))); | 719 static_cast<aura::ScrollEvent*>(event))); |
| 512 else if (CanRendererHandleEvent(event->native_event())) | 720 else if (CanRendererHandleEvent(event->native_event())) |
| 513 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event)); | 721 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event)); |
| 514 | 722 |
| 515 switch (event->type()) { | 723 switch (event->type()) { |
| 516 case ui::ET_MOUSE_PRESSED: | 724 case ui::ET_MOUSE_PRESSED: |
| 517 window_->SetCapture(); | 725 window_->SetCapture(); |
| 726 // Confirm existing composition text on mouse click events, to make sure |
| 727 // the input caret won't be moved with an ongoing composition text. |
| 728 FinishImeCompositionSession(); |
| 518 break; | 729 break; |
| 519 case ui::ET_MOUSE_RELEASED: | 730 case ui::ET_MOUSE_RELEASED: |
| 520 window_->ReleaseCapture(); | 731 window_->ReleaseCapture(); |
| 521 break; | 732 break; |
| 522 default: | 733 default: |
| 523 break; | 734 break; |
| 524 } | 735 } |
| 525 | 736 |
| 526 // Needed to propagate mouse event to native_tab_contents_view_aura. | 737 // Needed to propagate mouse event to native_tab_contents_view_aura. |
| 527 // TODO(pkotwicz): Find a better way of doing this. | 738 // TODO(pkotwicz): Find a better way of doing this. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 if (root_window->GetEventHandlerForPoint(screen_point) != window_) | 829 if (root_window->GetEventHandlerForPoint(screen_point) != window_) |
| 619 return; | 830 return; |
| 620 | 831 |
| 621 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); | 832 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); |
| 622 if (is_loading_ && cursor == aura::kCursorPointer) | 833 if (is_loading_ && cursor == aura::kCursorPointer) |
| 623 cursor = aura::kCursorProgress; | 834 cursor = aura::kCursorProgress; |
| 624 | 835 |
| 625 aura::RootWindow::GetInstance()->SetCursor(cursor); | 836 aura::RootWindow::GetInstance()->SetCursor(cursor); |
| 626 } | 837 } |
| 627 | 838 |
| 839 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { |
| 840 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
| 841 return reinterpret_cast<ui::InputMethod*>( |
| 842 root_window->GetProperty(aura::client::kRootWindowInputMethod)); |
| 843 } |
| 844 |
| 845 void RenderWidgetHostViewAura::FinishImeCompositionSession() { |
| 846 if (!has_composition_text_) |
| 847 return; |
| 848 if (host_) |
| 849 host_->ImeConfirmComposition(); |
| 850 ImeCancelComposition(); |
| 851 } |
| 852 |
| 628 //////////////////////////////////////////////////////////////////////////////// | 853 //////////////////////////////////////////////////////////////////////////////// |
| 629 // RenderWidgetHostView, public: | 854 // RenderWidgetHostView, public: |
| 630 | 855 |
| 631 // static | 856 // static |
| 632 void RenderWidgetHostView::GetDefaultScreenInfo( | 857 void RenderWidgetHostView::GetDefaultScreenInfo( |
| 633 WebKit::WebScreenInfo* results) { | 858 WebKit::WebScreenInfo* results) { |
| 634 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 859 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
| 635 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 860 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
| 636 results->availableRect = results->rect; | 861 results->availableRect = results->rect; |
| 637 // TODO(derat): Don't hardcode this? | 862 // TODO(derat): Don't hardcode this? |
| 638 results->depth = 24; | 863 results->depth = 24; |
| 639 results->depthPerComponent = 8; | 864 results->depthPerComponent = 8; |
| 640 } | 865 } |
| OLD | NEW |