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

Side by Side Diff: Source/core/css/SelectorChecker.cpp

Issue 15871005: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Merging ToT Created 7 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 487 }
488 if (!parentElement->isFinishedParsingChildren()) 488 if (!parentElement->isFinishedParsingChildren())
489 return false; 489 return false;
490 return siblingTraversalStrategy.isFirstOfType(element, element-> tagQName()) && siblingTraversalStrategy.isLastOfType(element, element->tagQName( )); 490 return siblingTraversalStrategy.isFirstOfType(element, element-> tagQName()) && siblingTraversalStrategy.isLastOfType(element, element->tagQName( ));
491 } 491 }
492 break; 492 break;
493 case CSSSelector::PseudoNthChild: 493 case CSSSelector::PseudoNthChild:
494 if (!selector->parseNth()) 494 if (!selector->parseNth())
495 break; 495 break;
496 if (Element* parentElement = element->parentElement()) { 496 if (Element* parentElement = element->parentElement()) {
497 int count = 1 + siblingTraversalStrategy.countElementsBefore(ele ment); 497 // FIXME: We should always have the index passed in to avoid nee ding countElementsBefore.
498 int count = context.childIndex ? context.childIndex : 1 + siblin gTraversalStrategy.countElementsBefore(element);
ojan 2013/05/31 18:05:07 Not sure where, but that childIndices start at 1 p
498 if (m_mode == ResolvingStyle) { 499 if (m_mode == ResolvingStyle) {
499 RenderStyle* childStyle = context.elementStyle ? context.ele mentStyle : element->renderStyle(); 500 RenderStyle* childStyle = context.elementStyle ? context.ele mentStyle : element->renderStyle();
500 element->setChildIndex(count); 501 element->setChildIndex(count);
501 if (childStyle) 502 if (childStyle)
502 childStyle->setUnique(); 503 childStyle->setUnique();
503 parentElement->setChildrenAffectedByForwardPositionalRules() ; 504 parentElement->setChildrenAffectedByForwardPositionalRules() ;
504 } 505 }
505 506
506 if (selector->matchNth(count)) 507 if (selector->matchNth(count))
507 return true; 508 return true;
(...skipping 12 matching lines...) Expand all
520 } 521 }
521 break; 522 break;
522 case CSSSelector::PseudoNthLastChild: 523 case CSSSelector::PseudoNthLastChild:
523 if (!selector->parseNth()) 524 if (!selector->parseNth())
524 break; 525 break;
525 if (Element* parentElement = element->parentElement()) { 526 if (Element* parentElement = element->parentElement()) {
526 if (m_mode == ResolvingStyle) 527 if (m_mode == ResolvingStyle)
527 parentElement->setChildrenAffectedByBackwardPositionalRules( ); 528 parentElement->setChildrenAffectedByBackwardPositionalRules( );
528 if (!parentElement->isFinishedParsingChildren()) 529 if (!parentElement->isFinishedParsingChildren())
529 return false; 530 return false;
530 int count = 1 + siblingTraversalStrategy.countElementsAfter(elem ent); 531 // FIXME: We should always have the index passed in to avoid nee ding countElementsAfter.
532 int count = context.childIndex ? context.childIndex : 1 + siblin gTraversalStrategy.countElementsAfter(element);
531 if (selector->matchNth(count)) 533 if (selector->matchNth(count))
532 return true; 534 return true;
533 } 535 }
534 break; 536 break;
535 case CSSSelector::PseudoNthLastOfType: 537 case CSSSelector::PseudoNthLastOfType:
536 if (!selector->parseNth()) 538 if (!selector->parseNth())
537 break; 539 break;
538 if (Element* parentElement = element->parentElement()) { 540 if (Element* parentElement = element->parentElement()) {
539 if (m_mode == ResolvingStyle) 541 if (m_mode == ResolvingStyle)
540 parentElement->setChildrenAffectedByBackwardPositionalRules( ); 542 parentElement->setChildrenAffectedByBackwardPositionalRules( );
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 return element->focused() && isFrameFocused(element); 909 return element->focused() && isFrameFocused(element);
908 } 910 }
909 911
910 template 912 template
911 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const DOMSiblingTraversalStrategy&) const; 913 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const DOMSiblingTraversalStrategy&) const;
912 914
913 template 915 template
914 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const ShadowDOMSiblingTraversalStrategy&) const; 916 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const ShadowDOMSiblingTraversalStrategy&) const;
915 917
916 } 918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698