Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (194970 => 194971)
--- branches/safari-601-branch/Source/WebCore/ChangeLog 2016-01-13 20:17:21 UTC (rev 194970)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog 2016-01-13 20:17:25 UTC (rev 194971)
@@ -1,3 +1,23 @@
+2016-01-13 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r190641. rdar://problem/24154291
+
+ 2015-10-06 Chris Dumez <cdu...@apple.com>
+
+ 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.
+
2016-01-12 Matthew Hanson <matthew_han...@apple.com>
Merge r194751. rdar://problem/24043054
Modified: branches/safari-601-branch/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (194970 => 194971)
--- branches/safari-601-branch/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2016-01-13 20:17:21 UTC (rev 194970)
+++ branches/safari-601-branch/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2016-01-13 20:17:25 UTC (rev 194971)
@@ -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;
}