summaryrefslogtreecommitdiff
path: root/Source/WebCore/inspector/DOMPatchSupport.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/inspector/DOMPatchSupport.h')
-rw-r--r--Source/WebCore/inspector/DOMPatchSupport.h49
1 files changed, 18 insertions, 31 deletions
diff --git a/Source/WebCore/inspector/DOMPatchSupport.h b/Source/WebCore/inspector/DOMPatchSupport.h
index ad5448487..d26c6f461 100644
--- a/Source/WebCore/inspector/DOMPatchSupport.h
+++ b/Source/WebCore/inspector/DOMPatchSupport.h
@@ -28,16 +28,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DOMPatchSupport_h
-#define DOMPatchSupport_h
-
-#include "ExceptionCode.h"
+#pragma once
+#include "ExceptionOr.h"
#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -46,43 +41,35 @@ class DOMEditor;
class Document;
class Node;
-#if ENABLE(INSPECTOR)
-
-class DOMPatchSupport {
- WTF_MAKE_NONCOPYABLE(DOMPatchSupport);
+class DOMPatchSupport final {
public:
- static void patchDocument(Document*, const String& markup);
-
- DOMPatchSupport(DOMEditor*, Document*);
- virtual ~DOMPatchSupport();
+ DOMPatchSupport(DOMEditor&, Document&);
void patchDocument(const String& markup);
- Node* patchNode(Node&, const String& markup, ExceptionCode&);
+ ExceptionOr<Node*> patchNode(Node&, const String& markup);
private:
struct Digest;
- typedef Vector<std::pair<Digest*, size_t>> ResultMap;
- typedef HashMap<String, Digest*> UnusedNodesMap;
- bool innerPatchNode(Digest* oldNode, Digest* newNode, ExceptionCode&);
- std::pair<ResultMap, ResultMap> diff(const Vector<OwnPtr<Digest>>& oldChildren, const Vector<OwnPtr<Digest>>& newChildren);
- bool innerPatchChildren(ContainerNode*, const Vector<OwnPtr<Digest>>& oldChildren, const Vector<OwnPtr<Digest>>& newChildren, ExceptionCode&);
- PassOwnPtr<Digest> createDigest(Node*, UnusedNodesMap*);
- bool insertBeforeAndMarkAsUsed(ContainerNode*, Digest*, Node* anchor, ExceptionCode&);
- bool removeChildAndMoveToNew(Digest*, ExceptionCode&);
- void markNodeAsUsed(Digest*);
+ using ResultMap = Vector<std::pair<Digest*, size_t>>;
+ using UnusedNodesMap = HashMap<String, Digest*>;
+
+ ExceptionOr<void> innerPatchNode(Digest& oldNode, Digest& newNode);
+ std::pair<ResultMap, ResultMap> diff(const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren);
+ ExceptionOr<void> innerPatchChildren(ContainerNode&, const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren);
+ std::unique_ptr<Digest> createDigest(Node&, UnusedNodesMap*);
+ ExceptionOr<void> insertBeforeAndMarkAsUsed(ContainerNode&, Digest&, Node* anchor);
+ ExceptionOr<void> removeChildAndMoveToNew(Digest&);
+ void markNodeAsUsed(Digest&);
+
#ifdef DEBUG_DOM_PATCH_SUPPORT
void dumpMap(const ResultMap&, const String& name);
#endif
- DOMEditor* m_domEditor;
- Document* m_document;
+ DOMEditor& m_domEditor;
+ Document& m_document;
UnusedNodesMap m_unusedNodesMap;
};
-#endif // ENABLE(INSPECTOR)
-
} // namespace WebCore
-
-#endif // !defined(DOMPatchSupport_h)