diff options
Diffstat (limited to 'WebCore/editing/Editor.cpp')
-rw-r--r-- | WebCore/editing/Editor.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp index 196384a..3dd6e27 100644 --- a/WebCore/editing/Editor.cpp +++ b/WebCore/editing/Editor.cpp @@ -326,6 +326,11 @@ void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame->domWindow(), pastingFragment, smartReplace, matchStyle), ec); } +void Editor::pasteAsPlainTextBypassingDHTML() +{ + pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); +} + void Editor::pasteAsPlainTextWithPasteboard(Pasteboard* pasteboard) { String text = pasteboard->plainText(m_frame); @@ -992,12 +997,12 @@ void Editor::reappliedEditing(PassRefPtr<EditCommand> cmd) Editor::Editor(Frame* frame) : m_frame(frame) - , m_deleteButtonController(new DeleteButtonController(frame)) + , m_deleteButtonController(adoptPtr(new DeleteButtonController(frame))) , m_ignoreCompositionSelectionChange(false) , m_shouldStartNewKillRingSequence(false) // This is off by default, since most editors want this behavior (this matches IE but not FF). , m_shouldStyleWithCSS(false) - , m_killRing(new KillRing) + , m_killRing(adoptPtr(new KillRing)) { } @@ -1563,7 +1568,7 @@ void Editor::ignoreSpelling() RefPtr<Range> selectedRange = frame()->selection()->toNormalizedRange(); if (selectedRange) - frame()->document()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling); + frame()->document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling); String text = frame()->selectedText(); ASSERT(text.length()); @@ -1629,7 +1634,7 @@ static String findFirstMisspellingInRange(EditorClient* client, Range* searchRan // Store marker for misspelled word. ExceptionCode ec = 0; - misspellingRange->startContainer(ec)->document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); + misspellingRange->startContainer(ec)->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); ASSERT(!ec); // Bail out if we're marking only the first misspelling, and not all instances. @@ -1692,7 +1697,7 @@ static int findFirstGrammarDetailInRange(const Vector<GrammarDetail>& grammarDet if (markAll) { RefPtr<Range> badGrammarRange = TextIterator::subrange(searchRange, badGrammarPhraseLocation - startOffset + detail->location, detail->length); ExceptionCode ec = 0; - badGrammarRange->startContainer(ec)->document()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); + badGrammarRange->startContainer(ec)->document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); ASSERT(!ec); } @@ -2063,7 +2068,7 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection) frame()->revealSelection(); client()->updateSpellingUIWithGrammarString(badGrammarPhrase, grammarDetail); - frame()->document()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, grammarDetail.userDescription); + frame()->document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, grammarDetail.userDescription); #endif } else if (!misspelledWord.isEmpty()) { // We found a misspelling, but not any earlier bad grammar. Select the misspelling, update the spelling panel, and store @@ -2074,7 +2079,7 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection) frame()->revealSelection(); client()->updateSpellingUIWithMisspelledWord(misspelledWord); - frame()->document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); + frame()->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); } } @@ -2543,7 +2548,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* if (markSpelling && result->type == TextCheckingTypeSpelling && resultLocation >= spellingRangeStartOffset && resultLocation + resultLength <= spellingRangeEndOffset) { ASSERT(resultLength > 0 && resultLocation >= 0); RefPtr<Range> misspellingRange = TextIterator::subrange(spellingRange, resultLocation - spellingRangeStartOffset, resultLength); - misspellingRange->startContainer(ec)->document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); + misspellingRange->startContainer(ec)->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling); } else if (markGrammar && result->type == TextCheckingTypeGrammar && resultLocation < grammarRangeEndOffset && resultLocation + resultLength > grammarRangeStartOffset) { ASSERT(resultLength > 0 && resultLocation >= 0); for (unsigned j = 0; j < result->details.size(); j++) { @@ -2551,7 +2556,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* ASSERT(detail->length > 0 && detail->location >= 0); if (resultLocation + detail->location >= grammarRangeStartOffset && resultLocation + detail->location + detail->length <= grammarRangeEndOffset) { RefPtr<Range> badGrammarRange = TextIterator::subrange(grammarRange, resultLocation + detail->location - grammarRangeStartOffset, detail->length); - grammarRange->startContainer(ec)->document()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); + grammarRange->startContainer(ec)->document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); } } } else if (performTextCheckingReplacements && resultLocation + resultLength <= spellingRangeEndOffset && resultLocation + resultLength >= spellingRangeStartOffset @@ -2581,7 +2586,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* Node* node = rangeToReplace->startContainer(); int startOffset = rangeToReplace->startOffset(); int endOffset = startOffset + replacementLength; - Vector<DocumentMarker> markers = node->document()->markersForNode(node); + Vector<DocumentMarker> markers = node->document()->markers()->markersForNode(node); size_t markerCount = markers.size(); for (size_t i = 0; i < markerCount; ++i) { const DocumentMarker& marker = markers[i]; @@ -2618,7 +2623,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* if (result->type == TextCheckingTypeCorrection) { // Add a marker so that corrections can easily be undone and won't be re-corrected. RefPtr<Range> replacedRange = TextIterator::subrange(paragraphRange.get(), resultLocation, replacementLength); - replacedRange->startContainer()->document()->addMarker(replacedRange.get(), DocumentMarker::Replacement, replacedString); + replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::Replacement, replacedString); } } } @@ -2656,7 +2661,7 @@ void Editor::changeBackToReplacedString(const String& replacedString) RefPtr<Range> paragraphRange = paragraphAlignedRangeForRange(selection.get(), selectionOffset, paragraphString); replaceSelectionWithText(replacedString, false, false); RefPtr<Range> changedRange = TextIterator::subrange(paragraphRange.get(), selectionOffset, replacedString.length()); - changedRange->startContainer()->document()->addMarker(changedRange.get(), DocumentMarker::Replacement, String()); + changedRange->startContainer()->document()->markers()->addMarker(changedRange.get(), DocumentMarker::Replacement, String()); } #endif @@ -2937,6 +2942,10 @@ PassRefPtr<Range> Editor::nextVisibleRange(Range* currentRange, const String& ta void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, bool closeTyping, bool clearTypingStyle) { + // If the new selection is orphaned, then don't update the selection. + if (newSelection.start().isOrphan() || newSelection.end().isOrphan()) + return; + // If there is no selection change, don't bother sending shouldChangeSelection, but still call setSelection, // because there is work that it must do in this situation. // The old selection can be invalid here and calling shouldChangeSelection can produce some strange calls. |