Title: [159149] trunk/Source/WebKit2
Revision
159149
Author
[email protected]
Date
2013-11-12 14:20:14 -0800 (Tue, 12 Nov 2013)

Log Message

Remove most uses of MutableArray
https://bugs.webkit.org/show_bug.cgi?id=124232

Reviewed by Sam Weinig.

* Shared/API/c/WKMutableArray.cpp:
(WKMutableArrayCreate):
* Shared/UserMessageCoders.h:
(WebKit::UserMessageDecoder::baseDecode):
* Shared/WebRenderLayer.h:
(WebKit::WebRenderLayer::create):
(WebKit::WebRenderLayer::WebRenderLayer):
* Shared/WebRenderObject.cpp:
(WebKit::WebRenderObject::WebRenderObject):
* Shared/WebRenderObject.h:
(WebKit::WebRenderObject::create):
(WebKit::WebRenderObject::WebRenderObject):
* WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp:
(WebKit::InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159148 => 159149)


--- trunk/Source/WebKit2/ChangeLog	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-12 22:20:14 UTC (rev 159149)
@@ -1,5 +1,27 @@
 2013-11-12  Anders Carlsson  <[email protected]>
 
+        Remove most uses of MutableArray
+        https://bugs.webkit.org/show_bug.cgi?id=124232
+
+        Reviewed by Sam Weinig.
+
+        * Shared/API/c/WKMutableArray.cpp:
+        (WKMutableArrayCreate):
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageDecoder::baseDecode):
+        * Shared/WebRenderLayer.h:
+        (WebKit::WebRenderLayer::create):
+        (WebKit::WebRenderLayer::WebRenderLayer):
+        * Shared/WebRenderObject.cpp:
+        (WebKit::WebRenderObject::WebRenderObject):
+        * Shared/WebRenderObject.h:
+        (WebKit::WebRenderObject::create):
+        (WebKit::WebRenderObject::WebRenderObject):
+        * WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp:
+        (WebKit::InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems):
+
+2013-11-12  Anders Carlsson  <[email protected]>
+
         Use Vector + ImmutableArray instead of MutableArray
         https://bugs.webkit.org/show_bug.cgi?id=124221
 

Modified: trunk/Source/WebKit2/Shared/API/c/WKMutableArray.cpp (159148 => 159149)


--- trunk/Source/WebKit2/Shared/API/c/WKMutableArray.cpp	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/Shared/API/c/WKMutableArray.cpp	2013-11-12 22:20:14 UTC (rev 159149)
@@ -33,8 +33,7 @@
 
 WKMutableArrayRef WKMutableArrayCreate()
 {
-    RefPtr<MutableArray> array = MutableArray::create();
-    return toAPI(array.release().leakRef());
+    return toAPI(MutableArray::create().leakRef());
 }
 
 bool WKArrayIsMutable(WKArrayRef arrayRef)

Modified: trunk/Source/WebKit2/Shared/UserMessageCoders.h (159148 => 159149)


