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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 24198006: [blink] Add a DocumentMarker::MisspellingMarkers helper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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/web/EditorClientImpl.cpp ('k') | no next file » | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 } 1233 }
1234 1234
1235 void WebFrameImpl::replaceMisspelledRange(const WebString& text) 1235 void WebFrameImpl::replaceMisspelledRange(const WebString& text)
1236 { 1236 {
1237 // If this caret selection has two or more markers, this function replace th e range covered by the first marker with the specified word as Microsoft Word do es. 1237 // If this caret selection has two or more markers, this function replace th e range covered by the first marker with the specified word as Microsoft Word do es.
1238 if (pluginContainerFromFrame(frame())) 1238 if (pluginContainerFromFrame(frame()))
1239 return; 1239 return;
1240 RefPtr<Range> caretRange = frame()->selection().toNormalizedRange(); 1240 RefPtr<Range> caretRange = frame()->selection().toNormalizedRange();
1241 if (!caretRange) 1241 if (!caretRange)
1242 return; 1242 return;
1243 Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInR ange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); 1243 Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInR ange(caretRange.get(), DocumentMarker::MisspellingMarkers());
1244 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset ()) 1244 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset ())
1245 return; 1245 return;
1246 RefPtr<Range> markerRange = Range::create(caretRange->ownerDocument(), caret Range->startContainer(), markers[0]->startOffset(), caretRange->endContainer(), markers[0]->endOffset()); 1246 RefPtr<Range> markerRange = Range::create(caretRange->ownerDocument(), caret Range->startContainer(), markers[0]->startOffset(), caretRange->endContainer(), markers[0]->endOffset());
1247 if (!markerRange) 1247 if (!markerRange)
1248 return; 1248 return;
1249 if (!frame()->selection().shouldChangeSelection(markerRange.get())) 1249 if (!frame()->selection().shouldChangeSelection(markerRange.get()))
1250 return; 1250 return;
1251 frame()->selection().setSelection(markerRange.get(), CharacterGranularity); 1251 frame()->selection().setSelection(markerRange.get(), CharacterGranularity);
1252 frame()->editor().replaceSelectionWithText(text, false, false); 1252 frame()->editor().replaceSelectionWithText(text, false, false);
1253 } 1253 }
1254 1254
1255 void WebFrameImpl::removeSpellingMarkers() 1255 void WebFrameImpl::removeSpellingMarkers()
1256 { 1256 {
1257 frame()->document()->markers()->removeMarkers(DocumentMarker::Spelling | Doc umentMarker::Grammar); 1257 frame()->document()->markers()->removeMarkers(DocumentMarker::MisspellingMar kers());
1258 } 1258 }
1259 1259
1260 bool WebFrameImpl::hasSelection() const 1260 bool WebFrameImpl::hasSelection() const
1261 { 1261 {
1262 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1262 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1263 if (pluginContainer) 1263 if (pluginContainer)
1264 return pluginContainer->plugin()->hasSelection(); 1264 return pluginContainer->plugin()->hasSelection();
1265 1265
1266 // frame()->selection()->isNone() never returns true. 1266 // frame()->selection()->isNone() never returns true.
1267 return frame()->selection().start() != frame()->selection().end(); 1267 return frame()->selection().start() != frame()->selection().end();
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 2476
2477 // There is a possibility that the frame being detached was the only 2477 // There is a possibility that the frame being detached was the only
2478 // pending one. We need to make sure final replies can be sent. 2478 // pending one. We need to make sure final replies can be sent.
2479 flushCurrentScopingEffort(m_findRequestIdentifier); 2479 flushCurrentScopingEffort(m_findRequestIdentifier);
2480 2480
2481 cancelPendingScopingEffort(); 2481 cancelPendingScopingEffort();
2482 } 2482 }
2483 } 2483 }
2484 2484
2485 } // namespace WebKit 2485 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/EditorClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698