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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); | 554 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); |
555 } | 555 } |
556 | 556 |
557 // Start loading resources referenced by this style. | 557 // Start loading resources referenced by this style. |
558 void StyleResolver::loadPendingResources(StyleResolverState& state) | 558 void StyleResolver::loadPendingResources(StyleResolverState& state) |
559 { | 559 { |
560 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 560 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
561 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 561 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
562 } | 562 } |
563 | 563 |
564 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, LayoutS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 564 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
ayoutStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
565 RuleMatchingBehavior matchingBehavior) | 565 RuleMatchingBehavior matchingBehavior) |
566 { | 566 { |
567 ASSERT(document().frame()); | 567 ASSERT(document().frame()); |
568 ASSERT(document().settings()); | 568 ASSERT(document().settings()); |
569 ASSERT(!hasPendingAuthorStyleSheets()); | 569 ASSERT(!hasPendingAuthorStyleSheets()); |
570 ASSERT(!m_needCollectFeatures); | 570 ASSERT(!m_needCollectFeatures); |
571 | 571 |
572 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 572 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
573 // will vanish if a style recalc happens during loading. | 573 // will vanish if a style recalc happens during loading. |
574 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { | 574 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } else { | 611 } else { |
612 state.setStyle(defaultStyleForElement()); | 612 state.setStyle(defaultStyleForElement()); |
613 state.setParentStyle(LayoutStyle::clone(*state.style())); | 613 state.setParentStyle(LayoutStyle::clone(*state.style())); |
614 } | 614 } |
615 } | 615 } |
616 | 616 |
617 // contenteditable attribute (implemented by -webkit-user-modify) should | 617 // contenteditable attribute (implemented by -webkit-user-modify) should |
618 // be propagated from shadow host to distributed node. | 618 // be propagated from shadow host to distributed node. |
619 if (state.distributedToInsertionPoint()) { | 619 if (state.distributedToInsertionPoint()) { |
620 if (Element* parent = element->parentElement()) { | 620 if (Element* parent = element->parentElement()) { |
621 if (LayoutStyle* styleOfShadowHost = parent->layoutStyle()) | 621 if (LayoutStyle* styleOfShadowHost = parent->mutableLayoutStyle()) |
622 state.style()->setUserModify(styleOfShadowHost->userModify()); | 622 state.style()->setUserModify(styleOfShadowHost->userModify()); |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 if (element->isLink()) { | 626 if (element->isLink()) { |
627 state.style()->setIsLink(true); | 627 state.style()->setIsLink(true); |
628 EInsideLink linkState = state.elementLinkState(); | 628 EInsideLink linkState = state.elementLinkState(); |
629 if (linkState != NotInsideLink) { | 629 if (linkState != NotInsideLink) { |
630 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 630 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
631 if (forceVisited) | 631 if (forceVisited) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 675 |
676 setAnimationUpdateIfNeeded(state, *element); | 676 setAnimationUpdateIfNeeded(state, *element); |
677 | 677 |
678 if (state.style()->hasViewportUnits()) | 678 if (state.style()->hasViewportUnits()) |
679 document().setHasViewportUnits(); | 679 document().setHasViewportUnits(); |
680 | 680 |
681 // Now return the style. | 681 // Now return the style. |
682 return state.takeStyle(); | 682 return state.takeStyle(); |
683 } | 683 } |
684 | 684 |
685 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, LayoutStyle* parentStyle, const StyleRuleKeyframe* ke
yframe, const AtomicString& animationName) | 685 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, const LayoutStyle* parentStyle, const StyleRuleKeyfra
me* keyframe, const AtomicString& animationName) |
686 { | 686 { |
687 ASSERT(document().frame()); | 687 ASSERT(document().frame()); |
688 ASSERT(document().settings()); | 688 ASSERT(document().settings()); |
689 ASSERT(!hasPendingAuthorStyleSheets()); | 689 ASSERT(!hasPendingAuthorStyleSheets()); |
690 | 690 |
691 StyleResolverState state(document(), &element, parentStyle); | 691 StyleResolverState state(document(), &element, parentStyle); |
692 | 692 |
693 MatchResult result; | 693 MatchResult result; |
694 result.addMatchedProperties(&keyframe->properties()); | 694 result.addMatchedProperties(&keyframe->properties()); |
695 | 695 |
(...skipping 21 matching lines...) Expand all Loading... |
717 didAccess(); | 717 didAccess(); |
718 | 718 |
719 return state.takeStyle(); | 719 return state.takeStyle(); |
720 } | 720 } |
721 | 721 |
722 // This function is used by the WebAnimations JavaScript API method animate(). | 722 // This function is used by the WebAnimations JavaScript API method animate(). |
723 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. | 723 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. |
724 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) | 724 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) |
725 { | 725 { |
726 RefPtr<LayoutStyle> style; | 726 RefPtr<LayoutStyle> style; |
727 if (LayoutStyle* elementStyle = element.layoutStyle()) | 727 if (const LayoutStyle* elementStyle = element.layoutStyle()) |
728 style = LayoutStyle::clone(*elementStyle); | 728 style = LayoutStyle::clone(*elementStyle); |
729 else | 729 else |
730 style = LayoutStyle::create(); | 730 style = LayoutStyle::create(); |
731 StyleResolverState state(element.document(), &element); | 731 StyleResolverState state(element.document(), &element); |
732 state.setStyle(style); | 732 state.setStyle(style); |
733 return createAnimatableValueSnapshot(state, property, value); | 733 return createAnimatableValueSnapshot(state, property, value); |
734 } | 734 } |
735 | 735 |
736 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) | 736 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) |
737 { | 737 { |
(...skipping 22 matching lines...) Expand all Loading... |
760 | 760 |
761 if (pseudoId == BACKDROP && !parent.isInTopLayer()) | 761 if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
762 return nullptr; | 762 return nullptr; |
763 | 763 |
764 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) | 764 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) |
765 return nullptr; | 765 return nullptr; |
766 | 766 |
767 if (!parentRenderer->canHaveGeneratedChildren()) | 767 if (!parentRenderer->canHaveGeneratedChildren()) |
768 return nullptr; | 768 return nullptr; |
769 | 769 |
770 LayoutStyle* parentStyle = parentRenderer->style(); | 770 LayoutStyle* parentStyle = parentRenderer->mutableStyle(); |
771 if (LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId))
{ | 771 if (const LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseud
oId)) { |
772 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 772 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
773 return nullptr; | 773 return nullptr; |
774 return createPseudoElement(&parent, pseudoId); | 774 return createPseudoElement(&parent, pseudoId); |
775 } | 775 } |
776 | 776 |
777 StyleResolverState state(document(), &parent, parentStyle); | 777 StyleResolverState state(document(), &parent, parentStyle); |
778 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 778 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
779 return nullptr; | 779 return nullptr; |
780 RefPtr<LayoutStyle> style = state.takeStyle(); | 780 RefPtr<LayoutStyle> style = state.takeStyle(); |
781 ASSERT(style); | 781 ASSERT(style); |
782 parentStyle->addCachedPseudoStyle(style); | 782 parentStyle->addCachedPseudoStyle(style); |
783 | 783 |
784 if (!pseudoElementRendererIsNeeded(style.get())) | 784 if (!pseudoElementRendererIsNeeded(style.get())) |
785 return nullptr; | 785 return nullptr; |
786 | 786 |
787 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 787 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); |
788 | 788 |
789 setAnimationUpdateIfNeeded(state, *pseudo); | 789 setAnimationUpdateIfNeeded(state, *pseudo); |
790 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) | 790 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) |
791 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); | 791 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); |
792 return pseudo.release(); | 792 return pseudo.release(); |
793 } | 793 } |
794 | 794 |
795 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle, StyleResolverState&
state) | 795 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle, StyleResolverS
tate& state) |
796 { | 796 { |
797 ASSERT(document().frame()); | 797 ASSERT(document().frame()); |
798 ASSERT(document().settings()); | 798 ASSERT(document().settings()); |
799 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 799 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
800 ASSERT(state.parentStyle()); | 800 ASSERT(state.parentStyle()); |
801 | 801 |
802 StyleResolverParentScope::ensureParentStackIsPushed(); | 802 StyleResolverParentScope::ensureParentStackIsPushed(); |
803 | 803 |
804 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 804 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
805 | 805 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 adjustLayoutStyle(state, 0); | 854 adjustLayoutStyle(state, 0); |
855 | 855 |
856 didAccess(); | 856 didAccess(); |
857 | 857 |
858 if (state.style()->hasViewportUnits()) | 858 if (state.style()->hasViewportUnits()) |
859 document().setHasViewportUnits(); | 859 document().setHasViewportUnits(); |
860 | 860 |
861 return true; | 861 return true; |
862 } | 862 } |
863 | 863 |
864 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle) | 864 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle) |
865 { | 865 { |
866 ASSERT(parentStyle); | 866 ASSERT(parentStyle); |
867 if (!element) | 867 if (!element) |
868 return nullptr; | 868 return nullptr; |
869 | 869 |
870 StyleResolverState state(document(), element, parentStyle); | 870 StyleResolverState state(document(), element, parentStyle); |
871 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { | 871 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { |
872 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 872 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
873 return nullptr; | 873 return nullptr; |
874 return state.takeStyle(); | 874 return state.takeStyle(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 return style.release(); | 943 return style.release(); |
944 } | 944 } |
945 | 945 |
946 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) | 946 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) |
947 { | 947 { |
948 ASSERT(textNode); | 948 ASSERT(textNode); |
949 | 949 |
950 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 950 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
951 if (!parentNode || !parentNode->layoutStyle()) | 951 if (!parentNode || !parentNode->layoutStyle()) |
952 return defaultStyleForElement(); | 952 return defaultStyleForElement(); |
953 return parentNode->layoutStyle(); | 953 return parentNode->mutableLayoutStyle(); |
954 } | 954 } |
955 | 955 |
956 void StyleResolver::updateFont(StyleResolverState& state) | 956 void StyleResolver::updateFont(StyleResolverState& state) |
957 { | 957 { |
958 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); | 958 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); |
959 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 959 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
960 state.setConversionZoom(state.style()->effectiveZoom()); | 960 state.setConversionZoom(state.style()->effectiveZoom()); |
961 } | 961 } |
962 | 962 |
963 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 963 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 visitor->trace(m_uncommonAttributeRuleSet); | 1547 visitor->trace(m_uncommonAttributeRuleSet); |
1548 visitor->trace(m_watchedSelectorsRules); | 1548 visitor->trace(m_watchedSelectorsRules); |
1549 visitor->trace(m_treeBoundaryCrossingRules); | 1549 visitor->trace(m_treeBoundaryCrossingRules); |
1550 visitor->trace(m_styleSharingLists); | 1550 visitor->trace(m_styleSharingLists); |
1551 visitor->trace(m_pendingStyleSheets); | 1551 visitor->trace(m_pendingStyleSheets); |
1552 visitor->trace(m_document); | 1552 visitor->trace(m_document); |
1553 #endif | 1553 #endif |
1554 } | 1554 } |
1555 | 1555 |
1556 } // namespace blink | 1556 } // namespace blink |
OLD | NEW |