/* * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CompositeEditCommand_h #define CompositeEditCommand_h #include "EditCommand.h" #include "CSSPropertyNames.h" #include namespace WebCore { class CSSStyleDeclaration; class HTMLElement; class StyledElement; class Text; class CompositeEditCommand : public EditCommand { public: bool isFirstCommand(EditCommand* command) { return !m_commands.isEmpty() && m_commands.first() == command; } protected: CompositeEditCommand(Document*); // // sugary-sweet convenience functions to help create and apply edit commands in composite commands // void appendNode(PassRefPtr, PassRefPtr parent); void applyCommandToComposite(PassRefPtr); void applyStyle(CSSStyleDeclaration*, EditAction = EditActionChangeAttributes); void applyStyle(CSSStyleDeclaration*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes); void applyStyledElement(PassRefPtr); void removeStyledElement(PassRefPtr); void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true); void deleteSelection(const VisibleSelection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true); virtual void deleteTextFromNode(PassRefPtr, unsigned offset, unsigned count); void inputText(const String&, bool selectInsertedText = false); void insertNodeAfter(PassRefPtr, PassRefPtr refChild); void insertNodeAt(PassRefPtr, const Position&); void insertNodeAtTabSpanPosition(PassRefPtr, const Position&); void insertNodeBefore(PassRefPtr, PassRefPtr refChild); void insertParagraphSeparator(bool useDefaultParagraphElement = false); void insertLineBreak(); void insertTextIntoNode(PassRefPtr, unsigned offset, const String& text); void joinTextNodes(PassRefPtr, PassRefPtr); void mergeIdenticalElements(PassRefPtr, PassRefPtr); void rebalanceWhitespace(); void rebalanceWhitespaceAt(const Position&); void prepareWhitespaceAtPositionForSplit(Position&); void removeCSSProperty(PassRefPtr, CSSPropertyID); void removeNodeAttribute(PassRefPtr, const QualifiedName& attribute); void removeChildrenInRange(PassRefPtr, unsigned from, unsigned to); virtual void removeNode(PassRefPtr); HTMLElement* replaceNodeWithSpanPreservingChildrenAndAttributes(PassRefPtr); void removeNodePreservingChildren(PassRefPtr); void removeNodeAndPruneAncestors(PassRefPtr); void prune(PassRefPtr); void replaceTextInNode(PassRefPtr, unsigned offset, unsigned count, const String& replacementText); Position positionOutsideTabSpan(const Position&); void setNodeAttribute(PassRefPtr, const QualifiedName& attribute, const AtomicString& value); void splitElement(PassRefPtr, PassRefPtr atChild); void splitTextNode(PassRefPtr, unsigned offset); void splitTextNodeContainingElement(PassRefPtr, unsigned offset); void wrapContentsInDummySpan(PassRefPtr); void deleteInsignificantText(PassRefPtr, unsigned start, unsigned end); void deleteInsignificantText(const Position& start, const Position& end); void deleteInsignificantTextDownstream(const Position&); PassRefPtr appendBlockPlaceholder(PassRefPtr); PassRefPtr insertBlockPlaceholder(const Position&); PassRefPtr addBlockPlaceholderIfNeeded(Element*); void removePlaceholderAt(const Position&); PassRefPtr insertNewDefaultParagraphElementAt(const Position&); PassRefPtr moveParagraphContentsToNewBlockIfNecessary(const Position&); void pushAnchorElementDown(Node*); void moveParagraph(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true); void moveParagraphs(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true); void moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode); void cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement); void cleanupAfterDeletion(); bool breakOutOfEmptyListItem(); bool breakOutOfEmptyMailBlockquotedParagraph(); Position positionAvoidingSpecialElementBoundary(const Position&); PassRefPtr splitTreeToNode(Node*, Node*, bool splitAncestor = false); Vector > m_commands; private: virtual void doUnapply(); virtual void doReapply(); }; } // namespace WebCore #endif // CompositeEditCommand_h