| 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 715 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 715 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 
| 716 { | 716 { | 
| 717     EventQueueScope scope; | 717     EventQueueScope scope; | 
| 718     m_frame.document()->updateLayout(); | 718     m_frame.document()->updateLayout(); | 
| 719 | 719 | 
| 720     dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
      ->endingRootEditableElement()); | 720     dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
      ->endingRootEditableElement()); | 
| 721 | 721 | 
| 722     VisibleSelection newSelection(cmd->startingSelection()); | 722     VisibleSelection newSelection(cmd->startingSelection()); | 
| 723     changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
      eSelection::ClearTypingStyle); | 723     changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
      eSelection::ClearTypingStyle); | 
| 724 | 724 | 
| 725     m_lastEditCommand = 0; | 725     m_lastEditCommand = nullptr; | 
| 726     if (UndoStack* undoStack = this->undoStack()) | 726     if (UndoStack* undoStack = this->undoStack()) | 
| 727         undoStack->registerRedoStep(cmd); | 727         undoStack->registerRedoStep(cmd); | 
| 728     respondToChangedContents(newSelection); | 728     respondToChangedContents(newSelection); | 
| 729 } | 729 } | 
| 730 | 730 | 
| 731 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 731 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 
| 732 { | 732 { | 
| 733     EventQueueScope scope; | 733     EventQueueScope scope; | 
| 734     m_frame.document()->updateLayout(); | 734     m_frame.document()->updateLayout(); | 
| 735 | 735 | 
| 736     dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
      ->endingRootEditableElement()); | 736     dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
      ->endingRootEditableElement()); | 
| 737 | 737 | 
| 738     VisibleSelection newSelection(cmd->endingSelection()); | 738     VisibleSelection newSelection(cmd->endingSelection()); | 
| 739     changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
      eSelection::ClearTypingStyle); | 739     changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
      eSelection::ClearTypingStyle); | 
| 740 | 740 | 
| 741     m_lastEditCommand = 0; | 741     m_lastEditCommand = nullptr; | 
| 742     if (UndoStack* undoStack = this->undoStack()) | 742     if (UndoStack* undoStack = this->undoStack()) | 
| 743         undoStack->registerUndoStep(cmd); | 743         undoStack->registerUndoStep(cmd); | 
| 744     respondToChangedContents(newSelection); | 744     respondToChangedContents(newSelection); | 
| 745 } | 745 } | 
| 746 | 746 | 
| 747 PassOwnPtr<Editor> Editor::create(Frame& frame) | 747 PassOwnPtr<Editor> Editor::create(Frame& frame) | 
| 748 { | 748 { | 
| 749     return adoptPtr(new Editor(frame)); | 749     return adoptPtr(new Editor(frame)); | 
| 750 } | 750 } | 
| 751 | 751 | 
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1124 | 1124 | 
| 1125     m_frame.selection().setSelection(VisibleSelection(resultRange.get(), DOWNSTR
      EAM)); | 1125     m_frame.selection().setSelection(VisibleSelection(resultRange.get(), DOWNSTR
      EAM)); | 
| 1126     m_frame.selection().revealSelection(); | 1126     m_frame.selection().revealSelection(); | 
| 1127     return true; | 1127     return true; | 
| 1128 } | 1128 } | 
| 1129 | 1129 | 
| 1130 PassRefPtr<Range> Editor::findStringAndScrollToVisible(const String& target, Ran
      ge* previousMatch, FindOptions options) | 1130 PassRefPtr<Range> Editor::findStringAndScrollToVisible(const String& target, Ran
      ge* previousMatch, FindOptions options) | 
| 1131 { | 1131 { | 
| 1132     RefPtr<Range> nextMatch = rangeOfString(target, previousMatch, options); | 1132     RefPtr<Range> nextMatch = rangeOfString(target, previousMatch, options); | 
| 1133     if (!nextMatch) | 1133     if (!nextMatch) | 
| 1134         return 0; | 1134         return nullptr; | 
| 1135 | 1135 | 
| 1136     nextMatch->firstNode()->renderer()->scrollRectToVisible(nextMatch->boundingB
      ox(), | 1136     nextMatch->firstNode()->renderer()->scrollRectToVisible(nextMatch->boundingB
      ox(), | 
| 1137         ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeed
      ed); | 1137         ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeed
      ed); | 
| 1138 | 1138 | 
| 1139     return nextMatch.release(); | 1139     return nextMatch.release(); | 
| 1140 } | 1140 } | 
| 1141 | 1141 | 
| 1142 PassRefPtr<Range> Editor::rangeOfString(const String& target, Range* referenceRa
      nge, FindOptions options) | 1142 PassRefPtr<Range> Editor::rangeOfString(const String& target, Range* referenceRa
      nge, FindOptions options) | 
