| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1453 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
| 1454 fprintf(stderr, "== Totals ==\n"); | 1454 fprintf(stderr, "== Totals ==\n"); |
| 1455 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1455 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) | 1458 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) |
| 1459 { | 1459 { |
| 1460 StyleResolverState state(document(), document().documentElement(), style); | 1460 StyleResolverState state(document(), document().documentElement(), style); |
| 1461 state.setStyle(style); | 1461 state.setStyle(style); |
| 1462 | 1462 |
| 1463 state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomR
ules()); | 1463 state.fontBuilder().initForStyleResolve(document(), style); |
| 1464 | 1464 |
| 1465 for (size_t i = 0; i < count; ++i) { | 1465 for (size_t i = 0; i < count; ++i) { |
| 1466 if (properties[i].value) { | 1466 if (properties[i].value) { |
| 1467 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1467 // 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). | 1468 // 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. | 1469 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
| 1470 switch (properties[i].property) { | 1470 switch (properties[i].property) { |
| 1471 case CSSPropertyFontSize: | 1471 case CSSPropertyFontSize: |
| 1472 case CSSPropertyLineHeight: | 1472 case CSSPropertyLineHeight: |
| 1473 updateFont(state); | 1473 updateFont(state); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1503 visitor->trace(m_features); | 1503 visitor->trace(m_features); |
| 1504 visitor->trace(m_siblingRuleSet); | 1504 visitor->trace(m_siblingRuleSet); |
| 1505 visitor->trace(m_uncommonAttributeRuleSet); | 1505 visitor->trace(m_uncommonAttributeRuleSet); |
| 1506 visitor->trace(m_watchedSelectorsRules); | 1506 visitor->trace(m_watchedSelectorsRules); |
| 1507 visitor->trace(m_treeBoundaryCrossingRules); | 1507 visitor->trace(m_treeBoundaryCrossingRules); |
| 1508 visitor->trace(m_pendingStyleSheets); | 1508 visitor->trace(m_pendingStyleSheets); |
| 1509 CSSFontSelectorClient::trace(visitor); | 1509 CSSFontSelectorClient::trace(visitor); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 } // namespace WebCore | 1512 } // namespace WebCore |
| OLD | NEW |