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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.cpp

Issue 1492303003: Load data URI images in an async way according to spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: align tests Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 return i; 349 return i;
350 } 350 }
351 351
352 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid ate*>& imageCandidates, unsigned winner, Document* document) 352 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid ate*>& imageCandidates, unsigned winner, Document* document)
353 { 353 {
354 if (!document) 354 if (!document)
355 return winner; 355 return winner;
356 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { 356 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) {
357 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image Candidates[i]->url())); 357 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image Candidates[i]->url()));
358 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden tifier())) 358 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden tifier()) || url.protocolIsData())
359 return i; 359 return i;
360 } 360 }
361 return winner; 361 return winner;
362 } 362 }
363 363
364 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) 364 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr)
365 { 365 {
366 const float defaultDensityValue = 1.0; 366 const float defaultDensityValue = 1.0;
367 bool ignoreSrc = false; 367 bool ignoreSrc = false;
368 if (imageCandidates.isEmpty()) 368 if (imageCandidates.isEmpty())
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 Vector<ImageCandidate> imageCandidates; 435 Vector<ImageCandidate> imageCandidates;
436 imageCandidates.append(srcsetImageCandidate); 436 imageCandidates.append(srcsetImageCandidate);
437 437
438 if (!srcAttribute.isEmpty()) 438 if (!srcAttribute.isEmpty())
439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); 439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin));
440 440
441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString(); 441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString();
442 } 442 }
443 443
444 } 444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698