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

Unified Diff: content/renderer/render_view.cc

Issue 7514013: Enforce the page title direction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ok Created 9 years, 5 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/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view.cc
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 27495c4a5973c5aefcd4ca3b017cb3632f93eaaa..f022b6cfca25be77d7e75d6190c2031e49d24dfe 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -1177,15 +1177,21 @@ void RenderView::UpdateURL(WebFrame* frame) {
}
// Tell the embedding application that the title of the active page has changed
-void RenderView::UpdateTitle(WebFrame* frame, const string16& title) {
- // Ignore all but top level navigations...
- if (!frame->parent()) {
- Send(new ViewHostMsg_UpdateTitle(
- routing_id_,
- page_id_,
- title.length() > content::kMaxTitleChars ?
- title.substr(0, content::kMaxTitleChars) : title));
- }
+void RenderView::UpdateTitle(WebFrame* frame, const string16& title,
+ WebTextDirection title_direction) {
+ // Ignore all but top level navigations.
+ if (frame->parent())
+ return;
+
+ // Insert a direction mark to make the title strongly directional.
+ string16 fixed_title;
+ if (title_direction == WebKit::WebTextDirectionLeftToRight)
+ fixed_title.push_back(0x200E); // U+200E LRM
brettw 2011/07/27 22:28:22 There are consts for these in base/i18n/rtl.h so y
+ else
+ fixed_title.push_back(0x200F); // U+200E RLM
+ fixed_title.append(title.substr(0, content::kMaxTitleChars));
+
+ Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, fixed_title));
}
void RenderView::UpdateEncoding(WebFrame* frame,
@@ -2518,9 +2524,7 @@ void RenderView::didCreateDocumentElement(WebFrame* frame) {
void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title,
WebTextDirection direction) {
- // TODO: pass direction through various APIs.
- // http://code.google.com/p/chromium/issues/detail?id=79903
- UpdateTitle(frame, title);
+ UpdateTitle(frame, title, direction);
// Also check whether we have new encoding name.
UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
@@ -2585,7 +2589,11 @@ void RenderView::didNavigateWithinPage(
didCommitProvisionalLoad(frame, is_new_navigation);
- UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle());
+ // TODO(evan): update this to use ->pageTitleDirection() once we pull in new
+ // WebKit.
+ // http://code.google.com/p/chromium/issues/detail?id=27094
+ UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle(),
+ WebKit::WebTextDirectionLeftToRight);
}
void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) {
« no previous file with comments | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698