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

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

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