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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLImageElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
index 6c492e273da854fdbb0747be8ecc5d36c61fde20..b9033e31d7925222a33d1dbd16abb4df5c32aa06 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
@@ -269,7 +269,7 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
if (text && text->textContent() != value)
text->setTextContent(altText());
}
- } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) {
+ } else if (name == srcAttr || ((name == srcsetAttr || name == sizesAttr) && (value != oldValue))) {
selectSourceURL(ImageLoader::UpdateIgnorePreviousError);
} else if (name == usemapAttr) {
setIsLink(!value.isNull());
@@ -399,19 +399,26 @@ Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode*
// If we have been inserted from a layoutObject-less document,
// our loader may have not fetched the image, so do it now.
- if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModified)
+ if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModified || isHTMLPictureElement(insertionPoint))
imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPolicy);
return HTMLElement::insertedInto(insertionPoint);
}
-void HTMLImageElement::removedFrom(ContainerNode* insertionPoint)
+void HTMLImageElement::removedFrom(ContainerNode* insertionPoint, Node* next)
{
if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTraversal::highestAncestorOrSelf(*this))
resetFormOwner();
if (m_listener)
document().mediaQueryMatcher().removeViewportListener(m_listener);
- HTMLElement::removedFrom(insertionPoint);
+ HTMLElement::removedFrom(insertionPoint, next);
+
+ if (isHTMLPictureElement(insertionPoint)) {
+ // This is diverging from the spec because we don't want to trigger spurious downloads of fallback images.
+ // See https://github.com/ResponsiveImagesCG/picture-element/issues/274
+ m_bestFitImageURL = AtomicString();
+ imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPolicy);
+ }
}
int HTMLImageElement::width()

Powered by Google App Engine
This is Rietveld 408576698