| 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 { | 509 { |
| 510 if (!m_watchedSelectorsRules) | 510 if (!m_watchedSelectorsRules) |
| 511 return; | 511 return; |
| 512 | 512 |
| 513 collector.clearMatchedRules(); | 513 collector.clearMatchedRules(); |
| 514 collector.matchedResult().ranges.lastUserRule = collector.matchedResult().ma
tchedProperties.size() - 1; | 514 collector.matchedResult().ranges.lastUserRule = collector.matchedResult().ma
tchedProperties.size() - 1; |
| 515 | 515 |
| 516 MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 516 MatchRequest matchRequest(m_watchedSelectorsRules.get()); |
| 517 RuleRange ruleRange = collector.matchedResult().ranges.userRuleRange(); | 517 RuleRange ruleRange = collector.matchedResult().ranges.userRuleRange(); |
| 518 collector.collectMatchingRules(matchRequest, ruleRange); | 518 collector.collectMatchingRules(matchRequest, ruleRange); |
| 519 collector.collectMatchingRulesForRegion(matchRequest, ruleRange); | |
| 520 | 519 |
| 521 collector.sortAndTransferMatchedRules(); | 520 collector.sortAndTransferMatchedRules(); |
| 522 } | 521 } |
| 523 | 522 |
| 524 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 523 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
| 525 { | 524 { |
| 526 collector.setMatchingUARules(true); | 525 collector.setMatchingUARules(true); |
| 527 | 526 |
| 528 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); | 527 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); |
| 529 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") | 528 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 document.setWritingModeSetOnDocumentElement(false); | 622 document.setWritingModeSetOnDocumentElement(false); |
| 624 } | 623 } |
| 625 | 624 |
| 626 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) | 625 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) |
| 627 { | 626 { |
| 628 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 627 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
| 629 features.addAttributeInASelector(contentAttrValues[i]); | 628 features.addAttributeInASelector(contentAttrValues[i]); |
| 630 } | 629 } |
| 631 | 630 |
| 632 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 631 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 633 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 632 RuleMatchingBehavior matchingBehavior) |
| 634 { | 633 { |
| 635 ASSERT(document().frame()); | 634 ASSERT(document().frame()); |
| 636 ASSERT(documentSettings()); | 635 ASSERT(documentSettings()); |
| 637 ASSERT(!hasPendingAuthorStyleSheets()); | 636 ASSERT(!hasPendingAuthorStyleSheets()); |
| 638 ASSERT(!m_needCollectFeatures); | 637 ASSERT(!m_needCollectFeatures); |
| 639 | 638 |
| 640 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 639 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
| 641 // will vanish if a style recalc happens during loading. | 640 // will vanish if a style recalc happens during loading. |
| 642 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { | 641 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { |
| 643 if (!s_styleNotYetAvailable) { | 642 if (!s_styleNotYetAvailable) { |
| 644 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 643 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
| 645 s_styleNotYetAvailable->setDisplay(NONE); | 644 s_styleNotYetAvailable->setDisplay(NONE); |
| 646 s_styleNotYetAvailable->font().update(document().styleEngine()->font
Selector()); | 645 s_styleNotYetAvailable->font().update(document().styleEngine()->font
Selector()); |
| 647 } | 646 } |
| 648 element->document().setHasNodesWithPlaceholderStyle(); | 647 element->document().setHasNodesWithPlaceholderStyle(); |
| 649 return s_styleNotYetAvailable; | 648 return s_styleNotYetAvailable; |
| 650 } | 649 } |
| 651 | 650 |
| 652 didAccess(); | 651 didAccess(); |
| 653 | 652 |
| 654 if (element == document().documentElement()) | 653 if (element == document().documentElement()) |
| 655 resetDirectionAndWritingModeOnDocument(document()); | 654 resetDirectionAndWritingModeOnDocument(document()); |
| 656 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); | 655 StyleResolverState state(document(), element, defaultParent); |
| 657 | 656 |
| 658 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { | 657 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { |
| 659 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); | 658 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); |
| 660 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) | 659 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) |
| 661 return sharedStyle.release(); | 660 return sharedStyle.release(); |
| 662 } | 661 } |
| 663 | 662 |
| 664 if (state.parentStyle()) { | 663 if (state.parentStyle()) { |
| 665 state.setStyle(RenderStyle::create()); | 664 state.setStyle(RenderStyle::create()); |
| 666 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 665 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 690 state.style()->setInsideLink(linkState); | 689 state.style()->setInsideLink(linkState); |
| 691 } | 690 } |
| 692 | 691 |
| 693 bool needsCollection = false; | 692 bool needsCollection = false; |
| 694 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element
, needsCollection); | 693 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element
, needsCollection); |
| 695 if (needsCollection) | 694 if (needsCollection) |
| 696 collectFeatures(); | 695 collectFeatures(); |
| 697 | 696 |
| 698 { | 697 { |
| 699 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 698 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
| 700 collector.setRegionForStyling(regionForStyling); | |
| 701 | 699 |
| 702 if (matchingBehavior == MatchOnlyUserAgentRules) | 700 if (matchingBehavior == MatchOnlyUserAgentRules) |
| 703 matchUARules(collector); | 701 matchUARules(collector); |
| 704 else | 702 else |
| 705 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExc
ludingSMIL); | 703 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExc
ludingSMIL); |
| 706 | 704 |
| 707 applyMatchedProperties(state, collector.matchedResult()); | 705 applyMatchedProperties(state, collector.matchedResult()); |
| 708 | 706 |
| 709 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 707 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 710 } | 708 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 { | 1001 { |
| 1004 ASSERT(textNode); | 1002 ASSERT(textNode); |
| 1005 | 1003 |
| 1006 NodeRenderingTraversal::ParentDetails parentDetails; | 1004 NodeRenderingTraversal::ParentDetails parentDetails; |
| 1007 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); | 1005 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); |
| 1008 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) | 1006 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) |
| 1009 return defaultStyleForElement(); | 1007 return defaultStyleForElement(); |
| 1010 return parentNode->renderStyle(); | 1008 return parentNode->renderStyle(); |
| 1011 } | 1009 } |
| 1012 | 1010 |
| 1013 bool StyleResolver::checkRegionStyle(Element* regionElement) | |
| 1014 { | |
| 1015 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she
ets for the moment, | |
| 1016 // so all region rules are global by default. Verify whether that can stand
or needs changing. | |
| 1017 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { | |
| 1018 if (scopedResolver->checkRegionStyle(regionElement)) | |
| 1019 return true; | |
| 1020 } | |
| 1021 return false; | |
| 1022 } | |
| 1023 | |
| 1024 void StyleResolver::updateFont(StyleResolverState& state) | 1011 void StyleResolver::updateFont(StyleResolverState& state) |
| 1025 { | 1012 { |
| 1026 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); | 1013 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); |
| 1027 if (state.fontBuilder().fontSizeHasViewportUnits()) | 1014 if (state.fontBuilder().fontSizeHasViewportUnits()) |
| 1028 state.style()->setHasViewportUnits(); | 1015 state.style()->setHasViewportUnits(); |
| 1029 } | 1016 } |
| 1030 | 1017 |
| 1031 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) | 1018 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) |
| 1032 { | 1019 { |
| 1033 ASSERT(element); | 1020 ASSERT(element); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { | 1098 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { |
| 1112 CSSPropertyID property = iter->key; | 1099 CSSPropertyID property = iter->key; |
| 1113 if (!isPropertyForPass<pass>(property)) | 1100 if (!isPropertyForPass<pass>(property)) |
| 1114 continue; | 1101 continue; |
| 1115 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); | 1102 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); |
| 1116 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); | 1103 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); |
| 1117 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); | 1104 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); |
| 1118 } | 1105 } |
| 1119 } | 1106 } |
| 1120 | 1107 |
| 1121 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule | |
| 1122 // FIXME: add incremental support for other region styling properties. | |
| 1123 static inline bool isValidRegionStyleProperty(CSSPropertyID id) | |
| 1124 { | |
| 1125 switch (id) { | |
| 1126 case CSSPropertyBackgroundColor: | |
| 1127 case CSSPropertyColor: | |
| 1128 return true; | |
| 1129 default: | |
| 1130 break; | |
| 1131 } | |
| 1132 | |
| 1133 return false; | |
| 1134 } | |
| 1135 | |
| 1136 static inline bool isValidCueStyleProperty(CSSPropertyID id) | 1108 static inline bool isValidCueStyleProperty(CSSPropertyID id) |
| 1137 { | 1109 { |
| 1138 switch (id) { | 1110 switch (id) { |
| 1139 case CSSPropertyBackground: | 1111 case CSSPropertyBackground: |
| 1140 case CSSPropertyBackgroundAttachment: | 1112 case CSSPropertyBackgroundAttachment: |
| 1141 case CSSPropertyBackgroundClip: | 1113 case CSSPropertyBackgroundClip: |
| 1142 case CSSPropertyBackgroundColor: | 1114 case CSSPropertyBackgroundColor: |
| 1143 case CSSPropertyBackgroundImage: | 1115 case CSSPropertyBackgroundImage: |
| 1144 case CSSPropertyBackgroundOrigin: | 1116 case CSSPropertyBackgroundOrigin: |
| 1145 case CSSPropertyBackgroundPosition: | 1117 case CSSPropertyBackgroundPosition: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 case LowPriorityProperties: | 1172 case LowPriorityProperties: |
| 1201 return property > lastHighPriorityProperty; | 1173 return property > lastHighPriorityProperty; |
| 1202 } | 1174 } |
| 1203 ASSERT_NOT_REACHED(); | 1175 ASSERT_NOT_REACHED(); |
| 1204 return false; | 1176 return false; |
| 1205 } | 1177 } |
| 1206 | 1178 |
| 1207 template <StyleResolver::StyleApplicationPass pass> | 1179 template <StyleResolver::StyleApplicationPass pass> |
| 1208 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper
tyWhitelistType propertyWhitelistType) | 1180 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper
tyWhitelistType propertyWhitelistType) |
| 1209 { | 1181 { |
| 1210 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionFor
Styling()); | |
| 1211 state.setCurrentRule(rule); | 1182 state.setCurrentRule(rule); |
| 1212 | 1183 |
| 1213 unsigned propertyCount = properties->propertyCount(); | 1184 unsigned propertyCount = properties->propertyCount(); |
| 1214 for (unsigned i = 0; i < propertyCount; ++i) { | 1185 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1215 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1186 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| 1216 if (isImportant != current.isImportant()) | 1187 if (isImportant != current.isImportant()) |
| 1217 continue; | 1188 continue; |
| 1218 if (inheritedOnly && !current.isInherited()) { | 1189 if (inheritedOnly && !current.isInherited()) { |
| 1219 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 1190 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
| 1220 // as they might override the value inherited here. For this reason
we don't allow declarations with | 1191 // as they might override the value inherited here. For this reason
we don't allow declarations with |
| 1221 // explicitly inherited properties to be cached. | 1192 // explicitly inherited properties to be cached. |
| 1222 ASSERT(!current.value()->isInheritedValue()); | 1193 ASSERT(!current.value()->isInheritedValue()); |
| 1223 continue; | 1194 continue; |
| 1224 } | 1195 } |
| 1225 CSSPropertyID property = current.id(); | 1196 CSSPropertyID property = current.id(); |
| 1226 | 1197 |
| 1227 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt
yleProperty(property)) | |
| 1228 continue; | |
| 1229 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) | 1198 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) |
| 1230 continue; | 1199 continue; |
| 1231 if (!isPropertyForPass<pass>(property)) | 1200 if (!isPropertyForPass<pass>(property)) |
| 1232 continue; | 1201 continue; |
| 1233 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 1202 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
| 1234 state.setLineHeightValue(current.value()); | 1203 state.setLineHeightValue(current.value()); |
| 1235 else | 1204 else |
| 1236 StyleBuilder::applyProperty(current.id(), state, current.value()); | 1205 StyleBuilder::applyProperty(current.id(), state, current.value()); |
| 1237 } | 1206 } |
| 1238 } | 1207 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 1411 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
| 1443 { | 1412 { |
| 1444 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1413 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 1445 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1414 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1446 return true; | 1415 return true; |
| 1447 } | 1416 } |
| 1448 return false; | 1417 return false; |
| 1449 } | 1418 } |
| 1450 | 1419 |
| 1451 } // namespace WebCore | 1420 } // namespace WebCore |
| OLD | NEW |