| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, | 645 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, |
| 646 OnMsgDidChangeLoadProgress) | 646 OnMsgDidChangeLoadProgress) |
| 647 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 647 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
| 648 OnMsgDocumentAvailableInMainFrame) | 648 OnMsgDocumentAvailableInMainFrame) |
| 649 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, | 649 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, |
| 650 OnMsgDocumentOnLoadCompletedInMainFrame) | 650 OnMsgDocumentOnLoadCompletedInMainFrame) |
| 651 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) | 651 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) |
| 652 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) | 652 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) |
| 653 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 653 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
| 654 OnMsgDidContentsPreferredSizeChange) | 654 OnMsgDidContentsPreferredSizeChange) |
| 655 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | |
| 656 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 655 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
| 657 OnMsgRunJavaScriptMessage) | 656 OnMsgRunJavaScriptMessage) |
| 658 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 657 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
| 659 OnMsgRunBeforeUnloadConfirm) | 658 OnMsgRunBeforeUnloadConfirm) |
| 660 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 659 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
| 661 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 660 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
| 662 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 661 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 663 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 662 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 664 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 663 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
| 665 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) | 664 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 } | 949 } |
| 951 | 950 |
| 952 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( | 951 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( |
| 953 const gfx::Size& new_size) { | 952 const gfx::Size& new_size) { |
| 954 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 953 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 955 if (!view) | 954 if (!view) |
| 956 return; | 955 return; |
| 957 view->UpdatePreferredSize(new_size); | 956 view->UpdatePreferredSize(new_size); |
| 958 } | 957 } |
| 959 | 958 |
| 960 void RenderViewHost::OnMsgSetTooltipText( | |
| 961 const std::wstring& tooltip_text, | |
| 962 WebTextDirection text_direction_hint) { | |
| 963 // First, add directionality marks around tooltip text if necessary. | |
| 964 // A naive solution would be to simply always wrap the text. However, on | |
| 965 // windows, Unicode directional embedding characters can't be displayed on | |
| 966 // systems that lack RTL fonts and are instead displayed as empty squares. | |
| 967 // | |
| 968 // To get around this we only wrap the string when we deem it necessary i.e. | |
| 969 // when the locale direction is different than the tooltip direction hint. | |
| 970 // | |
| 971 // Currently, we use element's directionality as the tooltip direction hint. | |
| 972 // An alternate solution would be to set the overall directionality based on | |
| 973 // trying to detect the directionality from the tooltip text rather than the | |
| 974 // element direction. One could argue that would be a preferable solution | |
| 975 // but we use the current approach to match Fx & IE's behavior. | |
| 976 string16 wrapped_tooltip_text = WideToUTF16(tooltip_text); | |
| 977 if (!tooltip_text.empty()) { | |
| 978 if (text_direction_hint == WebKit::WebTextDirectionLeftToRight) { | |
| 979 // Force the tooltip to have LTR directionality. | |
| 980 wrapped_tooltip_text = | |
| 981 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_tooltip_text); | |
| 982 } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && | |
| 983 !base::i18n::IsRTL()) { | |
| 984 // Force the tooltip to have RTL directionality. | |
| 985 base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); | |
| 986 } | |
| 987 } | |
| 988 if (view()) | |
| 989 view()->SetTooltipText(UTF16ToWide(wrapped_tooltip_text)); | |
| 990 } | |
| 991 | |
| 992 void RenderViewHost::OnMsgSelectionChanged(const std::string& text, | 959 void RenderViewHost::OnMsgSelectionChanged(const std::string& text, |
| 993 const ui::Range& range) { | 960 const ui::Range& range) { |
| 994 if (view()) | 961 if (view()) |
| 995 view()->SelectionChanged(text, range); | 962 view()->SelectionChanged(text, range); |
| 996 } | 963 } |
| 997 | 964 |
| 998 void RenderViewHost::OnMsgRunJavaScriptMessage( | 965 void RenderViewHost::OnMsgRunJavaScriptMessage( |
| 999 const std::wstring& message, | 966 const std::wstring& message, |
| 1000 const std::wstring& default_prompt, | 967 const std::wstring& default_prompt, |
| 1001 const GURL& frame_url, | 968 const GURL& frame_url, |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 if (view) { | 1246 if (view) { |
| 1280 view->ShowPopupMenu(params.bounds, | 1247 view->ShowPopupMenu(params.bounds, |
| 1281 params.item_height, | 1248 params.item_height, |
| 1282 params.item_font_size, | 1249 params.item_font_size, |
| 1283 params.selected_item, | 1250 params.selected_item, |
| 1284 params.popup_items, | 1251 params.popup_items, |
| 1285 params.right_aligned); | 1252 params.right_aligned); |
| 1286 } | 1253 } |
| 1287 } | 1254 } |
| 1288 #endif | 1255 #endif |
| OLD | NEW |