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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } | 604 } |
605 // contenteditable attribute (implemented by -webkit-user-modify) should | 605 // contenteditable attribute (implemented by -webkit-user-modify) should |
606 // be propagated from shadow host to distributed node. | 606 // be propagated from shadow host to distributed node. |
607 if (state.distributedToInsertionPoint()) { | 607 if (state.distributedToInsertionPoint()) { |
608 if (Element* parent = element->parentElement()) { | 608 if (Element* parent = element->parentElement()) { |
609 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 609 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) |
610 state.style()->setUserModify(styleOfShadowHost->userModify()); | 610 state.style()->setUserModify(styleOfShadowHost->userModify()); |
611 } | 611 } |
612 } | 612 } |
613 | 613 |
614 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | |
615 | |
616 if (element->isLink()) { | 614 if (element->isLink()) { |
617 state.style()->setIsLink(true); | 615 state.style()->setIsLink(true); |
618 EInsideLink linkState = state.elementLinkState(); | 616 EInsideLink linkState = state.elementLinkState(); |
619 if (linkState != NotInsideLink) { | 617 if (linkState != NotInsideLink) { |
620 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 618 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
621 if (forceVisited) | 619 if (forceVisited) |
622 linkState = InsideVisitedLink; | 620 linkState = InsideVisitedLink; |
623 } | 621 } |
624 state.style()->setInsideLink(linkState); | 622 state.style()->setInsideLink(linkState); |
625 } | 623 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 677 |
680 MatchResult result; | 678 MatchResult result; |
681 result.addMatchedProperties(&keyframe->properties()); | 679 result.addMatchedProperties(&keyframe->properties()); |
682 | 680 |
683 ASSERT(!state.style()); | 681 ASSERT(!state.style()); |
684 | 682 |
685 // Create the style | 683 // Create the style |
686 state.setStyle(RenderStyle::clone(&elementStyle)); | 684 state.setStyle(RenderStyle::clone(&elementStyle)); |
687 state.setLineHeightValue(0); | 685 state.setLineHeightValue(0); |
688 | 686 |
689 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | |
690 | |
691 // We don't need to bother with !important. Since there is only ever one | 687 // We don't need to bother with !important. Since there is only ever one |
692 // decl, there's nothing to override. So just add the first properties. | 688 // decl, there's nothing to override. So just add the first properties. |
693 // We also don't need to bother with animation properties since the only | 689 // We also don't need to bother with animation properties since the only |
694 // relevant one is animation-timing-function and we special-case that in | 690 // relevant one is animation-timing-function and we special-case that in |
695 // CSSAnimations.cpp | 691 // CSSAnimations.cpp |
696 bool inheritedOnly = false; | 692 bool inheritedOnly = false; |
697 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 693 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); |
698 | 694 |
699 // If our font got dirtied, go ahead and update it now. | 695 // If our font got dirtied, go ahead and update it now. |
700 updateFont(state); | 696 updateFont(state); |
(...skipping 16 matching lines...) Expand all Loading... |
717 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. | 713 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. |
718 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) | 714 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) |
719 { | 715 { |
720 RefPtr<RenderStyle> style; | 716 RefPtr<RenderStyle> style; |
721 if (element.renderStyle()) | 717 if (element.renderStyle()) |
722 style = RenderStyle::clone(element.renderStyle()); | 718 style = RenderStyle::clone(element.renderStyle()); |
723 else | 719 else |
724 style = RenderStyle::create(); | 720 style = RenderStyle::create(); |
725 StyleResolverState state(element.document(), &element); | 721 StyleResolverState state(element.document(), &element); |
726 state.setStyle(style); | 722 state.setStyle(style); |
727 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | |
728 return createAnimatableValueSnapshot(state, property, value); | 723 return createAnimatableValueSnapshot(state, property, value); |
729 } | 724 } |
730 | 725 |
731 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) | 726 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) |
732 { | 727 { |
733 StyleBuilder::applyProperty(property, state, &value); | 728 StyleBuilder::applyProperty(property, state, &value); |
734 return CSSAnimatableValueFactory::create(property, *state.style()); | 729 return CSSAnimatableValueFactory::create(property, *state.style()); |
735 } | 730 } |
736 | 731 |
737 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) | 732 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 state.setStyle(RenderStyle::clone(baseRenderStyle)); | 798 state.setStyle(RenderStyle::clone(baseRenderStyle)); |
804 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 799 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
805 state.setStyle(RenderStyle::create()); | 800 state.setStyle(RenderStyle::create()); |
806 state.style()->inheritFrom(state.parentStyle()); | 801 state.style()->inheritFrom(state.parentStyle()); |
807 } else { | 802 } else { |
808 state.setStyle(defaultStyleForElement()); | 803 state.setStyle(defaultStyleForElement()); |
809 state.setParentStyle(RenderStyle::clone(state.style())); | 804 state.setParentStyle(RenderStyle::clone(state.style())); |
810 } | 805 } |
811 | 806 |
812 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 807 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
813 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | |
814 | 808 |
815 // Since we don't use pseudo-elements in any of our quirk/print | 809 // Since we don't use pseudo-elements in any of our quirk/print |
816 // user agent rules, don't waste time walking those rules. | 810 // user agent rules, don't waste time walking those rules. |
817 | 811 |
818 if (!baseRenderStyle) { | 812 if (!baseRenderStyle) { |
819 // Check UA, user and author rules. | 813 // Check UA, user and author rules. |
820 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 814 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
821 collector.setPseudoStyleRequest(pseudoStyleRequest); | 815 collector.setPseudoStyleRequest(pseudoStyleRequest); |
822 | 816 |
823 matchUARules(collector); | 817 matchUARules(collector); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 { | 874 { |
881 ASSERT(!hasPendingAuthorStyleSheets()); | 875 ASSERT(!hasPendingAuthorStyleSheets()); |
882 resetDirectionAndWritingModeOnDocument(document()); | 876 resetDirectionAndWritingModeOnDocument(document()); |
883 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. | 877 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. |
884 | 878 |
885 state.setStyle(RenderStyle::create()); | 879 state.setStyle(RenderStyle::create()); |
886 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); | 880 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().renderStyle(); |
887 ASSERT(rootElementStyle); | 881 ASSERT(rootElementStyle); |
888 state.style()->inheritFrom(rootElementStyle); | 882 state.style()->inheritFrom(rootElementStyle); |
889 | 883 |
890 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | |
891 | |
892 PageRuleCollector collector(rootElementStyle, pageIndex); | 884 PageRuleCollector collector(rootElementStyle, pageIndex); |
893 | 885 |
894 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); | 886 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); |
895 | 887 |
896 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 888 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
897 scopedResolver->matchPageRules(collector); | 889 scopedResolver->matchPageRules(collector); |
898 | 890 |
899 state.setLineHeightValue(0); | 891 state.setLineHeightValue(0); |
900 bool inheritedOnly = false; | 892 bool inheritedOnly = false; |
901 | 893 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 927 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
936 scopedResolver->collectViewportRulesTo(this); | 928 scopedResolver->collectViewportRulesTo(this); |
937 | 929 |
938 viewportStyleResolver()->resolve(); | 930 viewportStyleResolver()->resolve(); |
939 } | 931 } |
940 | 932 |
941 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 933 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
942 { | 934 { |
943 StyleResolverState state(document(), 0); | 935 StyleResolverState state(document(), 0); |
944 state.setStyle(RenderStyle::create()); | 936 state.setStyle(RenderStyle::create()); |
945 state.fontBuilder().initForStyleResolve(document(), state.style()); | |
946 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 937 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
947 state.setLineHeightValue(0); | 938 state.setLineHeightValue(0); |
948 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 939 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
949 state.style()->font().update(document().styleEngine()->fontSelector()); | 940 state.style()->font().update(document().styleEngine()->fontSelector()); |
950 return state.takeStyle(); | 941 return state.takeStyle(); |
951 } | 942 } |
952 | 943 |
953 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 944 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
954 { | 945 { |
955 ASSERT(textNode); | 946 ASSERT(textNode); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1561 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
1571 fprintf(stderr, "== Totals ==\n"); | 1562 fprintf(stderr, "== Totals ==\n"); |
1572 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1563 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
1573 } | 1564 } |
1574 | 1565 |
1575 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) | 1566 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, RenderStyle* style) |
1576 { | 1567 { |
1577 StyleResolverState state(document(), document().documentElement(), style); | 1568 StyleResolverState state(document(), document().documentElement(), style); |
1578 state.setStyle(style); | 1569 state.setStyle(style); |
1579 | 1570 |
1580 state.fontBuilder().initForStyleResolve(document(), style); | |
1581 | |
1582 for (size_t i = 0; i < count; ++i) { | 1571 for (size_t i = 0; i < count; ++i) { |
1583 if (properties[i].value) { | 1572 if (properties[i].value) { |
1584 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1573 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, |
1585 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 1574 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
1586 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. | 1575 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
1587 switch (properties[i].property) { | 1576 switch (properties[i].property) { |
1588 case CSSPropertyFontSize: | 1577 case CSSPropertyFontSize: |
1589 case CSSPropertyLineHeight: | 1578 case CSSPropertyLineHeight: |
1590 updateFont(state); | 1579 updateFont(state); |
1591 break; | 1580 break; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 visitor->trace(m_uncommonAttributeRuleSet); | 1614 visitor->trace(m_uncommonAttributeRuleSet); |
1626 visitor->trace(m_watchedSelectorsRules); | 1615 visitor->trace(m_watchedSelectorsRules); |
1627 visitor->trace(m_treeBoundaryCrossingRules); | 1616 visitor->trace(m_treeBoundaryCrossingRules); |
1628 visitor->trace(m_styleSharingLists); | 1617 visitor->trace(m_styleSharingLists); |
1629 visitor->trace(m_pendingStyleSheets); | 1618 visitor->trace(m_pendingStyleSheets); |
1630 visitor->trace(m_document); | 1619 visitor->trace(m_document); |
1631 #endif | 1620 #endif |
1632 } | 1621 } |
1633 | 1622 |
1634 } // namespace blink | 1623 } // namespace blink |
OLD | NEW |