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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 { | 112 { |
113 VisibleSelection selection = frame().selection().selection(); | 113 VisibleSelection selection = frame().selection().selection(); |
114 if (!event) | 114 if (!event) |
115 return selection; | 115 return selection; |
116 // If the target is a text control, and the current selection is outside of
its shadow tree, | 116 // If the target is a text control, and the current selection is outside of
its shadow tree, |
117 // then use the saved selection for that text control. | 117 // then use the saved selection for that text control. |
118 HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextF
ormControl(selection.start()); | 118 HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextF
ormControl(selection.start()); |
119 HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlE
lement(*event->target()->toNode()) ? toHTMLTextFormControlElement(event->target(
)->toNode()) : 0; | 119 HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlE
lement(*event->target()->toNode()) ? toHTMLTextFormControlElement(event->target(
)->toNode()) : 0; |
120 if (textFromControlOfTarget && (selection.start().isNull() || textFromContro
lOfTarget != textFormControlOfSelectionStart)) { | 120 if (textFromControlOfTarget && (selection.start().isNull() || textFromContro
lOfTarget != textFormControlOfSelectionStart)) { |
121 if (RefPtrWillBeRawPtr<Range> range = textFromControlOfTarget->selection
()) | 121 if (RefPtrWillBeRawPtr<Range> range = textFromControlOfTarget->selection
()) |
122 return VisibleSelection(range.get(), TextAffinity::Downstream, selec
tion.isDirectional()); | 122 return VisibleSelection(EphemeralRange(range.get()), TextAffinity::D
ownstream, selection.isDirectional()); |
123 } | 123 } |
124 return selection; | 124 return selection; |
125 } | 125 } |
126 | 126 |
127 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. | 127 // Function considers Mac editing behavior a fallback when Page or Settings is n
ot available. |
128 EditingBehavior Editor::behavior() const | 128 EditingBehavior Editor::behavior() const |
129 { | 129 { |
130 if (!frame().settings()) | 130 if (!frame().settings()) |
131 return EditingBehavior(EditingMacBehavior); | 131 return EditingBehavior(EditingMacBehavior); |
132 | 132 |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 { | 1147 { |
1148 VisibleSelection selection = frame().selection().selection(); | 1148 VisibleSelection selection = frame().selection().selection(); |
1149 | 1149 |
1150 // TODO(yosin) We should make |findRangeOfString()| to return | 1150 // TODO(yosin) We should make |findRangeOfString()| to return |
1151 // |EphemeralRange| rather than|Range| object. | 1151 // |EphemeralRange| rather than|Range| object. |
1152 RefPtrWillBeRawPtr<Range> resultRange = findRangeOfString(target, EphemeralR
ange(selection.start(), selection.end()), static_cast<FindOptions>(options | Fin
dAPICall)); | 1152 RefPtrWillBeRawPtr<Range> resultRange = findRangeOfString(target, EphemeralR
ange(selection.start(), selection.end()), static_cast<FindOptions>(options | Fin
dAPICall)); |
1153 | 1153 |
1154 if (!resultRange) | 1154 if (!resultRange) |
1155 return false; | 1155 return false; |
1156 | 1156 |
1157 frame().selection().setSelection(VisibleSelection(resultRange.get())); | 1157 frame().selection().setSelection(VisibleSelection(EphemeralRange(resultRange
.get()))); |
1158 frame().selection().revealSelection(); | 1158 frame().selection().revealSelection(); |
1159 return true; | 1159 return true; |
1160 } | 1160 } |
1161 | 1161 |
1162 template <typename Strategy> | 1162 template <typename Strategy> |
1163 static PassRefPtrWillBeRawPtr<Range> findStringAndScrollToVisibleAlgorithm(Edito
r& editor, const String& target, const EphemeralRangeTemplate<Strategy>& previou
sMatch, FindOptions options) | 1163 static PassRefPtrWillBeRawPtr<Range> findStringAndScrollToVisibleAlgorithm(Edito
r& editor, const String& target, const EphemeralRangeTemplate<Strategy>& previou
sMatch, FindOptions options) |
1164 { | 1164 { |
1165 RefPtrWillBeRawPtr<Range> nextMatch = editor.findRangeOfString(target, previ
ousMatch, options); | 1165 RefPtrWillBeRawPtr<Range> nextMatch = editor.findRangeOfString(target, previ
ousMatch, options); |
1166 if (!nextMatch) | 1166 if (!nextMatch) |
1167 return nullptr; | 1167 return nullptr; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 } | 1301 } |
1302 | 1302 |
1303 DEFINE_TRACE(Editor) | 1303 DEFINE_TRACE(Editor) |
1304 { | 1304 { |
1305 visitor->trace(m_frame); | 1305 visitor->trace(m_frame); |
1306 visitor->trace(m_lastEditCommand); | 1306 visitor->trace(m_lastEditCommand); |
1307 visitor->trace(m_mark); | 1307 visitor->trace(m_mark); |
1308 } | 1308 } |
1309 | 1309 |
1310 } // namespace blink | 1310 } // namespace blink |
OLD | NEW |