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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 | 795 |
796 void SpellChecker::didEndEditingOnTextField(Element* e) { | 796 void SpellChecker::didEndEditingOnTextField(Element* e) { |
797 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); | 797 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); |
798 | 798 |
799 // Remove markers when deactivating a selection in an <input type="text"/>. | 799 // Remove markers when deactivating a selection in an <input type="text"/>. |
800 // Prevent new ones from appearing too. | 800 // Prevent new ones from appearing too. |
801 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 801 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
802 m_spellCheckRequester->cancelCheck(); | 802 m_spellCheckRequester->cancelCheck(); |
803 TextControlElement* textControlElement = toTextControlElement(e); | 803 TextControlElement* textControlElement = toTextControlElement(e); |
804 HTMLElement* innerEditor = textControlElement->innerEditorElement(); | 804 HTMLElement* innerEditor = textControlElement->innerEditorElement(); |
805 removeSpellingAndGrammarMarkers(*innerEditor); | |
806 } | |
807 | |
808 void SpellChecker::removeSpellingAndGrammarMarkers(const HTMLElement& element, | |
809 ElementsType elementsType) { | |
805 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); | 810 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); |
806 markerTypes.add(DocumentMarker::Grammar); | 811 markerTypes.add(DocumentMarker::Grammar); |
807 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor)) | 812 for (Node& node : NodeTraversal::inclusiveDescendantsOf(element)) { |
808 frame().document()->markers().removeMarkers(&node, markerTypes); | 813 // TODO(editing-dev): The use of |
814 // updateStyleAndLayoutIgnorePendingStylesheets | |
815 // needs to be audited. See http://crbug.com/590369 for more details. | |
816 frame().document()->updateStyleAndLayoutTreeForNode(&node); | |
Xiaocheng
2017/02/01 05:20:28
This style and layout update should be placed out
Manuel Rego
2017/02/01 14:50:25
Done.
| |
817 if (elementsType == All || !hasEditableStyle(node)) | |
818 frame().document()->markers().removeMarkers(&node, markerTypes); | |
819 } | |
809 } | 820 } |
810 | 821 |
811 void SpellChecker::replaceMisspelledRange(const String& text) { | 822 void SpellChecker::replaceMisspelledRange(const String& text) { |
812 EphemeralRange caretRange = | 823 EphemeralRange caretRange = |
813 frame().selection().selection().toNormalizedEphemeralRange(); | 824 frame().selection().selection().toNormalizedEphemeralRange(); |
814 if (caretRange.isNull()) | 825 if (caretRange.isNull()) |
815 return; | 826 return; |
816 DocumentMarkerVector markers = frame().document()->markers().markersInRange( | 827 DocumentMarkerVector markers = frame().document()->markers().markersInRange( |
817 caretRange, DocumentMarker::MisspellingMarkers()); | 828 caretRange, DocumentMarker::MisspellingMarkers()); |
818 if (markers.size() < 1 || | 829 if (markers.size() < 1 || |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1167 startOfNextParagraph(createVisiblePosition(paragraphEnd)); | 1178 startOfNextParagraph(createVisiblePosition(paragraphEnd)); |
1168 paragraphStart = newParagraphStart.toParentAnchoredPosition(); | 1179 paragraphStart = newParagraphStart.toParentAnchoredPosition(); |
1169 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); | 1180 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); |
1170 firstIteration = false; | 1181 firstIteration = false; |
1171 totalLengthProcessed += currentLength; | 1182 totalLengthProcessed += currentLength; |
1172 } | 1183 } |
1173 return std::make_pair(firstFoundItem, firstFoundOffset); | 1184 return std::make_pair(firstFoundItem, firstFoundOffset); |
1174 } | 1185 } |
1175 | 1186 |
1176 } // namespace blink | 1187 } // namespace blink |
OLD | NEW |