 Chromium Code Reviews
 Chromium Code Reviews Issue 299353004:
  Oilpan: move editing objects to the heap.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 299353004:
  Oilpan: move editing objects to the heap.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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 10 matching lines...) Expand all Loading... | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 24 */ | 24 */ | 
| 25 | 25 | 
| 26 #ifndef EditCommand_h | 26 #ifndef EditCommand_h | 
| 27 #define EditCommand_h | 27 #define EditCommand_h | 
| 28 | 28 | 
| 29 #include "core/editing/EditAction.h" | 29 #include "core/editing/EditAction.h" | 
| 30 #include "core/editing/VisibleSelection.h" | 30 #include "core/editing/VisibleSelection.h" | 
| 31 #include "platform/heap/Handle.h" | |
| 31 | 32 | 
| 32 #ifndef NDEBUG | 33 #ifndef NDEBUG | 
| 33 #include "wtf/HashSet.h" | 34 #include "wtf/HashSet.h" | 
| 34 #endif | 35 #endif | 
| 35 | 36 | 
| 36 namespace WebCore { | 37 namespace WebCore { | 
| 37 | 38 | 
| 38 class CompositeEditCommand; | 39 class CompositeEditCommand; | 
| 39 class Document; | 40 class Document; | 
| 40 class Element; | 41 class Element; | 
| 41 | 42 | 
| 42 class EditCommand : public RefCounted<EditCommand> { | 43 class EditCommand : public RefCountedWillBeGarbageCollectedFinalized<EditCommand > { | 
| 43 public: | 44 public: | 
| 44 virtual ~EditCommand(); | 45 virtual ~EditCommand(); | 
| 45 | 46 | 
| 46 void setParent(CompositeEditCommand*); | 47 void setParent(CompositeEditCommand*); | 
| 47 | 48 | 
| 48 virtual EditAction editingAction() const; | 49 virtual EditAction editingAction() const; | 
| 49 | 50 | 
| 50 const VisibleSelection& startingSelection() const { return m_startingSelecti on; } | 51 const VisibleSelection& startingSelection() const { return m_startingSelecti on; } | 
| 51 const VisibleSelection& endingSelection() const { return m_endingSelection; } | 52 const VisibleSelection& endingSelection() const { return m_endingSelection; } | 
| 52 | 53 | 
| 53 virtual bool isSimpleEditCommand() const { return false; } | 54 virtual bool isSimpleEditCommand() const { return false; } | 
| 54 virtual bool isCompositeEditCommand() const { return false; } | 55 virtual bool isCompositeEditCommand() const { return false; } | 
| 55 bool isTopLevelCommand() const { return !m_parent; } | 56 bool isTopLevelCommand() const { return !m_parent; } | 
| 56 | 57 | 
| 57 virtual void doApply() = 0; | 58 virtual void doApply() = 0; | 
| 58 | 59 | 
| 60 virtual void trace(Visitor*); | |
| 61 | |
| 59 protected: | 62 protected: | 
| 60 explicit EditCommand(Document&); | 63 explicit EditCommand(Document&); | 
| 61 EditCommand(Document*, const VisibleSelection&, const VisibleSelection&); | 64 EditCommand(Document*, const VisibleSelection&, const VisibleSelection&); | 
| 62 | 65 | 
| 63 Document& document() const { return *m_document.get(); } | 66 Document& document() const { return *m_document.get(); } | 
| 64 CompositeEditCommand* parent() const { return m_parent; } | 67 CompositeEditCommand* parent() const { return m_parent; } | 
| 65 void setStartingSelection(const VisibleSelection&); | 68 void setStartingSelection(const VisibleSelection&); | 
| 66 void setStartingSelection(const VisiblePosition&); | 69 void setStartingSelection(const VisiblePosition&); | 
| 67 void setEndingSelection(const VisibleSelection&); | 70 void setEndingSelection(const VisibleSelection&); | 
| 68 void setEndingSelection(const VisiblePosition&); | 71 void setEndingSelection(const VisiblePosition&); | 
| 69 | 72 | 
| 70 private: | 73 private: | 
| 71 RefPtr<Document> m_document; | 74 RefPtrWillBeMember<Document> m_document; | 
| 72 VisibleSelection m_startingSelection; | 75 VisibleSelection m_startingSelection; | 
| 73 VisibleSelection m_endingSelection; | 76 VisibleSelection m_endingSelection; | 
| 74 CompositeEditCommand* m_parent; | 77 CompositeEditCommand* m_parent; | 
| 
haraken
2014/05/26 02:36:12
Shouldn't this be a Member, since CompositeEditCom
 
sof
2014/05/28 08:31:35
Yes, now a Member. afaict, the command holding thi
 | |
| 75 }; | 78 }; | 
| 76 | 79 | 
| 77 enum ShouldAssumeContentIsAlwaysEditable { | 80 enum ShouldAssumeContentIsAlwaysEditable { | 
| 78 AssumeContentIsAlwaysEditable, | 81 AssumeContentIsAlwaysEditable, | 
| 79 DoNotAssumeContentIsAlwaysEditable, | 82 DoNotAssumeContentIsAlwaysEditable, | 
| 80 }; | 83 }; | 
| 81 | 84 | 
| 82 class SimpleEditCommand : public EditCommand { | 85 class SimpleEditCommand : public EditCommand { | 
| 
haraken
2014/05/26 02:36:12
Just to confirm: You don't need to define SimpleEd
 
sof
2014/05/28 08:31:35
That's the pattern I've tried to follow in this di
 | |
| 83 public: | 86 public: | 
| 84 virtual void doUnapply() = 0; | 87 virtual void doUnapply() = 0; | 
| 85 virtual void doReapply(); // calls doApply() | 88 virtual void doReapply(); // calls doApply() | 
| 86 | 89 | 
| 87 protected: | 90 protected: | 
| 88 explicit SimpleEditCommand(Document& document) : EditCommand(document) { } | 91 explicit SimpleEditCommand(Document& document) : EditCommand(document) { } | 
| 89 | 92 | 
| 90 private: | 93 private: | 
| 91 virtual bool isSimpleEditCommand() const OVERRIDE FINAL { return true; } | 94 virtual bool isSimpleEditCommand() const OVERRIDE FINAL { return true; } | 
| 92 }; | 95 }; | 
| 93 | 96 | 
| 94 DEFINE_TYPE_CASTS(SimpleEditCommand, EditCommand, command, command->isSimpleEdit Command(), command.isSimpleEditCommand()); | 97 DEFINE_TYPE_CASTS(SimpleEditCommand, EditCommand, command, command->isSimpleEdit Command(), command.isSimpleEditCommand()); | 
| 95 | 98 | 
| 96 } // namespace WebCore | 99 } // namespace WebCore | 
| 97 | 100 | 
| 98 #endif // EditCommand_h | 101 #endif // EditCommand_h | 
| OLD | NEW |