Commit 08b0dcea authored by bdakin's avatar bdakin

WebCore:

        Reviewed by Adam.

        Primarily, this patch implements/hooks-up actions for the sub-menu
        items in WebCore context menus. I fixed a few other things along
        the way too:
                -Made BUILDING_ON_TIGER ifdef work within C++ as well as
                 Obj-C
                -Fixed bug where we would throw and Obj-C exception and
                 fail to pop up menus with more than one separator item.
                -Re-named some of the spelling/grammar tags since Tiger and
                 Leopard share more of the actions than initially
                 anticipated.

        * WebCorePrefix.h: Make BUILDING_ON_TIGER available to C++
        * bridge/EditorClient.h: New functions to toggle
        spelling/grammar checking.
        * editing/Editor.cpp:
        (WebCore::Editor::toggleContinuousSpellChecking): Call into client.
        (WebCore::Editor::toggleGrammarChecking): Same.
        (WebCore::Editor::toggleBold): call execToggleBold()
        (WebCore::Editor::toggleUnderline): Create appropriate underline
        style and apply to selection.
        (WebCore::Editor::setBaseWritingDirection): Create appropriate
        writing direction and apply to selection.
        * editing/Editor.h:
        * editing/mac/EditorMac.mm: New functions to show spelling guesses,
        fonts, styles, and color panels.
        * page/ContextMenuClient.h: New functions for the speech sub-menu.
        * page/ContextMenuController.cpp:
        (WebCore::ContextMenuController::contextMenuItemSelected): Fill in
        editing sub-menu actions.
        * platform/ContextMenu.cpp:
        (WebCore::separatorItem): Helper function to create a separator 
        item.
        (WebCore::createFontSubMenu): Put very mac-specific things within a
        platform ifdef.
        (WebCore::createSpellingAndGrammarSubMenu): Re-named some of the
        spelling sub-menu tags.
        (WebCore::createSpellingSubMenu): Same.
        (WebCore::ContextMenu::populate): We can't share the separator
        item. When we do, menus with more than one separator throw and obj-
        c exception and fail to pop-up.
        * platform/ContextMenuItem.h:
        (WebCore::): Re-named some of the spelling sub-menu tags.

WebKit:
        Reviewed by Adam.

        WebKit support for editing sub-menu actions.

        * WebCoreSupport/WebContextMenuClient.h: New functions for the
        speech sub-menu.
        * WebCoreSupport/WebContextMenuClient.mm:
        (WebContextMenuClient::speak):
        (WebContextMenuClient::stopSpeaking):
        * WebCoreSupport/WebEditorClient.h: New functions to toggle
        spelling/grammar checking.
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::toggleContinuousSpellChecking):
        (WebEditorClient::toggleGrammarChecking):
        * WebView/WebUIDelegatePrivate.h: Re-named some of the spelling
        sub-menu tags.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@18166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 304a9583
