Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 // panel, and store a marker so we draw the red squiggle later. | 295 // panel, and store a marker so we draw the red squiggle later. |
| 296 | 296 |
| 297 const EphemeralRange misspellingRange = calculateCharacterSubrange( | 297 const EphemeralRange misspellingRange = calculateCharacterSubrange( |
| 298 EphemeralRange(spellingSearchStart, spellingSearchEnd), | 298 EphemeralRange(spellingSearchStart, spellingSearchEnd), |
| 299 misspellingOffset, misspelledWord.length()); | 299 misspellingOffset, misspelledWord.length()); |
| 300 frame().selection().setSelection(SelectionInDOMTree::Builder() | 300 frame().selection().setSelection(SelectionInDOMTree::Builder() |
| 301 .setBaseAndExtent(misspellingRange) | 301 .setBaseAndExtent(misspellingRange) |
| 302 .build()); | 302 .build()); |
| 303 frame().selection().revealSelection(); | 303 frame().selection().revealSelection(); |
| 304 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); | 304 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); |
| 305 frame().document()->markers().addSpellingMarker( | 305 frame().document()->markers().addSpellingMarker(misspellingRange); |
| 306 misspellingRange.startPosition(), misspellingRange.endPosition()); | |
| 307 } | 306 } |
| 308 } | 307 } |
| 309 | 308 |
| 310 void SpellChecker::showSpellingGuessPanel() { | 309 void SpellChecker::showSpellingGuessPanel() { |
| 311 if (spellCheckerClient().spellingUIIsShowing()) { | 310 if (spellCheckerClient().spellingUIIsShowing()) { |
| 312 spellCheckerClient().showSpellingUI(false); | 311 spellCheckerClient().showSpellingUI(false); |
| 313 return; | 312 return; |
| 314 } | 313 } |
| 315 | 314 |
| 316 advanceToNextMisspelling(true); | 315 advanceToNextMisspelling(true); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 DCHECK_GT(length, 0); | 541 DCHECK_GT(length, 0); |
| 543 DCHECK_GE(location, 0); | 542 DCHECK_GE(location, 0); |
| 544 const EphemeralRange& rangeToMark = | 543 const EphemeralRange& rangeToMark = |
| 545 calculateCharacterSubrange(checkingRange, location, length); | 544 calculateCharacterSubrange(checkingRange, location, length); |
| 546 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.startPosition())) | 545 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.startPosition())) |
| 547 return; | 546 return; |
| 548 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.endPosition())) | 547 if (!SpellChecker::isSpellCheckingEnabledAt(rangeToMark.endPosition())) |
| 549 return; | 548 return; |
| 550 | 549 |
| 551 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); | 550 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); |
| 552 if (type == DocumentMarker::Grammar) { | 551 if (type == DocumentMarker::Grammar) { |
|
Xiaocheng
2017/03/22 21:21:01
nit: no need to have braces now.
| |
| 553 document->markers().addGrammarMarker( | 552 document->markers().addGrammarMarker(rangeToMark, description); |
| 554 rangeToMark.startPosition(), rangeToMark.endPosition(), description); | |
| 555 } else { | 553 } else { |
| 556 document->markers().addSpellingMarker( | 554 document->markers().addSpellingMarker(rangeToMark, description); |
| 557 rangeToMark.startPosition(), rangeToMark.endPosition(), description); | |
| 558 } | 555 } |
| 559 } | 556 } |
| 560 | 557 |
| 561 void SpellChecker::markAndReplaceFor( | 558 void SpellChecker::markAndReplaceFor( |
| 562 SpellCheckRequest* request, | 559 SpellCheckRequest* request, |
| 563 const Vector<TextCheckingResult>& results) { | 560 const Vector<TextCheckingResult>& results) { |
| 564 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 561 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
| 565 DCHECK(request); | 562 DCHECK(request); |
| 566 if (!frame().selection().isAvailable()) { | 563 if (!frame().selection().isAvailable()) { |
| 567 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. | 564 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 if (!input.isFocusedElementInDocument()) | 1184 if (!input.isFocusedElementInDocument()) |
| 1188 return false; | 1185 return false; |
| 1189 } | 1186 } |
| 1190 } | 1187 } |
| 1191 HTMLElement* element = | 1188 HTMLElement* element = |
| 1192 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); | 1189 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); |
| 1193 return element && element->isSpellCheckingEnabled(); | 1190 return element && element->isSpellCheckingEnabled(); |
| 1194 } | 1191 } |
| 1195 | 1192 |
| 1196 } // namespace blink | 1193 } // namespace blink |
| OLD | NEW |