Title: [208780] trunk/Source/WebCore
Revision
208780
Author
[email protected]
Date
2016-11-15 20:07:30 -0800 (Tue, 15 Nov 2016)

Log Message

Simplify Element::stripScriptingAttributes()
https://bugs.webkit.org/show_bug.cgi?id=164785

Reviewed by Ryosuke Niwa.

Simplify Element::stripScriptingAttributes() by leveraging
Vector::removeAllMatching().

No new tests, no Web-exposed behavior change.

* dom/Element.cpp:
(WebCore::Element::stripScriptingAttributes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208779 => 208780)


--- trunk/Source/WebCore/ChangeLog	2016-11-16 03:10:04 UTC (rev 208779)
+++ trunk/Source/WebCore/ChangeLog	2016-11-16 04:07:30 UTC (rev 208780)
@@ -1,3 +1,18 @@
+2016-11-15  Chris Dumez  <[email protected]>
+
+        Simplify Element::stripScriptingAttributes()
+        https://bugs.webkit.org/show_bug.cgi?id=164785
+
+        Reviewed by Ryosuke Niwa.
+
+        Simplify Element::stripScriptingAttributes() by leveraging
+        Vector::removeAllMatching().
+
+        No new tests, no Web-exposed behavior change.
+
+        * dom/Element.cpp:
+        (WebCore::Element::stripScriptingAttributes):
+
 2016-11-15  Jon Lee  <[email protected]>
 
         Report active video and audio capture devices separately

Modified: trunk/Source/WebCore/dom/Element.cpp (208779 => 208780)


--- trunk/Source/WebCore/dom/Element.cpp	2016-11-16 03:10:04 UTC (rev 208779)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-11-16 04:07:30 UTC (rev 208780)
@@ -1499,19 +1499,11 @@
 
 void Element::stripScriptingAttributes(Vector<Attribute>& attributeVector) const
 {
-    size_t destination = 0;
-    for (size_t source = 0; source < attributeVector.size(); ++source) {
-        if (isEventHandlerAttribute(attributeVector[source])
-            || isJavaScriptURLAttribute(attributeVector[source])
-            || isHTMLContentAttribute(attributeVector[source]))
-            continue;
-
-        if (source != destination)
-            attributeVector[destination] = attributeVector[source];
-
-        ++destination;
-    }
-    attributeVector.shrink(destination);
+    attributeVector.removeAllMatching([this](auto& attribute) -> bool {
+        return isEventHandlerAttribute(attribute)
+            || this->isJavaScriptURLAttribute(attribute)
+            || this->isHTMLContentAttribute(attribute);
+    });
 }
 
 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to