Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 686723002: Improve RAII of StyleResolverState. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: When baseRenderStyle!=0: 1) don't inherit, and 2) use defaultStyleForElement as fallback parent. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/css/CSSValueList.h" 52 #include "core/css/CSSValueList.h"
53 #include "core/css/CSSValuePool.h" 53 #include "core/css/CSSValuePool.h"
54 #include "core/css/ElementRuleCollector.h" 54 #include "core/css/ElementRuleCollector.h"
55 #include "core/css/FontFace.h" 55 #include "core/css/FontFace.h"
56 #include "core/css/MediaQueryEvaluator.h" 56 #include "core/css/MediaQueryEvaluator.h"
57 #include "core/css/PageRuleCollector.h" 57 #include "core/css/PageRuleCollector.h"
58 #include "core/css/StylePropertySet.h" 58 #include "core/css/StylePropertySet.h"
59 #include "core/css/StyleRuleImport.h" 59 #include "core/css/StyleRuleImport.h"
60 #include "core/css/StyleSheetContents.h" 60 #include "core/css/StyleSheetContents.h"
61 #include "core/css/resolver/AnimatedStyleBuilder.h" 61 #include "core/css/resolver/AnimatedStyleBuilder.h"
62 #include "core/css/resolver/ElementResolveContext.h"
62 #include "core/css/resolver/MatchResult.h" 63 #include "core/css/resolver/MatchResult.h"
63 #include "core/css/resolver/MediaQueryResult.h" 64 #include "core/css/resolver/MediaQueryResult.h"
64 #include "core/css/resolver/SharedStyleFinder.h" 65 #include "core/css/resolver/SharedStyleFinder.h"
65 #include "core/css/resolver/StyleAdjuster.h" 66 #include "core/css/resolver/StyleAdjuster.h"
66 #include "core/css/resolver/StyleResolverParentScope.h" 67 #include "core/css/resolver/StyleResolverParentScope.h"
67 #include "core/css/resolver/StyleResolverState.h" 68 #include "core/css/resolver/StyleResolverState.h"
68 #include "core/css/resolver/StyleResolverStats.h" 69 #include "core/css/resolver/StyleResolverStats.h"
69 #include "core/css/resolver/ViewportStyleResolver.h" 70 #include "core/css/resolver/ViewportStyleResolver.h"
70 #include "core/dom/CSSSelectorWatch.h" 71 #include "core/dom/CSSSelectorWatch.h"
71 #include "core/dom/NodeRenderStyle.h" 72 #include "core/dom/NodeRenderStyle.h"
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 document().setHasNodesWithPlaceholderStyle(); 566 document().setHasNodesWithPlaceholderStyle();
566 return s_styleNotYetAvailable; 567 return s_styleNotYetAvailable;
567 } 568 }
568 569
569 didAccess(); 570 didAccess();
570 571
571 StyleResolverParentScope::ensureParentStackIsPushed(); 572 StyleResolverParentScope::ensureParentStackIsPushed();
572 573
573 if (element == document().documentElement()) 574 if (element == document().documentElement())
574 resetDirectionAndWritingModeOnDocument(document()); 575 resetDirectionAndWritingModeOnDocument(document());
575 StyleResolverState state(document(), element, defaultParent);
576 576
577 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { 577 ElementResolveContext elementContext(document(), element, defaultParent);
578 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); 578
579 if (sharingBehavior == AllowStyleSharing && elementContext.parentStyle()) {
580 SharedStyleFinder styleFinder(elementContext, m_features, m_siblingRuleS et.get(), m_uncommonAttributeRuleSet.get(), *this);
579 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) 581 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle())
580 return sharedStyle.release(); 582 return sharedStyle.release();
581 } 583 }
582 584
583 ActiveAnimations* activeAnimations = element->activeAnimations(); 585 StyleResolverState state(elementContext);
584 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr;
585 586
586 if (baseRenderStyle) { 587 if (!elementContext.baseRenderStyle() && elementContext.parentStyle())
587 state.setStyle(RenderStyle::clone(baseRenderStyle)); 588 state.style()->inheritFrom(elementContext.parentStyle(), isAtShadowBound ary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary) ;
588 } else if (state.parentStyle()) { 589
589 state.setStyle(RenderStyle::create());
590 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
591 } else {
592 state.setStyle(defaultStyleForElement());
593 state.setParentStyle(RenderStyle::clone(state.style()));
594 }
595 // contenteditable attribute (implemented by -webkit-user-modify) should 590 // contenteditable attribute (implemented by -webkit-user-modify) should
596 // be propagated from shadow host to distributed node. 591 // be propagated from shadow host to distributed node.
597 if (state.distributedToInsertionPoint()) { 592 if (state.distributedToInsertionPoint()) {
598 if (Element* parent = element->parentElement()) { 593 if (Element* parent = element->parentElement()) {
599 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) 594 if (RenderStyle* styleOfShadowHost = parent->renderStyle())
600 state.style()->setUserModify(styleOfShadowHost->userModify()); 595 state.style()->setUserModify(styleOfShadowHost->userModify());
601 } 596 }
602 } 597 }
603 598
604 if (element->isLink()) { 599 if (element->isLink()) {
605 state.style()->setIsLink(true); 600 state.style()->setIsLink(true);
606 EInsideLink linkState = state.elementLinkState(); 601 EInsideLink linkState = state.elementLinkState();
607 if (linkState != NotInsideLink) { 602 if (linkState != NotInsideLink) {
608 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited); 603 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme nt, CSSSelector::PseudoVisited);
609 if (forceVisited) 604 if (forceVisited)
610 linkState = InsideVisitedLink; 605 linkState = InsideVisitedLink;
611 } 606 }
612 state.style()->setInsideLink(linkState); 607 state.style()->setInsideLink(linkState);
613 } 608 }
614 609
615 if (!baseRenderStyle) { 610 if (!elementContext.baseRenderStyle()) {
616 611
617 bool needsCollection = false; 612 bool needsCollection = false;
618 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele ment, needsCollection); 613 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele ment, needsCollection);
619 if (needsCollection) 614 if (needsCollection)
620 collectFeatures(); 615 collectFeatures();
621 616
622 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); 617 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
623 618
624 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi ngSMIL); 619 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi ngSMIL);
625 620
626 applyMatchedProperties(state, collector.matchedResult()); 621 applyMatchedProperties(state, collector.matchedResult());
627 applyCallbackSelectors(state); 622 applyCallbackSelectors(state);
628 623
629 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); 624 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
630 625
631 // Cache our original display. 626 // Cache our original display.
632 state.style()->setOriginalDisplay(state.style()->display()); 627 state.style()->setOriginalDisplay(state.style()->display());
633 628
634 adjustRenderStyle(state, element); 629 adjustRenderStyle(state, element);
635 630
636 if (activeAnimations) 631 if (elementContext.activeAnimations())
637 activeAnimations->updateBaseRenderStyle(state.style()); 632 elementContext.activeAnimations()->updateBaseRenderStyle(state.style ());
638 } 633 }
639 634
640 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before 635 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before
641 // important rules, but this currently happens here as we require adjustment to have happened 636 // important rules, but this currently happens here as we require adjustment to have happened
642 // before deciding which properties to transition. 637 // before deciding which properties to transition.
643 if (applyAnimatedProperties(state, element)) 638 if (applyAnimatedProperties(state, element))
644 adjustRenderStyle(state, element); 639 adjustRenderStyle(state, element);
645 640
646 if (isHTMLBodyElement(*element)) 641 if (isHTMLBodyElement(*element))
647 document().textLinkColors().setTextColor(state.style()->color()); 642 document().textLinkColors().setTextColor(state.style()->color());
648 643
649 setAnimationUpdateIfNeeded(state, *element); 644 setAnimationUpdateIfNeeded(state, *element);
650 645
651 if (state.style()->hasViewportUnits()) 646 if (state.style()->hasViewportUnits())
652 document().setHasViewportUnits(); 647 document().setHasViewportUnits();
653 648
654 // Now return the style. 649 // Now return the style.
655 return state.takeStyle(); 650 return state.takeStyle();
656 } 651 }
657 652
658 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element& element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName) 653 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element& element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName)
659 { 654 {
660 ASSERT(document().frame()); 655 ASSERT(document().frame());
661 ASSERT(document().settings()); 656 ASSERT(document().settings());
662 ASSERT(!hasPendingAuthorStyleSheets()); 657 ASSERT(!hasPendingAuthorStyleSheets());
663 658
664 if (&element == document().documentElement()) 659 if (&element == document().documentElement())
665 resetDirectionAndWritingModeOnDocument(document()); 660 resetDirectionAndWritingModeOnDocument(document());
666 StyleResolverState state(document(), &element, parentStyle); 661 StyleResolverState state(document(), &element, RenderStyle::clone(&elementSt yle), parentStyle);
667 662
668 MatchResult result; 663 MatchResult result;
669 result.addMatchedProperties(&keyframe->properties()); 664 result.addMatchedProperties(&keyframe->properties());
670 665
671 ASSERT(!state.style());
672
673 // Create the style
674 state.setStyle(RenderStyle::clone(&elementStyle));
675 state.setLineHeightValue(0);
676 666
677 // We don't need to bother with !important. Since there is only ever one 667 // We don't need to bother with !important. Since there is only ever one
678 // decl, there's nothing to override. So just add the first properties. 668 // decl, there's nothing to override. So just add the first properties.
679 // We also don't need to bother with animation properties since the only 669 // We also don't need to bother with animation properties since the only
680 // relevant one is animation-timing-function and we special-case that in 670 // relevant one is animation-timing-function and we special-case that in
681 // CSSAnimations.cpp 671 // CSSAnimations.cpp
682 bool inheritedOnly = false; 672 bool inheritedOnly = false;
683 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); 673 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly);
684 674
685 // If our font got dirtied, go ahead and update it now. 675 // If our font got dirtied, go ahead and update it now.
686 updateFont(state); 676 updateFont(state);
687 677
688 // Line-height is set when we are sure we decided on the font-size
689 if (state.lineHeightValue())
690 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue());
691
692 // Now do rest of the properties. 678 // Now do rest of the properties.
693 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); 679 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly);
694 680
695 loadPendingResources(state); 681 loadPendingResources(state);
696 682
697 didAccess(); 683 didAccess();
698 684
699 return state.takeStyle(); 685 return state.takeStyle();
700 } 686 }
701 687
702 // This function is used by the WebAnimations JavaScript API method animate(). 688 // This function is used by the WebAnimations JavaScript API method animate().
703 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. 689 // FIXME: Remove this when animate() switches away from resolution-dependent par sing.
704 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value) 690 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(Element& element, CSSPropertyID property, CSSValue& value)
705 { 691 {
706 RefPtr<RenderStyle> style; 692 RefPtr<RenderStyle> style;
707 if (element.renderStyle()) 693 if (element.renderStyle())
708 style = RenderStyle::clone(element.renderStyle()); 694 style = RenderStyle::clone(element.renderStyle());
709 else 695 else
710 style = RenderStyle::create(); 696 style = RenderStyle::create();
711 StyleResolverState state(element.document(), &element); 697 StyleResolverState state(element.document(), &element, style);
712 state.setStyle(style);
713 return createAnimatableValueSnapshot(state, property, value); 698 return createAnimatableValueSnapshot(state, property, value);
714 } 699 }
715 700
716 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) 701 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value)
717 { 702 {
718 StyleBuilder::applyProperty(property, state, &value); 703 StyleBuilder::applyProperty(property, state, &value);
719 return CSSAnimatableValueFactory::create(property, *state.style()); 704 return CSSAnimatableValueFactory::create(property, *state.style());
720 } 705 }
721 706
722 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId) 707 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded (Element& parent, PseudoId pseudoId)
(...skipping 11 matching lines...) Expand all
734 if (!parentRenderer->canHaveGeneratedChildren()) 719 if (!parentRenderer->canHaveGeneratedChildren())
735 return nullptr; 720 return nullptr;
736 721
737 RenderStyle* parentStyle = parentRenderer->style(); 722 RenderStyle* parentStyle = parentRenderer->style();
738 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) { 723 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) {
739 if (!pseudoElementRendererIsNeeded(cachedStyle)) 724 if (!pseudoElementRendererIsNeeded(cachedStyle))
740 return nullptr; 725 return nullptr;
741 return PseudoElement::create(&parent, pseudoId); 726 return PseudoElement::create(&parent, pseudoId);
742 } 727 }
743 728
744 StyleResolverState state(document(), &parent, parentStyle); 729 ElementResolveContext elementContext(document(), &parent, parentStyle);
745 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) 730 StyleResolverState state(elementContext);
731 if (!pseudoStyleForElementInternal(pseudoId, parentStyle, state))
746 return nullptr; 732 return nullptr;
747 RefPtr<RenderStyle> style = state.takeStyle(); 733 RefPtr<RenderStyle> style = state.takeStyle();
748 ASSERT(style); 734 ASSERT(style);
749 parentStyle->addCachedPseudoStyle(style); 735 parentStyle->addCachedPseudoStyle(style);
750 736
751 if (!pseudoElementRendererIsNeeded(style.get())) 737 if (!pseudoElementRendererIsNeeded(style.get()))
752 return nullptr; 738 return nullptr;
753 739
754 RefPtrWillBeRawPtr<PseudoElement> pseudo = PseudoElement::create(&parent, ps eudoId); 740 RefPtrWillBeRawPtr<PseudoElement> pseudo = PseudoElement::create(&parent, ps eudoId);
755 741
756 setAnimationUpdateIfNeeded(state, *pseudo); 742 setAnimationUpdateIfNeeded(state, *pseudo);
757 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) 743 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations())
758 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); 744 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get());
759 return pseudo.release(); 745 return pseudo.release();
760 } 746 }
761 747
762 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) 748 bool StyleResolver::pseudoStyleForElementInternal(const PseudoStyleRequest& pseu doStyleRequest, RenderStyle* parentStyle, StyleResolverState& state)
763 { 749 {
764 ASSERT(document().frame()); 750 ASSERT(document().frame());
765 ASSERT(document().settings()); 751 ASSERT(document().settings());
766 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); 752 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED);
767 753
768 StyleResolverParentScope::ensureParentStackIsPushed(); 754 StyleResolverParentScope::ensureParentStackIsPushed();
769 755
770 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); 756 const ElementResolveContext& elementContext = state.elementContext();
771 757 Element* pseudoElement = elementContext.element()->pseudoElement(pseudoStyle Request.pseudoId);
772 ActiveAnimations* activeAnimations = pseudoElement ? pseudoElement->activeAn imations() : nullptr;
773 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba seRenderStyle() : nullptr;
774
775 if (baseRenderStyle) {
776 state.setStyle(RenderStyle::clone(baseRenderStyle));
777 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
778 state.setStyle(RenderStyle::create());
779 state.style()->inheritFrom(state.parentStyle());
780 } else {
781 state.setStyle(defaultStyleForElement());
782 state.setParentStyle(RenderStyle::clone(state.style()));
783 }
784 758
785 state.style()->setStyleType(pseudoStyleRequest.pseudoId); 759 state.style()->setStyleType(pseudoStyleRequest.pseudoId);
786 760
787 // Since we don't use pseudo-elements in any of our quirk/print 761 // Since we don't use pseudo-elements in any of our quirk/print
788 // user agent rules, don't waste time walking those rules. 762 // user agent rules, don't waste time walking those rules.
789 763
790 if (!baseRenderStyle) { 764 if (!elementContext.baseRenderStyle()) {
765
766 if (pseudoStyleRequest.allowsInheritance(elementContext.parentStyle()))
767 state.style()->inheritFrom(elementContext.parentStyle());
768
791 // Check UA, user and author rules. 769 // Check UA, user and author rules.
792 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); 770 ElementRuleCollector collector(elementContext, m_selectorFilter, state.s tyle());
793 collector.setPseudoStyleRequest(pseudoStyleRequest); 771 collector.setPseudoStyleRequest(pseudoStyleRequest);
794 772
795 matchUARules(collector); 773 matchUARules(collector);
796 matchAuthorRules(state.element(), collector, false); 774 matchAuthorRules(state.element(), collector, false);
797 775
798 if (collector.matchedResult().matchedProperties.isEmpty()) 776 if (collector.matchedResult().matchedProperties.isEmpty())
799 return false; 777 return false;
800 778
801 applyMatchedProperties(state, collector.matchedResult()); 779 applyMatchedProperties(state, collector.matchedResult());
802 applyCallbackSelectors(state); 780 applyCallbackSelectors(state);
803 781
804 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); 782 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
805 783
806 // Cache our original display. 784 // Cache our original display.
807 state.style()->setOriginalDisplay(state.style()->display()); 785 state.style()->setOriginalDisplay(state.style()->display());
808 786
809 // FIXME: Passing 0 as the Element* introduces a lot of complexity 787 // FIXME: Passing 0 as the Element* introduces a lot of complexity
810 // in the adjustRenderStyle code. 788 // in the adjustRenderStyle code.
811 adjustRenderStyle(state, 0); 789 adjustRenderStyle(state, 0);
812 790
813 if (activeAnimations) 791 if (elementContext.activeAnimations())
814 activeAnimations->updateBaseRenderStyle(state.style()); 792 elementContext.activeAnimations()->updateBaseRenderStyle(state.style ());
815 } 793 }
816 794
817 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before 795 // FIXME: The CSSWG wants to specify that the effects of animations are appl ied before
818 // important rules, but this currently happens here as we require adjustment to have happened 796 // important rules, but this currently happens here as we require adjustment to have happened
819 // before deciding which properties to transition. 797 // before deciding which properties to transition.
820 if (applyAnimatedProperties(state, pseudoElement)) 798 if (applyAnimatedProperties(state, pseudoElement))
821 adjustRenderStyle(state, 0); 799 adjustRenderStyle(state, 0);
822 800
823 didAccess(); 801 didAccess();
824 802
825 if (state.style()->hasViewportUnits()) 803 if (state.style()->hasViewportUnits())
826 document().setHasViewportUnits(); 804 document().setHasViewportUnits();
827 805
828 return true; 806 return true;
829 } 807 }
830 808
831 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) 809 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
832 { 810 {
833 ASSERT(parentStyle); 811 ASSERT(parentStyle);
834 if (!element) 812 if (!element)
835 return nullptr; 813 return nullptr;
836 814
837 StyleResolverState state(document(), element, parentStyle); 815 ElementResolveContext elementContext(document(), element, parentStyle);
838 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle , state)) { 816 StyleResolverState state(elementContext);
817 if (!pseudoStyleForElementInternal(pseudoStyleRequest, parentStyle, state)) {
839 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) 818 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer)
840 return nullptr; 819 return nullptr;
841 return state.takeStyle(); 820 return state.takeStyle();
842 } 821 }
843 822
844 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest .pseudoId)) 823 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest .pseudoId))
845 setAnimationUpdateIfNeeded(state, *pseudoElement); 824 setAnimationUpdateIfNeeded(state, *pseudoElement);
846 825
847 // Now return the style. 826 // Now return the style.
848 return state.takeStyle(); 827 return state.takeStyle();
849 } 828 }
850 829
851 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) 830 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
852 { 831 {
853 ASSERT(!hasPendingAuthorStyleSheets()); 832 ASSERT(!hasPendingAuthorStyleSheets());
854 resetDirectionAndWritingModeOnDocument(document()); 833 resetDirectionAndWritingModeOnDocument(document());
855 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. 834 StyleResolverState state(document(), document().documentElement(), RenderSty le::create()); // m_rootElementStyle will be set to the document style.
856 835
857 state.setStyle(RenderStyle::create());
858 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); 836 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle();
859 ASSERT(rootElementStyle); 837 ASSERT(rootElementStyle);
860 state.style()->inheritFrom(rootElementStyle); 838 state.style()->inheritFrom(rootElementStyle);
861 839
862 PageRuleCollector collector(rootElementStyle, pageIndex); 840 PageRuleCollector collector(rootElementStyle, pageIndex);
863 841
864 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); 842 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ());
865 843
866 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) 844 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
867 scopedResolver->matchPageRules(collector); 845 scopedResolver->matchPageRules(collector);
868 846
869 state.setLineHeightValue(0);
870 bool inheritedOnly = false; 847 bool inheritedOnly = false;
871 848
872 MatchResult& result = collector.matchedResult(); 849 MatchResult& result = collector.matchedResult();
873 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); 850 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly);
874 851
875 // If our font got dirtied, go ahead and update it now. 852 // If our font got dirtied, go ahead and update it now.
876 updateFont(state); 853 updateFont(state);
877 854
878 // Line-height is set when we are sure we decided on the font-size.
879 if (state.lineHeightValue())
880 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue());
881
882 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); 855 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly);
883 856
884 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); 857 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
885 858
886 loadPendingResources(state); 859 loadPendingResources(state);
887 860
888 didAccess(); 861 didAccess();
889 862
890 // Now return the style. 863 // Now return the style.
891 return state.takeStyle(); 864 return state.takeStyle();
892 } 865 }
893 866
894 void StyleResolver::collectViewportRules() 867 void StyleResolver::collectViewportRules()
895 { 868 {
896 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( ); 869 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( );
897 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.defaultStyl e(), ViewportStyleResolver::UserAgentOrigin); 870 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.defaultStyl e(), ViewportStyleResolver::UserAgentOrigin);
898 871
899 if (!InspectorInstrumentation::applyViewportStyleOverride(&document(), this) ) 872 if (!InspectorInstrumentation::applyViewportStyleOverride(&document(), this) )
900 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default ViewportStyle(), ViewportStyleResolver::UserAgentOrigin); 873 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default ViewportStyle(), ViewportStyleResolver::UserAgentOrigin);
901 874
902 if (document().isMobileDocument()) 875 if (document().isMobileDocument())
903 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default XHTMLMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin); 876 viewportStyleResolver()->collectViewportRules(defaultStyleSheets.default XHTMLMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin);
904 877
905 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) 878 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
906 scopedResolver->collectViewportRulesTo(this); 879 scopedResolver->collectViewportRulesTo(this);
907 880
908 viewportStyleResolver()->resolve(); 881 viewportStyleResolver()->resolve();
909 } 882 }
910 883
911 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
912 {
913 StyleResolverState state(document(), 0);
914 state.setStyle(RenderStyle::create());
915 state.style()->setLineHeight(RenderStyle::initialLineHeight());
916 state.setLineHeightValue(0);
917 state.fontBuilder().setInitial(state.style()->effectiveZoom());
918 state.style()->font().update(document().styleEngine()->fontSelector());
919 return state.takeStyle();
920 }
921
922 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 884 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
923 { 885 {
924 ASSERT(textNode); 886 ASSERT(textNode);
925 887
926 Node* parentNode = NodeRenderingTraversal::parent(textNode); 888 Node* parentNode = NodeRenderingTraversal::parent(textNode);
927 if (!parentNode || !parentNode->renderStyle()) 889 if (!parentNode || !parentNode->renderStyle())
928 return defaultStyleForElement(); 890 return StyleResolverState::defaultStyleForElement(document());
929 return parentNode->renderStyle(); 891 return parentNode->renderStyle();
930 } 892 }
931 893
932 void StyleResolver::updateFont(StyleResolverState& state) 894 void StyleResolver::updateFont(StyleResolverState& state)
933 { 895 {
934 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.parentStyle(), state.style()); 896 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.parentStyle(), state.style());
935 } 897 }
936 898
937 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) 899 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude)
938 { 900 {
939 ASSERT(element); 901 ASSERT(element);
940 StyleResolverState state(document(), element); 902 ElementResolveContext elementContext(document(), element, nullptr);
941 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 903 ElementRuleCollector collector(elementContext, m_selectorFilter, nullptr);
942 collector.setMode(SelectorChecker::CollectingStyleRules); 904 collector.setMode(SelectorChecker::CollectingStyleRules);
943 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); 905 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude);
944 return collector.matchedStyleRuleList(); 906 return collector.matchedStyleRuleList();
945 } 907 }
946 908
947 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Elem ent* element, PseudoId pseudoId, unsigned rulesToInclude) 909 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Elem ent* element, PseudoId pseudoId, unsigned rulesToInclude)
948 { 910 {
949 ASSERT(element); 911 ASSERT(element);
950 StyleResolverState state(document(), element); 912 ElementResolveContext elementContext(document(), element, nullptr);
951 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 913 ElementRuleCollector collector(elementContext, m_selectorFilter, nullptr);
952 collector.setMode(SelectorChecker::CollectingCSSRules); 914 collector.setMode(SelectorChecker::CollectingCSSRules);
953 collectPseudoRulesForElement(element, collector, pseudoId, rulesToInclude); 915 collectPseudoRulesForElement(element, collector, pseudoId, rulesToInclude);
954 return collector.matchedCSSRuleList(); 916 return collector.matchedCSSRuleList();
955 } 917 }
956 918
957 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* e lement, unsigned rulesToInclude) 919 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* e lement, unsigned rulesToInclude)
958 { 920 {
959 return pseudoCSSRulesForElement(element, NOPSEUDO, rulesToInclude); 921 return pseudoCSSRulesForElement(element, NOPSEUDO, rulesToInclude);
960 } 922 }
961 923
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 // lastCSSPropertyId<HighPriorityProperties>. 1208 // lastCSSPropertyId<HighPriorityProperties>.
1247 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr iorityProperties>() 1209 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr iorityProperties>()
1248 { 1210 {
1249 COMPILE_ASSERT(CSSPropertyColor == firstCSSProperty, CSS_color_is_first_high _priority_property); 1211 COMPILE_ASSERT(CSSPropertyColor == firstCSSProperty, CSS_color_is_first_high _priority_property);
1250 return CSSPropertyColor; 1212 return CSSPropertyColor;
1251 } 1213 }
1252 1214
1253 // This method returns the last CSSPropertyId of high priority properties. 1215 // This method returns the last CSSPropertyId of high priority properties.
1254 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri orityProperties>() 1216 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri orityProperties>()
1255 { 1217 {
1256 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 17, CSS_line_heig ht_is_end_of_high_prioity_property_range); 1218 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_ high_priority_property_range);
1257 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_bef ore_line_height); 1219 COMPILE_ASSERT(CSSPropertyTextRendering == CSSPropertyZoom - 1, CSS_text_ren dering_is_before_zoom);
1258 return CSSPropertyLineHeight; 1220 return CSSPropertyZoom;
1259 } 1221 }
1260 1222
1261 // This method returns the first CSSPropertyId of remaining properties, 1223 // This method returns the first CSSPropertyId of remaining properties,
1262 // i.e. low priority properties. No properties depend on low priority 1224 // i.e. low priority properties. No properties depend on low priority
1263 // properties. So we don't need to resolve such properties quickly. 1225 // properties. So we don't need to resolve such properties quickly.
1264 // All low priority properties are obtained by using 1226 // All low priority properties are obtained by using
1265 // firstCSSPropertyId<LowPriorityProperties> and 1227 // firstCSSPropertyId<LowPriorityProperties> and
1266 // lastCSSPropertyId<LowPriorityProperties>. 1228 // lastCSSPropertyId<LowPriorityProperties>.
1267 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri orityProperties>() 1229 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri orityProperties>()
1268 { 1230 {
1269 COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyLineHeight + 1, CSS_bac kground_is_first_low_priority_property); 1231 COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyZoom + 1, CSS_align_con tent_is_first_low_priority_property);
1270 return CSSPropertyAlignContent; 1232 return CSSPropertyAlignContent;
1271 } 1233 }
1272 1234
1273 // This method returns the last CSSPropertyId of low priority properties. 1235 // This method returns the last CSSPropertyId of low priority properties.
1274 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio rityProperties>() 1236 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio rityProperties>()
1275 { 1237 {
1276 return static_cast<CSSPropertyID>(lastCSSProperty); 1238 return static_cast<CSSPropertyID>(lastCSSProperty);
1277 } 1239 }
1278 1240
1279 template <StyleResolver::StyleApplicationPass pass> 1241 template <StyleResolver::StyleApplicationPass pass>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 ASSERT(!current.value()->isInheritedValue()); 1304 ASSERT(!current.value()->isInheritedValue());
1343 continue; 1305 continue;
1344 } 1306 }
1345 1307
1346 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) 1308 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property))
1347 continue; 1309 continue;
1348 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property)) 1310 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property))
1349 continue; 1311 continue;
1350 if (!isPropertyForPass<pass>(property)) 1312 if (!isPropertyForPass<pass>(property))
1351 continue; 1313 continue;
1352 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) 1314
1353 state.setLineHeightValue(current.value()); 1315 StyleBuilder::applyProperty(current.id(), state, current.value());
1354 else
1355 StyleBuilder::applyProperty(current.id(), state, current.value());
1356 } 1316 }
1357 } 1317 }
1358 1318
1359 template <StyleResolver::StyleApplicationPass pass> 1319 template <StyleResolver::StyleApplicationPass pass>
1360 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly) 1320 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly)
1361 { 1321 {
1362 if (startIndex == -1) 1322 if (startIndex == -1)
1363 return; 1323 return;
1364 1324
1365 if (state.style()->insideLink() != NotInsideLink) { 1325 if (state.style()->insideLink() != NotInsideLink) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 state.style()->setInsideLink(linkStatus); 1388 state.style()->setInsideLink(linkStatus);
1429 return; 1389 return;
1430 } 1390 }
1431 applyInheritedOnly = true; 1391 applyInheritedOnly = true;
1432 } 1392 }
1433 1393
1434 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1394 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1435 // high-priority properties first, i.e., those properties that other propert ies depend on. 1395 // high-priority properties first, i.e., those properties that other propert ies depend on.
1436 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1396 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1437 // and (4) normal important. 1397 // and (4) normal important.
1438 state.setLineHeightValue(0);
1439 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1398 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
1440 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); 1399 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly);
1441 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1400 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1442 1401
1443 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1402 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1444 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1403 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
1445 // 1404 //
1446 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the 1405 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the
1447 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related 1406 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related
1448 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the 1407 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
1449 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll 1408 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll
1450 // need to find another way of handling the SVG zoom model. 1409 // need to find another way of handling the SVG zoom model.
1451 state.setEffectiveZoom(RenderStyle::initialZoom()); 1410 state.setEffectiveZoom(RenderStyle::initialZoom());
1452 } 1411 }
1453 1412
1454 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { 1413 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) {
1455 state.fontBuilder().setFontDirty(true); 1414 state.fontBuilder().setFontDirty(true);
1456 applyInheritedOnly = false; 1415 applyInheritedOnly = false;
1457 } 1416 }
1458 1417
1459 // If our font got dirtied, go ahead and update it now. 1418 // If our font got dirtied, go ahead and update it now.
1460 updateFont(state); 1419 updateFont(state);
1461 1420
1462 // Line-height is set when we are sure we decided on the font-size.
1463 if (state.lineHeightValue())
1464 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue());
1465
1466 // Many properties depend on the font. If it changes we just apply all prope rties. 1421 // Many properties depend on the font. If it changes we just apply all prope rties.
1467 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) 1422 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription())
1468 applyInheritedOnly = false; 1423 applyInheritedOnly = false;
1469 1424
1470 // Now do the normal priority UA properties. 1425 // Now do the normal priority UA properties.
1471 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1426 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1472 1427
1473 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. 1428 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
1474 state.cacheUserAgentBorderAndBackground(); 1429 state.cacheUserAgentBorderAndBackground();
1475 1430
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 if (!m_styleResolverStats) 1491 if (!m_styleResolverStats)
1537 return; 1492 return;
1538 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty leResolverStatsSequence, document().url().string().utf8().data()); 1493 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty leResolverStatsSequence, document().url().string().utf8().data());
1539 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); 1494 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data());
1540 fprintf(stderr, "== Totals ==\n"); 1495 fprintf(stderr, "== Totals ==\n");
1541 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); 1496 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data());
1542 } 1497 }
1543 1498
1544 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style) 1499 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s ize_t count, RenderStyle* style)
1545 { 1500 {
1546 StyleResolverState state(document(), document().documentElement(), style); 1501 StyleResolverState state(document(), document().documentElement(), style, st yle);
1547 state.setStyle(style);
1548 1502
1549 for (size_t i = 0; i < count; ++i) { 1503 for (size_t i = 0; i < count; ++i) {
1550 if (properties[i].value) { 1504 if (properties[i].value) {
1551 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, 1505 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
1552 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). 1506 // which assumes the fontMetrics are available for the affected font , otherwise a crash occurs (see http://trac.webkit.org/changeset/96122).
1553 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height. 1507 // The updateFont() call below updates the fontMetrics and ensure th e proper setting of font-size and line-height.
1554 switch (properties[i].property) { 1508 switch (properties[i].property) {
1555 case CSSPropertyFontSize: 1509 case CSSPropertyFontSize:
1556 case CSSPropertyLineHeight: 1510 case CSSPropertyLineHeight:
1557 updateFont(state); 1511 updateFont(state);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 visitor->trace(m_uncommonAttributeRuleSet); 1546 visitor->trace(m_uncommonAttributeRuleSet);
1593 visitor->trace(m_watchedSelectorsRules); 1547 visitor->trace(m_watchedSelectorsRules);
1594 visitor->trace(m_treeBoundaryCrossingRules); 1548 visitor->trace(m_treeBoundaryCrossingRules);
1595 visitor->trace(m_styleSharingLists); 1549 visitor->trace(m_styleSharingLists);
1596 visitor->trace(m_pendingStyleSheets); 1550 visitor->trace(m_pendingStyleSheets);
1597 visitor->trace(m_document); 1551 visitor->trace(m_document);
1598 #endif 1552 #endif
1599 } 1553 }
1600 1554
1601 } // namespace blink 1555 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698