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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 6020017: Mac: Enable "Check Spelling While Typing" in Edit menu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <QuartzCore/QuartzCore.h> 5 #include <QuartzCore/QuartzCore.h>
6 6
7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 #include "app/app_switches.h" 9 #include "app/app_switches.h"
10 #include "app/surface/io_surface_support_mac.h" 10 #include "app/surface/io_surface_support_mac.h"
(...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 1900
1901 // For now, these actions are always enabled for render view, 1901 // For now, these actions are always enabled for render view,
1902 // this is sub-optimal. 1902 // this is sub-optimal.
1903 // TODO(suzhe): Plumb the "can*" methods up from WebCore. 1903 // TODO(suzhe): Plumb the "can*" methods up from WebCore.
1904 if (action == @selector(undo:) || 1904 if (action == @selector(undo:) ||
1905 action == @selector(redo:) || 1905 action == @selector(redo:) ||
1906 action == @selector(cut:) || 1906 action == @selector(cut:) ||
1907 action == @selector(copy:) || 1907 action == @selector(copy:) ||
1908 action == @selector(copyToFindPboard:) || 1908 action == @selector(copyToFindPboard:) ||
1909 action == @selector(paste:) || 1909 action == @selector(paste:) ||
1910 action == @selector(pasteAsPlainText:)) { 1910 action == @selector(pasteAsPlainText:) ||
1911 action == @selector(checkSpelling:)) {
1911 return renderWidgetHostView_->render_widget_host_->IsRenderView(); 1912 return renderWidgetHostView_->render_widget_host_->IsRenderView();
1912 } 1913 }
1913 1914
1915 if (action == @selector(toggleContinuousSpellChecking:)) {
1916 RenderViewHost::CommandState state;
1917 state.is_enabled = false;
1918 state.checked_state = 0;
1919 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
1920 state = static_cast<RenderViewHost*>(
1921 renderWidgetHostView_->render_widget_host_)->
brettw 2011/01/09 00:06:06 Ditto for 4 space indents (below as well).
sail 2011/01/12 01:26:36 Done.
1922 GetStateForCommand("ToggleSpellCheck");
1923 }
1924 if ([(id)item respondsToSelector:@selector(setState:)]) {
1925 NSCellStateValue checked_state;
1926 switch (state.checked_state) {
1927 case 0:
1928 checked_state = NSOffState;
1929 break;
1930 case 1:
1931 checked_state = NSOnState;
1932 break;
1933 case -1:
1934 checked_state = NSMixedState;
1935 break;
1936 default:
1937 checked_state = NSOffState;
1938 break;
1939 }
1940 [(id)item setState:checked_state];
1941 }
1942 return state.is_enabled;
1943 }
1944
1914 return editCommand_helper_->IsMenuItemEnabled(action, self); 1945 return editCommand_helper_->IsMenuItemEnabled(action, self);
1915 } 1946 }
1916 1947
1917 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac { 1948 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac {
1918 return renderWidgetHostView_.get(); 1949 return renderWidgetHostView_.get();
1919 } 1950 }
1920 1951
1921 // Determine whether we should autohide the cursor (i.e., hide it until mouse 1952 // Determine whether we should autohide the cursor (i.e., hide it until mouse
1922 // move) for the given event. Customize here to be more selective about which 1953 // move) for the given event. Customize here to be more selective about which
1923 // key presses to autohide on. 1954 // key presses to autohide on.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 base::SysNSStringToUTF16(newWord)); 2086 base::SysNSStringToUTF16(newWord));
2056 } 2087 }
2057 } 2088 }
2058 2089
2059 // This message is sent by NSSpellChecker whenever the next word should be 2090 // This message is sent by NSSpellChecker whenever the next word should be
2060 // advanced to, either after a correction or clicking the "Find Next" button. 2091 // advanced to, either after a correction or clicking the "Find Next" button.
2061 // This isn't documented anywhere useful, like in NSSpellProtocol.h with the 2092 // This isn't documented anywhere useful, like in NSSpellProtocol.h with the
2062 // other spelling panel methods. This is probably because Apple assumes that the 2093 // other spelling panel methods. This is probably because Apple assumes that the
2063 // the spelling panel will be used with an NSText, which will automatically 2094 // the spelling panel will be used with an NSText, which will automatically
2064 // catch this and advance to the next word for you. Thanks Apple. 2095 // catch this and advance to the next word for you. Thanks Apple.
2096 // This is also called from the Edit -> Spelling -> Check Spelling menu item.
2065 - (void)checkSpelling:(id)sender { 2097 - (void)checkSpelling:(id)sender {
2066 RenderWidgetHostViewMac* thisHostView = [self renderWidgetHostViewMac]; 2098 RenderWidgetHostViewMac* thisHostView = [self renderWidgetHostViewMac];
2067 thisHostView->GetRenderWidgetHost()->AdvanceToNextMisspelling(); 2099 thisHostView->GetRenderWidgetHost()->AdvanceToNextMisspelling();
2068 } 2100 }
2069 2101
2070 // This message is sent by the spelling panel whenever a word is ignored. 2102 // This message is sent by the spelling panel whenever a word is ignored.
2071 - (void)ignoreSpelling:(id)sender { 2103 - (void)ignoreSpelling:(id)sender {
2072 // Ideally, we would ask the current RenderView for its tag, but that would 2104 // Ideally, we would ask the current RenderView for its tag, but that would
2073 // mean making a blocking IPC call from the browser. Instead, 2105 // mean making a blocking IPC call from the browser. Instead,
2074 // SpellCheckerPlatform::CheckSpelling remembers the last tag and 2106 // SpellCheckerPlatform::CheckSpelling remembers the last tag and
2075 // SpellCheckerPlatform::IgnoreWord assumes that is the correct tag. 2107 // SpellCheckerPlatform::IgnoreWord assumes that is the correct tag.
2076 NSString* wordToIgnore = [sender stringValue]; 2108 NSString* wordToIgnore = [sender stringValue];
2077 if (wordToIgnore != nil) 2109 if (wordToIgnore != nil)
2078 SpellCheckerPlatform::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); 2110 SpellCheckerPlatform::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore));
2079 } 2111 }
2080 2112
2081 - (void)showGuessPanel:(id)sender { 2113 - (void)showGuessPanel:(id)sender {
2082 RenderWidgetHostViewMac* thisHostView = [self renderWidgetHostViewMac]; 2114 RenderWidgetHostViewMac* thisHostView = [self renderWidgetHostViewMac];
2083 thisHostView->GetRenderWidgetHost()->ToggleSpellPanel( 2115 thisHostView->GetRenderWidgetHost()->ToggleSpellPanel(
2084 SpellCheckerPlatform::SpellingPanelVisible()); 2116 SpellCheckerPlatform::SpellingPanelVisible());
2085 } 2117 }
2086 2118
2119 - (void)toggleContinuousSpellChecking:(id)sender {
2120 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
2121 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
2122 ToggleSpellCheck();
2123 }
2124 }
2125
2087 // END Spellchecking methods 2126 // END Spellchecking methods
2088 2127
2089 // Below is the nasty tooltip stuff -- copied from WebKit's WebHTMLView.mm 2128 // Below is the nasty tooltip stuff -- copied from WebKit's WebHTMLView.mm
2090 // with minor modifications for code style and commenting. 2129 // with minor modifications for code style and commenting.
2091 // 2130 //
2092 // The 'public' interface is -setToolTipAtMousePoint:. This differs from 2131 // The 'public' interface is -setToolTipAtMousePoint:. This differs from
2093 // -setToolTip: in that the updated tooltip takes effect immediately, 2132 // -setToolTip: in that the updated tooltip takes effect immediately,
2094 // without the user's having to move the mouse out of and back into the view. 2133 // without the user's having to move the mouse out of and back into the view.
2095 // 2134 //
2096 // Unfortunately, doing this requires sending fake mouseEnter/Exit events to 2135 // Unfortunately, doing this requires sending fake mouseEnter/Exit events to
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 if (!string) return NO; 2764 if (!string) return NO;
2726 2765
2727 // If the user is currently using an IME, confirm the IME input, 2766 // If the user is currently using an IME, confirm the IME input,
2728 // and then insert the text from the service, the same as TextEdit and Safari. 2767 // and then insert the text from the service, the same as TextEdit and Safari.
2729 [self confirmComposition]; 2768 [self confirmComposition];
2730 [self insertText:string]; 2769 [self insertText:string];
2731 return YES; 2770 return YES;
2732 } 2771 }
2733 2772
2734 @end 2773 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698