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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (isContinuousSpellCheckingEnabled() && unifiedTextCheckerEnabled()) { | 122 if (isContinuousSpellCheckingEnabled() && unifiedTextCheckerEnabled()) { |
123 bool isTextField = false; | 123 bool isTextField = false; |
124 HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0; | 124 HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0; |
125 if (!isHTMLTextFormControlElement(*element)) | 125 if (!isHTMLTextFormControlElement(*element)) |
126 enclosingHTMLTextFormControlElement = enclosingTextFormControl(first
PositionInNode(element)); | 126 enclosingHTMLTextFormControlElement = enclosingTextFormControl(first
PositionInNode(element)); |
127 element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormCon
trolElement : element; | 127 element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormCon
trolElement : element; |
128 Element* parent = element; | 128 Element* parent = element; |
129 if (isHTMLTextFormControlElement(*element)) { | 129 if (isHTMLTextFormControlElement(*element)) { |
130 HTMLTextFormControlElement* textControl = toHTMLTextFormControlEleme
nt(element); | 130 HTMLTextFormControlElement* textControl = toHTMLTextFormControlEleme
nt(element); |
131 parent = textControl; | 131 parent = textControl; |
132 element = textControl->innerTextElement(); | 132 element = textControl->innerEditorElement(); |
133 isTextField = isHTMLInputElement(*textControl) && toHTMLInputElement
(*textControl).isTextField(); | 133 isTextField = isHTMLInputElement(*textControl) && toHTMLInputElement
(*textControl).isTextField(); |
134 } | 134 } |
135 | 135 |
136 if (isTextField || !parent->isAlreadySpellChecked()) { | 136 if (isTextField || !parent->isAlreadySpellChecked()) { |
137 // We always recheck textfields because markers are removed from the
m on blur. | 137 // We always recheck textfields because markers are removed from the
m on blur. |
138 VisibleSelection selection = VisibleSelection::selectionFromContents
OfNode(element); | 138 VisibleSelection selection = VisibleSelection::selectionFromContents
OfNode(element); |
139 markMisspellingsAndBadGrammar(selection); | 139 markMisspellingsAndBadGrammar(selection); |
140 if (!isTextField) | 140 if (!isTextField) |
141 parent->setAlreadySpellChecked(true); | 141 parent->setAlreadySpellChecked(true); |
142 } | 142 } |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 | 695 |
696 document->markers().removeMarkers(wordRange.get(), DocumentMarker::Misspelli
ngMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); | 696 document->markers().removeMarkers(wordRange.get(), DocumentMarker::Misspelli
ngMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); |
697 } | 697 } |
698 | 698 |
699 void SpellChecker::didEndEditingOnTextField(Element* e) | 699 void SpellChecker::didEndEditingOnTextField(Element* e) |
700 { | 700 { |
701 // Remove markers when deactivating a selection in an <input type="text"/>. | 701 // Remove markers when deactivating a selection in an <input type="text"/>. |
702 // Prevent new ones from appearing too. | 702 // Prevent new ones from appearing too. |
703 m_spellCheckRequester->cancelCheck(); | 703 m_spellCheckRequester->cancelCheck(); |
704 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl
ement(e); | 704 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl
ement(e); |
705 HTMLElement* innerText = textFormControlElement->innerTextElement(); | 705 HTMLElement* innerEditor = textFormControlElement->innerEditorElement(); |
706 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); | 706 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); |
707 if (isGrammarCheckingEnabled() || unifiedTextCheckerEnabled()) | 707 if (isGrammarCheckingEnabled() || unifiedTextCheckerEnabled()) |
708 markerTypes.add(DocumentMarker::Grammar); | 708 markerTypes.add(DocumentMarker::Grammar); |
709 for (Node* node = innerText; node; node = NodeTraversal::next(*node, innerTe
xt)) { | 709 for (Node* node = innerEditor; node; node = NodeTraversal::next(*node, inner
Editor)) { |
710 m_frame.document()->markers().removeMarkers(node, markerTypes); | 710 m_frame.document()->markers().removeMarkers(node, markerTypes); |
711 } | 711 } |
712 } | 712 } |
713 | 713 |
714 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio
n, FrameSelection::SetSelectionOptions options) | 714 void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio
n, FrameSelection::SetSelectionOptions options) |
715 { | 715 { |
716 bool closeTyping = options & FrameSelection::CloseTyping; | 716 bool closeTyping = options & FrameSelection::CloseTyping; |
717 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabl
ed(); | 717 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabl
ed(); |
718 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled &
& isGrammarCheckingEnabled(); | 718 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled &
& isGrammarCheckingEnabled(); |
719 if (isContinuousSpellCheckingEnabled) { | 719 if (isContinuousSpellCheckingEnabled) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } | 847 } |
848 | 848 |
849 void SpellChecker::requestTextChecking(const Element& element) | 849 void SpellChecker::requestTextChecking(const Element& element) |
850 { | 850 { |
851 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); | 851 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); |
852 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); | 852 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); |
853 } | 853 } |
854 | 854 |
855 | 855 |
856 } // namespace WebCore | 856 } // namespace WebCore |
OLD | NEW |