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

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

Issue 672953002: Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 state.setStyle(style); 712 state.setStyle(style);
712 return createAnimatableValueSnapshot(state, property, value); 713 return createAnimatableValueSnapshot(state, property, value);
713 } 714 }
714 715
715 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) 716 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value)
716 { 717 {
717 StyleBuilder::applyProperty(property, state, &value); 718 StyleBuilder::applyProperty(property, state, &value);
718 return CSSAnimatableValueFactory::create(property, *state.style()); 719 return CSSAnimatableValueFactory::create(property, *state.style());
719 } 720 }
720 721
722 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId)
723 {
724 if (pseudoId == FIRST_LETTER)
725 return FirstLetterPseudoElement::create(parent);
726 return PseudoElement::create(parent, pseudoId);
727 }
728
721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) 729 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId)
722 { 730 {
723 RenderObject* parentRenderer = parent.renderer(); 731 RenderObject* parentRenderer = parent.renderer();
724 if (!parentRenderer) 732 if (!parentRenderer)
725 return nullptr; 733 return nullptr;
726 734
727 if (pseudoId < FIRST_INTERNAL_PSEUDOID && !parentRenderer->style()->hasPseud oStyle(pseudoId)) 735 // The first letter pseudo element has to look up the tree and see if any
736 // of the ancestors are first letter.
737 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren tRenderer->style()->hasPseudoStyle(pseudoId))
728 return nullptr; 738 return nullptr;
729 739
730 if (pseudoId == BACKDROP && !parent.isInTopLayer()) 740 if (pseudoId == BACKDROP && !parent.isInTopLayer())
731 return nullptr; 741 return nullptr;
732 742
743 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo Element::firstLetterTextRenderer(parent)))
744 return nullptr;
745
733 if (!parentRenderer->canHaveGeneratedChildren()) 746 if (!parentRenderer->canHaveGeneratedChildren())
734 return nullptr; 747 return nullptr;
735 748
736 RenderStyle* parentStyle = parentRenderer->style(); 749 RenderStyle* parentStyle = parentRenderer->style();
737 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) { 750 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) {
738 if (!pseudoElementRendererIsNeeded(cachedStyle)) 751 if (!pseudoElementRendererIsNeeded(cachedStyle))
739 return nullptr; 752 return nullptr;
740 return PseudoElement::create(&parent, pseudoId); 753 return createPseudoElement(&parent, pseudoId);
741 } 754 }
742 755
743 StyleResolverState state(document(), &parent, parentStyle); 756 StyleResolverState state(document(), &parent, parentStyle);
744 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) 757 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state))
745 return nullptr; 758 return nullptr;
746 RefPtr<RenderStyle> style = state.takeStyle(); 759 RefPtr<RenderStyle> style = state.takeStyle();
747 ASSERT(style); 760 ASSERT(style);
748 parentStyle->addCachedPseudoStyle(style); 761 parentStyle->addCachedPseudoStyle(style);
749 762
750 if (!pseudoElementRendererIsNeeded(style.get())) 763 if (!pseudoElementRendererIsNeeded(style.get()))
751 return nullptr; 764 return nullptr;
752 765
753 RefPtrWillBeRawPtr<PseudoElement> pseudo = PseudoElement::create(&parent, ps eudoId); 766 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu doId);
754 767
755 setAnimationUpdateIfNeeded(state, *pseudo); 768 setAnimationUpdateIfNeeded(state, *pseudo);
756 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) 769 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations())
757 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); 770 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get());
758 return pseudo.release(); 771 return pseudo.release();
759 } 772 }
760 773
761 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) 774 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state)
762 { 775 {
763 ASSERT(document().frame()); 776 ASSERT(document().frame());
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 visitor->trace(m_uncommonAttributeRuleSet); 1605 visitor->trace(m_uncommonAttributeRuleSet);
1593 visitor->trace(m_watchedSelectorsRules); 1606 visitor->trace(m_watchedSelectorsRules);
1594 visitor->trace(m_treeBoundaryCrossingRules); 1607 visitor->trace(m_treeBoundaryCrossingRules);
1595 visitor->trace(m_styleSharingLists); 1608 visitor->trace(m_styleSharingLists);
1596 visitor->trace(m_pendingStyleSheets); 1609 visitor->trace(m_pendingStyleSheets);
1597 visitor->trace(m_document); 1610 visitor->trace(m_document);
1598 #endif 1611 #endif
1599 } 1612 }
1600 1613
1601 } // namespace blink 1614 } // 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