Title: [257696] trunk/Source/WebCore
Revision
257696
Author
[email protected]
Date
2020-03-01 16:40:05 -0800 (Sun, 01 Mar 2020)

Log Message

Move some vectors around instead of heap-allocating them and moving the pointers
https://bugs.webkit.org/show_bug.cgi?id=208422

Reviewed by Sam Weinig.

* css/CSSKeyframeRule.cpp:
(WebCore::StyleRuleKeyframe::StyleRuleKeyframe): Take Vector&& instead of
unique_ptr<Vector>.
(WebCore::StyleRuleKeyframe::create): Moved these here from the header.
Take Vector&& instead of unique_ptr<Vector>.
(WebCore::StyleRuleKeyframe::setKeyText): Update since the result is a
Vector rather than a unique_ptr<Vector>.
* css/CSSKeyframeRule.h: Updated for the above.

* css/CSSKeyframesRule.cpp:
(WebCore::StyleRuleKeyframes::findKeyframeIndex const): Return Optional<size_t>
so we don't depend on notFound. This is our better modern pattern, since
notFound can work wrong if we mix size_t and unsigned, for example. Also
updatd since result of parseKeyFrameKeyList is now a Vector rather than
a unique_ptr<Vector>.
(WebCore::CSSKeyframesRule::deleteRule): Updated for the above.
(WebCore::CSSKeyframesRule::findRule): Ditto.
* css/CSSKeyframesRule.h: Updated for the above.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseKeyframeKeyList): Return Vector instead of
unique_ptr<Vector>.
* css/parser/CSSParser.h: Updated for the above.

* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::parseKeyframeKeyList): Return Vector instead of
unique_ptr<Vector>.
(WebCore::CSSParserImpl::consumeKeyframeStyleRule): Updated for the
above change.
(WebCore::CSSParserImpl::consumeKeyframeKeyList): Return Vector instead
of unique_ptr<Vector>.
* css/parser/CSSParserImpl.h: Updated for the above.

* platform/graphics/FloatPolygon.cpp:
(WebCore::FloatPolygon::FloatPolygon): Take Vector&& instead of
unique_ptr<Vector>.
* platform/graphics/FloatPolygon.h: Take Vector&& instead of unique_ptr<Vector>.
Also changed m_vertices to a Vector instead of a unique_ptr<Vector>.

* rendering/shapes/PolygonShape.h: Take Vector&& instead of unique_ptr<Vector>.

* rendering/shapes/Shape.cpp:
(WebCore::createPolygonShape): Take Vector&& instead of unique_ptr<Vector>.
(WebCore::Shape::createShape): Use a Vector instead of a unique_ptr<Vector>.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257695 => 257696)


--- trunk/Source/WebCore/ChangeLog	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/ChangeLog	2020-03-02 00:40:05 UTC (rev 257696)
@@ -1,3 +1,55 @@
+2020-02-29  Darin Adler  <[email protected]>
+
+        Move some vectors around instead of heap-allocating them and moving the pointers
+        https://bugs.webkit.org/show_bug.cgi?id=208422
+
+        Reviewed by Sam Weinig.
+
+        * css/CSSKeyframeRule.cpp:
+        (WebCore::StyleRuleKeyframe::StyleRuleKeyframe): Take Vector&& instead of
+        unique_ptr<Vector>.
+        (WebCore::StyleRuleKeyframe::create): Moved these here from the header.
+        Take Vector&& instead of unique_ptr<Vector>.
+        (WebCore::StyleRuleKeyframe::setKeyText): Update since the result is a
+        Vector rather than a unique_ptr<Vector>.
+        * css/CSSKeyframeRule.h: Updated for the above.
+
+        * css/CSSKeyframesRule.cpp:
+        (WebCore::StyleRuleKeyframes::findKeyframeIndex const): Return Optional<size_t>
+        so we don't depend on notFound. This is our better modern pattern, since
+        notFound can work wrong if we mix size_t and unsigned, for example. Also
+        updatd since result of parseKeyFrameKeyList is now a Vector rather than
+        a unique_ptr<Vector>.
+        (WebCore::CSSKeyframesRule::deleteRule): Updated for the above.
+        (WebCore::CSSKeyframesRule::findRule): Ditto.
+        * css/CSSKeyframesRule.h: Updated for the above.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseKeyframeKeyList): Return Vector instead of
+        unique_ptr<Vector>.
+        * css/parser/CSSParser.h: Updated for the above.
+
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::CSSParserImpl::parseKeyframeKeyList): Return Vector instead of
+        unique_ptr<Vector>.
+        (WebCore::CSSParserImpl::consumeKeyframeStyleRule): Updated for the
+        above change.
+        (WebCore::CSSParserImpl::consumeKeyframeKeyList): Return Vector instead
+        of unique_ptr<Vector>.
+        * css/parser/CSSParserImpl.h: Updated for the above.
+
+        * platform/graphics/FloatPolygon.cpp:
+        (WebCore::FloatPolygon::FloatPolygon): Take Vector&& instead of
+        unique_ptr<Vector>.
+        * platform/graphics/FloatPolygon.h: Take Vector&& instead of unique_ptr<Vector>.
+        Also changed m_vertices to a Vector instead of a unique_ptr<Vector>.
+
+        * rendering/shapes/PolygonShape.h: Take Vector&& instead of unique_ptr<Vector>.
+
+        * rendering/shapes/Shape.cpp:
+        (WebCore::createPolygonShape): Take Vector&& instead of unique_ptr<Vector>.
+        (WebCore::Shape::createShape): Use a Vector instead of a unique_ptr<Vector>.
+
 2020-03-01  Zalan Bujtas  <[email protected]>
 
         [LFC][MarginCollapsing] Do not re-compute PositiveAndNegativeVerticalMargin values

