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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 { | 499 { |
500 if (!m_watchedSelectorsRules) | 500 if (!m_watchedSelectorsRules) |
501 return; | 501 return; |
502 | 502 |
503 collector.clearMatchedRules(); | 503 collector.clearMatchedRules(); |
504 collector.matchedResult().ranges.lastUserRule = collector.matchedResult().ma
tchedProperties.size() - 1; | 504 collector.matchedResult().ranges.lastUserRule = collector.matchedResult().ma
tchedProperties.size() - 1; |
505 | 505 |
506 MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 506 MatchRequest matchRequest(m_watchedSelectorsRules.get()); |
507 RuleRange ruleRange = collector.matchedResult().ranges.userRuleRange(); | 507 RuleRange ruleRange = collector.matchedResult().ranges.userRuleRange(); |
508 collector.collectMatchingRules(matchRequest, ruleRange); | 508 collector.collectMatchingRules(matchRequest, ruleRange); |
509 collector.collectMatchingRulesForRegion(matchRequest, ruleRange); | |
510 | 509 |
511 collector.sortAndTransferMatchedRules(); | 510 collector.sortAndTransferMatchedRules(); |
512 } | 511 } |
513 | 512 |
514 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 513 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
515 { | 514 { |
516 collector.setMatchingUARules(true); | 515 collector.setMatchingUARules(true); |
517 | 516 |
518 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") | 517 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") |
519 ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defa
ultStyle; | 518 ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defa
ultStyle; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 document.setWritingModeSetOnDocumentElement(false); | 611 document.setWritingModeSetOnDocumentElement(false); |
613 } | 612 } |
614 | 613 |
615 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) | 614 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt
trValues, RuleFeatureSet& features) |
616 { | 615 { |
617 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 616 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
618 features.addAttributeInASelector(contentAttrValues[i]); | 617 features.addAttributeInASelector(contentAttrValues[i]); |
619 } | 618 } |
620 | 619 |
621 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 620 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
622 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 621 RuleMatchingBehavior matchingBehavior) |
623 { | 622 { |
624 ASSERT(document().frame()); | 623 ASSERT(document().frame()); |
625 ASSERT(documentSettings()); | 624 ASSERT(documentSettings()); |
626 ASSERT(!hasPendingAuthorStyleSheets()); | 625 ASSERT(!hasPendingAuthorStyleSheets()); |
627 ASSERT(!m_needCollectFeatures); | 626 ASSERT(!m_needCollectFeatures); |
628 | 627 |
629 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 628 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
630 // will vanish if a style recalc happens during loading. | 629 // will vanish if a style recalc happens during loading. |
631 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { | 630 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { |
632 if (!s_styleNotYetAvailable) { | 631 if (!s_styleNotYetAvailable) { |
633 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 632 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
634 s_styleNotYetAvailable->setDisplay(NONE); | 633 s_styleNotYetAvailable->setDisplay(NONE); |
635 s_styleNotYetAvailable->font().update(document().styleEngine()->font
Selector()); | 634 s_styleNotYetAvailable->font().update(document().styleEngine()->font
Selector()); |
636 } | 635 } |
637 element->document().setHasNodesWithPlaceholderStyle(); | 636 element->document().setHasNodesWithPlaceholderStyle(); |
638 return s_styleNotYetAvailable; | 637 return s_styleNotYetAvailable; |
639 } | 638 } |
640 | 639 |
641 didAccess(); | 640 didAccess(); |
642 | 641 |
643 if (element == document().documentElement()) | 642 if (element == document().documentElement()) |
644 resetDirectionAndWritingModeOnDocument(document()); | 643 resetDirectionAndWritingModeOnDocument(document()); |
645 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); | 644 StyleResolverState state(document(), element, defaultParent); |
646 | 645 |
647 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi
nt() && state.parentStyle()) { | 646 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi
nt() && state.parentStyle()) { |
648 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); | 647 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); |
649 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) | 648 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) |
650 return sharedStyle.release(); | 649 return sharedStyle.release(); |
651 } | 650 } |
652 | 651 |
653 if (state.parentStyle()) { | 652 if (state.parentStyle()) { |
654 state.setStyle(RenderStyle::create()); | 653 state.setStyle(RenderStyle::create()); |
655 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 654 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
(...skipping 23 matching lines...) Expand all Loading... |
679 state.style()->setInsideLink(linkState); | 678 state.style()->setInsideLink(linkState); |
680 } | 679 } |
681 | 680 |
682 bool needsCollection = false; | 681 bool needsCollection = false; |
683 CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsColl
ection); | 682 CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsColl
ection); |
684 if (needsCollection) | 683 if (needsCollection) |
685 collectFeatures(); | 684 collectFeatures(); |
686 | 685 |
687 { | 686 { |
688 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 687 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
689 collector.setRegionForStyling(regionForStyling); | |
690 | 688 |
691 if (matchingBehavior == MatchOnlyUserAgentRules) | 689 if (matchingBehavior == MatchOnlyUserAgentRules) |
692 matchUARules(collector); | 690 matchUARules(collector); |
693 else | 691 else |
694 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExc
ludingSMIL); | 692 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExc
ludingSMIL); |
695 | 693 |
696 applyMatchedProperties(state, collector.matchedResult()); | 694 applyMatchedProperties(state, collector.matchedResult()); |
697 | 695 |
698 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 696 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
699 } | 697 } |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 { | 1053 { |
1056 ASSERT(textNode); | 1054 ASSERT(textNode); |
1057 | 1055 |
1058 NodeRenderingTraversal::ParentDetails parentDetails; | 1056 NodeRenderingTraversal::ParentDetails parentDetails; |
1059 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); | 1057 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); |
1060 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) | 1058 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) |
1061 return defaultStyleForElement(); | 1059 return defaultStyleForElement(); |
1062 return parentNode->renderStyle(); | 1060 return parentNode->renderStyle(); |
1063 } | 1061 } |
1064 | 1062 |
1065 bool StyleResolver::checkRegionStyle(Element* regionElement) | |
1066 { | |
1067 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she
ets for the moment, | |
1068 // so all region rules are global by default. Verify whether that can stand
or needs changing. | |
1069 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { | |
1070 if (scopedResolver->checkRegionStyle(regionElement)) | |
1071 return true; | |
1072 } | |
1073 return false; | |
1074 } | |
1075 | |
1076 void StyleResolver::updateFont(StyleResolverState& state) | 1063 void StyleResolver::updateFont(StyleResolverState& state) |
1077 { | 1064 { |
1078 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); | 1065 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.parentStyle(), state.style()); |
1079 if (state.fontBuilder().fontSizeHasViewportUnits()) | 1066 if (state.fontBuilder().fontSizeHasViewportUnits()) |
1080 state.style()->setHasViewportUnits(); | 1067 state.style()->setHasViewportUnits(); |
1081 } | 1068 } |
1082 | 1069 |
1083 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) | 1070 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) |
1084 { | 1071 { |
1085 ASSERT(element); | 1072 ASSERT(element); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { | 1155 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { |
1169 CSSPropertyID property = iter->key; | 1156 CSSPropertyID property = iter->key; |
1170 if (!isPropertyForPass<pass>(property)) | 1157 if (!isPropertyForPass<pass>(property)) |
1171 continue; | 1158 continue; |
1172 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); | 1159 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); |
1173 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); | 1160 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); |
1174 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); | 1161 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); |
1175 } | 1162 } |
1176 } | 1163 } |
1177 | 1164 |
1178 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule | |
1179 // FIXME: add incremental support for other region styling properties. | |
1180 static inline bool isValidRegionStyleProperty(CSSPropertyID id) | |
1181 { | |
1182 switch (id) { | |
1183 case CSSPropertyBackgroundColor: | |
1184 case CSSPropertyColor: | |
1185 return true; | |
1186 default: | |
1187 break; | |
1188 } | |
1189 | |
1190 return false; | |
1191 } | |
1192 | |
1193 static inline bool isValidCueStyleProperty(CSSPropertyID id) | 1165 static inline bool isValidCueStyleProperty(CSSPropertyID id) |
1194 { | 1166 { |
1195 switch (id) { | 1167 switch (id) { |
1196 case CSSPropertyBackground: | 1168 case CSSPropertyBackground: |
1197 case CSSPropertyBackgroundAttachment: | 1169 case CSSPropertyBackgroundAttachment: |
1198 case CSSPropertyBackgroundClip: | 1170 case CSSPropertyBackgroundClip: |
1199 case CSSPropertyBackgroundColor: | 1171 case CSSPropertyBackgroundColor: |
1200 case CSSPropertyBackgroundImage: | 1172 case CSSPropertyBackgroundImage: |
1201 case CSSPropertyBackgroundOrigin: | 1173 case CSSPropertyBackgroundOrigin: |
1202 case CSSPropertyBackgroundPosition: | 1174 case CSSPropertyBackgroundPosition: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 case LowPriorityProperties: | 1232 case LowPriorityProperties: |
1261 return property > lastHighPriorityProperty; | 1233 return property > lastHighPriorityProperty; |
1262 } | 1234 } |
1263 ASSERT_NOT_REACHED(); | 1235 ASSERT_NOT_REACHED(); |
1264 return false; | 1236 return false; |
1265 } | 1237 } |
1266 | 1238 |
1267 template <StyleResolver::StyleApplicationPass pass> | 1239 template <StyleResolver::StyleApplicationPass pass> |
1268 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper
tyWhitelistType propertyWhitelistType) | 1240 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper
tyWhitelistType propertyWhitelistType) |
1269 { | 1241 { |
1270 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionFor
Styling()); | |
1271 state.setCurrentRule(rule); | 1242 state.setCurrentRule(rule); |
1272 | 1243 |
1273 unsigned propertyCount = properties->propertyCount(); | 1244 unsigned propertyCount = properties->propertyCount(); |
1274 for (unsigned i = 0; i < propertyCount; ++i) { | 1245 for (unsigned i = 0; i < propertyCount; ++i) { |
1275 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1246 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
1276 if (isImportant != current.isImportant()) | 1247 if (isImportant != current.isImportant()) |
1277 continue; | 1248 continue; |
1278 if (inheritedOnly && !current.isInherited()) { | 1249 if (inheritedOnly && !current.isInherited()) { |
1279 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 1250 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
1280 // as they might override the value inherited here. For this reason
we don't allow declarations with | 1251 // as they might override the value inherited here. For this reason
we don't allow declarations with |
1281 // explicitly inherited properties to be cached. | 1252 // explicitly inherited properties to be cached. |
1282 ASSERT(!current.value()->isInheritedValue()); | 1253 ASSERT(!current.value()->isInheritedValue()); |
1283 continue; | 1254 continue; |
1284 } | 1255 } |
1285 CSSPropertyID property = current.id(); | 1256 CSSPropertyID property = current.id(); |
1286 | 1257 |
1287 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt
yleProperty(property)) | |
1288 continue; | |
1289 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) | 1258 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) |
1290 continue; | 1259 continue; |
1291 if (!isPropertyForPass<pass>(property)) | 1260 if (!isPropertyForPass<pass>(property)) |
1292 continue; | 1261 continue; |
1293 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 1262 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
1294 state.setLineHeightValue(current.value()); | 1263 state.setLineHeightValue(current.value()); |
1295 else | 1264 else |
1296 StyleBuilder::applyProperty(current.id(), state, current.value()); | 1265 StyleBuilder::applyProperty(current.id(), state, current.value()); |
1297 } | 1266 } |
1298 } | 1267 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 1476 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
1508 { | 1477 { |
1509 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1478 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
1510 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1479 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1511 return true; | 1480 return true; |
1512 } | 1481 } |
1513 return false; | 1482 return false; |
1514 } | 1483 } |
1515 | 1484 |
1516 } // namespace WebCore | 1485 } // namespace WebCore |
OLD | NEW |