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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 | 582 |
583 ActiveAnimations* activeAnimations = element->activeAnimations(); | 583 ActiveAnimations* activeAnimations = element->activeAnimations(); |
584 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr; | 584 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr; |
585 | 585 |
586 if (baseRenderStyle) { | 586 if (baseRenderStyle) { |
587 state.setStyle(RenderStyle::clone(baseRenderStyle)); | 587 state.setStyle(RenderStyle::clone(baseRenderStyle)); |
588 if (!state.parentStyle()) | 588 if (!state.parentStyle()) |
589 state.setParentStyle(defaultStyleForElement()); | 589 state.setParentStyle(defaultStyleForElement()); |
590 } else { | 590 } else { |
591 if (state.parentStyle()) { | 591 if (state.parentStyle()) { |
592 state.setStyle(RenderStyle::create()); | 592 RefPtr<RenderStyle> style = RenderStyle::create(); |
593 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(e lement) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 593 style->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
594 state.setStyle(style); | |
Timothy Loh
2014/11/06 16:24:01
state.setStyle(style.release())?
andersr
2014/11/07 10:43:11
Done.
| |
594 } else { | 595 } else { |
595 state.setStyle(defaultStyleForElement()); | 596 state.setStyle(defaultStyleForElement()); |
596 state.setParentStyle(RenderStyle::clone(state.style())); | 597 state.setParentStyle(RenderStyle::clone(state.style())); |
597 } | 598 } |
598 } | 599 } |
599 | 600 |
600 // contenteditable attribute (implemented by -webkit-user-modify) should | 601 // contenteditable attribute (implemented by -webkit-user-modify) should |
601 // be propagated from shadow host to distributed node. | 602 // be propagated from shadow host to distributed node. |
602 if (state.distributedToInsertionPoint()) { | 603 if (state.distributedToInsertionPoint()) { |
603 if (Element* parent = element->parentElement()) { | 604 if (Element* parent = element->parentElement()) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 StyleResolverParentScope::ensureParentStackIsPushed(); | 770 StyleResolverParentScope::ensureParentStackIsPushed(); |
770 | 771 |
771 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 772 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
772 | 773 |
773 ActiveAnimations* activeAnimations = pseudoElement ? pseudoElement->activeAn imations() : nullptr; | 774 ActiveAnimations* activeAnimations = pseudoElement ? pseudoElement->activeAn imations() : nullptr; |
774 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr; | 775 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr; |
775 | 776 |
776 if (baseRenderStyle) { | 777 if (baseRenderStyle) { |
777 state.setStyle(RenderStyle::clone(baseRenderStyle)); | 778 state.setStyle(RenderStyle::clone(baseRenderStyle)); |
778 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 779 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
779 state.setStyle(RenderStyle::create()); | 780 RefPtr<RenderStyle> style = RenderStyle::create(); |
780 state.style()->inheritFrom(state.parentStyle()); | 781 style->inheritFrom(state.parentStyle()); |
782 state.setStyle(style); | |
Timothy Loh
2014/11/06 16:24:01
style.release()
andersr
2014/11/07 10:43:11
Done.
| |
781 } else { | 783 } else { |
782 state.setStyle(defaultStyleForElement()); | 784 state.setStyle(defaultStyleForElement()); |
783 state.setParentStyle(RenderStyle::clone(state.style())); | 785 state.setParentStyle(RenderStyle::clone(state.style())); |
784 } | 786 } |
785 | 787 |
786 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 788 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
787 | 789 |
788 // Since we don't use pseudo-elements in any of our quirk/print | 790 // Since we don't use pseudo-elements in any of our quirk/print |
789 // user agent rules, don't waste time walking those rules. | 791 // user agent rules, don't waste time walking those rules. |
790 | 792 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 // Now return the style. | 850 // Now return the style. |
849 return state.takeStyle(); | 851 return state.takeStyle(); |
850 } | 852 } |
851 | 853 |
852 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 854 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
853 { | 855 { |
854 ASSERT(!hasPendingAuthorStyleSheets()); | 856 ASSERT(!hasPendingAuthorStyleSheets()); |
855 resetDirectionAndWritingModeOnDocument(document()); | 857 resetDirectionAndWritingModeOnDocument(document()); |
856 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. | 858 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. |
857 | 859 |
858 state.setStyle(RenderStyle::create()); | 860 RefPtr<RenderStyle> style = RenderStyle::create(); |
859 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); | 861 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); |
860 ASSERT(rootElementStyle); | 862 ASSERT(rootElementStyle); |
861 state.style()->inheritFrom(rootElementStyle); | 863 style->inheritFrom(rootElementStyle); |
864 state.setStyle(style); | |
Timothy Loh
2014/11/06 16:24:01
style.release()
andersr
2014/11/07 10:43:11
Done.
| |
862 | 865 |
863 PageRuleCollector collector(rootElementStyle, pageIndex); | 866 PageRuleCollector collector(rootElementStyle, pageIndex); |
864 | 867 |
865 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); | 868 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); |
866 | 869 |
867 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 870 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
868 scopedResolver->matchPageRules(collector); | 871 scopedResolver->matchPageRules(collector); |
869 | 872 |
870 bool inheritedOnly = false; | 873 bool inheritedOnly = false; |
871 | 874 |
(...skipping 27 matching lines...) Expand all Loading... | |
899 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default XHTMLMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin); | 902 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default XHTMLMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin); |
900 | 903 |
901 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 904 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
902 scopedResolver->collectViewportRulesTo(this); | 905 scopedResolver->collectViewportRulesTo(this); |
903 | 906 |
904 viewportStyleResolver()->resolve(); | 907 viewportStyleResolver()->resolve(); |
905 } | 908 } |
906 | 909 |
907 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 910 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
908 { | 911 { |
909 StyleResolverState state(document(), 0); | 912 RefPtr<RenderStyle> style = RenderStyle::create(); |
910 state.setStyle(RenderStyle::create()); | 913 FontBuilder fontBuilder(document()); |
911 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 914 fontBuilder.setStyle(style.get()); |
912 state.style()->font().update(document().styleEngine()->fontSelector()); | 915 fontBuilder.setInitial(style->effectiveZoom()); |
913 return state.takeStyle(); | 916 style->font().update(document().styleEngine()->fontSelector()); |
917 return style; | |
Timothy Loh
2014/11/06 16:24:01
style.release()
andersr
2014/11/07 10:43:11
Done.
| |
914 } | 918 } |
915 | 919 |
916 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 920 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
917 { | 921 { |
918 ASSERT(textNode); | 922 ASSERT(textNode); |
919 | 923 |
920 Node* parentNode = NodeRenderingTraversal::parent(textNode); | 924 Node* parentNode = NodeRenderingTraversal::parent(textNode); |
921 if (!parentNode || !parentNode->renderStyle()) | 925 if (!parentNode || !parentNode->renderStyle()) |
922 return defaultStyleForElement(); | 926 return defaultStyleForElement(); |
923 return parentNode->renderStyle(); | 927 return parentNode->renderStyle(); |
924 } | 928 } |
925 | 929 |
926 void StyleResolver::updateFont(StyleResolverState& state) | 930 void StyleResolver::updateFont(StyleResolverState& state) |
927 { | 931 { |
928 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.parentStyle(), state.style()); | 932 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.parentStyle(), state.style()); |
933 state.setConversionFontSizes(CSSToLengthFontSizes(state.style(), state.rootE lementStyle())); | |
934 state.setConversionZoom(state.style()->effectiveZoom()); | |
929 } | 935 } |
930 | 936 |
931 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) | 937 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) |
932 { | 938 { |
933 ASSERT(element); | 939 ASSERT(element); |
934 StyleResolverState state(document(), element); | 940 StyleResolverState state(document(), element); |
935 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); | 941 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); |
936 collector.setMode(SelectorChecker::CollectingStyleRules); | 942 collector.setMode(SelectorChecker::CollectingStyleRules); |
937 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); | 943 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); |
938 return collector.matchedStyleRuleList(); | 944 return collector.matchedStyleRuleList(); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1412 && (!state.distributedToInsertionPoint() || state.style()->userModif y() == READ_ONLY)) { | 1418 && (!state.distributedToInsertionPoint() || state.style()->userModif y() == READ_ONLY)) { |
1413 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); | 1419 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); |
1414 | 1420 |
1415 EInsideLink linkStatus = state.style()->insideLink(); | 1421 EInsideLink linkStatus = state.style()->insideLink(); |
1416 // If the cache item parent style has identical inherited properties to the current parent style then the | 1422 // If the cache item parent style has identical inherited properties to the current parent style then the |
1417 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. | 1423 // resulting style will be identical too. We copy the inherited prop erties over from the cache and are done. |
1418 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); | 1424 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); |
1419 | 1425 |
1420 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. | 1426 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. |
1421 state.style()->setInsideLink(linkStatus); | 1427 state.style()->setInsideLink(linkStatus); |
1428 | |
1429 updateFont(state); | |
Timothy Loh
2014/11/06 16:24:01
This call is for animations, right?
andersr
2014/11/06 16:35:27
Yes.
| |
1430 | |
1422 return; | 1431 return; |
1423 } | 1432 } |
1424 applyInheritedOnly = true; | 1433 applyInheritedOnly = true; |
1425 } | 1434 } |
1426 | 1435 |
1427 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply | 1436 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply |
1428 // high-priority properties first, i.e., those properties that other propert ies depend on. | 1437 // high-priority properties first, i.e., those properties that other propert ies depend on. |
1429 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important | 1438 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important |
1430 // and (4) normal important. | 1439 // and (4) normal important. |
1431 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1440 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1580 visitor->trace(m_uncommonAttributeRuleSet); | 1589 visitor->trace(m_uncommonAttributeRuleSet); |
1581 visitor->trace(m_watchedSelectorsRules); | 1590 visitor->trace(m_watchedSelectorsRules); |
1582 visitor->trace(m_treeBoundaryCrossingRules); | 1591 visitor->trace(m_treeBoundaryCrossingRules); |
1583 visitor->trace(m_styleSharingLists); | 1592 visitor->trace(m_styleSharingLists); |
1584 visitor->trace(m_pendingStyleSheets); | 1593 visitor->trace(m_pendingStyleSheets); |
1585 visitor->trace(m_document); | 1594 visitor->trace(m_document); |
1586 #endif | 1595 #endif |
1587 } | 1596 } |
1588 | 1597 |
1589 } // namespace blink | 1598 } // namespace blink |
OLD | NEW |