--- trunk/Source/WebKit2/Shared/UserMessageCoders.h	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/Shared/UserMessageCoders.h	2013-11-12 22:20:14 UTC (rev 159149)
@@ -419,8 +419,8 @@
             if (!decoder.decode(positiveZOrderListCoder))
                 return false;
             coder.m_root = WebRenderLayer::create(static_pointer_cast<WebRenderObject>(renderer), isReflection, isClipping, isClipped, static_cast<WebRenderLayer::CompositingLayerType>(compositingLayerTypeAsUInt32),
-                absoluteBoundingBox, static_pointer_cast<MutableArray>(negativeZOrderList), static_pointer_cast<MutableArray>(normalFlowList),
-                static_pointer_cast<MutableArray>(positiveZOrderList));
+                absoluteBoundingBox, static_pointer_cast<ImmutableArray>(negativeZOrderList), static_pointer_cast<ImmutableArray>(normalFlowList),
+                static_pointer_cast<ImmutableArray>(positiveZOrderList));
             break;
         }
         case APIObject::TypeRenderObject: {
@@ -450,7 +450,7 @@
                 return false;
             if (children && children->type() != APIObject::TypeArray)
                 return false;
-            coder.m_root = WebRenderObject::create(name, elementTagName, elementID, WTF::static_pointer_cast<MutableArray>(elementClassNames), absolutePosition, frameRect, WTF::static_pointer_cast<MutableArray>(children));
+            coder.m_root = WebRenderObject::create(name, elementTagName, elementID, static_pointer_cast<ImmutableArray>(elementClassNames), absolutePosition, frameRect, static_pointer_cast<ImmutableArray>(children));
             break;
         }
         case APIObject::TypeURL: {

Modified: trunk/Source/WebKit2/Shared/WebRenderLayer.h (159148 => 159149)


--- trunk/Source/WebKit2/Shared/WebRenderLayer.h	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/Shared/WebRenderLayer.h	2013-11-12 22:20:14 UTC (rev 159149)
@@ -42,7 +42,7 @@
 
     static PassRefPtr<WebRenderLayer> create(WebPage*);
     static PassRefPtr<WebRenderLayer> create(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type,
-        WebCore::IntRect absoluteBoundingBox, PassRefPtr<MutableArray> negativeZOrderList, PassRefPtr<MutableArray> normalFlowList, PassRefPtr<MutableArray> positiveZOrderList)
+        WebCore::IntRect absoluteBoundingBox, PassRefPtr<ImmutableArray> negativeZOrderList, PassRefPtr<ImmutableArray> normalFlowList, PassRefPtr<ImmutableArray> positiveZOrderList)
     {
         return adoptRef(new WebRenderLayer(renderer, isReflection, isClipping, isClipped, type, absoluteBoundingBox, negativeZOrderList, normalFlowList, positiveZOrderList));
     }
@@ -61,7 +61,7 @@
 private:
     WebRenderLayer(WebCore::RenderLayer*);
     WebRenderLayer(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type, WebCore::IntRect absoluteBoundingBox,
-        PassRefPtr<MutableArray> negativeZOrderList, PassRefPtr<MutableArray> normalFlowList, PassRefPtr<MutableArray> positiveZOrderList)
+        PassRefPtr<ImmutableArray> negativeZOrderList, PassRefPtr<ImmutableArray> normalFlowList, PassRefPtr<ImmutableArray> positiveZOrderList)
         : m_renderer(renderer)
         , m_isReflection(isReflection)
         , m_isClipping(isClipping)

Modified: trunk/Source/WebKit2/Shared/WebRenderObject.cpp (159148 => 159149)


--- trunk/Source/WebKit2/Shared/WebRenderObject.cpp	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/Shared/WebRenderObject.cpp	2013-11-12 22:20:14 UTC (rev 159149)
@@ -64,12 +64,15 @@
             Element* element = toElement(node);
             m_elementTagName = element->tagName();
             m_elementID = element->getIdAttribute();
+            
             if (element->isStyledElement() && element->hasClass()) {
-                if (size_t classNameCount = element->classNames().size()) {
-                    m_elementClassNames = MutableArray::create();
-                    for (size_t i = 0; i < classNameCount; ++i)
-                        m_elementClassNames->append(WebString::create(element->classNames()[i]).get());
-                }
+                Vector<RefPtr<APIObject>> classNames;
+                classNames.reserveInitialCapacity(element->classNames().size());
+
+                for (size_t i = 0, size = element->classNames().size(); i < size; ++i)
+                    classNames.append(WebString::create(element->classNames()[i]));
+
+                m_elementClassNames = ImmutableArray::create(std::move(classNames));
             }
         }
     }
@@ -89,24 +92,27 @@
     if (!shouldIncludeDescendants)
         return;
 
-    m_children = MutableArray::create();
+    Vector<RefPtr<APIObject>> children;
+
     for (RenderObject* coreChild = renderer->firstChildSlow(); coreChild; coreChild = coreChild->nextSibling()) {
         RefPtr<WebRenderObject> child = adoptRef(new WebRenderObject(coreChild, shouldIncludeDescendants));
-        m_children->append(child.get());
+        children.append(std::move(child));
     }
 
