| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 TextControlElement* textControl = enclosingTextControl(selectionStart); | 65 TextControlElement* textControl = enclosingTextControl(selectionStart); |
| 66 return isHTMLInputElement(textControl) && | 66 return isHTMLInputElement(textControl) && |
| 67 toHTMLInputElement(textControl)->isTextField(); | 67 toHTMLInputElement(textControl)->isTextField(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool isPositionInTextArea(const Position& position) { | 70 bool isPositionInTextArea(const Position& position) { |
| 71 TextControlElement* textControl = enclosingTextControl(position); | 71 TextControlElement* textControl = enclosingTextControl(position); |
| 72 return isHTMLTextAreaElement(textControl); | 72 return isHTMLTextAreaElement(textControl); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool isSelectionInTextFormControl(const VisibleSelection& selection) { | |
| 76 return !!enclosingTextControl(selection.start()); | |
| 77 } | |
| 78 | |
| 79 static bool isSpellCheckingEnabledFor(const Position& position) { | 75 static bool isSpellCheckingEnabledFor(const Position& position) { |
| 80 if (position.isNull()) | 76 if (position.isNull()) |
| 81 return false; | 77 return false; |
| 82 // TODO(tkent): The following password type check should be done in | 78 // TODO(tkent): The following password type check should be done in |
| 83 // HTMLElement::spellcheck(). crbug.com/371567 | 79 // HTMLElement::spellcheck(). crbug.com/371567 |
| 84 if (TextControlElement* textControl = enclosingTextControl(position)) { | 80 if (TextControlElement* textControl = enclosingTextControl(position)) { |
| 85 if (isHTMLInputElement(textControl) && | 81 if (isHTMLInputElement(textControl) && |
| 86 toHTMLInputElement(textControl)->type() == InputTypeNames::password) | 82 toHTMLInputElement(textControl)->type() == InputTypeNames::password) |
| 87 return false; | 83 return false; |
| 88 } | 84 } |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 // needs to be audited. See http://crbug.com/590369 for more details. | 889 // needs to be audited. See http://crbug.com/590369 for more details. |
| 894 // In the long term we should use idle time spell checker to prevent | 890 // In the long term we should use idle time spell checker to prevent |
| 895 // synchronous layout caused by spell checking (see crbug.com/517298). | 891 // synchronous layout caused by spell checking (see crbug.com/517298). |
| 896 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 892 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 897 | 893 |
| 898 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 894 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
| 899 frame().document()->lifecycle()); | 895 frame().document()->lifecycle()); |
| 900 | 896 |
| 901 VisibleSelection newAdjacentWords; | 897 VisibleSelection newAdjacentWords; |
| 902 const VisibleSelection newSelection = frame().selection().selection(); | 898 const VisibleSelection newSelection = frame().selection().selection(); |
| 903 if (isSelectionInTextFormControl(newSelection)) { | 899 if (newSelection.isContentEditable()) { |
| 904 const Position newStart = newSelection.start(); | 900 newAdjacentWords = |
| 905 newAdjacentWords.setWithoutValidation( | 901 createVisibleSelection(selectWord(newSelection.visibleStart())); |
| 906 TextControlElement::startOfWord(newStart), | |
| 907 TextControlElement::endOfWord(newStart)); | |
| 908 } else { | |
| 909 if (newSelection.isContentEditable()) { | |
| 910 newAdjacentWords = | |
| 911 createVisibleSelection(selectWord(newSelection.visibleStart())); | |
| 912 } | |
| 913 } | 902 } |
| 914 | 903 |
| 915 // When typing we check spelling elsewhere, so don't redo it here. | 904 // When typing we check spelling elsewhere, so don't redo it here. |
| 916 // If this is a change in selection resulting from a delete operation, | 905 // If this is a change in selection resulting from a delete operation, |
| 917 // oldSelection may no longer be in the document. | 906 // oldSelection may no longer be in the document. |
| 918 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea | 907 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea |
| 919 // element, we cause synchronous layout. | 908 // element, we cause synchronous layout. |
| 920 spellCheckOldSelection(oldSelectionStart, newAdjacentWords); | 909 spellCheckOldSelection(oldSelectionStart, newAdjacentWords); |
| 921 } | 910 } |
| 922 | 911 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 startOfNextParagraph(createVisiblePosition(paragraphEnd)); | 1154 startOfNextParagraph(createVisiblePosition(paragraphEnd)); |
| 1166 paragraphStart = newParagraphStart.toParentAnchoredPosition(); | 1155 paragraphStart = newParagraphStart.toParentAnchoredPosition(); |
| 1167 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); | 1156 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); |
| 1168 firstIteration = false; | 1157 firstIteration = false; |
| 1169 totalLengthProcessed += currentLength; | 1158 totalLengthProcessed += currentLength; |
| 1170 } | 1159 } |
| 1171 return std::make_pair(firstFoundItem, firstFoundOffset); | 1160 return std::make_pair(firstFoundItem, firstFoundOffset); |
| 1172 } | 1161 } |
| 1173 | 1162 |
| 1174 } // namespace blink | 1163 } // namespace blink |
| OLD | NEW |