Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: Source/core/page/ContextMenuController.cpp

Issue 1032823003: Refactor HitTestResult to store the HitTestRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/layout/svg/line/SVGInlineTextBox.cpp ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 if (!event->isMouseEvent()) 152 if (!event->isMouseEvent())
153 return nullptr; 153 return nullptr;
154 154
155 MouseEvent* mouseEvent = toMouseEvent(event); 155 MouseEvent* mouseEvent = toMouseEvent(event);
156 return createContextMenu(event->target()->toNode()->document().frame(), mous eEvent->absoluteLocation()); 156 return createContextMenu(event->target()->toNode()->document().frame(), mous eEvent->absoluteLocation());
157 } 157 }
158 158
159 PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(LocalFrame* fra me, const LayoutPoint& location) 159 PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(LocalFrame* fra me, const LayoutPoint& location)
160 { 160 {
161 HitTestResult result(location); 161 HitTestRequest::HitTestRequestType type = HitTestRequest::ReadOnly | HitTest Request::Active;
162 HitTestResult result(type, location);
162 163
163 if (frame) 164 if (frame)
164 result = frame->eventHandler().hitTestResultAtPoint(location, HitTestReq uest::ReadOnly | HitTestRequest::Active); 165 result = frame->eventHandler().hitTestResultAtPoint(location, type);
165 166
166 if (!result.innerNonSharedNode()) 167 if (!result.innerNonSharedNode())
167 return nullptr; 168 return nullptr;
168 169
169 m_hitTestResult = result; 170 m_hitTestResult = result;
170 171
171 return adoptPtr(new ContextMenu); 172 return adoptPtr(new ContextMenu);
172 } 173 }
173 174
174 void ContextMenuController::showContextMenu(Event* event) 175 void ContextMenuController::showContextMenu(Event* event)
175 { 176 {
176 m_client->showContextMenu(m_contextMenu.get()); 177 m_client->showContextMenu(m_contextMenu.get());
177 if (event) 178 if (event)
178 event->setDefaultHandled(); 179 event->setDefaultHandled();
179 } 180 }
180 181
181 void ContextMenuController::contextMenuItemSelected(const ContextMenuItem* item) 182 void ContextMenuController::contextMenuItemSelected(const ContextMenuItem* item)
182 { 183 {
183 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); 184 ASSERT(item->type() == ActionType || item->type() == CheckableActionType);
184 185
185 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex tMenuItemLastCustomTag) 186 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex tMenuItemLastCustomTag)
186 return; 187 return;
187 188
188 ASSERT(m_menuProvider); 189 ASSERT(m_menuProvider);
189 m_menuProvider->contextMenuItemSelected(item); 190 m_menuProvider->contextMenuItemSelected(item);
190 } 191 }
191 192
192 } // namespace blink 193 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/svg/line/SVGInlineTextBox.cpp ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698