Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 else if (element.renderStyle() && (element.document().styleEngin e()->usesSiblingRules() || element.renderStyle()->unique())) | 611 else if (element.renderStyle() && (element.document().styleEngin e()->usesSiblingRules() || element.renderStyle()->unique())) |
| 612 element.renderStyle()->setEmptyState(result); | 612 element.renderStyle()->setEmptyState(result); |
| 613 } | 613 } |
| 614 return result; | 614 return result; |
| 615 } | 615 } |
| 616 case CSSSelector::PseudoFirstChild: | 616 case CSSSelector::PseudoFirstChild: |
| 617 // first-child matches the first child that is an element | 617 // first-child matches the first child that is an element |
| 618 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 618 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 619 bool result = siblingTraversalStrategy.isFirstChild(element); | 619 bool result = siblingTraversalStrategy.isFirstChild(element); |
| 620 if (m_mode == ResolvingStyle) { | 620 if (m_mode == ResolvingStyle) { |
| 621 RenderStyle* childStyle = context.elementStyle ? context.element Style : element.renderStyle(); | |
| 622 parent->setChildrenAffectedByFirstChildRules(); | 621 parent->setChildrenAffectedByFirstChildRules(); |
| 623 if (result && childStyle) | 622 element.setAffectedByFirstChildRules(); |
| 624 childStyle->setFirstChildState(); | |
| 625 } | 623 } |
| 626 return result; | 624 return result; |
| 627 } | 625 } |
| 628 break; | 626 break; |
| 629 case CSSSelector::PseudoFirstOfType: | 627 case CSSSelector::PseudoFirstOfType: |
| 630 // first-of-type matches the first element of its type | 628 // first-of-type matches the first element of its type |
| 631 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 629 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 632 bool result = siblingTraversalStrategy.isFirstOfType(element, elemen t.tagQName()); | 630 bool result = siblingTraversalStrategy.isFirstOfType(element, elemen t.tagQName()); |
| 633 if (m_mode == ResolvingStyle) | 631 if (m_mode == ResolvingStyle) |
| 634 parent->setChildrenAffectedByForwardPositionalRules(); | 632 parent->setChildrenAffectedByForwardPositionalRules(); |
| 635 return result; | 633 return result; |
| 636 } | 634 } |
| 637 break; | 635 break; |
| 638 case CSSSelector::PseudoLastChild: | 636 case CSSSelector::PseudoLastChild: |
| 639 // last-child matches the last child that is an element | 637 // last-child matches the last child that is an element |
| 640 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 638 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 641 bool result = parent->isFinishedParsingChildren() && siblingTraversa lStrategy.isLastChild(element); | 639 bool result = parent->isFinishedParsingChildren() && siblingTraversa lStrategy.isLastChild(element); |
| 642 if (m_mode == ResolvingStyle) { | 640 if (m_mode == ResolvingStyle) { |
| 643 RenderStyle* childStyle = context.elementStyle ? context.element Style : element.renderStyle(); | |
| 644 parent->setChildrenAffectedByLastChildRules(); | 641 parent->setChildrenAffectedByLastChildRules(); |
| 645 if (result && childStyle) | 642 element.setAffectedByLastChildRules(); |
| 646 childStyle->setLastChildState(); | |
| 647 } | 643 } |
| 648 return result; | 644 return result; |
| 649 } | 645 } |
| 650 break; | 646 break; |
| 651 case CSSSelector::PseudoLastOfType: | 647 case CSSSelector::PseudoLastOfType: |
| 652 // last-of-type matches the last element of its type | 648 // last-of-type matches the last element of its type |
| 653 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 649 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 654 if (m_mode == ResolvingStyle) | 650 if (m_mode == ResolvingStyle) |
| 655 parent->setChildrenAffectedByBackwardPositionalRules(); | 651 parent->setChildrenAffectedByBackwardPositionalRules(); |
| 656 if (!parent->isFinishedParsingChildren()) | 652 if (!parent->isFinishedParsingChildren()) |
| 657 return false; | 653 return false; |
| 658 return siblingTraversalStrategy.isLastOfType(element, element.tagQNa me()); | 654 return siblingTraversalStrategy.isLastOfType(element, element.tagQNa me()); |
| 659 } | 655 } |
| 660 break; | 656 break; |
| 661 case CSSSelector::PseudoOnlyChild: | 657 case CSSSelector::PseudoOnlyChild: |
| 662 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 658 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 663 bool firstChild = siblingTraversalStrategy.isFirstChild(element); | 659 bool firstChild = siblingTraversalStrategy.isFirstChild(element); |
| 664 bool onlyChild = firstChild && parent->isFinishedParsingChildren() & & siblingTraversalStrategy.isLastChild(element); | 660 bool onlyChild = firstChild && parent->isFinishedParsingChildren() & & siblingTraversalStrategy.isLastChild(element); |
| 665 if (m_mode == ResolvingStyle) { | 661 if (m_mode == ResolvingStyle) { |
| 666 RenderStyle* childStyle = context.elementStyle ? context.element Style : element.renderStyle(); | |
| 667 parent->setChildrenAffectedByFirstChildRules(); | 662 parent->setChildrenAffectedByFirstChildRules(); |
| 668 parent->setChildrenAffectedByLastChildRules(); | 663 parent->setChildrenAffectedByLastChildRules(); |
| 669 if (firstChild && childStyle) | 664 element.setAffectedByFirstChildRules(); |
| 670 childStyle->setFirstChildState(); | 665 element.setAffectedByLastChildRules(); |
|
esprehn
2014/11/24 18:46:05
Why not check firstChild and onlyChild like before
| |
| 671 if (onlyChild && childStyle) | |
| 672 childStyle->setLastChildState(); | |
| 673 } | 666 } |
| 674 return onlyChild; | 667 return onlyChild; |
| 675 } | 668 } |
| 676 break; | 669 break; |
| 677 case CSSSelector::PseudoOnlyOfType: | 670 case CSSSelector::PseudoOnlyOfType: |
| 678 // FIXME: This selector is very slow. | 671 // FIXME: This selector is very slow. |
| 679 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { | 672 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { |
| 680 if (m_mode == ResolvingStyle) { | 673 if (m_mode == ResolvingStyle) { |
| 681 parent->setChildrenAffectedByForwardPositionalRules(); | 674 parent->setChildrenAffectedByForwardPositionalRules(); |
| 682 parent->setChildrenAffectedByBackwardPositionalRules(); | 675 parent->setChildrenAffectedByBackwardPositionalRules(); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 return isHTMLSelectElement(element) && !toHTMLSelectElement(element).usesMen uList(); | 1173 return isHTMLSelectElement(element) && !toHTMLSelectElement(element).usesMen uList(); |
| 1181 } | 1174 } |
| 1182 | 1175 |
| 1183 template | 1176 template |
| 1184 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; | 1177 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; |
| 1185 | 1178 |
| 1186 template | 1179 template |
| 1187 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; | 1180 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; |
| 1188 | 1181 |
| 1189 } | 1182 } |
| OLD | NEW |