2006-12-11 Beth Dakin <bdakin@apple.com>
Reviewed by Adam.
Primarily, this patch implements/hooks-up actions for the sub-menu
items in WebCore context menus. I fixed a few other things along
the way too:
-Made BUILDING_ON_TIGER ifdef work within C++ as well as
Obj-C
-Fixed bug where we would throw and Obj-C exception and
fail to pop up menus with more than one separator item.
-Re-named some of the spelling/grammar tags since Tiger and
Leopard share more of the actions than initially
anticipated.
* WebCorePrefix.h: Make BUILDING_ON_TIGER available to C++
* bridge/EditorClient.h: New functions to toggle
spelling/grammar checking.
* editing/Editor.cpp:
(WebCore::Editor::toggleContinuousSpellChecking): Call into client.
(WebCore::Editor::toggleGrammarChecking): Same.
(WebCore::Editor::toggleBold): call execToggleBold()
(WebCore::Editor::toggleUnderline): Create appropriate underline
style and apply to selection.
(WebCore::Editor::setBaseWritingDirection): Create appropriate
writing direction and apply to selection.
* editing/Editor.h:
* editing/mac/EditorMac.mm: New functions to show spelling guesses,
fonts, styles, and color panels.
* page/ContextMenuClient.h: New functions for the speech sub-menu.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected): Fill in
editing sub-menu actions.
* platform/ContextMenu.cpp:
(WebCore::separatorItem): Helper function to create a separator
item.
(WebCore::createFontSubMenu): Put very mac-specific things within a
platform ifdef.
(WebCore::createSpellingAndGrammarSubMenu): Re-named some of the
spelling sub-menu tags.
(WebCore::createSpellingSubMenu): Same.
(WebCore::ContextMenu::populate): We can't share the separator
item. When we do, menus with more than one separator throw and obj-
c exception and fail to pop-up.
* platform/ContextMenuItem.h:
(WebCore::): Re-named some of the spelling sub-menu tags.
2006-12-11 Alice Liu <alice.liu@apple.com>
Reviewed by Geoff, Adam.
......@@ -85,14 +85,14 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
#define BUILDING_ON_TIGER 1
#endif
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
#ifdef __cplusplus
......
......@@ -51,9 +51,11 @@ public:
virtual bool shouldDeleteRange(Range*) = 0;
virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
virtual bool smartInsertDeleteEnabled() = 0;
virtual bool smartInsertDeleteEnabled() = 0;
virtual bool isContinuousSpellCheckingEnabled() = 0;
virtual void toggleContinuousSpellChecking() = 0;
virtual bool isGrammarCheckingEnabled() = 0;
virtual void toggleGrammarChecking() = 0;
virtual int spellCheckerDocumentTag() = 0;
virtual bool selectWordBeforeMenuEvent() = 0;
......
......@@ -1082,6 +1082,12 @@ bool Editor::isContinuousSpellCheckingEnabled()
return false;
}
void Editor::toggleContinuousSpellChecking()
{
if (client())
client()->toggleContinuousSpellChecking();
}
bool Editor::isGrammarCheckingEnabled()
{
if (client())
......@@ -1089,6 +1095,12 @@ bool Editor::isGrammarCheckingEnabled()
return false;
}
void Editor::toggleGrammarChecking()
{
if (client())
client()->toggleGrammarChecking();
}
int Editor::spellCheckerDocumentTag()
{
if (client())
......@@ -1154,4 +1166,29 @@ void Editor::didEndEditing()
client()->didEndEditing();
}
void Editor::toggleBold()
{
execToggleBold(frame());
}
void Editor::toggleUnderline()
{
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame()->document()->createCSSStyleDeclaration();
style->setProperty(CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, "underline", false, ec);
if (selectionStartHasStyle(style.get()))
style->setProperty(CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, "none", false, ec);
applyStyleToSelection(style.get(), EditActionUnderline);
}
void Editor::setBaseWritingDirection(String direction)
{
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame()->document()->createCSSStyleDeclaration();
style->setProperty(CSS_PROP_DIRECTION, direction, false, ec);
applyParagraphStyleToSelection(style.get(), EditActionSetWritingDirection);
}
} // namespace WebCore
......@@ -119,7 +119,9 @@ public:
bool execCommand(const String&);
bool isContinuousSpellCheckingEnabled();
void toggleContinuousSpellChecking();
bool isGrammarCheckingEnabled();
void toggleGrammarChecking();
void ignoreSpelling();
void learnSpelling();
int spellCheckerDocumentTag();
......@@ -127,6 +129,7 @@ public:
bool isSelectionMisspelled();
Vector<String> guessesForMisspelledSelection();
Vector<String> guessesForUngrammaticalSelection();
void showGuessPanel();
void markMisspellingsInAdjacentWords(const VisiblePosition&);
void markMisspellings(const Selection&);
void advanceToNextMisspelling(bool startBeforeSelection = false);
......@@ -142,6 +145,13 @@ public:
void didBeginEditing();
void didEndEditing();
void showFontPanel();
void showStylesPanel();
void showColorPanel();
void toggleBold();
void toggleUnderline();
void setBaseWritingDirection(String);
#if PLATFORM(MAC)
NSString* userVisibleString(NSURL* nsURL);
......
......@@ -508,6 +508,28 @@ Vector<String> Editor::guessesForMisspelledSelection()
return core([[NSSpellChecker sharedSpellChecker] guessesForWord:selectedString]);
}
void Editor::showGuessPanel()
{
NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
if (!checker) {
LOG_ERROR("No NSSpellChecker");
return;
}
NSPanel *spellingPanel = [checker spellingPanel];
#ifndef BUILDING_ON_TIGER
// Post-Tiger, this menu item is a show/hide toggle, to match AppKit. Leave Tiger behavior alone
// to match rest of OS X.
if ([spellingPanel isVisible]) {
[spellingPanel orderOut:nil];
return;
}
#endif
advanceToNextMisspelling(true);
[spellingPanel orderFront:nil];
}
void Editor::markMisspellingsInAdjacentWords(const VisiblePosition &p)
{
if (!isContinuousSpellCheckingEnabled())
......@@ -564,5 +586,20 @@ void Editor::markMisspellings(const Selection& selection)
markAllBadGrammarInRange(checker, spellCheckerDocumentTag(), searchRange.get());
#endif
}
void Editor::showFontPanel()
{
[[NSFontManager sharedFontManager] orderFrontFontPanel:nil];
}
void Editor::showStylesPanel()
{
[[NSFontManager sharedFontManager] orderFrontStylesPanel:nil];
}
void Editor::showColorPanel()
{
[[NSApplication sharedApplication] orderFrontColorPanel:nil];
}
} // namespace WebCore
......@@ -32,6 +32,7 @@ namespace WebCore {
class Frame;
class HitTestResult;
class KURL;
class String;
class ContextMenuClient {
public:
......@@ -44,6 +45,8 @@ namespace WebCore {
virtual void downloadURL(const KURL& url) = 0;
virtual void copyImageToClipboard(const HitTestResult&) = 0;
virtual void lookUpInDictionary(Frame*) = 0;
virtual void speak(const String&) = 0;
virtual void stopSpeaking() = 0;
#if PLATFORM(MAC)
virtual void searchWithSpotlight() = 0;
......
......@@ -181,7 +181,8 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
break;
case ContextMenuItemTagSpellingGuess:
ASSERT(frame->selectedText().length());
if (frame->editor()->shouldInsertText(item->title(), frame->selectionController()->toRange().get(), EditorInsertActionPasted)) {
if (frame->editor()->shouldInsertText(item->title(), frame->selectionController()->toRange().get(),
EditorInsertActionPasted)) {
Document* document = frame->document();
applyCommand(new ReplaceSelectionCommand(document, createFragmentFromMarkup(document, item->title(), ""),
true, false, true));
......@@ -194,11 +195,6 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
case ContextMenuItemTagLearnSpelling:
frame->editor()->learnSpelling();
break;
case ContextMenuItemTagSearchInSpotlight:
#if PLATFORM(MAC)
m_client->searchWithSpotlight();
#endif
break;
case ContextMenuItemTagSearchWeb: {
String url = makeGoogleSearchURL(frame->selectedText());
ResourceRequest request = ResourceRequest(url);
......@@ -216,29 +212,70 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
else
openNewWindow(result.absoluteLinkURL(), frame);
}
// Sub-menu actions.
#ifndef BUILDING_ON_TIGER
case ContextMenuItemTagShowSpellingAndGrammar:
case ContextMenuItemTagCheckDocumentNow:
case ContextMenuItemTagCheckSpellingWhileTyping:
case ContextMenuItemTagCheckGrammarWithSpelling:
#else
case ContextMenuItemTagSpellingMenuItem:
case ContextMenuItemTagCheckSpelling:
case ContextMenuItemTagCheckSpellingWhileTyping:
#endif
case ContextMenuItemTagShowFonts:
case ContextMenuItemTagBold:
frame->editor()->execCommand("ToggleBold");
break;
case ContextMenuItemTagItalic:
frame->editor()->execCommand("ToggleItalic");
break;
case ContextMenuItemTagUnderline:
frame->editor()->toggleUnderline();
break;
case ContextMenuItemTagOutline:
case ContextMenuItemTagStyles:
case ContextMenuItemTagShowColors:
case ContextMenuItemTagStartSpeaking:
// We actually never enable this because CSS does not have a way to specify an outline font,
// which may make this difficult to implement. Maybe a special case of text-shadow?
break;
case ContextMenuItemTagStartSpeaking: {
ExceptionCode ec;
RefPtr<Range> selectedRange = frame->selectionController()->toRange();
if (!selectedRange || selectedRange->collapsed(ec)) {
Document* document = result.innerNonSharedNode()->document();
selectedRange = document->createRange();
selectedRange->selectNode(document->documentElement(), ec);
}
m_client->speak(selectedRange->toString(true, ec));
break;
}
case ContextMenuItemTagStopSpeaking:
m_client->stopSpeaking();
break;
case ContextMenuItemTagDefaultDirection:
frame->editor()->setBaseWritingDirection("inherit");
break;
case ContextMenuItemTagLeftToRight:
frame->editor()->setBaseWritingDirection("ltr");
break;
case ContextMenuItemTagRightToLeft:
frame->editor()->setBaseWritingDirection("rtl");
break;
#if PLATFORM(MAC)
case ContextMenuItemTagSearchInSpotlight:
m_client->searchWithSpotlight();
break;
case ContextMenuItemTagShowSpellingPanel:
frame->editor()->showGuessPanel();
break;
case ContextMenuItemTagCheckSpelling:
frame->editor()->advanceToNextMisspelling();
break;
case ContextMenuItemTagCheckSpellingWhileTyping:
frame->editor()->toggleContinuousSpellChecking();
break;
#ifndef BUILDING_ON_TIGER
case ContextMenuItemTagCheckGrammarWithSpelling:
frame->editor()->toggleGrammarChecking();
break;
#endif
case ContextMenuItemTagShowFonts:
frame->editor()->showFontPanel();
break;
case ContextMenuItemTagStyles:
frame->editor()->showStylesPanel();
break;
case ContextMenuItemTagShowColors:
frame->editor()->showColorPanel();
break;
#endif
default:
break;
}
......
......@@ -48,26 +48,38 @@ ContextMenuController* ContextMenu::controller() const
return 0;
}
static const ContextMenuItem* separatorItem()
{
return new ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String());
}
static void createFontSubMenu(const HitTestResult& result, ContextMenuItem& fontMenuItem)
{
#if PLATFORM(MAC)
ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, "Show Fonts");
#endif
ContextMenuItem bold(ActionType, ContextMenuItemTagBold, "Bold");
ContextMenuItem italic(ActionType, ContextMenuItemTagItalic, "Italic");
ContextMenuItem underline(ActionType, ContextMenuItemTagUnderline, "Underline");
ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, "Outline");
#if PLATFORM(MAC)
ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, "Styles...");
ContextMenuItem separator(SeparatorType, ContextMenuItemTagNoAction, String());
ContextMenuItem showColors(ActionType, ContextMenuItemTagShowColors, "Show Colors");
#endif
ContextMenu* fontMenu = new ContextMenu(result);
ContextMenu* fontMenu = new ContextMenu(result);
#if PLATFORM(MAC)
fontMenu->appendItem(showFonts);
#endif
fontMenu->appendItem(bold);
fontMenu->appendItem(italic);
fontMenu->appendItem(underline);
fontMenu->appendItem(outline);
#if PLATFORM(MAC)
fontMenu->appendItem(styles);
fontMenu->appendItem(separator);
fontMenu->appendItem(*separatorItem());
fontMenu->appendItem(showColors);
#endif
fontMenuItem.setSubMenu(fontMenu);
}
......@@ -75,28 +87,28 @@ static void createFontSubMenu(const HitTestResult& result, ContextMenuItem& font
#ifndef BUILDING_ON_TIGER
static void createSpellingAndGrammarSubMenu(const HitTestResult& result, ContextMenuItem& spellingAndGrammarMenuItem)
{
ContextMenuItem show(ActionType, ContextMenuItemTagShowSpellingAndGrammar, "Show Spelling and Grammar");
ContextMenuItem checkNow(ActionType, ContextMenuItemTagCheckDocumentNow, "Check Document Now");
ContextMenuItem checkWhileTyping(ActionType, ContextMenuItemTagCheckSpellingWhileTyping, "Check Spelling While Typing");
ContextMenuItem showSpellingPanel(ActionType, ContextMenuItemTagShowSpellingPanel, "Show Spelling and Grammar");
ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling, "Check Document Now");
ContextMenuItem checkAsYouType(ActionType, ContextMenuItemTagCheckSpellingWhileTyping, "Check Spelling While Typing");
ContextMenuItem grammarWithSpelling(ActionType, ContextMenuItemTagCheckGrammarWithSpelling, "Check Grammar With Spelling");
ContextMenu* spellingAndGrammarMenu = new ContextMenu(result);
spellingAndGrammarMenu->appendItem(show);
spellingAndGrammarMenu->appendItem(checkNow);
spellingAndGrammarMenu->appendItem(checkWhileTyping);
spellingAndGrammarMenu->appendItem(showSpellingPanel);
spellingAndGrammarMenu->appendItem(checkSpelling);
spellingAndGrammarMenu->appendItem(checkAsYouType);
spellingAndGrammarMenu->appendItem(grammarWithSpelling);
spellingAndGrammarMenuItem.setSubMenu(spellingAndGrammarMenu);
}
#else
static void createSpellingSubMenu(const HitTestResult& result, const ContextMenuItem& spellingMenuItem)
static void createSpellingSubMenu(const HitTestResult& result, ContextMenuItem& spellingMenuItem)
{
ContextMenuItem spelling(ActionType, ContextMenuItemTagSpellingMenuItem, "Spelling...");
ContextMenuItem showSpellingPanel(ActionType, ContextMenuItemTagShowSpellingPanel, "Spelling...");
ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling, "Check Spelling");
ContextMenuItem checkAsYouType(ActionType, ContextMenuItemTagCheckSpellingWhileTyping, "Check Spelling as You Type");
ContextMenu* spellingMenu = new ContextMenu(result);
spellingMenu->appendItem(spelling);
spellingMenu->appendItem(showSpellingPanel);
spellingMenu->appendItem(checkSpelling);
spellingMenu->appendItem(checkAsYouType);
......@@ -134,7 +146,6 @@ static void createWritingDirectionSubMenu(const HitTestResult& result, ContextMe
void ContextMenu::populate()
{
ContextMenuItem SeparatorItem(SeparatorType, ContextMenuItemTagNoAction, String());
ContextMenuItem OpenLinkItem(ActionType, ContextMenuItemTagOpenLink, "Open Link");
ContextMenuItem OpenLinkInNewWindowItem(ActionType, ContextMenuItemTagOpenLinkInNewWindow, "Open Link in New Window");
ContextMenuItem DownloadFileItem(ActionType, ContextMenuItemTagDownloadLinkToDisk, "Download Linked File");
......@@ -184,7 +195,7 @@ void ContextMenu::populate()
KURL imageURL = result.absoluteImageURL();
if (!imageURL.isEmpty()) {
if (!linkURL.isEmpty())
appendItem(SeparatorItem);
appendItem(*separatorItem());
appendItem(OpenImageInNewWindowItem);
appendItem(DownloadImageItem);
......@@ -198,9 +209,9 @@ void ContextMenu::populate()
appendItem(SearchSpotlightItem);
#endif
appendItem(SearchWebItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
appendItem(LookInDictionaryItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
appendItem(CopyItem);
} else {
if (loader->canGoBackOrForward(-1))
......@@ -237,7 +248,7 @@ void ContextMenu::populate()
// list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit)
if (misspelling) {
appendItem(NowGuessesItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
}
} else {
for (unsigned i = 0; i < size; i++) {
......@@ -247,7 +258,7 @@ void ContextMenu::populate()
appendItem(item);
}
}
appendItem(SeparatorItem);
appendItem(*separatorItem());
}
if (misspelling) {
......@@ -255,7 +266,7 @@ void ContextMenu::populate()
appendItem(LearnSpellingItem);
} else
appendItem(IgnoreGrammarItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
}
}
......@@ -264,10 +275,10 @@ void ContextMenu::populate()
appendItem(SearchSpotlightItem);
#endif
appendItem(SearchWebItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
appendItem(LookInDictionaryItem);
appendItem(SeparatorItem);
appendItem(*separatorItem());
}
appendItem(CutItem);
......@@ -275,10 +286,9 @@ void ContextMenu::populate()
appendItem(PasteItem);
if (!inPasswordField) {
appendItem(SeparatorItem);
appendItem(*separatorItem());
#ifndef BUILDING_ON_TIGER
ContextMenuItem SpellingAndGrammarMenuItem(SubmenuType, ContextMenuItemTagSpellingAndGrammarMenu,
"Spelling and Grammar");
ContextMenuItem SpellingAndGrammarMenuItem(SubmenuType, ContextMenuItemTagSpellingMenu, "Spelling and Grammar");
createSpellingAndGrammarSubMenu(m_hitTestResult, SpellingAndGrammarMenuItem);
appendItem(SpellingAndGrammarMenuItem);
#else
......
......@@ -93,17 +93,12 @@ namespace WebCore {
// These are new tags! Not a part of API!!!!
ContextMenuItemTagOpenLink = 1000,
ContextMenuItemTagIgnoreGrammar,
#ifndef BUILDING_ON_TIGER
ContextMenuItemTagSpellingAndGrammarMenu, // Spelling sub-menu
ContextMenuItemTagShowSpellingAndGrammar,
ContextMenuItemTagCheckDocumentNow,
ContextMenuItemTagCheckSpellingWhileTyping,
ContextMenuItemTagCheckGrammarWithSpelling,
#else
ContextMenuItemTagSpellingMenu, // Tiger Spelling sub-menu
ContextMenuItemTagSpellingMenuItem,
ContextMenuItemTagSpellingMenu, // Spelling or Spelling/Grammar sub-menu
ContextMenuItemTagShowSpellingPanel,
ContextMenuItemTagCheckSpelling,
ContextMenuItemTagCheckSpellingWhileTyping,
#ifndef BUILDING_ON_TIGER
ContextMenuItemTagCheckGrammarWithSpelling,
#endif
ContextMenuItemTagFontMenu, // Font sub-menu
ContextMenuItemTagShowFonts,
......
2006-12-11 Beth Dakin <bdakin@apple.com>
Reviewed by Adam.
WebKit support for editing sub-menu actions.
* WebCoreSupport/WebContextMenuClient.h: New functions for the
speech sub-menu.
* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::speak):
(WebContextMenuClient::stopSpeaking):
* WebCoreSupport/WebEditorClient.h: New functions to toggle
spelling/grammar checking.
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::toggleContinuousSpellChecking):
(WebEditorClient::toggleGrammarChecking):
* WebView/WebUIDelegatePrivate.h: Re-named some of the spelling
sub-menu tags.
2006-12-11 Alice Liu <alice.liu@apple.com>
Reviewed by Geoff, Adam.
......
......@@ -46,6 +46,8 @@ public:
virtual void copyImageToClipboard(const WebCore::HitTestResult&);
virtual void searchWithSpotlight();
virtual void lookUpInDictionary(WebCore::Frame*);
virtual void speak(const WebCore::String&);
virtual void stopSpeaking();
WebView *webView() { return m_webView; }
......
......@@ -43,6 +43,10 @@
using namespace WebCore;
@interface NSApplication (AppKitSecretsIKnowAbout)
- (void)speakString:(NSString *)string;
@end
WebContextMenuClient::WebContextMenuClient(WebView *webView)
: m_webView(webView)
{
......@@ -109,3 +113,13 @@ void WebContextMenuClient::lookUpInDictionary(Frame* frame)
return;
[htmlView _lookUpInDictionaryFromMenu:nil];
}
void WebContextMenuClient::speak(const String& string)
{
[NSApp speakString:[[(NSString*)string copy] autorelease]];
}
void WebContextMenuClient::stopSpeaking()
{
[NSApp stopSpeaking];
}
......@@ -40,7 +40,9 @@ public:
virtual void pageDestroyed();
virtual bool isGrammarCheckingEnabled();
virtual void toggleGrammarChecking();
virtual bool isContinuousSpellCheckingEnabled();
virtual void toggleContinuousSpellChecking();
virtual int spellCheckerDocumentTag();
virtual bool smartInsertDeleteEnabled();
......
......@@ -145,6 +145,11 @@ bool WebEditorClient::isContinuousSpellCheckingEnabled()
return [m_webView isContinuousSpellCheckingEnabled];
}
void WebEditorClient::toggleContinuousSpellChecking()
{
[m_webView toggleContinuousSpellChecking:nil];
}
bool WebEditorClient::isGrammarCheckingEnabled()
{
#ifdef BUILDING_ON_TIGER
......@@ -154,6 +159,13 @@ bool WebEditorClient::isGrammarCheckingEnabled()
#endif
}
void WebEditorClient::toggleGrammarChecking()
{
#ifndef BUILDING_ON_TIGER
[m_webView toggleGrammarChecking:nil];
#endif
}
int WebEditorClient::spellCheckerDocumentTag()
{
return [m_webView spellCheckerDocumentTag];
......
......@@ -32,17 +32,12 @@
enum {
WebMenuItemTagOpenLink = 1000,
WebMenuItemTagIgnoreGrammar,
#ifndef BUILDING_ON_TIGER
WebMenuItemTagSpellingAndGrammarMenu,
WebMenuItemTagShowSpellingAndGrammar,
WebMenuItemTagCheckDocumentNow,
WebMenuItemTagCheckSpellingWhileTyping,
WebMenuItemTagCheckGrammarWithSpelling,
#else
WebMenuItemTagSpellingMenu,
WebMenuItemTagSpellingMenuItem,
WebtMenuItemTagSpellingMenu,
WebMenuItemTagShowSpellingPanel,
WebMenuItemTagCheckSpelling,
WebMenuItemTagCheckSpellingWhileTyping,
#ifndef BUILDING_ON_TIGER
WebMenuItemTagCheckGrammarWithSpelling,
#endif