| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 638 } |
| 639 // contenteditable attribute (implemented by -webkit-user-modify) should | 639 // contenteditable attribute (implemented by -webkit-user-modify) should |
| 640 // be propagated from shadow host to distributed node. | 640 // be propagated from shadow host to distributed node. |
| 641 if (state.distributedToInsertionPoint()) { | 641 if (state.distributedToInsertionPoint()) { |
| 642 if (Element* parent = element->parentElement()) { | 642 if (Element* parent = element->parentElement()) { |
| 643 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 643 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) |
| 644 state.style()->setUserModify(styleOfShadowHost->userModify()); | 644 state.style()->setUserModify(styleOfShadowHost->userModify()); |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 | 647 |
| 648 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 648 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 649 | 649 |
| 650 if (element->isLink()) { | 650 if (element->isLink()) { |
| 651 state.style()->setIsLink(true); | 651 state.style()->setIsLink(true); |
| 652 EInsideLink linkState = state.elementLinkState(); | 652 EInsideLink linkState = state.elementLinkState(); |
| 653 if (linkState != NotInsideLink) { | 653 if (linkState != NotInsideLink) { |
| 654 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 654 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
| 655 if (forceVisited) | 655 if (forceVisited) |
| 656 linkState = InsideVisitedLink; | 656 linkState = InsideVisitedLink; |
| 657 } | 657 } |
| 658 state.style()->setInsideLink(linkState); | 658 state.style()->setInsideLink(linkState); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 706 |
| 707 MatchResult result; | 707 MatchResult result; |
| 708 result.addMatchedProperties(&keyframe->properties()); | 708 result.addMatchedProperties(&keyframe->properties()); |
| 709 | 709 |
| 710 ASSERT(!state.style()); | 710 ASSERT(!state.style()); |
| 711 | 711 |
| 712 // Create the style | 712 // Create the style |
| 713 state.setStyle(RenderStyle::clone(&elementStyle)); | 713 state.setStyle(RenderStyle::clone(&elementStyle)); |
| 714 state.setLineHeightValue(0); | 714 state.setLineHeightValue(0); |
| 715 | 715 |
| 716 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 716 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 717 | 717 |
| 718 // We don't need to bother with !important. Since there is only ever one | 718 // We don't need to bother with !important. Since there is only ever one |
| 719 // decl, there's nothing to override. So just add the first properties. | 719 // decl, there's nothing to override. So just add the first properties. |
| 720 // We also don't need to bother with animation properties since the only | 720 // We also don't need to bother with animation properties since the only |
| 721 // relevant one is animation-timing-function and we special-case that in | 721 // relevant one is animation-timing-function and we special-case that in |
| 722 // CSSAnimations.cpp | 722 // CSSAnimations.cpp |
| 723 bool inheritedOnly = false; | 723 bool inheritedOnly = false; |
| 724 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 724 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); |
| 725 | 725 |
| 726 // If our font got dirtied, go ahead and update it now. | 726 // If our font got dirtied, go ahead and update it now. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 753 style = RenderStyle::clone(element.renderStyle()); | 753 style = RenderStyle::clone(element.renderStyle()); |
| 754 else | 754 else |
| 755 style = RenderStyle::create(); | 755 style = RenderStyle::create(); |
| 756 return createAnimatableValueSnapshot(element, property, value, *style); | 756 return createAnimatableValueSnapshot(element, property, value, *style); |
| 757 } | 757 } |
| 758 | 758 |
| 759 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty
le) | 759 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value, RenderStyle& sty
le) |
| 760 { | 760 { |
| 761 StyleResolverState state(element.document(), &element); | 761 StyleResolverState state(element.document(), &element); |
| 762 state.setStyle(&style); | 762 state.setStyle(&style); |
| 763 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 763 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 764 StyleBuilder::applyProperty(property, state, &value); | 764 StyleBuilder::applyProperty(property, state, &value); |
| 765 return CSSAnimatableValueFactory::create(property, style); | 765 return CSSAnimatableValueFactory::create(property, style); |
| 766 } | 766 } |
| 767 | 767 |
| 768 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) | 768 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) |
| 769 { | 769 { |
| 770 RenderObject* parentRenderer = parent.renderer(); | 770 RenderObject* parentRenderer = parent.renderer(); |
| 771 if (!parentRenderer) | 771 if (!parentRenderer) |
| 772 return nullptr; | 772 return nullptr; |
| 773 | 773 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 StyleResolverParentScope::ensureParentStackIsPushed(); | 814 StyleResolverParentScope::ensureParentStackIsPushed(); |
| 815 | 815 |
| 816 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 816 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
| 817 state.setStyle(RenderStyle::create()); | 817 state.setStyle(RenderStyle::create()); |
| 818 state.style()->inheritFrom(state.parentStyle()); | 818 state.style()->inheritFrom(state.parentStyle()); |
| 819 } else { | 819 } else { |
| 820 state.setStyle(defaultStyleForElement()); | 820 state.setStyle(defaultStyleForElement()); |
| 821 state.setParentStyle(RenderStyle::clone(state.style())); | 821 state.setParentStyle(RenderStyle::clone(state.style())); |
| 822 } | 822 } |
| 823 | 823 |
| 824 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 824 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 825 | 825 |
| 826 // Since we don't use pseudo-elements in any of our quirk/print | 826 // Since we don't use pseudo-elements in any of our quirk/print |
| 827 // user agent rules, don't waste time walking those rules. | 827 // user agent rules, don't waste time walking those rules. |
| 828 | 828 |
| 829 { | 829 { |
| 830 // Check UA, user and author rules. | 830 // Check UA, user and author rules. |
| 831 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 831 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
| 832 collector.setPseudoStyleRequest(pseudoStyleRequest); | 832 collector.setPseudoStyleRequest(pseudoStyleRequest); |
| 833 | 833 |
| 834 matchUARules(collector); | 834 matchUARules(collector); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 { | 883 { |
| 884 ASSERT(!hasPendingAuthorStyleSheets()); | 884 ASSERT(!hasPendingAuthorStyleSheets()); |
| 885 resetDirectionAndWritingModeOnDocument(document()); | 885 resetDirectionAndWritingModeOnDocument(document()); |
| 886 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. | 886 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. |
| 887 | 887 |
| 888 state.setStyle(RenderStyle::create()); | 888 state.setStyle(RenderStyle::create()); |
| 889 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); | 889 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); |
| 890 ASSERT(rootElementStyle); | 890 ASSERT(rootElementStyle); |
| 891 state.style()->inheritFrom(rootElementStyle); | 891 state.style()->inheritFrom(rootElementStyle); |
| 892 | 892 |
| 893 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 893 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 894 | 894 |
| 895 PageRuleCollector collector(rootElementStyle, pageIndex); | 895 PageRuleCollector collector(rootElementStyle, pageIndex); |
| 896 | 896 |
| 897 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); | 897 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); |
| 898 | 898 |
| 899 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) | 899 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) |
| 900 scopedResolver->matchPageRules(collector); | 900 scopedResolver->matchPageRules(collector); |
| 901 | 901 |
| 902 state.setLineHeightValue(0); | 902 state.setLineHeightValue(0); |
| 903 bool inheritedOnly = false; | 903 bool inheritedOnly = false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) | 938 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) |
| 939 scopedResolver->collectViewportRulesTo(this); | 939 scopedResolver->collectViewportRulesTo(this); |
| 940 | 940 |
| 941 viewportStyleResolver()->resolve(); | 941 viewportStyleResolver()->resolve(); |
| 942 } | 942 } |
| 943 | 943 |
| 944 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 944 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
| 945 { | 945 { |
| 946 StyleResolverState state(document(), 0); | 946 StyleResolverState state(document(), 0); |
| 947 state.setStyle(RenderStyle::create()); | 947 state.setStyle(RenderStyle::create()); |
| 948 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use
SVGZoomRules()); | 948 state.fontBuilder().initForStyleResolve(document(), state.style()); |
| 949 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 949 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
| 950 state.setLineHeightValue(0); | 950 state.setLineHeightValue(0); |
| 951 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 951 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
| 952 state.style()->font().update(document().styleEngine()->fontSelector()); | 952 state.style()->font().update(document().styleEngine()->fontSelector()); |
| 953 return state.takeStyle(); | 953 return state.takeStyle(); |
| 954 } | 954 } |
| 955 | 955 |
| 956 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 956 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
| 957 { | 957 { |
| 958 ASSERT(textNode); | 958 ASSERT(textNode); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 1371 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
| 1372 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 1372 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
| 1373 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 1373 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
| 1374 // and (4) normal important. | 1374 // and (4) normal important. |
| 1375 state.setLineHeightValue(0); | 1375 state.setLineHeightValue(0); |
| 1376 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1376 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
| 1377 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); | 1377 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); |
| 1378 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn
ly); | 1378 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn
ly); |
| 1379 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1379 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1380 | 1380 |
| 1381 if (UNLIKELY(isSVGForeignObjectElement(element))) { |
| 1382 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb
ject content should not be scaled again. |
| 1383 // |
| 1384 // FIXME: The following hijacks the zoom property for foreignObject so t
hat children of foreignObject get the |
| 1385 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP
roperties, along with other font-related |
| 1386 // properties used as input to the FontBuilder, so resetting it here may
cause the FontBuilder to recompute the |
| 1387 // font used as inheritable font for foreignObject content. If we want t
o support zoom on foreignObject we'll |
| 1388 // need to find another way of handling the SVG zoom model. |
| 1389 state.setEffectiveZoom(RenderStyle::initialZoom()); |
| 1390 } |
| 1391 |
| 1381 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { | 1392 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { |
| 1382 state.fontBuilder().setFontDirty(true); | 1393 state.fontBuilder().setFontDirty(true); |
| 1383 applyInheritedOnly = false; | 1394 applyInheritedOnly = false; |
| 1384 } | 1395 } |
| 1385 | 1396 |
| 1386 // If our font got dirtied, go ahead and update it now. | 1397 // If our font got dirtied, go ahead and update it now. |
| 1387 updateFont(state); | 1398 updateFont(state); |
| 1388 | 1399 |
| 1389 // Line-height is set when we are sure we decided on the font-size. | 1400 // Line-height is set when we are sure we decided on the font-size. |
| 1390 if (state.lineHeightValue()) | 1401 if (state.lineHeightValue()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1458 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
| 1448 fprintf(stderr, "== Totals ==\n"); | 1459 fprintf(stderr, "== Totals ==\n"); |
| 1449 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1460 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
| 1450 } | 1461 } |
| 1451 | 1462 |
| 1452 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) | 1463 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) |
| 1453 { | 1464 { |
| 1454 StyleResolverState state(document(), document().documentElement(), style); | 1465 StyleResolverState state(document(), document().documentElement(), style); |
| 1455 state.setStyle(style); | 1466 state.setStyle(style); |
| 1456 | 1467 |
| 1457 state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomR
ules()); | 1468 state.fontBuilder().initForStyleResolve(document(), style); |
| 1458 | 1469 |
| 1459 for (size_t i = 0; i < count; ++i) { | 1470 for (size_t i = 0; i < count; ++i) { |
| 1460 if (properties[i].value) { | 1471 if (properties[i].value) { |
| 1461 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1472 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, |
| 1462 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 1473 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
| 1463 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. | 1474 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
| 1464 switch (properties[i].property) { | 1475 switch (properties[i].property) { |
| 1465 case CSSPropertyFontSize: | 1476 case CSSPropertyFontSize: |
| 1466 case CSSPropertyLineHeight: | 1477 case CSSPropertyLineHeight: |
| 1467 updateFont(state); | 1478 updateFont(state); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1496 visitor->trace(m_viewportStyleResolver); | 1507 visitor->trace(m_viewportStyleResolver); |
| 1497 visitor->trace(m_features); | 1508 visitor->trace(m_features); |
| 1498 visitor->trace(m_siblingRuleSet); | 1509 visitor->trace(m_siblingRuleSet); |
| 1499 visitor->trace(m_uncommonAttributeRuleSet); | 1510 visitor->trace(m_uncommonAttributeRuleSet); |
| 1500 visitor->trace(m_watchedSelectorsRules); | 1511 visitor->trace(m_watchedSelectorsRules); |
| 1501 visitor->trace(m_treeBoundaryCrossingRules); | 1512 visitor->trace(m_treeBoundaryCrossingRules); |
| 1502 visitor->trace(m_pendingStyleSheets); | 1513 visitor->trace(m_pendingStyleSheets); |
| 1503 } | 1514 } |
| 1504 | 1515 |
| 1505 } // namespace WebCore | 1516 } // namespace WebCore |
| OLD | NEW |