| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 frame().selection().updateIfNeeded(); | 153 frame().selection().updateIfNeeded(); |
| 154 VisibleSelection selection = frame().selection().selection(); | 154 VisibleSelection selection = frame().selection().selection(); |
| 155 if (!event) | 155 if (!event) |
| 156 return selection; | 156 return selection; |
| 157 // If the target is a text control, and the current selection is outside of
its shadow tree, | 157 // If the target is a text control, and the current selection is outside of
its shadow tree, |
| 158 // then use the saved selection for that text control. | 158 // then use the saved selection for that text control. |
| 159 HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextF
ormControl(selection.start()); | 159 HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextF
ormControl(selection.start()); |
| 160 HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlE
lement(*event->target()->toNode()) ? toHTMLTextFormControlElement(event->target(
)->toNode()) : 0; | 160 HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlE
lement(*event->target()->toNode()) ? toHTMLTextFormControlElement(event->target(
)->toNode()) : 0; |
| 161 if (textFromControlOfTarget && (selection.start().isNull() || textFromContro
lOfTarget != textFormControlOfSelectionStart)) { | 161 if (textFromControlOfTarget && (selection.start().isNull() || textFromContro
lOfTarget != textFormControlOfSelectionStart)) { |
| 162 if (Range* range = textFromControlOfTarget->selection()) | 162 if (Range* range = textFromControlOfTarget->selection()) |
| 163 return VisibleSelection(EphemeralRange(range), TextAffinity::Downstr
eam, selection.isDirectional()); | 163 return createVisibleSelectionDeprecated(EphemeralRange(range), TextA
ffinity::Downstream, selection.isDirectional()); |
| 164 } | 164 } |
| 165 return selection; | 165 return selection; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. | 168 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. |
| 169 EditingBehavior Editor::behavior() const | 169 EditingBehavior Editor::behavior() const |
| 170 { | 170 { |
| 171 if (!frame().settings()) | 171 if (!frame().settings()) |
| 172 return EditingBehavior(EditingMacBehavior); | 172 return EditingBehavior(EditingMacBehavior); |
| 173 | 173 |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 VisiblePosition next = isEndOfParagraph(caret) ? caret : nextPositionOf(care
t); | 1106 VisiblePosition next = isEndOfParagraph(caret) ? caret : nextPositionOf(care
t); |
| 1107 VisiblePosition previous = previousPositionOf(next); | 1107 VisiblePosition previous = previousPositionOf(next); |
| 1108 if (next.deepEquivalent() == previous.deepEquivalent()) | 1108 if (next.deepEquivalent() == previous.deepEquivalent()) |
| 1109 return; | 1109 return; |
| 1110 previous = previousPositionOf(previous); | 1110 previous = previousPositionOf(previous); |
| 1111 if (!inSameParagraph(next, previous)) | 1111 if (!inSameParagraph(next, previous)) |
| 1112 return; | 1112 return; |
| 1113 const EphemeralRange range = makeRange(previous, next); | 1113 const EphemeralRange range = makeRange(previous, next); |
| 1114 if (range.isNull()) | 1114 if (range.isNull()) |
| 1115 return; | 1115 return; |
| 1116 VisibleSelection newSelection(range); | 1116 VisibleSelection newSelection = createVisibleSelectionDeprecated(range); |
| 1117 | 1117 |
| 1118 // Transpose the two characters. | 1118 // Transpose the two characters. |
| 1119 String text = plainText(range); | 1119 String text = plainText(range); |
| 1120 if (text.length() != 2) | 1120 if (text.length() != 2) |
| 1121 return; | 1121 return; |
| 1122 String transposed = text.right(1) + text.left(1); | 1122 String transposed = text.right(1) + text.left(1); |
| 1123 | 1123 |
| 1124 // Select the two characters. | 1124 // Select the two characters. |
| 1125 if (newSelection != frame().selection().selection()) | 1125 if (newSelection != frame().selection().selection()) |
| 1126 frame().selection().setSelection(newSelection); | 1126 frame().selection().setSelection(newSelection); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 { | 1225 { |
| 1226 VisibleSelection selection = frame().selection().selection(); | 1226 VisibleSelection selection = frame().selection().selection(); |
| 1227 | 1227 |
| 1228 // TODO(yosin) We should make |findRangeOfString()| to return | 1228 // TODO(yosin) We should make |findRangeOfString()| to return |
| 1229 // |EphemeralRange| rather than|Range| object. | 1229 // |EphemeralRange| rather than|Range| object. |
| 1230 Range* resultRange = findRangeOfString(target, EphemeralRange(selection.star
t(), selection.end()), static_cast<FindOptions>(options | FindAPICall)); | 1230 Range* resultRange = findRangeOfString(target, EphemeralRange(selection.star
t(), selection.end()), static_cast<FindOptions>(options | FindAPICall)); |
| 1231 | 1231 |
| 1232 if (!resultRange) | 1232 if (!resultRange) |
| 1233 return false; | 1233 return false; |
| 1234 | 1234 |
| 1235 frame().selection().setSelection(VisibleSelection(EphemeralRange(resultRange
))); | 1235 frame().selection().setSelection(createVisibleSelectionDeprecated(EphemeralR
ange(resultRange))); |
| 1236 frame().selection().revealSelection(); | 1236 frame().selection().revealSelection(); |
| 1237 return true; | 1237 return true; |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 Range* Editor::findStringAndScrollToVisible(const String& target, Range* previou
sMatch, FindOptions options) | 1240 Range* Editor::findStringAndScrollToVisible(const String& target, Range* previou
sMatch, FindOptions options) |
| 1241 { | 1241 { |
| 1242 Range* nextMatch = findRangeOfString(target, EphemeralRangeInFlatTree(previo
usMatch), options); | 1242 Range* nextMatch = findRangeOfString(target, EphemeralRangeInFlatTree(previo
usMatch), options); |
| 1243 if (!nextMatch) | 1243 if (!nextMatch) |
| 1244 return nullptr; | 1244 return nullptr; |
| 1245 | 1245 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 | 1417 |
| 1418 DEFINE_TRACE(Editor) | 1418 DEFINE_TRACE(Editor) |
| 1419 { | 1419 { |
| 1420 visitor->trace(m_frame); | 1420 visitor->trace(m_frame); |
| 1421 visitor->trace(m_lastEditCommand); | 1421 visitor->trace(m_lastEditCommand); |
| 1422 visitor->trace(m_undoStack); | 1422 visitor->trace(m_undoStack); |
| 1423 visitor->trace(m_mark); | 1423 visitor->trace(m_mark); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 } // namespace blink | 1426 } // namespace blink |
| OLD | NEW |