WebKit Bugzilla
Attachment 356358 Details for
Bug 191237
: Remove SVG properties tear-off objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
3-SVGList
3-SVGList.patch (text/plain), 75.45 KB, created by
Said Abou-Hallawa
on 2018-12-02 23:31:36 PST
(
hide
)
Description:
3-SVGList
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-12-02 23:31:36 PST
Size:
75.45 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 129018fbd61..4743626c757 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,84 @@ >+2018-12-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ Remove SVG properties tear-off objects >+ https://bugs.webkit.org/show_bug.cgi?id=191237 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The items in the SVGList will be RefCounted of the SVG type directly. >+ When returning an item in the list to JavaScript the item itself will be >+ returned. There is no need to create a tear-off wrapper encapsulating a >+ pointer/reference to the item in the list. >+ >+ -- SVGList is the base class, it provides the basic DOM interface but it >+ does not know what kind of item to store. >+ >+ -- SVGPropertyList holds RefCounted items. It is the base class of >+ SVGValuePropertyList and SVGPathSegList (not included in this patch). >+ >+ -- SVGValuePropertyList holds SVG type items, e.g. SVGNumber and SVGPoint. >+ >+ This patch eliminates the need to the ListValues classes because the items >+ are stored directly in the SVGList. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * svg/SVGLengthList.h: >+ (WebCore::SVGLengthList::create): >+ (WebCore::SVGLengthList::lengthMode const): >+ (WebCore::SVGLengthList::parse): >+ (WebCore::SVGLengthList::SVGLengthList): >+ * svg/SVGLengthListValues.cpp: Removed. >+ * svg/SVGLengthListValues.h: Removed. >+ * svg/SVGNumberList.h: >+ (WebCore::SVGNumberList::create): >+ (WebCore::SVGNumberList::parse): >+ (WebCore::SVGNumberList::SVGNumberList): Deleted. >+ * svg/SVGNumberListValues.cpp: Removed. >+ * svg/SVGNumberListValues.h: Removed. >+ * svg/SVGParserUtilities.cpp: >+ (WebCore::pointsListFromSVGData): Deleted. >+ * svg/SVGPointList.h: >+ (WebCore::SVGPointList::create): >+ (WebCore::SVGPointList::parse): >+ (WebCore::SVGPointList::SVGPointList): Deleted. >+ * svg/SVGPointListValues.cpp: Removed. >+ * svg/SVGPointListValues.h: Removed. >+ * svg/SVGStringList.h: >+ * svg/SVGStringListValues.cpp: Removed. >+ * svg/SVGStringListValues.h: Removed. >+ * svg/SVGTransformList.h: >+ * svg/SVGTransformList.idl: >+ * svg/SVGTransformListValues.cpp: Removed. >+ * svg/SVGTransformListValues.h: Removed. >+ * svg/properties/SVGList.h: Added. >+ (WebCore::SVGList::numberOfItems const): >+ (WebCore::SVGList::clear): >+ (WebCore::SVGList::getItem): >+ (WebCore::SVGList::initialize): >+ (WebCore::SVGList::insertItemBefore): >+ (WebCore::SVGList::replaceItem): >+ (WebCore::SVGList::removeItem): >+ (WebCore::SVGList::appendItem): >+ (WebCore::SVGList::items): >+ (WebCore::SVGList::items const): >+ (WebCore::SVGList::size const): >+ (WebCore::SVGList::isEmpty const): >+ (WebCore::SVGList::clearItems): >+ (WebCore::SVGList::canAlterList const): >+ (WebCore::SVGList::canGetItem): >+ (WebCore::SVGList::canReplaceItem): >+ (WebCore::SVGList::canRemoveItem): >+ (WebCore::SVGList::detachItems): >+ * svg/properties/SVGPrimitiveList.h: Added. >+ * svg/properties/SVGPropertyList.h: Added. >+ (WebCore::SVGPropertyList::SVGPropertyList): >+ (WebCore::SVGPropertyList::~SVGPropertyList): >+ * svg/properties/SVGValuePropertyList.h: Added. >+ (WebCore::SVGValuePropertyList::operator=): >+ (WebCore::SVGValuePropertyList::operator Vector<typename PropertyType::ValueType> const): >+ (WebCore::SVGValuePropertyList::resize): >+ (WebCore::SVGValuePropertyList::SVGValuePropertyList): >+ > 2018-12-02 Said Abou-Hallawa <sabouhallawa@apple.com> > > Remove SVG properties tear-off objects >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index e484f51df7f..d51bdf89819 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2197,8 +2197,6 @@ > 7C30D9861F815AEC00268356 /* JSAbortSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C30D9811F815AC100268356 /* JSAbortSignal.h */; }; > 7C330A021DF8FAC600D3395C /* GraphicsContext3DAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C330A011DF8FAC600D3395C /* GraphicsContext3DAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7C330A081DF9F95100D3395C /* JSPositionOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C330A061DF9F95100D3395C /* JSPositionOptions.h */; }; >- 7C39C3651DDA865200FEFB29 /* SVGLengthListValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C39C3631DDA864900FEFB29 /* SVGLengthListValues.h */; }; >- 7C39C3771DDBE17000FEFB29 /* SVGStringListValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C39C3671DDB82CF00FEFB29 /* SVGStringListValues.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7C3B79711908757B00B47A2D /* UserMessageHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */; }; > 7C3B79721908757B00B47A2D /* UserMessageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3B79701908757B00B47A2D /* UserMessageHandler.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -9323,6 +9321,10 @@ > 72227A6E21B4B302008EC3E4 /* SVGTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformValue.h; sourceTree = "<group>"; }; > 72227A6F21B4C5FE008EC3E4 /* SVGPathSegImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegImpl.h; sourceTree = "<group>"; }; > 72227A7021B4C5FF008EC3E4 /* SVGPathSegValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegValue.h; sourceTree = "<group>"; }; >+ 72227A7121B50900008EC3E4 /* SVGValuePropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValuePropertyList.h; sourceTree = "<group>"; }; >+ 72227A7221B50901008EC3E4 /* SVGPropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyList.h; sourceTree = "<group>"; }; >+ 72227A7321B50901008EC3E4 /* SVGPrimitiveList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPrimitiveList.h; sourceTree = "<group>"; }; >+ 72227A7421B50901008EC3E4 /* SVGList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGList.h; sourceTree = "<group>"; }; > 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTBlendMinMax.cpp; sourceTree = "<group>"; }; > 724ED32A1A3A7E5400F5F13C /* EXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTBlendMinMax.h; sourceTree = "<group>"; }; > 724ED32B1A3A7E5400F5F13C /* EXTBlendMinMax.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTBlendMinMax.idl; sourceTree = "<group>"; }; >@@ -9539,16 +9541,6 @@ > 7C330A051DF9F95100D3395C /* JSPositionOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPositionOptions.cpp; sourceTree = "<group>"; }; > 7C330A061DF9F95100D3395C /* JSPositionOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionOptions.h; sourceTree = "<group>"; }; > 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragmentCustom.cpp; sourceTree = "<group>"; }; >- 7C39C3621DDA864900FEFB29 /* SVGLengthListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthListValues.cpp; sourceTree = "<group>"; }; >- 7C39C3631DDA864900FEFB29 /* SVGLengthListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthListValues.h; sourceTree = "<group>"; }; >- 7C39C3661DDB82CF00FEFB29 /* SVGStringListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGStringListValues.cpp; sourceTree = "<group>"; }; >- 7C39C3671DDB82CF00FEFB29 /* SVGStringListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGStringListValues.h; sourceTree = "<group>"; }; >- 7C39C3681DDB86D300FEFB29 /* SVGNumberListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGNumberListValues.cpp; sourceTree = "<group>"; }; >- 7C39C3691DDB86D300FEFB29 /* SVGNumberListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGNumberListValues.h; sourceTree = "<group>"; }; >- 7C39C36A1DDB871C00FEFB29 /* SVGPointListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPointListValues.cpp; sourceTree = "<group>"; }; >- 7C39C36B1DDB871C00FEFB29 /* SVGPointListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPointListValues.h; sourceTree = "<group>"; }; >- 7C39C36C1DDB8BB000FEFB29 /* SVGTransformListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransformListValues.cpp; sourceTree = "<group>"; }; >- 7C39C36D1DDB8BB000FEFB29 /* SVGTransformListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformListValues.h; sourceTree = "<group>"; }; > 7C39C36E1DDBA3E000FEFB29 /* SVGPathSegListValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathSegListValues.cpp; sourceTree = "<group>"; }; > 7C39C36F1DDBA3E000FEFB29 /* SVGPathSegListValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegListValues.h; sourceTree = "<group>"; }; > 7C39C3701DDBA44000FEFB29 /* SVGPathSegList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathSegList.cpp; sourceTree = "<group>"; }; >@@ -15780,16 +15772,20 @@ > 55346AF021150FAF0059BCDD /* SVGAttributeOwnerProxy.h */, > 55346AFA2117FFAF0059BCDD /* SVGAttributeOwnerProxyImpl.h */, > 55FA7FF6210FBE3E005AEFE7 /* SVGAttributeRegistry.h */, >+ 72227A7421B50901008EC3E4 /* SVGList.h */, > 0810764312828556007C63BA /* SVGListProperty.h */, > 088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */, > 08CA3D4312894A3800FFF260 /* SVGMatrixTearOff.h */, >+ 72227A7321B50901008EC3E4 /* SVGPrimitiveList.h */, > 088A0E01126EF1DB00978F7A /* SVGProperty.h */, >+ 72227A7221B50901008EC3E4 /* SVGPropertyList.h */, > 72227A6C21B4B1F6008EC3E4 /* SVGPropertyOwner.h */, > 088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */, > 088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */, > 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */, > 0813A4E91284132600992511 /* SVGStaticPropertyTearOff.h */, > 72227A6D21B4B1F7008EC3E4 /* SVGValueProperty.h */, >+ 72227A7121B50900008EC3E4 /* SVGValuePropertyList.h */, > ); > path = properties; > sourceTree = "<group>"; >@@ -23659,8 +23655,6 @@ > 7134496C146941B300720312 /* SVGLengthContext.h */, > B22278A00D00BF200071B782 /* SVGLengthList.h */, > B22278A10D00BF200071B782 /* SVGLengthList.idl */, >- 7C39C3621DDA864900FEFB29 /* SVGLengthListValues.cpp */, >- 7C39C3631DDA864900FEFB29 /* SVGLengthListValues.h */, > 7CE58D521DD7B09300128552 /* SVGLengthValue.cpp */, > 7CE58D531DD7B09300128552 /* SVGLengthValue.h */, > B22278A20D00BF200071B782 /* SVGLinearGradientElement.cpp */, >@@ -23693,8 +23687,6 @@ > B22278B90D00BF200071B782 /* SVGNumber.idl */, > B22278BB0D00BF200071B782 /* SVGNumberList.h */, > B22278BC0D00BF200071B782 /* SVGNumberList.idl */, >- 7C39C3681DDB86D300FEFB29 /* SVGNumberListValues.cpp */, >- 7C39C3691DDB86D300FEFB29 /* SVGNumberListValues.h */, > B22278C00D00BF200071B782 /* SVGParserUtilities.cpp */, > B22278C10D00BF200071B782 /* SVGParserUtilities.h */, > 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */, >@@ -23763,8 +23755,6 @@ > B22278F40D00BF210071B782 /* SVGPoint.idl */, > B22278F60D00BF210071B782 /* SVGPointList.h */, > B22278F70D00BF210071B782 /* SVGPointList.idl */, >- 7C39C36A1DDB871C00FEFB29 /* SVGPointListValues.cpp */, >- 7C39C36B1DDB871C00FEFB29 /* SVGPointListValues.h */, > B22278F80D00BF210071B782 /* SVGPolyElement.cpp */, > B22278F90D00BF210071B782 /* SVGPolyElement.h */, > B22278FA0D00BF210071B782 /* SVGPolygonElement.cpp */, >@@ -23798,8 +23788,6 @@ > B22279140D00BF210071B782 /* SVGStopElement.idl */, > B22279160D00BF210071B782 /* SVGStringList.h */, > B22279170D00BF210071B782 /* SVGStringList.idl */, >- 7C39C3661DDB82CF00FEFB29 /* SVGStringListValues.cpp */, >- 7C39C3671DDB82CF00FEFB29 /* SVGStringListValues.h */, > B22279210D00BF210071B782 /* SVGStyleElement.cpp */, > B22279220D00BF210071B782 /* SVGStyleElement.h */, > B22279230D00BF210071B782 /* SVGStyleElement.idl */, >@@ -23841,8 +23829,6 @@ > B22279470D00BF210071B782 /* SVGTransformDistance.h */, > B22279490D00BF210071B782 /* SVGTransformList.h */, > B222794A0D00BF210071B782 /* SVGTransformList.idl */, >- 7C39C36C1DDB8BB000FEFB29 /* SVGTransformListValues.cpp */, >- 7C39C36D1DDB8BB000FEFB29 /* SVGTransformListValues.h */, > 72227A6E21B4B302008EC3E4 /* SVGTransformValue.h */, > B222794B0D00BF210071B782 /* SVGTRefElement.cpp */, > B222794C0D00BF210071B782 /* SVGTRefElement.h */, >@@ -31143,7 +31129,6 @@ > B2227A300D00BF220071B782 /* SVGLangSpace.h in Headers */, > 7134496E146941B300720312 /* SVGLengthContext.h in Headers */, > B2227A360D00BF220071B782 /* SVGLengthList.h in Headers */, >- 7C39C3651DDA865200FEFB29 /* SVGLengthListValues.h in Headers */, > 7CCEBFC01DD8F6AB002C40B8 /* SVGLengthValue.h in Headers */, > B2227A390D00BF220071B782 /* SVGLinearGradientElement.h in Headers */, > B2227A3C0D00BF220071B782 /* SVGLineElement.h in Headers */, >@@ -31212,7 +31197,6 @@ > 0813A4EA1284132600992511 /* SVGStaticPropertyTearOff.h in Headers */, > B2227AA90D00BF220071B782 /* SVGStopElement.h in Headers */, > B2227AAC0D00BF220071B782 /* SVGStringList.h in Headers */, >- 7C39C3771DDBE17000FEFB29 /* SVGStringListValues.h in Headers */, > B2227AB80D00BF220071B782 /* SVGStyleElement.h in Headers */, > B2227ABB0D00BF220071B782 /* SVGSVGElement.h in Headers */, > B2227ABE0D00BF220071B782 /* SVGSwitchElement.h in Headers */, >diff --git a/Source/WebCore/svg/SVGLengthList.h b/Source/WebCore/svg/SVGLengthList.h >index 9abaa4ffe83..f2a1d068c4d 100644 >--- a/Source/WebCore/svg/SVGLengthList.h >+++ b/Source/WebCore/svg/SVGLengthList.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -25,27 +25,92 @@ > > #pragma once > >-#include "SVGAnimatedListPropertyTearOff.h" >-#include "SVGLengthListValues.h" >-#include "SVGListPropertyTearOff.h" >+#include "SVGLength.h" >+#include "SVGValuePropertyList.h" > > namespace WebCore { > >-class SVGLengthList : public SVGListPropertyTearOff<SVGLengthListValues> { >+class SVGLengthList : public SVGValuePropertyList<SVGLength> { >+ using Base = SVGValuePropertyList<SVGLength>; >+ using Base::Base; >+ > public: >- using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGLengthListValues>; >- using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; >+ static Ref<SVGLengthList> create(SVGLengthMode lengthMode = LengthModeOther) >+ { >+ return adoptRef(*new SVGLengthList(lengthMode)); >+ } >+ >+ static Ref<SVGLengthList> create(SVGPropertyOwner* owner, SVGPropertyAccess access, SVGLengthMode lengthMode) >+ { >+ return adoptRef(*new SVGLengthList(owner, access, lengthMode)); >+ } > >- static Ref<SVGLengthList> create(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGLengthListValues& values, ListWrapperCache& wrappers) >+ static Ref<SVGLengthList> create(const SVGLengthList& other, SVGPropertyAccess access) > { >- return adoptRef(*new SVGLengthList(animatedProperty, role, values, wrappers)); >+ return adoptRef(*new SVGLengthList(other, access)); >+ } >+ >+ SVGLengthMode lengthMode() const { return m_lengthMode; } >+ >+ bool parse(const String& value) >+ { >+ clearItems(); >+ >+ auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >+ const UChar* ptr = upconvertedCharacters; >+ const UChar* end = ptr + value.length(); >+ while (ptr < end) { >+ const UChar* start = ptr; >+ while (ptr < end && *ptr != ',' && !isSVGSpace(*ptr)) >+ ptr++; >+ if (ptr == start) >+ break; >+ >+ String valueString(start, ptr - start); >+ SVGLengthValue value(m_lengthMode); >+ if (value.setValueAsString(valueString).hasException()) >+ break; >+ >+ append(SVGLength::create(value)); >+ skipOptionalSVGSpacesOrDelimiter(ptr, end); >+ } >+ >+ return ptr == end; >+ } >+ >+ String valueAsString() const override >+ { >+ StringBuilder builder; >+ >+ for (const auto& length : m_items) { >+ if (builder.length()) >+ builder.append(' '); >+ >+ builder.append(length->value().valueAsString()); >+ } >+ >+ return builder.toString(); > } > > private: >- SVGLengthList(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGLengthListValues& values, ListWrapperCache& wrappers) >- : SVGListPropertyTearOff<SVGLengthListValues>(animatedProperty, role, values, wrappers) >+ SVGLengthList(SVGLengthMode lengthMode) >+ : m_lengthMode(lengthMode) > { > } >+ >+ SVGLengthList(SVGPropertyOwner* owner, SVGPropertyAccess access, SVGLengthMode lengthMode) >+ : Base(owner, access) >+ , m_lengthMode(lengthMode) >+ { >+ } >+ >+ SVGLengthList(const SVGLengthList& other, SVGPropertyAccess access) >+ : Base(other, access) >+ , m_lengthMode(other.lengthMode()) >+ { >+ } >+ >+ SVGLengthMode m_lengthMode { LengthModeOther }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGLengthListValues.cpp b/Source/WebCore/svg/SVGLengthListValues.cpp >deleted file mode 100644 >index ba2064823a2..00000000000 >--- a/Source/WebCore/svg/SVGLengthListValues.cpp >+++ /dev/null >@@ -1,69 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "SVGLengthListValues.h" >- >-#include "SVGParserUtilities.h" >-#include <wtf/text/StringBuilder.h> >- >-namespace WebCore { >- >-void SVGLengthListValues::parse(const String& value, SVGLengthMode mode) >-{ >- clear(); >- >- auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >- const UChar* ptr = upconvertedCharacters; >- const UChar* end = ptr + value.length(); >- while (ptr < end) { >- const UChar* start = ptr; >- while (ptr < end && *ptr != ',' && !isSVGSpace(*ptr)) >- ptr++; >- if (ptr == start) >- break; >- >- SVGLengthValue length(mode); >- String valueString(start, ptr - start); >- if (valueString.isEmpty()) >- return; >- if (length.setValueAsString(valueString).hasException()) >- return; >- append(length); >- skipOptionalSVGSpacesOrDelimiter(ptr, end); >- } >-} >- >-String SVGLengthListValues::valueAsString() const >-{ >- StringBuilder builder; >- >- unsigned size = this->size(); >- for (unsigned i = 0; i < size; ++i) { >- if (i > 0) >- builder.append(' '); >- >- builder.append(at(i).valueAsString()); >- } >- >- return builder.toString(); >-} >- >-} >diff --git a/Source/WebCore/svg/SVGLengthListValues.h b/Source/WebCore/svg/SVGLengthListValues.h >deleted file mode 100644 >index b0728606443..00000000000 >--- a/Source/WebCore/svg/SVGLengthListValues.h >+++ /dev/null >@@ -1,59 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#pragma once >- >-#include "SVGLengthValue.h" >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-class SVGLength; >-class SVGLengthList; >- >-class SVGLengthListValues final : public Vector<SVGLengthValue> { >-public: >- void parse(const String& value, SVGLengthMode); >- String valueAsString() const; >-}; >- >-template<> >-struct SVGPropertyTraits<SVGLengthListValues> { >- static SVGLengthListValues initialValue() { return { }; } >- static SVGLengthListValues fromString(const String& string, SVGLengthMode lengthMode) >- { >- SVGLengthListValues list; >- list.parse(string, lengthMode); >- return list; >- } >- static std::optional<SVGLengthListValues> parse(const QualifiedName& attrName, const String& string) >- { >- SVGLengthListValues list; >- list.parse(string, SVGLengthValue::lengthModeForAnimatedLengthAttribute(attrName)); >- return list; >- } >- static String toString(const SVGLengthListValues& type) { return type.valueAsString(); } >- >- using ListItemType = SVGLengthValue; >- using ListItemTearOff = SVGLength; >- using ListPropertyTearOff = SVGLengthList; >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGNumberList.h b/Source/WebCore/svg/SVGNumberList.h >index 1e5cf8b5a0b..239602ca374 100644 >--- a/Source/WebCore/svg/SVGNumberList.h >+++ b/Source/WebCore/svg/SVGNumberList.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -25,26 +25,63 @@ > > #pragma once > >-#include "SVGAnimatedListPropertyTearOff.h" >-#include "SVGListPropertyTearOff.h" >-#include "SVGNumberListValues.h" >+#include "SVGNumber.h" >+#include "SVGValuePropertyList.h" > > namespace WebCore { > >-class SVGNumberList : public SVGListPropertyTearOff<SVGNumberListValues> { >+class SVGNumberList : public SVGValuePropertyList<SVGNumber> { >+ using Base = SVGValuePropertyList<SVGNumber>; >+ using Base::Base; >+ > public: >- using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGNumberListValues>; >- using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; >+ static Ref<SVGNumberList> create() >+ { >+ return adoptRef(*new SVGNumberList()); >+ } >+ >+ static Ref<SVGNumberList> create(SVGPropertyOwner* owner, SVGPropertyAccess access) >+ { >+ return adoptRef(*new SVGNumberList(owner, access)); >+ } > >- static Ref<SVGNumberList> create(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGNumberListValues& values, ListWrapperCache& wrappers) >+ static Ref<SVGNumberList> create(const SVGNumberList& other, SVGPropertyAccess access) >+ { >+ return adoptRef(*new SVGNumberList(other, access)); >+ } >+ >+ bool parse(const String& value) > { >- return adoptRef(*new SVGNumberList(animatedProperty, role, values, wrappers)); >+ clearItems(); >+ >+ float number = 0; >+ auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >+ const UChar* ptr = upconvertedCharacters; >+ const UChar* end = ptr + value.length(); >+ >+ // The spec (section 4.1) strangely doesn't allow leading whitespace. >+ // We might choose to violate that intentionally. >+ while (ptr < end) { >+ if (!parseNumber(ptr, end, number)) >+ break; >+ append(SVGNumber::create(number)); >+ } >+ >+ return ptr == end; > } > >-private: >- SVGNumberList(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGNumberListValues& values, ListWrapperCache& wrappers) >- : SVGListPropertyTearOff<SVGNumberListValues>(animatedProperty, role, values, wrappers) >+ String valueAsString() const override > { >+ StringBuilder builder; >+ >+ for (const auto& number : m_items) { >+ if (builder.length()) >+ builder.append(' '); >+ >+ builder.appendNumber(number->value()); >+ } >+ >+ return builder.toString(); > } > }; > >diff --git a/Source/WebCore/svg/SVGNumberListValues.cpp b/Source/WebCore/svg/SVGNumberListValues.cpp >deleted file mode 100644 >index 6dfd993b2b4..00000000000 >--- a/Source/WebCore/svg/SVGNumberListValues.cpp >+++ /dev/null >@@ -1,61 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "SVGNumberListValues.h" >- >-#include "SVGParserUtilities.h" >-#include <wtf/text/StringBuilder.h> >- >-namespace WebCore { >- >-void SVGNumberListValues::parse(const String& value) >-{ >- clear(); >- >- float number = 0; >- auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >- const UChar* ptr = upconvertedCharacters; >- const UChar* end = ptr + value.length(); >- >- // The spec (section 4.1) strangely doesn't allow leading whitespace. We might choose to violate that intentionally. >- while (ptr < end) { >- if (!parseNumber(ptr, end, number)) >- return; >- append(number); >- } >-} >- >-String SVGNumberListValues::valueAsString() const >-{ >- StringBuilder builder; >- >- unsigned size = this->size(); >- for (unsigned i = 0; i < size; ++i) { >- if (i > 0) >- builder.append(' '); >- >- builder.appendNumber(at(i)); >- } >- >- return builder.toString(); >-} >- >-} >diff --git a/Source/WebCore/svg/SVGNumberListValues.h b/Source/WebCore/svg/SVGNumberListValues.h >deleted file mode 100644 >index 30c2db3f988..00000000000 >--- a/Source/WebCore/svg/SVGNumberListValues.h >+++ /dev/null >@@ -1,53 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#pragma once >- >-#include "SVGPropertyTraits.h" >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-class SVGNumber; >-class SVGNumberList; >- >-class SVGNumberListValues final : public Vector<float> { >-public: >- void parse(const String&); >- String valueAsString() const; >-}; >- >-template<> struct SVGPropertyTraits<SVGNumberListValues> { >- static SVGNumberListValues initialValue() { return { }; } >- static SVGNumberListValues fromString(const String& string) >- { >- SVGNumberListValues list; >- list.parse(string); >- return list; >- } >- static std::optional<SVGNumberListValues> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(const SVGNumberListValues& list) { return list.valueAsString(); } >- >- using ListItemType = float; >- using ListItemTearOff = SVGNumber; >- using ListPropertyTearOff = SVGNumberList; >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGParserUtilities.cpp b/Source/WebCore/svg/SVGParserUtilities.cpp >index 14069ece903..98243fdc182 100644 >--- a/Source/WebCore/svg/SVGParserUtilities.cpp >+++ b/Source/WebCore/svg/SVGParserUtilities.cpp >@@ -25,7 +25,6 @@ > > #include "Document.h" > #include "FloatRect.h" >-#include "SVGPointListValues.h" > #include <limits> > #include <wtf/ASCIICType.h> > #include <wtf/text/StringView.h> >@@ -260,40 +259,6 @@ bool parseRect(const String& string, FloatRect& rect) > return valid; > } > >-bool pointsListFromSVGData(SVGPointListValues& pointsList, const String& points) >-{ >- if (points.isEmpty()) >- return true; >- auto upconvertedCharacters = StringView(points).upconvertedCharacters(); >- const UChar* cur = upconvertedCharacters; >- const UChar* end = cur + points.length(); >- >- skipOptionalSVGSpaces(cur, end); >- >- bool delimParsed = false; >- while (cur < end) { >- delimParsed = false; >- float xPos = 0.0f; >- if (!parseNumber(cur, end, xPos)) >- return false; >- >- float yPos = 0.0f; >- if (!parseNumber(cur, end, yPos, false)) >- return false; >- >- skipOptionalSVGSpaces(cur, end); >- >- if (cur < end && *cur == ',') { >- delimParsed = true; >- cur++; >- } >- skipOptionalSVGSpaces(cur, end); >- >- pointsList.append(FloatPoint(xPos, yPos)); >- } >- return cur == end && !delimParsed; >-} >- > bool parseGlyphName(const String& input, HashSet<String>& values) > { > // FIXME: Parsing error detection is missing. >diff --git a/Source/WebCore/svg/SVGPointList.h b/Source/WebCore/svg/SVGPointList.h >index b0c2a10311e..248476e2ac3 100644 >--- a/Source/WebCore/svg/SVGPointList.h >+++ b/Source/WebCore/svg/SVGPointList.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -25,27 +25,80 @@ > > #pragma once > >-#include "SVGAnimatedListPropertyTearOff.h" >-#include "SVGListPropertyTearOff.h" > #include "SVGPoint.h" >-#include "SVGPointListValues.h" >+#include "SVGValuePropertyList.h" > > namespace WebCore { > >-class SVGPointList : public SVGListPropertyTearOff<SVGPointListValues> { >+class SVGPointList : public SVGValuePropertyList<SVGPoint> { >+ using Base = SVGValuePropertyList<SVGPoint>; >+ using Base::Base; >+ > public: >- using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGPointListValues>; >- using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; >+ static Ref<SVGPointList> create() >+ { >+ return adoptRef(*new SVGPointList()); >+ } > >- static Ref<SVGPointList> create(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGPointListValues& values, ListWrapperCache& wrappers) >+ static Ref<SVGPointList> create(SVGPropertyOwner* owner, SVGPropertyAccess access) > { >- return adoptRef(*new SVGPointList(animatedProperty, role, values, wrappers)); >+ return adoptRef(*new SVGPointList(owner, access)); > } > >-private: >- SVGPointList(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGPointListValues& values, ListWrapperCache& wrappers) >- : SVGListPropertyTearOff<SVGPointListValues>(animatedProperty, role, values, wrappers) >+ static Ref<SVGPointList> create(const SVGPointList& other, SVGPropertyAccess access) > { >+ return adoptRef(*new SVGPointList(other, access)); >+ } >+ >+ bool parse(const String& value) >+ { >+ clearItems(); >+ >+ auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >+ const UChar* cur = upconvertedCharacters; >+ const UChar* end = cur + value.length(); >+ >+ skipOptionalSVGSpaces(cur, end); >+ >+ bool delimParsed = false; >+ while (cur < end) { >+ delimParsed = false; >+ float xPos = 0.0f; >+ if (!parseNumber(cur, end, xPos)) >+ return false; >+ >+ float yPos = 0.0f; >+ if (!parseNumber(cur, end, yPos, false)) >+ return false; >+ >+ skipOptionalSVGSpaces(cur, end); >+ >+ if (cur < end && *cur == ',') { >+ delimParsed = true; >+ cur++; >+ } >+ skipOptionalSVGSpaces(cur, end); >+ >+ append(SVGPoint::create(FloatPoint(xPos, yPos))); >+ } >+ >+ return !delimParsed; >+ } >+ >+ String valueAsString() const override >+ { >+ StringBuilder builder; >+ >+ for (const auto& point : m_items) { >+ if (builder.length()) >+ builder.append(' '); >+ >+ builder.appendNumber(point->x()); >+ builder.append(' '); >+ builder.appendNumber(point->y()); >+ } >+ >+ return builder.toString(); > } > }; > >diff --git a/Source/WebCore/svg/SVGPointListValues.cpp b/Source/WebCore/svg/SVGPointListValues.cpp >deleted file mode 100644 >index d81e6a2376e..00000000000 >--- a/Source/WebCore/svg/SVGPointListValues.cpp >+++ /dev/null >@@ -1,47 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "SVGPointListValues.h" >- >-#include <wtf/text/StringBuilder.h> >-#include <wtf/text/WTFString.h> >- >-namespace WebCore { >- >-String SVGPointListValues::valueAsString() const >-{ >- StringBuilder builder; >- >- unsigned size = this->size(); >- for (unsigned i = 0; i < size; ++i) { >- if (i > 0) >- builder.append(' '); // FIXME: Shouldn't we use commas to seperate? >- >- const auto& point = at(i); >- builder.appendNumber(point.x()); >- builder.append(' '); >- builder.appendNumber(point.y()); >- } >- >- return builder.toString(); >-} >- >-} >diff --git a/Source/WebCore/svg/SVGPointListValues.h b/Source/WebCore/svg/SVGPointListValues.h >deleted file mode 100644 >index 362fdcc5d7d..00000000000 >--- a/Source/WebCore/svg/SVGPointListValues.h >+++ /dev/null >@@ -1,55 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#pragma once >- >-#include "FloatPoint.h" >-#include "SVGPropertyTraits.h" >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-class SVGPoint; >-class SVGPointList; >- >-class SVGPointListValues final : public Vector<FloatPoint> { >-public: >- String valueAsString() const; >-}; >- >-template<> >-struct SVGPropertyTraits<SVGPointListValues> { >- static SVGPointListValues initialValue() { return { }; } >- static SVGPointListValues fromString(const String& string) >- { >- SVGPointListValues list; >- pointsListFromSVGData(list, string); >- return list; >- } >- static std::optional<SVGPointListValues> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return { }; } >- static String toString(const SVGPointListValues& list) { return list.valueAsString(); } >- >- using ListItemType = FloatPoint; >- using ListItemTearOff = SVGPoint; >- using ListPropertyTearOff = SVGPointList; >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGStringList.h b/Source/WebCore/svg/SVGStringList.h >index 7fe7f00fc52..999ac695973 100644 >--- a/Source/WebCore/svg/SVGStringList.h >+++ b/Source/WebCore/svg/SVGStringList.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -25,33 +25,62 @@ > > #pragma once > >-#include "SVGAnimatedListPropertyTearOff.h" >-#include "SVGListPropertyTearOff.h" >-#include "SVGStringListValues.h" >+#include "SVGPrimitiveList.h" > > namespace WebCore { > >-class SVGStringList final : public SVGStaticListPropertyTearOff<SVGStringListValues> { >+class SVGStringList final : public SVGPrimitiveList<String> { >+ using Base = SVGPrimitiveList<String>; >+ using Base::Base; >+ using Base::m_items; >+ > public: >- using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGStringListValues>; >- using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; >+ static Ref<SVGStringList> create(SVGPropertyOwner* owner) >+ { >+ return adoptRef(*new SVGStringList(owner)); >+ } > >- static Ref<SVGStringList> create(SVGElement& contextElement, SVGStringListValues& values) >+ void reset(const String& string) > { >- return adoptRef(*new SVGStringList(&contextElement, values)); >+ parse(string, ' '); >+ >+ // Add empty string, if list is empty. >+ if (m_items.isEmpty()) >+ m_items.append(emptyString()); > } > >- static Ref<SVGStringList> create(AnimatedListPropertyTearOff&, SVGPropertyRole, SVGStringListValues& values, ListWrapperCache&) >+ bool parse(const String& data, UChar delimiter) > { >- // FIXME: Find a way to remove this. It's only needed to keep Windows compiling. >- ASSERT_NOT_REACHED(); >- return adoptRef(*new SVGStringList(nullptr, values)); >+ clearItems(); >+ >+ auto upconvertedCharacters = StringView(data).upconvertedCharacters(); >+ const UChar* ptr = upconvertedCharacters; >+ const UChar* end = ptr + data.length(); >+ while (ptr < end) { >+ const UChar* start = ptr; >+ while (ptr < end && *ptr != delimiter && !isSVGSpace(*ptr)) >+ ptr++; >+ if (ptr == start) >+ break; >+ m_items.append(String(start, ptr - start)); >+ skipOptionalSVGSpacesOrDelimiter(ptr, end, delimiter); >+ } >+ >+ return ptr == end; > } > >-private: >- SVGStringList(SVGElement* contextElement, SVGStringListValues& values) >- : SVGStaticListPropertyTearOff<SVGStringListValues>(contextElement, values) >+ String valueAsString() const override > { >+ StringBuilder builder; >+ >+ for (auto string : m_items) { >+ if (builder.length()) >+ builder.append(' '); >+ >+ builder.append(string); >+ } >+ >+ return builder.toString(); > } > }; > >diff --git a/Source/WebCore/svg/SVGStringListValues.cpp b/Source/WebCore/svg/SVGStringListValues.cpp >deleted file mode 100644 >index 3ff898a912b..00000000000 >--- a/Source/WebCore/svg/SVGStringListValues.cpp >+++ /dev/null >@@ -1,79 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "SVGStringListValues.h" >- >-#include "SVGElement.h" >-#include "SVGParserUtilities.h" >-#include <wtf/text/StringBuilder.h> >- >-namespace WebCore { >- >-void SVGStringListValues::commitChange(SVGElement& contextElement) >-{ >- contextElement.invalidateSVGAttributes(); >- contextElement.svgAttributeChanged(m_attributeName); >-} >- >-void SVGStringListValues::reset(const String& string) >-{ >- parse(string, ' '); >- >- // Add empty string, if list is empty. >- if (isEmpty()) >- append(emptyString()); >-} >- >-void SVGStringListValues::parse(const String& data, UChar delimiter) >-{ >- // TODO : more error checking/reporting >- clear(); >- >- auto upconvertedCharacters = StringView(data).upconvertedCharacters(); >- const UChar* ptr = upconvertedCharacters; >- const UChar* end = ptr + data.length(); >- while (ptr < end) { >- const UChar* start = ptr; >- while (ptr < end && *ptr != delimiter && !isSVGSpace(*ptr)) >- ptr++; >- if (ptr == start) >- break; >- append(String(start, ptr - start)); >- skipOptionalSVGSpacesOrDelimiter(ptr, end, delimiter); >- } >-} >- >-String SVGStringListValues::valueAsString() const >-{ >- StringBuilder builder; >- >- unsigned size = this->size(); >- for (unsigned i = 0; i < size; ++i) { >- if (i > 0) >- builder.append(' '); >- >- builder.append(at(i)); >- } >- >- return builder.toString(); >-} >- >-} >diff --git a/Source/WebCore/svg/SVGStringListValues.h b/Source/WebCore/svg/SVGStringListValues.h >deleted file mode 100644 >index ff9a2742219..00000000000 >--- a/Source/WebCore/svg/SVGStringListValues.h >+++ /dev/null >@@ -1,71 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#pragma once >- >-#include "QualifiedName.h" >-#include "SVGAttributeAccessor.h" >-#include "SVGPropertyTraits.h" >- >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-class SVGElement; >-class SVGStringList; >-class SVGStringListValues; >- >-template<typename T> >-class SVGPropertyTearOff; >- >-using SVGStringListValuesAttribute = SVGPropertyAttribute<SVGStringListValues>; >- >-template<typename OwnerType> >-using SVGStringListValuesAttributeAccessor = SVGPropertyAttributeAccessor<OwnerType, SVGStringListValuesAttribute>; >- >-class SVGStringListValues final : public Vector<String> { >-public: >- SVGStringListValues(const QualifiedName& attributeName) >- : m_attributeName(attributeName) >- { >- } >- >- void reset(const String&); >- void parse(const String&, UChar delimiter = ','); >- >- // Only used by SVGStringList. >- void commitChange(SVGElement& contextElement); >- >- String valueAsString() const; >- >-private: >- const QualifiedName& m_attributeName; >-}; >- >-template<> struct SVGPropertyTraits<SVGStringListValues> { >- static String toString(const SVGStringListValues& list) { return list.valueAsString(); } >- >- using ListItemType = String; >- using ListItemTearOff = SVGPropertyTearOff<String>; >- using ListPropertyTearOff = SVGStringList; >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTransformList.h b/Source/WebCore/svg/SVGTransformList.h >index c872fca5276..a8fd42c0565 100644 >--- a/Source/WebCore/svg/SVGTransformList.h >+++ b/Source/WebCore/svg/SVGTransformList.h >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >+ * Copyright (C) 2018 Apple Inc. All rights reserved. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Library General Public >@@ -20,57 +21,124 @@ > > #pragma once > >-#include "SVGAnimatedListPropertyTearOff.h" >-#include "SVGListPropertyTearOff.h" >-#include "SVGTransformListValues.h" >+#include "SVGTransform.h" >+#include "SVGTransformable.h" >+#include "SVGValuePropertyList.h" > > namespace WebCore { > >-class SVGTransformList final : public SVGListPropertyTearOff<SVGTransformListValues> { >+class SVGTransformList final : public SVGValuePropertyList<SVGTransform> { >+ friend class SVGViewSpec; >+ using Base = SVGValuePropertyList<SVGTransform>; >+ using Base::Base; >+ > public: >- using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGTransformListValues>; >- using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; >+ static Ref<SVGTransformList> create() >+ { >+ return adoptRef(*new SVGTransformList()); >+ } > >- static Ref<SVGTransformList> create(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGTransformListValues& values, ListWrapperCache& wrappers) >+ static Ref<SVGTransformList> create(SVGPropertyOwner* owner, SVGPropertyAccess access) > { >- return adoptRef(*new SVGTransformList(animatedProperty, role, values, wrappers)); >+ return adoptRef(*new SVGTransformList(owner, access)); > } > >- ExceptionOr<Ref<SVGTransform>> createSVGTransformFromMatrix(SVGMatrix& matrix) >+ static Ref<SVGTransformList> create(const SVGTransformList& other, SVGPropertyAccess access) > { >- ASSERT(m_values); >- return m_values->createSVGTransformFromMatrix(matrix); >+ return adoptRef(*new SVGTransformList(other, access)); >+ } >+ >+ ExceptionOr<Ref<SVGTransform>> createSVGTransformFromMatrix(const Ref<SVGMatrix>& matrix) >+ { >+ return SVGTransform::create(matrix->value()); > } > > ExceptionOr<RefPtr<SVGTransform>> consolidate() > { >- ASSERT(m_values); >- ASSERT(m_wrappers); >- > auto result = canAlterList(); > if (result.hasException()) > return result.releaseException(); > ASSERT(result.releaseReturnValue()); > >- ASSERT(m_values->size() == m_wrappers->size()); >- > // Spec: If the list was empty, then a value of null is returned. >- if (m_values->isEmpty()) >+ if (m_items.isEmpty()) > return nullptr; > >- detachListWrappers(0); >+ if (m_items.size() == 1) >+ return makeRefPtr(at(0).get()); >+ >+ auto newItem = concatenate(); >+ clearItems(); > >- RefPtr<SVGTransform> wrapper = m_values->consolidate(); >- m_wrappers->append(makeWeakPtr(*wrapper)); >+ auto item = append(WTFMove(newItem)); >+ commitChange(); >+ return makeRefPtr(item.get()); >+ } >+ >+ void parse(const String& value) >+ { >+ clearItems(); >+ >+ auto upconvertedCharacters = StringView(value).upconvertedCharacters(); >+ const UChar* start = upconvertedCharacters; >+ if (!parse(start, start + value.length())) >+ clearItems(); >+ } > >- ASSERT(m_values->size() == m_wrappers->size()); >- return WTFMove(wrapper); >+ bool concatenate(AffineTransform &result) const >+ { >+ if (m_items.isEmpty()) >+ return false; >+ for (const auto& transform : m_items) >+ result *= transform->matrix()->value(); >+ return true; >+ } >+ >+ String valueAsString() const override >+ { >+ StringBuilder builder; >+ for (const auto& transfrom : m_items) { >+ if (builder.length()) >+ builder.append(' '); >+ >+ builder.append(transfrom->value().valueAsString()); >+ } >+ return builder.toString(); > } > > private: >- SVGTransformList(AnimatedListPropertyTearOff& animatedProperty, SVGPropertyRole role, SVGTransformListValues& values, ListWrapperCache& wrappers) >- : SVGListPropertyTearOff<SVGTransformListValues>(animatedProperty, role, values, wrappers) >+ bool parse(const UChar*& start, const UChar* end) >+ { >+ bool delimParsed = false; >+ while (start < end) { >+ delimParsed = false; >+ SVGTransformValue::SVGTransformType type = SVGTransformValue::SVG_TRANSFORM_UNKNOWN; >+ skipOptionalSVGSpaces(start, end); >+ >+ if (!SVGTransformable::parseAndSkipType(start, end, type)) >+ return false; >+ >+ Ref<SVGTransform> transform = SVGTransform::create(type); >+ if (!SVGTransformable::parseTransformValue(type, start, end, transform->value())) >+ return false; >+ >+ append(WTFMove(transform)); >+ skipOptionalSVGSpaces(start, end); >+ if (start < end && *start == ',') { >+ delimParsed = true; >+ ++start; >+ } >+ >+ skipOptionalSVGSpaces(start, end); >+ } >+ return !delimParsed; >+ } >+ >+ Ref<SVGTransform> concatenate() const > { >+ AffineTransform result; >+ concatenate(result); >+ return SVGTransform::create(result); > } > }; > >diff --git a/Source/WebCore/svg/SVGTransformList.idl b/Source/WebCore/svg/SVGTransformList.idl >index 3e81d62a35a..25630528de9 100644 >--- a/Source/WebCore/svg/SVGTransformList.idl >+++ b/Source/WebCore/svg/SVGTransformList.idl >@@ -36,5 +36,5 @@ interface SVGTransformList { > [MayThrowException] SVGTransform appendItem(SVGTransform item); > > [MayThrowException, NewObject] SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix); >- [MayThrowException, NewObject] SVGTransform consolidate(); >+ [MayThrowException] SVGTransform consolidate(); > }; >diff --git a/Source/WebCore/svg/SVGTransformListValues.cpp b/Source/WebCore/svg/SVGTransformListValues.cpp >deleted file mode 100644 >index 25b3c316f2e..00000000000 >--- a/Source/WebCore/svg/SVGTransformListValues.cpp >+++ /dev/null >@@ -1,82 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "SVGTransformListValues.h" >- >-#include "AffineTransform.h" >-#include "SVGSVGElement.h" >-#include "SVGTransformable.h" >-#include <wtf/text/StringBuilder.h> >- >-namespace WebCore { >- >-Ref<SVGTransform> SVGTransformListValues::createSVGTransformFromMatrix(SVGMatrix& matrix) const >-{ >- return SVGSVGElement::createSVGTransformFromMatrix(matrix); >-} >- >-Ref<SVGTransform> SVGTransformListValues::consolidate() >-{ >- AffineTransform matrix; >- if (!concatenate(matrix)) >- return SVGTransform::create(); >- >- SVGTransformValue transform(matrix); >- clear(); >- append(transform); >- return SVGTransform::create(transform); >-} >- >-bool SVGTransformListValues::concatenate(AffineTransform& result) const >-{ >- unsigned size = this->size(); >- if (!size) >- return false; >- >- for (unsigned i = 0; i < size; ++i) >- result *= at(i).matrix(); >- >- return true; >-} >- >-String SVGTransformListValues::valueAsString() const >-{ >- StringBuilder builder; >- unsigned size = this->size(); >- for (unsigned i = 0; i < size; ++i) { >- if (i > 0) >- builder.append(' '); >- >- builder.append(at(i).valueAsString()); >- } >- >- return builder.toString(); >-} >- >-void SVGTransformListValues::parse(const String& transform) >-{ >- auto upconvertedCharacters = StringView(transform).upconvertedCharacters(); >- const UChar* start = upconvertedCharacters; >- if (!SVGTransformable::parseTransformAttribute(*this, start, start + transform.length())) >- clear(); >-} >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTransformListValues.h b/Source/WebCore/svg/SVGTransformListValues.h >deleted file mode 100644 >index 2f32951e4be..00000000000 >--- a/Source/WebCore/svg/SVGTransformListValues.h >+++ /dev/null >@@ -1,61 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#pragma once >- >-#include "SVGPropertyTraits.h" >-#include "SVGTransform.h" >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-template<typename T> >-class SVGListPropertyTearOff; >- >-class SVGTransformList; >- >-class SVGTransformListValues final : public Vector<SVGTransformValue, 0, CrashOnOverflow, 2> { >-public: >- Ref<SVGTransform> createSVGTransformFromMatrix(SVGMatrix&) const; >- Ref<SVGTransform> consolidate(); >- >- bool concatenate(AffineTransform& result) const; >- >- String valueAsString() const; >- void parse(const String&); >-}; >- >-template<> struct SVGPropertyTraits<SVGTransformListValues> { >- static SVGTransformListValues initialValue() { return { }; } >- static SVGTransformListValues fromString(const String& string) >- { >- SVGTransformListValues values; >- values.parse(string); >- return values; >- } >- static std::optional<SVGTransformListValues> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(const SVGTransformListValues& list) { return list.valueAsString(); } >- >- using ListItemType = SVGTransformValue; >- using ListItemTearOff = SVGTransform; >- using ListPropertyTearOff = SVGTransformList; >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/properties/SVGList.h b/Source/WebCore/svg/properties/SVGList.h >index 8b137891791..0f353da857f 100644 >--- a/Source/WebCore/svg/properties/SVGList.h >+++ b/Source/WebCore/svg/properties/SVGList.h >@@ -1 +1,193 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "ExceptionOr.h" >+#include "SVGProperty.h" >+ >+namespace WebCore { >+ >+template<typename ItemType> >+class SVGList : public SVGProperty { >+public: >+ unsigned numberOfItems() const >+ { >+ return m_items.size(); >+ } >+ >+ ExceptionOr<void> clear() >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ clearItems(); >+ commitChange(); >+ return { }; >+ } >+ >+ ExceptionOr<ItemType> getItem(unsigned index) >+ { >+ auto result = canGetItem(index); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ return at(index); >+ } >+ >+ ExceptionOr<ItemType> initialize(ItemType&& newItem) >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ >+ // Spec: Clears all existing current items from the list. >+ clearItems(); >+ >+ auto item = append(WTFMove(newItem)); >+ commitChange(); >+ return WTFMove(item); >+ } >+ >+ ExceptionOr<ItemType> insertItemBefore(ItemType&& newItem, unsigned index) >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ // Spec: If the index is greater than or equal to numberOfItems, >+ // then the new item is appended to the end of the list. >+ if (index > numberOfItems()) >+ index = numberOfItems(); >+ >+ auto item = insert(index, WTFMove(newItem)); >+ commitChange(); >+ return WTFMove(item); >+ } >+ >+ ExceptionOr<ItemType> replaceItem(ItemType&& newItem, unsigned index) >+ { >+ auto result = canReplaceItem(index); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ auto item = replace(index, WTFMove(newItem)); >+ commitChange(); >+ return WTFMove(item); >+ } >+ >+ ExceptionOr<ItemType> removeItem(unsigned index) >+ { >+ auto result = canRemoveItem(index); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ auto item = remove(index); >+ commitChange(); >+ return WTFMove(item); >+ } >+ >+ ExceptionOr<ItemType> appendItem(ItemType&& newItem) >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ auto item = append(WTFMove(newItem)); >+ commitChange(); >+ return WTFMove(item); >+ } >+ >+ // Parsers and animators need to have a direct access to the items. >+ Vector<ItemType>& items() { return m_items; } >+ const Vector<ItemType>& items() const { return m_items; } >+ size_t size() const { return m_items.size(); } >+ bool isEmpty() const { return m_items.isEmpty(); } >+ >+ void clearItems() >+ { >+ detachItems(); >+ m_items.clear(); >+ } >+ >+protected: >+ using SVGProperty::SVGProperty; >+ >+ ExceptionOr<bool> canAlterList() const >+ { >+ if (isReadOnly()) >+ return Exception { NoModificationAllowedError }; >+ return true; >+ } >+ >+ ExceptionOr<bool> canGetItem(unsigned index) >+ { >+ if (index >= m_items.size()) >+ return Exception { IndexSizeError }; >+ return true; >+ } >+ >+ ExceptionOr<bool> canReplaceItem(unsigned index) >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ if (index >= m_items.size()) >+ return Exception { IndexSizeError }; >+ return true; >+ } >+ >+ ExceptionOr<bool> canRemoveItem(unsigned index) >+ { >+ auto result = canAlterList(); >+ if (result.hasException()) >+ return result.releaseException(); >+ ASSERT(result.releaseReturnValue()); >+ >+ if (index >= m_items.size()) >+ return Exception { IndexSizeError }; >+ return true; >+ } >+ >+ virtual void detachItems() { } >+ virtual ItemType at(unsigned index) const = 0; >+ virtual ItemType insert(unsigned index, ItemType&&) = 0; >+ virtual ItemType replace(unsigned index, ItemType&&) = 0; >+ virtual ItemType remove(unsigned index) = 0; >+ virtual ItemType append(ItemType&&) = 0; >+ >+ Vector<ItemType> m_items; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGPrimitiveList.h b/Source/WebCore/svg/properties/SVGPrimitiveList.h >index 8b137891791..dd67ec38d16 100644 >--- a/Source/WebCore/svg/properties/SVGPrimitiveList.h >+++ b/Source/WebCore/svg/properties/SVGPrimitiveList.h >@@ -1 +1,77 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "SVGList.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType> >+class SVGPrimitiveList : public SVGList<PropertyType> { >+protected: >+ using Base = SVGList<PropertyType>; >+ using Base::Base; >+ using Base::size; >+ using Base::m_items; >+ >+ PropertyType at(unsigned index) const override >+ { >+ ASSERT(index < size()); >+ return m_items.at(index); >+ } >+ >+ PropertyType insert(unsigned index, PropertyType&& newItem) override >+ { >+ ASSERT(index <= size()); >+ m_items.insert(index, WTFMove(newItem)); >+ return at(index); >+ } >+ >+ PropertyType replace(unsigned index, PropertyType&& newItem) override >+ { >+ ASSERT(index < size()); >+ m_items.at(index) = WTFMove(newItem); >+ return at(index); >+ } >+ >+ PropertyType remove(unsigned index) override >+ { >+ ASSERT(index < size()); >+ PropertyType item = at(index); >+ m_items.remove(index); >+ return WTFMove(item); >+ } >+ >+ PropertyType append(PropertyType&& newItem) override >+ { >+ m_items.append(WTFMove(newItem)); >+ return at(size() - 1); >+ } >+}; >+ >+} >+ > >diff --git a/Source/WebCore/svg/properties/SVGPropertyList.h b/Source/WebCore/svg/properties/SVGPropertyList.h >index 8b137891791..38b900eff81 100644 >--- a/Source/WebCore/svg/properties/SVGPropertyList.h >+++ b/Source/WebCore/svg/properties/SVGPropertyList.h >@@ -1 +1,137 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGList.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType> >+class SVGPropertyList : public SVGList<Ref<PropertyType>>, public SVGPropertyOwner { >+public: >+ using BaseList = SVGList<Ref<PropertyType>>; >+ using BaseList::isEmpty; >+ using BaseList::size; >+ using BaseList::append; >+ >+protected: >+ using SVGPropertyOwner::SVGPropertyOwner; >+ using BaseList::m_items; >+ using BaseList::m_access; >+ using BaseList::m_owner; >+ >+ SVGPropertyList(SVGPropertyOwner* owner = nullptr, SVGPropertyAccess access = SVGPropertyAccess::ReadWrite) >+ : BaseList(owner, access) >+ { >+ } >+ >+ ~SVGPropertyList() >+ { >+ // Detach the items from the list before it is deleted. >+ detachItems(); >+ } >+ >+ void detachItems() override >+ { >+ for (auto& item : m_items) >+ item->detach(); >+ } >+ >+ SVGPropertyOwner* owner() const override { return m_owner; } >+ >+ void commitPropertyChange(SVGProperty*) override >+ { >+ if (owner()) >+ owner()->commitPropertyChange(this); >+ } >+ >+ Ref<PropertyType> at(unsigned index) const override >+ { >+ ASSERT(index < size()); >+ return m_items.at(index).copyRef(); >+ } >+ >+ Ref<PropertyType> insert(unsigned index, Ref<PropertyType>&& newItem) override >+ { >+ ASSERT(index <= size()); >+ >+ // Spec: if newItem is not a detached object, then set newItem to be >+ // a clone object of newItem. >+ if (newItem->isAttached()) >+ newItem = newItem->clone(); >+ >+ // Spec: Attach newItem to the list object. >+ newItem->attach(this, m_access); >+ m_items.insert(index, WTFMove(newItem)); >+ return at(index); >+ } >+ >+ Ref<PropertyType> replace(unsigned index, Ref<PropertyType>&& newItem) override >+ { >+ ASSERT(index < size()); >+ Ref<PropertyType>& item = m_items[index]; >+ >+ // Spec: Detach item. >+ item->detach(); >+ >+ // Spec: if newItem is not a detached object, then set newItem to be >+ // a clone object of newItem. >+ if (newItem->isAttached()) >+ item = newItem->clone(); >+ else >+ item = WTFMove(newItem); >+ >+ // Spec: Attach newItem to the list object. >+ item->attach(this, m_access); >+ return at(index); >+ } >+ >+ Ref<PropertyType> remove(unsigned index) override >+ { >+ ASSERT(index < size()); >+ Ref<PropertyType> item = at(index); >+ >+ // Spec: Detach item. >+ item->detach(); >+ m_items.remove(index); >+ return WTFMove(item); >+ } >+ >+ Ref<PropertyType> append(Ref<PropertyType>&& newItem) override >+ { >+ // Spec: if newItem is not a detached object, then set newItem to be >+ // a clone object of newItem. >+ if (newItem->isAttached()) >+ newItem = newItem->clone(); >+ >+ // Spec: Attach newItem to the list object. >+ newItem->attach(this, m_access); >+ m_items.append(WTFMove(newItem)); >+ return at(size() - 1); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValuePropertyList.h b/Source/WebCore/svg/properties/SVGValuePropertyList.h >index 8b137891791..1a401135ac3 100644 >--- a/Source/WebCore/svg/properties/SVGValuePropertyList.h >+++ b/Source/WebCore/svg/properties/SVGValuePropertyList.h >@@ -1 +1,89 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGPropertyList.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType> >+class SVGValuePropertyList : public SVGPropertyList<PropertyType> { >+public: >+ using Base = SVGPropertyList<PropertyType>; >+ using Base::clearItems; >+ using Base::items; >+ using Base::size; >+ >+ SVGValuePropertyList& operator=(const SVGValuePropertyList& other) >+ { >+ clearItems(); >+ for (const auto& item : other.items()) >+ append(PropertyType::create(item->value())); >+ return *this; >+ } >+ >+ // This casting operator returns a Vector of the underlying ValueType, >+ // for example Vector<float> from SVGNumberList. >+ operator Vector<typename PropertyType::ValueType>() const >+ { >+ Vector<typename PropertyType::ValueType> values; >+ for (const auto& item : items()) >+ values.append(item->value()); >+ return values; >+ } >+ >+ void resize(size_t newSize) >+ { >+ // Add new items. >+ while (size() < newSize) >+ append(PropertyType::create()); >+ >+ // Remove existing items. >+ while (size() > newSize) >+ remove(size() - 1); >+ } >+ >+protected: >+ using Base::append; >+ using Base::remove; >+ >+ // Base and default constructor. Do not use "using Base::Base" because of Windows and GTK ports. >+ SVGValuePropertyList(SVGPropertyOwner* owner = nullptr, SVGPropertyAccess access = SVGPropertyAccess::ReadWrite) >+ : Base(owner, access) >+ { >+ } >+ >+ // Used by SVGAnimatedPropertyList when creating it animVal from baseVal. >+ SVGValuePropertyList(const SVGValuePropertyList& other, SVGPropertyAccess access = SVGPropertyAccess::ReadWrite) >+ : Base(other.owner(), access) >+ { >+ // Clone all items. >+ for (const auto& item : other.items()) >+ append(PropertyType::create(item->value())); >+ } >+}; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191237
:
353808
|
353812
|
353815
|
353817
|
353818
|
353820
|
353824
|
353825
|
355382
|
355386
|
355388
|
355393
|
355568
|
355574
|
355575
|
355577
|
355580
|
355582
|
355585
|
355666
|
355672
|
355693
|
355699
|
355711
|
355752
|
355777
|
355820
|
356333
|
356334
|
356338
|
356340
|
356342
|
356344
|
356346
|
356351
|
356352
|
356358
|
356360
|
356380
|
356497
|
356500
|
356507
|
356579
|
356607
|
356728
|
356729
|
356730
|
356731
|
356732
|
356733
|
356752
|
356810
|
356811
|
356879
|
356880
|
356881
|
356882
|
356883
|
356884
|
356885
|
356887
|
356888
|
356889
|
356892
|
356895
|
356896
|
359721
|
359735
|
359747
|
363581
|
363595
|
363613
|
363690
|
364172
|
364180
|
366512
|
366557
|
366636