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

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

Issue 639863006: Revert of Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Element.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "core/css/resolver/AnimatedStyleBuilder.h" 61 #include "core/css/resolver/AnimatedStyleBuilder.h"
62 #include "core/css/resolver/MatchResult.h" 62 #include "core/css/resolver/MatchResult.h"
63 #include "core/css/resolver/MediaQueryResult.h" 63 #include "core/css/resolver/MediaQueryResult.h"
64 #include "core/css/resolver/SharedStyleFinder.h" 64 #include "core/css/resolver/SharedStyleFinder.h"
65 #include "core/css/resolver/StyleAdjuster.h" 65 #include "core/css/resolver/StyleAdjuster.h"
66 #include "core/css/resolver/StyleResolverParentScope.h" 66 #include "core/css/resolver/StyleResolverParentScope.h"
67 #include "core/css/resolver/StyleResolverState.h" 67 #include "core/css/resolver/StyleResolverState.h"
68 #include "core/css/resolver/StyleResolverStats.h" 68 #include "core/css/resolver/StyleResolverStats.h"
69 #include "core/css/resolver/ViewportStyleResolver.h" 69 #include "core/css/resolver/ViewportStyleResolver.h"
70 #include "core/dom/CSSSelectorWatch.h" 70 #include "core/dom/CSSSelectorWatch.h"
71 #include "core/dom/FirstLetterPseudoElement.h"
72 #include "core/dom/NodeRenderStyle.h" 71 #include "core/dom/NodeRenderStyle.h"
73 #include "core/dom/StyleEngine.h" 72 #include "core/dom/StyleEngine.h"
74 #include "core/dom/Text.h" 73 #include "core/dom/Text.h"
75 #include "core/dom/shadow/ElementShadow.h" 74 #include "core/dom/shadow/ElementShadow.h"
76 #include "core/dom/shadow/ShadowRoot.h" 75 #include "core/dom/shadow/ShadowRoot.h"
77 #include "core/frame/FrameView.h" 76 #include "core/frame/FrameView.h"
78 #include "core/frame/LocalFrame.h" 77 #include "core/frame/LocalFrame.h"
79 #include "core/html/HTMLIFrameElement.h" 78 #include "core/html/HTMLIFrameElement.h"
80 #include "core/inspector/InspectorInstrumentation.h" 79 #include "core/inspector/InspectorInstrumentation.h"
81 #include "core/rendering/RenderView.h" 80 #include "core/rendering/RenderView.h"
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 state.fontBuilder().initForStyleResolve(state.document(), state.style()); 726 state.fontBuilder().initForStyleResolve(state.document(), state.style());
728 return createAnimatableValueSnapshot(state, property, value); 727 return createAnimatableValueSnapshot(state, property, value);
729 } 728 }
730 729
731 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) 730 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value)
732 { 731 {
733 StyleBuilder::applyProperty(property, state, &value); 732 StyleBuilder::applyProperty(property, state, &value);
734 return CSSAnimatableValueFactory::create(property, *state.style()); 733 return CSSAnimatableValueFactory::create(property, *state.style());
735 } 734 }
736 735
737 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId)
738 {
739 if (pseudoId == FIRST_LETTER)
740 return FirstLetterPseudoElement::create(parent);
741 return PseudoElement::create(parent, pseudoId);
742 }
743
744 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) 736 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId)
745 { 737 {
746 RenderObject* parentRenderer = parent.renderer(); 738 RenderObject* parentRenderer = parent.renderer();
747 if (!parentRenderer) 739 if (!parentRenderer)
748 return nullptr; 740 return nullptr;
749 741
750 // The first letter pseudo element has to look up the tree and see if any 742 if (pseudoId < FIRST_INTERNAL_PSEUDOID && !parentRenderer->style()->hasPseud oStyle(pseudoId))
751 // of the ancestors are first letter.
752 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren tRenderer->style()->hasPseudoStyle(pseudoId))
753 return nullptr; 743 return nullptr;
754 744
755 if (pseudoId == BACKDROP && !parent.isInTopLayer()) 745 if (pseudoId == BACKDROP && !parent.isInTopLayer())
756 return nullptr; 746 return nullptr;
757 747
758 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo Element::firstLetterTextRenderer(parent)))
759 return nullptr;
760
761 if (!parentRenderer->canHaveGeneratedChildren()) 748 if (!parentRenderer->canHaveGeneratedChildren())
762 return nullptr; 749 return nullptr;
763 750
764 RenderStyle* parentStyle = parentRenderer->style(); 751 RenderStyle* parentStyle = parentRenderer->style();
765 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) { 752 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) {
766 if (!pseudoElementRendererIsNeeded(cachedStyle)) 753 if (!pseudoElementRendererIsNeeded(cachedStyle))
767 return nullptr; 754 return nullptr;
768 return createPseudoElement(&parent, pseudoId); 755 return PseudoElement::create(&parent, pseudoId);
769 } 756 }
770 757
771 StyleResolverState state(document(), &parent, parentStyle); 758 StyleResolverState state(document(), &parent, parentStyle);
772 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) 759 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state))
773 return nullptr; 760 return nullptr;
774 RefPtr<RenderStyle> style = state.takeStyle(); 761 RefPtr<RenderStyle> style = state.takeStyle();
775 ASSERT(style); 762 ASSERT(style);
776 parentStyle->addCachedPseudoStyle(style); 763 parentStyle->addCachedPseudoStyle(style);
777 764
778 if (!pseudoElementRendererIsNeeded(style.get())) 765 if (!pseudoElementRendererIsNeeded(style.get()))
779 return nullptr; 766 return nullptr;
780 767
781 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu doId); 768 RefPtrWillBeRawPtr<PseudoElement> pseudo = PseudoElement::create(&parent, ps eudoId);
782 769
783 setAnimationUpdateIfNeeded(state, *pseudo); 770 setAnimationUpdateIfNeeded(state, *pseudo);
784 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) 771 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations())
785 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); 772 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get());
786 return pseudo.release(); 773 return pseudo.release();
787 } 774 }
788 775
789 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) 776 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state)
790 { 777 {
791 ASSERT(document().frame()); 778 ASSERT(document().frame());
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 visitor->trace(m_uncommonAttributeRuleSet); 1612 visitor->trace(m_uncommonAttributeRuleSet);
1626 visitor->trace(m_watchedSelectorsRules); 1613 visitor->trace(m_watchedSelectorsRules);
1627 visitor->trace(m_treeBoundaryCrossingRules); 1614 visitor->trace(m_treeBoundaryCrossingRules);
1628 visitor->trace(m_styleSharingLists); 1615 visitor->trace(m_styleSharingLists);
1629 visitor->trace(m_pendingStyleSheets); 1616 visitor->trace(m_pendingStyleSheets);
1630 visitor->trace(m_document); 1617 visitor->trace(m_document);
1631 #endif 1618 #endif
1632 } 1619 }
1633 1620
1634 } // namespace blink 1621 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698