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

Side by Side Diff: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp

Issue 1668553003: Fix server-side image map click location with "Open link in new tab" Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: appendServerMapMousePosition function made static Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 RefPtrWillBeRawPtr<Range> markerRange = selectionRange->cloneRange(); 124 RefPtrWillBeRawPtr<Range> markerRange = selectionRange->cloneRange();
125 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset ()); 125 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset ());
126 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); 126 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset());
127 127
128 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) 128 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation))
129 return String(); 129 return String();
130 130
131 return markerRange->text(); 131 return markerRange->text();
132 } 132 }
133 133
134 void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) 134 void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu, Even t* event)
135 { 135 {
136 // Displaying the context menu in this function is a big hack as we don't 136 // Displaying the context menu in this function is a big hack as we don't
137 // have context, i.e. whether this is being invoked via a script or in 137 // have context, i.e. whether this is being invoked via a script or in
138 // response to user input (Mouse event WM_RBUTTONDOWN, 138 // response to user input (Mouse event WM_RBUTTONDOWN,
139 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked 139 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked
140 // in response to the above input events before popping up the context menu. 140 // in response to the above input events before popping up the context menu.
141 if (!ContextMenuAllowedScope::isContextMenuAllowed()) 141 if (!ContextMenuAllowedScope::isContextMenuAllowed())
142 return; 142 return;
143 143
144 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; 144 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ;
(...skipping 18 matching lines...) Expand all
163 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste()) 163 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste())
164 data.editFlags |= WebContextMenuData::CanPaste; 164 data.editFlags |= WebContextMenuData::CanPaste;
165 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete()) 165 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete())
166 data.editFlags |= WebContextMenuData::CanDelete; 166 data.editFlags |= WebContextMenuData::CanDelete;
167 // We can always select all... 167 // We can always select all...
168 data.editFlags |= WebContextMenuData::CanSelectAll; 168 data.editFlags |= WebContextMenuData::CanSelectAll;
169 data.editFlags |= WebContextMenuData::CanTranslate; 169 data.editFlags |= WebContextMenuData::CanTranslate;
170 170
171 // Links, Images, Media tags, and Image/Media-Links take preference over 171 // Links, Images, Media tags, and Image/Media-Links take preference over
172 // all else. 172 // all else.
173 data.linkURL = r.absoluteLinkURL(); 173 StringBuilder url;
zino 2016/02/05 05:47:34 Even if the target node is not image map link, Thi
174 HTMLAnchorElement::appendServerMapMousePosition(url, event);
175 data.linkURL = KURL(r.absoluteLinkURL(), url.toString());
174 176
175 if (r.innerNode()->isHTMLElement()) { 177 if (r.innerNode()->isHTMLElement()) {
176 HTMLElement* htmlElement = toHTMLElement(r.innerNode()); 178 HTMLElement* htmlElement = toHTMLElement(r.innerNode());
177 if (!htmlElement->title().isEmpty()) { 179 if (!htmlElement->title().isEmpty()) {
178 data.titleText = htmlElement->title(); 180 data.titleText = htmlElement->title();
179 } else { 181 } else {
180 data.titleText = htmlElement->altText(); 182 data.titleText = htmlElement->altText();
181 } 183 }
182 } 184 }
183 185
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 outputItems[i] = subItems[i]; 416 outputItems[i] = subItems[i];
415 subMenuItems.swap(outputItems); 417 subMenuItems.swap(outputItems);
416 } 418 }
417 419
418 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe nu, WebContextMenuData* data) 420 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe nu, WebContextMenuData* data)
419 { 421 {
420 populateSubMenuItems(defaultMenu->items(), data->customItems); 422 populateSubMenuItems(defaultMenu->items(), data->customItems);
421 } 423 }
422 424
423 } // namespace blink 425 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698