Modified: trunk/Source/WebCore/css/CSSKeyframeRule.cpp (257695 => 257696)


--- trunk/Source/WebCore/css/CSSKeyframeRule.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -40,13 +40,23 @@
 {
 }
 
-StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, Ref<StyleProperties>&& properties)
+StyleRuleKeyframe::StyleRuleKeyframe(Vector<double>&& keys, Ref<StyleProperties>&& properties)
     : StyleRuleBase(StyleRuleType::Keyframe)
     , m_properties(WTFMove(properties))
-    , m_keys(*keys)
+    , m_keys(WTFMove(keys))
 {
 }
-    
+
+Ref<StyleRuleKeyframe> StyleRuleKeyframe::create(Ref<StyleProperties>&& properties)
+{
+    return adoptRef(*new StyleRuleKeyframe(WTFMove(properties)));
+}
+
+Ref<StyleRuleKeyframe> StyleRuleKeyframe::create(Vector<double>&& keys, Ref<StyleProperties>&& properties)
+{
+    return adoptRef(*new StyleRuleKeyframe(WTFMove(keys), WTFMove(properties)));
+}
+
 StyleRuleKeyframe::~StyleRuleKeyframe() = default;
 
 MutableStyleProperties& StyleRuleKeyframe::mutableProperties()
@@ -71,9 +81,9 @@
 {
     ASSERT(!keyText.isNull());
     auto keys = CSSParser::parseKeyframeKeyList(keyText);
-    if (!keys || keys->isEmpty())
+    if (keys.isEmpty())
         return false;
-    m_keys = *keys;
+    m_keys = WTFMove(keys);
     return true;
 }
 

Modified: trunk/Source/WebCore/css/CSSKeyframeRule.h (257695 => 257696)


--- trunk/Source/WebCore/css/CSSKeyframeRule.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -37,15 +37,8 @@
 
 class StyleRuleKeyframe final : public StyleRuleBase {
 public:
-    static Ref<StyleRuleKeyframe> create(Ref<StyleProperties>&& properties)
-    {
-        return adoptRef(*new StyleRuleKeyframe(WTFMove(properties)));
-    }
-
-    static Ref<StyleRuleKeyframe> create(std::unique_ptr<Vector<double>> keys, Ref<StyleProperties>&& properties)
-    {
-        return adoptRef(*new StyleRuleKeyframe(WTFMove(keys), WTFMove(properties)));
-    }
+    static Ref<StyleRuleKeyframe> create(Ref<StyleProperties>&&);
+    static Ref<StyleRuleKeyframe> create(Vector<double>&& keys, Ref<StyleProperties>&&);
     ~StyleRuleKeyframe();
 
     String keyText() const;
@@ -66,7 +59,7 @@
 
 private:
     explicit StyleRuleKeyframe(Ref<StyleProperties>&&);
-    StyleRuleKeyframe(std::unique_ptr<Vector<double>>, Ref<StyleProperties>&&);
+    StyleRuleKeyframe(Vector<double>&&, Ref<StyleProperties>&&);
 
     Ref<StyleProperties> m_properties;
     Vector<double> m_keys;

Modified: trunk/Source/WebCore/css/CSSKeyframesRule.cpp (257695 => 257696)


--- trunk/Source/WebCore/css/CSSKeyframesRule.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/CSSKeyframesRule.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -59,6 +59,16 @@
         m_keyframes.uncheckedAppend(keyframe.copyRef());
 }
 
