From 13c38e804c94b16949fc39ee4d018d7e5487a8f8 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Thu, 24 Mar 2016 16:38:22 +0800 Subject: [PATCH] Bug 1257742 - Part 2: Allow both width and static density candidates showing in same selector; r=jdm MozReview-Commit-ID: KJuo6wK765h --- dom/base/ResponsiveImageSelector.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dom/base/ResponsiveImageSelector.cpp b/dom/base/ResponsiveImageSelector.cpp index 8e3feeaaa3f2..93484f5bd225 100644 --- a/dom/base/ResponsiveImageSelector.cpp +++ b/dom/base/ResponsiveImageSelector.cpp @@ -259,9 +259,8 @@ ResponsiveImageSelector::AppendCandidateIfUnique(const ResponsiveImageCandidate int numCandidates = mCandidates.Length(); // With the exception of Default, which should not be added until we are done - // building the list, the spec forbids mixing width and explicit density - // selectors in the same set. - if (numCandidates && mCandidates[0].Type() != aCandidate.Type()) { + // building the list. + if (aCandidate.Type() == ResponsiveImageCandidate::eCandidateType_Default) { return; } @@ -369,15 +368,16 @@ ResponsiveImageSelector::SelectImage(bool aReselect) // the greatest density available // If the list contains computed width candidates, compute the current - // effective image width. Note that we currently disallow both computed and - // static density candidates in the same selector, so checking the first - // candidate is sufficient. + // effective image width. int32_t computedWidth = -1; - if (numCandidates && mCandidates[0].IsComputedFromWidth()) { - DebugOnly computeResult = \ - ComputeFinalWidthForCurrentViewport(&computedWidth); - MOZ_ASSERT(computeResult, - "Computed candidates not allowed without sizes data"); + for (int i = 0; i < numCandidates; i++) { + if (mCandidates[i].IsComputedFromWidth()) { + DebugOnly computeResult = \ + ComputeFinalWidthForCurrentViewport(&computedWidth); + MOZ_ASSERT(computeResult, + "Computed candidates not allowed without sizes data"); + break; + } } int bestIndex = -1;