Changeset 291933 in webkit
- Timestamp:
- Mar 25, 2022 10:26:02 PM (2 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r291911 r291933 1 2022-03-25 Chris Dumez <cdumez@apple.com> 2 3 Simplify / Optimize JSNodeOwner::isReachableFromOpaqueRoots() 4 https://bugs.webkit.org/show_bug.cgi?id=238380 5 6 Reviewed by Geoffrey Garen. 7 8 Drop checks specific to HTMLAudioElement and HTMLImageElement from 9 JSNodeOwner::isReachableFromOpaqueRoots() so that other Node wrappers 10 that are not audio or image elements do not have to pay the cost. 11 12 In the HTMLAudioElement case, HTMLAudioElement already subclasses HTMLMediaElement which 13 is an ActiveDOMObject and HTMLMediaElement::virtualHasPendingActivity() already takes 14 care of keeping the JS wrapper alive is there is audio playing. 15 16 For HTMLImageElement, I made it subclass ActiveDOMObject so that the JSHTMLImageElement 17 wrapper is now calling HTMLImageElement::hasPendingActivity() instead of every JS Node 18 wrapper via JSNodeOwner::isReachableFromOpaqueRoots(). 19 20 * bindings/js/JSNodeCustom.cpp: 21 (WebCore::isReachableFromDOM): 22 * html/HTMLImageElement.cpp: 23 (WebCore::HTMLImageElement::HTMLImageElement): 24 (WebCore::HTMLImageElement::create): 25 (WebCore::HTMLImageElement::createForLegacyFactoryFunction): 26 (WebCore::HTMLImageElement::activeDOMObjectName const): 27 (WebCore::HTMLImageElement::virtualHasPendingActivity const): 28 (WebCore::HTMLImageElement::hasPendingActivity const): Deleted. 29 * html/HTMLImageElement.h: 30 * html/HTMLImageElement.idl: 31 * html/ImageDocument.cpp: 32 (WebCore::ImageDocumentElement::create): 33 1 34 2022-03-25 Nikolaos Mouchtaris <nmouchtaris@apple.com> 2 35 -
trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp
r287327 r291933 33 33 #include "DocumentFragment.h" 34 34 #include "DocumentType.h" 35 #include "HTMLAudioElement.h"36 #include "HTMLCanvasElement.h"37 35 #include "HTMLElement.h" 38 #include "HTMLFrameElementBase.h"39 #include "HTMLImageElement.h"40 #include "HTMLLinkElement.h"41 36 #include "HTMLNames.h" 42 #include "HTMLScriptElement.h"43 #include "HTMLStyleElement.h"44 37 #include "JSAttr.h" 45 38 #include "JSCDATASection.h" … … 65 58 #include "ShadowRoot.h" 66 59 #include "GCReachableRef.h" 67 #include "StyleSheet.h"68 #include "StyledElement.h"69 60 #include "Text.h" 70 61 … … 77 68 { 78 69 if (!node->isConnected()) { 79 if (is<Element>(*node)) {80 auto& element = downcast<Element>(*node);81 82 // If a wrapper is the last reference to an image element83 // that is loading but not in the document, the wrapper is observable84 // because it is the only thing keeping the image element alive, and if85 // the element is destroyed, its load event will not fire.86 // FIXME: The DOM should manage this issue without the help of JavaScript wrappers.87 if (is<HTMLImageElement>(element)) {88 if (downcast<HTMLImageElement>(element).hasPendingActivity()) {89 if (UNLIKELY(reason))90 *reason = "Image element with pending activity";91 return true;92 }93 }94 #if ENABLE(VIDEO)95 else if (is<HTMLAudioElement>(element)) {96 if (!downcast<HTMLAudioElement>(element).paused()) {97 if (UNLIKELY(reason))98 *reason = "Audio element which is not paused";99 return true;100 }101 }102 #endif103 }104 105 70 // If a node is firing event listeners, its wrapper is observable because 106 71 // its wrapper is responsible for marking those event listeners. -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r287663 r291933 74 74 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form) 75 75 : HTMLElement(tagName, document) 76 , ActiveDOMObject(document) 76 77 , m_imageLoader(makeUnique<HTMLImageLoader>(*this)) 77 78 , m_form(nullptr) … … 86 87 Ref<HTMLImageElement> HTMLImageElement::create(Document& document) 87 88 { 88 return adoptRef(*new HTMLImageElement(imgTag, document)); 89 auto image = adoptRef(*new HTMLImageElement(imgTag, document)); 90 image->suspendIfNeeded(); 91 return image; 89 92 } 90 93 91 94 Ref<HTMLImageElement> HTMLImageElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) 92 95 { 93 return adoptRef(*new HTMLImageElement(tagName, document, form)); 96 auto image = adoptRef(*new HTMLImageElement(tagName, document, form)); 97 image->suspendIfNeeded(); 98 return image; 94 99 } 95 100 … … 109 114 if (height) 110 115 image->setHeight(height.value()); 116 image->suspendIfNeeded(); 111 117 return image; 112 118 } … … 867 873 } 868 874 869 bool HTMLImageElement::hasPendingActivity() const 875 const char* HTMLImageElement::activeDOMObjectName() const 876 { 877 return "HTMLImageElement"; 878 } 879 880 bool HTMLImageElement::virtualHasPendingActivity() const 870 881 { 871 882 return m_imageLoader->hasPendingActivity(); -
trunk/Source/WebCore/html/HTMLImageElement.h
r287663 r291933 24 24 #pragma once 25 25 26 #include "ActiveDOMObject.h" 26 27 #include "DecodingOptions.h" 27 28 #include "FormNamedItem.h" … … 46 47 enum class RelevantMutation : bool; 47 48 48 class HTMLImageElement : public HTMLElement, public FormNamedItem {49 class HTMLImageElement : public HTMLElement, public FormNamedItem, public ActiveDOMObject { 49 50 WTF_MAKE_ISO_ALLOCATED(HTMLImageElement); 50 51 friend class HTMLFormElement; … … 110 111 #endif 111 112 112 bool hasPendingActivity() const;113 113 WEBCORE_EXPORT size_t pendingDecodePromisesCountForTesting() const; 114 114 … … 166 166 void invalidateAttributeMapping(); 167 167 168 // ActiveDOMObject. 169 const char* activeDOMObjectName() const final; 170 bool virtualHasPendingActivity() const final; 171 168 172 void didAttachRenderers() override; 169 173 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; -
trunk/Source/WebCore/html/HTMLImageElement.idl
r289117 r291933 21 21 // https://html.spec.whatwg.org/multipage/embedded-content.html#htmlimageelement 22 22 [ 23 ActiveDOMObject, 23 24 ExportMacro=WEBCORE_EXPORT, 25 Exposed=Window, 24 26 JSGenerateToNativeObject, 25 Exposed=Window,26 27 LegacyFactoryFunctionCallWith=CurrentDocument, 27 28 LegacyFactoryFunction=Image(optional unsigned long width, optional unsigned long height) -
trunk/Source/WebCore/html/ImageDocument.cpp
r288201 r291933 117 117 inline Ref<ImageDocumentElement> ImageDocumentElement::create(ImageDocument& document) 118 118 { 119 return adoptRef(*new ImageDocumentElement(document)); 119 auto image = adoptRef(*new ImageDocumentElement(document)); 120 image->suspendIfNeeded(); 121 return image; 120 122 } 121 123
Note: See TracChangeset
for help on using the changeset viewer.