Title: [190967] releases/WebKitGTK/webkit-2.10/Source/WebCore
Revision
190967
Author
[email protected]
Date
2015-10-13 04:04:39 -0700 (Tue, 13 Oct 2015)

Log Message

Merge r190641 - Refactor TokenPreloadScanner::StartTagScanner::processAttribute()
https://bugs.webkit.org/show_bug.cgi?id=149847

Reviewed by Antti Koivisto.

Refactor TokenPreloadScanner::StartTagScanner::processAttribute() to only
process attributes that make sense given the current tagId. In particular,
- We only process the charset parameter if the tag is a link or a script.
- We only process the sizes / srcset attributes if the tag is an img.

* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
(WebCore::TokenPreloadScanner::StartTagScanner::setUrlToLoad): Deleted.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (190966 => 190967)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-13 11:03:20 UTC (rev 190966)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-13 11:04:39 UTC (rev 190967)
@@ -1,3 +1,19 @@
+2015-10-06  Chris Dumez  <[email protected]>
+
+        Refactor TokenPreloadScanner::StartTagScanner::processAttribute()
+        https://bugs.webkit.org/show_bug.cgi?id=149847
+
+        Reviewed by Antti Koivisto.
+
+        Refactor TokenPreloadScanner::StartTagScanner::processAttribute() to only
+        process attributes that make sense given the current tagId. In particular,
+        - We only process the charset parameter if the tag is a link or a script.
+        - We only process the sizes / srcset attributes if the tag is an img.
+
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
+        (WebCore::TokenPreloadScanner::StartTagScanner::setUrlToLoad): Deleted.
+
 2015-10-06  Jiewen Tan  <[email protected]>
 
         Fix crash in ApplyStyleCommand::applyRelativeFontStyleChange()

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (190966 => 190967)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/html/parser/HTMLPreloadScanner.cpp	2015-10-13 11:03:20 UTC (rev 190966)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/html/parser/HTMLPreloadScanner.cpp	2015-10-13 11:04:39 UTC (rev 190967)
@@ -140,38 +140,60 @@
     }
 
 private:
-    template<typename NameType>
-    void processAttribute(const NameType& attributeName, const String& attributeValue)
+    void processImageAndScriptAttribute(const AtomicString& attributeName, const String& attributeValue)
     {
-        if (match(attributeName, charsetAttr))
+        if (match(attributeName, srcAttr))
+            setUrlToLoad(attributeValue);
+        else if (match(attributeName, crossoriginAttr) && !attributeValue.isNull())
+            m_crossOriginMode = stripLeadingAndTrailingHTMLSpaces(attributeValue);
+        else if (match(attributeName, charsetAttr))
             m_charset = attributeValue;
+    }
 
-        if (m_tagId == TagId::Script || m_tagId == TagId::Img) {
-            if (match(attributeName, srcAttr))
-                setUrlToLoad(attributeValue);
-            else if (match(attributeName, srcsetAttr) && m_srcSetAttribute.isNull())
+    void processAttribute(const AtomicString& attributeName, const String& attributeValue)
+    {
+        switch (m_tagId) {
+        case TagId::Img:
+            if (match(attributeName, srcsetAttr) && m_srcSetAttribute.isNull()) {
                 m_srcSetAttribute = attributeValue;
-            else if (match(attributeName, sizesAttr) && m_sizesAttribute.isNull())
+                break;
+            }
+            if (match(attributeName, sizesAttr) && m_sizesAttribute.isNull()) {
                 m_sizesAttribute = attributeValue;
-            else if (match(attributeName, crossoriginAttr) && !attributeValue.isNull())
-                m_crossOriginMode = stripLeadingAndTrailingHTMLSpaces(attributeValue);
-        } else if (m_tagId == TagId::Link) {
+                break;
+            }
+            processImageAndScriptAttribute(attributeName, attributeValue);
+            break;
+        case TagId::Script:
+            processImageAndScriptAttribute(attributeName, attributeValue);
+            break;
+        case TagId::Link:
             if (match(attributeName, hrefAttr))
                 setUrlToLoad(attributeValue);
             else if (match(attributeName, relAttr))
                 m_linkIsStyleSheet = relAttributeIsStyleSheet(attributeValue);
             else if (match(attributeName, mediaAttr))
                 m_mediaAttribute = attributeValue;
-        } else if (m_tagId == TagId::Input) {
+            else if (match(attributeName, charsetAttr))
+                m_charset = attributeValue;
+            break;
+        case TagId::Input:
             if (match(attributeName, srcAttr))
                 setUrlToLoad(attributeValue);
             else if (match(attributeName, typeAttr))
                 m_inputIsImage = equalIgnoringCase(attributeValue, InputTypeNames::image());
-        } else if (m_tagId == TagId::Meta) {
+            break;
+        case TagId::Meta:
             if (match(attributeName, contentAttr))
                 m_metaContent = attributeValue;
             else if (match(attributeName, nameAttr))
                 m_metaIsViewport = equalIgnoringCase(attributeValue, "viewport");
+            break;
+        case TagId::Base:
+        case TagId::Style:
+        case TagId::Template:
+        case TagId::Unknown:
+            break;
         }
     }
 
@@ -195,9 +217,6 @@
 
     const String& charset() const
     {
-        // FIXME: Its not clear that this if is needed, the loader probably ignores charset for image requests anyway.
-        if (m_tagId == TagId::Img)
-            return emptyString();
         return m_charset;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to