TEST(ImageCandidateTest, Basic)
{
    ImageCandidate candidate;
    ASSERT_EQ(candidate.density(), 1);
    ASSERT_EQ(candidate.getResourceWidth(), -1);
    ASSERT_EQ(candidate.srcOrigin(), false);

}
Ejemplo n.º 2
0
void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidate& candidate)
{
    m_bestFitImageURL = candidate.url();
    float candidateDensity = candidate.density();
    if (candidateDensity >= 0)
        m_imageDevicePixelRatio = 1.0 / candidateDensity;
    if (candidate.resourceWidth() > 0) {
        m_intrinsicSizingViewportDependant = true;
        UseCounter::count(document(), UseCounter::SrcsetWDescriptor);
    } else if (!candidate.srcOrigin()) {
        UseCounter::count(document(), UseCounter::SrcsetXDescriptor);
    }
    if (layoutObject() && layoutObject()->isImage())
        toLayoutImage(layoutObject())->setImageDevicePixelRatio(m_imageDevicePixelRatio);
}