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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 898 |
899 if (style->hasTransform()) { | 899 if (style->hasTransform()) { |
900 if (const StylePropertySet* inlineStyle = this->inlineStyle()) | 900 if (const StylePropertySet* inlineStyle = this->inlineStyle()) |
901 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); | 901 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); |
902 } | 902 } |
903 | 903 |
904 document().didRecalculateStyleForElement(); | 904 document().didRecalculateStyleForElement(); |
905 return style.release(); | 905 return style.release(); |
906 } | 906 } |
907 | 907 |
908 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) | 908 void Element::recalcStyle(StyleRecalcChange change) |
909 { | 909 { |
910 ASSERT(document().inStyleRecalc()); | 910 ASSERT(document().inStyleRecalc()); |
911 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 911 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
912 | 912 |
913 if (isInsertionPoint()) | 913 if (isInsertionPoint()) |
914 toInsertionPoint(this)->willRecalcStyle(change); | 914 toInsertionPoint(this)->willRecalcStyle(change); |
915 | 915 |
916 if (change >= Inherit || needsStyleRecalc()) { | 916 if (change >= Inherit || needsStyleRecalc()) { |
917 if (hasRareData()) { | 917 if (hasRareData()) { |
918 ElementRareData* data = elementRareData(); | 918 ElementRareData* data = elementRareData(); |
919 data->clearComputedStyle(); | 919 data->clearComputedStyle(); |
920 | 920 |
921 if (change >= Inherit) { | 921 if (change >= Inherit) { |
922 if (ActiveAnimations* activeAnimations = data->activeAnimations(
)) | 922 if (ActiveAnimations* activeAnimations = data->activeAnimations(
)) |
923 activeAnimations->setAnimationStyleChange(false); | 923 activeAnimations->setAnimationStyleChange(false); |
924 } | 924 } |
925 } | 925 } |
926 if (parentRenderStyle()) | 926 if (parentRenderStyle()) |
927 change = recalcOwnStyle(change); | 927 change = recalcOwnStyle(change); |
928 clearNeedsStyleRecalc(); | 928 clearNeedsStyleRecalc(); |
929 } | 929 } |
930 | 930 |
931 // If we reattached we don't need to recalc the style of our descendants any
more. | 931 // If we reattached we don't need to recalc the style of our descendants any
more. |
932 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) { | 932 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) { |
933 recalcChildStyle(change); | 933 recalcChildStyle(change); |
934 clearChildNeedsStyleRecalc(); | 934 clearChildNeedsStyleRecalc(); |
935 } | 935 } |
936 | |
937 if (change == Reattach) | |
938 reattachWhitespaceSiblings(nextTextSibling); | |
939 } | 936 } |
940 | 937 |
941 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 938 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
942 { | 939 { |
943 ASSERT(document().inStyleRecalc()); | 940 ASSERT(document().inStyleRecalc()); |
944 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 941 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
945 ASSERT(change >= Inherit || needsStyleRecalc()); | 942 ASSERT(change >= Inherit || needsStyleRecalc()); |
946 ASSERT(parentRenderStyle()); | 943 ASSERT(parentRenderStyle()); |
947 | 944 |
948 RefPtr<RenderStyle> oldStyle = renderStyle(); | 945 RefPtr<RenderStyle> oldStyle = renderStyle(); |
949 RefPtr<RenderStyle> newStyle = styleForRenderer(); | 946 RefPtr<RenderStyle> newStyle = styleForRenderer(); |
950 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(oldStyle.g
et(), newStyle.get()); | 947 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(oldStyle.g
et(), newStyle.get()); |
951 | 948 |
952 ASSERT(newStyle); | 949 ASSERT(newStyle); |
953 | 950 |
954 if (localChange == Reattach) { | 951 if (localChange == Reattach) { |
955 AttachContext reattachContext; | 952 AttachContext reattachContext; |
956 reattachContext.resolvedStyle = newStyle.get(); | 953 reattachContext.resolvedStyle = newStyle.get(); |
957 bool rendererWillChange = needsAttach() || renderer(); | |
958 reattach(reattachContext); | 954 reattach(reattachContext); |
959 if (rendererWillChange || renderer()) | 955 return Reattach; |
960 return Reattach; | |
961 return ReattachNoRenderer; | |
962 } | 956 } |
963 | 957 |
964 ASSERT(oldStyle); | 958 ASSERT(oldStyle); |
965 | 959 |
966 if (RenderObject* renderer = this->renderer()) { | 960 if (RenderObject* renderer = this->renderer()) { |
967 if (localChange != NoChange) | 961 if (localChange != NoChange) |
968 renderer->setStyle(newStyle.get()); | 962 renderer->setStyle(newStyle.get()); |
969 } | 963 } |
970 | 964 |
971 if (styleChangeType() >= SubtreeStyleChange) | 965 if (styleChangeType() >= SubtreeStyleChange) |
(...skipping 15 matching lines...) Expand all Loading... |
987 if (ShadowRoot* root = shadowRoot()) { | 981 if (ShadowRoot* root = shadowRoot()) { |
988 if (root->shouldCallRecalcStyle(change)) | 982 if (root->shouldCallRecalcStyle(change)) |
989 root->recalcStyle(change); | 983 root->recalcStyle(change); |
990 } | 984 } |
991 | 985 |
992 // This loop is deliberately backwards because we use insertBefore in th
e rendering tree, and want to avoid | 986 // This loop is deliberately backwards because we use insertBefore in th
e rendering tree, and want to avoid |
993 // a potentially n^2 loop to find the insertion point while resolving st
yle. Having us start from the last | 987 // a potentially n^2 loop to find the insertion point while resolving st
yle. Having us start from the last |
994 // child and work our way back means in the common case, we'll find the
insertion point in O(1) time. | 988 // child and work our way back means in the common case, we'll find the
insertion point in O(1) time. |
995 // See crbug.com/288225 | 989 // See crbug.com/288225 |
996 StyleResolver& styleResolver = document().styleResolver(); | 990 StyleResolver& styleResolver = document().styleResolver(); |
997 Text* lastTextNode = 0; | |
998 for (Node* child = lastChild(); child; child = child->previousSibling())
{ | 991 for (Node* child = lastChild(); child; child = child->previousSibling())
{ |
999 if (child->isTextNode()) { | 992 if (child->isTextNode()) { |
1000 toText(child)->recalcTextStyle(change, lastTextNode); | 993 toText(child)->recalcTextStyle(change); |
1001 lastTextNode = toText(child); | |
1002 } else if (child->isElementNode()) { | 994 } else if (child->isElementNode()) { |
1003 Element* element = toElement(child); | 995 Element* element = toElement(child); |
1004 if (element->shouldCallRecalcStyle(change)) | 996 if (element->shouldCallRecalcStyle(change)) |
1005 element->recalcStyle(change, lastTextNode); | 997 element->recalcStyle(change); |
1006 else if (element->supportsStyleSharing()) | 998 else if (element->supportsStyleSharing()) |
1007 styleResolver.addToStyleSharingList(*element); | 999 styleResolver.addToStyleSharingList(*element); |
1008 if (element->renderer()) | |
1009 lastTextNode = 0; | |
1010 } | 1000 } |
1011 } | 1001 } |
1012 } | 1002 } |
1013 } | 1003 } |
1014 | 1004 |
1015 ElementShadow* Element::shadow() const | 1005 ElementShadow* Element::shadow() const |
1016 { | 1006 { |
1017 return hasRareData() ? elementRareData()->shadow() : 0; | 1007 return hasRareData() ? elementRareData()->shadow() : 0; |
1018 } | 1008 } |
1019 | 1009 |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 return false; | 1762 return false; |
1773 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) | 1763 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) |
1774 return true; | 1764 return true; |
1775 // Host rules could also have effects. | 1765 // Host rules could also have effects. |
1776 if (ShadowRoot* shadowRoot = this->shadowRoot()) | 1766 if (ShadowRoot* shadowRoot = this->shadowRoot()) |
1777 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); | 1767 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); |
1778 return false; | 1768 return false; |
1779 } | 1769 } |
1780 | 1770 |
1781 } // namespace blink | 1771 } // namespace blink |
OLD | NEW |