Title: [242391] trunk/Source/WebCore
Revision
242391
Author
[email protected]
Date
2019-03-04 14:00:28 -0800 (Mon, 04 Mar 2019)

Log Message

gPictureOwnerMap is unnecessary
https://bugs.webkit.org/show_bug.cgi?id=195228

Reviewed by Zalan Bujtas.

Just store in HTMLImageElement. An extra pointer isn't going to affect the memory use here.
If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::pictureElement const):
(WebCore::HTMLImageElement::setPictureElement):
* html/HTMLImageElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242390 => 242391)


--- trunk/Source/WebCore/ChangeLog	2019-03-04 21:59:09 UTC (rev 242390)
+++ trunk/Source/WebCore/ChangeLog	2019-03-04 22:00:28 UTC (rev 242391)
@@ -1,3 +1,18 @@
+2019-03-01  Ryosuke Niwa  <[email protected]>
+
+        gPictureOwnerMap is unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=195228
+
+        Reviewed by Zalan Bujtas.
+
+        Just store in HTMLImageElement. An extra pointer isn't going to affect the memory use here.
+        If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::pictureElement const):
+        (WebCore::HTMLImageElement::setPictureElement):
+        * html/HTMLImageElement.h:
+
 2019-03-04  Daniel Bates  <[email protected]>
 
         [iOS] Caret x-position in empty text area does not match text field

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (242390 => 242391)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2019-03-04 21:59:09 UTC (rev 242390)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2019-03-04 22:00:28 UTC (rev 242391)
@@ -67,9 +67,6 @@
 
 using namespace HTMLNames;
 
-typedef HashMap<const HTMLImageElement*, WeakPtr<HTMLPictureElement>> PictureOwnerMap;
-static PictureOwnerMap* gPictureOwnerMap = nullptr;
-
 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
     : HTMLElement(tagName, document)
     , m_imageLoader(*this)
@@ -454,25 +451,12 @@
 
 HTMLPictureElement* HTMLImageElement::pictureElement() const
 {
-    if (!gPictureOwnerMap || !gPictureOwnerMap->contains(this))
-        return nullptr;
-    auto result = gPictureOwnerMap->get(this);
-    if (!result)
-        gPictureOwnerMap->remove(this);
-    return result.get();
+    return m_pictureElement.get();
 }
     
 void HTMLImageElement::setPictureElement(HTMLPictureElement* pictureElement)
 {
-    if (!pictureElement) {
-        if (gPictureOwnerMap)
-            gPictureOwnerMap->remove(this);
-        return;
-    }
-    
-    if (!gPictureOwnerMap)
-        gPictureOwnerMap = new PictureOwnerMap();
-    gPictureOwnerMap->add(this, makeWeakPtr(*pictureElement));
+    m_pictureElement = makeWeakPtr(pictureElement);
 }
     
 unsigned HTMLImageElement::width(bool ignorePendingStylesheets)

Modified: trunk/Source/WebCore/html/HTMLImageElement.h (242390 => 242391)


--- trunk/Source/WebCore/html/HTMLImageElement.h	2019-03-04 21:59:09 UTC (rev 242390)
+++ trunk/Source/WebCore/html/HTMLImageElement.h	2019-03-04 22:00:28 UTC (rev 242391)
@@ -185,6 +185,8 @@
     bool m_hadNameBeforeAttributeChanged { false }; // FIXME: We only need this because parseAttribute() can't see the old value.
 
     RefPtr<EditableImageReference> m_editableImage;
+    WeakPtr<HTMLPictureElement> m_pictureElement;
+
 #if ENABLE(ATTACHMENT_ELEMENT)
     String m_pendingClonedAttachmentID;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to