Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp

Issue 2589123002: Fix links are not shown for srcset in view-source (Closed)
Patch Set: Fix links are not shown for srcset in view-source Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLViewSourceDocument.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1187e24824105607e6f1c0e99311ba7a09742927 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");
+ 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) {
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLViewSourceDocument.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698