| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 bool Editor::canDeleteRange(Range* range) const | 251 bool Editor::canDeleteRange(Range* range) const |
| 252 { | 252 { |
| 253 Node* startContainer = range->startContainer(); | 253 Node* startContainer = range->startContainer(); |
| 254 Node* endContainer = range->endContainer(); | 254 Node* endContainer = range->endContainer(); |
| 255 if (!startContainer || !endContainer) | 255 if (!startContainer || !endContainer) |
| 256 return false; | 256 return false; |
| 257 | 257 |
| 258 if (!startContainer->rendererIsEditable() || !endContainer->rendererIsEditab
le()) | 258 if (!startContainer->rendererIsEditable() || !endContainer->rendererIsEditab
le()) |
| 259 return false; | 259 return false; |
| 260 | 260 |
| 261 if (range->collapsed(IGNORE_EXCEPTION)) { | 261 if (range->collapsed()) { |
| 262 VisiblePosition start(range->startPosition(), DOWNSTREAM); | 262 VisiblePosition start(range->startPosition(), DOWNSTREAM); |
| 263 VisiblePosition previous = start.previous(); | 263 VisiblePosition previous = start.previous(); |
| 264 // FIXME: We sometimes allow deletions at the start of editable roots, l
ike when the caret is in an empty list item. | 264 // FIXME: We sometimes allow deletions at the start of editable roots, l
ike when the caret is in an empty list item. |
| 265 if (previous.isNull() || previous.deepEquivalent().deprecatedNode()->roo
tEditableElement() != startContainer->rootEditableElement()) | 265 if (previous.isNull() || previous.deepEquivalent().deprecatedNode()->roo
tEditableElement() != startContainer->rootEditableElement()) |
| 266 return false; | 266 return false; |
| 267 } | 267 } |
| 268 return true; | 268 return true; |
| 269 } | 269 } |
| 270 | 270 |
| 271 bool Editor::smartInsertDeleteEnabled() const | 271 bool Editor::smartInsertDeleteEnabled() const |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 replaceSelectionWithFragment(createFragmentFromText(selectedRange().get(), t
ext), selectReplacement, smartReplace, true); | 509 replaceSelectionWithFragment(createFragmentFromText(selectedRange().get(), t
ext), selectReplacement, smartReplace, true); |
| 510 } | 510 } |
| 511 | 511 |
| 512 PassRefPtrWillBeRawPtr<Range> Editor::selectedRange() | 512 PassRefPtrWillBeRawPtr<Range> Editor::selectedRange() |
| 513 { | 513 { |
| 514 return m_frame.selection().toNormalizedRange(); | 514 return m_frame.selection().toNormalizedRange(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 bool Editor::shouldDeleteRange(Range* range) const | 517 bool Editor::shouldDeleteRange(Range* range) const |
| 518 { | 518 { |
| 519 if (!range || range->collapsed(IGNORE_EXCEPTION)) | 519 if (!range || range->collapsed()) |
| 520 return false; | 520 return false; |
| 521 | 521 |
| 522 return canDeleteRange(range); | 522 return canDeleteRange(range); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void Editor::notifyComponentsOnChangedSelection(const VisibleSelection& oldSelec
tion, FrameSelection::SetSelectionOptions options) | 525 void Editor::notifyComponentsOnChangedSelection(const VisibleSelection& oldSelec
tion, FrameSelection::SetSelectionOptions options) |
| 526 { | 526 { |
| 527 client().respondToChangedSelection(&m_frame, m_frame.selection().selectionTy
pe()); | 527 client().respondToChangedSelection(&m_frame, m_frame.selection().selectionTy
pe()); |
| 528 setStartNewKillRingSequence(true); | 528 setStartNewKillRingSequence(true); |
| 529 } | 529 } |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 if (forward) | 1177 if (forward) |
| 1178 searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->countC
hildren()); | 1178 searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->countC
hildren()); |
| 1179 else | 1179 else |
| 1180 searchRange->setStart(shadowTreeRoot.get(), 0); | 1180 searchRange->setStart(shadowTreeRoot.get(), 0); |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 resultRange = findPlainText(searchRange.get(), target, options); | 1183 resultRange = findPlainText(searchRange.get(), target, options); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 // If nothing was found in the shadow tree, search in main content following
the shadow tree. | 1186 // If nothing was found in the shadow tree, search in main content following
the shadow tree. |
| 1187 if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && shadowTreeRoot) { | 1187 if (resultRange->collapsed() && shadowTreeRoot) { |
| 1188 searchRange = rangeOfContents(m_frame.document()); | 1188 searchRange = rangeOfContents(m_frame.document()); |
| 1189 if (forward) | 1189 if (forward) |
| 1190 searchRange->setStartAfter(shadowTreeRoot->shadowHost()); | 1190 searchRange->setStartAfter(shadowTreeRoot->shadowHost()); |
| 1191 else | 1191 else |
| 1192 searchRange->setEndBefore(shadowTreeRoot->shadowHost()); | 1192 searchRange->setEndBefore(shadowTreeRoot->shadowHost()); |
| 1193 | 1193 |
| 1194 resultRange = findPlainText(searchRange.get(), target, options); | 1194 resultRange = findPlainText(searchRange.get(), target, options); |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 // If we didn't find anything and we're wrapping, search again in the entire
document (this will | 1197 // If we didn't find anything and we're wrapping, search again in the entire
document (this will |
| 1198 // redundantly re-search the area already searched in some cases). | 1198 // redundantly re-search the area already searched in some cases). |
| 1199 if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && options & WrapAround) { | 1199 if (resultRange->collapsed() && options & WrapAround) { |
| 1200 searchRange = rangeOfContents(m_frame.document()); | 1200 searchRange = rangeOfContents(m_frame.document()); |
| 1201 resultRange = findPlainText(searchRange.get(), target, options); | 1201 resultRange = findPlainText(searchRange.get(), target, options); |
| 1202 // We used to return false here if we ended up with the same range that
we started with | 1202 // We used to return false here if we ended up with the same range that
we started with |
| 1203 // (e.g., the reference range was already the only instance of this text
). But we decided that | 1203 // (e.g., the reference range was already the only instance of this text
). But we decided that |
| 1204 // this should be a success case instead, so we'll just fall through in
that case. | 1204 // this should be a success case instead, so we'll just fall through in
that case. |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 return resultRange->collapsed(ASSERT_NO_EXCEPTION) ? nullptr : resultRange.r
elease(); | 1207 return resultRange->collapsed() ? nullptr : resultRange.release(); |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 void Editor::setMarkedTextMatchesAreHighlighted(bool flag) | 1210 void Editor::setMarkedTextMatchesAreHighlighted(bool flag) |
| 1211 { | 1211 { |
| 1212 if (flag == m_areMarkedTextMatchesHighlighted) | 1212 if (flag == m_areMarkedTextMatchesHighlighted) |
| 1213 return; | 1213 return; |
| 1214 | 1214 |
| 1215 m_areMarkedTextMatchesHighlighted = flag; | 1215 m_areMarkedTextMatchesHighlighted = flag; |
| 1216 m_frame.document()->markers().repaintMarkers(DocumentMarker::TextMatch); | 1216 m_frame.document()->markers().repaintMarkers(DocumentMarker::TextMatch); |
| 1217 } | 1217 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1228 return m_frame.spellChecker(); | 1228 return m_frame.spellChecker(); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 void Editor::toggleOverwriteModeEnabled() | 1231 void Editor::toggleOverwriteModeEnabled() |
| 1232 { | 1232 { |
| 1233 m_overwriteModeEnabled = !m_overwriteModeEnabled; | 1233 m_overwriteModeEnabled = !m_overwriteModeEnabled; |
| 1234 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 1234 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 } // namespace WebCore | 1237 } // namespace WebCore |
| OLD | NEW |