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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element, stat e.cachedUAStyle()); | 536 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element, stat e.cachedUAStyle()); |
537 } | 537 } |
538 | 538 |
539 // Start loading resources referenced by this style. | 539 // Start loading resources referenced by this style. |
540 void StyleResolver::loadPendingResources(StyleResolverState& state) | 540 void StyleResolver::loadPendingResources(StyleResolverState& state) |
541 { | 541 { |
542 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | 542 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); |
543 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 543 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
544 } | 544 } |
545 | 545 |
546 struct AnimationResolveData { | |
547 | |
548 AnimationResolveData(Element* element) | |
549 : baseRenderStyle(nullptr) | |
550 , useBaseRenderStyle(false) | |
551 { | |
552 if (!element) | |
553 return; | |
554 | |
555 if (ActiveAnimations* animations = element->activeAnimations()) { | |
556 useBaseRenderStyle = animations->isAnimationStyleChange(); | |
557 if (useBaseRenderStyle) | |
558 baseRenderStyle = animations->baseRenderStyle(); | |
559 else | |
560 animations->setBaseRenderStyle(nullptr); | |
esprehn
2014/10/13 21:44:26
This really doesn't seem like the right place to h
rune
2014/10/13 22:24:49
There are a bunch of ways to do this. Do you think
| |
561 | |
562 #if ENABLE(ASSERT) | |
563 // Force recalc of the base style to check that the cached one was c orrect. | |
564 baseRenderStyle = nullptr; | |
565 #endif // !ASSERT | |
566 } | |
567 } | |
568 | |
569 const RenderStyle* baseRenderStyle; | |
570 bool useBaseRenderStyle; | |
571 }; | |
572 | |
546 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 573 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
547 RuleMatchingBehavior matchingBehavior) | 574 RuleMatchingBehavior matchingBehavior) |
548 { | 575 { |
549 ASSERT(document().frame()); | 576 ASSERT(document().frame()); |
550 ASSERT(document().settings()); | 577 ASSERT(document().settings()); |
551 ASSERT(!hasPendingAuthorStyleSheets()); | 578 ASSERT(!hasPendingAuthorStyleSheets()); |
552 ASSERT(!m_needCollectFeatures); | 579 ASSERT(!m_needCollectFeatures); |
553 | 580 |
554 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer | 581 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer |
555 // will vanish if a style recalc happens during loading. | 582 // will vanish if a style recalc happens during loading. |
(...skipping 15 matching lines...) Expand all Loading... | |
571 if (element == document().documentElement()) | 598 if (element == document().documentElement()) |
572 resetDirectionAndWritingModeOnDocument(document()); | 599 resetDirectionAndWritingModeOnDocument(document()); |
573 StyleResolverState state(document(), element, defaultParent); | 600 StyleResolverState state(document(), element, defaultParent); |
574 | 601 |
575 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { | 602 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { |
576 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); | 603 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); |
577 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) | 604 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) |
578 return sharedStyle.release(); | 605 return sharedStyle.release(); |
579 } | 606 } |
580 | 607 |
581 if (state.parentStyle()) { | 608 |
609 AnimationResolveData animationData(element); | |
610 | |
611 if (animationData.baseRenderStyle) { | |
612 state.setStyle(RenderStyle::clone(animationData.baseRenderStyle)); | |
613 } else if (state.parentStyle()) { | |
582 state.setStyle(RenderStyle::create()); | 614 state.setStyle(RenderStyle::create()); |
583 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 615 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
584 } else { | 616 } else { |
585 state.setStyle(defaultStyleForElement()); | 617 state.setStyle(defaultStyleForElement()); |
586 state.setParentStyle(RenderStyle::clone(state.style())); | 618 state.setParentStyle(RenderStyle::clone(state.style())); |
587 } | 619 } |
588 // contenteditable attribute (implemented by -webkit-user-modify) should | 620 // contenteditable attribute (implemented by -webkit-user-modify) should |
589 // be propagated from shadow host to distributed node. | 621 // be propagated from shadow host to distributed node. |
590 if (state.distributedToInsertionPoint()) { | 622 if (state.distributedToInsertionPoint()) { |
591 if (Element* parent = element->parentElement()) { | 623 if (Element* parent = element->parentElement()) { |
592 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 624 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) |
593 state.style()->setUserModify(styleOfShadowHost->userModify()); | 625 state.style()->setUserModify(styleOfShadowHost->userModify()); |
594 } | 626 } |
595 } | 627 } |
596 | 628 |
597 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 629 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
598 | 630 |
599 if (element->isLink()) { | 631 if (element->isLink()) { |
600 state.style()->setIsLink(true); | 632 state.style()->setIsLink(true); |
601 EInsideLink linkState = state.elementLinkState(); | 633 EInsideLink linkState = state.elementLinkState(); |
602 if (linkState != NotInsideLink) { | 634 if (linkState != NotInsideLink) { |
603 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); | 635 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); |
604 if (forceVisited) | 636 if (forceVisited) |
605 linkState = InsideVisitedLink; | 637 linkState = InsideVisitedLink; |
606 } | 638 } |
607 state.style()->setInsideLink(linkState); | 639 state.style()->setInsideLink(linkState); |
608 } | 640 } |
609 | 641 |
610 bool needsCollection = false; | 642 if (!animationData.baseRenderStyle) { |
611 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element , needsCollection); | |
612 if (needsCollection) | |
613 collectFeatures(); | |
614 | 643 |
615 { | 644 bool needsCollection = false; |
645 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele ment, needsCollection); | |
646 if (needsCollection) | |
647 collectFeatures(); | |
648 | |
616 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); | 649 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); |
617 | 650 |
618 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi ngSMIL); | 651 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi ngSMIL); |
619 | 652 |
620 applyMatchedProperties(state, collector.matchedResult()); | 653 applyMatchedProperties(state, collector.matchedResult()); |
621 applyCallbackSelectors(state); | 654 applyCallbackSelectors(state); |
622 | 655 |
623 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 656 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
657 | |
658 // Cache our original display. | |
659 state.style()->setOriginalDisplay(state.style()->display()); | |
660 | |
661 adjustRenderStyle(state, element); | |
662 | |
663 if (animationData.useBaseRenderStyle) | |
664 element->activeAnimations()->setBaseRenderStyle(RenderStyle::clone(s tate.style())); | |
624 } | 665 } |
625 | 666 |
626 // Cache our original display. | |
627 state.style()->setOriginalDisplay(state.style()->display()); | |
628 | |
629 adjustRenderStyle(state, element); | |
630 | |
631 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before | 667 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before |
632 // important rules, but this currently happens here as we require adjustment to have happened | 668 // important rules, but this currently happens here as we require adjustment to have happened |
633 // before deciding which properties to transition. | 669 // before deciding which properties to transition. |
634 if (applyAnimatedProperties(state, element)) | 670 if (applyAnimatedProperties(state, element)) |
635 adjustRenderStyle(state, element); | 671 adjustRenderStyle(state, element); |
636 | 672 |
637 if (isHTMLBodyElement(*element)) | 673 if (isHTMLBodyElement(*element)) |
638 document().textLinkColors().setTextColor(state.style()->color()); | 674 document().textLinkColors().setTextColor(state.style()->color()); |
639 | 675 |
640 setAnimationUpdateIfNeeded(state, *element); | 676 setAnimationUpdateIfNeeded(state, *element); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 } | 790 } |
755 | 791 |
756 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) | 792 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) |
757 { | 793 { |
758 ASSERT(document().frame()); | 794 ASSERT(document().frame()); |
759 ASSERT(document().settings()); | 795 ASSERT(document().settings()); |
760 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 796 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
761 | 797 |
762 StyleResolverParentScope::ensureParentStackIsPushed(); | 798 StyleResolverParentScope::ensureParentStackIsPushed(); |
763 | 799 |
764 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 800 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
801 | |
802 AnimationResolveData animationData(pseudoElement); | |
803 | |
804 if (animationData.baseRenderStyle) { | |
805 state.setStyle(RenderStyle::clone(animationData.baseRenderStyle)); | |
806 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | |
765 state.setStyle(RenderStyle::create()); | 807 state.setStyle(RenderStyle::create()); |
766 state.style()->inheritFrom(state.parentStyle()); | 808 state.style()->inheritFrom(state.parentStyle()); |
767 } else { | 809 } else { |
768 state.setStyle(defaultStyleForElement()); | 810 state.setStyle(defaultStyleForElement()); |
769 state.setParentStyle(RenderStyle::clone(state.style())); | 811 state.setParentStyle(RenderStyle::clone(state.style())); |
770 } | 812 } |
771 | 813 |
772 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 814 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
773 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 815 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
774 | 816 |
775 // Since we don't use pseudo-elements in any of our quirk/print | 817 // Since we don't use pseudo-elements in any of our quirk/print |
776 // user agent rules, don't waste time walking those rules. | 818 // user agent rules, don't waste time walking those rules. |
777 | 819 |
778 { | 820 if (!animationData.baseRenderStyle) { |
779 // Check UA, user and author rules. | 821 // Check UA, user and author rules. |
780 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); | 822 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); |
781 collector.setPseudoStyleRequest(pseudoStyleRequest); | 823 collector.setPseudoStyleRequest(pseudoStyleRequest); |
782 | 824 |
783 matchUARules(collector); | 825 matchUARules(collector); |
784 matchAuthorRules(state.element(), collector, false); | 826 matchAuthorRules(state.element(), collector, false); |
785 | 827 |
786 if (collector.matchedResult().matchedProperties.isEmpty()) | 828 if (collector.matchedResult().matchedProperties.isEmpty()) |
787 return false; | 829 return false; |
788 | 830 |
789 applyMatchedProperties(state, collector.matchedResult()); | 831 applyMatchedProperties(state, collector.matchedResult()); |
790 applyCallbackSelectors(state); | 832 applyCallbackSelectors(state); |
791 | 833 |
792 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 834 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
835 | |
836 // Cache our original display. | |
837 state.style()->setOriginalDisplay(state.style()->display()); | |
838 | |
839 // FIXME: Passing 0 as the Element* introduces a lot of complexity | |
840 // in the adjustRenderStyle code. | |
841 adjustRenderStyle(state, 0); | |
842 | |
843 if (animationData.useBaseRenderStyle) | |
844 pseudoElement->activeAnimations()->setBaseRenderStyle(RenderStyle::c lone(state.style())); | |
793 } | 845 } |
794 | 846 |
795 // Cache our original display. | |
796 state.style()->setOriginalDisplay(state.style()->display()); | |
797 | |
798 // FIXME: Passing 0 as the Element* introduces a lot of complexity | |
799 // in the adjustRenderStyle code. | |
800 adjustRenderStyle(state, 0); | |
801 | |
802 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before | 847 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before |
803 // important rules, but this currently happens here as we require adjustment to have happened | 848 // important rules, but this currently happens here as we require adjustment to have happened |
804 // before deciding which properties to transition. | 849 // before deciding which properties to transition. |
805 if (applyAnimatedProperties(state, element.pseudoElement(pseudoStyleRequest. pseudoId))) | 850 if (applyAnimatedProperties(state, pseudoElement)) |
806 adjustRenderStyle(state, 0); | 851 adjustRenderStyle(state, 0); |
807 | 852 |
808 didAccess(); | 853 didAccess(); |
809 | 854 |
810 if (state.style()->hasViewportUnits()) | 855 if (state.style()->hasViewportUnits()) |
811 document().setHasViewportUnits(); | 856 document().setHasViewportUnits(); |
812 | 857 |
813 return true; | 858 return true; |
814 } | 859 } |
815 | 860 |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1582 visitor->trace(m_uncommonAttributeRuleSet); | 1627 visitor->trace(m_uncommonAttributeRuleSet); |
1583 visitor->trace(m_watchedSelectorsRules); | 1628 visitor->trace(m_watchedSelectorsRules); |
1584 visitor->trace(m_treeBoundaryCrossingRules); | 1629 visitor->trace(m_treeBoundaryCrossingRules); |
1585 visitor->trace(m_styleSharingLists); | 1630 visitor->trace(m_styleSharingLists); |
1586 visitor->trace(m_pendingStyleSheets); | 1631 visitor->trace(m_pendingStyleSheets); |
1587 visitor->trace(m_document); | 1632 visitor->trace(m_document); |
1588 #endif | 1633 #endif |
1589 } | 1634 } |
1590 | 1635 |
1591 } // namespace blink | 1636 } // namespace blink |
OLD | NEW |