| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 if (ElementShadow* shadow = data->shadow()) | 895 if (ElementShadow* shadow = data->shadow()) |
| 896 shadow->detach(context); | 896 shadow->detach(context); |
| 897 } | 897 } |
| 898 ContainerNode::detach(context); | 898 ContainerNode::detach(context); |
| 899 } | 899 } |
| 900 | 900 |
| 901 PassRefPtr<RenderStyle> Element::styleForRenderer() | 901 PassRefPtr<RenderStyle> Element::styleForRenderer() |
| 902 { | 902 { |
| 903 ASSERT(document().inStyleRecalc()); | 903 ASSERT(document().inStyleRecalc()); |
| 904 | 904 |
| 905 RefPtr<RenderStyle> style; | |
| 906 | |
| 907 // FIXME: Instead of clearing updates that may have been added from calls to
styleForElement | 905 // FIXME: Instead of clearing updates that may have been added from calls to
styleForElement |
| 908 // outside recalcStyle, we should just never set them if we're not inside re
calcStyle. | 906 // outside recalcStyle, we should just never set them if we're not inside re
calcStyle. |
| 909 if (ActiveAnimations* activeAnimations = this->activeAnimations()) | 907 if (ActiveAnimations* activeAnimations = this->activeAnimations()) |
| 910 activeAnimations->cssAnimations().setPendingUpdate(nullptr); | 908 activeAnimations->cssAnimations().setPendingUpdate(nullptr); |
| 911 | 909 |
| 912 if (hasCustomStyleCallbacks()) | 910 RefPtr<RenderStyle> style = document().ensureStyleResolver().styleForElement
(this); |
| 913 style = customStyleForRenderer(); | |
| 914 if (!style) | |
| 915 style = originalStyleForRenderer(); | |
| 916 ASSERT(style); | 911 ASSERT(style); |
| 917 | 912 |
| 918 // styleForElement() might add active animations so we need to get it again. | 913 // styleForElement() might add active animations so we need to get it again. |
| 919 if (ActiveAnimations* activeAnimations = this->activeAnimations()) { | 914 if (ActiveAnimations* activeAnimations = this->activeAnimations()) { |
| 920 activeAnimations->cssAnimations().maybeApplyPendingUpdate(this); | 915 activeAnimations->cssAnimations().maybeApplyPendingUpdate(this); |
| 921 activeAnimations->updateAnimationFlags(*style); | 916 activeAnimations->updateAnimationFlags(*style); |
| 922 } | 917 } |
| 923 | 918 |
| 924 if (style->hasTransform()) { | 919 if (style->hasTransform()) { |
| 925 if (const StylePropertySet* inlineStyle = this->inlineStyle()) | 920 if (const StylePropertySet* inlineStyle = this->inlineStyle()) |
| 926 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); | 921 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); |
| 927 } | 922 } |
| 928 | 923 |
| 929 document().didRecalculateStyleForElement(); | 924 document().didRecalculateStyleForElement(); |
| 930 return style.release(); | 925 return style.release(); |
| 931 } | 926 } |
| 932 | 927 |
| 933 PassRefPtr<RenderStyle> Element::originalStyleForRenderer() | |
| 934 { | |
| 935 ASSERT(document().inStyleRecalc()); | |
| 936 return document().ensureStyleResolver().styleForElement(this); | |
| 937 } | |
| 938 | |
| 939 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) | 928 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
| 940 { | 929 { |
| 941 ASSERT(document().inStyleRecalc()); | 930 ASSERT(document().inStyleRecalc()); |
| 942 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 931 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 943 | 932 |
| 944 if (hasCustomStyleCallbacks()) | 933 if (isInsertionPoint()) |
| 945 willRecalcStyle(change); | 934 toInsertionPoint(this)->willRecalcStyle(change); |
| 946 | 935 |
| 947 if (change >= Inherit || needsStyleRecalc()) { | 936 if (change >= Inherit || needsStyleRecalc()) { |
| 948 if (hasRareData()) { | 937 if (hasRareData()) { |
| 949 ElementRareData* data = elementRareData(); | 938 ElementRareData* data = elementRareData(); |
| 950 data->clearComputedStyle(); | 939 data->clearComputedStyle(); |
| 951 | 940 |
| 952 if (change >= Inherit) { | 941 if (change >= Inherit) { |
| 953 if (ActiveAnimations* activeAnimations = data->activeAnimations(
)) | 942 if (ActiveAnimations* activeAnimations = data->activeAnimations(
)) |
| 954 activeAnimations->setAnimationStyleChange(false); | 943 activeAnimations->setAnimationStyleChange(false); |
| 955 } | 944 } |
| 956 } | 945 } |
| 957 if (parentRenderStyle()) | 946 if (parentRenderStyle()) |
| 958 change = recalcOwnStyle(change); | 947 change = recalcOwnStyle(change); |
| 959 clearNeedsStyleRecalc(); | 948 clearNeedsStyleRecalc(); |
| 960 } | 949 } |
| 961 | 950 |
| 962 // If we reattached we don't need to recalc the style of our descendants any
more. | 951 // If we reattached we don't need to recalc the style of our descendants any
more. |
| 963 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) { | 952 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) { |
| 964 recalcChildStyle(change); | 953 recalcChildStyle(change); |
| 965 clearChildNeedsStyleRecalc(); | 954 clearChildNeedsStyleRecalc(); |
| 966 } | 955 } |
| 967 | 956 |
| 968 if (hasCustomStyleCallbacks()) | |
| 969 didRecalcStyle(change); | |
| 970 | |
| 971 if (change == Reattach) | 957 if (change == Reattach) |
| 972 reattachWhitespaceSiblings(nextTextSibling); | 958 reattachWhitespaceSiblings(nextTextSibling); |
| 973 } | 959 } |
| 974 | 960 |
| 975 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 961 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
| 976 { | 962 { |
| 977 ASSERT(document().inStyleRecalc()); | 963 ASSERT(document().inStyleRecalc()); |
| 978 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 964 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 979 ASSERT(change >= Inherit || needsStyleRecalc()); | 965 ASSERT(change >= Inherit || needsStyleRecalc()); |
| 980 ASSERT(parentRenderStyle()); | 966 ASSERT(parentRenderStyle()); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize
(); | 1652 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize
(); |
| 1667 } | 1653 } |
| 1668 | 1654 |
| 1669 void Element::setSavedLayerScrollOffset(const IntSize& size) | 1655 void Element::setSavedLayerScrollOffset(const IntSize& size) |
| 1670 { | 1656 { |
| 1671 if (size.isZero() && !hasRareData()) | 1657 if (size.isZero() && !hasRareData()) |
| 1672 return; | 1658 return; |
| 1673 ensureElementRareData().setSavedLayerScrollOffset(size); | 1659 ensureElementRareData().setSavedLayerScrollOffset(size); |
| 1674 } | 1660 } |
| 1675 | 1661 |
| 1676 void Element::willRecalcStyle(StyleRecalcChange) | |
| 1677 { | |
| 1678 ASSERT(hasCustomStyleCallbacks()); | |
| 1679 } | |
| 1680 | |
| 1681 void Element::didRecalcStyle(StyleRecalcChange) | |
| 1682 { | |
| 1683 ASSERT(hasCustomStyleCallbacks()); | |
| 1684 } | |
| 1685 | |
| 1686 | |
| 1687 PassRefPtr<RenderStyle> Element::customStyleForRenderer() | |
| 1688 { | |
| 1689 ASSERT(hasCustomStyleCallbacks()); | |
| 1690 return nullptr; | |
| 1691 } | |
| 1692 | |
| 1693 void Element::cloneAttributesFromElement(const Element& other) | 1662 void Element::cloneAttributesFromElement(const Element& other) |
| 1694 { | 1663 { |
| 1695 other.synchronizeAllAttributes(); | 1664 other.synchronizeAllAttributes(); |
| 1696 if (!other.m_elementData) { | 1665 if (!other.m_elementData) { |
| 1697 m_elementData.clear(); | 1666 m_elementData.clear(); |
| 1698 return; | 1667 return; |
| 1699 } | 1668 } |
| 1700 | 1669 |
| 1701 const AtomicString& oldID = getIdAttribute(); | 1670 const AtomicString& oldID = getIdAttribute(); |
| 1702 const AtomicString& newID = other.getIdAttribute(); | 1671 const AtomicString& newID = other.getIdAttribute(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 return false; | 1864 return false; |
| 1896 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. | 1865 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. |
| 1897 // See comments in RenderObject::setStyle(). | 1866 // See comments in RenderObject::setStyle(). |
| 1898 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? | 1867 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? |
| 1899 if (isHTMLCanvasElement(*this)) | 1868 if (isHTMLCanvasElement(*this)) |
| 1900 return false; | 1869 return false; |
| 1901 return true; | 1870 return true; |
| 1902 } | 1871 } |
| 1903 | 1872 |
| 1904 } // namespace blink | 1873 } // namespace blink |
| OLD | NEW |