| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const VisibleSelection& endingSelection() const { return m_endingSelection;
} | 51 const VisibleSelection& endingSelection() const { return m_endingSelection;
} |
| 52 | 52 |
| 53 virtual bool isSimpleEditCommand() const { return false; } | 53 virtual bool isSimpleEditCommand() const { return false; } |
| 54 virtual bool isCompositeEditCommand() const { return false; } | 54 virtual bool isCompositeEditCommand() const { return false; } |
| 55 virtual bool isEditCommandComposition() const { return false; } | 55 virtual bool isEditCommandComposition() const { return false; } |
| 56 bool isTopLevelCommand() const { return !m_parent; } | 56 bool isTopLevelCommand() const { return !m_parent; } |
| 57 | 57 |
| 58 virtual void doApply() = 0; | 58 virtual void doApply() = 0; |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 explicit EditCommand(Document*); | 61 explicit EditCommand(Document&); |
| 62 EditCommand(Document*, const VisibleSelection&, const VisibleSelection&); | 62 EditCommand(Document*, const VisibleSelection&, const VisibleSelection&); |
| 63 | 63 |
| 64 Document* document() const { return m_document.get(); } | 64 Document& document() const { return *m_document.get(); } |
| 65 CompositeEditCommand* parent() const { return m_parent; } | 65 CompositeEditCommand* parent() const { return m_parent; } |
| 66 void setStartingSelection(const VisibleSelection&); | 66 void setStartingSelection(const VisibleSelection&); |
| 67 void setEndingSelection(const VisibleSelection&); | 67 void setEndingSelection(const VisibleSelection&); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 RefPtr<Document> m_document; | 70 RefPtr<Document> m_document; |
| 71 VisibleSelection m_startingSelection; | 71 VisibleSelection m_startingSelection; |
| 72 VisibleSelection m_endingSelection; | 72 VisibleSelection m_endingSelection; |
| 73 CompositeEditCommand* m_parent; | 73 CompositeEditCommand* m_parent; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 enum ShouldAssumeContentIsAlwaysEditable { | 76 enum ShouldAssumeContentIsAlwaysEditable { |
| 77 AssumeContentIsAlwaysEditable, | 77 AssumeContentIsAlwaysEditable, |
| 78 DoNotAssumeContentIsAlwaysEditable, | 78 DoNotAssumeContentIsAlwaysEditable, |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class SimpleEditCommand : public EditCommand { | 81 class SimpleEditCommand : public EditCommand { |
| 82 public: | 82 public: |
| 83 virtual void doUnapply() = 0; | 83 virtual void doUnapply() = 0; |
| 84 virtual void doReapply(); // calls doApply() | 84 virtual void doReapply(); // calls doApply() |
| 85 | 85 |
| 86 #ifndef NDEBUG | 86 #ifndef NDEBUG |
| 87 virtual void getNodesInCommand(HashSet<Node*>&) = 0; | 87 virtual void getNodesInCommand(HashSet<Node*>&) = 0; |
| 88 #endif | 88 #endif |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 explicit SimpleEditCommand(Document* document) : EditCommand(document) { } | 91 explicit SimpleEditCommand(Document& document) : EditCommand(document) { } |
| 92 | 92 |
| 93 #ifndef NDEBUG | 93 #ifndef NDEBUG |
| 94 void addNodeAndDescendants(Node*, HashSet<Node*>&); | 94 void addNodeAndDescendants(Node*, HashSet<Node*>&); |
| 95 #endif | 95 #endif |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 virtual bool isSimpleEditCommand() const OVERRIDE { return true; } | 98 virtual bool isSimpleEditCommand() const OVERRIDE { return true; } |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 inline SimpleEditCommand* toSimpleEditCommand(EditCommand* command) | 101 inline SimpleEditCommand* toSimpleEditCommand(EditCommand* command) |
| 102 { | 102 { |
| 103 ASSERT(command); | 103 ASSERT(command); |
| 104 ASSERT_WITH_SECURITY_IMPLICATION(command->isSimpleEditCommand()); | 104 ASSERT_WITH_SECURITY_IMPLICATION(command->isSimpleEditCommand()); |
| 105 return static_cast<SimpleEditCommand*>(command); | 105 return static_cast<SimpleEditCommand*>(command); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace WebCore | 108 } // namespace WebCore |
| 109 | 109 |
| 110 #endif // EditCommand_h | 110 #endif // EditCommand_h |
| OLD | NEW |