| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 chunk_range.EndPosition(), check_range.EndPosition())); | 531 chunk_range.EndPosition(), check_range.EndPosition())); |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 static void AddMarker(Document* document, | 536 static void AddMarker(Document* document, |
| 537 const EphemeralRange& checking_range, | 537 const EphemeralRange& checking_range, |
| 538 DocumentMarker::MarkerType type, | 538 DocumentMarker::MarkerType type, |
| 539 int location, | 539 int location, |
| 540 int length, | 540 int length, |
| 541 const String& description) { | 541 const Vector<String>& descriptions) { |
| 542 DCHECK_GT(length, 0); | 542 DCHECK_GT(length, 0); |
| 543 DCHECK_GE(location, 0); | 543 DCHECK_GE(location, 0); |
| 544 const EphemeralRange& range_to_mark = | 544 const EphemeralRange& range_to_mark = |
| 545 CalculateCharacterSubrange(checking_range, location, length); | 545 CalculateCharacterSubrange(checking_range, location, length); |
| 546 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) | 546 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) |
| 547 return; | 547 return; |
| 548 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) | 548 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) |
| 549 return; | 549 return; |
| 550 |
| 551 String description; |
| 552 for (size_t i = 0; i < descriptions.size(); ++i) { |
| 553 if (i != 0) |
| 554 description.append('\n'); |
| 555 description.append(descriptions[i]); |
| 556 } |
| 557 |
| 550 document->Markers().AddMarker(range_to_mark.StartPosition(), | 558 document->Markers().AddMarker(range_to_mark.StartPosition(), |
| 551 range_to_mark.EndPosition(), type, description); | 559 range_to_mark.EndPosition(), type, description); |
| 552 } | 560 } |
| 553 | 561 |
| 554 void SpellChecker::MarkAndReplaceFor( | 562 void SpellChecker::MarkAndReplaceFor( |
| 555 SpellCheckRequest* request, | 563 SpellCheckRequest* request, |
| 556 const Vector<TextCheckingResult>& results) { | 564 const Vector<TextCheckingResult>& results) { |
| 557 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 565 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
| 558 DCHECK(request); | 566 DCHECK(request); |
| 559 if (!GetFrame().Selection().IsAvailable()) { | 567 if (!GetFrame().Selection().IsAvailable()) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // instance, we would not mark "wouldn'" as misspelled right after | 635 // instance, we would not mark "wouldn'" as misspelled right after |
| 628 // apostrophe is typed. | 636 // apostrophe is typed. |
| 629 switch (result.decoration) { | 637 switch (result.decoration) { |
| 630 case kTextDecorationTypeSpelling: | 638 case kTextDecorationTypeSpelling: |
| 631 if (result_location < paragraph.CheckingStart() || | 639 if (result_location < paragraph.CheckingStart() || |
| 632 result_location + result_length > spelling_range_end_offset || | 640 result_location + result_length > spelling_range_end_offset || |
| 633 result_ends_at_ambiguous_boundary) | 641 result_ends_at_ambiguous_boundary) |
| 634 continue; | 642 continue; |
| 635 AddMarker(GetFrame().GetDocument(), paragraph.CheckingRange(), | 643 AddMarker(GetFrame().GetDocument(), paragraph.CheckingRange(), |
| 636 DocumentMarker::kSpelling, result_location, result_length, | 644 DocumentMarker::kSpelling, result_location, result_length, |
| 637 result.replacement); | 645 result.replacements); |
| 638 continue; | 646 continue; |
| 639 | 647 |
| 640 case kTextDecorationTypeGrammar: | 648 case kTextDecorationTypeGrammar: |
| 641 if (!paragraph.CheckingRangeCovers(result_location, result_length)) | 649 if (!paragraph.CheckingRangeCovers(result_location, result_length)) |
| 642 continue; | 650 continue; |
| 643 DCHECK_GT(result_length, 0); | 651 DCHECK_GT(result_length, 0); |
| 644 DCHECK_GE(result_location, 0); | 652 DCHECK_GE(result_location, 0); |
| 645 for (const GrammarDetail& detail : result.details) { | 653 for (const GrammarDetail& detail : result.details) { |
| 646 DCHECK_GT(detail.length, 0); | 654 DCHECK_GT(detail.length, 0); |
| 647 DCHECK_GE(detail.location, 0); | 655 DCHECK_GE(detail.location, 0); |
| 648 if (!paragraph.CheckingRangeCovers(result_location + detail.location, | 656 if (!paragraph.CheckingRangeCovers(result_location + detail.location, |
| 649 detail.length)) | 657 detail.length)) |
| 650 continue; | 658 continue; |
| 651 AddMarker(GetFrame().GetDocument(), paragraph.CheckingRange(), | 659 AddMarker(GetFrame().GetDocument(), paragraph.CheckingRange(), |
| 652 DocumentMarker::kGrammar, result_location + detail.location, | 660 DocumentMarker::kGrammar, result_location + detail.location, |
| 653 detail.length, result.replacement); | 661 detail.length, result.replacements); |
| 654 } | 662 } |
| 655 continue; | 663 continue; |
| 656 } | 664 } |
| 657 NOTREACHED(); | 665 NOTREACHED(); |
| 658 } | 666 } |
| 659 } | 667 } |
| 660 | 668 |
| 661 void SpellChecker::UpdateMarkersForWordsAffectedByEditing( | 669 void SpellChecker::UpdateMarkersForWordsAffectedByEditing( |
| 662 bool do_not_remove_if_selection_at_word_boundary) { | 670 bool do_not_remove_if_selection_at_word_boundary) { |
| 663 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 671 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 if (!input.IsFocusedElementInDocument()) | 1206 if (!input.IsFocusedElementInDocument()) |
| 1199 return false; | 1207 return false; |
| 1200 } | 1208 } |
| 1201 } | 1209 } |
| 1202 HTMLElement* element = | 1210 HTMLElement* element = |
| 1203 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); | 1211 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); |
| 1204 return element && element->IsSpellCheckingEnabled(); | 1212 return element && element->IsSpellCheckingEnabled(); |
| 1205 } | 1213 } |
| 1206 | 1214 |
| 1207 } // namespace blink | 1215 } // namespace blink |
| OLD | NEW |