Commit 38765cde authored by bdakin's avatar bdakin

WebCore:

        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: http://svn.webkit.org/repository/webkit/trunk@18057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 260601f5
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.
......@@ -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)
......
......@@ -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:
......
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
......
......@@ -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*);
......
......@@ -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];
......
......@@ -1262,7 +1262,6 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -1277,7 +1276,6 @@
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
9398100A0824BF01008DF038 /* WebKit */,
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment