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

Unified Diff: third_party/WebKit/Source/core/html/HTMLPictureElement.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/HTMLPictureElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLPictureElement.cpp b/third_party/WebKit/Source/core/html/HTMLPictureElement.cpp
index f71379d9380dfb70f566c90e38b603870d037655..a3d1ab407096a5db4fccb50ae2d0045c5c861783 100644
--- a/third_party/WebKit/Source/core/html/HTMLPictureElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLPictureElement.cpp
@@ -9,6 +9,7 @@
#include "core/dom/ElementTraversal.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLImageElement.h"
+#include "core/html/HTMLSourceElement.h"
#include "core/loader/ImageLoader.h"
namespace blink {
@@ -22,10 +23,19 @@ inline HTMLPictureElement::HTMLPictureElement(Document& document)
DEFINE_NODE_FACTORY(HTMLPictureElement)
-void HTMLPictureElement::sourceOrMediaChanged()
+void HTMLPictureElement::sourceOrMediaChanged(HTMLElement* sourceElement, Node* next)
{
- for (HTMLImageElement* imageElement = Traversal<HTMLImageElement>::firstChild(*this); imageElement; imageElement = Traversal<HTMLImageElement>::nextSibling(*imageElement)) {
- imageElement->selectSourceURL(ImageLoader::UpdateNormal);
+ bool seenSource = false;
+ Node* node;
+ NodeVector potentialSourceNodes;
+ getChildNodes(*this, potentialSourceNodes);
esprehn 2015/12/14 22:52:42 This copies every kid into a vector, if you're rem
+
+ for (unsigned i = 0; i < potentialSourceNodes.size(); ++i) {
+ node = potentialSourceNodes[i].get();
+ if (sourceElement == node || (next && node == next))
+ seenSource = true;
+ if (isHTMLImageElement(node) && seenSource)
+ toHTMLImageElement(node)->selectSourceURL(ImageLoader::UpdateNormal);
}
}

Powered by Google App Engine
This is Rietveld 408576698