| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // then use the saved selection for that text control. | 167 // then use the saved selection for that text control. |
| 168 HTMLTextFormControlElement* textFormControlOfSelectionStart = | 168 HTMLTextFormControlElement* textFormControlOfSelectionStart = |
| 169 enclosingTextFormControl(selection.start()); | 169 enclosingTextFormControl(selection.start()); |
| 170 HTMLTextFormControlElement* textFromControlOfTarget = | 170 HTMLTextFormControlElement* textFromControlOfTarget = |
| 171 isHTMLTextFormControlElement(*event->target()->toNode()) | 171 isHTMLTextFormControlElement(*event->target()->toNode()) |
| 172 ? toHTMLTextFormControlElement(event->target()->toNode()) | 172 ? toHTMLTextFormControlElement(event->target()->toNode()) |
| 173 : 0; | 173 : 0; |
| 174 if (textFromControlOfTarget && | 174 if (textFromControlOfTarget && |
| 175 (selection.start().isNull() || | 175 (selection.start().isNull() || |
| 176 textFromControlOfTarget != textFormControlOfSelectionStart)) { | 176 textFromControlOfTarget != textFormControlOfSelectionStart)) { |
| 177 if (Range* range = textFromControlOfTarget->selection()) | 177 if (Range* range = textFromControlOfTarget->selection()) { |
| 178 return createVisibleSelectionDeprecated(EphemeralRange(range), | 178 return createVisibleSelection(EphemeralRange(range), |
| 179 TextAffinity::Downstream, | 179 TextAffinity::Downstream, |
| 180 selection.isDirectional()); | 180 selection.isDirectional()); |
| 181 } |
| 181 } | 182 } |
| 182 return selection; | 183 return selection; |
| 183 } | 184 } |
| 184 | 185 |
| 185 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. | 186 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. |
| 186 EditingBehavior Editor::behavior() const { | 187 EditingBehavior Editor::behavior() const { |
| 187 if (!frame().settings()) | 188 if (!frame().settings()) |
| 188 return EditingBehavior(EditingMacBehavior); | 189 return EditingBehavior(EditingMacBehavior); |
| 189 | 190 |
| 190 return EditingBehavior(frame().settings()->editingBehaviorType()); | 191 return EditingBehavior(frame().settings()->editingBehaviorType()); |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 isEndOfParagraph(caret) ? caret : nextPositionOf(caret); | 1187 isEndOfParagraph(caret) ? caret : nextPositionOf(caret); |
| 1187 VisiblePosition previous = previousPositionOf(next); | 1188 VisiblePosition previous = previousPositionOf(next); |
| 1188 if (next.deepEquivalent() == previous.deepEquivalent()) | 1189 if (next.deepEquivalent() == previous.deepEquivalent()) |
| 1189 return; | 1190 return; |
| 1190 previous = previousPositionOf(previous); | 1191 previous = previousPositionOf(previous); |
| 1191 if (!inSameParagraph(next, previous)) | 1192 if (!inSameParagraph(next, previous)) |
| 1192 return; | 1193 return; |
| 1193 const EphemeralRange range = makeRange(previous, next); | 1194 const EphemeralRange range = makeRange(previous, next); |
| 1194 if (range.isNull()) | 1195 if (range.isNull()) |
| 1195 return; | 1196 return; |
| 1196 VisibleSelection newSelection = createVisibleSelectionDeprecated(range); | 1197 VisibleSelection newSelection = createVisibleSelection(range); |
| 1197 | 1198 |
| 1198 // Transpose the two characters. | 1199 // Transpose the two characters. |
| 1199 String text = plainText(range); | 1200 String text = plainText(range); |
| 1200 if (text.length() != 2) | 1201 if (text.length() != 2) |
| 1201 return; | 1202 return; |
| 1202 String transposed = text.right(1) + text.left(1); | 1203 String transposed = text.right(1) + text.left(1); |
| 1203 | 1204 |
| 1204 // Select the two characters. | 1205 // Select the two characters. |
| 1205 if (newSelection != frame().selection().selection()) | 1206 if (newSelection != frame().selection().selection()) |
| 1206 frame().selection().setSelection(newSelection); | 1207 frame().selection().setSelection(newSelection); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 // TODO(yosin) We should make |findRangeOfString()| to return | 1320 // TODO(yosin) We should make |findRangeOfString()| to return |
| 1320 // |EphemeralRange| rather than|Range| object. | 1321 // |EphemeralRange| rather than|Range| object. |
| 1321 Range* resultRange = findRangeOfString( | 1322 Range* resultRange = findRangeOfString( |
| 1322 target, EphemeralRange(selection.start(), selection.end()), | 1323 target, EphemeralRange(selection.start(), selection.end()), |
| 1323 static_cast<FindOptions>(options | FindAPICall)); | 1324 static_cast<FindOptions>(options | FindAPICall)); |
| 1324 | 1325 |
| 1325 if (!resultRange) | 1326 if (!resultRange) |
| 1326 return false; | 1327 return false; |
| 1327 | 1328 |
| 1328 frame().selection().setSelection( | 1329 frame().selection().setSelection( |
| 1329 createVisibleSelectionDeprecated(EphemeralRange(resultRange))); | 1330 createVisibleSelection(EphemeralRange(resultRange))); |
| 1330 frame().selection().revealSelection(); | 1331 frame().selection().revealSelection(); |
| 1331 return true; | 1332 return true; |
| 1332 } | 1333 } |
| 1333 | 1334 |
| 1334 Range* Editor::findStringAndScrollToVisible(const String& target, | 1335 Range* Editor::findStringAndScrollToVisible(const String& target, |
| 1335 Range* previousMatch, | 1336 Range* previousMatch, |
| 1336 FindOptions options) { | 1337 FindOptions options) { |
| 1337 Range* nextMatch = findRangeOfString( | 1338 Range* nextMatch = findRangeOfString( |
| 1338 target, EphemeralRangeInFlatTree(previousMatch), options); | 1339 target, EphemeralRangeInFlatTree(previousMatch), options); |
| 1339 if (!nextMatch) | 1340 if (!nextMatch) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 DEFINE_TRACE(Editor) { | 1549 DEFINE_TRACE(Editor) { |
| 1549 visitor->trace(m_frame); | 1550 visitor->trace(m_frame); |
| 1550 visitor->trace(m_lastEditCommand); | 1551 visitor->trace(m_lastEditCommand); |
| 1551 visitor->trace(m_undoStack); | 1552 visitor->trace(m_undoStack); |
| 1552 visitor->trace(m_mark); | 1553 visitor->trace(m_mark); |
| 1553 } | 1554 } |
| 1554 | 1555 |
| 1555 } // namespace blink | 1556 } // namespace blink |
| OLD | NEW |