| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, state.cachedUAStyle()); | 532 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, state.cachedUAStyle()); |
| 533 } | 533 } |
| 534 | 534 |
| 535 // Start loading resources referenced by this style. | 535 // Start loading resources referenced by this style. |
| 536 void StyleResolver::loadPendingResources(StyleResolverState& state) | 536 void StyleResolver::loadPendingResources(StyleResolverState& state) |
| 537 { | 537 { |
| 538 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 538 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 539 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 539 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
| 540 } | 540 } |
| 541 | 541 |
| 542 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, LayoutS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 542 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
ayoutStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 543 RuleMatchingBehavior matchingBehavior) | 543 RuleMatchingBehavior matchingBehavior) |
| 544 { | 544 { |
| 545 ASSERT(document().frame()); | 545 ASSERT(document().frame()); |
| 546 ASSERT(document().settings()); | 546 ASSERT(document().settings()); |
| 547 ASSERT(!hasPendingAuthorStyleSheets()); | 547 ASSERT(!hasPendingAuthorStyleSheets()); |
| 548 ASSERT(!m_needCollectFeatures); | 548 ASSERT(!m_needCollectFeatures); |
| 549 | 549 |
| 550 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 550 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
| 551 // will vanish if a style recalc happens during loading. | 551 // will vanish if a style recalc happens during loading. |
| 552 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { | 552 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 } else { | 589 } else { |
| 590 state.setStyle(defaultStyleForElement()); | 590 state.setStyle(defaultStyleForElement()); |
| 591 state.setParentStyle(LayoutStyle::clone(*state.style())); | 591 state.setParentStyle(LayoutStyle::clone(*state.style())); |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 | 594 |
| 595 // contenteditable attribute (implemented by -webkit-user-modify) should | 595 // contenteditable attribute (implemented by -webkit-user-modify) should |
| 596 // be propagated from shadow host to distributed node. | 596 // be propagated from shadow host to distributed node. |
| 597 if (state.distributedToInsertionPoint()) { | 597 if (state.distributedToInsertionPoint()) { |
| 598 if (Element* parent = element->parentElement()) { | 598 if (Element* parent = element->parentElement()) { |
| 599 if (LayoutStyle* styleOfShadowHost = parent->layoutStyle()) | 599 if (LayoutStyle* styleOfShadowHost = parent->mutableLayoutStyle()) |
| 600 state.style()->setUserModify(styleOfShadowHost->userModify()); | 600 state.style()->setUserModify(styleOfShadowHost->userModify()); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 if (element->isLink()) { | 604 if (element->isLink()) { |
| 605 state.style()->setIsLink(true); | 605 state.style()->setIsLink(true); |
| 606 EInsideLink linkState = state.elementLinkState(); | 606 EInsideLink linkState = state.elementLinkState(); |
| 607 if (linkState != NotInsideLink) { | 607 if (linkState != NotInsideLink) { |
| 608 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 608 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
| 609 if (forceVisited) | 609 if (forceVisited) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 setAnimationUpdateIfNeeded(state, *element); | 654 setAnimationUpdateIfNeeded(state, *element); |
| 655 | 655 |
| 656 if (state.style()->hasViewportUnits()) | 656 if (state.style()->hasViewportUnits()) |
| 657 document().setHasViewportUnits(); | 657 document().setHasViewportUnits(); |
| 658 | 658 |
| 659 // Now return the style. | 659 // Now return the style. |
| 660 return state.takeStyle(); | 660 return state.takeStyle(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, LayoutStyle* parentStyle, const StyleRuleKeyframe* ke
yframe, const AtomicString& animationName) | 663 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, const LayoutStyle* parentStyle, const StyleRuleKeyfra
me* keyframe, const AtomicString& animationName) |
| 664 { | 664 { |
| 665 ASSERT(document().frame()); | 665 ASSERT(document().frame()); |
| 666 ASSERT(document().settings()); | 666 ASSERT(document().settings()); |
| 667 ASSERT(!hasPendingAuthorStyleSheets()); | 667 ASSERT(!hasPendingAuthorStyleSheets()); |
| 668 | 668 |
| 669 StyleResolverState state(document(), &element, parentStyle); | 669 StyleResolverState state(document(), &element, parentStyle); |
| 670 | 670 |
| 671 MatchResult result; | 671 MatchResult result; |
| 672 result.addMatchedProperties(&keyframe->properties()); | 672 result.addMatchedProperties(&keyframe->properties()); |
| 673 | 673 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 695 didAccess(); | 695 didAccess(); |
| 696 | 696 |
| 697 return state.takeStyle(); | 697 return state.takeStyle(); |
| 698 } | 698 } |
| 699 | 699 |
| 700 // This function is used by the WebAnimations JavaScript API method animate(). | 700 // This function is used by the WebAnimations JavaScript API method animate(). |
| 701 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. | 701 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. |
| 702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) | 702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, CSSPropertyID property, CSSValue& value) |
| 703 { | 703 { |
| 704 RefPtr<LayoutStyle> style; | 704 RefPtr<LayoutStyle> style; |
| 705 if (LayoutStyle* elementStyle = element.layoutStyle()) | 705 if (const LayoutStyle* elementStyle = element.layoutStyle()) |
| 706 style = LayoutStyle::clone(*elementStyle); | 706 style = LayoutStyle::clone(*elementStyle); |
| 707 else | 707 else |
| 708 style = LayoutStyle::create(); | 708 style = LayoutStyle::create(); |
| 709 StyleResolverState state(element.document(), &element); | 709 StyleResolverState state(element.document(), &element); |
| 710 state.setStyle(style); | 710 state.setStyle(style); |
| 711 return createAnimatableValueSnapshot(state, property, value); | 711 return createAnimatableValueSnapshot(state, property, value); |
| 712 } | 712 } |
| 713 | 713 |
| 714 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) | 714 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue& value) |
| 715 { | 715 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 738 | 738 |
| 739 if (pseudoId == BACKDROP && !parent.isInTopLayer()) | 739 if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
| 740 return nullptr; | 740 return nullptr; |
| 741 | 741 |
| 742 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) | 742 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) |
| 743 return nullptr; | 743 return nullptr; |
| 744 | 744 |
| 745 if (!parentRenderer->canHaveGeneratedChildren()) | 745 if (!parentRenderer->canHaveGeneratedChildren()) |
| 746 return nullptr; | 746 return nullptr; |
| 747 | 747 |
| 748 LayoutStyle* parentStyle = parentRenderer->style(); | 748 LayoutStyle* parentStyle = parentRenderer->mutableStyle(); |
| 749 if (LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId))
{ | 749 if (const LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseud
oId)) { |
| 750 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 750 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
| 751 return nullptr; | 751 return nullptr; |
| 752 return createPseudoElement(&parent, pseudoId); | 752 return createPseudoElement(&parent, pseudoId); |
| 753 } | 753 } |
| 754 | 754 |
| 755 StyleResolverState state(document(), &parent, parentStyle); | 755 StyleResolverState state(document(), &parent, parentStyle); |
| 756 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 756 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 757 return nullptr; | 757 return nullptr; |
| 758 RefPtr<LayoutStyle> style = state.takeStyle(); | 758 RefPtr<LayoutStyle> style = state.takeStyle(); |
| 759 ASSERT(style); | 759 ASSERT(style); |
| 760 parentStyle->addCachedPseudoStyle(style); | 760 parentStyle->addCachedPseudoStyle(style); |
| 761 | 761 |
| 762 if (!pseudoElementRendererIsNeeded(style.get())) | 762 if (!pseudoElementRendererIsNeeded(style.get())) |
| 763 return nullptr; | 763 return nullptr; |
| 764 | 764 |
| 765 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 765 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); |
| 766 | 766 |
| 767 setAnimationUpdateIfNeeded(state, *pseudo); | 767 setAnimationUpdateIfNeeded(state, *pseudo); |
| 768 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) | 768 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) |
| 769 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); | 769 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); |
| 770 return pseudo.release(); | 770 return pseudo.release(); |
| 771 } | 771 } |
| 772 | 772 |
| 773 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle, StyleResolverState&
state) | 773 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle, StyleResolverS
tate& state) |
| 774 { | 774 { |
| 775 ASSERT(document().frame()); | 775 ASSERT(document().frame()); |
| 776 ASSERT(document().settings()); | 776 ASSERT(document().settings()); |
| 777 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 777 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
| 778 ASSERT(state.parentStyle()); | 778 ASSERT(state.parentStyle()); |
| 779 | 779 |
| 780 StyleResolverParentScope::ensureParentStackIsPushed(); | 780 StyleResolverParentScope::ensureParentStackIsPushed(); |
| 781 | 781 |
| 782 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 782 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
| 783 | 783 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 adjustLayoutStyle(state, 0); | 832 adjustLayoutStyle(state, 0); |
| 833 | 833 |
| 834 didAccess(); | 834 didAccess(); |
| 835 | 835 |
| 836 if (state.style()->hasViewportUnits()) | 836 if (state.style()->hasViewportUnits()) |
| 837 document().setHasViewportUnits(); | 837 document().setHasViewportUnits(); |
| 838 | 838 |
| 839 return true; | 839 return true; |
| 840 } | 840 } |
| 841 | 841 |
| 842 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, LayoutStyle* parentStyle) | 842 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle) |
| 843 { | 843 { |
| 844 ASSERT(parentStyle); | 844 ASSERT(parentStyle); |
| 845 if (!element) | 845 if (!element) |
| 846 return nullptr; | 846 return nullptr; |
| 847 | 847 |
| 848 StyleResolverState state(document(), element, parentStyle); | 848 StyleResolverState state(document(), element, parentStyle); |
| 849 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { | 849 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { |
| 850 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 850 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
| 851 return nullptr; | 851 return nullptr; |
| 852 return state.takeStyle(); | 852 return state.takeStyle(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 return style.release(); | 921 return style.release(); |
| 922 } | 922 } |
| 923 | 923 |
| 924 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) | 924 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) |
| 925 { | 925 { |
| 926 ASSERT(textNode); | 926 ASSERT(textNode); |
| 927 | 927 |
| 928 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 928 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
| 929 if (!parentNode || !parentNode->layoutStyle()) | 929 if (!parentNode || !parentNode->layoutStyle()) |
| 930 return defaultStyleForElement(); | 930 return defaultStyleForElement(); |
| 931 return parentNode->layoutStyle(); | 931 return parentNode->mutableLayoutStyle(); |
| 932 } | 932 } |
| 933 | 933 |
| 934 void StyleResolver::updateFont(StyleResolverState& state) | 934 void StyleResolver::updateFont(StyleResolverState& state) |
| 935 { | 935 { |
| 936 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); | 936 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); |
| 937 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 937 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
| 938 state.setConversionZoom(state.style()->effectiveZoom()); | 938 state.setConversionZoom(state.style()->effectiveZoom()); |
| 939 } | 939 } |
| 940 | 940 |
| 941 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 941 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 visitor->trace(m_uncommonAttributeRuleSet); | 1525 visitor->trace(m_uncommonAttributeRuleSet); |
| 1526 visitor->trace(m_watchedSelectorsRules); | 1526 visitor->trace(m_watchedSelectorsRules); |
| 1527 visitor->trace(m_treeBoundaryCrossingRules); | 1527 visitor->trace(m_treeBoundaryCrossingRules); |
| 1528 visitor->trace(m_styleSharingLists); | 1528 visitor->trace(m_styleSharingLists); |
| 1529 visitor->trace(m_pendingStyleSheets); | 1529 visitor->trace(m_pendingStyleSheets); |
| 1530 visitor->trace(m_document); | 1530 visitor->trace(m_document); |
| 1531 #endif | 1531 #endif |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 } // namespace blink | 1534 } // namespace blink |
| OLD | NEW |