Commit ff7b94c4 authored by bweinstein@apple.com's avatar bweinstein@apple.com

Layering Violation in ContextMenu - member variable of type HitTestResult

https://bugs.webkit.org/show_bug.cgi?id=50586
        
Reviewed by John Sullivan.

WebCore: 

ContextMenu had a layering violation by having a member variable of type HitTestResult, because
classes in WebCore/platform can't know about classes in WebCore.
        
This patch moves the HitTestResult and all functions that use it out of ContextMenu into ContextMenuController.
All of the functions that dealt with populating the ContextMenu are now in ContextMenuController, and this
allowed us to delete the ContextMenu file, putting all of the cross-platform code that used to be it
in ContextMenuController, and the rest of the code is in the platform-specific files.

No change in behavior, no new tests.

* Android.mk: Removed ContextMenu.cpp.
* CMakeLists.txt: Ditto.
* GNUmakefile.am: Ditto.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::ContextMenuController): Initialized m_hitTestResult to an empty HitTestResult.
(WebCore::ContextMenuController::handleContextMenuEvent): Call populate on the ContextMenuController instead
    of the ContextMenu.
(WebCore::ContextMenuController::createContextMenu): Fix some indination, and store the HitTestResult in a member
    variable.
(WebCore::ContextMenuController::showContextMenu): Call addInspectElementItem on the ContextMenuController.
(WebCore::ContextMenuController::contextMenuItemSelected): Use m_hitTestResult whenever we need a HitTestResult.
(WebCore::ContextMenuController::appendItem): Validates the item for its state, and then appends it to the parent menu.
    This allowed us to move checkOrEnableIfNeeded from ContextMenu.

These functions were all moved from ContextMenu, and changed slightly to fit in ContextMenuController.
All calls to ContextMenu::appendItem were changed to ContextMenuController::appendItem, which takes care
of validating the menu.
(WebCore::separatorItem): Moved from ContextMenu.
(WebCore::ContextMenuController::createAndAppendFontSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSpellingAndGrammarSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSpeechSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendWritingDirectionSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendTextDirectionSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSubstitutionsSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendTransformationsSubMenu): Ditto.
(WebCore::selectionContainsPossibleWord): Ditto.
(WebCore::ContextMenuController::populate): Ditto.
(WebCore::ContextMenuController::addInspectElementItem): Ditto.
(WebCore::ContextMenuController::checkOrEnableIfNeeded): Ditto.
        
* page/ContextMenuController.h:
(WebCore::ContextMenuController::hitTestResult): Returns the HitTestResult of the current ContextMenu.

* platform/ContextMenu.cpp: Removed.
* platform/ContextMenu.h:
* platform/efl/ContextMenuEfl.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Removed the call to checkOrEnableIfNeeded.
* platform/gtk/ContextMenuGtk.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Ditto.
* platform/haiku/ContextMenuHaiku.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Ditto.
(WebCore::ContextMenu::insertItem): Ditto.
* platform/mac/ContextMenuMac.mm:
(-[WebCoreMenuTarget validateMenuItem:]): Calls checkOrEnableIfNeeded on the controller instead of
    the context menu.
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Removed the call to checkOrEnableIfNeeded.
(WebCore::ContextMenu::insertItem): Ditto.
* platform/win/ContextMenuWin.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::insertItem): Removed the call to checkOrEnableIfNeeded.
* platform/wx/ContextMenuWx.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(ContextMenu::appendItem): Ditto.

WebKit/chromium: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* src/ContextMenuClientImpl.cpp:
(WebKit::selectMisspelledWord):
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):

WebKit/gtk: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* WebCoreSupport/ContextMenuClientGtk.cpp:
(WebKit::ContextMenuClient::getCustomMenuFromDefaultItems):

WebKit/mac: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::getCustomMenuFromDefaultItems):
(WebContextMenuClient::contextMenuItemSelected):
* WebView/WebHTMLView.mm:
(-[WebMenuTarget validateMenuItem:]):

WebKit/qt: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* Api/qwebpage.cpp:
(QWebPagePrivate::createContextMenu):
(QWebPage::updatePositionDependentActions):

WebKit/win: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* WebCoreSupport/WebContextMenuClient.cpp:
(WebContextMenuClient::getCustomMenuFromDefaultItems): Get the HitTestResult and ContextMenu from the 
    ContextMenuController (from the page).