+Ref<StyleRuleKeyframes> StyleRuleKeyframes::create(const AtomString& name)
+{
+    return adoptRef(*new StyleRuleKeyframes(name));
+}
+
+Ref<StyleRuleKeyframes> StyleRuleKeyframes::create(const AtomString& name, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
+{
+    return adoptRef(*new StyleRuleKeyframes(name, WTFMove(deferredRules)));
+}
+
 StyleRuleKeyframes::~StyleRuleKeyframes() = default;
 
 void StyleRuleKeyframes::parseDeferredRulesIfNeeded() const
@@ -65,7 +75,7 @@
 {
     if (!m_deferredRules)
         return;
-    
+
     m_deferredRules->parseDeferredKeyframes(const_cast<StyleRuleKeyframes&>(*this));
     m_deferredRules = nullptr;
 }
@@ -95,21 +105,17 @@
     m_keyframes.remove(index);
 }
 
-size_t StyleRuleKeyframes::findKeyframeIndex(const String& key) const
+Optional<size_t> StyleRuleKeyframes::findKeyframeIndex(const String& key) const
 {
     parseDeferredRulesIfNeeded();
-
     auto keys = CSSParser::parseKeyframeKeyList(key);
-
-    if (!keys)
-        return notFound;
-
-    for (size_t i = m_keyframes.size(); i--; ) {
-        if (m_keyframes[i]->keys() == *keys)
+    if (keys.isEmpty())
+        return WTF::nullopt;
+    for (auto i = m_keyframes.size(); i--; ) {
+        if (m_keyframes[i]->keys() == keys)
             return i;
     }
-
-    return notFound;
+    return WTF::nullopt;
 }
 
 CSSKeyframesRule::CSSKeyframesRule(StyleRuleKeyframes& keyframesRule, CSSStyleSheet* parent)
@@ -165,23 +171,23 @@
 {
     ASSERT(m_childRuleCSSOMWrappers.size() == m_keyframesRule->keyframes().size());
 
-    size_t i = m_keyframesRule->findKeyframeIndex(s);
-    if (i == notFound)
+    auto i = m_keyframesRule->findKeyframeIndex(s);
+    if (!i)
         return;
 
     CSSStyleSheet::RuleMutationScope mutationScope(this);
 
-    m_keyframesRule->wrapperRemoveKeyframe(i);
+    m_keyframesRule->wrapperRemoveKeyframe(*i);
 
-    if (m_childRuleCSSOMWrappers[i])
-        m_childRuleCSSOMWrappers[i]->setParentRule(0);
-    m_childRuleCSSOMWrappers.remove(i);
+    if (m_childRuleCSSOMWrappers[*i])
+        m_childRuleCSSOMWrappers[*i]->setParentRule(nullptr);
+    m_childRuleCSSOMWrappers.remove(*i);
 }
 
 CSSKeyframeRule* CSSKeyframesRule::findRule(const String& s)
 {
-    size_t i = m_keyframesRule->findKeyframeIndex(s);
-    return i != notFound ? item(i) : nullptr;
+    auto i = m_keyframesRule->findKeyframeIndex(s);
+    return i ? item(*i) : nullptr;
 }
 
 String CSSKeyframesRule::cssText() const

Modified: trunk/Source/WebCore/css/CSSKeyframesRule.h (257695 => 257696)


--- trunk/Source/WebCore/css/CSSKeyframesRule.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/CSSKeyframesRule.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -33,15 +33,14 @@
 
 namespace WebCore {
 
+class CSSKeyframeRule;
 class CSSRuleList;
 class StyleRuleKeyframe;
-class CSSKeyframeRule;
 
 class StyleRuleKeyframes final : public StyleRuleBase {
 public:
-    static Ref<StyleRuleKeyframes> create(const AtomString& name) { return adoptRef(*new StyleRuleKeyframes(name)); }
-    static Ref<StyleRuleKeyframes> create(const AtomString& name, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules) { return adoptRef(*new StyleRuleKeyframes(name, WTFMove(deferredRules))); }
-    
+    static Ref<StyleRuleKeyframes> create(const AtomString& name);
+    static Ref<StyleRuleKeyframes> create(const AtomString& name, std::unique_ptr<DeferredStyleGroupRuleList>&&);
     ~StyleRuleKeyframes();
     
     const Vector<Ref<StyleRuleKeyframe>>& keyframes() const;
@@ -57,12 +56,12 @@
     const AtomString& name() const { return m_name; }
     void setName(const AtomString& name) { m_name = name; }
 
-    size_t findKeyframeIndex(const String& key) const;
+    Optional<size_t> findKeyframeIndex(const String& key) const;
 
     Ref<StyleRuleKeyframes> copy() const { return adoptRef(*new StyleRuleKeyframes(*this)); }
 
 private:
-    StyleRuleKeyframes(const AtomString&);
+    explicit StyleRuleKeyframes(const AtomString&);
     StyleRuleKeyframes(const AtomString&, std::unique_ptr<DeferredStyleGroupRuleList>&&);
     StyleRuleKeyframes(const StyleRuleKeyframes&);
 

Modified: trunk/Source/WebCore/css/StyleRule.cpp (257695 => 257696)


--- trunk/Source/WebCore/css/StyleRule.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/StyleRule.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -373,7 +373,7 @@
 {
 }
 
-StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported,  std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
+StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
     : StyleRuleGroup(StyleRuleType::Supports, WTFMove(deferredRules))
     , m_conditionText(conditionText)
     , m_conditionIsSupported(conditionIsSupported)

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (257695 => 257696)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -263,7 +263,7 @@
     return CSSPropertyParser::parseTypedCustomPropertyValue(name, syntax, resolvedData->tokens(), builderState, m_context);
 }
 
-std::unique_ptr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& selector)
+Vector<double> CSSParser::parseKeyframeKeyList(const String& selector)
 {
     return CSSParserImpl::parseKeyframeKeyList(selector);
 }

Modified: trunk/Source/WebCore/css/parser/CSSParser.h (257695 => 257696)


--- trunk/Source/WebCore/css/parser/CSSParser.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/parser/CSSParser.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -63,7 +63,7 @@
     static RefPtr<StyleRuleBase> parseRule(const CSSParserContext&, StyleSheetContents*, const String&);
     
     RefPtr<StyleRuleKeyframe> parseKeyframeRule(const String&);
-    static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&);
+    static Vector<double> parseKeyframeKeyList(const String&);
     
     bool parseSupportsCondition(const String&);
 

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (257695 => 257696)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -290,7 +290,7 @@
     return CSSSelectorList { Vector<std::unique_ptr<CSSParserSelector>>::from(WTFMove(selector)) };
 }
 
