| 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (element == document().documentElement()) | 571 if (element == document().documentElement()) |
| 572 resetDirectionAndWritingModeOnDocument(document()); | 572 resetDirectionAndWritingModeOnDocument(document()); |
| 573 StyleResolverState state(document(), element, defaultParent); | 573 StyleResolverState state(document(), element, defaultParent); |
| 574 | 574 |
| 575 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { | 575 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { |
| 576 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); | 576 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_sibl
ingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this); |
| 577 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) | 577 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) |
| 578 return sharedStyle.release(); | 578 return sharedStyle.release(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 if (state.parentStyle()) { | 581 ActiveAnimations* activeAnimations = element->activeAnimations(); |
| 582 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba
seRenderStyle() : nullptr; |
| 583 |
| 584 if (baseRenderStyle) { |
| 585 state.setStyle(RenderStyle::clone(baseRenderStyle)); |
| 586 } else if (state.parentStyle()) { |
| 582 state.setStyle(RenderStyle::create()); | 587 state.setStyle(RenderStyle::create()); |
| 583 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); | 588 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme
nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
| 584 } else { | 589 } else { |
| 585 state.setStyle(defaultStyleForElement()); | 590 state.setStyle(defaultStyleForElement()); |
| 586 state.setParentStyle(RenderStyle::clone(state.style())); | 591 state.setParentStyle(RenderStyle::clone(state.style())); |
| 587 } | 592 } |
| 588 // contenteditable attribute (implemented by -webkit-user-modify) should | 593 // contenteditable attribute (implemented by -webkit-user-modify) should |
| 589 // be propagated from shadow host to distributed node. | 594 // be propagated from shadow host to distributed node. |
| 590 if (state.distributedToInsertionPoint()) { | 595 if (state.distributedToInsertionPoint()) { |
| 591 if (Element* parent = element->parentElement()) { | 596 if (Element* parent = element->parentElement()) { |
| 592 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 597 if (RenderStyle* styleOfShadowHost = parent->renderStyle()) |
| 593 state.style()->setUserModify(styleOfShadowHost->userModify()); | 598 state.style()->setUserModify(styleOfShadowHost->userModify()); |
| 594 } | 599 } |
| 595 } | 600 } |
| 596 | 601 |
| 597 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 602 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 598 | 603 |
| 599 if (element->isLink()) { | 604 if (element->isLink()) { |
| 600 state.style()->setIsLink(true); | 605 state.style()->setIsLink(true); |
| 601 EInsideLink linkState = state.elementLinkState(); | 606 EInsideLink linkState = state.elementLinkState(); |
| 602 if (linkState != NotInsideLink) { | 607 if (linkState != NotInsideLink) { |
| 603 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 608 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
| 604 if (forceVisited) | 609 if (forceVisited) |
| 605 linkState = InsideVisitedLink; | 610 linkState = InsideVisitedLink; |
| 606 } | 611 } |
| 607 state.style()->setInsideLink(linkState); | 612 state.style()->setInsideLink(linkState); |
| 608 } | 613 } |
| 609 | 614 |
| 610 bool needsCollection = false; | 615 if (!baseRenderStyle) { |
| 611 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element
, needsCollection); | |
| 612 if (needsCollection) | |
| 613 collectFeatures(); | |
| 614 | 616 |
| 615 { | 617 bool needsCollection = false; |
| 618 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele
ment, needsCollection); |
| 619 if (needsCollection) |
| 620 collectFeatures(); |
| 621 |
| 616 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 622 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
| 617 | 623 |
| 618 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi
ngSMIL); | 624 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi
ngSMIL); |
| 619 | 625 |
| 620 applyMatchedProperties(state, collector.matchedResult()); | 626 applyMatchedProperties(state, collector.matchedResult()); |
| 621 applyCallbackSelectors(state); | 627 applyCallbackSelectors(state); |
| 622 | 628 |
| 623 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 629 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 630 |
| 631 // Cache our original display. |
| 632 state.style()->setOriginalDisplay(state.style()->display()); |
| 633 |
| 634 adjustRenderStyle(state, element); |
| 635 |
| 636 if (activeAnimations) |
| 637 activeAnimations->updateBaseRenderStyle(state.style()); |
| 624 } | 638 } |
| 625 | 639 |
| 626 // Cache our original display. | |
| 627 state.style()->setOriginalDisplay(state.style()->display()); | |
| 628 | |
| 629 adjustRenderStyle(state, element); | |
| 630 | |
| 631 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before | 640 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before |
| 632 // important rules, but this currently happens here as we require adjustment
to have happened | 641 // important rules, but this currently happens here as we require adjustment
to have happened |
| 633 // before deciding which properties to transition. | 642 // before deciding which properties to transition. |
| 634 if (applyAnimatedProperties(state, element)) | 643 if (applyAnimatedProperties(state, element)) |
| 635 adjustRenderStyle(state, element); | 644 adjustRenderStyle(state, element); |
| 636 | 645 |
| 637 if (isHTMLBodyElement(*element)) | 646 if (isHTMLBodyElement(*element)) |
| 638 document().textLinkColors().setTextColor(state.style()->color()); | 647 document().textLinkColors().setTextColor(state.style()->color()); |
| 639 | 648 |
| 640 setAnimationUpdateIfNeeded(state, *element); | 649 setAnimationUpdateIfNeeded(state, *element); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 763 } |
| 755 | 764 |
| 756 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState&
state) | 765 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState&
state) |
| 757 { | 766 { |
| 758 ASSERT(document().frame()); | 767 ASSERT(document().frame()); |
| 759 ASSERT(document().settings()); | 768 ASSERT(document().settings()); |
| 760 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 769 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
| 761 | 770 |
| 762 StyleResolverParentScope::ensureParentStackIsPushed(); | 771 StyleResolverParentScope::ensureParentStackIsPushed(); |
| 763 | 772 |
| 764 if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 773 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
| 774 |
| 775 ActiveAnimations* activeAnimations = pseudoElement ? pseudoElement->activeAn
imations() : nullptr; |
| 776 const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->ba
seRenderStyle() : nullptr; |
| 777 |
| 778 if (baseRenderStyle) { |
| 779 state.setStyle(RenderStyle::clone(baseRenderStyle)); |
| 780 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
| 765 state.setStyle(RenderStyle::create()); | 781 state.setStyle(RenderStyle::create()); |
| 766 state.style()->inheritFrom(state.parentStyle()); | 782 state.style()->inheritFrom(state.parentStyle()); |
| 767 } else { | 783 } else { |
| 768 state.setStyle(defaultStyleForElement()); | 784 state.setStyle(defaultStyleForElement()); |
| 769 state.setParentStyle(RenderStyle::clone(state.style())); | 785 state.setParentStyle(RenderStyle::clone(state.style())); |
| 770 } | 786 } |
| 771 | 787 |
| 772 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 788 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
| 773 state.fontBuilder().initForStyleResolve(state.document(), state.style()); | 789 state.fontBuilder().initForStyleResolve(state.document(), state.style()); |
| 774 | 790 |
| 775 // Since we don't use pseudo-elements in any of our quirk/print | 791 // Since we don't use pseudo-elements in any of our quirk/print |
| 776 // user agent rules, don't waste time walking those rules. | 792 // user agent rules, don't waste time walking those rules. |
| 777 | 793 |
| 778 { | 794 if (!baseRenderStyle) { |
| 779 // Check UA, user and author rules. | 795 // Check UA, user and author rules. |
| 780 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 796 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
| 781 collector.setPseudoStyleRequest(pseudoStyleRequest); | 797 collector.setPseudoStyleRequest(pseudoStyleRequest); |
| 782 | 798 |
| 783 matchUARules(collector); | 799 matchUARules(collector); |
| 784 matchAuthorRules(state.element(), collector, false); | 800 matchAuthorRules(state.element(), collector, false); |
| 785 | 801 |
| 786 if (collector.matchedResult().matchedProperties.isEmpty()) | 802 if (collector.matchedResult().matchedProperties.isEmpty()) |
| 787 return false; | 803 return false; |
| 788 | 804 |
| 789 applyMatchedProperties(state, collector.matchedResult()); | 805 applyMatchedProperties(state, collector.matchedResult()); |
| 790 applyCallbackSelectors(state); | 806 applyCallbackSelectors(state); |
| 791 | 807 |
| 792 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 808 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 809 |
| 810 // Cache our original display. |
| 811 state.style()->setOriginalDisplay(state.style()->display()); |
| 812 |
| 813 // FIXME: Passing 0 as the Element* introduces a lot of complexity |
| 814 // in the adjustRenderStyle code. |
| 815 adjustRenderStyle(state, 0); |
| 816 |
| 817 if (activeAnimations) |
| 818 activeAnimations->updateBaseRenderStyle(state.style()); |
| 793 } | 819 } |
| 794 | 820 |
| 795 // Cache our original display. | |
| 796 state.style()->setOriginalDisplay(state.style()->display()); | |
| 797 | |
| 798 // FIXME: Passing 0 as the Element* introduces a lot of complexity | |
| 799 // in the adjustRenderStyle code. | |
| 800 adjustRenderStyle(state, 0); | |
| 801 | |
| 802 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before | 821 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before |
| 803 // important rules, but this currently happens here as we require adjustment
to have happened | 822 // important rules, but this currently happens here as we require adjustment
to have happened |
| 804 // before deciding which properties to transition. | 823 // before deciding which properties to transition. |
| 805 if (applyAnimatedProperties(state, element.pseudoElement(pseudoStyleRequest.
pseudoId))) | 824 if (applyAnimatedProperties(state, pseudoElement)) |
| 806 adjustRenderStyle(state, 0); | 825 adjustRenderStyle(state, 0); |
| 807 | 826 |
| 808 didAccess(); | 827 didAccess(); |
| 809 | 828 |
| 810 if (state.style()->hasViewportUnits()) | 829 if (state.style()->hasViewportUnits()) |
| 811 document().setHasViewportUnits(); | 830 document().setHasViewportUnits(); |
| 812 | 831 |
| 813 return true; | 832 return true; |
| 814 } | 833 } |
| 815 | 834 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 visitor->trace(m_uncommonAttributeRuleSet); | 1601 visitor->trace(m_uncommonAttributeRuleSet); |
| 1583 visitor->trace(m_watchedSelectorsRules); | 1602 visitor->trace(m_watchedSelectorsRules); |
| 1584 visitor->trace(m_treeBoundaryCrossingRules); | 1603 visitor->trace(m_treeBoundaryCrossingRules); |
| 1585 visitor->trace(m_styleSharingLists); | 1604 visitor->trace(m_styleSharingLists); |
| 1586 visitor->trace(m_pendingStyleSheets); | 1605 visitor->trace(m_pendingStyleSheets); |
| 1587 visitor->trace(m_document); | 1606 visitor->trace(m_document); |
| 1588 #endif | 1607 #endif |
| 1589 } | 1608 } |
| 1590 | 1609 |
| 1591 } // namespace blink | 1610 } // namespace blink |
| OLD | NEW |