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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #include "platform/RuntimeEnabledFeatures.h" | 88 #include "platform/RuntimeEnabledFeatures.h" |
89 #include "wtf/StdLibExtras.h" | 89 #include "wtf/StdLibExtras.h" |
90 | 90 |
91 namespace { | 91 namespace { |
92 | 92 |
93 using namespace blink; | 93 using namespace blink; |
94 | 94 |
95 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) | 95 void setAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) |
96 { | 96 { |
97 // If any changes to CSS Animations were detected, stash the update away for
application after the | 97 // If any changes to CSS Animations were detected, stash the update away for
application after the |
98 // render object is updated if we're in the appropriate scope. | 98 // layout object is updated if we're in the appropriate scope. |
99 if (state.animationUpdate()) | 99 if (state.animationUpdate()) |
100 element.ensureElementAnimations().cssAnimations().setPendingUpdate(state
.takeAnimationUpdate()); | 100 element.ensureElementAnimations().cssAnimations().setPendingUpdate(state
.takeAnimationUpdate()); |
101 } | 101 } |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 namespace blink { | 105 namespace blink { |
106 | 106 |
107 using namespace HTMLNames; | 107 using namespace HTMLNames; |
108 | 108 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 } | 533 } |
534 | 534 |
535 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, | 535 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
536 RuleMatchingBehavior matchingBehavior) | 536 RuleMatchingBehavior matchingBehavior) |
537 { | 537 { |
538 ASSERT(document().frame()); | 538 ASSERT(document().frame()); |
539 ASSERT(document().settings()); | 539 ASSERT(document().settings()); |
540 ASSERT(!hasPendingAuthorStyleSheets()); | 540 ASSERT(!hasPendingAuthorStyleSheets()); |
541 ASSERT(!m_needCollectFeatures); | 541 ASSERT(!m_needCollectFeatures); |
542 | 542 |
543 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 543 // Once an element has a layoutObject, we don't try to destroy it, since oth
erwise the layoutObject |
544 // will vanish if a style recalc happens during loading. | 544 // will vanish if a style recalc happens during loading. |
545 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->layoutObject()) { | 545 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->layoutObject()) { |
546 if (!s_styleNotYetAvailable) { | 546 if (!s_styleNotYetAvailable) { |
547 s_styleNotYetAvailable = ComputedStyle::create().leakRef(); | 547 s_styleNotYetAvailable = ComputedStyle::create().leakRef(); |
548 s_styleNotYetAvailable->setDisplay(NONE); | 548 s_styleNotYetAvailable->setDisplay(NONE); |
549 s_styleNotYetAvailable->font().update(document().styleEngine().fontS
elector()); | 549 s_styleNotYetAvailable->font().update(document().styleEngine().fontS
elector()); |
550 } | 550 } |
551 | 551 |
552 document().setHasNodesWithPlaceholderStyle(); | 552 document().setHasNodesWithPlaceholderStyle(); |
553 return s_styleNotYetAvailable; | 553 return s_styleNotYetAvailable; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 713 |
714 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) | 714 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) |
715 { | 715 { |
716 if (pseudoId == FIRST_LETTER) | 716 if (pseudoId == FIRST_LETTER) |
717 return FirstLetterPseudoElement::create(parent); | 717 return FirstLetterPseudoElement::create(parent); |
718 return PseudoElement::create(parent, pseudoId); | 718 return PseudoElement::create(parent, pseudoId); |
719 } | 719 } |
720 | 720 |
721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) | 721 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) |
722 { | 722 { |
723 LayoutObject* parentRenderer = parent.layoutObject(); | 723 LayoutObject* parentLayoutObject = parent.layoutObject(); |
724 if (!parentRenderer) | 724 if (!parentLayoutObject) |
725 return nullptr; | 725 return nullptr; |
726 | 726 |
727 // The first letter pseudo element has to look up the tree and see if any | 727 // The first letter pseudo element has to look up the tree and see if any |
728 // of the ancestors are first letter. | 728 // of the ancestors are first letter. |
729 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren
tRenderer->style()->hasPseudoStyle(pseudoId)) | 729 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren
tLayoutObject->style()->hasPseudoStyle(pseudoId)) |
730 return nullptr; | 730 return nullptr; |
731 | 731 |
732 if (pseudoId == BACKDROP && !parent.isInTopLayer()) | 732 if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
733 return nullptr; | 733 return nullptr; |
734 | 734 |
735 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) | 735 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) |
736 return nullptr; | 736 return nullptr; |
737 | 737 |
738 if (!canHaveGeneratedChildren(*parentRenderer)) | 738 if (!canHaveGeneratedChildren(*parentLayoutObject)) |
739 return nullptr; | 739 return nullptr; |
740 | 740 |
741 ComputedStyle* parentStyle = parentRenderer->mutableStyle(); | 741 ComputedStyle* parentStyle = parentLayoutObject->mutableStyle(); |
742 if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)
) { | 742 if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)
) { |
743 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 743 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
744 return nullptr; | 744 return nullptr; |
745 return createPseudoElement(&parent, pseudoId); | 745 return createPseudoElement(&parent, pseudoId); |
746 } | 746 } |
747 | 747 |
748 StyleResolverState state(document(), &parent, parentStyle); | 748 StyleResolverState state(document(), &parent, parentStyle); |
749 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 749 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
750 return nullptr; | 750 return nullptr; |
751 RefPtr<ComputedStyle> style = state.takeStyle(); | 751 RefPtr<ComputedStyle> style = state.takeStyle(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 if (rulesToInclude & UAAndUserCSSRules) | 946 if (rulesToInclude & UAAndUserCSSRules) |
947 matchUARules(collector); | 947 matchUARules(collector); |
948 | 948 |
949 if (rulesToInclude & AuthorCSSRules) { | 949 if (rulesToInclude & AuthorCSSRules) { |
950 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); | 950 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); |
951 matchAuthorRules(element, collector, rulesToInclude & EmptyCSSRules); | 951 matchAuthorRules(element, collector, rulesToInclude & EmptyCSSRules); |
952 } | 952 } |
953 } | 953 } |
954 | 954 |
955 // -----------------------------------------------------------------------------
-------- | 955 // -----------------------------------------------------------------------------
-------- |
956 // this is mostly boring stuff on how to apply a certain rule to the renderstyle
... | 956 // this is mostly boring stuff on how to apply a certain rule to the Computedsty
le... |
957 | 957 |
958 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele
ment* animatingElement) | 958 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele
ment* animatingElement) |
959 { | 959 { |
960 Element* element = state.element(); | 960 Element* element = state.element(); |
961 ASSERT(element); | 961 ASSERT(element); |
962 | 962 |
963 // The animating element may be this element, or its pseudo element. It is | 963 // The animating element may be this element, or its pseudo element. It is |
964 // null when calculating the style for a potential pseudo element that has | 964 // null when calculating the style for a potential pseudo element that has |
965 // yet to be created. | 965 // yet to be created. |
966 ASSERT(animatingElement == element || !animatingElement || animatingElement-
>parentOrShadowHostElement() == element); | 966 ASSERT(animatingElement == element || !animatingElement || animatingElement-
>parentOrShadowHostElement() == element); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 visitor->trace(m_watchedSelectorsRules); | 1505 visitor->trace(m_watchedSelectorsRules); |
1506 visitor->trace(m_treeBoundaryCrossingRules); | 1506 visitor->trace(m_treeBoundaryCrossingRules); |
1507 visitor->trace(m_styleResourceLoader); | 1507 visitor->trace(m_styleResourceLoader); |
1508 visitor->trace(m_styleSharingLists); | 1508 visitor->trace(m_styleSharingLists); |
1509 visitor->trace(m_pendingStyleSheets); | 1509 visitor->trace(m_pendingStyleSheets); |
1510 visitor->trace(m_document); | 1510 visitor->trace(m_document); |
1511 #endif | 1511 #endif |
1512 } | 1512 } |
1513 | 1513 |
1514 } // namespace blink | 1514 } // namespace blink |
OLD | NEW |