diff options
author | Takano.Naoki@gmail.com <Takano.Naoki@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-06 20:11:30 +0000 |
---|---|---|
committer | Takano.Naoki@gmail.com <Takano.Naoki@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-06 20:11:30 +0000 |
commit | 8a9d6ca390c8f43be8e628f047f9140961ba0a79 (patch) | |
tree | f09a9a6309ab8da008d2d49718ce66ae914d9ad2 /content | |
parent | 136ed86f1ff3aee773a73ba1887d5166509d5dab (diff) | |
download | chromium_src-8a9d6ca390c8f43be8e628f047f9140961ba0a79.zip chromium_src-8a9d6ca390c8f43be8e628f047f9140961ba0a79.tar.gz chromium_src-8a9d6ca390c8f43be8e628f047f9140961ba0a79.tar.bz2 |
Move setToolTipText related functions from RenderView to RenderWidget.
WebPopupMenuImpl is derived from WebKit::WebWidget, not WebKit::WebView. So to call setToolTipText() function, we have to move the function from WebKit::WebWidget to WebKit::WebView. This change also includes WebKit change.
https://bugs.webkit.org/show_bug.cgi?id=61260
BUG=12721
TEST=1, Make html file in BUT=12721. 2, Make sure tooptip is shown.
Review URL: http://codereview.chromium.org/6974007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/render_view_host.cc | 33 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host.h | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.cc | 35 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.h | 2 | ||||
-rw-r--r-- | content/common/view_messages.h | 1 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 5 | ||||
-rw-r--r-- | content/renderer/render_view.h | 2 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 8 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 2 |
9 files changed, 48 insertions, 42 deletions
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 8c47c98..dd935bb 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -651,7 +651,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, OnMsgDidContentsPreferredSizeChange) - IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, OnMsgRunJavaScriptMessage) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, @@ -948,38 +947,6 @@ void RenderViewHost::OnMsgDidContentsPreferredSizeChange( view->UpdatePreferredSize(new_size); } -void RenderViewHost::OnMsgSetTooltipText( - const std::wstring& tooltip_text, - WebTextDirection text_direction_hint) { - // First, add directionality marks around tooltip text if necessary. - // A naive solution would be to simply always wrap the text. However, on - // windows, Unicode directional embedding characters can't be displayed on - // systems that lack RTL fonts and are instead displayed as empty squares. - // - // To get around this we only wrap the string when we deem it necessary i.e. - // when the locale direction is different than the tooltip direction hint. - // - // Currently, we use element's directionality as the tooltip direction hint. - // An alternate solution would be to set the overall directionality based on - // trying to detect the directionality from the tooltip text rather than the - // element direction. One could argue that would be a preferable solution - // but we use the current approach to match Fx & IE's behavior. - string16 wrapped_tooltip_text = WideToUTF16(tooltip_text); - if (!tooltip_text.empty()) { - if (text_direction_hint == WebKit::WebTextDirectionLeftToRight) { - // Force the tooltip to have LTR directionality. - wrapped_tooltip_text = - base::i18n::GetDisplayStringInLTRDirectionality(wrapped_tooltip_text); - } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && - !base::i18n::IsRTL()) { - // Force the tooltip to have RTL directionality. - base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); - } - } - if (view()) - view()->SetTooltipText(UTF16ToWide(wrapped_tooltip_text)); -} - void RenderViewHost::OnMsgSelectionChanged(const std::string& text, const ui::Range& range) { if (view()) diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index 8a63bd4..34aa17e 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -414,8 +414,6 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); void OnMsgDidContentsPreferredSizeChange(const gfx::Size& new_size); - void OnMsgSetTooltipText(const std::wstring& tooltip_text, - WebKit::WebTextDirection text_direction_hint); void OnMsgSelectionChanged(const std::string& text, const ui::Range& range); void OnMsgPasteFromSelectionClipboard(); void OnMsgRunJavaScriptMessage(const string16& message, diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 670e50f..9af103c 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -7,8 +7,10 @@ #include "base/auto_reset.h" #include "base/command_line.h" #include "base/debug/trace_event.h" +#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/common/chrome_switches.h" #include "content/browser/gpu/gpu_process_host.h" @@ -156,6 +158,7 @@ bool RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) + IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) @@ -788,6 +791,38 @@ void RenderWidgetHost::OnMsgClose() { Shutdown(); } +void RenderWidgetHost::OnMsgSetTooltipText( + const std::wstring& tooltip_text, + WebTextDirection text_direction_hint) { + // First, add directionality marks around tooltip text if necessary. + // A naive solution would be to simply always wrap the text. However, on + // windows, Unicode directional embedding characters can't be displayed on + // systems that lack RTL fonts and are instead displayed as empty squares. + // + // To get around this we only wrap the string when we deem it necessary i.e. + // when the locale direction is different than the tooltip direction hint. + // + // Currently, we use element's directionality as the tooltip direction hint. + // An alternate solution would be to set the overall directionality based on + // trying to detect the directionality from the tooltip text rather than the + // element direction. One could argue that would be a preferable solution + // but we use the current approach to match Fx & IE's behavior. + string16 wrapped_tooltip_text = WideToUTF16(tooltip_text); + if (!tooltip_text.empty()) { + if (text_direction_hint == WebKit::WebTextDirectionLeftToRight) { + // Force the tooltip to have LTR directionality. + wrapped_tooltip_text = + base::i18n::GetDisplayStringInLTRDirectionality(wrapped_tooltip_text); + } else if (text_direction_hint == WebKit::WebTextDirectionRightToLeft && + !base::i18n::IsRTL()) { + // Force the tooltip to have RTL directionality. + base::i18n::WrapStringWithRTLFormatting(&wrapped_tooltip_text); + } + } + if (view()) + view()->SetTooltipText(UTF16ToWide(wrapped_tooltip_text)); +} + void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { // Note that we ignore the position. if (view_) { diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index e610958..1bf0ca7 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -446,6 +446,8 @@ class RenderWidgetHost : public IPC::Channel::Listener, void OnMsgRenderViewGone(int status, int error_code); void OnMsgClose(); void OnMsgRequestMove(const gfx::Rect& pos); + void OnMsgSetTooltipText(const std::wstring& tooltip_text, + WebKit::WebTextDirection text_direction_hint); void OnMsgPaintAtSizeAck(int tag, const gfx::Size& size); void OnMsgUpdateRect(const ViewHostMsg_UpdateRect_Params& params); void OnMsgInputEventAck(const IPC::Message& message); diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 7f828b2..b559bfb 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -331,6 +331,7 @@ IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(WebMenuItem) IPC_STRUCT_TRAITS_MEMBER(label) + IPC_STRUCT_TRAITS_MEMBER(toolTip) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(action) IPC_STRUCT_TRAITS_MEMBER(rtl) diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 048da27..423c799 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -1683,11 +1683,6 @@ void RenderView::setKeyboardFocusURL(const WebURL& url) { UpdateTargetURL(focus_url_, mouse_over_url_); } -void RenderView::setToolTipText(const WebString& text, WebTextDirection hint) { - Send(new ViewHostMsg_SetTooltipText(routing_id_, UTF16ToWideHack(text), - hint)); -} - void RenderView::startDragging(const WebDragData& data, WebDragOperationsMask mask, const WebImage& image, diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index 2db3e1f..816e849 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -404,8 +404,6 @@ class RenderView : public RenderWidget, virtual void setStatusText(const WebKit::WebString& text); virtual void setMouseOverURL(const WebKit::WebURL& url); virtual void setKeyboardFocusURL(const WebKit::WebURL& url); - virtual void setToolTipText(const WebKit::WebString& text, - WebKit::WebTextDirection hint); virtual void startDragging(const WebKit::WebDragData& data, WebKit::WebDragOperationsMask mask, const WebKit::WebImage& image, diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 6e41354..f02b920 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -10,6 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" +#include "base/utf_string_conversions.h" #include "build/build_config.h" #include "content/common/content_switches.h" #include "content/common/swapped_out_messages.h" @@ -27,6 +28,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "ui/gfx/point.h" #include "ui/gfx/size.h" #include "ui/gfx/surface/transport_dib.h" @@ -1012,6 +1014,12 @@ WebRect RenderWidget::windowRect() { return rect; } +void RenderWidget::setToolTipText(const WebKit::WebString& text, + WebTextDirection hint) { + Send(new ViewHostMsg_SetTooltipText(routing_id_, UTF16ToWideHack(text), + hint)); +} + void RenderWidget::setWindowRect(const WebRect& pos) { if (did_show_) { Send(new ViewHostMsg_RequestMove(routing_id_, pos)); diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 199f168..d48c336 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -113,6 +113,8 @@ class RenderWidget : public IPC::Channel::Listener, virtual void show(WebKit::WebNavigationPolicy); virtual void runModal() {} virtual WebKit::WebRect windowRect(); + virtual void setToolTipText(const WebKit::WebString& text, + WebKit::WebTextDirection hint); virtual void setWindowRect(const WebKit::WebRect&); virtual WebKit::WebRect windowResizerRect(); virtual WebKit::WebRect rootWindowRect(); |