Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp b/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp |
| index f385cd82b5130f9c354cd5a24851c6efab6c8076..74cb59f14f1f7e449852e38305fca27b03e41f03 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp |
| @@ -162,9 +162,13 @@ void HTMLViewSourceDocument::processTagToken(const String& source, |
| index = addRange(source, index, |
| iter->valueRange().start - token.startIndex(), emptyAtom); |
| - bool isLink = name == srcAttr || name == hrefAttr; |
| - index = addRange(source, index, iter->valueRange().end - token.startIndex(), |
| - "html-attribute-value", isLink, tagName == aTag, value); |
| + if (name == srcsetAttr) { |
| + index = addSrcset(source, index, iter->valueRange().end - token.startIndex()); |
| + } else { |
| + bool isLink = name == srcAttr || name == hrefAttr; |
| + index = addRange(source, index, iter->valueRange().end - token.startIndex(), |
| + "html-attribute-value", isLink, tagName == aTag, value); |
| + } |
| ++iter; |
| } |
| @@ -312,6 +316,30 @@ Element* HTMLViewSourceDocument::addLink(const AtomicString& url, |
| return anchor; |
| } |
| +int HTMLViewSourceDocument::addSrcset(const String& source, |
| + int start, |
| + int end) { |
| + String srcset = source.substring(start, end-start); |
| + Vector<String> srclist; |
| + srcset.split(',', true, srclist); |
| + unsigned size = srclist.size(); |
| + for (unsigned i = 0; i < size; i++) { |
| + Vector<String> tmp; |
| + srclist[i].split(' ', tmp); |
| + if (tmp.size() > 0) { |
| + AtomicString link(tmp[0]); |
| + m_current = addLink(link, false); |
| + addText(srclist[i],"html-attribute-value"); |
|
skobes
2016/12/21 01:35:06
put a space after ','
|
| + m_current = toElement(m_current->parentNode()); |
| + } else { |
| + addText(srclist[i],"html-attribute-value"); |
| + } |
| + if (i + 1 < size) |
| + addText(",","html-attribute-value"); |
| + } |
| + return end; |
| +} |
| + |
| void HTMLViewSourceDocument::maybeAddSpanForAnnotation( |
| SourceAnnotation annotation) { |
| if (annotation == AnnotateSourceAsXSS) { |