-    if (!renderer->isWidget())
-        return;
+    if (renderer->isWidget()) {
+        if (Widget* widget = toRenderWidget(renderer)->widget()) {
+            if (widget->isFrameView()) {
+                FrameView* frameView = toFrameView(widget);
+                if (RenderView* coreContentRenderer = frameView->frame().contentRenderer()) {
+                    RefPtr<WebRenderObject> contentRenderer = adoptRef(new WebRenderObject(coreContentRenderer, shouldIncludeDescendants));
 
-    Widget* widget = toRenderWidget(renderer)->widget();
-    if (!widget || !widget->isFrameView())
-        return;
+                    children.append(std::move(contentRenderer));
+                }
+            }
+        }
+    }
 
-    FrameView* frameView = toFrameView(widget);
-    if (RenderView* coreContentRenderer = frameView->frame().contentRenderer()) {
-        RefPtr<WebRenderObject> contentRenderer = adoptRef(new WebRenderObject(coreContentRenderer, shouldIncludeDescendants));
-        m_children->append(contentRenderer.get());
-    }
+    m_children = ImmutableArray::create(std::move(children));
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/WebRenderObject.h (159148 => 159149)


--- trunk/Source/WebKit2/Shared/WebRenderObject.h	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/Shared/WebRenderObject.h	2013-11-12 22:20:14 UTC (rev 159149)
@@ -49,7 +49,7 @@
     }
 
     static PassRefPtr<WebRenderObject> create(const String& name, const String& elementTagName, const String& elementID,
-        PassRefPtr<MutableArray> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<MutableArray> children)
+        PassRefPtr<ImmutableArray> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<ImmutableArray> children)
     {
         return adoptRef(new WebRenderObject(name, elementTagName, elementID, elementClassNames, absolutePosition, frameRect, children));
     }
@@ -65,8 +65,8 @@
 
 private:
     WebRenderObject(WebCore::RenderObject*, bool shouldIncludeDescendants);
-    WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<MutableArray> elementClassNames,
-        WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<MutableArray> children)
+    WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<ImmutableArray> elementClassNames,
+        WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<ImmutableArray> children)
         : m_children(children)
         , m_name(name)
         , m_elementTagName(elementTagName)
@@ -77,12 +77,12 @@
     {
     }
 
-    RefPtr<MutableArray> m_children;
+    RefPtr<ImmutableArray> m_children;
 
     String m_name;
     String m_elementTagName;
     String m_elementID;
-    RefPtr<MutableArray> m_elementClassNames;
+    RefPtr<ImmutableArray> m_elementClassNames;
     WebCore::IntPoint m_absolutePosition;
     WebCore::IntRect m_frameRect;
 };

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp (159148 => 159149)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp	2013-11-12 21:51:17 UTC (rev 159148)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp	2013-11-12 22:20:14 UTC (rev 159149)
@@ -47,14 +47,14 @@
     if (!m_client.getContextMenuFromDefaultMenu)
         return false;
 
-    RefPtr<MutableArray> defaultMenuArray = MutableArray::create();
-    defaultMenuArray->reserveCapacity(defaultMenu.size());
-    for (unsigned i = 0; i < defaultMenu.size(); ++i)
-        defaultMenuArray->append(WebContextMenuItem::create(defaultMenu[i]).get());
+    Vector<RefPtr<APIObject>> defaultMenuItems;
+    defaultMenuItems.reserveInitialCapacity(defaultMenu.size());
+    for (const auto& item : defaultMenu)
+        defaultMenuItems.uncheckedAppend(WebContextMenuItem::create(item));
 
     WKArrayRef newMenuWK = 0;
     WKTypeRef userDataToPass = 0;
-    m_client.getContextMenuFromDefaultMenu(toAPI(page), toAPI(hitTestResult), toAPI(defaultMenuArray.get()), &newMenuWK, &userDataToPass, m_client.clientInfo);
+    m_client.getContextMenuFromDefaultMenu(toAPI(page), toAPI(hitTestResult), toAPI(ImmutableArray::create(std::move(defaultMenuItems)).get()), &newMenuWK, &userDataToPass, m_client.clientInfo);
     RefPtr<ImmutableArray> array = adoptRef(toImpl(newMenuWK));
     userData = adoptRef(toImpl(userDataToPass));
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to