OLD | NEW |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return isSpaceOrNewline(c) || WTF::Unicode::isPunct(c); | 106 return isSpaceOrNewline(c) || WTF::Unicode::isPunct(c); |
107 } | 107 } |
108 | 108 |
109 static String selectMisspellingAsync(LocalFrame* selectedFrame, String& descript
ion, uint32_t& hash) | 109 static String selectMisspellingAsync(LocalFrame* selectedFrame, String& descript
ion, uint32_t& hash) |
110 { | 110 { |
111 VisibleSelection selection = selectedFrame->selection().selection(); | 111 VisibleSelection selection = selectedFrame->selection().selection(); |
112 if (!selection.isCaretOrRange()) | 112 if (!selection.isCaretOrRange()) |
113 return String(); | 113 return String(); |
114 | 114 |
115 // Caret and range selections always return valid normalized ranges. | 115 // Caret and range selections always return valid normalized ranges. |
116 RawPtr<Range> selectionRange = createRange(selection.toNormalizedEphemeralRa
nge()); | 116 Range* selectionRange = createRange(selection.toNormalizedEphemeralRange()); |
117 DocumentMarkerVector markers = selectedFrame->document()->markers().markersI
nRange(EphemeralRange(selectionRange.get()), DocumentMarker::MisspellingMarkers(
)); | 117 DocumentMarkerVector markers = selectedFrame->document()->markers().markersI
nRange(EphemeralRange(selectionRange), DocumentMarker::MisspellingMarkers()); |
118 if (markers.size() != 1) | 118 if (markers.size() != 1) |
119 return String(); | 119 return String(); |
120 description = markers[0]->description(); | 120 description = markers[0]->description(); |
121 hash = markers[0]->hash(); | 121 hash = markers[0]->hash(); |
122 | 122 |
123 // Cloning a range fails only for invalid ranges. | 123 // Cloning a range fails only for invalid ranges. |
124 RawPtr<Range> markerRange = selectionRange->cloneRange(); | 124 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) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // in that case. See https://crbug.com/534561 | 270 // in that case. See https://crbug.com/534561 |
271 WebSecurityOrigin origin = m_webView->mainFrame()->getSecurityOrigin(); | 271 WebSecurityOrigin origin = m_webView->mainFrame()->getSecurityOrigin(); |
272 if (!origin.isNull()) | 272 if (!origin.isNull()) |
273 data.pageURL = KURL(ParsedURLString, origin.toString()); | 273 data.pageURL = KURL(ParsedURLString, origin.toString()); |
274 } else { | 274 } else { |
275 data.pageURL = urlFromFrame(toLocalFrame(m_webView->page()->mainFrame())
); | 275 data.pageURL = urlFromFrame(toLocalFrame(m_webView->page()->mainFrame())
); |
276 } | 276 } |
277 | 277 |
278 if (selectedFrame != m_webView->page()->mainFrame()) { | 278 if (selectedFrame != m_webView->page()->mainFrame()) { |
279 data.frameURL = urlFromFrame(selectedFrame); | 279 data.frameURL = urlFromFrame(selectedFrame); |
280 RawPtr<HistoryItem> historyItem = selectedFrame->loader().currentItem(); | 280 HistoryItem* historyItem = selectedFrame->loader().currentItem(); |
281 if (historyItem) | 281 if (historyItem) |
282 data.frameHistoryItem = WebHistoryItem(historyItem); | 282 data.frameHistoryItem = WebHistoryItem(historyItem); |
283 } | 283 } |
284 | 284 |
285 if (r.isSelected()) { | 285 if (r.isSelected()) { |
286 if (!isHTMLInputElement(*r.innerNode()) || toHTMLInputElement(r.innerNod
e())->type() != InputTypeNames::password) | 286 if (!isHTMLInputElement(*r.innerNode()) || toHTMLInputElement(r.innerNod
e())->type() != InputTypeNames::password) |
287 data.selectedText = selectedFrame->selectedText().stripWhiteSpace(); | 287 data.selectedText = selectedFrame->selectedText().stripWhiteSpace(); |
288 } | 288 } |
289 | 289 |
290 if (r.isContentEditable()) { | 290 if (r.isContentEditable()) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 outputItems[i] = subItems[i]; | 414 outputItems[i] = subItems[i]; |
415 subMenuItems.swap(outputItems); | 415 subMenuItems.swap(outputItems); |
416 } | 416 } |
417 | 417 |
418 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) | 418 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) |
419 { | 419 { |
420 populateSubMenuItems(defaultMenu->items(), data->customItems); | 420 populateSubMenuItems(defaultMenu->items(), data->customItems); |
421 } | 421 } |
422 | 422 |
423 } // namespace blink | 423 } // namespace blink |
OLD | NEW |