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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 oldSelection.start().document()->updateStyleAndLayoutIgnorePendingStylesheet s(); | 787 oldSelection.start().document()->updateStyleAndLayoutIgnorePendingStylesheet s(); |
| 788 return oldSelection.isContentEditable(); | 788 return oldSelection.isContentEditable(); |
| 789 } | 789 } |
| 790 | 790 |
| 791 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio n, FrameSelection::SetSelectionOptions options) | 791 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio n, FrameSelection::SetSelectionOptions options) |
| 792 { | 792 { |
| 793 TRACE_EVENT0("blink", "SpellChecker::respondToChangedSelection"); | 793 TRACE_EVENT0("blink", "SpellChecker::respondToChangedSelection"); |
| 794 if (!isSpellCheckingEnabledFor(oldSelection)) | 794 if (!isSpellCheckingEnabledFor(oldSelection)) |
| 795 return; | 795 return; |
| 796 | 796 |
| 797 bool closeTyping = options & FrameSelection::CloseTyping; | 797 const bool closeTyping = options & FrameSelection::CloseTyping; |
| 798 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabl ed(); | 798 const bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckin gEnabled(); |
| 799 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled; | |
| 800 if (isContinuousSpellCheckingEnabled && closeTyping && shouldCheckOldSelecti on(oldSelection)) { | 799 if (isContinuousSpellCheckingEnabled && closeTyping && shouldCheckOldSelecti on(oldSelection)) { |
| 801 VisibleSelection newAdjacentWords; | 800 VisibleSelection newAdjacentWords; |
| 802 bool caretBrowsing = frame().settings() && frame().settings()->caretBrow singEnabled(); | 801 bool caretBrowsing = frame().settings() && frame().settings()->caretBrow singEnabled(); |
| 803 const VisibleSelection newSelection = frame().selection().selection(); | 802 const VisibleSelection newSelection = frame().selection().selection(); |
| 804 if (isSelectionInTextFormControl(newSelection)) { | 803 if (isSelectionInTextFormControl(newSelection)) { |
| 805 Position newStart = newSelection.start(); | 804 Position newStart = newSelection.start(); |
| 806 newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::st artOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart)); | 805 newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::st artOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart)); |
| 807 } else { | 806 } else { |
| 808 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 807 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 809 if (newSelection.isContentEditable() || caretBrowsing) { | 808 if (newSelection.isContentEditable() || caretBrowsing) { |
| 810 VisiblePosition newStart(newSelection.visibleStart()); | 809 VisiblePosition newStart(newSelection.visibleStart()); |
| 811 newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWo rdIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); | 810 newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWo rdIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); |
| 812 } | 811 } |
| 813 } | 812 } |
| 814 | 813 |
| 815 // When typing we check spelling elsewhere, so don't redo it here. | 814 // When typing we check spelling elsewhere, so don't redo it here. |
| 816 // If this is a change in selection resulting from a delete operation, | 815 // If this is a change in selection resulting from a delete operation, |
| 817 // oldSelection may no longer be in the document. | 816 // oldSelection may no longer be in the document. |
| 818 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea | 817 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea |
| 819 // element, we cause synchronous layout. | 818 // element, we cause synchronous layout. |
| 820 spellCheckOldSelection(oldSelection, newAdjacentWords); | 819 spellCheckOldSelection(oldSelection, newAdjacentWords); |
| 821 } | 820 } |
| 822 | 821 |
| 823 // When continuous spell checking is off, existing markers disappear after t he selection changes. | 822 // When continuous spell checking is off, existing markers disappear after t he selection changes. |
| 824 if (!isContinuousSpellCheckingEnabled) | 823 if (!isContinuousSpellCheckingEnabled) { |
|
yosin_UTC9
2016/06/30 03:49:44
We prefer early return.
When |isContinuousSpellCh
yoichio
2016/06/30 05:51:47
Done.
| |
| 825 frame().document()->markers().removeMarkers(DocumentMarker::Spelling); | 824 frame().document()->markers().removeMarkers(DocumentMarker::Spelling); |
| 826 if (!isContinuousGrammarCheckingEnabled) | |
| 827 frame().document()->markers().removeMarkers(DocumentMarker::Grammar); | 825 frame().document()->markers().removeMarkers(DocumentMarker::Grammar); |
| 826 } | |
| 828 } | 827 } |
| 829 | 828 |
| 830 void SpellChecker::removeSpellingMarkers() | 829 void SpellChecker::removeSpellingMarkers() |
| 831 { | 830 { |
| 832 frame().document()->markers().removeMarkers(DocumentMarker::MisspellingMarke rs()); | 831 frame().document()->markers().removeMarkers(DocumentMarker::MisspellingMarke rs()); |
| 833 } | 832 } |
| 834 | 833 |
| 835 void SpellChecker::removeSpellingMarkersUnderWords(const Vector<String>& words) | 834 void SpellChecker::removeSpellingMarkersUnderWords(const Vector<String>& words) |
| 836 { | 835 { |
| 837 MarkerRemoverPredicate removerPredicate(words); | 836 MarkerRemoverPredicate removerPredicate(words); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 visitor->trace(m_frame); | 954 visitor->trace(m_frame); |
| 956 visitor->trace(m_spellCheckRequester); | 955 visitor->trace(m_spellCheckRequester); |
| 957 } | 956 } |
| 958 | 957 |
| 959 void SpellChecker::prepareForLeakDetection() | 958 void SpellChecker::prepareForLeakDetection() |
| 960 { | 959 { |
| 961 m_spellCheckRequester->prepareForLeakDetection(); | 960 m_spellCheckRequester->prepareForLeakDetection(); |
| 962 } | 961 } |
| 963 | 962 |
| 964 } // namespace blink | 963 } // namespace blink |
| OLD | NEW |