diff options
Diffstat (limited to 'Source/WebCore/dom/ElementIteratorAssertions.h')
-rw-r--r-- | Source/WebCore/dom/ElementIteratorAssertions.h | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Source/WebCore/dom/ElementIteratorAssertions.h b/Source/WebCore/dom/ElementIteratorAssertions.h index c054ba371..df3703aca 100644 --- a/Source/WebCore/dom/ElementIteratorAssertions.h +++ b/Source/WebCore/dom/ElementIteratorAssertions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,50 +23,51 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ElementIteratorAssertions_h -#define ElementIteratorAssertions_h +#pragma once -#include "Document.h" #include "Element.h" +#include "NoEventDispatchAssertion.h" namespace WebCore { class ElementIteratorAssertions { public: - ElementIteratorAssertions(); - ElementIteratorAssertions(const Element* first); + ElementIteratorAssertions(const Node* first = nullptr); bool domTreeHasMutated() const; void dropEventDispatchAssertion(); + void clear(); private: const Document* m_document; uint64_t m_initialDOMTreeVersion; - OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion; + std::optional<NoEventDispatchAssertion> m_eventDispatchAssertion; }; -inline ElementIteratorAssertions::ElementIteratorAssertions() - : m_document(nullptr) - , m_initialDOMTreeVersion(0) -{ -} +// FIXME: No real point in doing these as inlines; they are for debugging and we usually turn off inlining in debug builds. -inline ElementIteratorAssertions::ElementIteratorAssertions(const Element* first) +inline ElementIteratorAssertions::ElementIteratorAssertions(const Node* first) : m_document(first ? &first->document() : nullptr) - , m_initialDOMTreeVersion(m_document ? m_document->domTreeVersion() : 0) - , m_noEventDispatchAssertion(m_document ? adoptPtr(new NoEventDispatchAssertion) : nullptr) + , m_initialDOMTreeVersion(first ? m_document->domTreeVersion() : 0) { + if (first) + m_eventDispatchAssertion = NoEventDispatchAssertion(); } inline bool ElementIteratorAssertions::domTreeHasMutated() const { - return m_initialDOMTreeVersion && m_document && m_document->domTreeVersion() != m_initialDOMTreeVersion; + return m_document && m_document->domTreeVersion() != m_initialDOMTreeVersion; } inline void ElementIteratorAssertions::dropEventDispatchAssertion() { - m_noEventDispatchAssertion = nullptr; + m_eventDispatchAssertion = std::nullopt; } +inline void ElementIteratorAssertions::clear() +{ + m_document = nullptr; + m_initialDOMTreeVersion = 0; + m_eventDispatchAssertion = std::nullopt; } -#endif +} // namespace WebCore |