Diff
Modified: trunk/Source/WebKit2/ChangeLog (159141 => 159142)
--- trunk/Source/WebKit2/ChangeLog 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-12 21:04:45 UTC (rev 159142)
@@ -1,3 +1,22 @@
+2013-11-12 Anders Carlsson <[email protected]>
+
+ Use Vector + ImmutableArray instead of MutableArray
+ https://bugs.webkit.org/show_bug.cgi?id=124221
+
+ Reviewed by Andreas Kling.
+
+ * Shared/WebRenderLayer.cpp:
+ (WebKit::WebRenderLayer::createArrayFromLayerList):
+ * Shared/WebRenderLayer.h:
+ * UIProcess/Notifications/WebNotificationProvider.cpp:
+ (WebKit::WebNotificationProvider::clearNotifications):
+ * UIProcess/WebPageContextMenuClient.cpp:
+ (WebKit::WebPageContextMenuClient::getContextMenuFromProposedMenu):
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+ (contextMenuItems):
+ (WKBundlePageCopyContextMenuItems):
+ (WKBundlePageCopyContextMenuAtPointInWindow):
+
2013-11-12 Zan Dobersek <[email protected]>
Unreviewed GTK build fix after r159129.
Modified: trunk/Source/WebKit2/Shared/WebRenderLayer.cpp (159141 => 159142)
--- trunk/Source/WebKit2/Shared/WebRenderLayer.cpp 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/Shared/WebRenderLayer.cpp 2013-11-12 21:04:45 UTC (rev 159142)
@@ -60,18 +60,18 @@
return adoptRef(new WebRenderLayer(rootLayer));
}
-PassRefPtr<MutableArray> WebRenderLayer::createArrayFromLayerList(Vector<RenderLayer*>* list)
+PassRefPtr<ImmutableArray> WebRenderLayer::createArrayFromLayerList(Vector<RenderLayer*>* list)
{
if (!list || !list->size())
- return 0;
+ return nullptr;
- RefPtr<MutableArray> array = MutableArray::create();
- for (size_t i = 0; i < list->size(); ++i) {
- RefPtr<WebRenderLayer> layer = adoptRef(new WebRenderLayer(list->at(i)));
- array->append(layer.get());
- }
+ Vector<RefPtr<APIObject>> layers;
+ layers.reserveInitialCapacity(list->size());
- return array.release();
+ for (const auto& layer : *list)
+ layers.uncheckedAppend(adoptRef(new WebRenderLayer(layer)));
+
+ return ImmutableArray::create(std::move(layers));
}
WebRenderLayer::WebRenderLayer(RenderLayer* layer)
Modified: trunk/Source/WebKit2/Shared/WebRenderLayer.h (159141 => 159142)
--- trunk/Source/WebKit2/Shared/WebRenderLayer.h 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/Shared/WebRenderLayer.h 2013-11-12 21:04:45 UTC (rev 159142)
@@ -74,7 +74,7 @@
{
}
- static PassRefPtr<MutableArray> createArrayFromLayerList(Vector<WebCore::RenderLayer*>*);
+ static PassRefPtr<ImmutableArray> createArrayFromLayerList(Vector<WebCore::RenderLayer*>*);
RefPtr<WebRenderObject> m_renderer;
bool m_isReflection;
@@ -83,9 +83,9 @@
CompositingLayerType m_compositingLayerType;
WebCore::IntRect m_absoluteBoundingBox;
- RefPtr<MutableArray> m_negativeZOrderList;
- RefPtr<MutableArray> m_normalFlowList;
- RefPtr<MutableArray> m_positiveZOrderList;
+ RefPtr<ImmutableArray> m_negativeZOrderList;
+ RefPtr<ImmutableArray> m_normalFlowList;
+ RefPtr<ImmutableArray> m_positiveZOrderList;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp (159141 => 159142)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp 2013-11-12 21:04:45 UTC (rev 159142)
@@ -65,13 +65,13 @@
if (!m_client.clearNotifications)
return;
- RefPtr<MutableArray> arrayIDs = MutableArray::create();
- size_t count = notificationIDs.size();
- arrayIDs->reserveCapacity(count);
- for (size_t i = 0; i < count; ++i)
- arrayIDs->append(WebUInt64::create(notificationIDs[i]).leakRef());
+ Vector<RefPtr<APIObject>> arrayIDs;
+ arrayIDs.reserveInitialCapacity(notificationIDs.size());
- m_client.clearNotifications(toAPI(arrayIDs.get()), m_client.clientInfo);
+ for (const auto& notificationID : notificationIDs)
+ arrayIDs.uncheckedAppend(WebUInt64::create(notificationID));
+
+ m_client.clearNotifications(toAPI(ImmutableArray::create(std::move(arrayIDs)).get()), m_client.clientInfo);
}
void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager)
Modified: trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp (159141 => 159142)
--- trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp 2013-11-12 21:04:45 UTC (rev 159142)
@@ -45,18 +45,18 @@
if (m_client.version >= 2 && !m_client.getContextMenuFromProposedMenu)
return false;
- unsigned size = proposedMenuVector.size();
- RefPtr<MutableArray> proposedMenu = MutableArray::create();
- proposedMenu->reserveCapacity(size);
- for (unsigned i = 0; i < size; ++i)
- proposedMenu->append(WebContextMenuItem::create(proposedMenuVector[i]).get());
-
- WKArrayRef newMenu = 0;
+ Vector<RefPtr<APIObject>> proposedMenuItems;
+ proposedMenuItems.reserveInitialCapacity(proposedMenuVector.size());
+
+ for (const auto& menuItem : proposedMenuVector)
+ proposedMenuItems.uncheckedAppend(WebContextMenuItem::create(menuItem));
+
+ WKArrayRef newMenu = nullptr;
if (m_client.version >= 2) {
RefPtr<WebHitTestResult> webHitTestResult = WebHitTestResult::create(hitTestResultData);
- m_client.getContextMenuFromProposedMenu(toAPI(page), toAPI(proposedMenu.get()), &newMenu, toAPI(webHitTestResult.get()), toAPI(userData), m_client.clientInfo);
+ m_client.getContextMenuFromProposedMenu(toAPI(page), toAPI(ImmutableArray::create(std::move(proposedMenuItems)).get()), &newMenu, toAPI(webHitTestResult.get()), toAPI(userData), m_client.clientInfo);
} else
- m_client.getContextMenuFromProposedMenu_deprecatedForUseWithV0(toAPI(page), toAPI(proposedMenu.get()), &newMenu, toAPI(userData), m_client.clientInfo);
+ m_client.getContextMenuFromProposedMenu_deprecatedForUseWithV0(toAPI(page), toAPI(ImmutableArray::create(std::move(proposedMenuItems)).get()), &newMenu, toAPI(userData), m_client.clientInfo);
RefPtr<ImmutableArray> array = adoptRef(toImpl(newMenu));
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (159141 => 159142)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2013-11-12 21:02:12 UTC (rev 159141)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2013-11-12 21:04:45 UTC (rev 159142)
@@ -165,20 +165,25 @@
#endif
}
-WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef)
+static PassRefPtr<ImmutableArray> contextMenuItems(const WebContextMenu& contextMenu)
{
-#if ENABLE(CONTEXT_MENUS)
- WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu();
+ auto items = contextMenu.items();
- auto items = contextMenu->items();
-
Vector<RefPtr<APIObject>> menuItems;
menuItems.reserveInitialCapacity(items.size());
for (const auto& item : items)
menuItems.uncheckedAppend(WebContextMenuItem::create(item));
- return toAPI(ImmutableArray::create(std::move(menuItems)).leakRef());
+ return ImmutableArray::create(std::move(menuItems));
+}
+
+WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef)
+{
+#if ENABLE(CONTEXT_MENUS)
+ WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu();
+
+ return toAPI(contextMenuItems(*contextMenu).leakRef());
#else
return nullptr;
#endif
@@ -189,19 +194,11 @@
#if ENABLE(CONTEXT_MENUS)
WebContextMenu* contextMenu = toImpl(pageRef)->contextMenuAtPointInWindow(toIntPoint(point));
if (!contextMenu)
- return 0;
+ return nullptr;
- const Vector<WebContextMenuItemData>& items = contextMenu->items();
- size_t arrayLength = items.size();
-
- RefPtr<MutableArray> menuArray = MutableArray::create();
- menuArray->reserveCapacity(arrayLength);
- for (unsigned i = 0; i < arrayLength; ++i)
- menuArray->append(WebContextMenuItem::create(items[i]).get());
-
- return toAPI(menuArray.release().leakRef());
+ return toAPI(contextMenuItems(*contextMenu).leakRef());
#else
- return 0;
+ return nullptr;
#endif
}