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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); | 520 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); |
521 } | 521 } |
522 | 522 |
523 // Start loading resources referenced by this style. | 523 // Start loading resources referenced by this style. |
524 void StyleResolver::loadPendingResources(StyleResolverState& state) | 524 void StyleResolver::loadPendingResources(StyleResolverState& state) |
525 { | 525 { |
526 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 526 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
527 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 527 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
528 } | 528 } |
529 | 529 |
530 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
ayoutStyle* defaultParent, StyleSharingBehavior sharingBehavior, | 530 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, LayoutS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
531 RuleMatchingBehavior matchingBehavior) | 531 RuleMatchingBehavior matchingBehavior) |
532 { | 532 { |
533 ASSERT(document().frame()); | 533 ASSERT(document().frame()); |
534 ASSERT(document().settings()); | 534 ASSERT(document().settings()); |
535 ASSERT(!hasPendingAuthorStyleSheets()); | 535 ASSERT(!hasPendingAuthorStyleSheets()); |
536 ASSERT(!m_needCollectFeatures); | 536 ASSERT(!m_needCollectFeatures); |
537 | 537 |
538 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 538 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
539 // will vanish if a style recalc happens during loading. | 539 // will vanish if a style recalc happens during loading. |
540 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { | 540 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 } else { | 577 } else { |
578 state.setStyle(defaultStyleForElement()); | 578 state.setStyle(defaultStyleForElement()); |
579 state.setParentStyle(LayoutStyle::clone(*state.style())); | 579 state.setParentStyle(LayoutStyle::clone(*state.style())); |
580 } | 580 } |
581 } | 581 } |
582 | 582 |
583 // contenteditable attribute (implemented by -webkit-user-modify) should | 583 // contenteditable attribute (implemented by -webkit-user-modify) should |
584 // be propagated from shadow host to distributed node. | 584 // be propagated from shadow host to distributed node. |
585 if (state.distributedToInsertionPoint()) { | 585 if (state.distributedToInsertionPoint()) { |
586 if (Element* parent = element->parentElement()) { | 586 if (Element* parent = element->parentElement()) { |
587 if (LayoutStyle* styleOfShadowHost = parent->mutableLayoutStyle()) | 587 if (LayoutStyle* styleOfShadowHost = parent->layoutStyle()) |
588 state.style()->setUserModify(styleOfShadowHost->userModify()); | 588 state.style()->setUserModify(styleOfShadowHost->userModify()); |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 if (element->isLink()) { | 592 if (element->isLink()) { |
593 state.style()->setIsLink(true); | 593 state.style()->setIsLink(true); |
594 EInsideLink linkState = state.elementLinkState(); | 594 EInsideLink linkState = state.elementLinkState(); |
595 if (linkState != NotInsideLink) { | 595 if (linkState != NotInsideLink) { |
596 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 596 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
597 if (forceVisited) | 597 if (forceVisited) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 | 641 |
642 setAnimationUpdateIfNeeded(state, *element); | 642 setAnimationUpdateIfNeeded(state, *element); |
643 | 643 |
644 if (state.style()->hasViewportUnits()) | 644 if (state.style()->hasViewportUnits()) |
645 document().setHasViewportUnits(); | 645 document().setHasViewportUnits(); |
646 | 646 |
647 // Now return the style. | 647 // Now return the style. |
648 return state.takeStyle(); | 648 return state.takeStyle(); |
649 } | 649 } |
650 | 650 |
651 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, const LayoutStyle* parentStyle, const StyleRuleKeyfra
me* keyframe, const AtomicString& animationName) | 651 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, LayoutStyle* parentStyle, const StyleRuleKeyframe* ke
yframe, const AtomicString& animationName) |
652 { | 652 { |
653 ASSERT(document().frame()); | 653 ASSERT(document().frame()); |
654 ASSERT(document().settings()); | 654 ASSERT(document().settings()); |
655 ASSERT(!hasPendingAuthorStyleSheets()); | 655 ASSERT(!hasPendingAuthorStyleSheets()); |
656 | 656 |
657 StyleResolverState state(document(), &element, parentStyle); | 657 StyleResolverState state(document(), &element, parentStyle); |
658 | 658 |
659 MatchResult result; | 659 MatchResult result; |
660 result.addMatchedProperties(&keyframe->properties()); | 660 result.addMatchedProperties(&keyframe->properties()); |
661 | 661 |
(...skipping 21 matching lines...) Expand all Loading... |
683 didAccess(); | 683 didAccess(); |
684 | 684 |
685 return state.takeStyle(); | 685 return state.takeStyle(); |
686 } | 686 } |
687 | 687 |
688 // This function is used by the WebAnimations JavaScript API method animate(). | 688 // This function is used by the WebAnimations JavaScript API method animate(). |
689 // 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. |
690 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) | 690 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) |
691 { | 691 { |
692 RefPtr<LayoutStyle> style; | 692 RefPtr<LayoutStyle> style; |
693 if (const LayoutStyle* elementStyle = element.layoutStyle()) | 693 if (LayoutStyle* elementStyle = element.layoutStyle()) |
694 style = LayoutStyle::clone(*elementStyle); | 694 style = LayoutStyle::clone(*elementStyle); |
695 else | 695 else |
696 style = LayoutStyle::create(); | 696 style = LayoutStyle::create(); |
697 StyleResolverState state(element.document(), &element); | 697 StyleResolverState state(element.document(), &element); |
698 state.setStyle(style); | 698 state.setStyle(style); |
699 return createAnimatableValueSnapshot(state, property, value); | 699 return createAnimatableValueSnapshot(state, property, value); |
700 } | 700 } |
701 | 701 |
702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) | 702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) |
703 { | 703 { |
(...skipping 22 matching lines...) Expand all Loading... |
726 | 726 |
727 if (pseudoId == BACKDROP && !parent.isInTopLayer()) | 727 if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
728 return nullptr; | 728 return nullptr; |
729 | 729 |
730 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) | 730 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) |
731 return nullptr; | 731 return nullptr; |
732 | 732 |
733 if (!parentRenderer->canHaveGeneratedChildren()) | 733 if (!parentRenderer->canHaveGeneratedChildren()) |
734 return nullptr; | 734 return nullptr; |
735 | 735 |
736 LayoutStyle* parentStyle = parentRenderer->mutableStyle(); | 736 LayoutStyle* parentStyle = parentRenderer->style(); |
737 if (const LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseud
oId)) { | 737 if (LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId))
{ |
738 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 738 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
739 return nullptr; | 739 return nullptr; |
740 return createPseudoElement(&parent, pseudoId); | 740 return createPseudoElement(&parent, pseudoId); |
741 } | 741 } |
742 | 742 |
743 StyleResolverState state(document(), &parent, parentStyle); | 743 StyleResolverState state(document(), &parent, parentStyle); |
744 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 744 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
745 return nullptr; | 745 return nullptr; |
746 RefPtr<LayoutStyle> style = state.takeStyle(); | 746 RefPtr<LayoutStyle> style = state.takeStyle(); |
747 ASSERT(style); | 747 ASSERT(style); |
748 parentStyle->addCachedPseudoStyle(style); | 748 parentStyle->addCachedPseudoStyle(style); |
749 | 749 |
750 if (!pseudoElementRendererIsNeeded(style.get())) | 750 if (!pseudoElementRendererIsNeeded(style.get())) |
751 return nullptr; | 751 return nullptr; |
752 | 752 |
753 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 753 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); |
754 | 754 |
755 setAnimationUpdateIfNeeded(state, *pseudo); | 755 setAnimationUpdateIfNeeded(state, *pseudo); |
756 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) | 756 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) |
757 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); | 757 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); |
758 return pseudo.release(); | 758 return pseudo.release(); |
759 } | 759 } |
760 | 760 |
761 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle, StyleResolverS
tate& state) | 761 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle, StyleResolverState&
state) |
762 { | 762 { |
763 ASSERT(document().frame()); | 763 ASSERT(document().frame()); |
764 ASSERT(document().settings()); | 764 ASSERT(document().settings()); |
765 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 765 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
766 ASSERT(state.parentStyle()); | 766 ASSERT(state.parentStyle()); |
767 | 767 |
768 StyleResolverParentScope::ensureParentStackIsPushed(); | 768 StyleResolverParentScope::ensureParentStackIsPushed(); |
769 | 769 |
770 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 770 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
771 | 771 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 adjustLayoutStyle(state, 0); | 820 adjustLayoutStyle(state, 0); |
821 | 821 |
822 didAccess(); | 822 didAccess(); |
823 | 823 |
824 if (state.style()->hasViewportUnits()) | 824 if (state.style()->hasViewportUnits()) |
825 document().setHasViewportUnits(); | 825 document().setHasViewportUnits(); |
826 | 826 |
827 return true; | 827 return true; |
828 } | 828 } |
829 | 829 |
830 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle) | 830 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle) |
831 { | 831 { |
832 ASSERT(parentStyle); | 832 ASSERT(parentStyle); |
833 if (!element) | 833 if (!element) |
834 return nullptr; | 834 return nullptr; |
835 | 835 |
836 StyleResolverState state(document(), element, parentStyle); | 836 StyleResolverState state(document(), element, parentStyle); |
837 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { | 837 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { |
838 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 838 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
839 return nullptr; | 839 return nullptr; |
840 return state.takeStyle(); | 840 return state.takeStyle(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 return style.release(); | 909 return style.release(); |
910 } | 910 } |
911 | 911 |
912 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) | 912 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) |
913 { | 913 { |
914 ASSERT(textNode); | 914 ASSERT(textNode); |
915 | 915 |
916 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 916 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
917 if (!parentNode || !parentNode->layoutStyle()) | 917 if (!parentNode || !parentNode->layoutStyle()) |
918 return defaultStyleForElement(); | 918 return defaultStyleForElement(); |
919 return parentNode->mutableLayoutStyle(); | 919 return parentNode->layoutStyle(); |
920 } | 920 } |
921 | 921 |
922 void StyleResolver::updateFont(StyleResolverState& state) | 922 void StyleResolver::updateFont(StyleResolverState& state) |
923 { | 923 { |
924 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); | 924 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); |
925 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 925 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
926 state.setConversionZoom(state.style()->effectiveZoom()); | 926 state.setConversionZoom(state.style()->effectiveZoom()); |
927 } | 927 } |
928 | 928 |
929 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 929 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 visitor->trace(m_uncommonAttributeRuleSet); | 1513 visitor->trace(m_uncommonAttributeRuleSet); |
1514 visitor->trace(m_watchedSelectorsRules); | 1514 visitor->trace(m_watchedSelectorsRules); |
1515 visitor->trace(m_treeBoundaryCrossingRules); | 1515 visitor->trace(m_treeBoundaryCrossingRules); |
1516 visitor->trace(m_styleSharingLists); | 1516 visitor->trace(m_styleSharingLists); |
1517 visitor->trace(m_pendingStyleSheets); | 1517 visitor->trace(m_pendingStyleSheets); |
1518 visitor->trace(m_document); | 1518 visitor->trace(m_document); |
1519 #endif | 1519 #endif |
1520 } | 1520 } |
1521 | 1521 |
1522 } // namespace blink | 1522 } // namespace blink |
OLD | NEW |