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

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

Issue 1511523002: Align HTMLImageElement relevant mutations to spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix removal issue when a text node is between <source> and <img> 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) 263 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value)
264 { 264 {
265 if (name == altAttr || name == titleAttr) { 265 if (name == altAttr || name == titleAttr) {
266 if (userAgentShadowRoot()) { 266 if (userAgentShadowRoot()) {
267 Element* text = userAgentShadowRoot()->getElementById("alttext"); 267 Element* text = userAgentShadowRoot()->getElementById("alttext");
268 String value = altText(); 268 String value = altText();
269 if (text && text->textContent() != value) 269 if (text && text->textContent() != value)
270 text->setTextContent(altText()); 270 text->setTextContent(altText());
271 } 271 }
272 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { 272 } else if (name == srcAttr || ((name == srcsetAttr || name == sizesAttr) && (value != oldValue))) {
273 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); 273 selectSourceURL(ImageLoader::UpdateIgnorePreviousError);
274 } else if (name == usemapAttr) { 274 } else if (name == usemapAttr) {
275 setIsLink(!value.isNull()); 275 setIsLink(!value.isNull());
276 } else if (RuntimeEnabledFeatures::referrerPolicyAttributeEnabled() && name == referrerpolicyAttr) { 276 } else if (RuntimeEnabledFeatures::referrerPolicyAttributeEnabled() && name == referrerpolicyAttr) {
277 m_referrerPolicy = ReferrerPolicyDefault; 277 m_referrerPolicy = ReferrerPolicyDefault;
278 if (!value.isNull()) 278 if (!value.isNull())
279 SecurityPolicy::referrerPolicyFromString(value, &m_referrerPolicy); 279 SecurityPolicy::referrerPolicyFromString(value, &m_referrerPolicy);
280 } else { 280 } else {
281 HTMLElement::parseAttribute(name, oldValue, value); 281 HTMLElement::parseAttribute(name, oldValue, value);
282 } 282 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (document().isActive()) { 392 if (document().isActive()) {
393 ImageCandidate candidate = findBestFitImageFromPictureParent(); 393 ImageCandidate candidate = findBestFitImageFromPictureParent();
394 if (!candidate.isEmpty()) { 394 if (!candidate.isEmpty()) {
395 setBestFitURLAndDPRFromImageCandidate(candidate); 395 setBestFitURLAndDPRFromImageCandidate(candidate);
396 imageWasModified = true; 396 imageWasModified = true;
397 } 397 }
398 } 398 }
399 399
400 // If we have been inserted from a layoutObject-less document, 400 // If we have been inserted from a layoutObject-less document,
401 // our loader may have not fetched the image, so do it now. 401 // our loader may have not fetched the image, so do it now.
402 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied) 402 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied || isHTMLPictureElement(insertionPoint))
403 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy); 403 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy);
404 404
405 return HTMLElement::insertedInto(insertionPoint); 405 return HTMLElement::insertedInto(insertionPoint);
406 } 406 }
407 407
408 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) 408 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint, Node* next)
409 { 409 {
410 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) 410 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this))
411 resetFormOwner(); 411 resetFormOwner();
412 if (m_listener) 412 if (m_listener)
413 document().mediaQueryMatcher().removeViewportListener(m_listener); 413 document().mediaQueryMatcher().removeViewportListener(m_listener);
414 HTMLElement::removedFrom(insertionPoint); 414 HTMLElement::removedFrom(insertionPoint, next);
415
416 if (isHTMLPictureElement(insertionPoint)) {
417 // This is diverging from the spec because we don't want to trigger spur ious downloads of fallback images.
418 // See https://github.com/ResponsiveImagesCG/picture-element/issues/274
419 m_bestFitImageURL = AtomicString();
420 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy);
421 }
415 } 422 }
416 423
417 int HTMLImageElement::width() 424 int HTMLImageElement::width()
418 { 425 {
419 if (inActiveDocument()) 426 if (inActiveDocument())
420 document().updateLayoutIgnorePendingStylesheets(); 427 document().updateLayoutIgnorePendingStylesheets();
421 428
422 if (!layoutObject()) { 429 if (!layoutObject()) {
423 // check the attribute first for an explicit pixel value 430 // check the attribute first for an explicit pixel value
424 bool ok; 431 bool ok;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 { 814 {
808 ImageResource* image = cachedImage(); 815 ImageResource* image = cachedImage();
809 if (!image) 816 if (!image)
810 return IntSize(); 817 return IntSize();
811 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); 818 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f);
812 ASSERT(lSize.fraction().isZero()); 819 ASSERT(lSize.fraction().isZero());
813 return IntSize(lSize.width(), lSize.height()); 820 return IntSize(lSize.width(), lSize.height());
814 } 821 }
815 822
816 } 823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698