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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/HTMLPictureElement.h" 6 #include "core/html/HTMLPictureElement.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/dom/ElementTraversal.h" 9 #include "core/dom/ElementTraversal.h"
10 #include "core/frame/UseCounter.h" 10 #include "core/frame/UseCounter.h"
11 #include "core/html/HTMLImageElement.h" 11 #include "core/html/HTMLImageElement.h"
12 #include "core/html/HTMLSourceElement.h"
12 #include "core/loader/ImageLoader.h" 13 #include "core/loader/ImageLoader.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 using namespace HTMLNames; 17 using namespace HTMLNames;
17 18
18 inline HTMLPictureElement::HTMLPictureElement(Document& document) 19 inline HTMLPictureElement::HTMLPictureElement(Document& document)
19 : HTMLElement(pictureTag, document) 20 : HTMLElement(pictureTag, document)
20 { 21 {
21 } 22 }
22 23
23 DEFINE_NODE_FACTORY(HTMLPictureElement) 24 DEFINE_NODE_FACTORY(HTMLPictureElement)
24 25
25 void HTMLPictureElement::sourceOrMediaChanged() 26 void HTMLPictureElement::sourceOrMediaChanged(HTMLElement* sourceElement, Node* next)
26 { 27 {
27 for (HTMLImageElement* imageElement = Traversal<HTMLImageElement>::firstChil d(*this); imageElement; imageElement = Traversal<HTMLImageElement>::nextSibling( *imageElement)) { 28 bool seenSource = false;
28 imageElement->selectSourceURL(ImageLoader::UpdateNormal); 29 Node* node;
30 NodeVector potentialSourceNodes;
31 getChildNodes(*this, potentialSourceNodes);
esprehn 2015/12/14 22:52:42 This copies every kid into a vector, if you're rem
32
33 for (unsigned i = 0; i < potentialSourceNodes.size(); ++i) {
34 node = potentialSourceNodes[i].get();
35 if (sourceElement == node || (next && node == next))
36 seenSource = true;
37 if (isHTMLImageElement(node) && seenSource)
38 toHTMLImageElement(node)->selectSourceURL(ImageLoader::UpdateNormal) ;
29 } 39 }
30 } 40 }
31 41
32 Node::InsertionNotificationRequest HTMLPictureElement::insertedInto(ContainerNod e* insertionPoint) 42 Node::InsertionNotificationRequest HTMLPictureElement::insertedInto(ContainerNod e* insertionPoint)
33 { 43 {
34 UseCounter::count(document(), UseCounter::Picture); 44 UseCounter::count(document(), UseCounter::Picture);
35 return HTMLElement::insertedInto(insertionPoint); 45 return HTMLElement::insertedInto(insertionPoint);
36 } 46 }
37 47
38 } // namespace 48 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698