Changeset 102833 in webkit
- Timestamp:
- Dec 14, 2011 3:16:06 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102832 r102833 1 2011-12-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Push more member functions from EditCommand to CompositeEditCommand 4 https://bugs.webkit.org/show_bug.cgi?id=74249 5 6 Reviewed by Enrica Casucci. 7 8 Moved startingRootEditableElement and endingRootEditableElement from EditCommand to EditCommandComposition, 9 and isTypingCommand, preservesTypingStyle, shouldRetainAutocorrectionIndicator, 10 setShouldRetainAutocorrectionIndicator, and shouldStopCaretBlinking from EditCommand to CompositeEditCommand. 11 Also removed EditCommand::updateLayout(). 12 13 * editing/ApplyBlockElementCommand.cpp: 14 (WebCore::ApplyBlockElementCommand::doApply): 15 * editing/ApplyStyleCommand.cpp: 16 (WebCore::ApplyStyleCommand::applyBlockStyle): 17 (WebCore::ApplyStyleCommand::applyInlineStyle): 18 * editing/CompositeEditCommand.cpp: 19 (WebCore::EditCommandComposition::EditCommandComposition): 20 (WebCore::EditCommandComposition::setStartingSelection): 21 (WebCore::EditCommandComposition::setEndingSelection): 22 (WebCore::CompositeEditCommand::preservesTypingStyle): 23 (WebCore::CompositeEditCommand::isTypingCommand): 24 (WebCore::CompositeEditCommand::shouldRetainAutocorrectionIndicator): 25 (WebCore::CompositeEditCommand::setShouldRetainAutocorrectionIndicator): 26 (WebCore::CompositeEditCommand::addBlockPlaceholderIfNeeded): 27 (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): 28 (WebCore::CompositeEditCommand::moveParagraphs): 29 * editing/CompositeEditCommand.h: 30 (WebCore::EditCommandComposition::startingRootEditableElement): 31 (WebCore::EditCommandComposition::endingRootEditableElement): 32 (WebCore::CompositeEditCommand::shouldStopCaretBlinking): 33 * editing/DeleteSelectionCommand.cpp: 34 (WebCore::DeleteSelectionCommand::removeNode): 35 (WebCore::DeleteSelectionCommand::fixupWhitespace): 36 * editing/EditCommand.cpp: 37 (WebCore::EditCommand::apply): 38 (WebCore::EditCommand::unapply): 39 (WebCore::EditCommand::reapply): 40 (WebCore::EditCommand::setStartingSelection): 41 (WebCore::EditCommand::setEndingSelection): 42 (WebCore::EditCommand::setParent): 43 * editing/EditCommand.h: 44 (WebCore::EditCommand::isEditCommandComposition): 45 * editing/Editor.cpp: 46 (WebCore::dispatchEditableContentChangedEvents): 47 (WebCore::Editor::appliedEditing): 48 (WebCore::Editor::unappliedEditing): 49 (WebCore::Editor::reappliedEditing): 50 * editing/Editor.h: 51 (WebCore::Editor::lastEditCommand): 52 * editing/FrameSelection.cpp: 53 (WebCore::FrameSelection::updateAppearance): 54 * editing/IndentOutdentCommand.cpp: 55 (WebCore::IndentOutdentCommand::outdentParagraph): 56 * editing/InsertLineBreakCommand.cpp: 57 (WebCore::InsertLineBreakCommand::doApply): 58 * editing/InsertParagraphSeparatorCommand.cpp: 59 (WebCore::InsertParagraphSeparatorCommand::doApply): 60 * editing/TypingCommand.cpp: 61 (WebCore::TypingCommand::lastTypingCommandIfStillOpenForTyping): 62 * editing/TypingCommand.h: 63 (WebCore::TypingCommand::shouldRetainAutocorrectionIndicator): 64 1 65 2011-12-14 Tony Chang <tony@chromium.org> 2 66 -
trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp
r95901 r102833 88 88 formatSelection(startOfSelection, endOfSelection); 89 89 90 updateLayout();91 90 document()->updateLayoutIgnorePendingStylesheets(); 91 92 92 ASSERT(startScope == endScope); 93 93 ASSERT(startIndex >= 0); -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r101707 r102833 244 244 // so that we avoid the expense of updating before each and every call 245 245 // to check a computed style 246 updateLayout();246 document()->updateLayoutIgnorePendingStylesheets(); 247 247 248 248 // get positions we want to use for applying style … … 541 541 // so that we avoid the expense of updating before each and every call 542 542 // to check a computed style 543 updateLayout();543 document()->updateLayoutIgnorePendingStylesheets(); 544 544 545 545 // adjust to the positions we want to use for applying style … … 631 631 // so that we avoid the expense of updating before each and every call 632 632 // to check a computed style 633 updateLayout();633 document()->updateLayoutIgnorePendingStylesheets(); 634 634 635 635 RefPtr<EditingStyle> styleToApply = style; -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r102643 r102833 79 79 EditCommandComposition::EditCommandComposition(Document* document, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, bool wasCreateLinkCommand) 80 80 : EditCommand(document, startingSelection, endingSelection) 81 , m_startingRootEditableElement(startingSelection.rootEditableElement()) 82 , m_endingRootEditableElement(endingSelection.rootEditableElement()) 81 83 , m_wasCreateLinkCommand(wasCreateLinkCommand) 82 84 { … … 105 107 { 106 108 m_commands.append(command); 109 } 110 111 void EditCommandComposition::setStartingSelection(const VisibleSelection& selection) 112 { 113 EditCommand::setStartingSelection(selection); 114 m_startingRootEditableElement = selection.rootEditableElement(); 115 } 116 117 void EditCommandComposition::setEndingSelection(const VisibleSelection& selection) 118 { 119 EditCommand::setEndingSelection(selection); 120 m_endingRootEditableElement = selection.rootEditableElement(); 107 121 } 108 122 … … 149 163 { 150 164 return false; 165 } 166 167 bool CompositeEditCommand::preservesTypingStyle() const 168 { 169 return false; 170 } 171 172 bool CompositeEditCommand::isTypingCommand() const 173 { 174 return false; 175 } 176 177 bool CompositeEditCommand::shouldRetainAutocorrectionIndicator() const 178 { 179 return false; 180 } 181 182 void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) 183 { 151 184 } 152 185 … … 729 762 return 0; 730 763 731 updateLayout();764 document()->updateLayoutIgnorePendingStylesheets(); 732 765 733 766 RenderObject* renderer = container->renderer(); … … 774 807 return 0; 775 808 776 updateLayout();809 document()->updateLayoutIgnorePendingStylesheets(); 777 810 778 811 // It's strange that this function is responsible for verifying that pos has not been invalidated … … 1084 1117 insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquivalent()); 1085 1118 // Need an updateLayout here in case inserting the br has split a text node. 1086 updateLayout();1119 document()->updateLayoutIgnorePendingStylesheets(); 1087 1120 } 1088 1121 -
trunk/Source/WebCore/editing/CompositeEditCommand.h
r102643 r102833 48 48 bool wasCreateLinkCommand() const { return m_wasCreateLinkCommand; } 49 49 50 Element* startingRootEditableElement() const { return m_startingRootEditableElement.get(); } 51 Element* endingRootEditableElement() const { return m_endingRootEditableElement.get(); } 52 50 53 #ifndef NDEBUG 51 54 virtual void getNodesInCommand(HashSet<Node*>&); … … 55 58 EditCommandComposition(Document*, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, bool wasCreateLinkCommand); 56 59 virtual bool isEditCommandComposition() const OVERRIDE { return true; } 60 virtual void setStartingSelection(const VisibleSelection&) OVERRIDE; 61 virtual void setEndingSelection(const VisibleSelection&) OVERRIDE; 57 62 58 63 Vector<RefPtr<SimpleEditCommand> > m_commands; 64 RefPtr<Element> m_startingRootEditableElement; 65 RefPtr<Element> m_endingRootEditableElement; 59 66 bool m_wasCreateLinkCommand; 60 67 }; … … 69 76 70 77 virtual bool isCreateLinkCommand() const; 78 virtual bool isTypingCommand() const; 79 virtual bool preservesTypingStyle() const; 80 virtual bool shouldRetainAutocorrectionIndicator() const; 81 virtual void setShouldRetainAutocorrectionIndicator(bool); 82 virtual bool shouldStopCaretBlinking() const { return false; } 71 83 72 84 protected: -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r101830 r102833 362 362 363 363 // Make sure empty cell has some height, if a placeholder can be inserted. 364 updateLayout();364 document()->updateLayoutIgnorePendingStylesheets(); 365 365 RenderObject *r = node->renderer(); 366 366 if (r && r->isTableCell() && toRenderTableCell(r)->contentHeight() <= 0) { … … 529 529 void DeleteSelectionCommand::fixupWhitespace() 530 530 { 531 updateLayout();531 document()->updateLayoutIgnorePendingStylesheets(); 532 532 // FIXME: isRenderedCharacter should be removed, and we should use VisiblePosition::characterAfter and VisiblePosition::characterBefore 533 533 if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharacter() && m_leadingWhitespace.deprecatedNode()->isTextNode()) { -
trunk/Source/WebCore/editing/EditCommand.cpp
r102643 r102833 96 96 // use them perform one if one is necessary (like for the creation of VisiblePositions). 97 97 if (isTopLevelCommand()) 98 updateLayout();98 document()->updateLayoutIgnorePendingStylesheets(); 99 99 100 100 { … … 108 108 if (isTopLevelCommand()) { 109 109 ASSERT(isCompositeEditCommand()); 110 CompositeEditCommand* command = toCompositeEditCommand(this); 110 111 // Only need to call appliedEditing for top-level commands, and TypingCommands do it on their 111 112 // own (see TypingCommand::typingAddedToOpenCommand). 112 if (!isTypingCommand()) 113 frame->editor()->appliedEditing(toCompositeEditCommand(this)); 114 } 115 116 setShouldRetainAutocorrectionIndicator(false); 113 if (!command->isTypingCommand()) 114 frame->editor()->appliedEditing(command); 115 command->setShouldRetainAutocorrectionIndicator(false); 116 } 117 117 } 118 118 … … 129 129 // use them perform one if one is necessary (like for the creation of VisiblePositions). 130 130 if (isTopLevelCommand()) 131 updateLayout();131 document()->updateLayoutIgnorePendingStylesheets(); 132 132 133 133 DeleteButtonController* deleteButtonController = frame->editor()->deleteButtonController(); … … 152 152 // use them perform one if one is necessary (like for the creation of VisiblePositions). 153 153 if (isTopLevelCommand()) 154 updateLayout();154 document()->updateLayoutIgnorePendingStylesheets(); 155 155 156 156 DeleteButtonController* deleteButtonController = frame->editor()->deleteButtonController(); … … 182 182 void EditCommand::setStartingSelection(const VisibleSelection& s) 183 183 { 184 Element* root = s.rootEditableElement();185 184 for (EditCommand* cmd = this; ; cmd = cmd->m_parent) { 186 185 if (EditCommandComposition* composition = compositionIfPossible(cmd)) { 187 186 ASSERT(cmd->isTopLevelCommand()); 188 composition->m_startingSelection = s; 189 composition->m_startingRootEditableElement = root; 187 static_cast<EditCommand*>(composition)->setStartingSelection(s); 190 188 } 191 189 cmd->m_startingSelection = s; 192 cmd->m_startingRootEditableElement = root;193 190 if (!cmd->m_parent || cmd->m_parent->isFirstCommand(cmd)) 194 191 break; … … 198 195 void EditCommand::setEndingSelection(const VisibleSelection &s) 199 196 { 200 Element* root = s.rootEditableElement();201 197 for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) { 202 198 if (EditCommandComposition* composition = compositionIfPossible(cmd)) { 203 199 ASSERT(cmd->isTopLevelCommand()); 204 composition->m_endingSelection = s; 205 composition->m_endingRootEditableElement = root; 200 static_cast<EditCommand*>(composition)->setEndingSelection(s); 206 201 } 207 202 cmd->m_endingSelection = s; 208 cmd->m_endingRootEditableElement = root; 209 } 210 } 211 212 bool EditCommand::preservesTypingStyle() const 213 { 214 return false; 215 } 216 217 bool EditCommand::isTypingCommand() const 218 { 219 return false; 220 } 221 222 bool EditCommand::shouldRetainAutocorrectionIndicator() const 223 { 224 return false; 225 } 226 227 void EditCommand::setShouldRetainAutocorrectionIndicator(bool) 228 { 229 } 230 231 void EditCommand::updateLayout() const 232 { 233 document()->updateLayoutIgnorePendingStylesheets(); 203 } 234 204 } 235 205 … … 242 212 m_startingSelection = parent->m_endingSelection; 243 213 m_endingSelection = parent->m_endingSelection; 244 m_startingRootEditableElement = parent->m_endingRootEditableElement;245 m_endingRootEditableElement = parent->m_endingRootEditableElement;246 214 } 247 215 } -
trunk/Source/WebCore/editing/EditCommand.h
r102643 r102833 55 55 const VisibleSelection& endingSelection() const { return m_endingSelection; } 56 56 57 Element* startingRootEditableElement() const { return m_startingRootEditableElement.get(); }58 Element* endingRootEditableElement() const { return m_endingRootEditableElement.get(); }59 60 57 virtual bool isSimpleEditCommand() const { return false; } 61 58 virtual bool isCompositeEditCommand() const { return false; } 62 59 virtual bool isEditCommandComposition() const { return false; } 63 virtual bool isTypingCommand() const;64 65 virtual bool preservesTypingStyle() const;66 67 60 bool isTopLevelCommand() const { return !m_parent; } 68 69 virtual bool shouldRetainAutocorrectionIndicator() const;70 virtual void setShouldRetainAutocorrectionIndicator(bool);71 virtual bool shouldStopCaretBlinking() const { return false; }72 61 73 62 protected: … … 78 67 CompositeEditCommand* parent() const { return m_parent; } 79 68 80 void setStartingSelection(const VisibleSelection&); 81 void setEndingSelection(const VisibleSelection&); 82 83 void updateLayout() const; 69 virtual void setStartingSelection(const VisibleSelection&); 70 virtual void setEndingSelection(const VisibleSelection&); 84 71 85 72 private: … … 91 78 VisibleSelection m_startingSelection; 92 79 VisibleSelection m_endingSelection; 93 RefPtr<Element> m_startingRootEditableElement;94 RefPtr<Element> m_endingRootEditableElement;95 80 CompositeEditCommand* m_parent; 96 81 -
trunk/Source/WebCore/editing/Editor.cpp
r102553 r102833 855 855 } 856 856 857 static void dispatchEditableContentChangedEvents(const EditCommand& command) 858 { 859 Element* startRoot = command.startingRootEditableElement(); 860 Element* endRoot = command.endingRootEditableElement(); 857 static void dispatchEditableContentChangedEvents(Element* startRoot, Element* endRoot) 858 { 861 859 ExceptionCode ec; 862 860 if (startRoot) … … 870 868 m_frame->document()->updateLayout(); 871 869 872 dispatchEditableContentChangedEvents(*cmd); 870 EditCommandComposition* composition = cmd->composition(); 871 ASSERT(composition); 872 dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement()); 873 873 VisibleSelection newSelection(cmd->endingSelection()); 874 874 … … 899 899 m_frame->document()->updateLayout(); 900 900 901 dispatchEditableContentChangedEvents( *cmd);901 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); 902 902 903 903 VisibleSelection newSelection(cmd->startingSelection()); … … 915 915 m_frame->document()->updateLayout(); 916 916 917 dispatchEditableContentChangedEvents( *cmd);917 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); 918 918 919 919 VisibleSelection newSelection(cmd->endingSelection()); -
trunk/Source/WebCore/editing/Editor.h
r102627 r102833 92 92 Frame* frame() const { return m_frame; } 93 93 DeleteButtonController* deleteButtonController() const { return m_deleteButtonController.get(); } 94 EditCommand* lastEditCommand() { return m_lastEditCommand.get(); }94 CompositeEditCommand* lastEditCommand() { return m_lastEditCommand.get(); } 95 95 96 96 void handleKeyboardEvent(KeyboardEvent*); … … 386 386 Frame* m_frame; 387 387 OwnPtr<DeleteButtonController> m_deleteButtonController; 388 RefPtr< EditCommand> m_lastEditCommand;388 RefPtr<CompositeEditCommand> m_lastEditCommand; 389 389 RefPtr<Node> m_removedAnchor; 390 390 RefPtr<Text> m_compositionNode; -
trunk/Source/WebCore/editing/FrameSelection.cpp
r102413 r102833 1658 1658 bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing); 1659 1659 1660 EditCommand* lastEditCommand = m_frame ? m_frame->editor()->lastEditCommand() : 0;1660 CompositeEditCommand* lastEditCommand = m_frame ? m_frame->editor()->lastEditCommand() : 0; 1661 1661 bool shouldStopBlinkingDueToTypingCommand = lastEditCommand && lastEditCommand->shouldStopCaretBlinking(); 1662 1662 -
trunk/Source/WebCore/editing/IndentOutdentCommand.cpp
r99918 r102833 162 162 } 163 163 } 164 165 updateLayout();164 165 document()->updateLayoutIgnorePendingStylesheets(); 166 166 visibleStartOfParagraph = VisiblePosition(visibleStartOfParagraph.deepEquivalent()); 167 167 visibleEndOfParagraph = VisiblePosition(visibleEndOfParagraph.deepEquivalent()); -
trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp
r93134 r102833 144 144 145 145 // Handle whitespace that occurs after the split 146 updateLayout();146 document()->updateLayoutIgnorePendingStylesheets(); 147 147 if (!endingPosition.isRenderedCharacter()) { 148 148 Position positionBeforeTextNode(positionInParentBeforeNode(textNode)); -
trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r93134 r102833 349 349 insertNodeAfter(blockToInsert.get(), startBlock); 350 350 351 updateLayout();351 document()->updateLayoutIgnorePendingStylesheets(); 352 352 353 353 // If the paragraph separator was inserted at the end of a paragraph, an empty line must be … … 385 385 // Handle whitespace that occurs after the split 386 386 if (splitText) { 387 updateLayout();387 document()->updateLayoutIgnorePendingStylesheets(); 388 388 if (insertionPosition.anchorType() == Position::PositionIsOffsetInAnchor) 389 389 insertionPosition.moveToOffset(0); -
trunk/Source/WebCore/editing/SpellingCorrectionController.cpp
r102643 r102833 428 428 } 429 429 430 void SpellingCorrectionController::respondToAppliedEditing( EditCommand* command)430 void SpellingCorrectionController::respondToAppliedEditing(CompositeEditCommand* command) 431 431 { 432 432 if (command->isTopLevelCommand() && !command->shouldRetainAutocorrectionIndicator()) -
trunk/Source/WebCore/editing/SpellingCorrectionController.h
r102643 r102833 37 37 namespace WebCore { 38 38 39 class CompositeEditCommand; 39 40 class EditorClient; 40 41 class EditCommand; … … 89 90 90 91 void respondToUnappliedSpellCorrection(const VisibleSelection&, const String& corrected, const String& correction) UNLESS_ENABLED({ UNUSED_PARAM(corrected); UNUSED_PARAM(correction); }) 91 void respondToAppliedEditing( EditCommand*) UNLESS_ENABLED({})92 void respondToAppliedEditing(CompositeEditCommand*) UNLESS_ENABLED({ }) 92 93 void respondToUnappliedEditing(EditCommandComposition*) UNLESS_ENABLED({ }) 93 94 void respondToChangedSelection(const VisibleSelection& oldSelection) UNLESS_ENABLED({ UNUSED_PARAM(oldSelection); }) -
trunk/Source/WebCore/editing/TypingCommand.cpp
r102225 r102833 241 241 ASSERT(frame); 242 242 243 EditCommand* lastEditCommand = frame->editor()->lastEditCommand();243 CompositeEditCommand* lastEditCommand = frame->editor()->lastEditCommand(); 244 244 if (!lastEditCommand || !lastEditCommand->isTypingCommand() || !static_cast<TypingCommand*>(lastEditCommand)->isOpenForMoreTyping()) 245 245 return 0; -
trunk/Source/WebCore/editing/TypingCommand.h
r102413 r102833 102 102 virtual bool isTypingCommand() const; 103 103 virtual bool preservesTypingStyle() const { return m_preservesTypingStyle; } 104 virtual bool shouldRetainAutocorrectionIndicator() const { return m_shouldRetainAutocorrectionIndicator; } 104 virtual bool shouldRetainAutocorrectionIndicator() const 105 { 106 ASSERT(isTopLevelCommand()); 107 return m_shouldRetainAutocorrectionIndicator; 108 } 105 109 virtual void setShouldRetainAutocorrectionIndicator(bool retain) { m_shouldRetainAutocorrectionIndicator = retain; } 106 110 virtual bool shouldStopCaretBlinking() const { return true; }
Note: See TracChangeset
for help on using the changeset viewer.