(WebContextMenuClient::contextMenuItemSelected): Get the HitTestResult from the ContextMenuController.
* WebView.cpp:
(WebView::handleContextMenuEvent): Ditto.

WebKit2: 

Update users of ContextMenu and ContextMenuController to match where the new functions 
are located.

* Shared/WebContextMenuItemData.cpp:
(WebKit::WebContextMenuItemData::WebContextMenuItemData): Remove the call to checkOrEnableItem, that call will be made when
    the ContextMenuItem is added to the ContextMenu through the ContextMenuController.
* WebProcess/WebPage/WebContextMenu.cpp:
(WebKit::WebContextMenu::show):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b0ecf4f8
......@@ -450,7 +450,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
\
platform/Arena.cpp \
platform/ContentType.cpp \
platform/ContextMenu.cpp \
platform/CrossThreadCopier.cpp \
platform/DeprecatedPtrListImpl.cpp \
platform/DragData.cpp \
......
......@@ -1270,7 +1270,6 @@ SET(WebCore_SOURCES
platform/Arena.cpp
platform/ContentType.cpp
platform/ContextMenu.cpp
platform/CrossThreadCopier.cpp
platform/DeprecatedPtrListImpl.cpp
platform/DragData.cpp
......
2010-12-07 Brian Weinstein <bweinstein@apple.com>
Reviewed by John Sullivan.
Layering Violation in ContextMenu - member variable of type HitTestResult
https://bugs.webkit.org/show_bug.cgi?id=50586
ContextMenu had a layering violation by having a member variable of type HitTestResult, because
classes in WebCore/platform can't know about classes in WebCore.
This patch moves the HitTestResult and all functions that use it out of ContextMenu into ContextMenuController.
All of the functions that dealt with populating the ContextMenu are now in ContextMenuController, and this
allowed us to delete the ContextMenu file, putting all of the cross-platform code that used to be it
in ContextMenuController, and the rest of the code is in the platform-specific files.
No change in behavior, no new tests.
* Android.mk: Removed ContextMenu.cpp.
* CMakeLists.txt: Ditto.
* GNUmakefile.am: Ditto.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::ContextMenuController): Initialized m_hitTestResult to an empty HitTestResult.
(WebCore::ContextMenuController::handleContextMenuEvent): Call populate on the ContextMenuController instead
of the ContextMenu.
(WebCore::ContextMenuController::createContextMenu): Fix some indination, and store the HitTestResult in a member
variable.
(WebCore::ContextMenuController::showContextMenu): Call addInspectElementItem on the ContextMenuController.
(WebCore::ContextMenuController::contextMenuItemSelected): Use m_hitTestResult whenever we need a HitTestResult.
(WebCore::ContextMenuController::appendItem): Validates the item for its state, and then appends it to the parent menu.
This allowed us to move checkOrEnableIfNeeded from ContextMenu.
These functions were all moved from ContextMenu, and changed slightly to fit in ContextMenuController.
All calls to ContextMenu::appendItem were changed to ContextMenuController::appendItem, which takes care
of validating the menu.
(WebCore::separatorItem): Moved from ContextMenu.
(WebCore::ContextMenuController::createAndAppendFontSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSpellingAndGrammarSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSpeechSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendWritingDirectionSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendTextDirectionSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendSubstitutionsSubMenu): Ditto.
(WebCore::ContextMenuController::createAndAppendTransformationsSubMenu): Ditto.
(WebCore::selectionContainsPossibleWord): Ditto.
(WebCore::ContextMenuController::populate): Ditto.
(WebCore::ContextMenuController::addInspectElementItem): Ditto.
(WebCore::ContextMenuController::checkOrEnableIfNeeded): Ditto.
* page/ContextMenuController.h:
(WebCore::ContextMenuController::hitTestResult): Returns the HitTestResult of the current ContextMenu.
* platform/ContextMenu.cpp: Removed.
* platform/ContextMenu.h:
* platform/efl/ContextMenuEfl.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Removed the call to checkOrEnableIfNeeded.
* platform/gtk/ContextMenuGtk.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Ditto.
* platform/haiku/ContextMenuHaiku.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Ditto.
(WebCore::ContextMenu::insertItem): Ditto.
* platform/mac/ContextMenuMac.mm:
(-[WebCoreMenuTarget validateMenuItem:]): Calls checkOrEnableIfNeeded on the controller instead of
the context menu.
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::appendItem): Removed the call to checkOrEnableIfNeeded.
(WebCore::ContextMenu::insertItem): Ditto.
* platform/win/ContextMenuWin.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(WebCore::ContextMenu::insertItem): Removed the call to checkOrEnableIfNeeded.
* platform/wx/ContextMenuWx.cpp:
(WebCore::ContextMenu::ContextMenu): Removed m_hitTestResult from the constructor.
(ContextMenu::appendItem): Ditto.
2010-12-08 Martin Robinson <mrobinson@igalia.com>
Reviewed by John Sullivan.
......
......@@ -2258,7 +2258,6 @@ webcore_sources += \
WebCore/platform/AutodrainedPool.h \
WebCore/platform/ContentType.cpp \
WebCore/platform/ContentType.h \
WebCore/platform/ContextMenu.cpp \
WebCore/platform/ContextMenu.h \
WebCore/platform/ContextMenuItem.h \
WebCore/platform/Cookie.h \
......
......@@ -1253,12 +1253,12 @@ __ZN7WebCore15ContextMenuItemC1ENS_19ContextMenuItemTypeENS_17ContextMenuActionE
__ZN7WebCore15ContextMenuItemC1EP10NSMenuItem
__ZN7WebCore15ContextMenuItemD1Ev
__ZN7WebCore21ContextMenuController16clearContextMenuEv
__ZNK7WebCore21ContextMenuController21checkOrEnableIfNeededERNS_15ContextMenuItemE
__ZN7WebCore21ContextMenuController23contextMenuItemSelectedEPNS_15ContextMenuItemE
__ZN7WebCore21contextMenuItemVectorEP14NSMutableArray
__ZN7WebCore23platformMenuDescriptionERN3WTF6VectorINS_15ContextMenuItemELm0EEE
__ZN7WebCore6Chrome15showContextMenuEv
__ZNK7WebCore11ContextMenu19platformDescriptionEv
__ZNK7WebCore11ContextMenu21checkOrEnableIfNeededERNS_15ContextMenuItemE
__ZNK7WebCore15ContextMenuItem15platformSubMenuEv
__ZNK7WebCore15ContextMenuItem4typeEv
__ZNK7WebCore15ContextMenuItem5titleEv
......
......@@ -3421,7 +3421,6 @@
'platform/AutodrainedPool.h',
'platform/ContentType.cpp',
'platform/ContentType.h',
'platform/ContextMenu.cpp',
'platform/ContextMenu.h',
'platform/ContextMenuItem.h',
'platform/Cookie.h',
......
......@@ -1151,7 +1151,6 @@ SOURCES += \
platform/text/BidiContext.cpp \
platform/text/Hyphenation.cpp \
platform/ContentType.cpp \
platform/ContextMenu.cpp \
platform/CrossThreadCopier.cpp \
platform/DeprecatedPtrListImpl.cpp \
platform/DragData.cpp \
......
......@@ -25313,10 +25313,6 @@
RelativePath="..\platform\ContentType.h"
>
</File>
<File
RelativePath="..\platform\ContextMenu.cpp"
>
</File>
<File
RelativePath="..\platform\ContextMenu.h"
>
......@@ -2839,7 +2839,6 @@
93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */; };
93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */; };
93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B6A0E80B0BCA6700F5027A /* ContextMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B6A0E70B0BCA6700F5027A /* ContextMenu.cpp */; };
93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */; };
93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */; };
93B70D6409EB0C7C009D8468 /* JSDOMBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -9007,7 +9006,6 @@
93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuddenTermination.h; sourceTree = "<group>"; };
93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SuddenTermination.mm; sourceTree = "<group>"; };
93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenu.h; sourceTree = "<group>"; };
93B6A0E70B0BCA6700F5027A /* ContextMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ContextMenu.cpp; sourceTree = "<group>"; };
93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuMac.mm; sourceTree = "<group>"; };
93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMBinding.cpp; sourceTree = "<group>"; };
93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDOMBinding.h; sourceTree = "<group>"; };
......@@ -17574,7 +17572,6 @@
BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
41D015C90F4B5C71004A662F /* ContentType.cpp */,
41D015C80F4B5C71004A662F /* ContentType.h */,
93B6A0E70B0BCA6700F5027A /* ContextMenu.cpp */,
93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */,
06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */,
D8B6152E1032495100C8554A /* Cookie.h */,
......@@ -21956,7 +21953,6 @@
A818721F0977D3C0005826D9 /* ContainerNode.cpp in Sources */,
BC5EB9800E82072500B25965 /* ContentData.cpp in Sources */,
41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
93B6A0E80B0BCA6700F5027A /* ContextMenu.cpp in Sources */,
065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */,
06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */,
This diff is collapsed.
......@@ -26,6 +26,7 @@
#ifndef ContextMenuController_h
#define ContextMenuController_h
#include "HitTestResult.h"
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
......@@ -45,7 +46,7 @@ namespace WebCore {
ContextMenuController(Page*, ContextMenuClient*);
~ContextMenuController();
ContextMenuClient* client() { return m_client; }
ContextMenuClient* client() const { return m_client; }
ContextMenu* contextMenu() const { return m_contextMenu.get(); }
void clearContextMenu();
......@@ -53,16 +54,35 @@ namespace WebCore {
void handleContextMenuEvent(Event*);
void showContextMenu(Event*, PassRefPtr<ContextMenuProvider>);
void populate();
void contextMenuItemSelected(ContextMenuItem*);
void addInspectElementItem();
void checkOrEnableIfNeeded(ContextMenuItem&) const;
void setHitTestResult(const HitTestResult& result) { m_hitTestResult = result; }
const HitTestResult& hitTestResult() { return m_hitTestResult; }
private:
ContextMenu* createContextMenu(Event*);
PassOwnPtr<ContextMenu> createContextMenu(Event*);
void showContextMenu(Event*);
void appendItem(ContextMenuItem&, ContextMenu* parentMenu);
void createAndAppendFontSubMenu(ContextMenuItem&);
void createAndAppendSpellingAndGrammarSubMenu(ContextMenuItem&);
void createAndAppendSpellingSubMenu(ContextMenuItem&);
void createAndAppendSpeechSubMenu(ContextMenuItem& );
void createAndAppendWritingDirectionSubMenu(ContextMenuItem&);
void createAndAppendTextDirectionSubMenu(ContextMenuItem&);
void createAndAppendSubstitutionsSubMenu(ContextMenuItem&);
void createAndAppendTransformationsSubMenu(ContextMenuItem&);
Page* m_page;
ContextMenuClient* m_client;
OwnPtr<ContextMenu> m_contextMenu;
RefPtr<ContextMenuProvider> m_menuProvider;
HitTestResult m_hitTestResult;
};
}
......
This diff is collapsed.
......@@ -29,7 +29,6 @@
#include <wtf/Noncopyable.h>
#include "ContextMenuItem.h"
#include "HitTestResult.h"
#include "PlatformMenuDescription.h"
#include "PlatformString.h"
#if PLATFORM(MAC)
......@@ -48,14 +47,10 @@ namespace WebCore {
class ContextMenu : public Noncopyable
{
public:
ContextMenu(const HitTestResult&);
ContextMenu(const HitTestResult&, const PlatformMenuDescription);
ContextMenu();
ContextMenu(const PlatformMenuDescription);
~ContextMenu();
void populate();
void addInspectElementItem();
void checkOrEnableIfNeeded(ContextMenuItem&) const;
void insertItem(unsigned position, ContextMenuItem&);
void appendItem(ContextMenuItem&);
......@@ -64,9 +59,6 @@ namespace WebCore {
unsigned itemCount() const;
HitTestResult hitTestResult() const { return m_hitTestResult; }
ContextMenuController* controller() const;
PlatformMenuDescription platformDescription() const;
void setPlatformDescription(PlatformMenuDescription);
......@@ -75,7 +67,6 @@ namespace WebCore {
static ContextMenuItem* itemWithId(int);
#endif
private:
HitTestResult m_hitTestResult;
#if PLATFORM(MAC)
// Keep this in sync with the PlatformMenuDescription typedef
RetainPtr<NSMutableArray> m_platformDescription;
......
......@@ -167,7 +167,7 @@ Pasteboard::~Pasteboard()
}
ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result)
ContextMenu::ContextMenu()
{
ASSERT_NOT_REACHED();
notImplemented();
......
......@@ -32,15 +32,13 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
ASSERT_NOT_REACHED();
notImplemented();
}
ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
: m_hitTestResult(result)
ContextMenu::ContextMenu(const PlatformMenuDescription menu)
{
ASSERT_NOT_REACHED();
notImplemented();
......
......@@ -36,13 +36,11 @@ namespace WebCore {
// This is a stub implementation of WebKit's ContextMenu class that does
// nothing.
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
}
ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
: m_hitTestResult(result)
ContextMenu::ContextMenu(const PlatformMenuDescription menu)
{
}
......
......@@ -29,30 +29,25 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
m_contextMenuClient = static_cast<ContextMenuClientEfl*>(controller()->client());
m_platformDescription = m_contextMenuClient->createPlatformDescription(this);
m_platformDescription = (PlatformMenuDescription) ewk_context_menu_new(m_view, menu->controller());
}
ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
: m_hitTestResult(result)
, m_platformDescription(menu)
ContextMenu::ContextMenu(const PlatformMenuDescription menu)
: m_platformDescription(menu)
{
m_contextMenuClient = static_cast<ContextMenuClientEfl*>(controller()->client());
}
ContextMenu::~ContextMenu()
{
if (m_platformDescription)
m_contextMenuClient->freePlatformDescription(m_platformDescription);
ewk_context_menu_free(static_cast<Ewk_Context_Menu*>(m_platformDescription));
}
void ContextMenu::appendItem(ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
m_contextMenuClient->appendItem(m_platformDescription, item);
ewk_context_menu_item_append(static_cast<Ewk_Context_Menu*>(m_platformDescription), item);
}
void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
......@@ -60,7 +55,7 @@ void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
ASSERT(!m_platformDescription);
m_platformDescription = menu;
m_contextMenuClient->show(m_platformDescription);
ewk_context_menu_show(static_cast<Ewk_Context_Menu*>(m_platformDescription));
}
PlatformMenuDescription ContextMenu::platformDescription() const
......
......@@ -116,8 +116,7 @@ void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
return;
m_platformDescription.type = SubmenuType;
m_platformDescription.subMenu = new ContextMenu(subMenu->hitTestResult(),
subMenu->releasePlatformDescription());
m_platformDescription.subMenu = new ContextMenu(subMenu->releasePlatformDescription());
}
bool ContextMenuItem::checked() const
......
......@@ -23,8 +23,7 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
m_platformDescription = GTK_MENU(gtk_menu_new());
......@@ -40,7 +39,6 @@ ContextMenu::~ContextMenu()
void ContextMenu::appendItem(ContextMenuItem& item)
{
ASSERT(m_platformDescription);
checkOrEnableIfNeeded(item);
GtkMenuItem* platformItem = ContextMenuItem::createNativeMenuItem(item.releasePlatformDescription());
ASSERT(platformItem);
......
......@@ -75,9 +75,8 @@ private:
int m_result;
};
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
, m_platformDescription(new BMenu("context_menu"))
ContextMenu::ContextMenu()
: m_platformDescription(new BMenu("context_menu"))
{
}
......@@ -88,8 +87,6 @@ ContextMenu::~ContextMenu()
void ContextMenu::appendItem(ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
BMenuItem* menuItem = item.releasePlatformDescription();
if (menuItem)
m_platformDescription->AddItem(menuItem);
......@@ -102,8 +99,6 @@ unsigned ContextMenu::itemCount() const
void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
BMenuItem* menuItem = item.releasePlatformDescription();
if (menuItem)
m_platformDescription->AddItem(menuItem, position);
......
......@@ -30,17 +30,15 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
NSMutableArray* array = [[NSMutableArray alloc] init];
m_platformDescription = array;
[array release];
}
ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
: m_hitTestResult(result)
, m_platformDescription(menu)
ContextMenu::ContextMenu(const PlatformMenuDescription menu)
: m_platformDescription(menu)
{
}
......@@ -50,8 +48,6 @@ ContextMenu::~ContextMenu()
void ContextMenu::appendItem(ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
NSMenuItem* platformItem = item.releasePlatformDescription();
[m_platformDescription.get() addObject:platformItem];
......@@ -60,8 +56,6 @@ void ContextMenu::appendItem(ContextMenuItem& item)
void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
NSMenuItem* platformItem = item.releasePlatformDescription();
[m_platformDescription.get() insertObject:platformItem atIndex:position];
......
......@@ -35,8 +35,7 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
ContextMenu::ContextMenu()
{
}
......
......@@ -43,9 +43,8 @@
namespace WebCore {
ContextMenu::ContextMenu(const HitTestResult& result)
: m_hitTestResult(result)
, m_platformDescription(0)
ContextMenu::ContextMenu()
: m_platformDescription(0)
#if OS(WINCE)
, m_itemCount(0)
#endif
......@@ -53,9 +52,8 @@ ContextMenu::ContextMenu(const HitTestResult& result)
setPlatformDescription(::CreatePopupMenu());
}
ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
: m_hitTestResult(result)
, m_platformDescription(0)
ContextMenu::ContextMenu(const PlatformMenuDescription menu)
: m_platformDescription(0)
#if OS(WINCE)
, m_itemCount(0)
#endif
......@@ -118,8 +116,6 @@ void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item)
if (!m_platformDescription)
return;
checkOrEnableIfNeeded(item);
#if OS(WINCE)
if (insertMenuItem(m_platformDescription, position, item))
++m_itemCount;
......
......@@ -42,7 +42,7 @@ ContextMenuItem* ContextMenu::itemWithId(int id)
return new ContextMenuItem(ActionType, s_itemActions.get(id), "");
}
ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result)
ContextMenu::ContextMenu()
{
m_platformDescription = new wxMenu(0);
}
......@@ -57,8 +57,6 @@ void ContextMenu::appendItem(ContextMenuItem& item)
{
if (!m_platformDescription)
return;
checkOrEnableIfNeeded(item);
PlatformMenuItemDescription itemDescription = item.releasePlatformDescription();
wxItemKind menuKindWx = ( itemDescription.type == CheckableActionType ) ? wxITEM_CHECK : wxITEM_NORMAL;
......
......@@ -48,6 +48,16 @@ namespace WebCore {
using namespace HTMLNames;
HitTestResult::HitTestResult()
: m_isOverWidget(false)
, m_isRectBased(false)
, m_topPadding(0)
, m_rightPadding(0)
, m_bottomPadding(0)
, m_leftPadding(0)
{
}
HitTestResult::HitTestResult(const IntPoint& point)
: m_point(point)
, m_isOverWidget(false)
......
......@@ -43,6 +43,7 @@ class Scrollbar;
class HitTestResult {
public:
HitTestResult();
HitTestResult(const IntPoint&);
// Pass non-negative padding values to perform a rect-based hit test.
HitTestResult(const IntPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
......
2010-12-07 Brian Weinstein <bweinstein@apple.com>
Reviewed by John Sullivan.
Layering Violation in ContextMenu - member variable of type HitTestResult
https://bugs.webkit.org/show_bug.cgi?id=50586
Update users of ContextMenu and ContextMenuController to match where the new functions
are located.
* src/ContextMenuClientImpl.cpp:
(WebKit::selectMisspelledWord):
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
2010-12-06 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
......
......@@ -34,6 +34,7 @@
#include "CSSPropertyNames.h"
#include "CSSStyleDeclaration.h"
#include "ContextMenu.h"
#include "ContextMenuController.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Editor.h"
......@@ -45,6 +46,7 @@
#include "HTMLNames.h"
#include "KURL.h"
#include "MediaError.h"
#include "Page.h"
#include "PlatformString.h"
#include "RenderWidget.h"
#include "TextBreakIterator.h"
......@@ -110,7 +112,7 @@ static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* select
// Selection is empty, so change the selection to the word under the cursor.
HitTestResult hitTestResult = selectedFrame->eventHandler()->
hitTestResultAtPoint(defaultMenu->hitTestResult().point(), true);
hitTestResultAtPoint(selectedFrame->page()->contextMenuController()->hitTestResult().point(), true);
Node* innerNode = hitTestResult.innerNode();
VisiblePosition pos(innerNode->renderer()->positionForPoint(
hitTestResult.localPoint()));
......@@ -144,7 +146,7 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
if (!m_webView->contextMenuAllowed())
return 0;
HitTestResult r = defaultMenu->hitTestResult();
HitTestResult r = m_webView->page()->contextMenuController()->hitTestResult();
Frame* selectedFrame = r.innerNonSharedNode()->document()->frame();
WebContextMenuData data;
......
2010-12-08 Brian Weinstein <bweinstein@apple.com>
Reviewed by John Sullivan.
Layering Violation in ContextMenu - member variable of type HitTestResult
https://bugs.webkit.org/show_bug.cgi?id=50586
Update users of ContextMenu and ContextMenuController to match where the new functions
are located.
* WebCoreSupport/ContextMenuClientGtk.cpp:
(WebKit::ContextMenuClient::getCustomMenuFromDefaultItems):
2010-12-08 Martin Robinson <mrobinson@igalia.com>
Reviewed by John Sullivan.
......
......@@ -20,10 +20,12 @@
#include "config.h"
#include "ContextMenu.h"
#include "ContextMenuClientGtk.h"
#include "ContextMenuController.h"