| 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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 811 |
| 812 PseudoElement* StyleResolver::createPseudoElement(Element* parent, | 812 PseudoElement* StyleResolver::createPseudoElement(Element* parent, |
| 813 PseudoId pseudoId) { | 813 PseudoId pseudoId) { |
| 814 if (pseudoId == PseudoIdFirstLetter) | 814 if (pseudoId == PseudoIdFirstLetter) |
| 815 return FirstLetterPseudoElement::create(parent); | 815 return FirstLetterPseudoElement::create(parent); |
| 816 return PseudoElement::create(parent, pseudoId); | 816 return PseudoElement::create(parent, pseudoId); |
| 817 } | 817 } |
| 818 | 818 |
| 819 PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent, | 819 PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent, |
| 820 PseudoId pseudoId) { | 820 PseudoId pseudoId) { |
| 821 if (!parent.isPseudoElementAllowed(pseudoId)) |
| 822 return nullptr; |
| 823 |
| 821 LayoutObject* parentLayoutObject = parent.layoutObject(); | 824 LayoutObject* parentLayoutObject = parent.layoutObject(); |
| 825 if (!parentLayoutObject) { |
| 826 DCHECK(parent.hasDisplayContentsStyle()); |
| 827 parentLayoutObject = LayoutTreeBuilderTraversal::parentLayoutObject(parent); |
| 828 } |
| 829 |
| 822 if (!parentLayoutObject) | 830 if (!parentLayoutObject) |
| 823 return nullptr; | 831 return nullptr; |
| 824 | 832 |
| 833 ComputedStyle* parentStyle = parent.mutableComputedStyle(); |
| 834 DCHECK(parentStyle); |
| 835 |
| 825 // The first letter pseudo element has to look up the tree and see if any | 836 // The first letter pseudo element has to look up the tree and see if any |
| 826 // of the ancestors are first letter. | 837 // of the ancestors are first letter. |
| 827 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && | 838 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && |
| 828 !parentLayoutObject->style()->hasPseudoStyle(pseudoId)) | 839 !parentStyle->hasPseudoStyle(pseudoId)) { |
| 829 return nullptr; | 840 return nullptr; |
| 841 } |
| 830 | 842 |
| 831 if (pseudoId == PseudoIdBackdrop && !parent.isInTopLayer()) | 843 if (pseudoId == PseudoIdBackdrop && !parent.isInTopLayer()) |
| 832 return nullptr; | 844 return nullptr; |
| 833 | 845 |
| 834 if (pseudoId == PseudoIdFirstLetter && | 846 if (pseudoId == PseudoIdFirstLetter && |
| 835 (parent.isSVGElement() || | 847 (parent.isSVGElement() || |
| 836 !FirstLetterPseudoElement::firstLetterTextLayoutObject(parent))) | 848 !FirstLetterPseudoElement::firstLetterTextLayoutObject(parent))) |
| 837 return nullptr; | 849 return nullptr; |
| 838 | 850 |
| 839 if (!canHaveGeneratedChildren(*parentLayoutObject)) | 851 if (!canHaveGeneratedChildren(*parentLayoutObject)) |
| 840 return nullptr; | 852 return nullptr; |
| 841 | 853 |
| 842 ComputedStyle* parentStyle = parentLayoutObject->mutableStyle(); | |
| 843 if (ComputedStyle* cachedStyle = | 854 if (ComputedStyle* cachedStyle = |
| 844 parentStyle->getCachedPseudoStyle(pseudoId)) { | 855 parentStyle->getCachedPseudoStyle(pseudoId)) { |
| 845 if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) | 856 if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) |
| 846 return nullptr; | 857 return nullptr; |
| 847 return createPseudoElement(&parent, pseudoId); | 858 return createPseudoElement(&parent, pseudoId); |
| 848 } | 859 } |
| 849 | 860 |
| 850 StyleResolverState state(document(), &parent, parentStyle, parentStyle); | 861 StyleResolverState state(document(), &parent, parentStyle, |
| 862 parentLayoutObject->style()); |
| 851 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 863 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 852 return nullptr; | 864 return nullptr; |
| 853 RefPtr<ComputedStyle> style = state.takeStyle(); | 865 RefPtr<ComputedStyle> style = state.takeStyle(); |
| 854 DCHECK(style); | 866 DCHECK(style); |
| 855 parentStyle->addCachedPseudoStyle(style); | 867 parentStyle->addCachedPseudoStyle(style); |
| 856 | 868 |
| 857 if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 869 if (!pseudoElementLayoutObjectIsNeeded(style.get())) |
| 858 return nullptr; | 870 return nullptr; |
| 859 | 871 |
| 860 PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); | 872 PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 | 1957 |
| 1946 DEFINE_TRACE(StyleResolver) { | 1958 DEFINE_TRACE(StyleResolver) { |
| 1947 visitor->trace(m_matchedPropertiesCache); | 1959 visitor->trace(m_matchedPropertiesCache); |
| 1948 visitor->trace(m_selectorFilter); | 1960 visitor->trace(m_selectorFilter); |
| 1949 visitor->trace(m_styleSharingLists); | 1961 visitor->trace(m_styleSharingLists); |
| 1950 visitor->trace(m_document); | 1962 visitor->trace(m_document); |
| 1951 visitor->trace(m_tracker); | 1963 visitor->trace(m_tracker); |
| 1952 } | 1964 } |
| 1953 | 1965 |
| 1954 } // namespace blink | 1966 } // namespace blink |
| OLD | NEW |