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

Side by Side 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 3 years, 12 months 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLViewSourceDocument.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 iter->nameRange().start - token.startIndex(), emptyAtom); 155 iter->nameRange().start - token.startIndex(), emptyAtom);
156 index = addRange(source, index, iter->nameRange().end - token.startIndex(), 156 index = addRange(source, index, iter->nameRange().end - token.startIndex(),
157 "html-attribute-name"); 157 "html-attribute-name");
158 158
159 if (tagName == baseTag && name == hrefAttr) 159 if (tagName == baseTag && name == hrefAttr)
160 addBase(value); 160 addBase(value);
161 161
162 index = addRange(source, index, 162 index = addRange(source, index,
163 iter->valueRange().start - token.startIndex(), emptyAtom); 163 iter->valueRange().start - token.startIndex(), emptyAtom);
164 164
165 bool isLink = name == srcAttr || name == hrefAttr; 165 if (name == srcsetAttr) {
166 index = addRange(source, index, iter->valueRange().end - token.startIndex(), 166 index = addSrcset(source, index, iter->valueRange().end - token.startInd ex());
167 "html-attribute-value", isLink, tagName == aTag, value); 167 } else {
168 bool isLink = name == srcAttr || name == hrefAttr;
169 index = addRange(source, index, iter->valueRange().end - token.startInde x(),
170 "html-attribute-value", isLink, tagName == aTag, value) ;
171 }
168 172
169 ++iter; 173 ++iter;
170 } 174 }
171 m_current = m_td; 175 m_current = m_td;
172 } 176 }
173 177
174 void HTMLViewSourceDocument::processCommentToken(const String& source, 178 void HTMLViewSourceDocument::processCommentToken(const String& source,
175 HTMLToken&) { 179 HTMLToken&) {
176 m_current = addSpanWithClassName("html-comment"); 180 m_current = addSpanWithClassName("html-comment");
177 addText(source, "html-comment"); 181 addText(source, "html-comment");
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 classValue = "html-attribute-value html-external-link"; 309 classValue = "html-attribute-value html-external-link";
306 else 310 else
307 classValue = "html-attribute-value html-resource-link"; 311 classValue = "html-attribute-value html-resource-link";
308 anchor->setAttribute(classAttr, classValue); 312 anchor->setAttribute(classAttr, classValue);
309 anchor->setAttribute(targetAttr, "_blank"); 313 anchor->setAttribute(targetAttr, "_blank");
310 anchor->setAttribute(hrefAttr, url); 314 anchor->setAttribute(hrefAttr, url);
311 m_current->parserAppendChild(anchor); 315 m_current->parserAppendChild(anchor);
312 return anchor; 316 return anchor;
313 } 317 }
314 318
319 int HTMLViewSourceDocument::addSrcset(const String& source,
320 int start,
321 int end) {
322 String srcset = source.substring(start, end-start);
323 Vector<String> srclist;
324 srcset.split(',', true, srclist);
325 unsigned size = srclist.size();
326 for (unsigned i = 0; i < size; i++) {
327 Vector<String> tmp;
328 srclist[i].split(' ', tmp);
329 if (tmp.size() > 0) {
330 AtomicString link(tmp[0]);
331 m_current = addLink(link, false);
332 addText(srclist[i], "html-attribute-value");
333 m_current = toElement(m_current->parentNode());
334 } else {
335 addText(srclist[i], "html-attribute-value");
336 }
337 if (i + 1 < size)
338 addText(",", "html-attribute-value");
339 }
340 return end;
341 }
342
315 void HTMLViewSourceDocument::maybeAddSpanForAnnotation( 343 void HTMLViewSourceDocument::maybeAddSpanForAnnotation(
316 SourceAnnotation annotation) { 344 SourceAnnotation annotation) {
317 if (annotation == AnnotateSourceAsXSS) { 345 if (annotation == AnnotateSourceAsXSS) {
318 m_current = addSpanWithClassName("highlight"); 346 m_current = addSpanWithClassName("highlight");
319 m_current->setAttribute(titleAttr, kXSSDetected); 347 m_current->setAttribute(titleAttr, kXSSDetected);
320 } 348 }
321 } 349 }
322 350
323 DEFINE_TRACE(HTMLViewSourceDocument) { 351 DEFINE_TRACE(HTMLViewSourceDocument) {
324 visitor->trace(m_current); 352 visitor->trace(m_current);
325 visitor->trace(m_tbody); 353 visitor->trace(m_tbody);
326 visitor->trace(m_td); 354 visitor->trace(m_td);
327 HTMLDocument::trace(visitor); 355 HTMLDocument::trace(visitor);
328 } 356 }
329 357
330 } // namespace blink 358 } // namespace blink
OLDNEW
« 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