diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/page/ContextMenuController.cpp | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/page/ContextMenuController.cpp')
-rw-r--r-- | WebCore/page/ContextMenuController.cpp | 397 |
1 files changed, 196 insertions, 201 deletions
diff --git a/WebCore/page/ContextMenuController.cpp b/WebCore/page/ContextMenuController.cpp index 58e6519..0ec9d1c 100644 --- a/WebCore/page/ContextMenuController.cpp +++ b/WebCore/page/ContextMenuController.cpp @@ -39,11 +39,11 @@ #include "EventNames.h" #include "FormState.h" #include "Frame.h" -#include "FrameLoader.h" #include "FrameLoadRequest.h" +#include "FrameLoader.h" +#include "HTMLFormElement.h" #include "HitTestRequest.h" #include "HitTestResult.h" -#include "HTMLFormElement.h" #include "InspectorController.h" #include "MouseEvent.h" #include "Node.h" @@ -108,8 +108,7 @@ static void openNewWindow(const KURL& urlToLoad, Frame* frame) { if (Page* oldPage = frame->page()) { WindowFeatures features; - if (Page* newPage = oldPage->chrome()->createWindow(frame, - FrameLoadRequest(ResourceRequest(urlToLoad, frame->loader()->outgoingReferrer())), features)) + if (Page* newPage = oldPage->chrome()->createWindow(frame, FrameLoadRequest(ResourceRequest(urlToLoad, frame->loader()->outgoingReferrer())), features)) newPage->chrome()->show(); } } @@ -127,215 +126,211 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item) Frame* frame = result.innerNonSharedNode()->document()->frame(); if (!frame) return; - + switch (item->action()) { - case ContextMenuItemTagOpenLinkInNewWindow: - openNewWindow(result.absoluteLinkURL(), frame); - break; - case ContextMenuItemTagDownloadLinkToDisk: - // FIXME: Some day we should be able to do this from within WebCore. - m_client->downloadURL(result.absoluteLinkURL()); - break; - case ContextMenuItemTagCopyLinkToClipboard: - frame->editor()->copyURL(result.absoluteLinkURL(), result.textContent()); - break; - case ContextMenuItemTagOpenImageInNewWindow: - openNewWindow(result.absoluteImageURL(), frame); - break; - case ContextMenuItemTagDownloadImageToDisk: - // FIXME: Some day we should be able to do this from within WebCore. - m_client->downloadURL(result.absoluteImageURL()); - break; - case ContextMenuItemTagCopyImageToClipboard: - // FIXME: The Pasteboard class is not written yet - // For now, call into the client. This is temporary! - frame->editor()->copyImage(result); - break; - case ContextMenuItemTagOpenFrameInNewWindow: { - DocumentLoader* loader = frame->loader()->documentLoader(); - if (!loader->unreachableURL().isEmpty()) - openNewWindow(loader->unreachableURL(), frame); - else - openNewWindow(loader->url(), frame); - break; - } - case ContextMenuItemTagCopy: - frame->editor()->copy(); - break; - case ContextMenuItemTagGoBack: - frame->loader()->goBackOrForward(-1); - break; - case ContextMenuItemTagGoForward: - frame->loader()->goBackOrForward(1); - break; - case ContextMenuItemTagStop: - frame->loader()->stop(); - break; - case ContextMenuItemTagReload: - frame->loader()->reload(); - break; - case ContextMenuItemTagCut: - frame->editor()->cut(); - break; - case ContextMenuItemTagPaste: - frame->editor()->paste(); - break; + case ContextMenuItemTagOpenLinkInNewWindow: + openNewWindow(result.absoluteLinkURL(), frame); + break; + case ContextMenuItemTagDownloadLinkToDisk: + // FIXME: Some day we should be able to do this from within WebCore. + m_client->downloadURL(result.absoluteLinkURL()); + break; + case ContextMenuItemTagCopyLinkToClipboard: + frame->editor()->copyURL(result.absoluteLinkURL(), result.textContent()); + break; + case ContextMenuItemTagOpenImageInNewWindow: + openNewWindow(result.absoluteImageURL(), frame); + break; + case ContextMenuItemTagDownloadImageToDisk: + // FIXME: Some day we should be able to do this from within WebCore. + m_client->downloadURL(result.absoluteImageURL()); + break; + case ContextMenuItemTagCopyImageToClipboard: + // FIXME: The Pasteboard class is not written yet + // For now, call into the client. This is temporary! + frame->editor()->copyImage(result); + break; + case ContextMenuItemTagOpenFrameInNewWindow: { + DocumentLoader* loader = frame->loader()->documentLoader(); + if (!loader->unreachableURL().isEmpty()) + openNewWindow(loader->unreachableURL(), frame); + else + openNewWindow(loader->url(), frame); + break; + } + case ContextMenuItemTagCopy: + frame->editor()->copy(); + break; + case ContextMenuItemTagGoBack: + frame->loader()->goBackOrForward(-1); + break; + case ContextMenuItemTagGoForward: + frame->loader()->goBackOrForward(1); + break; + case ContextMenuItemTagStop: + frame->loader()->stop(); + break; + case ContextMenuItemTagReload: + frame->loader()->reload(); + break; + case ContextMenuItemTagCut: + frame->editor()->cut(); + break; + case ContextMenuItemTagPaste: + frame->editor()->paste(); + break; #if PLATFORM(GTK) - case ContextMenuItemTagDelete: - frame->editor()->performDelete(); - break; - case ContextMenuItemTagSelectAll: - frame->editor()->command("SelectAll").execute(); - break; + case ContextMenuItemTagDelete: + frame->editor()->performDelete(); + break; + case ContextMenuItemTagSelectAll: + frame->editor()->command("SelectAll").execute(); + break; #endif - case ContextMenuItemTagSpellingGuess: - ASSERT(frame->selectedText().length()); - if (frame->editor()->shouldInsertText(item->title(), frame->selection()->toNormalizedRange().get(), - EditorInsertActionPasted)) { - Document* document = frame->document(); - RefPtr<ReplaceSelectionCommand> command = - ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), - true, false, true); - applyCommand(command); - frame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); - } - break; - case ContextMenuItemTagIgnoreSpelling: - frame->editor()->ignoreSpelling(); - break; - case ContextMenuItemTagLearnSpelling: - frame->editor()->learnSpelling(); - break; - case ContextMenuItemTagSearchWeb: - m_client->searchWithGoogle(frame); - break; - case ContextMenuItemTagLookUpInDictionary: - // FIXME: Some day we may be able to do this from within WebCore. - m_client->lookUpInDictionary(frame); - break; - case ContextMenuItemTagOpenLink: - if (Frame* targetFrame = result.targetFrame()) { - targetFrame->loader()->loadFrameRequest(FrameLoadRequest(ResourceRequest(result.absoluteLinkURL(), - frame->loader()->outgoingReferrer())), false, false, 0, 0); - } else - openNewWindow(result.absoluteLinkURL(), frame); - break; - case ContextMenuItemTagBold: - frame->editor()->command("ToggleBold").execute(); - break; - case ContextMenuItemTagItalic: - frame->editor()->command("ToggleItalic").execute(); - break; - case ContextMenuItemTagUnderline: - frame->editor()->toggleUnderline(); - break; - case ContextMenuItemTagOutline: - // 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->selection()->toNormalizedRange(); - if (!selectedRange || selectedRange->collapsed(ec)) { - Document* document = result.innerNonSharedNode()->document(); - selectedRange = document->createRange(); - selectedRange->selectNode(document->documentElement(), ec); - } - m_client->speak(plainText(selectedRange.get())); - break; + case ContextMenuItemTagSpellingGuess: + ASSERT(frame->selectedText().length()); + if (frame->editor()->shouldInsertText(item->title(), frame->selection()->toNormalizedRange().get(), EditorInsertActionPasted)) { + Document* document = frame->document(); + RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), true, false, true); + applyCommand(command); + frame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); } - case ContextMenuItemTagStopSpeaking: - m_client->stopSpeaking(); - break; - case ContextMenuItemTagDefaultDirection: - frame->editor()->setBaseWritingDirection(NaturalWritingDirection); - break; - case ContextMenuItemTagLeftToRight: - frame->editor()->setBaseWritingDirection(LeftToRightWritingDirection); - break; - case ContextMenuItemTagRightToLeft: - frame->editor()->setBaseWritingDirection(RightToLeftWritingDirection); - break; - case ContextMenuItemTagTextDirectionDefault: - frame->editor()->command("MakeTextWritingDirectionNatural").execute(); - break; - case ContextMenuItemTagTextDirectionLeftToRight: - frame->editor()->command("MakeTextWritingDirectionLeftToRight").execute(); - break; - case ContextMenuItemTagTextDirectionRightToLeft: - frame->editor()->command("MakeTextWritingDirectionRightToLeft").execute(); - break; + break; + case ContextMenuItemTagIgnoreSpelling: + frame->editor()->ignoreSpelling(); + break; + case ContextMenuItemTagLearnSpelling: + frame->editor()->learnSpelling(); + break; + case ContextMenuItemTagSearchWeb: + m_client->searchWithGoogle(frame); + break; + case ContextMenuItemTagLookUpInDictionary: + // FIXME: Some day we may be able to do this from within WebCore. + m_client->lookUpInDictionary(frame); + break; + case ContextMenuItemTagOpenLink: + if (Frame* targetFrame = result.targetFrame()) + targetFrame->loader()->loadFrameRequest(FrameLoadRequest(ResourceRequest(result.absoluteLinkURL(), frame->loader()->outgoingReferrer())), false, false, 0, 0); + else + openNewWindow(result.absoluteLinkURL(), frame); + break; + case ContextMenuItemTagBold: + frame->editor()->command("ToggleBold").execute(); + break; + case ContextMenuItemTagItalic: + frame->editor()->command("ToggleItalic").execute(); + break; + case ContextMenuItemTagUnderline: + frame->editor()->toggleUnderline(); + break; + case ContextMenuItemTagOutline: + // 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->selection()->toNormalizedRange(); + if (!selectedRange || selectedRange->collapsed(ec)) { + Document* document = result.innerNonSharedNode()->document(); + selectedRange = document->createRange(); + selectedRange->selectNode(document->documentElement(), ec); + } + m_client->speak(plainText(selectedRange.get())); + break; + } + case ContextMenuItemTagStopSpeaking: + m_client->stopSpeaking(); + break; + case ContextMenuItemTagDefaultDirection: + frame->editor()->setBaseWritingDirection(NaturalWritingDirection); + break; + case ContextMenuItemTagLeftToRight: + frame->editor()->setBaseWritingDirection(LeftToRightWritingDirection); + break; + case ContextMenuItemTagRightToLeft: + frame->editor()->setBaseWritingDirection(RightToLeftWritingDirection); + break; + case ContextMenuItemTagTextDirectionDefault: + frame->editor()->command("MakeTextWritingDirectionNatural").execute(); + break; + case ContextMenuItemTagTextDirectionLeftToRight: + frame->editor()->command("MakeTextWritingDirectionLeftToRight").execute(); + break; + case ContextMenuItemTagTextDirectionRightToLeft: + frame->editor()->command("MakeTextWritingDirectionRightToLeft").execute(); + break; #if PLATFORM(MAC) - case ContextMenuItemTagSearchInSpotlight: - m_client->searchWithSpotlight(); - break; + case ContextMenuItemTagSearchInSpotlight: + m_client->searchWithSpotlight(); + break; #endif - case ContextMenuItemTagShowSpellingPanel: - frame->editor()->showSpellingGuessPanel(); - break; - case ContextMenuItemTagCheckSpelling: - frame->editor()->advanceToNextMisspelling(); - break; - case ContextMenuItemTagCheckSpellingWhileTyping: - frame->editor()->toggleContinuousSpellChecking(); - break; + case ContextMenuItemTagShowSpellingPanel: + frame->editor()->showSpellingGuessPanel(); + break; + case ContextMenuItemTagCheckSpelling: + frame->editor()->advanceToNextMisspelling(); + break; + case ContextMenuItemTagCheckSpellingWhileTyping: + frame->editor()->toggleContinuousSpellChecking(); + break; #ifndef BUILDING_ON_TIGER - case ContextMenuItemTagCheckGrammarWithSpelling: - frame->editor()->toggleGrammarChecking(); - break; + case ContextMenuItemTagCheckGrammarWithSpelling: + frame->editor()->toggleGrammarChecking(); + break; #endif #if PLATFORM(MAC) - case ContextMenuItemTagShowFonts: - frame->editor()->showFontPanel(); - break; - case ContextMenuItemTagStyles: - frame->editor()->showStylesPanel(); - break; - case ContextMenuItemTagShowColors: - frame->editor()->showColorPanel(); - break; + case ContextMenuItemTagShowFonts: + frame->editor()->showFontPanel(); + break; + case ContextMenuItemTagStyles: + frame->editor()->showStylesPanel(); + break; + case ContextMenuItemTagShowColors: + frame->editor()->showColorPanel(); + break; #endif #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - case ContextMenuItemTagMakeUpperCase: - frame->editor()->uppercaseWord(); - break; - case ContextMenuItemTagMakeLowerCase: - frame->editor()->lowercaseWord(); - break; - case ContextMenuItemTagCapitalize: - frame->editor()->capitalizeWord(); - break; - case ContextMenuItemTagShowSubstitutions: - frame->editor()->showSubstitutionsPanel(); - break; - case ContextMenuItemTagSmartCopyPaste: - frame->editor()->toggleSmartInsertDelete(); - break; - case ContextMenuItemTagSmartQuotes: - frame->editor()->toggleAutomaticQuoteSubstitution(); - break; - case ContextMenuItemTagSmartDashes: - frame->editor()->toggleAutomaticDashSubstitution(); - break; - case ContextMenuItemTagSmartLinks: - frame->editor()->toggleAutomaticLinkDetection(); - break; - case ContextMenuItemTagTextReplacement: - frame->editor()->toggleAutomaticTextReplacement(); - break; - case ContextMenuItemTagCorrectSpellingAutomatically: - frame->editor()->toggleAutomaticSpellingCorrection(); - break; - case ContextMenuItemTagChangeBack: - frame->editor()->changeBackToReplacedString(result.replacedString()); - break; + case ContextMenuItemTagMakeUpperCase: + frame->editor()->uppercaseWord(); + break; + case ContextMenuItemTagMakeLowerCase: + frame->editor()->lowercaseWord(); + break; + case ContextMenuItemTagCapitalize: + frame->editor()->capitalizeWord(); + break; + case ContextMenuItemTagShowSubstitutions: + frame->editor()->showSubstitutionsPanel(); + break; + case ContextMenuItemTagSmartCopyPaste: + frame->editor()->toggleSmartInsertDelete(); + break; + case ContextMenuItemTagSmartQuotes: + frame->editor()->toggleAutomaticQuoteSubstitution(); + break; + case ContextMenuItemTagSmartDashes: + frame->editor()->toggleAutomaticDashSubstitution(); + break; + case ContextMenuItemTagSmartLinks: + frame->editor()->toggleAutomaticLinkDetection(); + break; + case ContextMenuItemTagTextReplacement: + frame->editor()->toggleAutomaticTextReplacement(); + break; + case ContextMenuItemTagCorrectSpellingAutomatically: + frame->editor()->toggleAutomaticSpellingCorrection(); + break; + case ContextMenuItemTagChangeBack: + frame->editor()->changeBackToReplacedString(result.replacedString()); + break; #endif - case ContextMenuItemTagInspectElement: - if (Page* page = frame->page()) - page->inspectorController()->inspect(result.innerNonSharedNode()); - break; - default: - break; + case ContextMenuItemTagInspectElement: + if (Page* page = frame->page()) + page->inspectorController()->inspect(result.innerNonSharedNode()); + break; + default: + break; } } |