Layering Violation in ContextMenu - member variable of type HitTestResult
authorbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Dec 2010 19:26:05 +0000 (19:26 +0000)
committerbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Dec 2010 19:26:05 +0000 (19:26 +0000)
commit00f7ec78e865aeeb1974c03ec2409a8892e228ef
tree8050de8c25de8405a1587c6c4db354ff9c397b71
parent50469ae20ea1a3894b5da4544d8cf3f8dfe19b3e
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: https://svn.webkit.org/repository/webkit/trunk@73535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
WebCore/Android.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.exp.in
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/page/ContextMenuController.cpp
WebCore/page/ContextMenuController.h
WebCore/platform/ContextMenu.cpp [deleted file]
WebCore/platform/ContextMenu.h
WebCore/platform/android/TemporaryLinkStubs.cpp
WebCore/platform/brew/ContextMenuBrew.cpp
WebCore/platform/chromium/ContextMenuChromium.cpp
WebCore/platform/efl/ContextMenuEfl.cpp
WebCore/platform/efl/ContextMenuItemEfl.cpp
WebCore/platform/gtk/ContextMenuGtk.cpp
WebCore/platform/haiku/ContextMenuHaiku.cpp
WebCore/platform/mac/ContextMenuMac.mm
WebCore/platform/qt/ContextMenuQt.cpp
WebCore/platform/win/ContextMenuWin.cpp
WebCore/platform/wx/ContextMenuWx.cpp
WebCore/rendering/HitTestResult.cpp
WebCore/rendering/HitTestResult.h
WebKit/chromium/ChangeLog
WebKit/chromium/src/ContextMenuClientImpl.cpp
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
WebKit/mac/WebView/WebHTMLView.mm
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog
WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/WebContextMenuClient.cpp
WebKit/win/WebView.cpp
WebKit2/ChangeLog
WebKit2/Shared/WebContextMenuItemData.cpp
WebKit2/WebProcess/WebPage/WebContextMenu.cpp