Changeset 17855 in webkit
- Timestamp:
- Nov 19, 2006 5:21:56 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r17853 r17855 1 2006-11-19 Beth Dakin <bdakin@apple.com> 2 3 Reviewed by Adam. 4 5 Implementation of actions for the new context menus. 6 7 * WebCore.exp: 8 * WebCore.xcodeproj/project.pbxproj: 9 * bridge/EditorClient.h: Declaration of shouldInsertText. 10 * bridge/mac/FrameMac.h: Two new spelling functions. 11 * bridge/mac/FrameMac.mm: 12 (WebCore::FrameMac::ignoreSpelling): 13 (WebCore::FrameMac::learnSpelling): 14 * editing/Editor.cpp: 15 (WebCore::Editor::shouldInsertText): Call into the client. 16 * editing/Editor.h: 17 * editing/EditorInsertAction.h: Added. 18 (WebCore::): The WebCore equivalent of WebViewInsertAction. This is 19 defined in its own header so that we can use it from Editor.h and 20 EditorClient.h without having one of the above include the other. 21 * page/ContextMenuClient.h: A few currently WebKit-implemented 22 function needed for menu actions. 23 * page/ContextMenuController.cpp: 24 (WebCore::makeGoogleSearchURL): 25 (WebCore::ContextMenuController::contextMenuActionSelected): The 26 actions! 27 * page/ContextMenuController.h: 28 * page/Frame.h: New pure-virtual spelling functions. 29 * platform/ContextMenu.cpp: 30 (WebCore::ContextMenu::controller): Get the controller from the 31 menu. 32 * platform/ContextMenu.h: 33 * platform/mac/ContextMenuMac.mm: 34 (-[MenuTarget 35 forwardContextMenuAction:initWithContextMenuController:WebCore::]): 36 Use the controller instead of the menu 37 (-[MenuTarget WebCore::]): 38 (-[MenuTarget setMenuController:WebCore::]): 39 (-[MenuTarget forwardContextMenuAction:]): 40 (getNSMenuItem): 41 (ContextMenu::show): 42 (ContextMenu::hide): 43 1 44 2006-11-19 Simon Hausmann <hausmann@kde.org> 2 45 -
trunk/WebCore/WebCore.exp
r17805 r17855 395 395 __ZNK7WebCore8FrameMac14selectionImageEb 396 396 __ZNK7WebCore8FrameMac31fontAttributesForSelectionStartEv 397 __ZNK7WebCore8IntPointcv8_NSPointEv398 397 __ZNK7WebCore9FloatRectcv7_NSRectEv 399 398 __ZNK7WebCore9FrameTree12traverseNextEPKNS_5FrameE -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r17850 r17855 1622 1622 93F19B1708245E59001E9ABC /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F1D31A0558CC5C00821BC0 /* libicucore.dylib */; }; 1623 1623 93F19B1808245E59001E9ABC /* libxslt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 840633070731A77200DB1FD1 /* libxslt.dylib */; }; 1624 93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1624 1625 A70023FD0B02BEAB00170215 /* MimeTypeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70023FB0B02BEAB00170215 /* MimeTypeRegistry.cpp */; }; 1625 1626 A70023FE0B02BEAB00170215 /* MimeTypeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = A70023FC0B02BEAB00170215 /* MimeTypeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4531 4532 93F8B3070A300FEA00F61AB8 /* generate-bindings.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = "generate-bindings.pl"; path = "scripts/generate-bindings.pl"; sourceTree = "<group>"; }; 4532 4533 93F8B3080A300FEA00F61AB8 /* IDLStructure.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = IDLStructure.pm; path = scripts/IDLStructure.pm; sourceTree = "<group>"; }; 4534 93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; }; 4533 4535 A70023FB0B02BEAB00170215 /* MimeTypeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MimeTypeRegistry.cpp; sourceTree = "<group>"; }; 4534 4536 A70023FC0B02BEAB00170215 /* MimeTypeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MimeTypeRegistry.h; sourceTree = "<group>"; }; … … 7597 7599 4B3043CA0AE0373B00A82647 /* Editor.cpp */, 7598 7600 4B3043CB0AE0373B00A82647 /* Editor.h */, 7601 93FDAFC90B11307400E2746F /* EditorInsertAction.h */, 7599 7602 93309D98099E64910056E581 /* htmlediting.cpp */, 7600 7603 93309D99099E64910056E581 /* htmlediting.h */, … … 10799 10802 B2E27C9C0B0F2AE600F17C7B /* SVGSpotLightSource.h in Headers */, 10800 10803 B2E27CA00B0F2B0900F17C7B /* FloatPoint3D.h in Headers */, 10804 93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */, 10801 10805 ); 10802 10806 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bridge/EditorClient.h
r17777 r17855 30 30 #include "AbstractShared.h" 31 31 32 #include "EditorInsertAction.h" 33 32 34 namespace WebCore { 33 35 … … 35 37 class EditCommand; 36 38 class HTMLElement; 39 class String; 37 40 class Range; 38 41 … … 52 55 virtual bool shouldEndEditing(Range*) = 0; 53 56 // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) = 0; 54 // virtual bool shouldInsertText(NSString*, Range *replacingRange, WebViewInsertAction) = 0;57 virtual bool shouldInsertText(String, Range*, EditorInsertAction) = 0; 55 58 // virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, NSSelectionAffinity, bool stillSelecting) = 0; 56 59 virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) = 0; -
trunk/WebCore/bridge/mac/FrameMac.h
r17770 r17855 167 167 NSWritingDirection baseWritingDirectionForSelectionStart() const; 168 168 169 virtual void ignoreSpelling(); 170 virtual void learnSpelling(); 169 171 virtual void markMisspellingsInAdjacentWords(const VisiblePosition&); 170 172 virtual void markMisspellings(const Selection&); -
trunk/WebCore/bridge/mac/FrameMac.mm
r17818 r17855 106 106 #endif 107 107 108 @interface NSSpellChecker (CurrentlyPrivateForTextView) 109 - (void)learnWord:(NSString *)word; 110 @end 111 108 112 using namespace std; 109 113 using namespace KJS::Bindings; … … 1148 1152 } 1149 1153 1154 void FrameMac::ignoreSpelling() 1155 { 1156 String text = selectedText(); 1157 ASSERT(text.length() != 0); 1158 [[NSSpellChecker sharedSpellChecker] ignoreWord:text 1159 inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag()]; 1160 } 1161 1162 void FrameMac::learnSpelling() 1163 { 1164 String text = selectedText(); 1165 ASSERT(text.length() != 0); 1166 [[NSSpellChecker sharedSpellChecker] learnWord:text]; 1167 } 1168 1150 1169 void FrameMac::markMisspellingsInAdjacentWords(const VisiblePosition &p) 1151 1170 { -
trunk/WebCore/editing/Editor.cpp
r17777 r17855 187 187 void Editor::writeSelectionToPasteboard(Pasteboard pasteboard) 188 188 { 189 } 190 191 bool Editor::shouldInsertText(String text, Range* range, EditorInsertAction action) const 192 { 193 return m_client->shouldInsertText(text, range, action); 189 194 } 190 195 -
trunk/WebCore/editing/Editor.h
r17777 r17855 27 27 #define Editor_h 28 28 29 #include "EditorInsertAction.h" 29 30 #include "Frame.h" 30 31 #include <wtf/Forward.h> … … 71 72 void outdent(); 72 73 74 bool shouldInsertText(String, Range*, EditorInsertAction) const; 73 75 bool shouldShowDeleteInterface(HTMLElement*) const; 74 76 bool shouldDeleteRange(Range*) const; -
trunk/WebCore/page/ContextMenuClient.h
r17805 r17855 31 31 namespace WebCore { 32 32 class ContextMenu; 33 class Frame; 34 class HitTestResult; 35 class KURL; 33 36 34 37 class ContextMenuClient : public AbstractShared { 35 38 public: 36 39 virtual void addCustomContextMenuItems(ContextMenu*) = 0; 40 41 virtual void copyLinkToClipboard(HitTestResult) = 0; 42 virtual void downloadURL(KURL url) = 0; 43 virtual void copyImageToClipboard(HitTestResult) = 0; 44 virtual void lookUpInDictionary(Frame*) = 0; 45 46 #if PLATFORM(MAC) 47 virtual void searchWithSpotlight() = 0; 48 #endif 37 49 }; 38 50 } -
trunk/WebCore/page/ContextMenuController.cpp
r17806 r17855 29 29 #include "ContextMenu.h" 30 30 #include "ContextMenuClient.h" 31 #include "Document.h" 32 #include "DocumentFragment.h" 33 #include "DocumentLoader.h" 34 #include "Editor.h" 35 #include "EditorClient.h" 31 36 #include "Event.h" 32 37 #include "EventNames.h" 38 #include "Frame.h" 39 #include "FrameLoader.h" 40 #include "FrameLoadRequest.h" 33 41 #include "HitTestRequest.h" 34 42 #include "HitTestResult.h" 43 #include "KURL.h" 35 44 #include "MouseEvent.h" 36 45 #include "Node.h" 46 #include "Page.h" 37 47 #include "RenderLayer.h" 38 48 #include "RenderObject.h" 49 #include "ReplaceSelectionCommand.h" 50 #include "ResourceRequest.h" 51 #include "markup.h" 39 52 40 53 namespace WebCore { … … 72 85 } 73 86 74 void ContextMenuController::contextMenuActionSelected(ContextMenuAction action) 75 { 76 // FIXME: Implement this 87 static String makeGoogleSearchURL(String searchString) 88 { 89 searchString.stripWhiteSpace(); 90 DeprecatedString encoded = KURL::encode_string(searchString.deprecatedString()); 91 encoded.replace(DeprecatedString("%20"), DeprecatedString("+")); 92 93 String url("http://www.google.com/search?client=safari&q="); 94 url.append(String(encoded)); 95 url.append("&ie=UTF-8&oe=UTF-8"); 96 return url; 97 } 98 99 void ContextMenuController::contextMenuActionSelected(ContextMenuAction action, String title) 100 { 101 Frame* frame = m_contextMenu->hitTestResult().innerNonSharedNode()->document()->frame(); 102 if (!frame) 103 return; 104 ASSERT(m_page == frame->page()); 105 106 switch (action) { 107 case ContextMenuItemTagOpenLinkInNewWindow: { 108 ResourceRequest request = ResourceRequest(m_contextMenu->hitTestResult().absoluteLinkURL()); 109 String referrer = frame->loader()->referrer(); 110 m_page->chrome()->createWindow(FrameLoadRequest(request, referrer)); 111 break; 112 } 113 case ContextMenuItemTagDownloadLinkToDisk: 114 // FIXME: Some day we should be able to do this from within WebCore. 115 m_client->downloadURL(m_contextMenu->hitTestResult().absoluteLinkURL()); 116 break; 117 case ContextMenuItemTagCopyLinkToClipboard: 118 // FIXME: The Pasteboard class is not written yet. This is what we should be able to do some day: 119 // generalPasteboard()->copy(m_contextMenu->hitTestResult().absoluteLinkURL(), 120 // m_contextMenu->hitTestResult.textContent()); 121 // For now, call into the client. This is temporary! 122 m_client->copyLinkToClipboard(m_contextMenu->hitTestResult()); 123 break; 124 case ContextMenuItemTagOpenImageInNewWindow: { 125 ResourceRequest request = ResourceRequest(m_contextMenu->hitTestResult().absoluteImageURL()); 126 String referrer = frame->loader()->referrer(); 127 m_page->chrome()->createWindow(FrameLoadRequest(request, referrer)); 128 break; 129 } 130 case ContextMenuItemTagDownloadImageToDisk: 131 // FIXME: Some day we should be able to do this from within WebCore. 132 m_client->downloadURL(m_contextMenu->hitTestResult().absoluteImageURL()); 133 break; 134 case ContextMenuItemTagCopyImageToClipboard: 135 // FIXME: The Pasteboard class is not written yet 136 // For now, call into the client. This is temporary! 137 m_client->copyImageToClipboard(m_contextMenu->hitTestResult()); 138 break; 139 case ContextMenuItemTagOpenFrameInNewWindow: { 140 // FIXME: The DocumentLoader is all-Mac right now 141 #if PLATFORM(MAC) 142 KURL unreachableURL = frame->loader()->documentLoader()->unreachableURL(); 143 if (frame && unreachableURL.isEmpty()) 144 unreachableURL = frame->loader()->documentLoader()->URL(); 145 ResourceRequest request = ResourceRequest(unreachableURL); 146 String referrer = frame->loader()->referrer(); 147 if (m_page) 148 m_page->chrome()->createWindow(FrameLoadRequest(request, referrer)); 149 #endif 150 break; 151 } 152 case ContextMenuItemTagCopy: 153 frame->editor()->copy(); 154 break; 155 case ContextMenuItemTagGoBack: 156 frame->loader()->goBackOrForward(-1); 157 break; 158 case ContextMenuItemTagGoForward: 159 frame->loader()->goBackOrForward(1); 160 break; 161 case ContextMenuItemTagStop: 162 frame->loader()->stop(); 163 break; 164 case ContextMenuItemTagReload: 165 frame->loader()->reload(); 166 break; 167 case ContextMenuItemTagCut: 168 frame->editor()->cut(); 169 break; 170 case ContextMenuItemTagPaste: 171 frame->editor()->paste(); 172 break; 173 case ContextMenuItemTagSpellingGuess: 174 ASSERT(frame->selectedText().length() != 0); 175 if (frame->editor()->shouldInsertText(title, frame->selectionController()->toRange().get(), EditorInsertActionPasted)) { 176 Document* document = frame->document(); 177 applyCommand(new ReplaceSelectionCommand(document, createFragmentFromMarkup(document, title, ""), 178 true, false, true)); 179 frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded); 180 } 181 break; 182 case ContextMenuItemTagIgnoreSpelling: 183 frame->ignoreSpelling(); 184 break; 185 case ContextMenuItemTagLearnSpelling: 186 frame->learnSpelling(); 187 break; 188 case ContextMenuItemTagSearchInSpotlight: 189 #if PLATFORM(MAC) 190 m_client->searchWithSpotlight(); 191 #endif 192 break; 193 case ContextMenuItemTagSearchWeb: { 194 String url = makeGoogleSearchURL(frame->selectedText()); 195 ResourceRequest request = ResourceRequest(url); 196 frame->loader()->urlSelected(FrameLoadRequest(request), new Event()); 197 break; 198 } 199 case ContextMenuItemTagLookUpInDictionary: 200 // FIXME: Some day we may be able to do this from within WebCore. 201 m_client->lookUpInDictionary(frame); 202 break; 203 // PDF actions. Let's take care of this later. 204 case ContextMenuItemTagOpenWithDefaultApplication: 205 case ContextMenuItemPDFActualSize: 206 case ContextMenuItemPDFZoomIn: 207 case ContextMenuItemPDFZoomOut: 208 case ContextMenuItemPDFAutoSize: 209 case ContextMenuItemPDFSinglePage: 210 case ContextMenuItemPDFFacingPages: 211 case ContextMenuItemPDFContinuous: 212 case ContextMenuItemPDFNextPage: 213 case ContextMenuItemPDFPreviousPage: 214 default: 215 break; 216 } 77 217 } 78 218 -
trunk/WebCore/page/ContextMenuController.h
r17806 r17855 49 49 50 50 void handleContextMenuEvent(Event*); 51 void contextMenuActionSelected(ContextMenuAction );51 void contextMenuActionSelected(ContextMenuAction, String); 52 52 53 53 private: -
trunk/WebCore/page/Frame.h
r17770 r17855 259 259 void removeEditingStyleFromElement(Element*) const; 260 260 261 virtual void ignoreSpelling() = 0; 262 virtual void learnSpelling() = 0; 261 263 virtual void markMisspellingsInAdjacentWords(const VisiblePosition&) = 0; 262 264 virtual void markMisspellings(const Selection&) = 0; -
trunk/WebCore/platform/ContextMenu.cpp
r17807 r17855 39 39 40 40 #define MENU_ACTION_ITEM(action, title) static ContextMenuItem action##Item(ActionType, ContextMenuItemTag##action, String(title)) 41 42 ContextMenuController* ContextMenu::controller() const 43 { 44 if (Node* node = m_hitTestResult.innerNonSharedNode()) 45 if (Frame* frame = node->document()->frame()) 46 if (Page* page = frame->page()) 47 return page->contextMenuController(); 48 return 0; 49 } 41 50 42 51 void ContextMenu::populate() -
trunk/WebCore/platform/ContextMenu.h
r17827 r17855 43 43 44 44 namespace WebCore { 45 46 class ContextMenuController; 45 47 46 48 // This enum needs to be in sync with WebMenuItemTag, which is defined in WebUIDelegate.h … … 129 131 void populate(); 130 132 131 // FIXME: Implement these 132 void show() {} 133 void hide() {} 133 void show(); 134 void hide(); 134 135 135 136 void insertItem(unsigned position, ContextMenuItem); … … 139 140 140 141 HitTestResult hitTestResult() const { return m_hitTestResult; } 142 ContextMenuController* controller() const; 141 143 142 144 PlatformMenuDescription platformMenuDescription() { return m_menu; } -
trunk/WebCore/platform/mac/ContextMenuMac.mm
r17797 r17855 26 26 #include "config.h" 27 27 #include "ContextMenu.h" 28 29 #include "ContextMenuController.h" 28 30 29 31 @interface MenuTarget : NSObject { 30 WebCore::ContextMenu * _menu;32 WebCore::ContextMenuController* _menuController; 31 33 } 32 - (WebCore::ContextMenu *)menu;33 - (void)setMenu :(WebCore::ContextMenu*)menu;34 - (WebCore::ContextMenuController*)menuController; 35 - (void)setMenuController:(WebCore::ContextMenuController*)menuController; 34 36 - (void)forwardContextMenuAction:(id)sender; 35 37 @end … … 37 39 @implementation MenuTarget 38 40 39 - (id)initWithContextMenu :(WebCore::ContextMenu*)menu41 - (id)initWithContextMenuController:(WebCore::ContextMenuController*)menuController 40 42 { 41 43 self = [super init]; … … 43 45 return nil; 44 46 45 _menu = menu;47 _menuController = menuController; 46 48 return self; 47 49 } 48 50 49 - (WebCore::ContextMenu *)menu51 - (WebCore::ContextMenuController*)menuController 50 52 { 51 return _menu ;53 return _menuController; 52 54 } 53 55 54 - (void)setMenu :(WebCore::ContextMenu*)menu56 - (void)setMenuController:(WebCore::ContextMenuController*)menuController 55 57 { 56 _menu = menu;58 _menuController = menuController; 57 59 } 58 60 59 61 - (void)forwardContextMenuAction:(id)sender 60 62 { 63 WebCore::ContextMenuAction action = static_cast<WebCore::ContextMenuAction>([sender tag]); 64 _menuController->contextMenuActionSelected(action, [sender title]); 61 65 } 62 66 … … 72 76 menu->setPlatformMenuDescription([[[NSMutableArray alloc] init] autorelease]); 73 77 78 ContextMenuController* currentController = menu->controller(); 74 79 if (!target) 75 target = [[MenuTarget alloc] initWithContextMenu :menu];76 else if ( menu != [target menu])77 [target setMenu :menu];80 target = [[MenuTarget alloc] initWithContextMenuController:currentController]; 81 else if (currentController != [target menuController]) 82 [target setMenuController:currentController]; 78 83 79 84 NSMenuItem* menuItem = [[[NSMenuItem alloc] init] autorelease]; … … 107 112 m_menu = menu; 108 113 } 114 115 void ContextMenu::show() 116 { 117 } 118 119 void ContextMenu::hide() 120 { 121 } -
trunk/WebKit/ChangeLog
r17847 r17855 1 2006-11-19 Beth Dakin <bdakin@apple.com> 2 3 Reviewed by Adam. 4 5 WebKit side of new context menu actions. 6 7 * WebCoreSupport/WebContextMenuClient.h: These are for the 8 currently-WebKit-dependent menu actions. 9 * WebCoreSupport/WebContextMenuClient.mm: 10 (WebContextMenuClient::copyLinkToClipboard): 11 (WebContextMenuClient::downloadURL): 12 (WebContextMenuClient::copyImageToClipboard): 13 (WebContextMenuClient::searchWithSpotlight): 14 (WebContextMenuClient::lookUpInDictionary): 15 * WebCoreSupport/WebEditorClient.h: 16 * WebCoreSupport/WebEditorClient.mm: 17 (core): These are to convert between WebViewInsertAction and 18 EditorInsertAction. 19 (kit): 20 (WebEditorClient::shouldInsertText): Added implementation for 21 shouldInsertText. 22 * WebKit.xcodeproj/project.pbxproj: 23 * WebView/WebHTMLView.m: 24 (-[WebHTMLView _lookUpInDictionaryFromMenu:]): Moved 25 _lookUpInDictionary to be within the implementation of WebHTMLView 26 internal. 27 * WebView/WebHTMLViewInternal.h: Add _lookUpInDictionaryFromMenu 28 * WebView/WebViewInternal.h: Add _searchWithSpotlightFromMenu 29 1 30 2006-11-18 Don Gibson <dgibson77@gmail.com> 2 31 -
trunk/WebKit/WebCoreSupport/WebContextMenuClient.h
r17805 r17855 41 41 42 42 virtual void addCustomContextMenuItems(WebCore::ContextMenu* menu); 43 44 virtual void copyLinkToClipboard(WebCore::HitTestResult); 45 virtual void downloadURL(WebCore::KURL url); 46 virtual void copyImageToClipboard(WebCore::HitTestResult); 47 virtual void searchWithSpotlight(); 48 virtual void lookUpInDictionary(WebCore::Frame*); 43 49 44 50 WebView *webView() { return m_webView; } -
trunk/WebKit/WebCoreSupport/WebContextMenuClient.mm
r17805 r17855 31 31 #import "WebElementDictionary.h" 32 32 #import "WebFrame.h" 33 #import "WebFrameInternal.h" 34 #import "WebHTMLView.h" 35 #import "WebHTMLViewInternal.h" 36 #import "WebNSPasteboardExtras.h" 33 37 #import "WebUIDelegate.h" 34 38 #import "WebView.h" 39 #import "WebViewInternal.h" 35 40 #import <WebCore/ContextMenu.h> 41 #import <WebCore/KURL.h> 36 42 37 43 using namespace WebCore; … … 66 72 } 67 73 } 74 75 void WebContextMenuClient::copyLinkToClipboard(HitTestResult hitTestResult) 76 { 77 NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:hitTestResult] autorelease]; 78 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 79 NSArray *types = [NSPasteboard _web_writableTypesForURL]; 80 [m_webView _writeLinkElement:element withPasteboardTypes:types toPasteboard:pasteboard]; 81 } 82 83 void WebContextMenuClient::downloadURL(KURL url) 84 { 85 [m_webView _downloadURL:url.getNSURL()]; 86 } 87 88 void WebContextMenuClient::copyImageToClipboard(HitTestResult hitTestResult) 89 { 90 NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:hitTestResult] autorelease]; 91 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 92 NSArray *types = [NSPasteboard _web_writableTypesForImageIncludingArchive:(hitTestResult.innerNonSharedNode() != 0)]; 93 [[[element objectForKey:WebElementFrameKey] webView] _writeImageForElement:element 94 withPasteboardTypes:types 95 toPasteboard:pasteboard]; 96 } 97 98 void WebContextMenuClient::searchWithSpotlight() 99 { 100 [m_webView _searchWithSpotlightFromMenu:nil]; 101 } 102 103 void WebContextMenuClient::lookUpInDictionary(Frame* frame) 104 { 105 WebHTMLView* htmlView = (WebHTMLView*)[[kit(frame) frameView] documentView]; 106 if(![htmlView isKindOfClass:[WebHTMLView class]]) 107 return; 108 [htmlView _lookUpInDictionaryFromMenu:nil]; 109 } -
trunk/WebKit/WebCoreSupport/WebEditorClient.h
r17777 r17855 57 57 bool shouldBeginEditing(WebCore::Range*); 58 58 bool shouldEndEditing(WebCore::Range*); 59 bool shouldInsertText(WebCore::String, WebCore::Range*, WebCore::EditorInsertAction); 59 60 60 61 bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); -
trunk/WebKit/WebCoreSupport/WebEditorClient.mm
r17777 r17855 42 42 using namespace WebCore; 43 43 44 EditorInsertAction core(WebViewInsertAction); 45 WebViewInsertAction kit(EditorInsertAction); 46 47 EditorInsertAction core(WebViewInsertAction kitAction) 48 { 49 return static_cast<EditorInsertAction>(kitAction); 50 } 51 52 WebViewInsertAction kit(EditorInsertAction coreAction) 53 { 54 return static_cast<WebViewInsertAction>(coreAction); 55 } 56 44 57 @interface WebEditCommand : NSObject 45 58 { … … 203 216 return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView] 204 217 shouldEndEditingInDOMRange:kit(range)]; 218 } 219 220 bool WebEditorClient::shouldInsertText(String text, Range* range, EditorInsertAction action) 221 { 222 WebView* webView = [m_webFrame webView]; 223 return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:text replacingDOMRange:kit(range) givenAction:kit(action)]; 205 224 } 206 225 -
trunk/WebKit/WebKit.xcodeproj/project.pbxproj
r17831 r17855 42 42 22E42A9A0A5BA4D00003275B /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E42A990A5BA4D00003275B /* AGL.framework */; }; 43 43 22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 44 4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */; };44 4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */; settings = {ATTRIBUTES = (); }; }; 45 45 4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */; }; 46 46 51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */; }; … … 1253 1253 isa = PBXProject; 1254 1254 buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */; 1255 compatibilityVersion = "Xcode 2.4";1256 1255 hasScannedForEncodings = 1; 1257 1256 knownRegions = ( … … 1267 1266 productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; 1268 1267 projectDirPath = ""; 1269 projectRoot = "";1270 shouldCheckCompatibility = 1;1271 1268 targets = ( 1272 1269 9398100A0824BF01008DF038 /* WebKit */, -
trunk/WebKit/WebView/WebHTMLView.m
r17788 r17855 1761 1761 } 1762 1762 1763 - (void)_lookUpInDictionaryFromMenu:(id)sender1764 {1765 // This should only be called when there's a selection, but play it safe.1766 if (![self _hasSelection])1767 return;1768 1769 // Soft link to dictionary-display function to avoid linking another framework (ApplicationServices/LangAnalysis)1770 static bool lookedForFunction = false;1771 typedef OSStatus (*ServiceWindowShowFunction)(id inWordString, NSRect inWordBoundary, UInt16 inLineDirection);1772 static ServiceWindowShowFunction dictionaryServiceWindowShow;1773 if (!lookedForFunction) {1774 const struct mach_header *frameworkImageHeader = 0;1775 dictionaryServiceWindowShow = reinterpret_cast<ServiceWindowShowFunction>(1776 _NSSoftLinkingGetFrameworkFuncPtr(@"ApplicationServices", @"LangAnalysis", "_DCMDictionaryServiceWindowShow", &frameworkImageHeader));1777 lookedForFunction = true;1778 }1779 if (!dictionaryServiceWindowShow) {1780 LOG_ERROR("Couldn't find _DCMDictionaryServiceWindowShow");1781 return;1782 }1783 1784 // FIXME: must check for right-to-left here1785 NSWritingDirection writingDirection = NSWritingDirectionLeftToRight;1786 1787 NSAttributedString *attrString = [self selectedAttributedString];1788 // FIXME: the dictionary API expects the rect for the first line of selection. Passing1789 // the rect for the entire selection, as we do here, positions the pop-up window near1790 // the bottom of the selection rather than at the selected word.1791 NSRect rect = [self convertRect:core([self _frame])->visibleSelectionRect() toView:nil];1792 rect.origin = [[self window] convertBaseToScreen:rect.origin];1793 NSData *data = [attrString RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil];1794 dictionaryServiceWindowShow(data, rect, (writingDirection == NSWritingDirectionRightToLeft) ? 1 : 0);1795 }1796 1797 1763 - (BOOL)_transparentBackground 1798 1764 { … … 5263 5229 #endif /* !BUILDING_ON_TIGER */ 5264 5230 5231 - (void)_lookUpInDictionaryFromMenu:(id)sender 5232 { 5233 // This should only be called when there's a selection, but play it safe. 5234 if (![self _hasSelection]) 5235 return; 5236 5237 // Soft link to dictionary-display function to avoid linking another framework (ApplicationServices/LangAnalysis) 5238 static bool lookedForFunction = false; 5239 typedef OSStatus (*ServiceWindowShowFunction)(id inWordString, NSRect inWordBoundary, UInt16 inLineDirection); 5240 static ServiceWindowShowFunction dictionaryServiceWindowShow; 5241 if (!lookedForFunction) { 5242 const struct mach_header *frameworkImageHeader = 0; 5243 dictionaryServiceWindowShow = reinterpret_cast<ServiceWindowShowFunction>( 5244 _NSSoftLinkingGetFrameworkFuncPtr(@"ApplicationServices", @"LangAnalysis", "_DCMDictionaryServiceWindowShow", &frameworkImageHeader)); 5245 lookedForFunction = true; 5246 } 5247 if (!dictionaryServiceWindowShow) { 5248 LOG_ERROR("Couldn't find _DCMDictionaryServiceWindowShow"); 5249 return; 5250 } 5251 5252 // FIXME: must check for right-to-left here 5253 NSWritingDirection writingDirection = NSWritingDirectionLeftToRight; 5254 5255 NSAttributedString *attrString = [self selectedAttributedString]; 5256 // FIXME: the dictionary API expects the rect for the first line of selection. Passing 5257 // the rect for the entire selection, as we do here, positions the pop-up window near 5258 // the bottom of the selection rather than at the selected word. 5259 NSRect rect = [self convertRect:core([self _frame])->visibleSelectionRect() toView:nil]; 5260 rect.origin = [[self window] convertBaseToScreen:rect.origin]; 5261 NSData *data = [attrString RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil]; 5262 dictionaryServiceWindowShow(data, rect, (writingDirection == NSWritingDirectionRightToLeft) ? 1 : 0); 5263 } 5264 5265 5265 @end 5266 5266 -
trunk/WebKit/WebView/WebHTMLViewInternal.h
r17760 r17855 115 115 - (void)paste:(id)sender; 116 116 - (void)pasteAsPlainText:(id)sender; 117 - (void)_lookUpInDictionaryFromMenu:(id)sender; 117 118 #if !BUILDING_ON_TIGER 118 119 - (BOOL)isGrammarCheckingEnabled; -
trunk/WebKit/WebView/WebViewInternal.h
r17670 r17855 98 98 - (void)_writeImageForElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard; 99 99 - (void)_writeLinkElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard; 100 - (void)_searchWithSpotlightFromMenu:(id)sender; 100 101 - (void)_progressCompleted:(WebFrame *)frame; 101 102 - (void)_didCommitLoadForFrame:(WebFrame *)frame;
Note: See TracChangeset
for help on using the changeset viewer.