-std::unique_ptr<Vector<double>> CSSParserImpl::parseKeyframeKeyList(const String& keyList)
+Vector<double> CSSParserImpl::parseKeyframeKeyList(const String& keyList)
 {
     return consumeKeyframeKeyList(CSSTokenizer(keyList).tokenRange());
 }
@@ -654,8 +654,8 @@
     
 RefPtr<StyleRuleKeyframe> CSSParserImpl::consumeKeyframeStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
 {
-    std::unique_ptr<Vector<double>> keyList = consumeKeyframeKeyList(prelude);
-    if (!keyList)
+    auto keyList = consumeKeyframeKeyList(prelude);
+    if (keyList.isEmpty())
         return nullptr;
 
     if (m_observerWrapper) {
@@ -819,24 +819,24 @@
     CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_parsedProperties, ruleType);
 }
 
-std::unique_ptr<Vector<double>> CSSParserImpl::consumeKeyframeKeyList(CSSParserTokenRange range)
+Vector<double> CSSParserImpl::consumeKeyframeKeyList(CSSParserTokenRange range)
 {
-    std::unique_ptr<Vector<double>> result = std::unique_ptr<Vector<double>>(new Vector<double>);
+    Vector<double> result;
     while (true) {
         range.consumeWhitespace();
         const CSSParserToken& token = range.consumeIncludingWhitespace();
         if (token.type() == PercentageToken && token.numericValue() >= 0 && token.numericValue() <= 100)
-            result->append(token.numericValue() / 100);
+            result.append(token.numericValue() / 100);
         else if (token.type() == IdentToken && equalIgnoringASCIICase(token.value(), "from"))
-            result->append(0);
+            result.append(0);
         else if (token.type() == IdentToken && equalIgnoringASCIICase(token.value(), "to"))
-            result->append(1);
+            result.append(1);
         else
-            return nullptr; // Parser error, invalid value in keyframe selector
+            return { }; // Parser error, invalid value in keyframe selector
         if (range.atEnd())
             return result;
         if (range.consume().type() != CommaToken)
-            return nullptr; // Parser error
+            return { }; // Parser error
     }
 }
 

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.h (257695 => 257696)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -90,7 +90,7 @@
     static void parseStyleSheet(const String&, const CSSParserContext&, StyleSheetContents*, CSSParser::RuleParsing);
     static CSSSelectorList parsePageSelector(CSSParserTokenRange, StyleSheetContents*);
 
-    static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&);
+    static Vector<double> parseKeyframeKeyList(const String&);
 
     bool supportsDeclaration(CSSParserTokenRange&);
 
