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

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 572043002: Support getComputedStyle for non-rendered pseudo elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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/PseudoStyleRequest.h ('k') | Source/core/dom/Element.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) 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 StyleResolverParentScope::ensureParentStackIsPushed(); 769 StyleResolverParentScope::ensureParentStackIsPushed();
770 770
771 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { 771 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
772 state.setStyle(RenderStyle::create()); 772 state.setStyle(RenderStyle::create());
773 state.style()->inheritFrom(state.parentStyle()); 773 state.style()->inheritFrom(state.parentStyle());
774 } else { 774 } else {
775 state.setStyle(defaultStyleForElement()); 775 state.setStyle(defaultStyleForElement());
776 state.setParentStyle(RenderStyle::clone(state.style())); 776 state.setParentStyle(RenderStyle::clone(state.style()));
777 } 777 }
778 778
779 state.style()->setStyleType(pseudoStyleRequest.pseudoId);
779 state.fontBuilder().initForStyleResolve(state.document(), state.style()); 780 state.fontBuilder().initForStyleResolve(state.document(), state.style());
780 781
781 // Since we don't use pseudo-elements in any of our quirk/print 782 // Since we don't use pseudo-elements in any of our quirk/print
782 // user agent rules, don't waste time walking those rules. 783 // user agent rules, don't waste time walking those rules.
783 784
784 { 785 {
785 // Check UA, user and author rules. 786 // Check UA, user and author rules.
786 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); 787 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
787 collector.setPseudoStyleRequest(pseudoStyleRequest); 788 collector.setPseudoStyleRequest(pseudoStyleRequest);
788 789
789 matchUARules(collector); 790 matchUARules(collector);
790 matchAuthorRules(state.element(), collector, false); 791 matchAuthorRules(state.element(), collector, false);
791 792
792 if (collector.matchedResult().matchedProperties.isEmpty()) 793 if (collector.matchedResult().matchedProperties.isEmpty())
793 return false; 794 return false;
794 795
795 state.style()->setStyleType(pseudoStyleRequest.pseudoId);
796
797 applyMatchedProperties(state, collector.matchedResult()); 796 applyMatchedProperties(state, collector.matchedResult());
798 applyCallbackSelectors(state); 797 applyCallbackSelectors(state);
799 798
800 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); 799 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
801 } 800 }
802 801
803 // Cache our original display. 802 // Cache our original display.
804 state.style()->setOriginalDisplay(state.style()->display()); 803 state.style()->setOriginalDisplay(state.style()->display());
805 804
806 // FIXME: Passing 0 as the Element* introduces a lot of complexity 805 // FIXME: Passing 0 as the Element* introduces a lot of complexity
(...skipping 14 matching lines...) Expand all
821 return true; 820 return true;
822 } 821 }
823 822
824 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) 823 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
825 { 824 {
826 ASSERT(parentStyle); 825 ASSERT(parentStyle);
827 if (!element) 826 if (!element)
828 return nullptr; 827 return nullptr;
829 828
830 StyleResolverState state(document(), element, parentStyle); 829 StyleResolverState state(document(), element, parentStyle);
831 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle , state)) 830 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle , state)) {
832 return nullptr; 831 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer)
esprehn 2014/09/17 19:04:42 This doesn't make sense, pseudoStyleForElementInte
rune 2014/09/17 20:00:33 http://www.w3.org/TR/CSS2/generate.html#before-aft
832 return nullptr;
833 return state.takeStyle();
834 }
833 835
834 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest .pseudoId)) 836 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest .pseudoId))
835 setAnimationUpdateIfNeeded(state, *pseudoElement); 837 setAnimationUpdateIfNeeded(state, *pseudoElement);
836 838
837 // Now return the style. 839 // Now return the style.
838 return state.takeStyle(); 840 return state.takeStyle();
839 } 841 }
840 842
841 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) 843 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
842 { 844 {
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 visitor->trace(m_uncommonAttributeRuleSet); 1594 visitor->trace(m_uncommonAttributeRuleSet);
1593 visitor->trace(m_watchedSelectorsRules); 1595 visitor->trace(m_watchedSelectorsRules);
1594 visitor->trace(m_treeBoundaryCrossingRules); 1596 visitor->trace(m_treeBoundaryCrossingRules);
1595 visitor->trace(m_styleSharingLists); 1597 visitor->trace(m_styleSharingLists);
1596 visitor->trace(m_pendingStyleSheets); 1598 visitor->trace(m_pendingStyleSheets);
1597 visitor->trace(m_document); 1599 visitor->trace(m_document);
1598 #endif 1600 #endif
1599 } 1601 }
1600 1602
1601 } // namespace blink 1603 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/PseudoStyleRequest.h ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698