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

Side by Side Diff: Source/core/editing/Editor.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/core/dom/DocumentMarker.h ('k') | Source/core/editing/SpellCheckRequester.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, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 return; 1380 return;
1381 } 1381 }
1382 1382
1383 advanceToNextMisspelling(true); 1383 advanceToNextMisspelling(true);
1384 client().showSpellingUI(true); 1384 client().showSpellingUI(true);
1385 } 1385 }
1386 1386
1387 void Editor::clearMisspellingsAndBadGrammar(const VisibleSelection &movingSelect ion) 1387 void Editor::clearMisspellingsAndBadGrammar(const VisibleSelection &movingSelect ion)
1388 { 1388 {
1389 RefPtr<Range> selectedRange = movingSelection.toNormalizedRange(); 1389 RefPtr<Range> selectedRange = movingSelection.toNormalizedRange();
1390 if (selectedRange) { 1390 if (selectedRange)
1391 frame().document()->markers()->removeMarkers(selectedRange.get(), Docume ntMarker::Spelling); 1391 frame().document()->markers()->removeMarkers(selectedRange.get(), Docume ntMarker::MisspellingMarkers());
1392 frame().document()->markers()->removeMarkers(selectedRange.get(), Docume ntMarker::Grammar);
1393 }
1394 } 1392 }
1395 1393
1396 void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelecti on) 1394 void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelecti on)
1397 { 1395 {
1398 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab led() && isGrammarCheckingEnabled(), movingSelection); 1396 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab led() && isGrammarCheckingEnabled(), movingSelection);
1399 } 1397 }
1400 1398
1401 void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping) 1399 void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping)
1402 { 1400 {
1403 if (unifiedTextCheckerEnabled()) { 1401 if (unifiedTextCheckerEnabled()) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord. 1743 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord.
1746 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the 1744 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the
1747 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant 1745 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant
1748 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde, 1746 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde,
1749 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of 1747 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of
1750 // of marker that contains the word in question, and remove marker on that w hole range. 1748 // of marker that contains the word in question, and remove marker on that w hole range.
1751 Document* document = m_frame->document(); 1749 Document* document = m_frame->document();
1752 ASSERT(document); 1750 ASSERT(document);
1753 RefPtr<Range> wordRange = Range::create(*document, startOfFirstWord.deepEqui valent(), endOfLastWord.deepEquivalent()); 1751 RefPtr<Range> wordRange = Range::create(*document, startOfFirstWord.deepEqui valent(), endOfLastWord.deepEquivalent());
1754 1752
1755 document->markers()->removeMarkers(wordRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar, DocumentMarkerController::RemovePartiallyOverlapping Marker); 1753 document->markers()->removeMarkers(wordRange.get(), DocumentMarker::Misspell ingMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker);
1756 } 1754 }
1757 1755
1758 PassRefPtr<Range> Editor::rangeForPoint(const IntPoint& windowPoint) 1756 PassRefPtr<Range> Editor::rangeForPoint(const IntPoint& windowPoint)
1759 { 1757 {
1760 Document* document = m_frame->documentAtPoint(windowPoint); 1758 Document* document = m_frame->documentAtPoint(windowPoint);
1761 if (!document) 1759 if (!document)
1762 return 0; 1760 return 0;
1763 1761
1764 Frame* frame = document->frame(); 1762 Frame* frame = document->frame();
1765 ASSERT(frame); 1763 ASSERT(frame);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 return WebCore::unifiedTextCheckerEnabled(m_frame); 2211 return WebCore::unifiedTextCheckerEnabled(m_frame);
2214 } 2212 }
2215 2213
2216 void Editor::toggleOverwriteModeEnabled() 2214 void Editor::toggleOverwriteModeEnabled()
2217 { 2215 {
2218 m_overwriteModeEnabled = !m_overwriteModeEnabled; 2216 m_overwriteModeEnabled = !m_overwriteModeEnabled;
2219 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 2217 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
2220 }; 2218 };
2221 2219
2222 } // namespace WebCore 2220 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentMarker.h ('k') | Source/core/editing/SpellCheckRequester.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698