Chromium Code Reviews| 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.adjustRenderStyle(state.style(), state.parentStyle(), element, stat e.cachedUAStyle()); | 532 adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element, stat e.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<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 542 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, const R enderStyle* 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(RenderStyle::clone(state.style())); | 591 state.setParentStyle(RenderStyle::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 (RenderStyle* styleOfShadowHost = parent->renderStyle()) | 599 if (RenderStyle* styleOfShadowHost = parent->mutableRenderStyle()) |
|
andersr
2015/01/29 18:10:07
We can use a const RenderStyle here?
| |
| 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<RenderStyle> StyleResolver::styleForKeyframe(Element& element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleRuleKeyframe* ke yframe, const AtomicString& animationName) | 663 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element& element, const RenderStyle& elementStyle, const RenderStyle* 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 RenderStyle* parentStyle = parentRenderer->style(); | 748 // Required for addCachedPseudoStyle, should probably make it logical const. |
| 749 if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) { | 749 RenderStyle* parentStyle = parentRenderer->deprecatedMutableStyle(); |
| 750 if (const RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseud oId)) { | |
| 750 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 751 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
| 751 return nullptr; | 752 return nullptr; |
| 752 return createPseudoElement(&parent, pseudoId); | 753 return createPseudoElement(&parent, pseudoId); |
| 753 } | 754 } |
| 754 | 755 |
| 755 StyleResolverState state(document(), &parent, parentStyle); | 756 StyleResolverState state(document(), &parent, parentStyle); |
| 756 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 757 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 757 return nullptr; | 758 return nullptr; |
| 758 RefPtr<RenderStyle> style = state.takeStyle(); | 759 RefPtr<RenderStyle> style = state.takeStyle(); |
| 759 ASSERT(style); | 760 ASSERT(style); |
| 760 parentStyle->addCachedPseudoStyle(style); | 761 parentStyle->addCachedPseudoStyle(style); |
| 761 | 762 |
| 762 if (!pseudoElementRendererIsNeeded(style.get())) | 763 if (!pseudoElementRendererIsNeeded(style.get())) |
| 763 return nullptr; | 764 return nullptr; |
| 764 | 765 |
| 765 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu doId); | 766 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu doId); |
| 766 | 767 |
| 767 setAnimationUpdateIfNeeded(state, *pseudo); | 768 setAnimationUpdateIfNeeded(state, *pseudo); |
| 768 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) | 769 if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) |
| 769 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); | 770 activeAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get()); |
| 770 return pseudo.release(); | 771 return pseudo.release(); |
| 771 } | 772 } |
| 772 | 773 |
| 773 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, RenderStyle* parentStyle, StyleResolverState& state) | 774 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo StyleRequest& pseudoStyleRequest, const RenderStyle* parentStyle, StyleResolverS tate& state) |
| 774 { | 775 { |
| 775 ASSERT(document().frame()); | 776 ASSERT(document().frame()); |
| 776 ASSERT(document().settings()); | 777 ASSERT(document().settings()); |
| 777 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 778 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
| 778 ASSERT(state.parentStyle()); | 779 ASSERT(state.parentStyle()); |
| 779 | 780 |
| 780 StyleResolverParentScope::ensureParentStackIsPushed(); | 781 StyleResolverParentScope::ensureParentStackIsPushed(); |
| 781 | 782 |
| 782 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 783 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
| 783 | 784 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 adjustRenderStyle(state, 0); | 833 adjustRenderStyle(state, 0); |
| 833 | 834 |
| 834 didAccess(); | 835 didAccess(); |
| 835 | 836 |
| 836 if (state.style()->hasViewportUnits()) | 837 if (state.style()->hasViewportUnits()) |
| 837 document().setHasViewportUnits(); | 838 document().setHasViewportUnits(); |
| 838 | 839 |
| 839 return true; | 840 return true; |
| 840 } | 841 } |
| 841 | 842 |
| 842 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) | 843 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, c onst PseudoStyleRequest& pseudoStyleRequest, const RenderStyle* parentStyle) |
| 843 { | 844 { |
| 844 ASSERT(parentStyle); | 845 ASSERT(parentStyle); |
| 845 if (!element) | 846 if (!element) |
| 846 return nullptr; | 847 return nullptr; |
| 847 | 848 |
| 848 StyleResolverState state(document(), element, parentStyle); | 849 StyleResolverState state(document(), element, parentStyle); |
| 849 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle , state)) { | 850 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle , state)) { |
| 850 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 851 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
| 851 return nullptr; | 852 return nullptr; |
| 852 return state.takeStyle(); | 853 return state.takeStyle(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 return style.release(); | 922 return style.release(); |
| 922 } | 923 } |
| 923 | 924 |
| 924 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 925 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
| 925 { | 926 { |
| 926 ASSERT(textNode); | 927 ASSERT(textNode); |
| 927 | 928 |
| 928 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 929 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
| 929 if (!parentNode || !parentNode->renderStyle()) | 930 if (!parentNode || !parentNode->renderStyle()) |
| 930 return defaultStyleForElement(); | 931 return defaultStyleForElement(); |
| 931 return parentNode->renderStyle(); | 932 return parentNode->mutableRenderStyle(); |
| 932 } | 933 } |
| 933 | 934 |
| 934 void StyleResolver::updateFont(StyleResolverState& state) | 935 void StyleResolver::updateFont(StyleResolverState& state) |
| 935 { | 936 { |
| 936 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style(), state.parentStyle()); | 937 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta te.style(), state.parentStyle()); |
| 937 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle())); | 938 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl e(), state.rootElementStyle())); |
| 938 state.setConversionZoom(state.style()->effectiveZoom()); | 939 state.setConversionZoom(state.style()->effectiveZoom()); |
| 939 } | 940 } |
| 940 | 941 |
| 941 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) | 942 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen t* element, unsigned rulesToInclude) |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1573 visitor->trace(m_uncommonAttributeRuleSet); | 1574 visitor->trace(m_uncommonAttributeRuleSet); |
| 1574 visitor->trace(m_watchedSelectorsRules); | 1575 visitor->trace(m_watchedSelectorsRules); |
| 1575 visitor->trace(m_treeBoundaryCrossingRules); | 1576 visitor->trace(m_treeBoundaryCrossingRules); |
| 1576 visitor->trace(m_styleSharingLists); | 1577 visitor->trace(m_styleSharingLists); |
| 1577 visitor->trace(m_pendingStyleSheets); | 1578 visitor->trace(m_pendingStyleSheets); |
| 1578 visitor->trace(m_document); | 1579 visitor->trace(m_document); |
| 1579 #endif | 1580 #endif |
| 1580 } | 1581 } |
| 1581 | 1582 |
| 1582 } // namespace blink | 1583 } // namespace blink |
| OLD | NEW |