| 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 773 |
| 774 void SpellChecker::didEndEditingOnTextField(Element* e) { | 774 void SpellChecker::didEndEditingOnTextField(Element* e) { |
| 775 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); | 775 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); |
| 776 | 776 |
| 777 // Remove markers when deactivating a selection in an <input type="text"/>. | 777 // Remove markers when deactivating a selection in an <input type="text"/>. |
| 778 // Prevent new ones from appearing too. | 778 // Prevent new ones from appearing too. |
| 779 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 779 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 780 m_spellCheckRequester->cancelCheck(); | 780 m_spellCheckRequester->cancelCheck(); |
| 781 TextControlElement* textControlElement = toTextControlElement(e); | 781 TextControlElement* textControlElement = toTextControlElement(e); |
| 782 HTMLElement* innerEditor = textControlElement->innerEditorElement(); | 782 HTMLElement* innerEditor = textControlElement->innerEditorElement(); |
| 783 removeSpellingAndGrammarMarkers(*innerEditor); | |
| 784 } | |
| 785 | |
| 786 void SpellChecker::removeSpellingAndGrammarMarkers(const HTMLElement& element, | |
| 787 ElementsType elementsType) { | |
| 788 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 789 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 790 frame().document()->updateStyleAndLayoutTreeForNode(&element); | |
| 791 | |
| 792 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); | 783 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); |
| 793 markerTypes.add(DocumentMarker::Grammar); | 784 markerTypes.add(DocumentMarker::Grammar); |
| 794 for (Node& node : NodeTraversal::inclusiveDescendantsOf(element)) { | 785 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor)) |
| 795 if (elementsType == ElementsType::kAll || !hasEditableStyle(node)) | 786 frame().document()->markers().removeMarkers(&node, markerTypes); |
| 796 frame().document()->markers().removeMarkers(&node, markerTypes); | |
| 797 } | |
| 798 } | 787 } |
| 799 | 788 |
| 800 void SpellChecker::replaceMisspelledRange(const String& text) { | 789 void SpellChecker::replaceMisspelledRange(const String& text) { |
| 801 EphemeralRange caretRange = frame() | 790 EphemeralRange caretRange = frame() |
| 802 .selection() | 791 .selection() |
| 803 .computeVisibleSelectionInDOMTreeDeprecated() | 792 .computeVisibleSelectionInDOMTreeDeprecated() |
| 804 .toNormalizedEphemeralRange(); | 793 .toNormalizedEphemeralRange(); |
| 805 if (caretRange.isNull()) | 794 if (caretRange.isNull()) |
| 806 return; | 795 return; |
| 807 DocumentMarkerVector markers = frame().document()->markers().markersInRange( | 796 DocumentMarkerVector markers = frame().document()->markers().markersInRange( |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 if (!input.isFocusedElementInDocument()) | 1190 if (!input.isFocusedElementInDocument()) |
| 1202 return false; | 1191 return false; |
| 1203 } | 1192 } |
| 1204 } | 1193 } |
| 1205 HTMLElement* element = | 1194 HTMLElement* element = |
| 1206 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); | 1195 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); |
| 1207 return element && element->isSpellCheckingEnabled(); | 1196 return element && element->isSpellCheckingEnabled(); |
| 1208 } | 1197 } |
| 1209 | 1198 |
| 1210 } // namespace blink | 1199 } // namespace blink |
| OLD | NEW |