WebCore:
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 19:49:21 +0000 (19:49 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 19:49:21 +0000 (19:49 +0000)
        Reviewed by Brady.

        Fixes "Open in new Window" item in WebCore ContextMenus. It wasn't
        doing anything before, and now it works! Also some formatting
        changes, etc.

        * page/ContextMenuClient.h: Several of the parameters to several of
        the functions here should be const or const references. And now
        they are!
        * page/ContextMenuController.cpp:
        (WebCore::openNewWindow): Moved the open new window functionality
        into a helper function since it is used by several menu item tags.
        Now after calling chrome()->createWindow() we call chrome()->show()
        on the new window, and so it appears!
        (WebCore::ContextMenuController::contextMenuItemSelected): Call new
        openNewWindow function to do the right thing. Shift some
        formatting, use local variable for HitTestResult. Implement action
        for ContextMenuItemTagOpenLink.

WebKit:
        Reviewed by Brady.

        Make some parameters const and const references.

        * WebCoreSupport/WebContextMenuClient.h:
        * WebCoreSupport/WebContextMenuClient.mm:
        (WebContextMenuClient::contextMenuItemSelected):
        (WebContextMenuClient::copyLinkToClipboard):
        (WebContextMenuClient::downloadURL):
        (WebContextMenuClient::copyImageToClipboard):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18057 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/ContextMenuClient.h
WebCore/page/ContextMenuController.cpp
WebKit/ChangeLog
WebKit/WebCoreSupport/WebContextMenuClient.h
WebKit/WebCoreSupport/WebContextMenuClient.mm
WebKit/WebKit.xcodeproj/project.pbxproj

index 44acfa56d2b715985985af499701a413a9914dd0..60384df16e6cc46e5785c5dbd41d2987112aaefd 100644 (file)
@@ -1,3 +1,24 @@
+2006-12-07  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Brady.
+
+        Fixes "Open in new Window" item in WebCore ContextMenus. It wasn't 
+        doing anything before, and now it works! Also some formatting 
+        changes, etc.
+
+        * page/ContextMenuClient.h: Several of the parameters to several of 
+        the functions here should be const or const references. And now 
+        they are!
+        * page/ContextMenuController.cpp:
+        (WebCore::openNewWindow): Moved the open new window functionality 
+        into a helper function since it is used by several menu item tags. 
+        Now after calling chrome()->createWindow() we call chrome()->show() 
+        on the new window, and so it appears!
+        (WebCore::ContextMenuController::contextMenuItemSelected): Call new 
+        openNewWindow function to do the right thing. Shift some 
+        formatting, use local variable for HitTestResult. Implement action 
+        for ContextMenuItemTagOpenLink.
+
 2006-12-06  Kevin McCullough  <KMcCullough@apple.com>
 
         Reviewed by.
index 13565b43f28d2722f9196ba3a38598705fab974e..cddc5a21b1202aa75987640c3e90224194048655 100644 (file)
@@ -39,11 +39,11 @@ namespace WebCore {
         virtual void contextMenuDestroyed() = 0;
         
         virtual void addCustomContextMenuItems(ContextMenu*) = 0;
-        virtual void contextMenuItemSelected(ContextMenuItem*) = 0;
+        virtual void contextMenuItemSelected(const ContextMenuItem*) = 0;
 
-        virtual void copyLinkToClipboard(HitTestResult) = 0;
-        virtual void downloadURL(KURL url) = 0;
-        virtual void copyImageToClipboard(HitTestResult) = 0;
+        virtual void copyLinkToClipboard(const HitTestResult&) = 0;
+        virtual void downloadURL(const KURL& url) = 0;
+        virtual void copyImageToClipboard(const HitTestResult&) = 0;
         virtual void lookUpInDictionary(Frame*) = 0;
 
 #if PLATFORM(MAC)
index e35ece211115bd4495cb33271a2e343ad7cdb32d..5affbe2ddc3925f150a2c9e1c8fdb0f868b14032 100644 (file)
@@ -101,6 +101,14 @@ static String makeGoogleSearchURL(String searchString)
     return url;
 }
 
+static void openNewWindow(const KURL& urlToLoad, const Frame* frame)
+{
+    Page* newPage = frame->page()->chrome()->createWindow(FrameLoadRequest(ResourceRequest(urlToLoad, 
+        frame->loader()->outgoingReferrer())));
+    if (newPage)
+        newPage->chrome()->show();
+}
+
 void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
 {
     ASSERT(item->parentMenu() == contextMenu());
@@ -111,43 +119,38 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
         return;
     }
 
-    Frame* frame = m_contextMenu->hitTestResult().innerNonSharedNode()->document()->frame();
+    HitTestResult result = m_contextMenu->hitTestResult();
+    Frame* frame = result.innerNonSharedNode()->document()->frame();
     if (!frame)
         return;
     ASSERT(m_page == frame->page());
     
     switch (item->action()) {
-        case ContextMenuItemTagOpenLinkInNewWindow: {
-            ResourceRequest request = ResourceRequest(m_contextMenu->hitTestResult().absoluteLinkURL());
-            String referrer = frame->loader()->referrer();
-            m_page->chrome()->createWindow(FrameLoadRequest(request, referrer));
+        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(m_contextMenu->hitTestResult().absoluteLinkURL());
+            m_client->downloadURL(result.absoluteLinkURL());
             break;
         case ContextMenuItemTagCopyLinkToClipboard:
             // FIXME: The Pasteboard class is not written yet. This is what we should be able to do some day:
-            // generalPasteboard()->copy(m_contextMenu->hitTestResult().absoluteLinkURL(), 
+            // generalPasteboard()->copy(result.absoluteLinkURL(), 
             //      m_contextMenu->hitTestResult.textContent());
             // For now, call into the client. This is temporary!
-            m_client->copyLinkToClipboard(m_contextMenu->hitTestResult());
+            m_client->copyLinkToClipboard(result);
             break;
-        case ContextMenuItemTagOpenImageInNewWindow: {
-            ResourceRequest request = ResourceRequest(m_contextMenu->hitTestResult().absoluteImageURL());
-            String referrer = frame->loader()->referrer();
-            m_page->chrome()->createWindow(FrameLoadRequest(request, referrer));
+        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(m_contextMenu->hitTestResult().absoluteImageURL());
+            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!
-            m_client->copyImageToClipboard(m_contextMenu->hitTestResult());
+            m_client->copyImageToClipboard(result);
             break;
         case ContextMenuItemTagOpenFrameInNewWindow: {
             // FIXME: The DocumentLoader is all-Mac right now
@@ -155,10 +158,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
             KURL unreachableURL = frame->loader()->documentLoader()->unreachableURL();
             if (frame && unreachableURL.isEmpty())
                 unreachableURL = frame->loader()->documentLoader()->URL();
-            ResourceRequest request = ResourceRequest(unreachableURL);
-            String referrer = frame->loader()->referrer();
-            if (m_page)
-                m_page->chrome()->createWindow(FrameLoadRequest(request, referrer));
+            openNewWindow(unreachableURL, frame);
 #endif
             break;
         }
@@ -213,7 +213,13 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
             // FIXME: Some day we may be able to do this from within WebCore.
             m_client->lookUpInDictionary(frame);
             break;
-        case ContextMenuItemTagOpenLink:
+        case ContextMenuItemTagOpenLink: {
+            if (Frame* targetFrame = result.targetFrame())
+                targetFrame->loader()->load(FrameLoadRequest(ResourceRequest(result.absoluteLinkURL(), 
+                    frame->loader()->outgoingReferrer())), true, new Event(), 0, HashMap<String, String>());
+            else
+                openNewWindow(result.absoluteLinkURL(), frame);
+        }
         // Sub-menu actions.
 #ifndef BUILDING_ON_TIGER
         case ContextMenuItemTagShowSpellingAndGrammar:
index bc5a7be7467758fe7e75ff8ebfbb850ead22930e..549b37a72559a9f604bb5fd6c551838c43746e2a 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-07  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Brady.
+
+        Make some parameters const and const references.
+
+        * WebCoreSupport/WebContextMenuClient.h:
+        * WebCoreSupport/WebContextMenuClient.mm:
+        (WebContextMenuClient::contextMenuItemSelected):
+        (WebContextMenuClient::copyLinkToClipboard):
+        (WebContextMenuClient::downloadURL):
+        (WebContextMenuClient::copyImageToClipboard):
+
 2006-12-06  Brady Eidson  <beidson@apple.com>
 
         Reviewed by John Sullivan
index 915853475b10ede4d610a5195aaad1383c2c5484..8a9fd37a7ee2874fcf07c5e8f4610631a63f0f8d 100644 (file)
@@ -39,11 +39,11 @@ public:
     virtual void contextMenuDestroyed();
     
     virtual void addCustomContextMenuItems(WebCore::ContextMenu*);
-    virtual void contextMenuItemSelected(WebCore::ContextMenuItem*);
+    virtual void contextMenuItemSelected(const WebCore::ContextMenuItem*);
     
-    virtual void copyLinkToClipboard(WebCore::HitTestResult);
-    virtual void downloadURL(WebCore::KURL url);
-    virtual void copyImageToClipboard(WebCore::HitTestResult);
+    virtual void copyLinkToClipboard(const WebCore::HitTestResult&);
+    virtual void downloadURL(const WebCore::KURL&);
+    virtual void copyImageToClipboard(const WebCore::HitTestResult&);
     virtual void searchWithSpotlight();
     virtual void lookUpInDictionary(WebCore::Frame*);
 
index 1c92df5db0f1e0c423d4831cea6bfa95616fff64..d2d33e2eb965cf58df67ec658c6662685816dc03 100644 (file)
@@ -63,7 +63,7 @@ void WebContextMenuClient::addCustomContextMenuItems(ContextMenu* menu)
     }
 }
 
-void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item)
+void WebContextMenuClient::contextMenuItemSelected(const ContextMenuItem* item)
 {
     ASSERT(item->parentMenu());
     
@@ -74,7 +74,7 @@ void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item)
     }
 }
 
-void WebContextMenuClient::copyLinkToClipboard(HitTestResult hitTestResult)
+void WebContextMenuClient::copyLinkToClipboard(const HitTestResult& hitTestResult)
 {
     NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:hitTestResult] autorelease];
     NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
@@ -82,12 +82,12 @@ void WebContextMenuClient::copyLinkToClipboard(HitTestResult hitTestResult)
     [m_webView _writeLinkElement:element withPasteboardTypes:types toPasteboard:pasteboard];
 }
 
-void WebContextMenuClient::downloadURL(KURL url)
+void WebContextMenuClient::downloadURL(const KURL& url)
 {
     [m_webView _downloadURL:url.getNSURL()];
 }
 
-void WebContextMenuClient::copyImageToClipboard(HitTestResult hitTestResult)
+void WebContextMenuClient::copyImageToClipboard(const HitTestResult& hitTestResult)
 {
     NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:hitTestResult] autorelease];
     NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
index 539be61dfafad149b165927aebd4597f147f917b..37fa6e151f2dc7035fd0e30a9dbadf363cab4334 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       shouldCheckCompatibility = 1;
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );