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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 resetDirectionAndWritingModeOnDocument(document()); | 665 resetDirectionAndWritingModeOnDocument(document()); |
666 StyleResolverState state(document(), &element, parentStyle); | 666 StyleResolverState state(document(), &element, parentStyle); |
667 | 667 |
668 MatchResult result; | 668 MatchResult result; |
669 result.addMatchedProperties(&keyframe->properties()); | 669 result.addMatchedProperties(&keyframe->properties()); |
670 | 670 |
671 ASSERT(!state.style()); | 671 ASSERT(!state.style()); |
672 | 672 |
673 // Create the style | 673 // Create the style |
674 state.setStyle(RenderStyle::clone(&elementStyle)); | 674 state.setStyle(RenderStyle::clone(&elementStyle)); |
675 state.setLineHeightValue(0); | |
676 | 675 |
677 // We don't need to bother with !important. Since there is only ever one | 676 // We don't need to bother with !important. Since there is only ever one |
678 // decl, there's nothing to override. So just add the first properties. | 677 // decl, there's nothing to override. So just add the first properties. |
679 // We also don't need to bother with animation properties since the only | 678 // We also don't need to bother with animation properties since the only |
680 // relevant one is animation-timing-function and we special-case that in | 679 // relevant one is animation-timing-function and we special-case that in |
681 // CSSAnimations.cpp | 680 // CSSAnimations.cpp |
682 bool inheritedOnly = false; | 681 bool inheritedOnly = false; |
683 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 682 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); |
684 | 683 |
685 // If our font got dirtied, go ahead and update it now. | 684 // If our font got dirtied, go ahead and update it now. |
686 updateFont(state); | 685 updateFont(state); |
687 | 686 |
688 // Line-height is set when we are sure we decided on the font-size | |
689 if (state.lineHeightValue()) | |
690 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | |
691 | |
692 // Now do rest of the properties. | 687 // Now do rest of the properties. |
693 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 688 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); |
694 | 689 |
695 loadPendingResources(state); | 690 loadPendingResources(state); |
696 | 691 |
697 didAccess(); | 692 didAccess(); |
698 | 693 |
699 return state.takeStyle(); | 694 return state.takeStyle(); |
700 } | 695 } |
701 | 696 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 ASSERT(rootElementStyle); | 854 ASSERT(rootElementStyle); |
860 state.style()->inheritFrom(rootElementStyle); | 855 state.style()->inheritFrom(rootElementStyle); |
861 | 856 |
862 PageRuleCollector collector(rootElementStyle, pageIndex); | 857 PageRuleCollector collector(rootElementStyle, pageIndex); |
863 | 858 |
864 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); | 859 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); |
865 | 860 |
866 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 861 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
867 scopedResolver->matchPageRules(collector); | 862 scopedResolver->matchPageRules(collector); |
868 | 863 |
869 state.setLineHeightValue(0); | |
870 bool inheritedOnly = false; | 864 bool inheritedOnly = false; |
871 | 865 |
872 MatchResult& result = collector.matchedResult(); | 866 MatchResult& result = collector.matchedResult(); |
873 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 867 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); |
874 | 868 |
875 // If our font got dirtied, go ahead and update it now. | 869 // If our font got dirtied, go ahead and update it now. |
876 updateFont(state); | 870 updateFont(state); |
877 | 871 |
878 // Line-height is set when we are sure we decided on the font-size. | |
879 if (state.lineHeightValue()) | |
880 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | |
881 | |
882 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 872 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); |
883 | 873 |
884 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 874 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
885 | 875 |
886 loadPendingResources(state); | 876 loadPendingResources(state); |
887 | 877 |
888 didAccess(); | 878 didAccess(); |
889 | 879 |
890 // Now return the style. | 880 // Now return the style. |
891 return state.takeStyle(); | 881 return state.takeStyle(); |
(...skipping 13 matching lines...) Expand all Loading... |
905 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 895 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
906 scopedResolver->collectViewportRulesTo(this); | 896 scopedResolver->collectViewportRulesTo(this); |
907 | 897 |
908 viewportStyleResolver()->resolve(); | 898 viewportStyleResolver()->resolve(); |
909 } | 899 } |
910 | 900 |
911 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 901 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
912 { | 902 { |
913 StyleResolverState state(document(), 0); | 903 StyleResolverState state(document(), 0); |
914 state.setStyle(RenderStyle::create()); | 904 state.setStyle(RenderStyle::create()); |
915 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | |
916 state.setLineHeightValue(0); | |
917 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 905 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
918 state.style()->font().update(document().styleEngine()->fontSelector()); | 906 state.style()->font().update(document().styleEngine()->fontSelector()); |
919 return state.takeStyle(); | 907 return state.takeStyle(); |
920 } | 908 } |
921 | 909 |
922 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 910 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
923 { | 911 { |
924 ASSERT(textNode); | 912 ASSERT(textNode); |
925 | 913 |
926 Node* parentNode = NodeRenderingTraversal::parent(textNode); | 914 Node* parentNode = NodeRenderingTraversal::parent(textNode); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 // lastCSSPropertyId<HighPriorityProperties>. | 1234 // lastCSSPropertyId<HighPriorityProperties>. |
1247 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr
iorityProperties>() | 1235 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr
iorityProperties>() |
1248 { | 1236 { |
1249 COMPILE_ASSERT(CSSPropertyColor == firstCSSProperty, CSS_color_is_first_high
_priority_property); | 1237 COMPILE_ASSERT(CSSPropertyColor == firstCSSProperty, CSS_color_is_first_high
_priority_property); |
1250 return CSSPropertyColor; | 1238 return CSSPropertyColor; |
1251 } | 1239 } |
1252 | 1240 |
1253 // This method returns the last CSSPropertyId of high priority properties. | 1241 // This method returns the last CSSPropertyId of high priority properties. |
1254 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri
orityProperties>() | 1242 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri
orityProperties>() |
1255 { | 1243 { |
1256 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 17, CSS_line_heig
ht_is_end_of_high_prioity_property_range); | 1244 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_
high_priority_property_range); |
1257 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_bef
ore_line_height); | 1245 COMPILE_ASSERT(CSSPropertyTextRendering == CSSPropertyZoom - 1, CSS_text_ren
dering_is_before_zoom); |
1258 return CSSPropertyLineHeight; | 1246 return CSSPropertyZoom; |
1259 } | 1247 } |
1260 | 1248 |
1261 // This method returns the first CSSPropertyId of remaining properties, | 1249 // This method returns the first CSSPropertyId of remaining properties, |
1262 // i.e. low priority properties. No properties depend on low priority | 1250 // i.e. low priority properties. No properties depend on low priority |
1263 // properties. So we don't need to resolve such properties quickly. | 1251 // properties. So we don't need to resolve such properties quickly. |
1264 // All low priority properties are obtained by using | 1252 // All low priority properties are obtained by using |
1265 // firstCSSPropertyId<LowPriorityProperties> and | 1253 // firstCSSPropertyId<LowPriorityProperties> and |
1266 // lastCSSPropertyId<LowPriorityProperties>. | 1254 // lastCSSPropertyId<LowPriorityProperties>. |
1267 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri
orityProperties>() | 1255 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri
orityProperties>() |
1268 { | 1256 { |
1269 COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyLineHeight + 1, CSS_bac
kground_is_first_low_priority_property); | 1257 COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyZoom + 1, CSS_align_con
tent_is_first_low_priority_property); |
1270 return CSSPropertyAlignContent; | 1258 return CSSPropertyAlignContent; |
1271 } | 1259 } |
1272 | 1260 |
1273 // This method returns the last CSSPropertyId of low priority properties. | 1261 // This method returns the last CSSPropertyId of low priority properties. |
1274 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio
rityProperties>() | 1262 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio
rityProperties>() |
1275 { | 1263 { |
1276 return static_cast<CSSPropertyID>(lastCSSProperty); | 1264 return static_cast<CSSPropertyID>(lastCSSProperty); |
1277 } | 1265 } |
1278 | 1266 |
1279 template <StyleResolver::StyleApplicationPass pass> | 1267 template <StyleResolver::StyleApplicationPass pass> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 ASSERT(!current.value()->isInheritedValue()); | 1330 ASSERT(!current.value()->isInheritedValue()); |
1343 continue; | 1331 continue; |
1344 } | 1332 } |
1345 | 1333 |
1346 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) | 1334 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) |
1347 continue; | 1335 continue; |
1348 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir
stLetterStyleProperty(property)) | 1336 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir
stLetterStyleProperty(property)) |
1349 continue; | 1337 continue; |
1350 if (!isPropertyForPass<pass>(property)) | 1338 if (!isPropertyForPass<pass>(property)) |
1351 continue; | 1339 continue; |
1352 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 1340 |
1353 state.setLineHeightValue(current.value()); | 1341 StyleBuilder::applyProperty(current.id(), state, current.value()); |
1354 else | |
1355 StyleBuilder::applyProperty(current.id(), state, current.value()); | |
1356 } | 1342 } |
1357 } | 1343 } |
1358 | 1344 |
1359 template <StyleResolver::StyleApplicationPass pass> | 1345 template <StyleResolver::StyleApplicationPass pass> |
1360 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher
itedOnly) | 1346 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher
itedOnly) |
1361 { | 1347 { |
1362 if (startIndex == -1) | 1348 if (startIndex == -1) |
1363 return; | 1349 return; |
1364 | 1350 |
1365 if (state.style()->insideLink() != NotInsideLink) { | 1351 if (state.style()->insideLink() != NotInsideLink) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 state.style()->setInsideLink(linkStatus); | 1414 state.style()->setInsideLink(linkStatus); |
1429 return; | 1415 return; |
1430 } | 1416 } |
1431 applyInheritedOnly = true; | 1417 applyInheritedOnly = true; |
1432 } | 1418 } |
1433 | 1419 |
1434 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 1420 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
1435 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 1421 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
1436 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 1422 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
1437 // and (4) normal important. | 1423 // and (4) normal important. |
1438 state.setLineHeightValue(0); | |
1439 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1424 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
1440 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); | 1425 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); |
1441 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1426 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1442 | 1427 |
1443 if (UNLIKELY(isSVGForeignObjectElement(element))) { | 1428 if (UNLIKELY(isSVGForeignObjectElement(element))) { |
1444 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb
ject content should not be scaled again. | 1429 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb
ject content should not be scaled again. |
1445 // | 1430 // |
1446 // FIXME: The following hijacks the zoom property for foreignObject so t
hat children of foreignObject get the | 1431 // FIXME: The following hijacks the zoom property for foreignObject so t
hat children of foreignObject get the |
1447 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP
roperties, along with other font-related | 1432 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP
roperties, along with other font-related |
1448 // properties used as input to the FontBuilder, so resetting it here may
cause the FontBuilder to recompute the | 1433 // properties used as input to the FontBuilder, so resetting it here may
cause the FontBuilder to recompute the |
1449 // font used as inheritable font for foreignObject content. If we want t
o support zoom on foreignObject we'll | 1434 // font used as inheritable font for foreignObject content. If we want t
o support zoom on foreignObject we'll |
1450 // need to find another way of handling the SVG zoom model. | 1435 // need to find another way of handling the SVG zoom model. |
1451 state.setEffectiveZoom(RenderStyle::initialZoom()); | 1436 state.setEffectiveZoom(RenderStyle::initialZoom()); |
1452 } | 1437 } |
1453 | 1438 |
1454 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { | 1439 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { |
1455 state.fontBuilder().setFontDirty(true); | 1440 state.fontBuilder().setFontDirty(true); |
1456 applyInheritedOnly = false; | 1441 applyInheritedOnly = false; |
1457 } | 1442 } |
1458 | 1443 |
1459 // If our font got dirtied, go ahead and update it now. | 1444 // If our font got dirtied, go ahead and update it now. |
1460 updateFont(state); | 1445 updateFont(state); |
1461 | 1446 |
1462 // Line-height is set when we are sure we decided on the font-size. | |
1463 if (state.lineHeightValue()) | |
1464 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | |
1465 | |
1466 // Many properties depend on the font. If it changes we just apply all prope
rties. | 1447 // Many properties depend on the font. If it changes we just apply all prope
rties. |
1467 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) | 1448 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) |
1468 applyInheritedOnly = false; | 1449 applyInheritedOnly = false; |
1469 | 1450 |
1470 // Now do the normal priority UA properties. | 1451 // Now do the normal priority UA properties. |
1471 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1452 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1472 | 1453 |
1473 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1454 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
1474 state.cacheUserAgentBorderAndBackground(); | 1455 state.cacheUserAgentBorderAndBackground(); |
1475 | 1456 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 visitor->trace(m_uncommonAttributeRuleSet); | 1573 visitor->trace(m_uncommonAttributeRuleSet); |
1593 visitor->trace(m_watchedSelectorsRules); | 1574 visitor->trace(m_watchedSelectorsRules); |
1594 visitor->trace(m_treeBoundaryCrossingRules); | 1575 visitor->trace(m_treeBoundaryCrossingRules); |
1595 visitor->trace(m_styleSharingLists); | 1576 visitor->trace(m_styleSharingLists); |
1596 visitor->trace(m_pendingStyleSheets); | 1577 visitor->trace(m_pendingStyleSheets); |
1597 visitor->trace(m_document); | 1578 visitor->trace(m_document); |
1598 #endif | 1579 #endif |
1599 } | 1580 } |
1600 | 1581 |
1601 } // namespace blink | 1582 } // namespace blink |
OLD | NEW |