| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // panel, and store a marker so we draw the red squiggle later. | 298 // panel, and store a marker so we draw the red squiggle later. |
| 299 | 299 |
| 300 const EphemeralRange misspelling_range = CalculateCharacterSubrange( | 300 const EphemeralRange misspelling_range = CalculateCharacterSubrange( |
| 301 EphemeralRange(spelling_search_start, spelling_search_end), | 301 EphemeralRange(spelling_search_start, spelling_search_end), |
| 302 misspelling_offset, misspelled_word.length()); | 302 misspelling_offset, misspelled_word.length()); |
| 303 GetFrame().Selection().SetSelection(SelectionInDOMTree::Builder() | 303 GetFrame().Selection().SetSelection(SelectionInDOMTree::Builder() |
| 304 .SetBaseAndExtent(misspelling_range) | 304 .SetBaseAndExtent(misspelling_range) |
| 305 .Build()); | 305 .Build()); |
| 306 GetFrame().Selection().RevealSelection(); | 306 GetFrame().Selection().RevealSelection(); |
| 307 GetSpellCheckerClient().UpdateSpellingUIWithMisspelledWord(misspelled_word); | 307 GetSpellCheckerClient().UpdateSpellingUIWithMisspelledWord(misspelled_word); |
| 308 GetFrame().GetDocument()->Markers().AddMarker( | 308 GetFrame().GetDocument()->Markers().AddSpellingMarker( |
| 309 misspelling_range.StartPosition(), misspelling_range.EndPosition(), | 309 misspelling_range.StartPosition(), misspelling_range.EndPosition()); |
| 310 DocumentMarker::kSpelling); | |
| 311 } | 310 } |
| 312 } | 311 } |
| 313 | 312 |
| 314 void SpellChecker::ShowSpellingGuessPanel() { | 313 void SpellChecker::ShowSpellingGuessPanel() { |
| 315 if (GetSpellCheckerClient().SpellingUIIsShowing()) { | 314 if (GetSpellCheckerClient().SpellingUIIsShowing()) { |
| 316 GetSpellCheckerClient().ShowSpellingUI(false); | 315 GetSpellCheckerClient().ShowSpellingUI(false); |
| 317 return; | 316 return; |
| 318 } | 317 } |
| 319 | 318 |
| 320 AdvanceToNextMisspelling(true); | 319 AdvanceToNextMisspelling(true); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 531 } |
| 533 } | 532 } |
| 534 } | 533 } |
| 535 | 534 |
| 536 static void AddMarker(Document* document, | 535 static void AddMarker(Document* document, |
| 537 const EphemeralRange& checking_range, | 536 const EphemeralRange& checking_range, |
| 538 DocumentMarker::MarkerType type, | 537 DocumentMarker::MarkerType type, |
| 539 int location, | 538 int location, |
| 540 int length, | 539 int length, |
| 541 const String& description) { | 540 const String& description) { |
| 541 DCHECK(type == DocumentMarker::kSpelling || type == DocumentMarker::kGrammar) |
| 542 << type; |
| 542 DCHECK_GT(length, 0); | 543 DCHECK_GT(length, 0); |
| 543 DCHECK_GE(location, 0); | 544 DCHECK_GE(location, 0); |
| 544 const EphemeralRange& range_to_mark = | 545 const EphemeralRange& range_to_mark = |
| 545 CalculateCharacterSubrange(checking_range, location, length); | 546 CalculateCharacterSubrange(checking_range, location, length); |
| 546 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) | 547 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) |
| 547 return; | 548 return; |
| 548 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) | 549 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) |
| 549 return; | 550 return; |
| 550 document->Markers().AddMarker(range_to_mark.StartPosition(), | 551 |
| 551 range_to_mark.EndPosition(), type, description); | 552 if (type == DocumentMarker::kSpelling) { |
| 553 document->Markers().AddSpellingMarker(range_to_mark.StartPosition(), |
| 554 range_to_mark.EndPosition(), |
| 555 description); |
| 556 return; |
| 557 } |
| 558 |
| 559 DCHECK_EQ(type, DocumentMarker::kGrammar); |
| 560 document->Markers().AddGrammarMarker( |
| 561 range_to_mark.StartPosition(), range_to_mark.EndPosition(), description); |
| 552 } | 562 } |
| 553 | 563 |
| 554 void SpellChecker::MarkAndReplaceFor( | 564 void SpellChecker::MarkAndReplaceFor( |
| 555 SpellCheckRequest* request, | 565 SpellCheckRequest* request, |
| 556 const Vector<TextCheckingResult>& results) { | 566 const Vector<TextCheckingResult>& results) { |
| 557 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 567 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
| 558 DCHECK(request); | 568 DCHECK(request); |
| 559 if (!GetFrame().Selection().IsAvailable()) { | 569 if (!GetFrame().Selection().IsAvailable()) { |
| 560 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. | 570 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. |
| 561 return; | 571 return; |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 if (!input.IsFocusedElementInDocument()) | 1230 if (!input.IsFocusedElementInDocument()) |
| 1221 return false; | 1231 return false; |
| 1222 } | 1232 } |
| 1223 } | 1233 } |
| 1224 HTMLElement* element = | 1234 HTMLElement* element = |
| 1225 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); | 1235 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); |
| 1226 return element && element->IsSpellCheckingEnabled(); | 1236 return element && element->IsSpellCheckingEnabled(); |
| 1227 } | 1237 } |
| 1228 | 1238 |
| 1229 } // namespace blink | 1239 } // namespace blink |
| OLD | NEW |