Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: content/browser/renderer_host/render_widget_host.cc

Issue 6974007: Move setToolTipText related functions from RenderView to RenderWidget. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Check tool tip is empty in Mac code. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host.cc
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
index 2ca9173d08d39270bd8f3d1afc4aa4fead9a6deb..17699b9b2d94032c9d3da3d8ec75e372f6a45df5 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"
@@ -166,6 +168,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)
@@ -803,6 +806,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_) {
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698