Title: [241947] trunk/Source/WebCore
Revision
241947
Author
[email protected]
Date
2019-02-22 08:31:17 -0800 (Fri, 22 Feb 2019)

Log Message

Remove stripLeadingAndTrailingWhitespace from MathMLElement.cpp
https://bugs.webkit.org/show_bug.cgi?id=160172

Patch by Rob Buis <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (241946 => 241947)


--- trunk/Source/WebCore/ChangeLog	2019-02-22 14:28:41 UTC (rev 241946)
+++ trunk/Source/WebCore/ChangeLog	2019-02-22 16:31:17 UTC (rev 241947)
@@ -1,3 +1,23 @@
+2019-02-22  Rob Buis  <[email protected]>
+
+        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  <[email protected]>
 
         Update some media logging

Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (241946 => 241947)


--- trunk/Source/WebCore/mathml/MathMLElement.cpp	2019-02-22 14:28:41 UTC (rev 241946)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp	2019-02-22 16:31:17 UTC (rev 241947)
@@ -219,18 +219,6 @@
     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)

Modified: trunk/Source/WebCore/mathml/MathMLElement.h (241946 => 241947)


--- trunk/Source/WebCore/mathml/MathMLElement.h	2019-02-22 14:28:41 UTC (rev 241946)
+++ trunk/Source/WebCore/mathml/MathMLElement.h	2019-02-22 16:31:17 UTC (rev 241947)
@@ -93,8 +93,6 @@
 protected:
     MathMLElement(const QualifiedName& tagName, Document&);
 
-    static StringView stripLeadingAndTrailingWhitespace(const StringView&);
-
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     bool childShouldCreateRenderer(const Node&) const override;
 

Modified: trunk/Source/WebCore/mathml/MathMLPresentationElement.cpp (241946 => 241947)


--- trunk/Source/WebCore/mathml/MathMLPresentationElement.cpp	2019-02-22 14:28:41 UTC (rev 241946)
+++ trunk/Source/WebCore/mathml/MathMLPresentationElement.cpp	2019-02-22 16:31:17 UTC (rev 241947)
@@ -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 @@
     // 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)

Modified: trunk/Source/WebCore/mathml/MathMLTokenElement.cpp (241946 => 241947)


--- trunk/Source/WebCore/mathml/MathMLTokenElement.cpp	2019-02-22 14:28:41 UTC (rev 241946)
+++ trunk/Source/WebCore/mathml/MathMLTokenElement.cpp	2019-02-22 16:31:17 UTC (rev 241947)
@@ -30,6 +30,7 @@
 
 #if ENABLE(MATHML)
 
+#include "HTTPParsers.h"
 #include "MathMLNames.h"
 #include "RenderMathMLToken.h"
 #include <wtf/IsoMallocInlines.h>
@@ -82,7 +83,7 @@
 
 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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to