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

Side by Side Diff: Source/core/html/HTMLFormElement.cpp

Issue 239703007: Rename Node::lastDescendant() / Node::highestAncestor() for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename highestAncestor() as well Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLImageElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 for (size_t i = 0; i < size; ++i) 129 for (size_t i = 0; i < size; ++i)
130 elements[i]->formRemovedFromTree(root); 130 elements[i]->formRemovedFromTree(root);
131 ASSERT(elements.size() == size); 131 ASSERT(elements.size() == size);
132 } 132 }
133 133
134 void HTMLFormElement::removedFrom(ContainerNode* insertionPoint) 134 void HTMLFormElement::removedFrom(ContainerNode* insertionPoint)
135 { 135 {
136 // We don't need to take care of form association by 'form' content 136 // We don't need to take care of form association by 'form' content
137 // attribute becuse IdTargetObserver handles it. 137 // attribute becuse IdTargetObserver handles it.
138 if (m_hasElementsAssociatedByParser) { 138 if (m_hasElementsAssociatedByParser) {
139 Node& root = highestAncestor(); 139 Node& root = highestAncestorOrSelf();
140 if (!m_associatedElementsAreDirty) { 140 if (!m_associatedElementsAreDirty) {
141 Vector<FormAssociatedElement*> elements(associatedElements()); 141 Vector<FormAssociatedElement*> elements(associatedElements());
142 notifyFormRemovedFromTree(elements, root); 142 notifyFormRemovedFromTree(elements, root);
143 } else { 143 } else {
144 Vector<FormAssociatedElement*> elements; 144 Vector<FormAssociatedElement*> elements;
145 collectAssociatedElements(insertionPoint->highestAncestor(), element s); 145 collectAssociatedElements(insertionPoint->highestAncestorOrSelf(), e lements);
146 notifyFormRemovedFromTree(elements, root); 146 notifyFormRemovedFromTree(elements, root);
147 collectAssociatedElements(root, elements); 147 collectAssociatedElements(root, elements);
148 notifyFormRemovedFromTree(elements, root); 148 notifyFormRemovedFromTree(elements, root);
149 } 149 }
150 150
151 if (!m_imageElementsAreDirty) { 151 if (!m_imageElementsAreDirty) {
152 Vector<HTMLImageElement*> images(imageElements()); 152 Vector<HTMLImageElement*> images(imageElements());
153 notifyFormRemovedFromTree(images, root); 153 notifyFormRemovedFromTree(images, root);
154 } else { 154 } else {
155 Vector<HTMLImageElement*> images; 155 Vector<HTMLImageElement*> images;
156 collectImageElements(insertionPoint->highestAncestor(), images); 156 collectImageElements(insertionPoint->highestAncestorOrSelf(), images );
157 notifyFormRemovedFromTree(images, root); 157 notifyFormRemovedFromTree(images, root);
158 collectImageElements(root, images); 158 collectImageElements(root, images);
159 notifyFormRemovedFromTree(images, root); 159 notifyFormRemovedFromTree(images, root);
160 } 160 }
161 } 161 }
162 HTMLElement::removedFrom(insertionPoint); 162 HTMLElement::removedFrom(insertionPoint);
163 } 163 }
164 164
165 void HTMLFormElement::handleLocalEvents(Event* event) 165 void HTMLFormElement::handleLocalEvents(Event* event)
166 { 166 {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 // This function should be const conceptually. However we update some fields 558 // This function should be const conceptually. However we update some fields
559 // because of lazy evaluation. 559 // because of lazy evaluation.
560 const Vector<FormAssociatedElement*>& HTMLFormElement::associatedElements() cons t 560 const Vector<FormAssociatedElement*>& HTMLFormElement::associatedElements() cons t
561 { 561 {
562 if (!m_associatedElementsAreDirty) 562 if (!m_associatedElementsAreDirty)
563 return m_associatedElements; 563 return m_associatedElements;
564 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this); 564 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this);
565 Node* scope = mutableThis; 565 Node* scope = mutableThis;
566 if (m_hasElementsAssociatedByParser) 566 if (m_hasElementsAssociatedByParser)
567 scope = &highestAncestor(); 567 scope = &highestAncestorOrSelf();
568 if (inDocument() && treeScope().idTargetObserverRegistry().hasObservers(fast GetAttribute(idAttr))) 568 if (inDocument() && treeScope().idTargetObserverRegistry().hasObservers(fast GetAttribute(idAttr)))
569 scope = &treeScope().rootNode(); 569 scope = &treeScope().rootNode();
570 ASSERT(scope); 570 ASSERT(scope);
571 collectAssociatedElements(*scope, mutableThis->m_associatedElements); 571 collectAssociatedElements(*scope, mutableThis->m_associatedElements);
572 mutableThis->m_associatedElementsAreDirty = false; 572 mutableThis->m_associatedElementsAreDirty = false;
573 return m_associatedElements; 573 return m_associatedElements;
574 } 574 }
575 575
576 void HTMLFormElement::collectImageElements(Node& root, Vector<HTMLImageElement*> & elements) 576 void HTMLFormElement::collectImageElements(Node& root, Vector<HTMLImageElement*> & elements)
577 { 577 {
578 elements.clear(); 578 elements.clear();
579 for (HTMLImageElement* image = Traversal<HTMLImageElement>::firstWithin(root ); image; image = Traversal<HTMLImageElement>::next(*image)) { 579 for (HTMLImageElement* image = Traversal<HTMLImageElement>::firstWithin(root ); image; image = Traversal<HTMLImageElement>::next(*image)) {
580 if (image->formOwner() == this) 580 if (image->formOwner() == this)
581 elements.append(image); 581 elements.append(image);
582 } 582 }
583 } 583 }
584 584
585 const Vector<HTMLImageElement*>& HTMLFormElement::imageElements() 585 const Vector<HTMLImageElement*>& HTMLFormElement::imageElements()
586 { 586 {
587 if (!m_imageElementsAreDirty) 587 if (!m_imageElementsAreDirty)
588 return m_imageElements; 588 return m_imageElements;
589 collectImageElements(m_hasElementsAssociatedByParser ? highestAncestor() : * this, m_imageElements); 589 collectImageElements(m_hasElementsAssociatedByParser ? highestAncestorOrSelf () : *this, m_imageElements);
590 m_imageElementsAreDirty = false; 590 m_imageElementsAreDirty = false;
591 return m_imageElements; 591 return m_imageElements;
592 } 592 }
593 593
594 String HTMLFormElement::name() const 594 String HTMLFormElement::name() const
595 { 595 {
596 return getNameAttribute(); 596 return getNameAttribute();
597 } 597 }
598 598
599 bool HTMLFormElement::noValidate() const 599 bool HTMLFormElement::noValidate() const
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 779
780 void HTMLFormElement::setDemoted(bool demoted) 780 void HTMLFormElement::setDemoted(bool demoted)
781 { 781 {
782 if (demoted) 782 if (demoted)
783 UseCounter::count(document(), UseCounter::DemotedFormElement); 783 UseCounter::count(document(), UseCounter::DemotedFormElement);
784 m_wasDemoted = demoted; 784 m_wasDemoted = demoted;
785 } 785 }
786 786
787 } // namespace 787 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLImageElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698