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

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

Issue 69543007: Have NodeTraversal::nextSkippingChildren() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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
« no previous file with comments | « Source/core/editing/markup.cpp ('k') | Source/core/html/HTMLDialogElement.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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (type() == DocAll && !nameShouldBeVisibleInDocumentAll(e)) 522 if (type() == DocAll && !nameShouldBeVisibleInDocumentAll(e))
523 return false; 523 return false;
524 524
525 return e->getNameAttribute() == name && e->getIdAttribute() != name; 525 return e->getNameAttribute() == name && e->getIdAttribute() != name;
526 } 526 }
527 527
528 inline Element* firstMatchingChildElement(const HTMLCollection* nodeList, Contai nerNode* root) 528 inline Element* firstMatchingChildElement(const HTMLCollection* nodeList, Contai nerNode* root)
529 { 529 {
530 Element* element = ElementTraversal::firstWithin(root); 530 Element* element = ElementTraversal::firstWithin(root);
531 while (element && !isMatchingElement(nodeList, element)) 531 while (element && !isMatchingElement(nodeList, element))
532 element = ElementTraversal::nextSkippingChildren(element, root); 532 element = ElementTraversal::nextSkippingChildren(*element, root);
533 return element; 533 return element;
534 } 534 }
535 535
536 inline Element* nextMatchingChildElement(const HTMLCollection* nodeList, Element * current, ContainerNode* root) 536 inline Element* nextMatchingChildElement(const HTMLCollection* nodeList, Element & current, ContainerNode* root)
537 { 537 {
538 Element* next = &current;
538 do { 539 do {
539 current = ElementTraversal::nextSkippingChildren(current, root); 540 next = ElementTraversal::nextSkippingChildren(*next, root);
540 } while (current && !isMatchingElement(nodeList, current)); 541 } while (next && !isMatchingElement(nodeList, next));
541 return current; 542 return next;
542 } 543 }
543 544
544 inline Element* HTMLCollection::traverseFirstElement(unsigned& offsetInArray, Co ntainerNode* root) const 545 inline Element* HTMLCollection::traverseFirstElement(unsigned& offsetInArray, Co ntainerNode* root) const
545 { 546 {
546 if (overridesItemAfter()) 547 if (overridesItemAfter())
547 return virtualItemAfter(offsetInArray, 0); 548 return virtualItemAfter(offsetInArray, 0);
548 ASSERT(!offsetInArray); 549 ASSERT(!offsetInArray);
549 if (shouldOnlyIncludeDirectChildren()) 550 if (shouldOnlyIncludeDirectChildren())
550 return firstMatchingChildElement(static_cast<const HTMLCollection*>(this ), root); 551 return firstMatchingChildElement(static_cast<const HTMLCollection*>(this ), root);
551 return firstMatchingElement(static_cast<const HTMLCollection*>(this), root); 552 return firstMatchingElement(static_cast<const HTMLCollection*>(this), root);
552 } 553 }
553 554
554 inline Element* HTMLCollection::traverseNextElement(unsigned& offsetInArray, Ele ment& previous, ContainerNode* root) const 555 inline Element* HTMLCollection::traverseNextElement(unsigned& offsetInArray, Ele ment& previous, ContainerNode* root) const
555 { 556 {
556 if (overridesItemAfter()) 557 if (overridesItemAfter())
557 return virtualItemAfter(offsetInArray, &previous); 558 return virtualItemAfter(offsetInArray, &previous);
558 ASSERT(!offsetInArray); 559 ASSERT(!offsetInArray);
559 if (shouldOnlyIncludeDirectChildren()) 560 if (shouldOnlyIncludeDirectChildren())
560 return nextMatchingChildElement(this, &previous, root); 561 return nextMatchingChildElement(this, previous, root);
561 return nextMatchingElement(this, previous, root); 562 return nextMatchingElement(this, previous, root);
562 } 563 }
563 564
564 inline Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element & currentElement, unsigned& currentOffset, unsigned& offsetInArray, ContainerNod e* root) const 565 inline Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element & currentElement, unsigned& currentOffset, unsigned& offsetInArray, ContainerNod e* root) const
565 { 566 {
566 ASSERT(currentOffset < offset); 567 ASSERT(currentOffset < offset);
567 if (overridesItemAfter()) { 568 if (overridesItemAfter()) {
568 offsetInArray = m_cachedElementsArrayOffset; 569 offsetInArray = m_cachedElementsArrayOffset;
569 Element* next = &currentElement; 570 Element* next = &currentElement;
570 while ((next = virtualItemAfter(offsetInArray, next))) { 571 while ((next = virtualItemAfter(offsetInArray, next))) {
571 if (++currentOffset == offset) 572 if (++currentOffset == offset)
572 return next; 573 return next;
573 } 574 }
574 return 0; 575 return 0;
575 } 576 }
576 if (shouldOnlyIncludeDirectChildren()) { 577 if (shouldOnlyIncludeDirectChildren()) {
577 Element* next = &currentElement; 578 Element* next = &currentElement;
578 while ((next = nextMatchingChildElement(this, next, root))) { 579 while ((next = nextMatchingChildElement(this, *next, root))) {
579 if (++currentOffset == offset) 580 if (++currentOffset == offset)
580 return next; 581 return next;
581 } 582 }
582 return 0; 583 return 0;
583 } 584 }
584 return traverseMatchingElementsForwardToOffset(this, offset, currentElement, currentOffset, root); 585 return traverseMatchingElementsForwardToOffset(this, offset, currentElement, currentOffset, root);
585 } 586 }
586 587
587 Node* HTMLCollection::namedItem(const AtomicString& name) const 588 Node* HTMLCollection::namedItem(const AtomicString& name) const
588 { 589 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 683
683 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element) 684 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element)
684 { 685 {
685 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue; 686 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue;
686 if (!vector) 687 if (!vector)
687 vector = adoptPtr(new Vector<Element*>); 688 vector = adoptPtr(new Vector<Element*>);
688 vector->append(element); 689 vector->append(element);
689 } 690 }
690 691
691 } // namespace WebCore 692 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/markup.cpp ('k') | Source/core/html/HTMLDialogElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698