| 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_view_host.h" | 5 #include "content/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, | 650 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, |
| 651 OnMsgDidChangeLoadProgress) | 651 OnMsgDidChangeLoadProgress) |
| 652 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 652 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
| 653 OnMsgDocumentAvailableInMainFrame) | 653 OnMsgDocumentAvailableInMainFrame) |
| 654 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, | 654 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, |
| 655 OnMsgDocumentOnLoadCompletedInMainFrame) | 655 OnMsgDocumentOnLoadCompletedInMainFrame) |
| 656 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) | 656 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) |
| 657 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) | 657 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) |
| 658 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 658 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
| 659 OnMsgDidContentsPreferredSizeChange) | 659 OnMsgDidContentsPreferredSizeChange) |
| 660 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | |
| 661 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 660 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
| 662 OnMsgRunJavaScriptMessage) | 661 OnMsgRunJavaScriptMessage) |
| 663 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 662 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
| 664 OnMsgRunBeforeUnloadConfirm) | 663 OnMsgRunBeforeUnloadConfirm) |
| 665 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 664 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
| 666 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 665 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
| 667 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 666 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 668 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 667 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 669 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 668 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
| 670 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) | 669 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 } | 953 } |
| 955 | 954 |
| 956 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( | 955 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( |
| 957 const gfx::Size& new_size) { | 956 const gfx::Size& new_size) { |
| 958 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 957 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 959 if (!view) | 958 if (!view) |
| 960 return; | 959 return; |
| 961 view->UpdatePreferredSize(new_size); | 960 view->UpdatePreferredSize(new_size); |
| 962 } | 961 } |
| 963 | 962 |
| 964 void RenderViewHost::OnMsgSetTooltipText( | |
| 965 const std::wstring& tooltip_text, | |
| 966 WebTextDirection text_direction_hint) { | |
| 967 // First, add directionality marks around tooltip text if necessary. | |
| 968 // A naive solution would be to simply always wrap the text. However, on | |
| 969 // windows, Unicode directional embedding characters can't be displayed on | |
| 970 // systems that lack RTL fonts and are instead displayed as empty squares. | |
| 971 // | |
| 972 // To get around this we only wrap the string when we deem it necessary i.e. | |
| 973 // when the locale direction is different than the tooltip direction hint. | |
| 974 // | |
| 975 // Currently, we use element's directionality as the tooltip direction hint. | |
| 976 // An alternate solution would be to set the overall directionality based on | |
| 977 // trying to detect the directionality from the tooltip text rather than the | |
| 978 // element direction. One could argue that would be a preferable solution | |
| 979 // but we use the current approach to match Fx & IE's behavior. | |
| 980 string16 wrapped_tooltip_text = WideToUTF16(tooltip_text); | |
| 981 if (!tooltip_text.empty()) { | |
| 982 if (text_direction_hint == WebKit::WebTextDirectionLeftToRight) { | |
| 983 // Force the tooltip to have LTR directionality. | |
| 984 wrapped_tooltip_text = | |
| 985 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_tooltip_text); | |
| 986 } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && | |
| 987 !base::i18n::IsRTL()) { | |
| 988 // Force the tooltip to have RTL directionality. | |
| 989 base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); | |
| 990 } | |
| 991 } | |
| 992 if (view()) | |
| 993 view()->SetTooltipText(UTF16ToWide(wrapped_tooltip_text)); | |
| 994 } | |
| 995 | |
| 996 void RenderViewHost::OnMsgSelectionChanged(const std::string& text, | 963 void RenderViewHost::OnMsgSelectionChanged(const std::string& text, |
| 997 const ui::Range& range) { | 964 const ui::Range& range) { |
| 998 if (view()) | 965 if (view()) |
| 999 view()->SelectionChanged(text, range); | 966 view()->SelectionChanged(text, range); |
| 1000 } | 967 } |
| 1001 | 968 |
| 1002 void RenderViewHost::OnMsgRunJavaScriptMessage( | 969 void RenderViewHost::OnMsgRunJavaScriptMessage( |
| 1003 const std::wstring& message, | 970 const std::wstring& message, |
| 1004 const std::wstring& default_prompt, | 971 const std::wstring& default_prompt, |
| 1005 const GURL& frame_url, | 972 const GURL& frame_url, |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 if (view) { | 1228 if (view) { |
| 1262 view->ShowPopupMenu(params.bounds, | 1229 view->ShowPopupMenu(params.bounds, |
| 1263 params.item_height, | 1230 params.item_height, |
| 1264 params.item_font_size, | 1231 params.item_font_size, |
| 1265 params.selected_item, | 1232 params.selected_item, |
| 1266 params.popup_items, | 1233 params.popup_items, |
| 1267 params.right_aligned); | 1234 params.right_aligned); |
| 1268 } | 1235 } |
| 1269 } | 1236 } |
| 1270 #endif | 1237 #endif |
| OLD | NEW |