+2015-10-06 Chris Dumez <cdumez@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.
+
2015-10-06 Youenn Fablet <youenn.fablet@crf.canon.fr>
Binding generator XXConstructor::finishCreation should take references as parameters
}
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;
}
}
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;
}