diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/inspector/InspectorHistory.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/inspector/InspectorHistory.cpp')
-rw-r--r-- | Source/WebCore/inspector/InspectorHistory.cpp | 91 |
1 files changed, 27 insertions, 64 deletions
diff --git a/Source/WebCore/inspector/InspectorHistory.cpp b/Source/WebCore/inspector/InspectorHistory.cpp index bcfef4a4b..2c0816e81 100644 --- a/Source/WebCore/inspector/InspectorHistory.cpp +++ b/Source/WebCore/inspector/InspectorHistory.cpp @@ -29,119 +29,84 @@ */ #include "config.h" - -#if ENABLE(INSPECTOR) - #include "InspectorHistory.h" -#include "ExceptionCodePlaceholder.h" #include "Node.h" namespace WebCore { -namespace { - class UndoableStateMark : public InspectorHistory::Action { public: - UndoableStateMark() : InspectorHistory::Action("[UndoableState]") { } - - virtual bool perform(ExceptionCode&) override { return true; } - - virtual bool undo(ExceptionCode&) override { return true; } - - virtual bool redo(ExceptionCode&) override { return true; } + UndoableStateMark() + : Action("[UndoableState]") + { + } - virtual bool isUndoableStateMark() override { return true; } +private: + ExceptionOr<void> perform() final { return { }; } + ExceptionOr<void> undo() final { return { }; } + ExceptionOr<void> redo() final { return { }; } + bool isUndoableStateMark() final { return true; } }; -} - -InspectorHistory::Action::Action(const String& name) : m_name(name) -{ -} - -InspectorHistory::Action::~Action() -{ -} - -String InspectorHistory::Action::toString() +ExceptionOr<void> InspectorHistory::perform(std::unique_ptr<Action> action) { - return m_name; -} - -bool InspectorHistory::Action::isUndoableStateMark() -{ - return false; -} - -String InspectorHistory::Action::mergeId() -{ - return ""; -} - -void InspectorHistory::Action::merge(PassOwnPtr<Action>) -{ -} - -InspectorHistory::InspectorHistory() : m_afterLastActionIndex(0) { } - -InspectorHistory::~InspectorHistory() { } - -bool InspectorHistory::perform(PassOwnPtr<Action> action, ExceptionCode& ec) -{ - if (!action->perform(ec)) - return false; + auto performResult = action->perform(); + if (performResult.hasException()) + return performResult.releaseException(); if (!action->mergeId().isEmpty() && m_afterLastActionIndex > 0 && action->mergeId() == m_history[m_afterLastActionIndex - 1]->mergeId()) - m_history[m_afterLastActionIndex - 1]->merge(action); + m_history[m_afterLastActionIndex - 1]->merge(WTFMove(action)); else { m_history.resize(m_afterLastActionIndex); - m_history.append(action); + m_history.append(WTFMove(action)); ++m_afterLastActionIndex; } - return true; + return { }; } void InspectorHistory::markUndoableState() { - perform(adoptPtr(new UndoableStateMark()), IGNORE_EXCEPTION); + perform(std::make_unique<UndoableStateMark>()); } -bool InspectorHistory::undo(ExceptionCode& ec) +ExceptionOr<void> InspectorHistory::undo() { while (m_afterLastActionIndex > 0 && m_history[m_afterLastActionIndex - 1]->isUndoableStateMark()) --m_afterLastActionIndex; while (m_afterLastActionIndex > 0) { Action* action = m_history[m_afterLastActionIndex - 1].get(); - if (!action->undo(ec)) { + auto undoResult = action->undo(); + if (undoResult.hasException()) { reset(); - return false; + return undoResult.releaseException(); } --m_afterLastActionIndex; if (action->isUndoableStateMark()) break; } - return true; + return { }; } -bool InspectorHistory::redo(ExceptionCode& ec) +ExceptionOr<void> InspectorHistory::redo() { while (m_afterLastActionIndex < m_history.size() && m_history[m_afterLastActionIndex]->isUndoableStateMark()) ++m_afterLastActionIndex; while (m_afterLastActionIndex < m_history.size()) { Action* action = m_history[m_afterLastActionIndex].get(); - if (!action->redo(ec)) { + auto redoResult = action->redo(); + if (redoResult.hasException()) { reset(); - return false; + return redoResult.releaseException(); } ++m_afterLastActionIndex; if (action->isUndoableStateMark()) break; } - return true; + return { }; } void InspectorHistory::reset() @@ -151,5 +116,3 @@ void InspectorHistory::reset() } } // namespace WebCore - -#endif // ENABLE(INSPECTOR) |