+2006-11-15 Adam Roben <aroben@apple.com>
+
+ Reviewed by Anders.
+
+ Add new ContextMenuController and ContextMenuClient classes, and move
+ context menu responsibilities from Chrome and ChromeClient to them.
+
+ * WebCore.exp:
+ * WebCore.xcodeproj/project.pbxproj: Add new files to project, and
+ alphabetize some others.
+ * page/Chrome.cpp: Remove context menu-related code.
+ * page/Chrome.h: Ditto.
+ * page/ChromeClient.h:
+ * page/ContextMenuClient.h: Added.
+ * page/ContextMenuController.cpp: Added.
+ (WebCore::ContextMenuController::ContextMenuController):
+ (WebCore::ContextMenuController::~ContextMenuController):
+ (WebCore::ContextMenuController::handleContextMenuEvent):
+ (WebCore::ContextMenuController::contextMenuActionSelected):
+ * page/ContextMenuController.h: Added.
+ (WebCore::ContextMenuController::client):
+ * page/Page.cpp: Every Page now has a ContextMenuController.
+ (WebCore::Page::Page):
+ * page/Page.h: Made m_dragCaretController and m_chrome objects instead
+ of pointers to objects.
+ (WebCore::Page::contextMenuController):
+ * platform/ContextMenu.cpp:
+ (WebCore::ContextMenu::populate): Removed the call to Chrome to ask the
+ delegate to add its menu items, and moved the code from the static
+ addDefaultItems function into this method.
+ * platform/ContextMenu.h:
+ (WebCore::ContextMenu::show): Added an empty method body since this
+ method is now called from ContextMenuController (although no one calls
+ into ContextMenuController yet, so it's OK for this to be empty).
+ (WebCore::ContextMenu::hide): Ditto.
+
2006-11-15 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
__ZN7WebCore4KURLC1ERKNS_16DeprecatedStringE
__ZN7WebCore4Page12setGroupNameERKNS_6StringE
__ZN7WebCore4Page16setDefersLoadingEb
-__ZN7WebCore4PageC1EN3WTF10PassRefPtrINS_12ChromeClientEEE
+__ZN7WebCore4PageC1EN3WTF10PassRefPtrINS_12ChromeClientEEENS2_INS_17ContextMenuClientEEE
__ZN7WebCore4PageD1Ev
__ZN7WebCore5Frame11setSettingsEPNS_8SettingsE
__ZN7WebCore5Frame12ownerElementEv
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
+ 065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 065AD4F20B0C2EDA005A2B1D /* ContextMenuClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 065AD4F30B0C2EDA005A2B1D /* ContextMenuController.cpp */; };
+ 065AD4F70B0C2EDA005A2B1D /* ContextMenuController.h in Headers */ = {isa = PBXBuildFile; fileRef = 065AD4F40B0C2EDA005A2B1D /* ContextMenuController.h */; };
0668E18B0ADD9624004128E0 /* PopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 0668E1890ADD9624004128E0 /* PopupMenu.h */; };
0668E1900ADD9640004128E0 /* PopupMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0668E18E0ADD9640004128E0 /* PopupMenuMac.mm */; };
066C772B0AB603B700238CC4 /* FileChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = 066C772A0AB603B700238CC4 /* FileChooser.h */; };
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 065AD4F20B0C2EDA005A2B1D /* ContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenuClient.h; sourceTree = "<group>"; };
+ 065AD4F30B0C2EDA005A2B1D /* ContextMenuController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ContextMenuController.cpp; sourceTree = "<group>"; };
+ 065AD4F40B0C2EDA005A2B1D /* ContextMenuController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenuController.h; sourceTree = "<group>"; };
0668E1890ADD9624004128E0 /* PopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PopupMenu.h; sourceTree = "<group>"; };
0668E18E0ADD9640004128E0 /* PopupMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PopupMenuMac.mm; sourceTree = "<group>"; };
066C772A0AB603B700238CC4 /* FileChooser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileChooser.h; sourceTree = "<group>"; };
8538F0000AD71770006A81D1 /* AbstractView.idl */,
14D8238A0AF92DF60004F057 /* Chrome.cpp */,
14D823500AF92A790004F057 /* Chrome.h */,
+ 065AD4F20B0C2EDA005A2B1D /* ContextMenuClient.h */,
+ 065AD4F30B0C2EDA005A2B1D /* ContextMenuController.cpp */,
+ 065AD4F40B0C2EDA005A2B1D /* ContextMenuController.h */,
14D824060AF93AEB0004F057 /* ChromeClient.h */,
1403B99609EB13AF00797C7F /* DOMWindow.cpp */,
1403B99509EB13AF00797C7F /* DOMWindow.h */,
B2A015910AF6CD53006BCE0E /* graphics */ = {
isa = PBXGroup;
children = (
+ B27535290B053814002CE64F /* cg */,
+ B27535490B053814002CE64F /* mac */,
+ B2A015960AF6CD53006BCE0E /* svg */,
B27535270B053814002CE64F /* AffineTransform.cpp */,
B27535280B053814002CE64F /* AffineTransform.h */,
- B27535290B053814002CE64F /* cg */,
B27535380B053814002CE64F /* Color.cpp */,
B27535390B053814002CE64F /* Color.h */,
B275353A0B053814002CE64F /* FloatPoint.cpp */,
B275353D0B053814002CE64F /* FloatRect.h */,
B275353E0B053814002CE64F /* FloatSize.cpp */,
B275353F0B053814002CE64F /* FloatSize.h */,
+ B2A015920AF6CD53006BCE0E /* GraphicsContext.cpp */,
+ B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
+ B2A015940AF6CD53006BCE0E /* GraphicsTypes.cpp */,
+ B2A015950AF6CD53006BCE0E /* GraphicsTypes.h */,
B27535400B053814002CE64F /* Icon.h */,
B27535410B053814002CE64F /* Image.cpp */,
B27535420B053814002CE64F /* Image.h */,
B27535460B053814002CE64F /* IntRect.h */,
B27535470B053814002CE64F /* IntSize.h */,
B27535480B053814002CE64F /* IntSizeHash.h */,
- B27535490B053814002CE64F /* mac */,
B27535520B053814002CE64F /* Path.cpp */,
B27535530B053814002CE64F /* Path.h */,
B27535540B053814002CE64F /* Pen.cpp */,
B27535550B053814002CE64F /* Pen.h */,
- B2A015920AF6CD53006BCE0E /* GraphicsContext.cpp */,
- B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
- B2A015940AF6CD53006BCE0E /* GraphicsTypes.cpp */,
- B2A015950AF6CD53006BCE0E /* GraphicsTypes.h */,
- B2A015960AF6CD53006BCE0E /* svg */,
);
path = graphics;
sourceTree = "<group>";
93C09A530B064DB3005ABD4D /* EventHandler.h in Headers */,
93C09C860B0657AA005ABD4D /* ScrollTypes.h in Headers */,
93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */,
+ 065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */,
+ 065AD4F70B0C2EDA005A2B1D /* ContextMenuController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
93C09A810B064F00005ABD4D /* EventHandler.cpp in Sources */,
93B6A0E80B0BCA6700F5027A /* ContextMenu.cpp in Sources */,
93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */,
+ 065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
m_client->setResizable(b);
}
-void Chrome::addCustomContextMenuItems(ContextMenu* defaultMenu) const
-{
- m_client->addCustomContextMenuItems(defaultMenu);
-}
-
} // namespace WebCore
void setResizable(bool) const;
- void addCustomContextMenuItems(ContextMenu*) const;
-
private:
Page* m_page;
RefPtr<ChromeClient> m_client;
namespace WebCore {
- class ContextMenu;
class FloatRect;
class Page;
virtual bool menubarVisible() = 0;
virtual void setResizable(bool) = 0;
-
- virtual void addCustomContextMenuItems(ContextMenu*) = 0;
};
}
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ContextMenuClient_h
+#define ContextMenuClient_h
+
+#include "AbstractShared.h"
+
+namespace WebCore {
+ class ContextMenu;
+
+ class ContextMenuClient : public AbstractShared {
+ public:
+ virtual void addCustomContextMenuItems(ContextMenu*) = 0;
+ };
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ContextMenuController.h"
+
+#include "ContextMenu.h"
+#include "ContextMenuClient.h"
+#include "Event.h"
+#include "EventNames.h"
+#include "HitTestRequest.h"
+#include "HitTestResult.h"
+#include "MouseEvent.h"
+#include "Node.h"
+#include "RenderLayer.h"
+#include "RenderObject.h"
+
+namespace WebCore {
+
+using namespace EventNames;
+
+ContextMenuController::ContextMenuController(Page* page, PassRefPtr<ContextMenuClient> client)
+ : m_page(page)
+ , m_client(client)
+ , m_contextMenu(0)
+{
+}
+
+ContextMenuController::~ContextMenuController()
+{
+}
+
+void ContextMenuController::handleContextMenuEvent(Event* event)
+{
+ ASSERT(event->type() == contextmenuEvent);
+ MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+ HitTestResult result(IntPoint(mouseEvent->x(), mouseEvent->y()));
+
+ if (RenderObject* renderer = event->target()->renderer())
+ if (RenderLayer* layer = renderer->layer())
+ layer->hitTest(HitTestRequest(false, true), result);
+
+ if (!result.innerNonSharedNode())
+ return;
+
+ m_contextMenu = new ContextMenu(result);
+ m_contextMenu->populate();
+ m_client->addCustomContextMenuItems(m_contextMenu.get());
+ m_contextMenu->show();
+}
+
+void ContextMenuController::contextMenuActionSelected(ContextMenuAction action)
+{
+ // FIXME: Implement this
+}
+
+} // namespace WebCore
+
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ContextMenuController_h
+#define ContextMenuController_h
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+
+#include "ContextMenu.h"
+
+namespace WebCore {
+ class ContextMenuClient;
+ class Event;
+ class Node;
+ class Page;
+
+ class ContextMenuController : Noncopyable
+ {
+ public:
+ ContextMenuController(Page*, PassRefPtr<ContextMenuClient>);
+ ~ContextMenuController();
+
+ ContextMenuClient* client() { return m_client.get(); }
+
+ void handleContextMenuEvent(Event*);
+ void contextMenuActionSelected(ContextMenuAction);
+
+ private:
+ Page* m_page;
+ RefPtr<ContextMenuClient> m_client;
+
+ std::auto_ptr<ContextMenu> m_contextMenu;
+ };
+
+}
+
+#endif
#include "config.h"
#include "Page.h"
-#include "Chrome.h"
#include "ChromeClient.h"
+#include "ContextMenuClient.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameTree.h"
-#include "SelectionController.h"
#include "StringHash.h"
#include "Widget.h"
#include <kjs/collector.h>
static HashSet<Page*>* allPages;
static HashMap<String, HashSet<Page*>*>* frameNamespaces;
-Page::Page(PassRefPtr<ChromeClient> chromeClient)
- : m_dragCaretController(new SelectionController(0, true))
- , m_chrome(new Chrome(this, chromeClient))
+Page::Page(PassRefPtr<ChromeClient> chromeClient, PassRefPtr<ContextMenuClient> contextMenuClient)
+ : m_dragCaretController(0, true)
+ , m_chrome(this, chromeClient)
+ , m_contextMenuController(this, contextMenuClient)
, m_frameCount(0)
, m_defersLoading(false)
{
Collector::collect();
#endif
}
-
- delete m_dragCaretController;
- delete m_chrome;
}
void Page::setMainFrame(PassRefPtr<Frame> mainFrame)
#ifndef Page_h
#define Page_h
+#include "Chrome.h"
+#include "ContextMenuController.h"
#include "PlatformString.h"
+#include "SelectionController.h"
#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
#if PLATFORM(WIN)
typedef struct HINSTANCE__* HINSTANCE;
namespace WebCore {
- class Chrome;
class ChromeClient;
+ class ContextMenuClient;
class Frame;
class FrameNamespace;
class FloatRect;
class Settings;
- class SelectionController;
class Widget;
class Page : Noncopyable {
public:
- Page(PassRefPtr<ChromeClient>);
+ Page(PassRefPtr<ChromeClient>, PassRefPtr<ContextMenuClient>);
~Page();
void setMainFrame(PassRefPtr<Frame>);
static void setNeedsReapplyStyles();
static void setNeedsReapplyStylesForSettingsChange(Settings*);
- SelectionController* dragCaretController() { return m_dragCaretController; }
- Chrome* chrome() { return m_chrome; }
+ SelectionController* dragCaretController() { return &m_dragCaretController; }
+ Chrome* chrome() { return &m_chrome; }
+ ContextMenuController* contextMenuController() { return &m_contextMenuController; }
void setDefersLoading(bool);
bool defersLoading() const { return m_defersLoading; }
#endif
private:
- SelectionController* m_dragCaretController;
- Chrome* m_chrome;
+ SelectionController m_dragCaretController;
+ Chrome m_chrome;
+ ContextMenuController m_contextMenuController;
RefPtr<Frame> m_mainFrame;
int m_frameCount;
#include "config.h"
#include "ContextMenu.h"
-#include "Chrome.h"
+#include "ContextMenuController.h"
#include "Document.h"
#include "Frame.h"
#include "FrameLoader.h"
#define MENU_ACTION_ITEM(action, title) static ContextMenuItem action##Item(ActionType, WebMenuItemTag##action, String(title))
-static void addDefaultItems(ContextMenu* menu)
+void ContextMenu::populate()
{
MENU_ACTION_ITEM(OpenLinkInNewWindow, "Open Link in New Window");
MENU_ACTION_ITEM(DownloadLinkToDisk, "Download Linked File");
// FIXME: Add PDF action items
ContextMenuItem SeparatorItem(SeparatorType, WebMenuItemTagNoAction, String());
- HitTestResult result = menu->hitTestResult();
+ HitTestResult result = hitTestResult();
if (!result.isContentEditable()) {
KURL linkURL = result.absoluteLinkURL();
if (!linkURL.isEmpty()) {
if (true) { // FIXME: if FrameLoaderClient can handle the request
- menu->appendItem(OpenLinkInNewWindowItem);
- menu->appendItem(DownloadLinkToDiskItem);
+ appendItem(OpenLinkInNewWindowItem);
+ appendItem(DownloadLinkToDiskItem);
}
- menu->appendItem(CopyLinkToClipboardItem);
+ appendItem(CopyLinkToClipboardItem);
}
KURL imageURL = result.absoluteImageURL();
if (!imageURL.isEmpty()) {
if (!linkURL.isEmpty())
- menu->appendItem(SeparatorItem);
+ appendItem(SeparatorItem);
- menu->appendItem(OpenImageInNewWindowItem);
- menu->appendItem(DownloadImageToDiskItem);
+ appendItem(OpenImageInNewWindowItem);
+ appendItem(DownloadImageToDiskItem);
if (imageURL.isLocalFile())
- menu->appendItem(CopyImageToClipboardItem);
+ appendItem(CopyImageToClipboardItem);
}
if (imageURL.isEmpty() && linkURL.isEmpty()) {
if (result.isSelected()) {
#if PLATFORM(MAC)
- menu->appendItem(SearchInSpotlightItem);
+ appendItem(SearchInSpotlightItem);
#endif
- menu->appendItem(SearchWebItem);
- menu->appendItem(SeparatorItem);
- menu->appendItem(LookUpInDictionaryItem);
- menu->appendItem(SeparatorItem);
- menu->appendItem(CopyItem);
+ appendItem(SearchWebItem);
+ appendItem(SeparatorItem);
+ appendItem(LookUpInDictionaryItem);
+ appendItem(SeparatorItem);
+ appendItem(CopyItem);
} else {
FrameLoader* loader = result.innerNonSharedNode()->document()->frame()->loader();
if (loader->canGoBackOrForward(-1))
- menu->appendItem(GoBackItem);
+ appendItem(GoBackItem);
if (loader->canGoBackOrForward(1))
- menu->appendItem(GoForwardItem);
+ appendItem(GoForwardItem);
if (loader->isLoading())
- menu->appendItem(StopItem);
+ appendItem(StopItem);
else
- menu->appendItem(ReloadItem);
+ appendItem(ReloadItem);
if (result.innerNonSharedNode()->document()->frame() != result.innerNonSharedNode()->document()->frame()->page()->mainFrame())
- menu->appendItem(OpenFrameInNewWindowItem);
+ appendItem(OpenFrameInNewWindowItem);
}
}
} else { // Make an editing context menu
// Add spelling-related context menu items.
if (true) { // FIXME: Should be (selectionController->isSelectionMisspelled() && !inPasswordField)
// FIXME: Add spelling guesses here
- menu->appendItem(NoGuessesFoundItem);
+ appendItem(NoGuessesFoundItem);
- menu->appendItem(SeparatorItem);
- menu->appendItem(IgnoreSpellingItem);
- menu->appendItem(LearnSpellingItem);
- menu->appendItem(SeparatorItem);
+ appendItem(SeparatorItem);
+ appendItem(IgnoreSpellingItem);
+ appendItem(LearnSpellingItem);
+ appendItem(SeparatorItem);
}
if (result.isSelected() && !inPasswordField) {
#if PLATFORM(MAC)
- menu->appendItem(SearchInSpotlightItem);
+ appendItem(SearchInSpotlightItem);
#endif
- menu->appendItem(SearchWebItem);
- menu->appendItem(SeparatorItem);
+ appendItem(SearchWebItem);
+ appendItem(SeparatorItem);
- menu->appendItem(LookUpInDictionaryItem);
- menu->appendItem(SeparatorItem);
+ appendItem(LookUpInDictionaryItem);
+ appendItem(SeparatorItem);
}
- menu->appendItem(CutItem);
- menu->appendItem(CopyItem);
- menu->appendItem(PasteItem);
- menu->appendItem(SeparatorItem);
+ appendItem(CutItem);
+ appendItem(CopyItem);
+ appendItem(PasteItem);
+ appendItem(SeparatorItem);
// FIXME: Add "Spelling [and Grammar, on Leopard]", "Font", "Speech", "Writing Direction" submenus here.
}
}
-void ContextMenu::populate()
-{
- addDefaultItems(this);
- if (Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame())
- if (Page* page = frame->page())
- page->chrome()->addCustomContextMenuItems(this);
-}
-
}
void populate();
- void show();
- void hide();
+ // FIXME: Implement these
+ void show() {}
+ void hide() {}
void insertItem(unsigned position, ContextMenuItem);
void appendItem(ContextMenuItem item);
+2006-11-15 Adam Roben <aroben@apple.com>
+
+ Reviewed by Anders.
+
+ Added new WebContextMenuClient class to act as WebCore's ChromeClient,
+ and moved context menu-related code there from WebChromeClient.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ * WebCoreSupport/WebContextMenuClient.h: Added.
+ (WebContextMenuClient::webView):
+ * WebCoreSupport/WebContextMenuClient.mm: Added.
+ (WebContextMenuClient::create):
+ (WebContextMenuClient::WebContextMenuClient):
+ (WebContextMenuClient::ref):
+ (WebContextMenuClient::deref):
+ (WebContextMenuClient::addCustomContextMenuItems):
+ * WebKit.xcodeproj/project.pbxproj: Added new files.
+ * WebView/WebView.mm:
+ (-[WebView _commonInitializationWithFrameName:groupName:]):
+
2006-11-15 Beth Dakin <bdakin@apple.com>
& Adam Roben <aroben@apple.com>
virtual void setResizable(bool);
- virtual void addCustomContextMenuItems(WebCore::ContextMenu*);
-
private:
WebChromeClient(WebView *webView);
#import "WebChromeClient.h"
#import "WebDefaultUIDelegate.h"
-#import "WebElementDictionary.h"
#import "WebFrameInternal.h"
#import "WebFrameView.h"
#import "WebNSURLRequestExtras.h"
#import "WebUIDelegate.h"
#import "WebView.h"
#import "WebViewInternal.h"
-#import <WebCore/ContextMenu.h>
#import <WebCore/FloatRect.h>
#import <WebCore/FrameLoadRequest.h>
#import <WebCore/ResourceRequestMac.h>
[[m_webView _UIDelegateForwarder] webView:m_webView setResizable:b];
}
-void WebChromeClient::addCustomContextMenuItems(ContextMenu* menu)
-{
- id delegate = [m_webView UIDelegate];
- if ([delegate respondsToSelector:@selector(webView:contextMenuItemsForElement:defaultMenuItems:)]) {
- NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:menu->hitTestResult()] autorelease];
- NSArray *newMenu = [delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:menu->platformMenuDescription()];
- menu->setPlatformMenuDescription(newMenu);
- }
-}
-
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebCore/ContextMenuClient.h>
+#import <WebCore/Shared.h>
+#import <wtf/Forward.h>
+
+@class WebView;
+
+class WebContextMenuClient : public WebCore::ContextMenuClient, public WebCore::Shared<WebContextMenuClient> {
+public:
+ static PassRefPtr<WebContextMenuClient> create(WebView *webView);
+
+ virtual void ref();
+ virtual void deref();
+
+ virtual void addCustomContextMenuItems(WebCore::ContextMenu* menu);
+
+ WebView *webView() { return m_webView; }
+
+private:
+ WebContextMenuClient(WebView *webView);
+
+ WebView *m_webView;
+};
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebContextMenuClient.h"
+
+#import "WebElementDictionary.h"
+#import "WebFrame.h"
+#import "WebUIDelegate.h"
+#import "WebView.h"
+#import <WebCore/ContextMenu.h>
+
+using namespace WebCore;
+
+PassRefPtr<WebContextMenuClient> WebContextMenuClient::create(WebView *webView)
+{
+ return new WebContextMenuClient(webView);
+}
+
+WebContextMenuClient::WebContextMenuClient(WebView *webView)
+ : m_webView(webView)
+{
+}
+
+void WebContextMenuClient::ref()
+{
+ Shared<WebContextMenuClient>::ref();
+}
+
+void WebContextMenuClient::deref()
+{
+ Shared<WebContextMenuClient>::deref();
+}
+
+void WebContextMenuClient::addCustomContextMenuItems(ContextMenu* menu)
+{
+ id delegate = [m_webView UIDelegate];
+ if ([delegate respondsToSelector:@selector(webView:contextMenuItemsForElement:defaultMenuItems:)]) {
+ NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:menu->hitTestResult()] autorelease];
+ NSArray *newMenu = [delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:menu->platformMenuDescription()];
+ menu->setPlatformMenuDescription(newMenu);
+ }
+}
objects = {
/* Begin PBXBuildFile section */
+ 065AD5A30B0C32C7005A2B1D /* WebContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 065AD5A10B0C32C7005A2B1D /* WebContextMenuClient.h */; };
+ 065AD5A40B0C32C7005A2B1D /* WebContextMenuClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 065AD5A20B0C32C7005A2B1D /* WebContextMenuClient.mm */; };
14D8252F0AF955090004F057 /* WebChromeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D8252D0AF955090004F057 /* WebChromeClient.h */; };
14D825300AF955090004F057 /* WebChromeClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 14D8252E0AF955090004F057 /* WebChromeClient.mm */; };
1C0706630A431E01001078F6 /* WebScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0706620A431E01001078F6 /* WebScriptDebugServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
/* End PBXBuildRule section */
/* Begin PBXFileReference section */
+ 065AD5A10B0C32C7005A2B1D /* WebContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebContextMenuClient.h; sourceTree = "<group>"; };
+ 065AD5A20B0C32C7005A2B1D /* WebContextMenuClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMenuClient.mm; sourceTree = "<group>"; };
14D8252D0AF955090004F057 /* WebChromeClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebChromeClient.h; sourceTree = "<group>"; };
14D8252E0AF955090004F057 /* WebChromeClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebChromeClient.mm; sourceTree = "<group>"; };
1C0706620A431E01001078F6 /* WebScriptDebugServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugServer.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
children = (
14D8252D0AF955090004F057 /* WebChromeClient.h */,
14D8252E0AF955090004F057 /* WebChromeClient.mm */,
+ 065AD5A10B0C32C7005A2B1D /* WebContextMenuClient.h */,
+ 065AD5A20B0C32C7005A2B1D /* WebContextMenuClient.mm */,
9305892A070868B300E79D96 /* WebDashboardRegion.h */,
4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */,
4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */,
14D8252F0AF955090004F057 /* WebChromeClient.h in Headers */,
9304B3000B02341500F7850D /* WebIconDatabaseInternal.h in Headers */,
51FDC4D30B0AF5C100F84EB3 /* WebHistoryItemPrivate.h in Headers */,
+ 065AD5A30B0C32C7005A2B1D /* WebContextMenuClient.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1CA57D630AED6A470009BDD0 /* WebGraphicsExtras.c in Sources */,
931633EF0AEDFFAE0062B92D /* WebFrameLoaderClient.mm in Sources */,
14D825300AF955090004F057 /* WebChromeClient.mm in Sources */,
+ 065AD5A40B0C32C7005A2B1D /* WebContextMenuClient.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#import "WebBackForwardList.h"
#import "WebBaseNetscapePluginView.h"
#import "WebChromeClient.h"
+#import "WebContextMenuClient.h"
#import "WebDOMOperationsPrivate.h"
#import "WebDashboardRegion.h"
#import "WebDataSourceInternal.h"
WebKitInitializeLoggingChannelsIfNecessary();
WebCore::InitializeLoggingChannelsIfNecessary();
- _private->page = new Page(WebChromeClient::create(self));
+ _private->page = new Page(WebChromeClient::create(self), WebContextMenuClient::create(self));
[[[WebFrameBridge alloc] initMainFrameWithPage:_private->page frameName:frameName view:frameView webView:self] release];
[self _addToAllWebViewsSet];