WebKit Bugzilla
Attachment 350093 Details for
Bug 184307
: Custom elements in a reaction queue can lose its JS wrapper and become HTMLUnknownElement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP2
wip184307b.patch (text/plain), 11.63 KB, created by
Ryosuke Niwa
on 2018-09-18 21:29:59 PDT
(
hide
)
Description:
WIP2
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-09-18 21:29:59 PDT
Size:
11.63 KB
patch
obsolete
>Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 236158) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -2839,6 +2839,8 @@ > 9B6C41531344949000085B62 /* StringWithDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6C41521344949000085B62 /* StringWithDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9B714E211C91166900AC0E92 /* EventPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B714E1F1C91166900AC0E92 /* EventPath.h */; }; > 9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */; }; >+ 9BAAC45B2151FAE7003D4A98 /* StrongNodeRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BAAC4582151E77A003D4A98 /* StrongNodeRef.cpp */; }; >+ 9BAAC45C21520128003D4A98 /* StrongNodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAAC4562151E39E003D4A98 /* StrongNodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAB6C6A12550631001626D4 /* EditingStyle.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BBA2CAB1F679E0C00FD1C1E /* WebContentReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF433761F67619B00E1FD71 /* WebContentReader.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -10861,6 +10863,8 @@ > 9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderCocoa.mm; sourceTree = "<group>"; }; > 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicalSelectionOffsetCaches.h; sourceTree = "<group>"; }; > 9BA827781F06156500F71E75 /* NavigationDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationDisabler.h; sourceTree = "<group>"; }; >+ 9BAAC4562151E39E003D4A98 /* StrongNodeRef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StrongNodeRef.h; sourceTree = "<group>"; }; >+ 9BAAC4582151E77A003D4A98 /* StrongNodeRef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StrongNodeRef.cpp; sourceTree = "<group>"; }; > 9BAB6C6A12550631001626D4 /* EditingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingStyle.h; sourceTree = "<group>"; }; > 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditingStyle.cpp; sourceTree = "<group>"; }; > 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritingDirection.h; sourceTree = "<group>"; }; >@@ -26570,6 +26574,8 @@ > F44EBBD61DB5D1B600277334 /* StaticRange.idl */, > 8102C5871325BB1100DDE67A /* StringCallback.cpp */, > 81AC6C35131C57D30009A7E0 /* StringCallback.h */, >+ 9BAAC4562151E39E003D4A98 /* StrongNodeRef.h */, >+ 9BAAC4582151E77A003D4A98 /* StrongNodeRef.cpp */, > 81AC6C34131C57C20009A7E0 /* StringCallback.idl */, > A8C4A7EC09D563270003AC8D /* StyledElement.cpp */, > A8C4A7EB09D563270003AC8D /* StyledElement.h */, >@@ -28153,6 +28159,7 @@ > 934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */, > A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */, > 0F580B0D0F12A2690051D689 /* GraphicsLayer.h in Headers */, >+ 9BAAC45C21520128003D4A98 /* StrongNodeRef.h in Headers */, > 499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */, > 0F580B0E0F12A2690051D689 /* GraphicsLayerClient.h in Headers */, > 1AC69593161A1E53003732CB /* GraphicsLayerFactory.h in Headers */, >@@ -32000,6 +32007,7 @@ > DECA80551F9FED6A00E3B661 /* UnifiedSource276.cpp in Sources */, > DECA80561F9FED6A00E3B661 /* UnifiedSource277.cpp in Sources */, > DECA80571F9FED6A00E3B661 /* UnifiedSource278.cpp in Sources */, >+ 9BAAC45B2151FAE7003D4A98 /* StrongNodeRef.cpp in Sources */, > DECA80581F9FED6A00E3B661 /* UnifiedSource279.cpp in Sources */, > DECA80591F9FED6A00E3B661 /* UnifiedSource280.cpp in Sources */, > DECA805A1F9FED6A00E3B661 /* UnifiedSource281.cpp in Sources */, >Index: Source/WebCore/bindings/js/JSNodeCustom.cpp >=================================================================== >--- Source/WebCore/bindings/js/JSNodeCustom.cpp (revision 236158) >+++ Source/WebCore/bindings/js/JSNodeCustom.cpp (working copy) >@@ -61,6 +61,7 @@ > #include "SVGElement.h" > #include "ScriptState.h" > #include "ShadowRoot.h" >+#include "StrongNodeRef.h" > #include "StyleSheet.h" > #include "StyledElement.h" > #include "Text.h" >@@ -107,6 +108,11 @@ > *reason = "Node which is firing event listeners"; > return true; > } >+ if (StrongNodeRefMap::contains(*node)) { >+ if (UNLIKELY(reason)) >+ *reason = "Node is scheduled to be used in an async script invocation)"; >+ return true; >+ } > } > > if (UNLIKELY(reason)) >Index: Source/WebCore/dom/CustomElementReactionQueue.cpp >=================================================================== >--- Source/WebCore/dom/CustomElementReactionQueue.cpp (revision 236158) >+++ Source/WebCore/dom/CustomElementReactionQueue.cpp (working copy) >@@ -234,7 +234,7 @@ > { > RELEASE_ASSERT(!m_invoking); > SetForScope<bool> invoking(m_invoking, true); >- Vector<Ref<Element>> elements; >+ Vector<StrongNodeRef<Element>> elements; > elements.swap(m_elements); > RELEASE_ASSERT(m_elements.isEmpty()); > for (auto& element : elements) { >Index: Source/WebCore/dom/CustomElementReactionQueue.h >=================================================================== >--- Source/WebCore/dom/CustomElementReactionQueue.h (revision 236158) >+++ Source/WebCore/dom/CustomElementReactionQueue.h (working copy) >@@ -28,6 +28,7 @@ > #include <wtf/Forward.h> > #include <wtf/Noncopyable.h> > #include <wtf/Vector.h> >+#include "StrongNodeRef.h" > > namespace JSC { > >@@ -71,7 +72,7 @@ > private: > void invokeAll(); > >- Vector<Ref<Element>> m_elements; >+ Vector<StrongNodeRef<Element>> m_elements; > bool m_invoking { false }; > }; > >Index: Source/WebCore/dom/StrongNodeRef.cpp >=================================================================== >--- Source/WebCore/dom/StrongNodeRef.cpp (nonexistent) >+++ Source/WebCore/dom/StrongNodeRef.cpp (working copy) >@@ -0,0 +1,37 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 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. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "StrongNodeRef.h" >+ >+namespace WebCore { >+ >+HashCountedSet<Node*>& StrongNodeRefMap::map() >+{ >+ static NeverDestroyed<HashCountedSet<Node*>> map; >+ return map; >+} >+ >+} // namespace WebCore >Index: Source/WebCore/dom/StrongNodeRef.h >=================================================================== >--- Source/WebCore/dom/StrongNodeRef.h (nonexistent) >+++ Source/WebCore/dom/StrongNodeRef.h (working copy) >@@ -0,0 +1,87 @@ >+/* >+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 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. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/DumbPtrTraits.h> >+#include <wtf/HashCountedSet.h> >+#include <wtf/Ref.h> >+ >+namespace WebCore { >+ >+class Node; >+ >+class StrongNodeRefMap { >+public: >+ static inline bool contains(Node& node) { return map().contains(&node); } >+ static inline void add(Node& node) { map().add(&node); } >+ static inline void remove(Node& node) { map().remove(&node); } >+ >+private: >+ static HashCountedSet<Node*>& map(); >+}; >+ >+template <typename T, typename = std::enable_if_t<std::is_same<T, typename std::remove_const<T>::type>::value>> >+class StrongNodeRef { >+ WTF_MAKE_NONCOPYABLE(StrongNodeRef); >+public: >+ >+ template<typename = std::enable_if_t<std::is_base_of<Node, T>::value>> >+ StrongNodeRef(T& object) >+ : m_ref(object) >+ { >+ StrongNodeRefMap::add(m_ref.get()); >+ } >+ >+ ~StrongNodeRef() >+ { >+ StrongNodeRefMap::remove(m_ref.get()); >+ } >+ >+ template<typename X, typename Y, typename = std::enable_if_t<std::is_base_of<Node, T>::value>> >+ StrongNodeRef(Ref<X, Y>&& other) >+ : m_ref(WTFMove(other.m_ref)) >+ { >+ StrongNodeRefMap::add(m_ref.get()); >+ } >+ >+ StrongNodeRef(StrongNodeRef&& other) >+ : m_ref(WTFMove(other.m_ref)) >+ { >+ } >+ >+ template<typename X, typename Y> StrongNodeRef(const StrongNodeRef<X, Y>& other) = delete; >+ >+ T* operator->() const { ASSERT(m_ref.ptr()); return m_ref.ptr(); } >+ T* ptr() const RETURNS_NONNULL { ASSERT(m_ref.ptr()); return m_ref.ptr(); } >+ T& get() const { ASSERT(m_ref.ptr()); return m_ref.get(); } >+ operator T&() const { ASSERT(m_ref.ptr()); return m_ref.get(); } >+ bool operator!() const { ASSERT(m_ref.ptr()); return !m_ref.get(); } >+ >+private: >+ Ref<T> m_ref; >+}; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 184307
:
337178
|
345910
|
349736
|
349740
|
349844
|
350093
|
350146
|
350157
|
350178