Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1437)

Unified Diff: Source/core/svg/properties/SVGListPropertyHelper.h

Issue 1177303004: Updated SVGListPropertyHelper as per SVG2 Spec (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed presubmit error Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPathSegMovetoRel.h ('k') | Source/core/svg/properties/SVGListPropertyTearOffHelper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/properties/SVGListPropertyHelper.h
diff --git a/Source/core/svg/properties/SVGListPropertyHelper.h b/Source/core/svg/properties/SVGListPropertyHelper.h
index a6fd4d713bc2ef6d9031351b66ccb2211cea05ee..76e6c8b1601e3fd88138cbde08dcf1439b80cd6e 100644
--- a/Source/core/svg/properties/SVGListPropertyHelper.h
+++ b/Source/core/svg/properties/SVGListPropertyHelper.h
@@ -171,7 +171,6 @@ protected:
private:
inline bool checkIndexBound(size_t, ExceptionState&);
- bool removeFromOldOwnerListAndAdjustIndex(PassRefPtrWillBeRawPtr<ItemPropertyType>, size_t* indexToModify);
size_t findItem(PassRefPtrWillBeRawPtr<ItemPropertyType>);
WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType>> m_values;
@@ -221,9 +220,6 @@ PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
{
RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem;
- // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list.
- removeFromOldOwnerListAndAdjustIndex(newItem, 0);
-
// Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
clear();
append(newItem);
@@ -250,12 +246,6 @@ PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem;
- // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
- if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) {
- // Inserting the item before itself is a no-op.
- return newItem.release();
- }
-
// Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be
// inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list.
m_values.insert(index, newItem);
@@ -283,9 +273,6 @@ PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
{
RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem;
- // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
- removeFromOldOwnerListAndAdjustIndex(newItem, 0);
-
// Append the value and wrapper at the end of the list.
append(newItem);
@@ -300,13 +287,6 @@ PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem;
- // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
- // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
- if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) {
- // Replacing the item with itself is a no-op.
- return newItem.release();
- }
-
if (m_values.isEmpty()) {
// 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace.
exceptionState.throwDOMException(IndexSizeError, String::format("Failed to replace the provided item at index %zu.", index));
@@ -335,41 +315,6 @@ bool SVGListPropertyHelper<Derived, ItemProperty>::checkIndexBound(size_t index,
}
template<typename Derived, typename ItemProperty>
-bool SVGListPropertyHelper<Derived, ItemProperty>::removeFromOldOwnerListAndAdjustIndex(PassRefPtrWillBeRawPtr<ItemPropertyType> passItem, size_t* indexToModify)
-{
- RefPtrWillBeRawPtr<ItemPropertyType> item = passItem;
- ASSERT(item);
- RefPtrWillBeRawPtr<Derived> ownerList = toDerived(item->ownerList());
- if (!ownerList)
- return true;
-
- // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
- // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal.
- bool livesInOtherList = ownerList.get() != this;
- size_t indexToRemove = ownerList->findItem(item);
- ASSERT(indexToRemove != WTF::kNotFound);
-
- // Do not remove newItem if already in this list at the target index.
- if (!livesInOtherList && indexToModify && indexToRemove == *indexToModify)
- return false;
-
- ownerList->removeItem(indexToRemove, ASSERT_NO_EXCEPTION);
-
- if (!indexToModify)
- return true;
-
- // If the item lived in our list, adjust the insertion index.
- if (!livesInOtherList) {
- size_t& index = *indexToModify;
- // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item.
- if (static_cast<size_t>(indexToRemove) < index)
- --index;
- }
-
- return true;
-}
-
-template<typename Derived, typename ItemProperty>
size_t SVGListPropertyHelper<Derived, ItemProperty>::findItem(PassRefPtrWillBeRawPtr<ItemPropertyType> item)
{
return m_values.find(item);
« no previous file with comments | « Source/core/svg/SVGPathSegMovetoRel.h ('k') | Source/core/svg/properties/SVGListPropertyTearOffHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698