| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Igalia S.L | 3 * Copyright (C) 2010 Igalia S.L |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 m_menuProvider->contextMenuCleared(); | 65 m_menuProvider->contextMenuCleared(); |
| 66 m_menuProvider = 0; | 66 m_menuProvider = 0; |
| 67 m_hitTestResult = HitTestResult(); | 67 m_hitTestResult = HitTestResult(); |
| 68 m_client->clearContextMenu(); | 68 m_client->clearContextMenu(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void ContextMenuController::documentDetached(Document* document) | 71 void ContextMenuController::documentDetached(Document* document) |
| 72 { | 72 { |
| 73 if (Node* innerNode = m_hitTestResult.innerNode()) { | 73 if (Node* innerNode = m_hitTestResult.innerNode()) { |
| 74 // Invalidate the context menu info if its target document is detached. | 74 // Invalidate the context menu info if its target document is detached. |
| 75 if (innerNode->document() == document) | 75 if (&innerNode->document() == document) |
| 76 clearContextMenu(); | 76 clearContextMenu(); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ContextMenuController::handleContextMenuEvent(Event* event) | 80 void ContextMenuController::handleContextMenuEvent(Event* event) |
| 81 { | 81 { |
| 82 m_contextMenu = createContextMenu(event); | 82 m_contextMenu = createContextMenu(event); |
| 83 if (!m_contextMenu) | 83 if (!m_contextMenu) |
| 84 return; | 84 return; |
| 85 | 85 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(Event* event) | 103 PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(Event* event) |
| 104 { | 104 { |
| 105 ASSERT(event); | 105 ASSERT(event); |
| 106 | 106 |
| 107 if (!event->isMouseEvent()) | 107 if (!event->isMouseEvent()) |
| 108 return nullptr; | 108 return nullptr; |
| 109 | 109 |
| 110 MouseEvent* mouseEvent = toMouseEvent(event); | 110 MouseEvent* mouseEvent = toMouseEvent(event); |
| 111 HitTestResult result(mouseEvent->absoluteLocation()); | 111 HitTestResult result(mouseEvent->absoluteLocation()); |
| 112 | 112 |
| 113 if (Frame* frame = event->target()->toNode()->document()->frame()) | 113 if (Frame* frame = event->target()->toNode()->document().frame()) |
| 114 result = frame->eventHandler()->hitTestResultAtPoint(mouseEvent->absolut
eLocation(), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest:
:DisallowShadowContent); | 114 result = frame->eventHandler()->hitTestResultAtPoint(mouseEvent->absolut
eLocation(), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest:
:DisallowShadowContent); |
| 115 | 115 |
| 116 if (!result.innerNonSharedNode()) | 116 if (!result.innerNonSharedNode()) |
| 117 return nullptr; | 117 return nullptr; |
| 118 | 118 |
| 119 m_hitTestResult = result; | 119 m_hitTestResult = result; |
| 120 | 120 |
| 121 return adoptPtr(new ContextMenu); | 121 return adoptPtr(new ContextMenu); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ContextMenuController::showContextMenu(Event* event) | 124 void ContextMenuController::showContextMenu(Event* event) |
| 125 { | 125 { |
| 126 m_client->showContextMenu(m_contextMenu.get()); | 126 m_client->showContextMenu(m_contextMenu.get()); |
| 127 event->setDefaultHandled(); | 127 event->setDefaultHandled(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ContextMenuController::contextMenuItemSelected(const ContextMenuItem* item) | 130 void ContextMenuController::contextMenuItemSelected(const ContextMenuItem* item) |
| 131 { | 131 { |
| 132 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); | 132 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); |
| 133 | 133 |
| 134 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex
tMenuItemLastCustomTag) | 134 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex
tMenuItemLastCustomTag) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 ASSERT(m_menuProvider); | 137 ASSERT(m_menuProvider); |
| 138 m_menuProvider->contextMenuItemSelected(item); | 138 m_menuProvider->contextMenuItemSelected(item); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace WebCore | 141 } // namespace WebCore |
| OLD | NEW |