summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 11:51:27 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 11:51:27 +0000
commit6c8493c5bf17929c6cd6815e8dc80c5038cbbd29 (patch)
treead69c84e7332b9b51fa72cf8a53bcfea4795924a /chrome/browser/tab_contents
parentdee5464259bc255197d56b250f66ee80b380c2c5 (diff)
downloadchromium_src-6c8493c5bf17929c6cd6815e8dc80c5038cbbd29.zip
chromium_src-6c8493c5bf17929c6cd6815e8dc80c5038cbbd29.tar.gz
chromium_src-6c8493c5bf17929c6cd6815e8dc80c5038cbbd29.tar.bz2
WebKit side is in https://bugs.webkit.org/show_bug.cgi?id=34524
BUG=NONE TEST=Right clicking on a text input field in Web content on OS X should now show a Writing Direction submenu. Clicking on "Left To Right" should align the input to the left, and "Right To Left" should do the opposit. The "Default" menu item should always be disabled. Review URL: http://codereview.chromium.org/566031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc63
1 files changed, 62 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 039b245..a9cc073 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -34,8 +34,9 @@
#include "net/base/escape.h"
#include "net/url_request/url_request.h"
#include "webkit/glue/webmenuitem.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h"
#include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h"
using WebKit::WebContextMenuData;
using WebKit::WebMediaPlayerAction;
@@ -337,6 +338,25 @@ void RenderViewContextMenu::AppendEditableItems() {
}
FinishSubMenu();
+#if defined(OS_MACOSX)
+ // OS X provides a contextual menu to set writing direction for BiDi
+ // languages.
+ // This functionality is exposed as a keyboard shortcut on Windows & Linux.
+
+ // Add writing direction sub menu.
+ StartSubMenu(IDC_WRITING_DIRECTION_MENU,
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU));
+
+ AppendCheckboxMenuItem(IDC_WRITING_DIRECTION_DEFAULT,
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT));
+ AppendCheckboxMenuItem(IDC_WRITING_DIRECTION_LTR,
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR));
+ AppendCheckboxMenuItem(IDC_WRITING_DIRECTION_RTL,
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL));
+
+ FinishSubMenu();
+#endif // OS_MACOSX
+
AppendSeparator();
AppendMenuItem(IDS_CONTENT_CONTEXT_SELECTALL);
}
@@ -512,6 +532,18 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const {
case IDC_CHECK_SPELLING_OF_THIS_FIELD:
return profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck);
+#if defined(OS_MACOSX)
+ case IDC_WRITING_DIRECTION_DEFAULT: // Provided to match OS defaults.
+ return params_.writing_direction_default &
+ WebContextMenuData::CheckableMenuItemEnabled;
+ case IDC_WRITING_DIRECTION_RTL:
+ return params_.writing_direction_right_to_left &
+ WebContextMenuData::CheckableMenuItemEnabled;
+ case IDC_WRITING_DIRECTION_LTR:
+ return params_.writing_direction_left_to_right &
+ WebContextMenuData::CheckableMenuItemEnabled;
+#endif // OS_MACOSX
+
#if defined(OS_LINUX)
// Enable the input methods context menu if the content is editable.
// TODO(suzhe): It should not be enabled in password boxes. Anyway,
@@ -535,6 +567,18 @@ bool RenderViewContextMenu::ItemIsChecked(int id) const {
WebContextMenuData::MediaLoop) != 0;
}
+#if defined(OS_MACOSX)
+ if (id == IDC_WRITING_DIRECTION_DEFAULT)
+ return params_.writing_direction_default &
+ WebContextMenuData::CheckableMenuItemChecked;
+ if (id == IDC_WRITING_DIRECTION_RTL)
+ return params_.writing_direction_right_to_left &
+ WebContextMenuData::CheckableMenuItemChecked;
+ if (id == IDC_WRITING_DIRECTION_LTR)
+ return params_.writing_direction_left_to_right &
+ WebContextMenuData::CheckableMenuItemChecked;
+#endif // OS_MACOSX
+
// Check box for 'Check the Spelling of this field'.
if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) {
return (params_.spellcheck_enabled &&
@@ -816,6 +860,23 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) {
source_tab_contents_->render_view_host()->ToggleSpellPanel(
SpellCheckerPlatform::SpellingPanelVisible());
break;
+
+#if defined(OS_MACOSX)
+ case IDC_WRITING_DIRECTION_DEFAULT:
+ // WebKit's current behavior is for this menu item to always be disabled.
+ NOTREACHED();
+ break;
+ case IDC_WRITING_DIRECTION_RTL:
+ case IDC_WRITING_DIRECTION_LTR: {
+ WebKit::WebTextDirection dir = WebKit::WebTextDirectionLeftToRight;
+ if (id == IDC_WRITING_DIRECTION_RTL)
+ dir = WebKit::WebTextDirectionRightToLeft;
+ source_tab_contents_->render_view_host()->UpdateTextDirection(dir);
+ source_tab_contents_->render_view_host()->NotifyTextDirection();
+ break;
+ }
+#endif // OS_MACOSX
+
case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented.
default:
break;