Commit bf821c6f authored by bdakin's avatar bdakin

WebCore:

        Reviewed by Adam. Manual test added.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=12399 REGRESSION: 
        Unable to prevent default context menu from appearing. <rdar://
        problem/5017416>

        This problem appeared because of two facets of the current context 
        menu design. First, all context menu events are now considered to 
        be "swallowed" since we take care of building up the regular 
        context menu through the defaultEventHandler(). Second, the context 
        menu controller holds onto it's context menu until a new one is 
        created. There would be logistical problems changing this since 
        AppKit relies on the menu being around for as long as it is
        visible on the screen and we don't get any notification once the 
        menu is popped-down.

        This patch fixes the problem by giving WebKit a way to clear the 
        controller's context menu. WebKit now clears the menu before it 
        propagates a new context menu event through the DOM.

        * WebCore.exp:
        * manual-tests/DOMContextMenuEvent.html: Added.
        * page/ContextMenuController.cpp:
        (WebCore::ContextMenuController::clearContextMenu):
        * page/ContextMenuController.h:

WebKit:
        Reviewed by Adam.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=12399 REGRESSION: 
        Unable to prevent default context menu from appearing. <rdar://
        problem/5017416>

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView menuForEvent:]): Clear the controller's context menu 
        before propagating a new context menu event through the DOM.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 03aeb879
2007-02-22 Beth Dakin <bdakin@apple.com>
Reviewed by Adam. Manual test added.
Fix for http://bugs.webkit.org/show_bug.cgi?id=12399 REGRESSION:
Unable to prevent default context menu from appearing. <rdar://
problem/5017416>
This problem appeared because of two facets of the current context
menu design. First, all context menu events are now considered to
be "swallowed" since we take care of building up the regular
context menu through the defaultEventHandler(). Second, the context
menu controller holds onto it's context menu until a new one is
created. There would be logistical problems changing this since
AppKit relies on the menu being around for as long as it is
visible on the screen and we don't get any notification once the
menu is popped-down.
This patch fixes the problem by giving WebKit a way to clear the
controller's context menu. WebKit now clears the menu before it
propagates a new context menu event through the DOM.
* WebCore.exp:
* manual-tests/DOMContextMenuEvent.html: Added.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::clearContextMenu):
* page/ContextMenuController.h:
2007-02-22 John Sullivan <sullivan@apple.com>
Reviewed by Kevin and Adele
......
......@@ -305,6 +305,7 @@ __ZN7WebCore19TextResourceDecoder5flushEv
__ZN7WebCore19TextResourceDecoder6decodeEPKcm
__ZN7WebCore19TextResourceDecoderC1ERKNS_6StringERKNS_12TextEncodingE
__ZN7WebCore19TextResourceDecoderD1Ev
__ZN7WebCore21ContextMenuController16clearContextMenuEv
__ZN7WebCore21PlatformKeyboardEventC1EP7NSEventb
__ZN7WebCore21findEventWithKeyStateEPNS_5EventE
__ZN7WebCore21isBackForwardLoadTypeENS_13FrameLoadTypeE
......
<html>
<script type="text/javascript">
function context_event(event)
{
if (window.event)
{
event = window.event;
}
var swallow = document.getElementById("swallow_context").checked;
var str =
"EVENT PROPERTIES<br>" +
"cancelable = "+event.cancelable+"<br>" +
"ctrlKey = "+event.ctrlKey+"<br>" +
"metaKey = "+event.metaKey+"<br>" +
"shiftKey = "+event.shiftKey+"<br>" +
"<br>" +
"TEST PROPERTIES<br>" +
"prevent default = "+swallow+"<br>" +
"event time = "+new Date()+"<br>" +
"";
document.getElementById("event_info").innerHTML=str;
if (swallow)
{
if ((typeof event.cancelBubble) != "undefined")
event.cancelBubble=true;
if ((typeof event.preventDefault) != "undefined")
event.preventDefault();
if ((typeof event.returnValue) != "undefined")
event.returnValue = false;
if ((typeof event.stopPropagation) != "undefined")
event.stopPropagation();
return false;
}
return true;
}
</script>
<body oncontextmenu="return context_event(event)">
<div>To activate context menu, right-click or ctrl-click anywhere on the page.</div>
<div>&nbsp;</div>
<div><input type="checkbox" value="1" name="swallow_context" id="swallow_context"> Prevent default context menu</div>
<div>&nbsp;</div>
<tt id="event_info" style='background-color:#eeeeee'>
-- No event captured --
</tt>
</body>
</html>
\ No newline at end of file
......@@ -69,6 +69,11 @@ ContextMenuController::~ContextMenuController()
m_client->contextMenuDestroyed();
}
void ContextMenuController::clearContextMenu()
{
m_contextMenu.set(0);
}
void ContextMenuController::handleContextMenuEvent(Event* event)
{
ASSERT(event->type() == contextmenuEvent);
......
......@@ -48,6 +48,7 @@ namespace WebCore {
ContextMenuClient* client() { return m_client; }
ContextMenu* contextMenu() const { return m_contextMenu.get(); }
void clearContextMenu();
void handleContextMenuEvent(Event*);
void contextMenuItemSelected(ContextMenuItem*);
......
2007-02-22 Beth Dakin <bdakin@apple.com>
Reviewed by Adam.
Fix for http://bugs.webkit.org/show_bug.cgi?id=12399 REGRESSION:
Unable to prevent default context menu from appearing. <rdar://
problem/5017416>
* WebView/WebHTMLView.mm:
(-[WebHTMLView menuForEvent:]): Clear the controller's context menu
before propagating a new context menu event through the DOM.
2007-02-22 John Sullivan <sullivan@apple.com>
Reviewed by Darin
......
......@@ -2627,16 +2627,17 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
return nil;
}
Page* page = coreFrame->page();
if (!page)
return nil;
page->contextMenuController()->clearContextMenu();
handledEvent = coreFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(event));
_private->handlingMouseDownEvent = NO;
if (!handledEvent)
return nil;
Page* page = coreFrame->page();
if (!page)
return nil;
ContextMenu* coreMenu = page->contextMenuController()->contextMenu();
if (!coreMenu)
return nil;
......
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