Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (154647 => 154648)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2013-08-26 22:40:55 UTC (rev 154647)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2013-08-26 22:49:18 UTC (rev 154648)
@@ -132,7 +132,7 @@
return true;
}
-AlternativeTextController::AlternativeTextController(Frame* frame)
+AlternativeTextController::AlternativeTextController(Frame& frame)
: m_timer(this, &AlternativeTextController::timerFired)
, m_frame(frame)
{
@@ -165,7 +165,7 @@
void AlternativeTextController::stopPendingCorrection(const VisibleSelection& oldSelection)
{
// Make sure there's no pending autocorrection before we call markMisspellingsAndBadGrammar() below.
- VisibleSelection currentSelection(m_frame->selection().selection());
+ VisibleSelection currentSelection(m_frame.selection().selection());
if (currentSelection == oldSelection)
return;
@@ -197,7 +197,7 @@
bool AlternativeTextController::isSpellingMarkerAllowed(PassRefPtr<Range> misspellingRange) const
{
- return !m_frame->document()->markers().hasMarkers(misspellingRange.get(), DocumentMarker::SpellCheckingExemption);
+ return !m_frame.document()->markers().hasMarkers(misspellingRange.get(), DocumentMarker::SpellCheckingExemption);
}
void AlternativeTextController::show(PassRefPtr<Range> rangeToReplace, const String& replacement)
@@ -276,12 +276,12 @@
// Clone the range, since the caller of this method may want to keep the original range around.
RefPtr<Range> rangeWithAlternative = range->cloneRange(ec);
- int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame->document(), m_frame->document(), 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get());
+ int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame.document(), m_frame.document(), 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get());
applyCommand(SpellingCorrectionCommand::create(rangeWithAlternative, alternative));
// Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
- paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(m_frame->document(), paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
+ paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(m_frame.document(), paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
- setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection().selection().start());
+ setEnd(paragraphRangeContainingCorrection.get(), m_frame.selection().selection().start());
RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, alternative.length());
String newText = plainText(replacementRange.get());
@@ -303,7 +303,7 @@
if (m_alternativeTextInfo.type != AlternativeTextTypeCorrection)
return false;
- Position caretPosition = m_frame->selection().selection().start();
+ Position caretPosition = m_frame.selection().selection().start();
if (m_alternativeTextInfo.rangeWithAlternative->endPosition() == caretPosition) {
handleAlternativeTextUIResult(dismissSoon(ReasonForDismissingAlternativeTextAccepted));
@@ -320,11 +320,11 @@
{
if (AlternativeTextClient* client = alternativeTextClient())
client->recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction);
- m_frame->document()->updateLayout();
- m_frame->selection().setSelection(selectionOfCorrected, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::SpellCorrectionTriggered);
- RefPtr<Range> range = Range::create(m_frame->document(), m_frame->selection().selection().start(), m_frame->selection().selection().end());
+ m_frame.document()->updateLayout();
+ m_frame.selection().setSelection(selectionOfCorrected, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::SpellCorrectionTriggered);
+ RefPtr<Range> range = Range::create(m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end());
- DocumentMarkerController& markers = m_frame->document()->markers();
+ DocumentMarkerController& markers = m_frame.document()->markers();
markers.removeMarkers(range.get(), DocumentMarker::Spelling | DocumentMarker::Autocorrected, DocumentMarkerController::RemovePartiallyOverlappingMarker);
markers.addMarker(range.get(), DocumentMarker::Replacement);
markers.addMarker(range.get(), DocumentMarker::SpellCheckingExemption);
@@ -335,11 +335,11 @@
m_isDismissedByEditing = false;
switch (m_alternativeTextInfo.type) {
case AlternativeTextTypeCorrection: {
- VisibleSelection selection(m_frame->selection().selection());
+ VisibleSelection selection(m_frame.selection().selection());
VisiblePosition start(selection.start(), selection.affinity());
VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary);
VisibleSelection adjacentWords = VisibleSelection(p, start);
- m_frame->editor().markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeSpelling | TextCheckingTypeReplacement | TextCheckingTypeShowCorrectionPanel, adjacentWords.toNormalizedRange().get(), 0);
+ m_frame.editor().markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeSpelling | TextCheckingTypeReplacement | TextCheckingTypeShowCorrectionPanel, adjacentWords.toNormalizedRange().get(), 0);
}
break;
case AlternativeTextTypeReversion: {
@@ -397,7 +397,7 @@
void AlternativeTextController::handleAlternativeTextUIResult(const String& result)
{
Range* rangeWithAlternative = m_alternativeTextInfo.rangeWithAlternative.get();
- if (!rangeWithAlternative || m_frame->document() != rangeWithAlternative->ownerDocument())
+ if (!rangeWithAlternative || m_frame.document() != rangeWithAlternative->ownerDocument())
return;
String currentWord = plainText(rangeWithAlternative);
@@ -435,7 +435,7 @@
FloatRect AlternativeTextController::rootViewRectForRange(const Range* range) const
{
- FrameView* view = m_frame->view();
+ FrameView* view = m_frame.view();
if (!view)
return FloatRect();
Vector<FloatQuad> textQuads;
@@ -449,7 +449,7 @@
void AlternativeTextController::respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions options)
{
- VisibleSelection currentSelection(m_frame->selection().selection());
+ VisibleSelection currentSelection(m_frame.selection().selection());
// When user moves caret to the end of autocorrected word and pauses, we show the panel
// containing the original pre-correction word so that user can quickly revert the
// undesired autocorrection. Here, we start correction panel timer once we confirm that
@@ -488,7 +488,7 @@
void AlternativeTextController::respondToAppliedEditing(CompositeEditCommand* command)
{
if (command->isTopLevelCommand() && !command->shouldRetainAutocorrectionIndicator())
- m_frame->document()->markers().removeMarkers(DocumentMarker::CorrectionIndicator);
+ m_frame.document()->markers().removeMarkers(DocumentMarker::CorrectionIndicator);
markPrecedingWhitespaceForDeletedAutocorrectionAfterCommand(command);
m_originalStringForLastDeletedAutocorrection = String();
@@ -498,28 +498,22 @@
{
if (!command->wasCreateLinkCommand())
return;
- RefPtr<Range> range = Range::create(m_frame->document(), command->startingSelection().start(), command->startingSelection().end());
+ RefPtr<Range> range = Range::create(m_frame.document(), command->startingSelection().start(), command->startingSelection().end());
if (!range)
return;
- DocumentMarkerController& markers = m_frame->document()->markers();
+ DocumentMarkerController& markers = m_frame.document()->markers();
markers.addMarker(range.get(), DocumentMarker::Replacement);
markers.addMarker(range.get(), DocumentMarker::SpellCheckingExemption);
}
AlternativeTextClient* AlternativeTextController::alternativeTextClient()
{
- if (!m_frame)
- return 0;
-
- return m_frame->page() ? m_frame->page()->alternativeTextClient() : 0;
+ return m_frame.page() ? m_frame.page()->alternativeTextClient() : 0;
}
EditorClient* AlternativeTextController::editorClient()
{
- if (!m_frame)
- return 0;
-
- return m_frame->page() ? m_frame->page()->editorClient() : 0;
+ return m_frame.page() ? m_frame.page()->editorClient() : 0;
}
TextCheckerClient* AlternativeTextController::textChecker()
@@ -596,7 +590,7 @@
if (endOfSelection == precedingCharacterPosition)
return;
- RefPtr<Range> precedingCharacterRange = Range::create(m_frame->document(), precedingCharacterPosition, endOfSelection);
+ RefPtr<Range> precedingCharacterRange = Range::create(m_frame.document(), precedingCharacterPosition, endOfSelection);
String string = plainText(precedingCharacterRange.get());
if (string.isEmpty() || !isWhitespace(string[string.length() - 1]))
return;
@@ -604,12 +598,12 @@
// Mark this whitespace to indicate we have deleted an autocorrection following this
// whitespace. So if the user types the same original word again at this position, we
// won't autocorrect it again.
- m_frame->document()->markers().addMarker(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection, m_originalStringForLastDeletedAutocorrection);
+ m_frame.document()->markers().addMarker(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection, m_originalStringForLastDeletedAutocorrection);
}
bool AlternativeTextController::processMarkersOnTextToBeReplacedByResult(const TextCheckingResult* result, Range* rangeWithAlternative, const String& stringToBeReplaced)
{
- DocumentMarkerController& markerController = m_frame->document()->markers();
+ DocumentMarkerController& markerController = m_frame.document()->markers();
if (markerController.hasMarkers(rangeWithAlternative, DocumentMarker::Replacement)) {
if (result->type == TextCheckingTypeCorrection)
recordSpellcheckerResponseForModifiedCorrection(rangeWithAlternative, stringToBeReplaced, result->replacement);
@@ -621,7 +615,7 @@
Position beginningOfRange = rangeWithAlternative->startPosition();
Position precedingCharacterPosition = beginningOfRange.previous();
- RefPtr<Range> precedingCharacterRange = Range::create(m_frame->document(), precedingCharacterPosition, beginningOfRange);
+ RefPtr<Range> precedingCharacterRange = Range::create(m_frame.document(), precedingCharacterPosition, beginningOfRange);
Vector<DocumentMarker*> markers = markerController.markersInRange(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection);
@@ -645,7 +639,7 @@
if (!shouldStartTimerFor(marker, endOfWordPosition.offsetInContainerNode()))
return false;
Node* node = endOfWordPosition.containerNode();
- RefPtr<Range> wordRange = Range::create(m_frame->document(), node, marker.startOffset(), node, marker.endOffset());
+ RefPtr<Range> wordRange = Range::create(m_frame.document(), node, marker.startOffset(), node, marker.endOffset());
if (!wordRange)
return false;
String currentWord = plainText(wordRange.get());
@@ -693,20 +687,18 @@
bool AlternativeTextController::insertDictatedText(const String& text, const Vector<DictationAlternative>& dictationAlternatives, Event* triggeringEvent)
{
- if (!m_frame)
- return false;
EventTarget* target;
if (triggeringEvent)
target = triggeringEvent->target();
else
- target = eventTargetNodeForDocument(m_frame->document());
+ target = eventTargetNodeForDocument(m_frame.document());
if (!target)
return false;
- if (FrameView* view = m_frame->view())
+ if (FrameView* view = m_frame.view())
view->resetDeferredRepaintDelay();
- RefPtr<TextEvent> event = TextEvent::createForDictation(m_frame->document()->domWindow(), text, dictationAlternatives);
+ RefPtr<TextEvent> event = TextEvent::createForDictation(m_frame.document()->domWindow(), text, dictationAlternatives);
event->setUnderlyingEvent(triggeringEvent);
target->dispatchEvent(event, IGNORE_EXCEPTION);
@@ -742,7 +734,7 @@
void AlternativeTextController::applyDictationAlternative(const String& alternativeString)
{
#if USE(DICTATION_ALTERNATIVES)
- Editor& editor = m_frame->editor();
+ Editor& editor = m_frame.editor();
RefPtr<Range> selection = editor.selectedRange();
if (!selection || !editor.shouldInsertText(alternativeString, selection.get(), EditorInsertActionPasted))
return;