Remove stripLeadingAndTrailingWhitespace from MathMLElement.cpp
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 16:31:17 +0000 (16:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 16:31:17 +0000 (16:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160172

Patch by Rob Buis <rbuis@igalia.com> on 2019-02-22
Reviewed by Frédéric Wang.

Remove stripLeadingAndTrailingWhitespace and use stripLeadingAndTrailingHTTPSpaces
from HTTPParsers instead.

No new tests, already covered by MathML tests.

* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::stripLeadingAndTrailingWhitespace): Deleted.
* mathml/MathMLElement.h:
* mathml/MathMLPresentationElement.cpp:
(WebCore::MathMLPresentationElement::parseMathMLLength):
* mathml/MathMLTokenElement.cpp:
(WebCore::MathMLTokenElement::convertToSingleCodePoint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241947 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/mathml/MathMLElement.cpp
Source/WebCore/mathml/MathMLElement.h
Source/WebCore/mathml/MathMLPresentationElement.cpp
Source/WebCore/mathml/MathMLTokenElement.cpp

index c7b81ce..067363d 100644 (file)
@@ -1,3 +1,23 @@
+2019-02-22  Rob Buis  <rbuis@igalia.com>
+
+        Remove stripLeadingAndTrailingWhitespace from MathMLElement.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=160172
+
+        Reviewed by Frédéric Wang.
+
+        Remove stripLeadingAndTrailingWhitespace and use stripLeadingAndTrailingHTTPSpaces
+        from HTTPParsers instead.
+
+        No new tests, already covered by MathML tests.
+
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::stripLeadingAndTrailingWhitespace): Deleted.
+        * mathml/MathMLElement.h:
+        * mathml/MathMLPresentationElement.cpp:
+        (WebCore::MathMLPresentationElement::parseMathMLLength):
+        * mathml/MathMLTokenElement.cpp:
+        (WebCore::MathMLTokenElement::convertToSingleCodePoint):
+
 2019-02-22  Eric Carlson  <eric.carlson@apple.com>
 
         Update some media logging
index d8cb1c4..96d570a 100644 (file)
@@ -219,18 +219,6 @@ int MathMLElement::tabIndex() const
     return Element::tabIndex();
 }
 
-StringView MathMLElement::stripLeadingAndTrailingWhitespace(const StringView& stringView)
-{
-    unsigned start = 0, stringLength = stringView.length();
-    while (stringLength > 0 && isHTMLSpace(stringView[start])) {
-        start++;
-        stringLength--;
-    }
-    while (stringLength > 0 && isHTMLSpace(stringView[start + stringLength - 1]))
-        stringLength--;
-    return stringView.substring(start, stringLength);
-}
-
 }
 
 #endif // ENABLE(MATHML)
index b35f016..0679f02 100644 (file)
@@ -93,8 +93,6 @@ public:
 protected:
     MathMLElement(const QualifiedName& tagName, Document&);
 
-    static StringView stripLeadingAndTrailingWhitespace(const StringView&);
-
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     bool childShouldCreateRenderer(const Node&) const override;
 
index 84b7d20..7bbbbfb 100644 (file)
@@ -35,6 +35,7 @@
 #include "HTMLMapElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "HTTPParsers.h"
 #include "MathMLMathElement.h"
 #include "MathMLNames.h"
 #include "RenderMathMLBlock.h"
@@ -294,18 +295,19 @@ MathMLElement::Length MathMLPresentationElement::parseMathMLLength(const String&
     // Instead, we just use isHTMLSpace and toFloat to parse these parts.
 
     // We first skip whitespace from both ends of the string.
-    StringView stringView = stripLeadingAndTrailingWhitespace(string);
+    StringView stringView = string;
+    StringView strippedLength = stripLeadingAndTrailingHTTPSpaces(stringView);
 
-    if (stringView.isEmpty())
+    if (strippedLength.isEmpty())
         return Length();
 
     // We consider the most typical case: a number followed by an optional unit.
-    UChar firstChar = stringView[0];
+    UChar firstChar = strippedLength[0];
     if (isASCIIDigit(firstChar) || firstChar == '-' || firstChar == '.')
-        return parseNumberAndUnit(stringView);
+        return parseNumberAndUnit(strippedLength);
 
     // Otherwise, we try and parse a named space.
-    return parseNamedSpace(stringView);
+    return parseNamedSpace(strippedLength);
 }
 
 const MathMLElement::Length& MathMLPresentationElement::cachedMathMLLength(const QualifiedName& name, Optional<Length>& length)
index 9352393..db8d037 100644 (file)
@@ -30,6 +30,7 @@
 
 #if ENABLE(MATHML)
 
+#include "HTTPParsers.h"
 #include "MathMLNames.h"
 #include "RenderMathMLToken.h"
 #include <wtf/IsoMallocInlines.h>
@@ -82,7 +83,7 @@ bool MathMLTokenElement::childShouldCreateRenderer(const Node& child) const
 
 Optional<UChar32> MathMLTokenElement::convertToSingleCodePoint(StringView string)
 {
-    auto codePoints = stripLeadingAndTrailingWhitespace(string).codePoints();
+    auto codePoints = stripLeadingAndTrailingHTTPSpaces(string).codePoints();
     auto iterator = codePoints.begin();
     if (iterator == codePoints.end())
         return WTF::nullopt;