| 1143 { | 1143 { | 
| 1144     if (target.isEmpty()) | 1144     if (target.isEmpty()) | 
| 1145         return 0; | 1145         return nullptr; | 
| 1146 | 1146 | 
| 1147     // Start from an edge of the reference range, if there's a reference range t
      hat's not in shadow content. Which edge | 1147     // Start from an edge of the reference range, if there's a reference range t
      hat's not in shadow content. Which edge | 
| 1148     // is used depends on whether we're searching forward or backward, and wheth
      er startInSelection is set. | 1148     // is used depends on whether we're searching forward or backward, and wheth
      er startInSelection is set. | 
| 1149     RefPtr<Range> searchRange(rangeOfContents(m_frame.document())); | 1149     RefPtr<Range> searchRange(rangeOfContents(m_frame.document())); | 
| 1150 | 1150 | 
| 1151     bool forward = !(options & Backwards); | 1151     bool forward = !(options & Backwards); | 
| 1152     bool startInReferenceRange = referenceRange && (options & StartInSelection); | 1152     bool startInReferenceRange = referenceRange && (options & StartInSelection); | 
| 1153     if (referenceRange) { | 1153     if (referenceRange) { | 
| 1154         if (forward) | 1154         if (forward) | 
| 1155             searchRange->setStart(startInReferenceRange ? referenceRange->startP
      osition() : referenceRange->endPosition()); | 1155             searchRange->setStart(startInReferenceRange ? referenceRange->startP
      osition() : referenceRange->endPosition()); | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1200     // If we didn't find anything and we're wrapping, search again in the entire
       document (this will | 1200     // If we didn't find anything and we're wrapping, search again in the entire
       document (this will | 
| 1201     // redundantly re-search the area already searched in some cases). | 1201     // redundantly re-search the area already searched in some cases). | 
| 1202     if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && options & WrapAround) { | 1202     if (resultRange->collapsed(ASSERT_NO_EXCEPTION) && options & WrapAround) { | 
| 1203         searchRange = rangeOfContents(m_frame.document()); | 1203         searchRange = rangeOfContents(m_frame.document()); | 
| 1204         resultRange = findPlainText(searchRange.get(), target, options); | 1204         resultRange = findPlainText(searchRange.get(), target, options); | 
| 1205         // We used to return false here if we ended up with the same range that 
      we started with | 1205         // We used to return false here if we ended up with the same range that 
      we started with | 
| 1206         // (e.g., the reference range was already the only instance of this text
      ). But we decided that | 1206         // (e.g., the reference range was already the only instance of this text
      ). But we decided that | 
| 1207         // this should be a success case instead, so we'll just fall through in 
      that case. | 1207         // this should be a success case instead, so we'll just fall through in 
      that case. | 
| 1208     } | 1208     } | 
| 1209 | 1209 | 
| 1210     return resultRange->collapsed(ASSERT_NO_EXCEPTION) ? 0 : resultRange.release
      (); | 1210     return resultRange->collapsed(ASSERT_NO_EXCEPTION) ? nullptr : resultRange.r
      elease(); | 
| 1211 } | 1211 } | 
| 1212 | 1212 | 
| 1213 void Editor::setMarkedTextMatchesAreHighlighted(bool flag) | 1213 void Editor::setMarkedTextMatchesAreHighlighted(bool flag) | 
| 1214 { | 1214 { | 
| 1215     if (flag == m_areMarkedTextMatchesHighlighted) | 1215     if (flag == m_areMarkedTextMatchesHighlighted) | 
| 1216         return; | 1216         return; | 
| 1217 | 1217 | 
| 1218     m_areMarkedTextMatchesHighlighted = flag; | 1218     m_areMarkedTextMatchesHighlighted = flag; | 
| 1219     m_frame.document()->markers()->repaintMarkers(DocumentMarker::TextMatch); | 1219     m_frame.document()->markers()->repaintMarkers(DocumentMarker::TextMatch); | 
| 1220 } | 1220 } | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 1231     return m_frame.spellChecker(); | 1231     return m_frame.spellChecker(); | 
| 1232 } | 1232 } | 
| 1233 | 1233 | 
| 1234 void Editor::toggleOverwriteModeEnabled() | 1234 void Editor::toggleOverwriteModeEnabled() | 
| 1235 { | 1235 { | 
| 1236     m_overwriteModeEnabled = !m_overwriteModeEnabled; | 1236     m_overwriteModeEnabled = !m_overwriteModeEnabled; | 
| 1237     frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 1237     frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 
| 1238 } | 1238 } | 
| 1239 | 1239 | 
| 1240 } // namespace WebCore | 1240 } // namespace WebCore | 
| OLD | NEW | 
|---|