| 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 819 |
| 820 PseudoElement* StyleResolver::createPseudoElement(Element* parent, | 820 PseudoElement* StyleResolver::createPseudoElement(Element* parent, |
| 821 PseudoId pseudoId) { | 821 PseudoId pseudoId) { |
| 822 if (pseudoId == PseudoIdFirstLetter) | 822 if (pseudoId == PseudoIdFirstLetter) |
| 823 return FirstLetterPseudoElement::create(parent); | 823 return FirstLetterPseudoElement::create(parent); |
| 824 return PseudoElement::create(parent, pseudoId); | 824 return PseudoElement::create(parent, pseudoId); |
| 825 } | 825 } |
| 826 | 826 |
| 827 PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent, | 827 PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent, |
| 828 PseudoId pseudoId) { | 828 PseudoId pseudoId) { |
| 829 if (!parent.canHaveGeneratedPseudo(pseudoId)) |
| 830 return nullptr; |
| 831 |
| 829 LayoutObject* parentLayoutObject = parent.layoutObject(); | 832 LayoutObject* parentLayoutObject = parent.layoutObject(); |
| 833 if (!parentLayoutObject) { |
| 834 DCHECK(parent.hasDisplayContentsStyle()); |
| 835 parentLayoutObject = LayoutTreeBuilderTraversal::parentLayoutObject(parent); |
| 836 } |
| 837 |
| 830 if (!parentLayoutObject) | 838 if (!parentLayoutObject) |
| 831 return nullptr; | 839 return nullptr; |
| 832 | 840 |
| 841 ComputedStyle* parentStyle = parent.mutableComputedStyle(); |
| 842 DCHECK(parentStyle); |
| 843 |
| 833 // The first letter pseudo element has to look up the tree and see if any | 844 // The first letter pseudo element has to look up the tree and see if any |
| 834 // of the ancestors are first letter. | 845 // of the ancestors are first letter. |
| 835 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && | 846 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && |
| 836 !parentLayoutObject->style()->hasPseudoStyle(pseudoId)) | 847 !parentStyle->hasPseudoStyle(pseudoId)) { |
| 837 return nullptr; | 848 return nullptr; |
| 849 } |
| 838 | 850 |
| 839 if (pseudoId == PseudoIdBackdrop && !parent.isInTopLayer()) | 851 if (pseudoId == PseudoIdBackdrop && !parent.isInTopLayer()) |
| 840 return nullptr; | 852 return nullptr; |
| 841 | 853 |
| 842 if (pseudoId == PseudoIdFirstLetter && | 854 if (pseudoId == PseudoIdFirstLetter && |
| 843 (parent.isSVGElement() || | 855 (parent.isSVGElement() || |
| 844 !FirstLetterPseudoElement::firstLetterTextLayoutObject(parent))) | 856 !FirstLetterPseudoElement::firstLetterTextLayoutObject(parent))) |
| 845 return nullptr; | 857 return nullptr; |
| 846 | 858 |
| 847 if (!canHaveGeneratedChildren(*parentLayoutObject)) | 859 if (!canHaveGeneratedChildren(*parentLayoutObject)) |
| 848 return nullptr; | 860 return nullptr; |
| 849 | 861 |
| 850 ComputedStyle* parentStyle = parentLayoutObject->mutableStyle(); | |
| 851 if (ComputedStyle* cachedStyle = | 862 if (ComputedStyle* cachedStyle = |
| 852 parentStyle->getCachedPseudoStyle(pseudoId)) { | 863 parentStyle->getCachedPseudoStyle(pseudoId)) { |
| 853 if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) | 864 if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) |
| 854 return nullptr; | 865 return nullptr; |
| 855 return createPseudoElement(&parent, pseudoId); | 866 return createPseudoElement(&parent, pseudoId); |
| 856 } | 867 } |
| 857 | 868 |
| 858 StyleResolverState state(document(), &parent, parentStyle, parentStyle); | 869 StyleResolverState state(document(), &parent, parentStyle, |
| 870 parentLayoutObject->style()); |
| 859 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 871 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 860 return nullptr; | 872 return nullptr; |
| 861 RefPtr<ComputedStyle> style = state.takeStyle(); | 873 RefPtr<ComputedStyle> style = state.takeStyle(); |
| 862 DCHECK(style); | 874 DCHECK(style); |
| 863 parentStyle->addCachedPseudoStyle(style); | 875 parentStyle->addCachedPseudoStyle(style); |
| 864 | 876 |
| 865 if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 877 if (!pseudoElementLayoutObjectIsNeeded(style.get())) |
| 866 return nullptr; | 878 return nullptr; |
| 867 | 879 |
| 868 PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); | 880 PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 | 1982 |
| 1971 DEFINE_TRACE(StyleResolver) { | 1983 DEFINE_TRACE(StyleResolver) { |
| 1972 visitor->trace(m_matchedPropertiesCache); | 1984 visitor->trace(m_matchedPropertiesCache); |
| 1973 visitor->trace(m_selectorFilter); | 1985 visitor->trace(m_selectorFilter); |
| 1974 visitor->trace(m_styleSharingLists); | 1986 visitor->trace(m_styleSharingLists); |
| 1975 visitor->trace(m_document); | 1987 visitor->trace(m_document); |
| 1976 visitor->trace(m_tracker); | 1988 visitor->trace(m_tracker); |
| 1977 } | 1989 } |
| 1978 | 1990 |
| 1979 } // namespace blink | 1991 } // namespace blink |
| OLD | NEW |