diff options
Diffstat (limited to 'Source/WebCore/dom/CurrentScriptIncrementer.h')
-rw-r--r-- | Source/WebCore/dom/CurrentScriptIncrementer.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Source/WebCore/dom/CurrentScriptIncrementer.h b/Source/WebCore/dom/CurrentScriptIncrementer.h index a8ceca25d..d08902334 100644 --- a/Source/WebCore/dom/CurrentScriptIncrementer.h +++ b/Source/WebCore/dom/CurrentScriptIncrementer.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -26,8 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CurrentScriptIncrementer_h -#define CurrentScriptIncrementer_h +#pragma once #include "Document.h" #include "HTMLScriptElement.h" @@ -37,25 +36,27 @@ namespace WebCore { class CurrentScriptIncrementer { WTF_MAKE_NONCOPYABLE(CurrentScriptIncrementer); public: - CurrentScriptIncrementer(Document* document, Element* element) + CurrentScriptIncrementer(Document& document, Element& element) : m_document(document) - , m_isHTMLScriptElement(isHTMLScriptElement(element)) + , m_isHTMLScriptElement(is<HTMLScriptElement>(element)) { - if (m_isHTMLScriptElement) - m_document->pushCurrentScript(toHTMLScriptElement(element)); + if (!m_isHTMLScriptElement) + return; + auto& scriptElement = downcast<HTMLScriptElement>(element); + bool shouldPushNullForCurrentScript = scriptElement.isInShadowTree() || scriptElement.scriptType() == ScriptElement::ScriptType::Module; + m_document.pushCurrentScript(shouldPushNullForCurrentScript ? nullptr : &scriptElement); } ~CurrentScriptIncrementer() { - if (m_isHTMLScriptElement) - m_document->popCurrentScript(); + if (!m_isHTMLScriptElement) + return; + m_document.popCurrentScript(); } private: - Document* m_document; + Document& m_document; bool m_isHTMLScriptElement; }; -} - -#endif +} // namespace WebCore |