@@ -143,7 +143,7 @@
     void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool important, StyleRuleType);
     void consumeCustomPropertyValue(CSSParserTokenRange, const AtomString& propertyName, bool important);
 
-    static std::unique_ptr<Vector<double>> consumeKeyframeKeyList(CSSParserTokenRange);
+    static Vector<double> consumeKeyframeKeyList(CSSParserTokenRange);
 
     Ref<DeferredStyleProperties> createDeferredStyleProperties(const CSSParserTokenRange& propertyRange);
     

Modified: trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp (257695 => 257696)


--- trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -83,7 +83,7 @@
     return vertexIndex2;
 }
 
-FloatPolygon::FloatPolygon(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule)
+FloatPolygon::FloatPolygon(Vector<FloatPoint>&& vertices, WindRule fillRule)
     : m_vertices(WTFMove(vertices))
     , m_fillRule(fillRule)
 {

Modified: trunk/Source/WebCore/platform/graphics/FloatPolygon.h (257695 => 257696)


--- trunk/Source/WebCore/platform/graphics/FloatPolygon.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/platform/graphics/FloatPolygon.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -42,10 +42,10 @@
 
 class FloatPolygon {
 public:
-    FloatPolygon(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule);
+    FloatPolygon(Vector<FloatPoint>&& vertices, WindRule fillRule);
 
-    const FloatPoint& vertexAt(unsigned index) const { return (*m_vertices)[index]; }
-    unsigned numberOfVertices() const { return m_vertices->size(); }
+    const FloatPoint& vertexAt(unsigned index) const { return m_vertices[index]; }
+    unsigned numberOfVertices() const { return m_vertices.size(); }
 
     WindRule fillRule() const { return m_fillRule; }
 
@@ -58,12 +58,12 @@
     bool isEmpty() const { return m_empty; }
 
 private:
-    typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree;
+    using EdgeIntervalTree = PODIntervalTree<float, FloatPolygonEdge*>;
 
     bool containsNonZero(const FloatPoint&) const;
     bool containsEvenOdd(const FloatPoint&) const;
 
-    std::unique_ptr<Vector<FloatPoint>> m_vertices;
+    Vector<FloatPoint> m_vertices;
     WindRule m_fillRule;
     FloatRect m_boundingBox;
     bool m_empty;

Modified: trunk/Source/WebCore/rendering/shapes/PolygonShape.h (257695 => 257696)


--- trunk/Source/WebCore/rendering/shapes/PolygonShape.h	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/rendering/shapes/PolygonShape.h	2020-03-02 00:40:05 UTC (rev 257696)
@@ -59,7 +59,7 @@
 class PolygonShape : public Shape {
     WTF_MAKE_NONCOPYABLE(PolygonShape);
 public:
-    PolygonShape(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule)
+    PolygonShape(Vector<FloatPoint>&& vertices, WindRule fillRule)
         : m_polygon(WTFMove(vertices), fillRule)
     {
     }

Modified: trunk/Source/WebCore/rendering/shapes/Shape.cpp (257695 => 257696)


--- trunk/Source/WebCore/rendering/shapes/Shape.cpp	2020-03-02 00:06:35 UTC (rev 257695)
+++ trunk/Source/WebCore/rendering/shapes/Shape.cpp	2020-03-02 00:40:05 UTC (rev 257696)
@@ -62,7 +62,7 @@
     return makeUnique<RectangleShape>(FloatRect(center.x() - radii.width(), center.y() - radii.height(), radii.width()*2, radii.height()*2), radii);
 }
 
-static std::unique_ptr<Shape> createPolygonShape(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule)
+static std::unique_ptr<Shape> createPolygonShape(Vector<FloatPoint>&& vertices, WindRule fillRule)
 {
     return makeUnique<PolygonShape>(WTFMove(vertices), fillRule);
 }
@@ -129,14 +129,13 @@
         const Vector<Length>& values = polygon.values();
         size_t valuesSize = values.size();
         ASSERT(!(valuesSize % 2));
-        std::unique_ptr<Vector<FloatPoint>> vertices = makeUnique<Vector<FloatPoint>>(valuesSize / 2);
+        Vector<FloatPoint> vertices(valuesSize / 2);
         for (unsigned i = 0; i < valuesSize; i += 2) {
             FloatPoint vertex(
                 floatValueForLength(values.at(i), boxWidth),
                 floatValueForLength(values.at(i + 1), boxHeight));
-            (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.height(), writingMode);
+            vertices[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.height(), writingMode);
         }
-
         shape = createPolygonShape(WTFMove(vertices), polygon.windRule());
         break;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to