Changeset 154943 in webkit
- Timestamp:
- Sep 1, 2013 7:57:23 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154940 r154943 1 2013-09-01 Andreas Kling <akling@apple.com> 2 3 Give EditCommand a protected Frame& getter. 4 <https://webkit.org/b/120574> 5 6 Reviewed by Darin Adler. 7 8 EditCommand is only created for documents that are attached to a Frame, 9 we already ASSERTed as much in the EditCommand constructor. 10 11 This patch adds a "Frame& EditCommand::frame()" helper, so EditCommand 12 and its subclasses don't have to fumble around with pointers. 13 1 14 2013-08-31 Antti Koivisto <antti@apple.com> 2 15 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r154938 r154943 206 206 document().updateLayoutIgnorePendingStylesheets(); 207 207 208 Frame* frame = document().frame();209 ASSERT(frame);210 208 { 211 209 EventQueueScope scope; 212 210 #if ENABLE(DELETION_UI) 213 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope( frame);211 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(&frame()); 214 212 #endif 215 213 doApply(); … … 219 217 // and TypingCommands do it on their own (see TypingCommand::typingAddedToOpenCommand). 220 218 if (!isTypingCommand()) 221 frame ->editor().appliedEditing(this);219 frame().editor().appliedEditing(this); 222 220 setShouldRetainAutocorrectionIndicator(false); 223 221 } … … 1217 1215 1218 1216 setEndingSelection(VisibleSelection(start, end, DOWNSTREAM)); 1219 document().frame()->editor().clearMisspellingsAndBadGrammar(endingSelection());1217 frame().editor().clearMisspellingsAndBadGrammar(endingSelection()); 1220 1218 deleteSelection(false, false, false, false); 1221 1219 … … 1250 1248 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, options)); 1251 1249 1252 document().frame()->editor().markMisspellingsAndBadGrammar(endingSelection());1250 frame().editor().markMisspellingsAndBadGrammar(endingSelection()); 1253 1251 1254 1252 // If the selection is in an empty paragraph, restore styles from the old empty paragraph to the new empty paragraph. -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r154938 r154943 656 656 RefPtr<Range> range = Range::create(&document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), endOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent()); 657 657 RefPtr<Range> rangeToBeReplaced = Range::create(&document(), mergeDestination.deepEquivalent().parentAnchoredEquivalent(), mergeDestination.deepEquivalent().parentAnchoredEquivalent()); 658 if (! document().frame()->editor().client()->shouldMoveRangeAfterDelete(range.get(), rangeToBeReplaced.get()))658 if (!frame().editor().client()->shouldMoveRangeAfterDelete(range.get(), rangeToBeReplaced.get())) 659 659 return; 660 660 … … 729 729 // but, if we change the selection, come back and start typing that style should be lost. Also see 730 730 // preserveTypingStyle() below. 731 document().frame()->selection().setTypingStyle(m_typingStyle);731 frame().selection().setTypingStyle(m_typingStyle); 732 732 } 733 733 … … 802 802 Element* textControl = enclosingTextFormControl(m_selectionToDelete.start()); 803 803 if (textControl && textControl->focused()) 804 document().frame()->editor().textWillBeDeletedInTextField(textControl);804 frame().editor().textWillBeDeletedInTextField(textControl); 805 805 } 806 806 … … 860 860 calculateTypingStyleAfterDelete(); 861 861 862 if (!originalString.isEmpty()) { 863 if (Frame* frame = document().frame()) 864 frame->editor().deletedAutocorrectionAtPosition(m_endingPosition, originalString); 865 } 862 if (!originalString.isEmpty()) 863 frame().editor().deletedAutocorrectionAtPosition(m_endingPosition, originalString); 866 864 867 865 setEndingSelection(VisibleSelection(m_endingPosition, affinity, endingSelection().isDirectional())); -
trunk/Source/WebCore/editing/EditCommand.cpp
r154938 r154943 62 62 } 63 63 64 Frame& EditCommand::frame() const 65 { 66 ASSERT(document().frame()); 67 return *document().frame(); 68 } 69 64 70 EditAction EditCommand::editingAction() const 65 71 { -
trunk/Source/WebCore/editing/EditCommand.h
r154938 r154943 39 39 class Document; 40 40 class Element; 41 class Frame; 41 42 42 43 class EditCommand : public RefCounted<EditCommand> { … … 62 63 EditCommand(Document&, const VisibleSelection&, const VisibleSelection&); 63 64 65 Frame& frame() const; 64 66 Document& document() const { return *m_document; } 65 67 CompositeEditCommand* parent() const { return m_parent; } -
trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp
r154938 r154943 168 168 // Handle the case where there is a typing style. 169 169 170 RefPtr<EditingStyle> typingStyle = document().frame()->selection().typingStyle();170 RefPtr<EditingStyle> typingStyle = frame().selection().typingStyle(); 171 171 172 172 if (typingStyle && !typingStyle->isEmpty()) { -
trunk/Source/WebCore/editing/InsertTextCommand.cpp
r154938 r154943 147 147 if (endingSelection().isNone()) 148 148 return; 149 } else if ( document().frame()->editor().isOverwriteModeEnabled()) {149 } else if (frame().editor().isOverwriteModeEnabled()) { 150 150 if (performOverwrite(m_text, m_selectInsertedText)) 151 151 return; … … 223 223 224 224 // Handle the case where there is a typing style. 225 if (RefPtr<EditingStyle> typingStyle = document().frame()->selection().typingStyle()) {225 if (RefPtr<EditingStyle> typingStyle = frame().selection().typingStyle()) { 226 226 typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWritingDirection); 227 227 if (!typingStyle->isEmpty()) -
trunk/Source/WebCore/editing/RemoveFormatCommand.cpp
r154938 r154943 80 80 void RemoveFormatCommand::doApply() 81 81 { 82 Frame* frame = document().frame(); 83 84 if (!frame->selection().selection().isNonOrphanedCaretOrRange()) 82 if (!frame().selection().selection().isNonOrphanedCaretOrRange()) 85 83 return; 86 84 87 85 // Get the default style for this editable root, it's the style that we'll give the 88 86 // content that we're operating on. 89 Node* root = frame ->selection().rootEditableElement();87 Node* root = frame().selection().rootEditableElement(); 90 88 RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root); 91 89 -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r154938 r154943 1013 1013 // FIXME: Can this wait until after the operation has been performed? There doesn't seem to be 1014 1014 // any work performed after this that queries or uses the typing style. 1015 if (Frame* frame = document().frame()) 1016 frame->selection().clearTypingStyle(); 1015 frame().selection().clearTypingStyle(); 1017 1016 1018 1017 removeHeadContents(fragment); -
trunk/Source/WebCore/editing/SetSelectionCommand.cpp
r154938 r154943 41 41 void SetSelectionCommand::doApply() 42 42 { 43 FrameSelection& selection = document().frame()->selection();43 FrameSelection& selection = frame().selection(); 44 44 45 45 if (selection.shouldChangeSelection(m_selectionToSet) && m_selectionToSet.isNonOrphanedCaretOrRange()) { … … 51 51 void SetSelectionCommand::doUnapply() 52 52 { 53 FrameSelection& selection = document().frame()->selection();53 FrameSelection& selection = frame().selection(); 54 54 55 55 if (selection.shouldChangeSelection(startingSelection()) && startingSelection().isNonOrphanedCaretOrRange()) -
trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp
r154938 r154943 64 64 { 65 65 if (!m_hasBeenUndone) { 66 document().frame()->editor().unappliedSpellCorrection(startingSelection(), m_corrected, m_correction);66 frame().editor().unappliedSpellCorrection(startingSelection(), m_corrected, m_correction); 67 67 m_hasBeenUndone = true; 68 68 } … … 96 96 return; 97 97 98 if (! document().frame()->selection().shouldChangeSelection(m_selectionToBeCorrected))98 if (!frame().selection().shouldChangeSelection(m_selectionToBeCorrected)) 99 99 return; 100 100 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r154938 r154943 294 294 void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType) 295 295 { 296 Frame* frame = document().frame(); 297 if (!frame) 298 return; 296 Frame& frame = this->frame(); 299 297 300 298 #if PLATFORM(MAC) 301 if (!frame ->editor().isContinuousSpellCheckingEnabled()302 && !frame ->editor().isAutomaticQuoteSubstitutionEnabled()303 && !frame ->editor().isAutomaticLinkDetectionEnabled()304 && !frame ->editor().isAutomaticDashSubstitutionEnabled()305 && !frame ->editor().isAutomaticTextReplacementEnabled())299 if (!frame.editor().isContinuousSpellCheckingEnabled() 300 && !frame.editor().isAutomaticQuoteSubstitutionEnabled() 301 && !frame.editor().isAutomaticLinkDetectionEnabled() 302 && !frame.editor().isAutomaticDashSubstitutionEnabled() 303 && !frame.editor().isAutomaticTextReplacementEnabled()) 306 304 return; 307 305 #else 308 if (!frame ->editor().isContinuousSpellCheckingEnabled())306 if (!frame.editor().isContinuousSpellCheckingEnabled()) 309 307 return; 310 308 #endif … … 323 321 if (range && (commandType == TypingCommand::InsertText || commandType == TypingCommand::InsertLineBreak || commandType == TypingCommand::InsertParagraphSeparator || commandType == TypingCommand::InsertParagraphSeparatorInQuotedContent)) 324 322 strippedPreviousWord = plainText(range.get()).stripWhiteSpace(); 325 frame ->editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());323 frame.editor().markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty()); 326 324 } else if (commandType == TypingCommand::InsertText) 327 frame ->editor().startAlternativeTextUITimer();325 frame.editor().startAlternativeTextUITimer(); 328 326 } 329 327 } … … 331 329 void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping) 332 330 { 333 Frame* frame = document().frame(); 334 if (!frame) 335 return; 331 Frame& frame = this->frame(); 336 332 337 333 updatePreservesTypingStyle(commandTypeForAddedTyping); 338 334 339 335 #if PLATFORM(MAC) 340 frame ->editor().appliedEditing(this);336 frame.editor().appliedEditing(this); 341 337 // Since the spellchecking code may also perform corrections and other replacements, it should happen after the typing changes. 342 338 if (!m_shouldPreventSpellChecking) … … 345 341 // The old spellchecking code requires that checking be done first, to prevent issues like that in 6864072, where <doesn't> is marked as misspelled. 346 342 markMisspellingsAfterTyping(commandTypeForAddedTyping); 347 frame ->editor().appliedEditing(this);343 frame.editor().appliedEditing(this); 348 344 #endif 349 345 } … … 424 420 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing) 425 421 { 426 Frame* frame = document().frame(); 427 if (!frame) 428 return; 429 430 frame->editor().updateMarkersForWordsAffectedByEditing(false); 422 Frame& frame = this->frame(); 423 424 frame.editor().updateMarkersForWordsAffectedByEditing(false); 431 425 432 426 VisibleSelection selectionToDelete; … … 511 505 return; 512 506 513 if (selectionToDelete.isCaret() || !frame ->selection().shouldDeleteSelection(selectionToDelete))507 if (selectionToDelete.isCaret() || !frame.selection().shouldDeleteSelection(selectionToDelete)) 514 508 return; 515 509 516 510 if (killRing) 517 frame ->editor().addToKillRing(selectionToDelete.toNormalizedRange().get(), false);511 frame.editor().addToKillRing(selectionToDelete.toNormalizedRange().get(), false); 518 512 // Make undo select everything that has been deleted, unless an undo will undo more than just this deletion. 519 513 // FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete … … 528 522 void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing) 529 523 { 530 Frame* frame = document().frame(); 531 if (!frame) 532 return; 533 534 frame->editor().updateMarkersForWordsAffectedByEditing(false); 524 Frame& frame = this->frame(); 525 526 frame.editor().updateMarkersForWordsAffectedByEditing(false); 535 527 536 528 VisibleSelection selectionToDelete; … … 604 596 return; 605 597 606 if (selectionToDelete.isCaret() || !frame ->selection().shouldDeleteSelection(selectionToDelete))598 if (selectionToDelete.isCaret() || !frame.selection().shouldDeleteSelection(selectionToDelete)) 607 599 return; 608 600 609 601 if (killRing) 610 frame ->editor().addToKillRing(selectionToDelete.toNormalizedRange().get(), false);602 frame.editor().addToKillRing(selectionToDelete.toNormalizedRange().get(), false); 611 603 // make undo select what was deleted 612 604 setStartingSelection(selectionAfterUndo);
Note: See TracChangeset
for help on using the changeset viewer.