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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // "editing/spelling/spellcheck-async-mutation.html" reaches here. | 597 // "editing/spelling/spellcheck-async-mutation.html" reaches here. |
598 return; | 598 return; |
599 } | 599 } |
600 | 600 |
601 TextCheckingParagraph paragraph(checking_range, checking_range); | 601 TextCheckingParagraph paragraph(checking_range, checking_range); |
602 | 602 |
603 // TODO(xiaochengh): The following comment does not match the current behavior | 603 // TODO(xiaochengh): The following comment does not match the current behavior |
604 // and should be rewritten. | 604 // and should be rewritten. |
605 // Expand the range to encompass entire paragraphs, since text checking needs | 605 // Expand the range to encompass entire paragraphs, since text checking needs |
606 // that much context. | 606 // that much context. |
607 int selection_offset = 0; | |
608 int ambiguous_boundary_offset = -1; | 607 int ambiguous_boundary_offset = -1; |
609 | 608 |
610 if (GetFrame().Selection().ComputeVisibleSelectionInDOMTree().IsCaret()) { | 609 if (GetFrame().Selection().ComputeVisibleSelectionInDOMTree().IsCaret()) { |
611 // TODO(xiaochengh): The following comment does not match the current | 610 // TODO(xiaochengh): The following comment does not match the current |
612 // behavior and should be rewritten. | 611 // behavior and should be rewritten. |
613 // Attempt to save the caret position so we can restore it later if needed | 612 // Attempt to save the caret position so we can restore it later if needed |
614 const Position& caret_position = | 613 const Position& caret_position = |
615 GetFrame().Selection().ComputeVisibleSelectionInDOMTree().end(); | 614 GetFrame().Selection().ComputeVisibleSelectionInDOMTree().end(); |
616 selection_offset = paragraph.OffsetTo(caret_position); | 615 const Position& paragraph_start = checking_range.StartPosition(); |
| 616 const int selection_offset = |
| 617 paragraph_start < caret_position |
| 618 ? TextIterator::RangeLength(paragraph_start, caret_position) |
| 619 : 0; |
617 if (selection_offset > 0 && | 620 if (selection_offset > 0 && |
618 static_cast<unsigned>(selection_offset) <= | 621 static_cast<unsigned>(selection_offset) <= |
619 paragraph.GetText().length() && | 622 paragraph.GetText().length() && |
620 IsAmbiguousBoundaryCharacter( | 623 IsAmbiguousBoundaryCharacter( |
621 paragraph.TextCharAt(selection_offset - 1))) { | 624 paragraph.TextCharAt(selection_offset - 1))) { |
622 ambiguous_boundary_offset = selection_offset - 1; | 625 ambiguous_boundary_offset = selection_offset - 1; |
623 } | 626 } |
624 } | 627 } |
625 | 628 |
626 const int spelling_range_end_offset = paragraph.CheckingEnd(); | 629 const int spelling_range_end_offset = paragraph.CheckingEnd(); |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 if (!input.IsFocusedElementInDocument()) | 1235 if (!input.IsFocusedElementInDocument()) |
1233 return false; | 1236 return false; |
1234 } | 1237 } |
1235 } | 1238 } |
1236 HTMLElement* element = | 1239 HTMLElement* element = |
1237 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); | 1240 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); |
1238 return element && element->IsSpellCheckingEnabled(); | 1241 return element && element->IsSpellCheckingEnabled(); |
1239 } | 1242 } |
1240 | 1243 |
1241 } // namespace blink | 1244 } // namespace blink |
OLD | NEW |