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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 } | 644 } |
645 // contenteditable attribute (implemented by -webkit-user-modify) should | 645 // contenteditable attribute (implemented by -webkit-user-modify) should |
646 // be propagated from shadow host to distributed node. | 646 // be propagated from shadow host to distributed node. |
647 if (state.distributedToInsertionPoint()) { | 647 if (state.distributedToInsertionPoint()) { |
648 if (Element* parent = element->parentElement()) { | 648 if (Element* parent = element->parentElement()) { |
649 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 649 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) |
650 state.style()->setUserModify(styleOfShadowHost->userModify()); | 650 state.style()->setUserModify(styleOfShadowHost->userModify()); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 654 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
655 | 655 |
656 if (element->isLink()) { | 656 if (element->isLink()) { |
657 state.style()->setIsLink(true); | 657 state.style()->setIsLink(true); |
658 EInsideLink linkState = state.elementLinkState(); | 658 EInsideLink linkState = state.elementLinkState(); |
659 if (linkState != NotInsideLink) { | 659 if (linkState != NotInsideLink) { |
660 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); | 660 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); |
661 if (forceVisited) | 661 if (forceVisited) |
662 linkState = InsideVisitedLink; | 662 linkState = InsideVisitedLink; |
663 } | 663 } |
664 state.style()->setInsideLink(linkState); | 664 state.style()->setInsideLink(linkState); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 712 |
713 MatchResult result; | 713 MatchResult result; |
714 result.addMatchedProperties(&keyframe->properties()); | 714 result.addMatchedProperties(&keyframe->properties()); |
715 | 715 |
716 ASSERT(!state.style()); | 716 ASSERT(!state.style()); |
717 | 717 |
718 // Create the style | 718 // Create the style |
719 state.setStyle(RenderStyle::clone(&elementStyle)); | 719 state.setStyle(RenderStyle::clone(&elementStyle)); |
720 state.setLineHeightValue(0); | 720 state.setLineHeightValue(0); |
721 | 721 |
722 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 722 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
723 | 723 |
724 // We don't need to bother with !important. Since there is only ever one | 724 // We don't need to bother with !important. Since there is only ever one |
725 // decl, there's nothing to override. So just add the first properties. | 725 // decl, there's nothing to override. So just add the first properties. |
726 // We also don't need to bother with animation properties since the only | 726 // We also don't need to bother with animation properties since the only |
727 // relevant one is animation-timing-function and we special-case that in | 727 // relevant one is animation-timing-function and we special-case that in |
728 // CSSAnimations.cpp | 728 // CSSAnimations.cpp |
729 bool inheritedOnly = false; | 729 bool inheritedOnly = false; |
730 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); | 730 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); |
731 | 731 |
732 // If our font got dirtied, go ahead and update it now. | 732 // If our font got dirtied, go ahead and update it now. |
(...skipping 26 matching lines...) Expand all Loading... | |
759 style = RenderStyle::clone(element.renderStyle()); | 759 style = RenderStyle::clone(element.renderStyle()); |
760 else | 760 else |
761 style = RenderStyle::create(); | 761 style = RenderStyle::create(); |
762 return createAnimatableValueSnapshot(element, property, value, *style); | 762 return createAnimatableValueSnapshot(element, property, value, *style); |
763 } | 763 } |
764 | 764 |
765 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty le) | 765 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty le) |
766 { | 766 { |
767 StyleResolverState state(element.document(), &element); | 767 StyleResolverState state(element.document(), &element); |
768 state.setStyle(&style); | 768 state.setStyle(&style); |
769 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 769 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
770 StyleBuilder::applyProperty(property, state, &value); | 770 StyleBuilder::applyProperty(property, state, &value); |
771 return CSSAnimatableValueFactory::create(property, style); | 771 return CSSAnimatableValueFactory::create(property, style); |
772 } | 772 } |
773 | 773 |
774 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) | 774 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) |
775 { | 775 { |
776 RenderObject* parentRenderer = parent.renderer(); | 776 RenderObject* parentRenderer = parent.renderer(); |
777 if (!parentRenderer) | 777 if (!parentRenderer) |
778 return nullptr; | 778 return nullptr; |
779 | 779 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 StyleResolverParentScope::ensureParentStackIsPushed(); | 820 StyleResolverParentScope::ensureParentStackIsPushed(); |
821 | 821 |
822 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 822 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
823 state.setStyle(RenderStyle::create()); | 823 state.setStyle(RenderStyle::create()); |
824 state.style()->inheritFrom(state.parentStyle()); | 824 state.style()->inheritFrom(state.parentStyle()); |
825 } else { | 825 } else { |
826 state.setStyle(defaultStyleForElement()); | 826 state.setStyle(defaultStyleForElement()); |
827 state.setParentStyle(RenderStyle::clone(state.style())); | 827 state.setParentStyle(RenderStyle::clone(state.style())); |
828 } | 828 } |
829 | 829 |
830 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 830 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
831 | 831 |
832 // Since we don't use pseudo-elements in any of our quirk/print | 832 // Since we don't use pseudo-elements in any of our quirk/print |
833 // user agent rules, don't waste time walking those rules. | 833 // user agent rules, don't waste time walking those rules. |
834 | 834 |
835 { | 835 { |
836 // Check UA, user and author rules. | 836 // Check UA, user and author rules. |
837 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); | 837 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); |
838 collector.setPseudoStyleRequest(pseudoStyleRequest); | 838 collector.setPseudoStyleRequest(pseudoStyleRequest); |
839 | 839 |
840 matchUARules(collector); | 840 matchUARules(collector); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
889 { | 889 { |
890 ASSERT(!hasPendingAuthorStyleSheets()); | 890 ASSERT(!hasPendingAuthorStyleSheets()); |
891 resetDirectionAndWritingModeOnDocument(document()); | 891 resetDirectionAndWritingModeOnDocument(document()); |
892 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. | 892 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. |
893 | 893 |
894 state.setStyle(RenderStyle::create()); | 894 state.setStyle(RenderStyle::create()); |
895 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); | 895 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); |
896 ASSERT(rootElementStyle); | 896 ASSERT(rootElementStyle); |
897 state.style()->inheritFrom(rootElementStyle); | 897 state.style()->inheritFrom(rootElementStyle); |
898 | 898 |
899 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 899 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
900 | 900 |
901 PageRuleCollector collector(rootElementStyle, pageIndex); | 901 PageRuleCollector collector(rootElementStyle, pageIndex); |
902 | 902 |
903 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); | 903 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); |
904 | 904 |
905 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) | 905 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) |
906 scopedResolver->matchPageRules(collector); | 906 scopedResolver->matchPageRules(collector); |
907 | 907 |
908 state.setLineHeightValue(0); | 908 state.setLineHeightValue(0); |
909 bool inheritedOnly = false; | 909 bool inheritedOnly = false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) | 944 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor Document()) |
945 scopedResolver->collectViewportRulesTo(this); | 945 scopedResolver->collectViewportRulesTo(this); |
946 | 946 |
947 viewportStyleResolver()->resolve(); | 947 viewportStyleResolver()->resolve(); |
948 } | 948 } |
949 | 949 |
950 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 950 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
951 { | 951 { |
952 StyleResolverState state(document(), 0); | 952 StyleResolverState state(document(), 0); |
953 state.setStyle(RenderStyle::create()); | 953 state.setStyle(RenderStyle::create()); |
954 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use SVGZoomRules()); | 954 state.fontBuilder().initForStyleResolve(document(), state.style()); |
955 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 955 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
956 state.setLineHeightValue(0); | 956 state.setLineHeightValue(0); |
957 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 957 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
958 state.style()->font().update(document().styleEngine()->fontSelector()); | 958 state.style()->font().update(document().styleEngine()->fontSelector()); |
959 return state.takeStyle(); | 959 return state.takeStyle(); |
960 } | 960 } |
961 | 961 |
962 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 962 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
963 { | 963 { |
964 ASSERT(textNode); | 964 ASSERT(textNode); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1377 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply | 1377 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply |
1378 // high-priority properties first, i.e., those properties that other propert ies depend on. | 1378 // high-priority properties first, i.e., those properties that other propert ies depend on. |
1379 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important | 1379 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important |
1380 // and (4) normal important. | 1380 // and (4) normal important. |
1381 state.setLineHeightValue(0); | 1381 state.setLineHeightValue(0); |
1382 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1382 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
1383 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); | 1383 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); |
1384 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly); | 1384 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly); |
1385 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1385 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1386 | 1386 |
1387 if (UNLIKELY(isSVGForeignObjectElement(element))) { | |
1388 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should | |
1389 // not be scaled again. | |
1390 state.setEffectiveZoom(RenderStyle::initialZoom()); | |
1391 } | |
rune
2014/06/04 10:05:20
If kept here, we need to document that it's import
davve
2014/06/04 11:38:36
Yes, that would work for me. Patch coming up.
davve
2014/06/04 13:27:20
Added as a FIXME.
| |
1392 | |
1387 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { | 1393 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { |
1388 state.fontBuilder().setFontDirty(true); | 1394 state.fontBuilder().setFontDirty(true); |
1389 applyInheritedOnly = false; | 1395 applyInheritedOnly = false; |
1390 } | 1396 } |
1391 | 1397 |
1392 // If our font got dirtied, go ahead and update it now. | 1398 // If our font got dirtied, go ahead and update it now. |
1393 updateFont(state); | 1399 updateFont(state); |
1394 | 1400 |
1395 // Line-height is set when we are sure we decided on the font-size. | 1401 // Line-height is set when we are sure we decided on the font-size. |
1396 if (state.lineHeightValue()) | 1402 if (state.lineHeightValue()) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1453 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1459 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
1454 fprintf(stderr, "== Totals ==\n"); | 1460 fprintf(stderr, "== Totals ==\n"); |
1455 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1461 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
1456 } | 1462 } |
1457 | 1463 |
1458 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style) | 1464 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style) |
1459 { | 1465 { |
1460 StyleResolverState state(document(), document().documentElement(), style); | 1466 StyleResolverState state(document(), document().documentElement(), style); |
1461 state.setStyle(style); | 1467 state.setStyle(style); |
1462 | 1468 |
1463 state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomR ules()); | 1469 state.fontBuilder().initForStyleResolve(document(), style); |
1464 | 1470 |
1465 for (size_t i = 0; i < count; ++i) { | 1471 for (size_t i = 0; i < count; ++i) { |
1466 if (properties[i].value) { | 1472 if (properties[i].value) { |
1467 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1473 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, |
1468 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 1474 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
1469 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height. | 1475 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height. |
1470 switch (properties[i].property) { | 1476 switch (properties[i].property) { |
1471 case CSSPropertyFontSize: | 1477 case CSSPropertyFontSize: |
1472 case CSSPropertyLineHeight: | 1478 case CSSPropertyLineHeight: |
1473 updateFont(state); | 1479 updateFont(state); |
(...skipping 29 matching lines...) Expand all Loading... | |
1503 visitor->trace(m_features); | 1509 visitor->trace(m_features); |
1504 visitor->trace(m_siblingRuleSet); | 1510 visitor->trace(m_siblingRuleSet); |
1505 visitor->trace(m_uncommonAttributeRuleSet); | 1511 visitor->trace(m_uncommonAttributeRuleSet); |
1506 visitor->trace(m_watchedSelectorsRules); | 1512 visitor->trace(m_watchedSelectorsRules); |
1507 visitor->trace(m_treeBoundaryCrossingRules); | 1513 visitor->trace(m_treeBoundaryCrossingRules); |
1508 visitor->trace(m_pendingStyleSheets); | 1514 visitor->trace(m_pendingStyleSheets); |
1509 CSSFontSelectorClient::trace(visitor); | 1515 CSSFontSelectorClient::trace(visitor); |
1510 } | 1516 } |
1511 | 1517 |
1512 } // namespace WebCore | 1518 } // namespace WebCore |
OLD | NEW |