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_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <InputScope.h> | 7 #include <InputScope.h> |
8 #include <wtsapi32.h> | 8 #include <wtsapi32.h> |
9 #pragma comment(lib, "wtsapi32.lib") | 9 #pragma comment(lib, "wtsapi32.lib") |
10 | 10 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 typedef void (*MetroCloseFrameWindow)(HWND window); | 384 typedef void (*MetroCloseFrameWindow)(HWND window); |
385 | 385 |
386 /////////////////////////////////////////////////////////////////////////////// | 386 /////////////////////////////////////////////////////////////////////////////// |
387 // RenderWidgetHostViewWin, public: | 387 // RenderWidgetHostViewWin, public: |
388 | 388 |
389 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) | 389 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
390 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 390 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
391 compositor_host_window_(NULL), | 391 compositor_host_window_(NULL), |
392 hide_compositor_window_at_next_paint_(false), | 392 hide_compositor_window_at_next_paint_(false), |
393 track_mouse_leave_(false), | 393 track_mouse_leave_(false), |
| 394 imm32_manager_(new ui::IMM32Manager), |
394 ime_notification_(false), | 395 ime_notification_(false), |
395 capture_enter_key_(false), | 396 capture_enter_key_(false), |
396 is_hidden_(false), | 397 is_hidden_(false), |
397 about_to_validate_and_paint_(false), | 398 about_to_validate_and_paint_(false), |
398 close_on_deactivate_(false), | 399 close_on_deactivate_(false), |
399 being_destroyed_(false), | 400 being_destroyed_(false), |
400 tooltip_hwnd_(NULL), | 401 tooltip_hwnd_(NULL), |
401 tooltip_showing_(false), | 402 tooltip_showing_(false), |
402 weak_factory_(this), | 403 weak_factory_(this), |
403 is_loading_(false), | 404 is_loading_(false), |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 701 } |
701 } | 702 } |
702 | 703 |
703 void RenderWidgetHostViewWin::SelectionBoundsChanged( | 704 void RenderWidgetHostViewWin::SelectionBoundsChanged( |
704 const ViewHostMsg_SelectionBounds_Params& params) { | 705 const ViewHostMsg_SelectionBounds_Params& params) { |
705 bool is_enabled = (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && | 706 bool is_enabled = (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && |
706 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD); | 707 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD); |
707 // Only update caret position if the input method is enabled. | 708 // Only update caret position if the input method is enabled. |
708 if (is_enabled) { | 709 if (is_enabled) { |
709 caret_rect_ = gfx::UnionRects(params.anchor_rect, params.focus_rect); | 710 caret_rect_ = gfx::UnionRects(params.anchor_rect, params.focus_rect); |
710 imm32_manager_.UpdateCaretRect(m_hWnd, caret_rect_); | 711 imm32_manager_->UpdateCaretRect(m_hWnd, caret_rect_); |
711 } | 712 } |
712 } | 713 } |
713 | 714 |
714 void RenderWidgetHostViewWin::ScrollOffsetChanged() { | 715 void RenderWidgetHostViewWin::ScrollOffsetChanged() { |
715 } | 716 } |
716 | 717 |
717 void RenderWidgetHostViewWin::ImeCancelComposition() { | 718 void RenderWidgetHostViewWin::ImeCancelComposition() { |
718 imm32_manager_.CancelIME(m_hWnd); | 719 imm32_manager_->CancelIME(m_hWnd); |
719 } | 720 } |
720 | 721 |
721 void RenderWidgetHostViewWin::ImeCompositionRangeChanged( | 722 void RenderWidgetHostViewWin::ImeCompositionRangeChanged( |
722 const ui::Range& range, | 723 const ui::Range& range, |
723 const std::vector<gfx::Rect>& character_bounds) { | 724 const std::vector<gfx::Rect>& character_bounds) { |
724 composition_range_ = range; | 725 composition_range_ = range; |
725 composition_character_bounds_ = character_bounds; | 726 composition_character_bounds_ = character_bounds; |
726 } | 727 } |
727 | 728 |
728 void RenderWidgetHostViewWin::Redraw() { | 729 void RenderWidgetHostViewWin::Redraw() { |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 // (i.e. ime_notification_ == true), | 1529 // (i.e. ime_notification_ == true), |
1529 // send this request only if the input context does not have IMEs, | 1530 // send this request only if the input context does not have IMEs, |
1530 // (i.e. ime_status == false). | 1531 // (i.e. ime_status == false). |
1531 // When it successfully sends the request, toggle its notification status, | 1532 // When it successfully sends the request, toggle its notification status, |
1532 // (i.e.ime_notification_ = !ime_notification_ = false). | 1533 // (i.e.ime_notification_ = !ime_notification_ = false). |
1533 // To analyze the above actions, we can optimize them into the ones | 1534 // To analyze the above actions, we can optimize them into the ones |
1534 // listed below: | 1535 // listed below: |
1535 // 1 Sending a request only if ime_status_ != ime_notification_, and; | 1536 // 1 Sending a request only if ime_status_ != ime_notification_, and; |
1536 // 2 Copying ime_status to ime_notification_ if it sends the request | 1537 // 2 Copying ime_status to ime_notification_ if it sends the request |
1537 // successfully (because Action 1 shows ime_status = !ime_notification_.) | 1538 // successfully (because Action 1 shows ime_status = !ime_notification_.) |
1538 bool ime_status = imm32_manager_.SetInputLanguage(); | 1539 bool ime_status = imm32_manager_->SetInputLanguage(); |
1539 if (ime_status != ime_notification_) { | 1540 if (ime_status != ime_notification_) { |
1540 if (render_widget_host_) { | 1541 if (render_widget_host_) { |
1541 render_widget_host_->SetInputMethodActive(ime_status); | 1542 render_widget_host_->SetInputMethodActive(ime_status); |
1542 ime_notification_ = ime_status; | 1543 ime_notification_ = ime_status; |
1543 } | 1544 } |
1544 } | 1545 } |
1545 // Call DefWindowProc() for consistency with other Chrome windows. | 1546 // Call DefWindowProc() for consistency with other Chrome windows. |
1546 // TODO(hbono): This is a speculative fix for Bug 36354 and this code may be | 1547 // TODO(hbono): This is a speculative fix for Bug 36354 and this code may be |
1547 // reverted if it does not fix it. | 1548 // reverted if it does not fix it. |
1548 SetMsgHandled(FALSE); | 1549 SetMsgHandled(FALSE); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 // fortunately sent to an application only while the input context has IMEs. | 1601 // fortunately sent to an application only while the input context has IMEs. |
1601 // Therefore, we just start/stop status messages according to the activation | 1602 // Therefore, we just start/stop status messages according to the activation |
1602 // status of this application without checks. | 1603 // status of this application without checks. |
1603 bool activated = (wparam == TRUE); | 1604 bool activated = (wparam == TRUE); |
1604 if (render_widget_host_) { | 1605 if (render_widget_host_) { |
1605 render_widget_host_->SetInputMethodActive(activated); | 1606 render_widget_host_->SetInputMethodActive(activated); |
1606 ime_notification_ = activated; | 1607 ime_notification_ = activated; |
1607 } | 1608 } |
1608 | 1609 |
1609 if (ime_notification_) | 1610 if (ime_notification_) |
1610 imm32_manager_.CreateImeWindow(m_hWnd); | 1611 imm32_manager_->CreateImeWindow(m_hWnd); |
1611 | 1612 |
1612 imm32_manager_.CleanupComposition(m_hWnd); | 1613 imm32_manager_->CleanupComposition(m_hWnd); |
1613 return imm32_manager_.SetImeWindowStyle( | 1614 return imm32_manager_->SetImeWindowStyle( |
1614 m_hWnd, message, wparam, lparam, &handled); | 1615 m_hWnd, message, wparam, lparam, &handled); |
1615 } | 1616 } |
1616 | 1617 |
1617 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( | 1618 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( |
1618 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1619 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
1619 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeStartComposition"); | 1620 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeStartComposition"); |
1620 if (!render_widget_host_) | 1621 if (!render_widget_host_) |
1621 return 0; | 1622 return 0; |
1622 | 1623 |
1623 // Reset the composition status and create IME windows. | 1624 // Reset the composition status and create IME windows. |
1624 imm32_manager_.CreateImeWindow(m_hWnd); | 1625 imm32_manager_->CreateImeWindow(m_hWnd); |
1625 imm32_manager_.ResetComposition(m_hWnd); | 1626 imm32_manager_->ResetComposition(m_hWnd); |
1626 // When the focus is on an element that does not draw composition by itself | 1627 // When the focus is on an element that does not draw composition by itself |
1627 // (i.e., PPAPI plugin not handling IME), let IME to draw the text. Otherwise | 1628 // (i.e., PPAPI plugin not handling IME), let IME to draw the text. Otherwise |
1628 // we have to prevent WTL from calling ::DefWindowProc() because the function | 1629 // we have to prevent WTL from calling ::DefWindowProc() because the function |
1629 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to | 1630 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to |
1630 // over-write the position of IME windows. | 1631 // over-write the position of IME windows. |
1631 handled = (can_compose_inline_ ? TRUE : FALSE); | 1632 handled = (can_compose_inline_ ? TRUE : FALSE); |
1632 return 0; | 1633 return 0; |
1633 } | 1634 } |
1634 | 1635 |
1635 LRESULT RenderWidgetHostViewWin::OnImeComposition( | 1636 LRESULT RenderWidgetHostViewWin::OnImeComposition( |
1636 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1637 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
1637 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); | 1638 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); |
1638 if (!render_widget_host_) | 1639 if (!render_widget_host_) |
1639 return 0; | 1640 return 0; |
1640 | 1641 |
1641 // At first, update the position of the IME window. | 1642 // At first, update the position of the IME window. |
1642 imm32_manager_.UpdateImeWindow(m_hWnd); | 1643 imm32_manager_->UpdateImeWindow(m_hWnd); |
1643 | 1644 |
1644 // ui::CompositionUnderline should be identical to | 1645 // ui::CompositionUnderline should be identical to |
1645 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. | 1646 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. |
1646 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == | 1647 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == |
1647 sizeof(WebKit::WebCompositionUnderline), | 1648 sizeof(WebKit::WebCompositionUnderline), |
1648 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); | 1649 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); |
1649 | 1650 |
1650 // Retrieve the result string and its attributes of the ongoing composition | 1651 // Retrieve the result string and its attributes of the ongoing composition |
1651 // and send it to a renderer process. | 1652 // and send it to a renderer process. |
1652 ui::CompositionText composition; | 1653 ui::CompositionText composition; |
1653 if (imm32_manager_.GetResult(m_hWnd, lparam, &composition.text)) { | 1654 if (imm32_manager_->GetResult(m_hWnd, lparam, &composition.text)) { |
1654 render_widget_host_->ImeConfirmComposition( | 1655 render_widget_host_->ImeConfirmComposition( |
1655 composition.text, ui::Range::InvalidRange(), false); | 1656 composition.text, ui::Range::InvalidRange(), false); |
1656 imm32_manager_.ResetComposition(m_hWnd); | 1657 imm32_manager_->ResetComposition(m_hWnd); |
1657 // Fall though and try reading the composition string. | 1658 // Fall though and try reading the composition string. |
1658 // Japanese IMEs send a message containing both GCS_RESULTSTR and | 1659 // Japanese IMEs send a message containing both GCS_RESULTSTR and |
1659 // GCS_COMPSTR, which means an ongoing composition has been finished | 1660 // GCS_COMPSTR, which means an ongoing composition has been finished |
1660 // by the start of another composition. | 1661 // by the start of another composition. |
1661 } | 1662 } |
1662 // Retrieve the composition string and its attributes of the ongoing | 1663 // Retrieve the composition string and its attributes of the ongoing |
1663 // composition and send it to a renderer process. | 1664 // composition and send it to a renderer process. |
1664 if (imm32_manager_.GetComposition(m_hWnd, lparam, &composition)) { | 1665 if (imm32_manager_->GetComposition(m_hWnd, lparam, &composition)) { |
1665 // TODO(suzhe): due to a bug of webkit, we can't use selection range with | 1666 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
1666 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 | 1667 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
1667 composition.selection = ui::Range(composition.selection.end()); | 1668 composition.selection = ui::Range(composition.selection.end()); |
1668 | 1669 |
1669 // TODO(suzhe): convert both renderer_host and renderer to use | 1670 // TODO(suzhe): convert both renderer_host and renderer to use |
1670 // ui::CompositionText. | 1671 // ui::CompositionText. |
1671 const std::vector<WebKit::WebCompositionUnderline>& underlines = | 1672 const std::vector<WebKit::WebCompositionUnderline>& underlines = |
1672 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( | 1673 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
1673 composition.underlines); | 1674 composition.underlines); |
1674 render_widget_host_->ImeSetComposition( | 1675 render_widget_host_->ImeSetComposition( |
(...skipping 13 matching lines...) Expand all Loading... |
1688 } | 1689 } |
1689 return 0; | 1690 return 0; |
1690 } | 1691 } |
1691 | 1692 |
1692 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( | 1693 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( |
1693 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1694 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
1694 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeEndComposition"); | 1695 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeEndComposition"); |
1695 if (!render_widget_host_) | 1696 if (!render_widget_host_) |
1696 return 0; | 1697 return 0; |
1697 | 1698 |
1698 if (imm32_manager_.is_composing()) { | 1699 if (imm32_manager_->is_composing()) { |
1699 // A composition has been ended while there is an ongoing composition, | 1700 // A composition has been ended while there is an ongoing composition, |
1700 // i.e. the ongoing composition has been canceled. | 1701 // i.e. the ongoing composition has been canceled. |
1701 // We need to reset the composition status both of the IMM32Manager object | 1702 // We need to reset the composition status both of the IMM32Manager object |
1702 // and of the renderer process. | 1703 // and of the renderer process. |
1703 render_widget_host_->ImeCancelComposition(); | 1704 render_widget_host_->ImeCancelComposition(); |
1704 imm32_manager_.ResetComposition(m_hWnd); | 1705 imm32_manager_->ResetComposition(m_hWnd); |
1705 } | 1706 } |
1706 imm32_manager_.DestroyImeWindow(m_hWnd); | 1707 imm32_manager_->DestroyImeWindow(m_hWnd); |
1707 // Let WTL call ::DefWindowProc() and release its resources. | 1708 // Let WTL call ::DefWindowProc() and release its resources. |
1708 handled = FALSE; | 1709 handled = FALSE; |
1709 return 0; | 1710 return 0; |
1710 } | 1711 } |
1711 | 1712 |
1712 LRESULT RenderWidgetHostViewWin::OnImeRequest( | 1713 LRESULT RenderWidgetHostViewWin::OnImeRequest( |
1713 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1714 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
1714 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeRequest"); | 1715 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeRequest"); |
1715 if (!render_widget_host_) { | 1716 if (!render_widget_host_) { |
1716 handled = FALSE; | 1717 handled = FALSE; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 if (!is_fullscreen_ && !close_on_deactivate_) { | 1816 if (!is_fullscreen_ && !close_on_deactivate_) { |
1816 switch (message) { | 1817 switch (message) { |
1817 case WM_LBUTTONDOWN: | 1818 case WM_LBUTTONDOWN: |
1818 case WM_MBUTTONDOWN: | 1819 case WM_MBUTTONDOWN: |
1819 case WM_RBUTTONDOWN: | 1820 case WM_RBUTTONDOWN: |
1820 // Finish the ongoing composition whenever a mouse click happens. | 1821 // Finish the ongoing composition whenever a mouse click happens. |
1821 // It matches IE's behavior. | 1822 // It matches IE's behavior. |
1822 if (base::win::IsTSFAwareRequired()) { | 1823 if (base::win::IsTSFAwareRequired()) { |
1823 ui::TSFBridge::GetInstance()->CancelComposition(); | 1824 ui::TSFBridge::GetInstance()->CancelComposition(); |
1824 } else { | 1825 } else { |
1825 imm32_manager_.CleanupComposition(m_hWnd); | 1826 imm32_manager_->CleanupComposition(m_hWnd); |
1826 } | 1827 } |
1827 // Fall through. | 1828 // Fall through. |
1828 case WM_MOUSEMOVE: | 1829 case WM_MOUSEMOVE: |
1829 case WM_MOUSELEAVE: { | 1830 case WM_MOUSELEAVE: { |
1830 // Give the WebContentsImpl first crack at the message. It may want to | 1831 // Give the WebContentsImpl first crack at the message. It may want to |
1831 // prevent forwarding to the renderer if some higher level browser | 1832 // prevent forwarding to the renderer if some higher level browser |
1832 // functionality is invoked. | 1833 // functionality is invoked. |
1833 LPARAM parent_msg_lparam = lparam; | 1834 LPARAM parent_msg_lparam = lparam; |
1834 if (message != WM_MOUSELEAVE) { | 1835 if (message != WM_MOUSELEAVE) { |
1835 // For the messages except WM_MOUSELEAVE, before forwarding them to | 1836 // For the messages except WM_MOUSELEAVE, before forwarding them to |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 } | 2203 } |
2203 | 2204 |
2204 LRESULT RenderWidgetHostViewWin::OnTouchEvent(UINT message, WPARAM wparam, | 2205 LRESULT RenderWidgetHostViewWin::OnTouchEvent(UINT message, WPARAM wparam, |
2205 LPARAM lparam, BOOL& handled) { | 2206 LPARAM lparam, BOOL& handled) { |
2206 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnTouchEvent"); | 2207 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnTouchEvent"); |
2207 // Finish the ongoing composition whenever a touch event happens. | 2208 // Finish the ongoing composition whenever a touch event happens. |
2208 // It matches IE's behavior. | 2209 // It matches IE's behavior. |
2209 if (base::win::IsTSFAwareRequired()) { | 2210 if (base::win::IsTSFAwareRequired()) { |
2210 ui::TSFBridge::GetInstance()->CancelComposition(); | 2211 ui::TSFBridge::GetInstance()->CancelComposition(); |
2211 } else { | 2212 } else { |
2212 imm32_manager_.CleanupComposition(m_hWnd); | 2213 imm32_manager_->CleanupComposition(m_hWnd); |
2213 } | 2214 } |
2214 | 2215 |
2215 // TODO(jschuh): Add support for an arbitrary number of touchpoints. | 2216 // TODO(jschuh): Add support for an arbitrary number of touchpoints. |
2216 size_t total = std::min(static_cast<int>(LOWORD(wparam)), | 2217 size_t total = std::min(static_cast<int>(LOWORD(wparam)), |
2217 static_cast<int>(WebKit::WebTouchEvent::touchesLengthCap)); | 2218 static_cast<int>(WebKit::WebTouchEvent::touchesLengthCap)); |
2218 TOUCHINPUT points[WebKit::WebTouchEvent::touchesLengthCap]; | 2219 TOUCHINPUT points[WebKit::WebTouchEvent::touchesLengthCap]; |
2219 | 2220 |
2220 if (!total || !ui::GetTouchInputInfoWrapper((HTOUCHINPUT)lparam, total, | 2221 if (!total || !ui::GetTouchInputInfoWrapper((HTOUCHINPUT)lparam, total, |
2221 points, sizeof(TOUCHINPUT))) { | 2222 points, sizeof(TOUCHINPUT))) { |
2222 TRACE_EVENT0("browser", "EarlyOut_NothingToDo"); | 2223 TRACE_EVENT0("browser", "EarlyOut_NothingToDo"); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3059 selection_text_.c_str(), len * sizeof(WCHAR)); | 3060 selection_text_.c_str(), len * sizeof(WCHAR)); |
3060 | 3061 |
3061 // According to Microsft API document, IMR_RECONVERTSTRING and | 3062 // According to Microsft API document, IMR_RECONVERTSTRING and |
3062 // IMR_DOCUMENTFEED should return reconv, but some applications return | 3063 // IMR_DOCUMENTFEED should return reconv, but some applications return |
3063 // need_size. | 3064 // need_size. |
3064 return reinterpret_cast<LRESULT>(reconv); | 3065 return reinterpret_cast<LRESULT>(reconv); |
3065 } | 3066 } |
3066 | 3067 |
3067 LRESULT RenderWidgetHostViewWin::OnReconvertString(RECONVERTSTRING* reconv) { | 3068 LRESULT RenderWidgetHostViewWin::OnReconvertString(RECONVERTSTRING* reconv) { |
3068 // If there is a composition string already, we don't allow reconversion. | 3069 // If there is a composition string already, we don't allow reconversion. |
3069 if (imm32_manager_.is_composing()) | 3070 if (imm32_manager_->is_composing()) |
3070 return 0; | 3071 return 0; |
3071 | 3072 |
3072 if (selection_range_.is_empty()) | 3073 if (selection_range_.is_empty()) |
3073 return 0; | 3074 return 0; |
3074 | 3075 |
3075 if (selection_text_.empty()) | 3076 if (selection_text_.empty()) |
3076 return 0; | 3077 return 0; |
3077 | 3078 |
3078 if (selection_range_.GetMin() < selection_text_offset_ || | 3079 if (selection_range_.GetMin() < selection_text_offset_ || |
3079 selection_range_.GetMax() > | 3080 selection_range_.GetMax() > |
(...skipping 29 matching lines...) Expand all Loading... |
3109 } | 3110 } |
3110 | 3111 |
3111 LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( | 3112 LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( |
3112 IMECHARPOSITION* position) { | 3113 IMECHARPOSITION* position) { |
3113 DCHECK(position); | 3114 DCHECK(position); |
3114 | 3115 |
3115 if (position->dwSize < sizeof(IMECHARPOSITION)) | 3116 if (position->dwSize < sizeof(IMECHARPOSITION)) |
3116 return 0; | 3117 return 0; |
3117 | 3118 |
3118 RECT target_rect = {}; | 3119 RECT target_rect = {}; |
3119 if (imm32_manager_.is_composing() && !composition_range_.is_empty() && | 3120 if (imm32_manager_->is_composing() && !composition_range_.is_empty() && |
3120 position->dwCharPos < composition_character_bounds_.size()) { | 3121 position->dwCharPos < composition_character_bounds_.size()) { |
3121 target_rect = | 3122 target_rect = |
3122 composition_character_bounds_[position->dwCharPos].ToRECT(); | 3123 composition_character_bounds_[position->dwCharPos].ToRECT(); |
3123 } else if (position->dwCharPos == 0) { | 3124 } else if (position->dwCharPos == 0) { |
3124 // When there is no on-going composition but |position->dwCharPos| is 0, | 3125 // When there is no on-going composition but |position->dwCharPos| is 0, |
3125 // use the caret rect. This behavior is the same to RichEdit. In fact, | 3126 // use the caret rect. This behavior is the same to RichEdit. In fact, |
3126 // CUAS (Cicero Unaware Application Support) relies on this behavior to | 3127 // CUAS (Cicero Unaware Application Support) relies on this behavior to |
3127 // implement ITfContextView::GetTextExt on top of IMM32-based applications. | 3128 // implement ITfContextView::GetTextExt on top of IMM32-based applications. |
3128 target_rect = caret_rect_.ToRECT(); | 3129 target_rect = caret_rect_.ToRECT(); |
3129 } else { | 3130 } else { |
(...skipping 11 matching lines...) Expand all Loading... |
3141 return 1; | 3142 return 1; |
3142 } | 3143 } |
3143 | 3144 |
3144 void RenderWidgetHostViewWin::UpdateIMEState() { | 3145 void RenderWidgetHostViewWin::UpdateIMEState() { |
3145 if (base::win::IsTSFAwareRequired()) { | 3146 if (base::win::IsTSFAwareRequired()) { |
3146 ui::TSFBridge::GetInstance()->OnTextInputTypeChanged(this); | 3147 ui::TSFBridge::GetInstance()->OnTextInputTypeChanged(this); |
3147 return; | 3148 return; |
3148 } | 3149 } |
3149 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && | 3150 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && |
3150 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { | 3151 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { |
3151 imm32_manager_.EnableIME(m_hWnd); | 3152 imm32_manager_->EnableIME(m_hWnd); |
3152 imm32_manager_.SetUseCompositionWindow(!can_compose_inline_); | 3153 imm32_manager_->SetUseCompositionWindow(!can_compose_inline_); |
3153 } else { | 3154 } else { |
3154 imm32_manager_.DisableIME(m_hWnd); | 3155 imm32_manager_->DisableIME(m_hWnd); |
3155 } | 3156 } |
3156 } | 3157 } |
3157 | 3158 |
3158 void RenderWidgetHostViewWin::UpdateInputScopeIfNecessary( | 3159 void RenderWidgetHostViewWin::UpdateInputScopeIfNecessary( |
3159 ui::TextInputType text_input_type) { | 3160 ui::TextInputType text_input_type) { |
3160 // The text store is responsible for handling input scope when TSF-aware is | 3161 // The text store is responsible for handling input scope when TSF-aware is |
3161 // required. | 3162 // required. |
3162 if (base::win::IsTSFAwareRequired()) | 3163 if (base::win::IsTSFAwareRequired()) |
3163 return; | 3164 return; |
3164 | 3165 |
(...skipping 10 matching lines...) Expand all Loading... |
3175 return new RenderWidgetHostViewWin(widget); | 3176 return new RenderWidgetHostViewWin(widget); |
3176 } | 3177 } |
3177 | 3178 |
3178 // static | 3179 // static |
3179 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3180 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3180 WebKit::WebScreenInfo* results) { | 3181 WebKit::WebScreenInfo* results) { |
3181 GetScreenInfoForWindow(0, results); | 3182 GetScreenInfoForWindow(0, results); |
3182 } | 3183 } |
3183 | 3184 |
3184 } // namespace content | 3185 } // namespace content |
OLD | NEW |