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

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

Issue 778003003: List marker pseudo elements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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/parser/CSSSelectorParser.cpp ('k') | Source/core/dom/Element.cpp » ('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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "core/css/resolver/MediaQueryResult.h" 63 #include "core/css/resolver/MediaQueryResult.h"
64 #include "core/css/resolver/ScopedStyleResolver.h" 64 #include "core/css/resolver/ScopedStyleResolver.h"
65 #include "core/css/resolver/SharedStyleFinder.h" 65 #include "core/css/resolver/SharedStyleFinder.h"
66 #include "core/css/resolver/StyleAdjuster.h" 66 #include "core/css/resolver/StyleAdjuster.h"
67 #include "core/css/resolver/StyleResolverParentScope.h" 67 #include "core/css/resolver/StyleResolverParentScope.h"
68 #include "core/css/resolver/StyleResolverState.h" 68 #include "core/css/resolver/StyleResolverState.h"
69 #include "core/css/resolver/StyleResolverStats.h" 69 #include "core/css/resolver/StyleResolverStats.h"
70 #include "core/css/resolver/ViewportStyleResolver.h" 70 #include "core/css/resolver/ViewportStyleResolver.h"
71 #include "core/dom/CSSSelectorWatch.h" 71 #include "core/dom/CSSSelectorWatch.h"
72 #include "core/dom/FirstLetterPseudoElement.h" 72 #include "core/dom/FirstLetterPseudoElement.h"
73 #include "core/dom/MarkerPseudoElement.h"
73 #include "core/dom/NodeComputedStyle.h" 74 #include "core/dom/NodeComputedStyle.h"
74 #include "core/dom/StyleEngine.h" 75 #include "core/dom/StyleEngine.h"
75 #include "core/dom/Text.h" 76 #include "core/dom/Text.h"
76 #include "core/dom/shadow/ElementShadow.h" 77 #include "core/dom/shadow/ElementShadow.h"
77 #include "core/dom/shadow/ShadowRoot.h" 78 #include "core/dom/shadow/ShadowRoot.h"
78 #include "core/frame/FrameView.h" 79 #include "core/frame/FrameView.h"
79 #include "core/frame/LocalFrame.h" 80 #include "core/frame/LocalFrame.h"
80 #include "core/frame/Settings.h" 81 #include "core/frame/Settings.h"
81 #include "core/html/HTMLIFrameElement.h" 82 #include "core/html/HTMLIFrameElement.h"
82 #include "core/inspector/InspectorInstrumentation.h" 83 #include "core/inspector/InspectorInstrumentation.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 { 707 {
707 if (value) { 708 if (value) {
708 StyleBuilder::applyProperty(property, state, value); 709 StyleBuilder::applyProperty(property, state, value);
709 state.fontBuilder().createFont(state.document().styleEngine().fontSelect or(), state.mutableStyleRef()); 710 state.fontBuilder().createFont(state.document().styleEngine().fontSelect or(), state.mutableStyleRef());
710 } 711 }
711 return CSSAnimatableValueFactory::create(property, *state.style()); 712 return CSSAnimatableValueFactory::create(property, *state.style());
712 } 713 }
713 714
714 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId) 715 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element * parent, PseudoId pseudoId)
715 { 716 {
717 if (pseudoId == MARKER) {
718 ASSERT(RuntimeEnabledFeatures::listMarkerPseudoElementEnabled());
719 return MarkerPseudoElement::create(parent);
720 }
716 if (pseudoId == FIRST_LETTER) 721 if (pseudoId == FIRST_LETTER)
717 return FirstLetterPseudoElement::create(parent); 722 return FirstLetterPseudoElement::create(parent);
718 return PseudoElement::create(parent, pseudoId); 723 return PseudoElement::create(parent, pseudoId);
719 } 724 }
720 725
726 static bool pseudoElementRequired(PseudoId pseudoId, LayoutObject& parentRendere r)
727 {
728 if (pseudoId == FIRST_LETTER)
729 return true;
730 if (pseudoId == MARKER)
731 return true;
732 if (parentRenderer.style()->hasPseudoStyle(pseudoId))
733 return true;
734 return pseudoId >= FIRST_INTERNAL_PSEUDOID;
735 }
736
721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) 737 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId)
722 { 738 {
723 LayoutObject* parentLayoutObject = parent.layoutObject(); 739 LayoutObject* parentLayoutObject = parent.layoutObject();
724 if (!parentLayoutObject) 740 if (!parentLayoutObject)
725 return nullptr; 741 return nullptr;
726 742
727 // The first letter pseudo element has to look up the tree and see if any 743 if (!pseudoElementRequired(pseudoId, *parentLayoutObject))
728 // of the ancestors are first letter.
729 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren tLayoutObject->style()->hasPseudoStyle(pseudoId))
730 return nullptr; 744 return nullptr;
731 745
732 if (pseudoId == BACKDROP && !parent.isInTopLayer()) 746 if (pseudoId == BACKDROP && !parent.isInTopLayer())
733 return nullptr; 747 return nullptr;
734 748
749 // FIXME: This should also probably take inline-list-item into account when
750 // we add support.
751 if (pseudoId == MARKER && parentLayoutObject->style()->display() != LIST_ITE M)
752 return nullptr;
753
735 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo Element::firstLetterTextRenderer(parent))) 754 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo Element::firstLetterTextRenderer(parent)))
736 return nullptr; 755 return nullptr;
737 756
738 if (!canHaveGeneratedChildren(*parentLayoutObject)) 757 if (!canHaveGeneratedChildren(*parentLayoutObject))
739 return nullptr; 758 return nullptr;
740 759
741 ComputedStyle* parentStyle = parentLayoutObject->mutableStyle(); 760 ComputedStyle* parentStyle = parentLayoutObject->mutableStyle();
742 if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId) ) { 761 if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId) ) {
743 if (!pseudoElementRendererIsNeeded(cachedStyle)) 762 if (!pseudoElementRendererIsNeeded(cachedStyle))
744 return nullptr; 763 return nullptr;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 // user agent rules, don't waste time walking those rules. 813 // user agent rules, don't waste time walking those rules.
795 814
796 if (!baseComputedStyle) { 815 if (!baseComputedStyle) {
797 // Check UA, user and author rules. 816 // Check UA, user and author rules.
798 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); 817 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
799 collector.setPseudoStyleRequest(pseudoStyleRequest); 818 collector.setPseudoStyleRequest(pseudoStyleRequest);
800 819
801 matchUARules(collector); 820 matchUARules(collector);
802 matchAuthorRules(state.element(), collector, false); 821 matchAuthorRules(state.element(), collector, false);
803 822
804 if (collector.matchedResult().matchedProperties.isEmpty()) 823 if (!collector.matchedResult().matchedProperties.isEmpty())
824 applyMatchedProperties(state, collector.matchedResult());
825 else if (pseudoStyleRequest.pseudoId != MARKER)
805 return false; 826 return false;
806 827
807 applyMatchedProperties(state, collector.matchedResult());
808 applyCallbackSelectors(state); 828 applyCallbackSelectors(state);
809 829
810 // Cache our original display. 830 // Cache our original display.
811 state.style()->setOriginalDisplay(state.style()->display()); 831 state.style()->setOriginalDisplay(state.style()->display());
812 832
813 // FIXME: Passing 0 as the Element* introduces a lot of complexity 833 // FIXME: Passing 0 as the Element* introduces a lot of complexity
814 // in the adjustComputedStyle code. 834 // in the adjustComputedStyle code.
815 adjustComputedStyle(state, 0); 835 adjustComputedStyle(state, 0);
816 836
817 if (elementAnimations) 837 if (elementAnimations)
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 visitor->trace(m_watchedSelectorsRules); 1525 visitor->trace(m_watchedSelectorsRules);
1506 visitor->trace(m_treeBoundaryCrossingRules); 1526 visitor->trace(m_treeBoundaryCrossingRules);
1507 visitor->trace(m_styleResourceLoader); 1527 visitor->trace(m_styleResourceLoader);
1508 visitor->trace(m_styleSharingLists); 1528 visitor->trace(m_styleSharingLists);
1509 visitor->trace(m_pendingStyleSheets); 1529 visitor->trace(m_pendingStyleSheets);
1510 visitor->trace(m_document); 1530 visitor->trace(m_document);
1511 #endif 1531 #endif
1512 } 1532 }
1513 1533
1514 } // namespace blink 1534 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSSelectorParser.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698