Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: Source/core/editing/SpellChecker.cpp

Issue 196683003: Use new is*Element() helper functions more in editing code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 namespace WebCore { 49 namespace WebCore {
50 50
51 using namespace HTMLNames; 51 using namespace HTMLNames;
52 52
53 namespace { 53 namespace {
54 54
55 bool isSelectionInTextField(const VisibleSelection& selection) 55 bool isSelectionInTextField(const VisibleSelection& selection)
56 { 56 {
57 HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection .start()); 57 HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection .start());
58 return textControl && textControl->hasTagName(inputTag) && toHTMLInputElemen t(textControl)->isTextField(); 58 return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->i sTextField();
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 62
63 PassOwnPtr<SpellChecker> SpellChecker::create(LocalFrame& frame) 63 PassOwnPtr<SpellChecker> SpellChecker::create(LocalFrame& frame)
64 { 64 {
65 return adoptPtr(new SpellChecker(frame)); 65 return adoptPtr(new SpellChecker(frame));
66 } 66 }
67 67
68 static SpellCheckerClient& emptySpellCheckerClient() 68 static SpellCheckerClient& emptySpellCheckerClient()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bool isTextField = false; 121 bool isTextField = false;
122 HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0; 122 HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0;
123 if (!isHTMLTextFormControlElement(*element)) 123 if (!isHTMLTextFormControlElement(*element))
124 enclosingHTMLTextFormControlElement = enclosingTextFormControl(first PositionInNode(element)); 124 enclosingHTMLTextFormControlElement = enclosingTextFormControl(first PositionInNode(element));
125 element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormCon trolElement : element; 125 element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormCon trolElement : element;
126 Element* parent = element; 126 Element* parent = element;
127 if (isHTMLTextFormControlElement(*element)) { 127 if (isHTMLTextFormControlElement(*element)) {
128 HTMLTextFormControlElement* textControl = toHTMLTextFormControlEleme nt(element); 128 HTMLTextFormControlElement* textControl = toHTMLTextFormControlEleme nt(element);
129 parent = textControl; 129 parent = textControl;
130 element = textControl->innerTextElement(); 130 element = textControl->innerTextElement();
131 isTextField = textControl->hasTagName(inputTag) && toHTMLInputElemen t(textControl)->isTextField(); 131 isTextField = isHTMLInputElement(*textControl) && toHTMLInputElement (*textControl).isTextField();
132 } 132 }
133 133
134 if (isTextField || !parent->isAlreadySpellChecked()) { 134 if (isTextField || !parent->isAlreadySpellChecked()) {
135 // We always recheck textfields because markers are removed from the m on blur. 135 // We always recheck textfields because markers are removed from the m on blur.
136 VisibleSelection selection = VisibleSelection::selectionFromContents OfNode(element); 136 VisibleSelection selection = VisibleSelection::selectionFromContents OfNode(element);
137 markMisspellingsAndBadGrammar(selection); 137 markMisspellingsAndBadGrammar(selection);
138 if (!isTextField) 138 if (!isTextField)
139 parent->setAlreadySpellChecked(true); 139 parent->setAlreadySpellChecked(true);
140 } 140 }
141 } 141 }
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } 845 }
846 846
847 void SpellChecker::requestTextChecking(const Element& element) 847 void SpellChecker::requestTextChecking(const Element& element)
848 { 848 {
849 RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(&element)) ; 849 RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(&element)) ;
850 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 850 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
851 } 851 }
852 852
853 853
854 } // namespace WebCore 854 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698