#ifndef EditCommand_h
#define EditCommand_h
#include "core/editing/EditAction.h"
#include "core/editing/VisibleSelection.h"
#ifndef NDEBUG
#include "wtf/HashSet.h"
#endif
namespace WebCore {
class CompositeEditCommand;
class Document;
class Element;
class EditCommand : public RefCounted<EditCommand> {
public:
virtual ~EditCommand();
void setParent(CompositeEditCommand*);
virtual EditAction editingAction() const;
const VisibleSelection& startingSelection() const { return m_startingSelection; }
const VisibleSelection& endingSelection() const { return m_endingSelection; }
virtual bool isSimpleEditCommand() const { return false; }
virtual bool isCompositeEditCommand() const { return false; }
bool isTopLevelCommand() const { return !m_parent; }
virtual void doApply() = 0;
protected:
explicit EditCommand(Document&);
EditCommand(Document*, const VisibleSelection&, const VisibleSelection&);
Document& document() const { return *m_document.get(); }
CompositeEditCommand* parent() const { return m_parent; }
void setStartingSelection(const VisibleSelection&);
void setStartingSelection(const VisiblePosition&);
void setEndingSelection(const VisibleSelection&);
void setEndingSelection(const VisiblePosition&);
private:
RefPtr<Document> m_document;
VisibleSelection m_startingSelection;
VisibleSelection m_endingSelection;
CompositeEditCommand* m_parent;
};
enum ShouldAssumeContentIsAlwaysEditable {
AssumeContentIsAlwaysEditable,
DoNotAssumeContentIsAlwaysEditable,
};
class SimpleEditCommand : public EditCommand {
public:
virtual void doUnapply() = 0;
virtual void doReapply();
protected:
explicit SimpleEditCommand(Document& document) : EditCommand(document) { }
private:
virtual bool isSimpleEditCommand() const OVERRIDE FINAL { return true; }
};
DEFINE_TYPE_CASTS(SimpleEditCommand, EditCommand, command, command->isSimpleEditCommand(), command.isSimpleEditCommand());
}
#endif