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

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: Adding a mitigation for the perf regression to Element::recalcStyle. Created 7 years, 5 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
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/css/SiblingTraversalStrategies.h » ('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) 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 if (!parentElement->isFinishedParsingChildren()) 489 if (!parentElement->isFinishedParsingChildren())
490 return false; 490 return false;
491 return siblingTraversalStrategy.isFirstOfType(element, element-> tagQName()) && siblingTraversalStrategy.isLastOfType(element, element->tagQName( )); 491 return siblingTraversalStrategy.isFirstOfType(element, element-> tagQName()) && siblingTraversalStrategy.isLastOfType(element, element->tagQName( ));
492 } 492 }
493 break; 493 break;
494 case CSSSelector::PseudoNthChild: 494 case CSSSelector::PseudoNthChild:
495 if (!selector->parseNth()) 495 if (!selector->parseNth())
496 break; 496 break;
497 if (Element* parentElement = element->parentElement()) { 497 if (Element* parentElement = element->parentElement()) {
498 int count = 1 + siblingTraversalStrategy.countElementsBefore(ele ment); 498 // FIXME: We should always have the index passed in to avoid nee ding countElementsBefore.
499 int count = context.childIndex ? context.childIndex : 1 + siblin gTraversalStrategy.countElementsBefore(element);
499 if (m_mode == ResolvingStyle) { 500 if (m_mode == ResolvingStyle) {
500 RenderStyle* childStyle = context.elementStyle ? context.ele mentStyle : element->renderStyle(); 501 RenderStyle* childStyle = context.elementStyle ? context.ele mentStyle : element->renderStyle();
501 element->setChildIndex(count); 502 element->setChildIndex(count);
502 if (childStyle) 503 if (childStyle)
503 childStyle->setUnique(); 504 childStyle->setUnique();
504 parentElement->setChildrenAffectedByForwardPositionalRules() ; 505 parentElement->setChildrenAffectedByForwardPositionalRules() ;
505 } 506 }
506 507
507 if (selector->matchNth(count)) 508 if (selector->matchNth(count))
508 return true; 509 return true;
(...skipping 12 matching lines...) Expand all
521 } 522 }
522 break; 523 break;
523 case CSSSelector::PseudoNthLastChild: 524 case CSSSelector::PseudoNthLastChild:
524 if (!selector->parseNth()) 525 if (!selector->parseNth())
525 break; 526 break;
526 if (Element* parentElement = element->parentElement()) { 527 if (Element* parentElement = element->parentElement()) {
527 if (m_mode == ResolvingStyle) 528 if (m_mode == ResolvingStyle)
528 parentElement->setChildrenAffectedByBackwardPositionalRules( ); 529 parentElement->setChildrenAffectedByBackwardPositionalRules( );
529 if (!parentElement->isFinishedParsingChildren()) 530 if (!parentElement->isFinishedParsingChildren())
530 return false; 531 return false;
531 int count = 1 + siblingTraversalStrategy.countElementsAfter(elem ent); 532 // FIXME: We should always have the index passed in to avoid nee ding countElementsAfter.
533 int count = context.childIndex ? context.childIndex : 1 + siblin gTraversalStrategy.countElementsAfter(element);
532 if (selector->matchNth(count)) 534 if (selector->matchNth(count))
533 return true; 535 return true;
534 } 536 }
535 break; 537 break;
536 case CSSSelector::PseudoNthLastOfType: 538 case CSSSelector::PseudoNthLastOfType:
537 if (!selector->parseNth()) 539 if (!selector->parseNth())
538 break; 540 break;
539 if (Element* parentElement = element->parentElement()) { 541 if (Element* parentElement = element->parentElement()) {
540 if (m_mode == ResolvingStyle) 542 if (m_mode == ResolvingStyle)
541 parentElement->setChildrenAffectedByBackwardPositionalRules( ); 543 parentElement->setChildrenAffectedByBackwardPositionalRules( );
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 return element->focused() && isFrameFocused(element); 912 return element->focused() && isFrameFocused(element);
911 } 913 }
912 914
913 template 915 template
914 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const DOMSiblingTraversalStrategy&) const; 916 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const DOMSiblingTraversalStrategy&) const;
915 917
916 template 918 template
917 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const ShadowDOMSiblingTraversalStrategy&) const; 919 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, Ps eudoId&, const ShadowDOMSiblingTraversalStrategy&) const;
918 920
919 } 921 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/css/SiblingTraversalStrategies.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698