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. 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 13 matching lines...) Loading... | |
24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "core/css/resolver/StyleResolver.h" | 30 #include "core/css/resolver/StyleResolver.h" |
31 | 31 |
32 #include "core/CSSPropertyNames.h" | 32 #include "core/CSSPropertyNames.h" |
33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
34 #include "core/StylePropertyShorthand.h" | |
35 #include "core/animation/ActiveAnimations.h" | 34 #include "core/animation/ActiveAnimations.h" |
36 #include "core/animation/Animation.h" | 35 #include "core/animation/Animation.h" |
37 #include "core/animation/AnimationTimeline.h" | 36 #include "core/animation/AnimationTimeline.h" |
38 #include "core/animation/animatable/AnimatableValue.h" | 37 #include "core/animation/animatable/AnimatableValue.h" |
39 #include "core/animation/css/CSSAnimatableValueFactory.h" | 38 #include "core/animation/css/CSSAnimatableValueFactory.h" |
40 #include "core/animation/css/CSSAnimations.h" | 39 #include "core/animation/css/CSSAnimations.h" |
41 #include "core/animation/interpolation/StyleInterpolation.h" | 40 #include "core/animation/interpolation/StyleInterpolation.h" |
42 #include "core/css/CSSCalculationValue.h" | 41 #include "core/css/CSSCalculationValue.h" |
43 #include "core/css/CSSDefaultStyleSheets.h" | 42 #include "core/css/CSSDefaultStyleSheets.h" |
44 #include "core/css/CSSFontSelector.h" | 43 #include "core/css/CSSFontSelector.h" |
45 #include "core/css/CSSKeyframeRule.h" | 44 #include "core/css/CSSKeyframeRule.h" |
46 #include "core/css/CSSKeyframesRule.h" | 45 #include "core/css/CSSKeyframesRule.h" |
47 #include "core/css/CSSReflectValue.h" | 46 #include "core/css/CSSReflectValue.h" |
48 #include "core/css/CSSRuleList.h" | 47 #include "core/css/CSSRuleList.h" |
49 #include "core/css/CSSSelector.h" | 48 #include "core/css/CSSSelector.h" |
50 #include "core/css/CSSStyleRule.h" | 49 #include "core/css/CSSStyleRule.h" |
51 #include "core/css/CSSValueList.h" | 50 #include "core/css/CSSValueList.h" |
52 #include "core/css/CSSValuePool.h" | 51 #include "core/css/CSSValuePool.h" |
53 #include "core/css/ElementRuleCollector.h" | 52 #include "core/css/ElementRuleCollector.h" |
54 #include "core/css/FontFace.h" | 53 #include "core/css/FontFace.h" |
55 #include "core/css/MediaQueryEvaluator.h" | 54 #include "core/css/MediaQueryEvaluator.h" |
56 #include "core/css/PageRuleCollector.h" | 55 #include "core/css/PageRuleCollector.h" |
57 #include "core/css/StylePropertySet.h" | 56 #include "core/css/StylePropertySet.h" |
58 #include "core/css/StyleRuleImport.h" | 57 #include "core/css/StyleRuleImport.h" |
59 #include "core/css/StyleSheetContents.h" | 58 #include "core/css/StyleSheetContents.h" |
60 #include "core/css/parser/BisonCSSParser.h" | 59 #include "core/css/parser/BisonCSSParser.h" |
61 #include "core/css/resolver/AnimatedStyleBuilder.h" | 60 #include "core/css/resolver/AnimatedStyleBuilder.h" |
61 #include "core/css/resolver/CascadedValues.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/NodeRenderStyle.h" | 71 #include "core/dom/NodeRenderStyle.h" |
(...skipping 18 matching lines...) Loading... | |
90 using namespace blink; | 90 using namespace blink; |
91 | 91 |
92 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) | 92 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) |
93 { | 93 { |
94 // If any changes to CSS Animations were detected, stash the update away for application after the | 94 // If any changes to CSS Animations were detected, stash the update away for application after the |
95 // render object is updated if we're in the appropriate scope. | 95 // render object is updated if we're in the appropriate scope. |
96 if (state.animationUpdate()) | 96 if (state.animationUpdate()) |
97 element.ensureActiveAnimations().cssAnimations().setPendingUpdate(state. takeAnimationUpdate()); | 97 element.ensureActiveAnimations().cssAnimations().setPendingUpdate(state. takeAnimationUpdate()); |
98 } | 98 } |
99 | 99 |
100 static bool elementTypeHasAppearanceFromUAStyle(const Element& element) | |
101 { | |
102 // These elements have -webkit-appearance specified in html.css | |
esprehn
2014/07/21 18:50:34
What happens if someone uses webkit-appearance not
Timothy Loh
2014/07/22 14:32:48
It isn't of concern here whether -webkit-appearanc
| |
103 const AtomicString& localName = element.localName(); | |
104 return localName == HTMLNames::inputTag | |
105 || localName == HTMLNames::textareaTag | |
106 || localName == HTMLNames::buttonTag | |
107 || localName == HTMLNames::progressTag | |
108 || localName == HTMLNames::selectTag | |
109 || localName == HTMLNames::meterTag; | |
110 } | |
111 | |
100 } // namespace | 112 } // namespace |
101 | 113 |
102 namespace blink { | 114 namespace blink { |
103 | 115 |
104 using namespace HTMLNames; | 116 using namespace HTMLNames; |
105 | 117 |
106 RenderStyle* StyleResolver::s_styleNotYetAvailable; | 118 RenderStyle* StyleResolver::s_styleNotYetAvailable; |
107 | 119 |
108 static StylePropertySet* leftToRightDeclaration() | 120 static StylePropertySet* leftToRightDeclaration() |
109 { | 121 { |
(...skipping 574 matching lines...) Loading... | |
684 | 696 |
685 setAnimationUpdateIfNeeded(state, *element); | 697 setAnimationUpdateIfNeeded(state, *element); |
686 | 698 |
687 if (state.style()->hasViewportUnits()) | 699 if (state.style()->hasViewportUnits()) |
688 document().setHasViewportUnits(); | 700 document().setHasViewportUnits(); |
689 | 701 |
690 // Now return the style. | 702 // Now return the style. |
691 return state.takeStyle(); | 703 return state.takeStyle(); |
692 } | 704 } |
693 | 705 |
706 // FIXME: Consider refactoring to create a new class which owns the following | |
707 // first/last/range properties. | |
708 // c.f. //src/third_party/WebKit/Source/core/css/CSSPropertyNames.in. | |
709 | |
710 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr iorityProperties>() | |
711 { | |
712 COMPILE_ASSERT(CSSPropertyColor == CSSPropertyWebkitWritingMode + 1, CSS_col or_is_first_high_priority_property); | |
713 return CSSPropertyColor; | |
714 } | |
715 | |
716 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri orityProperties>() | |
717 { | |
718 return CSSPropertyZoom; | |
719 } | |
720 | |
721 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri orityProperties>() | |
722 { | |
723 COMPILE_ASSERT(CSSPropertyBackground == CSSPropertyZoom + 1, CSS_background_ is_first_low_priority_property); | |
724 return CSSPropertyBackground; | |
725 } | |
726 | |
727 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio rityProperties>() | |
728 { | |
729 return convertToCSSPropertyID(lastCSSProperty); | |
730 } | |
731 | |
732 template <StyleResolver::StyleApplicationPass pass> | |
733 bool StyleResolver::isPropertyForPass(CSSPropertyID property) | |
734 { | |
735 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty Id<pass>(); | |
736 } | |
737 | |
694 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName) | 738 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName) |
695 { | 739 { |
696 ASSERT(document().frame()); | 740 ASSERT(document().frame()); |
697 ASSERT(document().settings()); | 741 ASSERT(document().settings()); |
698 ASSERT(!hasPendingAuthorStyleSheets()); | 742 ASSERT(!hasPendingAuthorStyleSheets()); |
699 | 743 |
700 if (element == document().documentElement()) | 744 if (element == document().documentElement()) |
701 resetDirectionAndWritingModeOnDocument(document()); | 745 resetDirectionAndWritingModeOnDocument(document()); |
702 StyleResolverState state(document(), element, parentStyle); | 746 StyleResolverState state(document(), element, parentStyle); |
703 | 747 |
704 MatchResult result; | 748 MatchResult matchResult; |
705 result.addMatchedProperties(&keyframe->properties()); | 749 matchResult.addMatchedProperties(&keyframe->properties()); |
706 | 750 |
707 ASSERT(!state.style()); | 751 ASSERT(!state.style()); |
708 | 752 |
709 // Create the style | 753 // Create the style |
710 state.setStyle(RenderStyle::clone(&elementStyle)); | 754 state.setStyle(RenderStyle::clone(&elementStyle)); |
711 state.setLineHeightValue(0); | |
712 | 755 |
713 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 756 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
714 | 757 |
715 // We don't need to bother with !important. Since there is only ever one | 758 // We don't need to bother with !important. Since there is only ever one |
716 // decl, there's nothing to override. So just add the first properties. | 759 // decl, there's nothing to override. So just add the first properties. |
717 // We also don't need to bother with animation properties since the only | 760 // We also don't need to bother with animation properties since the only |
718 // relevant one is animation-timing-function and we special-case that in | 761 // relevant one is animation-timing-function and we special-case that in |
719 // CSSAnimations.cpp | 762 // CSSAnimations.cpp |
720 bool inheritedOnly = false; | 763 CascadedValues cascadedValues(state, matchResult); |
721 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); | 764 cascadedValues.addMatchResult(matchResult, false, 0, matchResult.matchedProp erties.size() - 1); |
765 | |
766 cascadedValues.applyValues(firstCSSPropertyId<HighPriorityProperties>(), las tCSSPropertyId<HighPriorityProperties>()); | |
722 | 767 |
723 // If our font got dirtied, go ahead and update it now. | 768 // If our font got dirtied, go ahead and update it now. |
724 updateFont(state); | 769 updateFont(state); |
725 | 770 |
726 // Line-height is set when we are sure we decided on the font-size | 771 cascadedValues.applyValues(firstCSSPropertyId<LowPriorityProperties>(), last CSSPropertyId<LowPriorityProperties>()); |
727 if (state.lineHeightValue()) | |
728 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); | |
729 | |
730 // Now do rest of the properties. | |
731 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); | |
732 | 772 |
733 // If our font got dirtied by one of the non-essential font props, | 773 // If our font got dirtied by one of the non-essential font props, |
734 // go ahead and update it a second time. | 774 // go ahead and update it a second time. |
735 updateFont(state); | 775 updateFont(state); |
736 | 776 |
737 loadPendingResources(state); | 777 loadPendingResources(state); |
738 | 778 |
739 didAccess(); | 779 didAccess(); |
740 | 780 |
741 return state.takeStyle(); | 781 return state.takeStyle(); |
(...skipping 147 matching lines...) Loading... | |
889 | 929 |
890 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 930 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
891 | 931 |
892 PageRuleCollector collector(rootElementStyle, pageIndex); | 932 PageRuleCollector collector(rootElementStyle, pageIndex); |
893 | 933 |
894 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); | 934 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); |
895 | 935 |
896 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) | 936 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) |
897 scopedResolver->matchPageRules(collector); | 937 scopedResolver->matchPageRules(collector); |
898 | 938 |
899 state.setLineHeightValue(0); | 939 MatchResult& matchResult = collector.matchedResult(); |
900 bool inheritedOnly = false; | 940 CascadedValues cascadedValues(state, matchResult); |
941 cascadedValues.addMatchResult(matchResult, false, 0, matchResult.matchedProp erties.size() - 1); | |
942 cascadedValues.addMatchResult(matchResult, true, 0, matchResult.matchedPrope rties.size() - 1); | |
901 | 943 |
902 MatchResult& result = collector.matchedResult(); | 944 cascadedValues.applyValues(firstCSSPropertyId<HighPriorityProperties>(), las tCSSPropertyId<HighPriorityProperties>()); |
903 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); | |
904 | 945 |
905 // If our font got dirtied, go ahead and update it now. | 946 // If our font got dirtied, go ahead and update it now. |
906 updateFont(state); | 947 updateFont(state); |
907 | 948 |
908 // Line-height is set when we are sure we decided on the font-size. | 949 cascadedValues.applyValues(firstCSSPropertyId<LowPriorityProperties>(), last CSSPropertyId<LowPriorityProperties>()); |
909 if (state.lineHeightValue()) | |
910 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); | |
911 | |
912 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); | |
913 | 950 |
914 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 951 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
915 | 952 |
916 loadPendingResources(state); | 953 loadPendingResources(state); |
917 | 954 |
918 didAccess(); | 955 didAccess(); |
919 | 956 |
920 // Now return the style. | 957 // Now return the style. |
921 return state.takeStyle(); | 958 return state.takeStyle(); |
922 } | 959 } |
(...skipping 14 matching lines...) Loading... | |
937 | 974 |
938 viewportStyleResolver()->resolve(); | 975 viewportStyleResolver()->resolve(); |
939 } | 976 } |
940 | 977 |
941 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 978 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
942 { | 979 { |
943 StyleResolverState state(document(), 0); | 980 StyleResolverState state(document(), 0); |
944 state.setStyle(RenderStyle::create()); | 981 state.setStyle(RenderStyle::create()); |
945 state.fontBuilder().initForStyleResolve(document(), state.style()); | 982 state.fontBuilder().initForStyleResolve(document(), state.style()); |
946 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 983 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
947 state.setLineHeightValue(0); | |
948 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 984 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
949 state.style()->font().update(document().styleEngine()->fontSelector()); | 985 state.style()->font().update(document().styleEngine()->fontSelector()); |
950 return state.takeStyle(); | 986 return state.takeStyle(); |
951 } | 987 } |
952 | 988 |
953 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 989 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
954 { | 990 { |
955 ASSERT(textNode); | 991 ASSERT(textNode); |
956 | 992 |
957 NodeRenderingTraversal::ParentDetails parentDetails; | 993 NodeRenderingTraversal::ParentDetails parentDetails; |
(...skipping 64 matching lines...) Loading... | |
1022 if (!(animatingElement && animatingElement->hasActiveAnimations()) | 1058 if (!(animatingElement && animatingElement->hasActiveAnimations()) |
1023 && !state.style()->transitions() && !state.style()->animations()) | 1059 && !state.style()->transitions() && !state.style()->animations()) |
1024 return false; | 1060 return false; |
1025 | 1061 |
1026 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this)); | 1062 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this)); |
1027 if (!state.animationUpdate()) | 1063 if (!state.animationUpdate()) |
1028 return false; | 1064 return false; |
1029 | 1065 |
1030 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations = state.animationUpdate()->activeInterpolation sForAnimations(); | 1066 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations = state.animationUpdate()->activeInterpolation sForAnimations(); |
1031 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions = state.animationUpdate()->activeInterpolatio nsForTransitions(); | 1067 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions = state.animationUpdate()->activeInterpolatio nsForTransitions(); |
1068 | |
1069 // FIXME: Is it possible to use CascadedValues here or is it too expensive t o | |
1070 // convert from Interpolations to CSSValues? | |
1032 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orAnimations); | 1071 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orAnimations); |
1033 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orTransitions); | 1072 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orTransitions); |
1034 | 1073 |
1035 updateFont(state); | 1074 updateFont(state); |
1036 | 1075 |
1037 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rAnimations); | 1076 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rAnimations); |
1038 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rTransitions); | 1077 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rTransitions); |
1039 | 1078 |
1040 // Start loading resources used by animations. | 1079 // Start loading resources used by animations. |
1041 loadPendingResources(state); | 1080 loadPendingResources(state); |
1042 | 1081 |
1043 ASSERT(!state.fontBuilder().fontDirty()); | 1082 ASSERT(!state.fontBuilder().fontDirty()); |
1044 | 1083 |
1045 return true; | 1084 return true; |
1046 } | 1085 } |
1047 | 1086 |
1048 template <StyleResolver::StyleApplicationPass pass> | 1087 template <StyleResolver::StyleApplicationPass pass> |
1049 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo lations) | 1088 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo lations) |
1050 { | 1089 { |
1051 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations. end(); ++iter) { | 1090 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations. end(); ++iter) { |
1052 CSSPropertyID property = iter->key; | 1091 CSSPropertyID property = iter->key; |
1053 if (!isPropertyForPass<pass>(property)) | 1092 if (!isPropertyForPass<pass>(property)) |
1054 continue; | 1093 continue; |
1055 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val ue.get()); | 1094 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val ue.get()); |
1056 interpolation->apply(state); | 1095 interpolation->apply(state); |
1057 } | 1096 } |
1058 } | 1097 } |
1059 | 1098 |
1060 static inline bool isValidCueStyleProperty(CSSPropertyID id) | |
1061 { | |
1062 switch (id) { | |
1063 case CSSPropertyBackground: | |
1064 case CSSPropertyBackgroundAttachment: | |
1065 case CSSPropertyBackgroundClip: | |
1066 case CSSPropertyBackgroundColor: | |
1067 case CSSPropertyBackgroundImage: | |
1068 case CSSPropertyBackgroundOrigin: | |
1069 case CSSPropertyBackgroundPosition: | |
1070 case CSSPropertyBackgroundPositionX: | |
1071 case CSSPropertyBackgroundPositionY: | |
1072 case CSSPropertyBackgroundRepeat: | |
1073 case CSSPropertyBackgroundRepeatX: | |
1074 case CSSPropertyBackgroundRepeatY: | |
1075 case CSSPropertyBackgroundSize: | |
1076 case CSSPropertyColor: | |
1077 case CSSPropertyFont: | |
1078 case CSSPropertyFontFamily: | |
1079 case CSSPropertyFontSize: | |
1080 case CSSPropertyFontStyle: | |
1081 case CSSPropertyFontVariant: | |
1082 case CSSPropertyFontWeight: | |
1083 case CSSPropertyLineHeight: | |
1084 case CSSPropertyOpacity: | |
1085 case CSSPropertyOutline: | |
1086 case CSSPropertyOutlineColor: | |
1087 case CSSPropertyOutlineOffset: | |
1088 case CSSPropertyOutlineStyle: | |
1089 case CSSPropertyOutlineWidth: | |
1090 case CSSPropertyVisibility: | |
1091 case CSSPropertyWhiteSpace: | |
1092 // FIXME: 'text-decoration' shorthand to be handled when available. | |
1093 // See https://chromiumcodereview.appspot.com/19516002 for details. | |
1094 case CSSPropertyTextDecoration: | |
1095 case CSSPropertyTextShadow: | |
1096 case CSSPropertyBorderStyle: | |
1097 return true; | |
1098 case CSSPropertyTextDecorationLine: | |
1099 case CSSPropertyTextDecorationStyle: | |
1100 case CSSPropertyTextDecorationColor: | |
1101 return RuntimeEnabledFeatures::css3TextDecorationsEnabled(); | |
1102 default: | |
1103 break; | |
1104 } | |
1105 return false; | |
1106 } | |
1107 | |
1108 static inline bool isValidFirstLetterStyleProperty(CSSPropertyID id) | |
1109 { | |
1110 switch (id) { | |
1111 // Valid ::first-letter properties listed in spec: | |
1112 // http://www.w3.org/TR/css3-selectors/#application-in-css | |
1113 case CSSPropertyBackgroundAttachment: | |
1114 case CSSPropertyBackgroundBlendMode: | |
1115 case CSSPropertyBackgroundClip: | |
1116 case CSSPropertyBackgroundColor: | |
1117 case CSSPropertyBackgroundImage: | |
1118 case CSSPropertyBackgroundOrigin: | |
1119 case CSSPropertyBackgroundPosition: | |
1120 case CSSPropertyBackgroundPositionX: | |
1121 case CSSPropertyBackgroundPositionY: | |
1122 case CSSPropertyBackgroundRepeat: | |
1123 case CSSPropertyBackgroundRepeatX: | |
1124 case CSSPropertyBackgroundRepeatY: | |
1125 case CSSPropertyBackgroundSize: | |
1126 case CSSPropertyBorderBottomColor: | |
1127 case CSSPropertyBorderBottomLeftRadius: | |
1128 case CSSPropertyBorderBottomRightRadius: | |
1129 case CSSPropertyBorderBottomStyle: | |
1130 case CSSPropertyBorderBottomWidth: | |
1131 case CSSPropertyBorderImageOutset: | |
1132 case CSSPropertyBorderImageRepeat: | |
1133 case CSSPropertyBorderImageSlice: | |
1134 case CSSPropertyBorderImageSource: | |
1135 case CSSPropertyBorderImageWidth: | |
1136 case CSSPropertyBorderLeftColor: | |
1137 case CSSPropertyBorderLeftStyle: | |
1138 case CSSPropertyBorderLeftWidth: | |
1139 case CSSPropertyBorderRightColor: | |
1140 case CSSPropertyBorderRightStyle: | |
1141 case CSSPropertyBorderRightWidth: | |
1142 case CSSPropertyBorderTopColor: | |
1143 case CSSPropertyBorderTopLeftRadius: | |
1144 case CSSPropertyBorderTopRightRadius: | |
1145 case CSSPropertyBorderTopStyle: | |
1146 case CSSPropertyBorderTopWidth: | |
1147 case CSSPropertyColor: | |
1148 case CSSPropertyFloat: | |
1149 case CSSPropertyFont: | |
1150 case CSSPropertyFontFamily: | |
1151 case CSSPropertyFontKerning: | |
1152 case CSSPropertyFontSize: | |
1153 case CSSPropertyFontStretch: | |
1154 case CSSPropertyFontStyle: | |
1155 case CSSPropertyFontVariant: | |
1156 case CSSPropertyFontVariantLigatures: | |
1157 case CSSPropertyFontWeight: | |
1158 case CSSPropertyLetterSpacing: | |
1159 case CSSPropertyLineHeight: | |
1160 case CSSPropertyMarginBottom: | |
1161 case CSSPropertyMarginLeft: | |
1162 case CSSPropertyMarginRight: | |
1163 case CSSPropertyMarginTop: | |
1164 case CSSPropertyPaddingBottom: | |
1165 case CSSPropertyPaddingLeft: | |
1166 case CSSPropertyPaddingRight: | |
1167 case CSSPropertyPaddingTop: | |
1168 case CSSPropertyTextTransform: | |
1169 case CSSPropertyVerticalAlign: | |
1170 case CSSPropertyWebkitBackgroundClip: | |
1171 case CSSPropertyWebkitBackgroundComposite: | |
1172 case CSSPropertyWebkitBackgroundOrigin: | |
1173 case CSSPropertyWebkitBackgroundSize: | |
1174 case CSSPropertyWebkitBorderAfter: | |
1175 case CSSPropertyWebkitBorderAfterColor: | |
1176 case CSSPropertyWebkitBorderAfterStyle: | |
1177 case CSSPropertyWebkitBorderAfterWidth: | |
1178 case CSSPropertyWebkitBorderBefore: | |
1179 case CSSPropertyWebkitBorderBeforeColor: | |
1180 case CSSPropertyWebkitBorderBeforeStyle: | |
1181 case CSSPropertyWebkitBorderBeforeWidth: | |
1182 case CSSPropertyWebkitBorderEnd: | |
1183 case CSSPropertyWebkitBorderEndColor: | |
1184 case CSSPropertyWebkitBorderEndStyle: | |
1185 case CSSPropertyWebkitBorderEndWidth: | |
1186 case CSSPropertyWebkitBorderFit: | |
1187 case CSSPropertyWebkitBorderHorizontalSpacing: | |
1188 case CSSPropertyWebkitBorderImage: | |
1189 case CSSPropertyWebkitBorderRadius: | |
1190 case CSSPropertyWebkitBorderStart: | |
1191 case CSSPropertyWebkitBorderStartColor: | |
1192 case CSSPropertyWebkitBorderStartStyle: | |
1193 case CSSPropertyWebkitBorderStartWidth: | |
1194 case CSSPropertyWebkitBorderVerticalSpacing: | |
1195 case CSSPropertyWebkitFontSmoothing: | |
1196 case CSSPropertyWebkitMarginAfter: | |
1197 case CSSPropertyWebkitMarginAfterCollapse: | |
1198 case CSSPropertyWebkitMarginBefore: | |
1199 case CSSPropertyWebkitMarginBeforeCollapse: | |
1200 case CSSPropertyWebkitMarginBottomCollapse: | |
1201 case CSSPropertyWebkitMarginCollapse: | |
1202 case CSSPropertyWebkitMarginEnd: | |
1203 case CSSPropertyWebkitMarginStart: | |
1204 case CSSPropertyWebkitMarginTopCollapse: | |
1205 case CSSPropertyWordSpacing: | |
1206 return true; | |
1207 case CSSPropertyTextDecorationColor: | |
1208 case CSSPropertyTextDecorationLine: | |
1209 case CSSPropertyTextDecorationStyle: | |
1210 return RuntimeEnabledFeatures::css3TextDecorationsEnabled(); | |
1211 | |
1212 // text-shadow added in text decoration spec: | |
1213 // http://www.w3.org/TR/css-text-decor-3/#text-shadow-property | |
1214 case CSSPropertyTextShadow: | |
1215 // box-shadox added in CSS3 backgrounds spec: | |
1216 // http://www.w3.org/TR/css3-background/#placement | |
1217 case CSSPropertyBoxShadow: | |
1218 case CSSPropertyWebkitBoxShadow: | |
1219 // Properties that we currently support outside of spec. | |
1220 case CSSPropertyWebkitLineBoxContain: | |
1221 case CSSPropertyVisibility: | |
1222 return true; | |
1223 | |
1224 default: | |
1225 return false; | |
1226 } | |
1227 } | |
1228 | |
1229 // FIXME: Consider refactoring to create a new class which owns the following | |
1230 // first/last/range properties. | |
1231 // This method returns the first CSSPropertyId of high priority properties. | |
1232 // Other properties can depend on high priority properties. For example, | |
1233 // border-color property with currentColor value depends on color property. | |
1234 // All high priority properties are obtained by using | |
1235 // firstCSSPropertyId<HighPriorityProperties> and | |
1236 // lastCSSPropertyId<HighPriorityProperties>. | |
1237 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr iorityProperties>() | |
1238 { | |
1239 COMPILE_ASSERT(CSSPropertyColor == firstCSSProperty, CSS_color_is_first_high _priority_property); | |
1240 return CSSPropertyColor; | |
1241 } | |
1242 | |
1243 // This method returns the last CSSPropertyId of high priority properties. | |
1244 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri orityProperties>() | |
1245 { | |
1246 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 17, CSS_line_heig ht_is_end_of_high_prioity_property_range); | |
1247 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_bef ore_line_height); | |
1248 return CSSPropertyLineHeight; | |
1249 } | |
1250 | |
1251 // This method returns the first CSSPropertyId of remaining properties, | |
1252 // i.e. low priority properties. No properties depend on low priority | |
1253 // properties. So we don't need to resolve such properties quickly. | |
1254 // All low priority properties are obtained by using | |
1255 // firstCSSPropertyId<LowPriorityProperties> and | |
1256 // lastCSSPropertyId<LowPriorityProperties>. | |
1257 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri orityProperties>() | |
1258 { | |
1259 COMPILE_ASSERT(CSSPropertyBackground == CSSPropertyLineHeight + 1, CSS_backg round_is_first_low_priority_property); | |
1260 return CSSPropertyBackground; | |
1261 } | |
1262 | |
1263 // This method returns the last CSSPropertyId of low priority properties. | |
1264 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio rityProperties>() | |
1265 { | |
1266 return static_cast<CSSPropertyID>(lastCSSProperty); | |
1267 } | |
1268 | |
1269 template <StyleResolver::StyleApplicationPass pass> | |
1270 bool StyleResolver::isPropertyForPass(CSSPropertyID property) | |
1271 { | |
1272 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty Id<pass>(); | |
1273 } | |
1274 | |
1275 // This method expands the 'all' shorthand property to longhand properties | |
1276 // and applies the expanded longhand properties. | |
1277 template <StyleResolver::StyleApplicationPass pass> | |
1278 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue) | |
1279 { | |
1280 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal ue(); | |
1281 unsigned startCSSProperty = firstCSSPropertyId<pass>(); | |
1282 unsigned endCSSProperty = lastCSSPropertyId<pass>(); | |
1283 | |
1284 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { | |
1285 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); | |
1286 | |
1287 // StyleBuilder does not allow any expanded shorthands. | |
1288 if (isExpandedShorthandForAll(propertyId)) | |
1289 continue; | |
1290 | |
1291 // all shorthand spec says: | |
1292 // The all property is a shorthand that resets all CSS properties | |
1293 // except direction and unicode-bidi. | |
1294 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand | |
1295 // We skip applyProperty when a given property is unicode-bidi or | |
1296 // direction. | |
1297 if (!CSSProperty::isAffectedByAllProperty(propertyId)) | |
1298 continue; | |
1299 | |
1300 CSSValue* value; | |
1301 if (!isUnsetValue) { | |
1302 value = allValue; | |
1303 } else { | |
1304 if (CSSProperty::isInheritedProperty(propertyId)) | |
1305 value = cssValuePool().createInheritedValue().get(); | |
1306 else | |
1307 value = cssValuePool().createExplicitInitialValue().get(); | |
1308 } | |
1309 StyleBuilder::applyProperty(propertyId, state, value); | |
1310 } | |
1311 } | |
1312 | |
1313 template <StyleResolver::StyleApplicationPass pass> | |
1314 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType) | |
1315 { | |
1316 state.setCurrentRule(rule); | |
1317 | |
1318 unsigned propertyCount = properties->propertyCount(); | |
1319 for (unsigned i = 0; i < propertyCount; ++i) { | |
1320 StylePropertySet::PropertyReference current = properties->propertyAt(i); | |
1321 if (isImportant != current.isImportant()) | |
1322 continue; | |
1323 | |
1324 CSSPropertyID property = current.id(); | |
1325 if (property == CSSPropertyAll) { | |
1326 applyAllProperty<pass>(state, current.value()); | |
1327 continue; | |
1328 } | |
1329 | |
1330 if (inheritedOnly && !current.isInherited()) { | |
1331 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties | |
1332 // as they might override the value inherited here. For this reason we don't allow declarations with | |
1333 // explicitly inherited properties to be cached. | |
1334 ASSERT(!current.value()->isInheritedValue()); | |
1335 continue; | |
1336 } | |
1337 | |
1338 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) | |
1339 continue; | |
1340 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property)) | |
1341 continue; | |
1342 if (!isPropertyForPass<pass>(property)) | |
1343 continue; | |
1344 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | |
1345 state.setLineHeightValue(current.value()); | |
1346 else | |
1347 StyleBuilder::applyProperty(current.id(), state, current.value()); | |
1348 } | |
1349 } | |
1350 | |
1351 template <StyleResolver::StyleApplicationPass pass> | |
1352 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly) | |
1353 { | |
1354 if (startIndex == -1) | |
1355 return; | |
1356 | |
1357 if (state.style()->insideLink() != NotInsideLink) { | |
1358 for (int i = startIndex; i <= endIndex; ++i) { | |
1359 const MatchedProperties& matchedProperties = matchResult.matchedProp erties[i]; | |
1360 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; | |
1361 // FIXME: It would be nicer to pass these as arguments but that requ ires changes in many places. | |
1362 state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker ::MatchLink); | |
1363 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChe cker::MatchVisited); | |
1364 | |
1365 applyProperties<pass>(state, matchedProperties.properties.get(), mat chResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitel istType>(matchedProperties.m_types.whitelistType)); | |
1366 } | |
1367 state.setApplyPropertyToRegularStyle(true); | |
1368 state.setApplyPropertyToVisitedLinkStyle(false); | |
1369 return; | |
1370 } | |
1371 for (int i = startIndex; i <= endIndex; ++i) { | |
1372 const MatchedProperties& matchedProperties = matchResult.matchedProperti es[i]; | |
1373 applyProperties<pass>(state, matchedProperties.properties.get(), matchRe sult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistT ype>(matchedProperties.m_types.whitelistType)); | |
1374 } | |
1375 } | |
1376 | |
1377 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) | 1099 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) |
1378 { | 1100 { |
1379 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); | 1101 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); |
1380 } | 1102 } |
1381 | 1103 |
1382 void StyleResolver::invalidateMatchedPropertiesCache() | 1104 void StyleResolver::invalidateMatchedPropertiesCache() |
1383 { | 1105 { |
1384 m_matchedPropertiesCache.clear(); | 1106 m_matchedPropertiesCache.clear(); |
1385 } | 1107 } |
1386 | 1108 |
(...skipping 29 matching lines...) Loading... | |
1416 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. | 1138 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. |
1417 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); | 1139 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); |
1418 | 1140 |
1419 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. | 1141 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. |
1420 state.style()->setInsideLink(linkStatus); | 1142 state.style()->setInsideLink(linkStatus); |
1421 return; | 1143 return; |
1422 } | 1144 } |
1423 applyInheritedOnly = true; | 1145 applyInheritedOnly = true; |
1424 } | 1146 } |
1425 | 1147 |
1426 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply | 1148 CascadedValues cascadedValues(state, matchResult); |
1427 // high-priority properties first, i.e., those properties that other propert ies depend on. | 1149 |
1428 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important | 1150 // The MatchResult has rules in UA - User - Author order, although we only |
1429 // and (4) normal important. | 1151 // use user rules for callback selectors. |
1430 state.setLineHeightValue(0); | 1152 cascadedValues.addMatchResult(matchResult, false, 0, matchResult.matchedProp erties.size() - 1); |
1431 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1153 cascadedValues.addMatchResult(matchResult, true, matchResult.ranges.firstAut horRule, matchResult.ranges.lastAuthorRule); |
1432 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); | 1154 cascadedValues.addMatchResult(matchResult, true, matchResult.ranges.firstUAR ule, matchResult.ranges.lastUARule); |
esprehn
2014/07/21 18:50:34
Can we get rid of this boolean?
Timothy Loh
2014/07/22 14:32:48
See other comment
| |
1433 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly); | 1155 |
1434 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1156 cascadedValues.applyValues(firstCSSPropertyId<HighPriorityProperties>(), las tCSSPropertyId<HighPriorityProperties>(), applyInheritedOnly); |
1435 | 1157 |
1436 if (UNLIKELY(isSVGForeignObjectElement(element))) { | 1158 if (UNLIKELY(isSVGForeignObjectElement(element))) { |
1437 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. | 1159 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. |
1438 // | 1160 // |
1439 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the | 1161 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the |
1440 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related | 1162 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related |
1441 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the | 1163 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the |
1442 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll | 1164 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll |
1443 // need to find another way of handling the SVG zoom model. | 1165 // need to find another way of handling the SVG zoom model. |
1444 state.setEffectiveZoom(RenderStyle::initialZoom()); | 1166 state.setEffectiveZoom(RenderStyle::initialZoom()); |
1445 } | 1167 } |
1446 | 1168 |
1447 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { | 1169 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { |
1448 state.fontBuilder().setFontDirty(true); | 1170 state.fontBuilder().setFontDirty(true); |
1449 applyInheritedOnly = false; | 1171 applyInheritedOnly = false; |
1450 } | 1172 } |
1451 | 1173 |
1452 // If our font got dirtied, go ahead and update it now. | 1174 // If our font got dirtied, go ahead and update it now. |
1453 updateFont(state); | 1175 updateFont(state); |
1454 | 1176 |
1455 // Line-height is set when we are sure we decided on the font-size. | |
1456 if (state.lineHeightValue()) | |
1457 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); | |
1458 | |
1459 // Many properties depend on the font. If it changes we just apply all prope rties. | 1177 // Many properties depend on the font. If it changes we just apply all prope rties. |
1460 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) | 1178 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) |
1461 applyInheritedOnly = false; | 1179 applyInheritedOnly = false; |
1462 | 1180 |
1463 // Now do the normal priority UA properties. | 1181 // This code supports -webkit-appearance, for which we are interested |
1464 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1182 // in whether the user has specified border or background properties. |
1183 // FIXME: This is a bit of a mess, we should just compare CSSValues and | |
1184 // store a single bit for this. | |
1185 if (elementTypeHasAppearanceFromUAStyle(*element)) { | |
1186 CascadedValues userAgentValues(state, matchResult); | |
1187 userAgentValues.addMatchResult(matchResult, false, matchResult.ranges.fi rstUARule, matchResult.ranges.lastUARule); | |
1188 // We only actually care about border and background properties here | |
1189 userAgentValues.applyValues(firstCSSPropertyId<LowPriorityProperties>(), lastCSSPropertyId<LowPriorityProperties>(), applyInheritedOnly); | |
1190 state.cacheUserAgentBorderAndBackground(); | |
1191 } | |
1465 | 1192 |
1466 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1193 cascadedValues.applyValues(firstCSSPropertyId<LowPriorityProperties>(), last CSSPropertyId<LowPriorityProperties>(), applyInheritedOnly); |
1467 state.cacheUserAgentBorderAndBackground(); | |
1468 | |
1469 // Now do the author and user normal priority properties and all the !import ant properties. | |
1470 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); | |
1471 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); | |
1472 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y); | |
1473 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | |
1474 | 1194 |
1475 loadPendingResources(state); | 1195 loadPendingResources(state); |
1476 | 1196 |
1477 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { | 1197 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { |
1478 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | 1198 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); |
1479 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); | 1199 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); |
1480 } | 1200 } |
1481 | 1201 |
1482 ASSERT(!state.fontBuilder().fontDirty()); | 1202 ASSERT(!state.fontBuilder().fontDirty()); |
1483 } | 1203 } |
(...skipping 81 matching lines...) Loading... | |
1565 visitor->trace(m_features); | 1285 visitor->trace(m_features); |
1566 visitor->trace(m_siblingRuleSet); | 1286 visitor->trace(m_siblingRuleSet); |
1567 visitor->trace(m_uncommonAttributeRuleSet); | 1287 visitor->trace(m_uncommonAttributeRuleSet); |
1568 visitor->trace(m_watchedSelectorsRules); | 1288 visitor->trace(m_watchedSelectorsRules); |
1569 visitor->trace(m_treeBoundaryCrossingRules); | 1289 visitor->trace(m_treeBoundaryCrossingRules); |
1570 visitor->trace(m_pendingStyleSheets); | 1290 visitor->trace(m_pendingStyleSheets); |
1571 #endif | 1291 #endif |
1572 } | 1292 } |
1573 | 1293 |
1574 } // namespace blink | 1294 } // namespace blink |
OLD | NEW |