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. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * (C) 2007 Eric Seidel (eric@webkit.org) | 9 * (C) 2007 Eric Seidel (eric@webkit.org) |
10 * | 10 * |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 } | 1735 } |
1736 | 1736 |
1737 void Element::AttachLayoutTree(const AttachContext& context) { | 1737 void Element::AttachLayoutTree(const AttachContext& context) { |
1738 DCHECK(GetDocument().InStyleRecalc()); | 1738 DCHECK(GetDocument().InStyleRecalc()); |
1739 | 1739 |
1740 // We've already been through detach when doing an attach, but we might | 1740 // We've already been through detach when doing an attach, but we might |
1741 // need to clear any state that's been added since then. | 1741 // need to clear any state that's been added since then. |
1742 if (HasRareData() && NeedsAttach()) { | 1742 if (HasRareData() && NeedsAttach()) { |
1743 ElementRareData* data = GetElementRareData(); | 1743 ElementRareData* data = GetElementRareData(); |
1744 data->ClearComputedStyle(); | 1744 data->ClearComputedStyle(); |
| 1745 SetNonAttachedStyle(nullptr); |
1745 } | 1746 } |
1746 | 1747 |
1747 if (!IsActiveSlotOrActiveInsertionPoint()) { | 1748 if (!IsActiveSlotOrActiveInsertionPoint()) { |
1748 LayoutTreeBuilderForElement builder(*this, context.resolved_style); | 1749 LayoutTreeBuilderForElement builder(*this, context.resolved_style); |
1749 builder.CreateLayoutObjectIfNeeded(); | 1750 builder.CreateLayoutObjectIfNeeded(); |
1750 | 1751 |
1751 if (ComputedStyle* style = builder.ResolvedStyle()) { | 1752 if (ComputedStyle* style = builder.ResolvedStyle()) { |
1752 if (!GetLayoutObject() && ShouldStoreNonLayoutObjectComputedStyle(*style)) | 1753 if (!GetLayoutObject() && ShouldStoreNonLayoutObjectComputedStyle(*style)) |
1753 StoreNonLayoutObjectComputedStyle(style); | 1754 StoreNonLayoutObjectComputedStyle(style); |
1754 } | 1755 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 void Element::DetachLayoutTree(const AttachContext& context) { | 1788 void Element::DetachLayoutTree(const AttachContext& context) { |
1788 HTMLFrameOwnerElement::UpdateSuspendScope suspend_widget_hierarchy_updates; | 1789 HTMLFrameOwnerElement::UpdateSuspendScope suspend_widget_hierarchy_updates; |
1789 CancelFocusAppearanceUpdate(); | 1790 CancelFocusAppearanceUpdate(); |
1790 RemoveCallbackSelectors(); | 1791 RemoveCallbackSelectors(); |
1791 if (HasRareData()) { | 1792 if (HasRareData()) { |
1792 ElementRareData* data = GetElementRareData(); | 1793 ElementRareData* data = GetElementRareData(); |
1793 data->ClearPseudoElements(); | 1794 data->ClearPseudoElements(); |
1794 | 1795 |
1795 // attachLayoutTree() will clear the computed style for us when inside | 1796 // attachLayoutTree() will clear the computed style for us when inside |
1796 // recalcStyle. | 1797 // recalcStyle. |
1797 if (!GetDocument().InStyleRecalc()) | 1798 if (!GetDocument().InStyleRecalc()) { |
1798 data->ClearComputedStyle(); | 1799 data->ClearComputedStyle(); |
| 1800 SetNonAttachedStyle(nullptr); |
| 1801 } |
1799 | 1802 |
1800 if (ElementAnimations* element_animations = data->GetElementAnimations()) { | 1803 if (ElementAnimations* element_animations = data->GetElementAnimations()) { |
1801 if (context.performing_reattach) { | 1804 if (context.performing_reattach) { |
1802 // FIXME: We call detach from within style recalc, so compositingState | 1805 // FIXME: We call detach from within style recalc, so compositingState |
1803 // is not up to date. | 1806 // is not up to date. |
1804 // https://code.google.com/p/chromium/issues/detail?id=339847 | 1807 // https://code.google.com/p/chromium/issues/detail?id=339847 |
1805 DisableCompositingQueryAsserts disabler; | 1808 DisableCompositingQueryAsserts disabler; |
1806 | 1809 |
1807 // FIXME: restart compositor animations rather than pull back to the | 1810 // FIXME: restart compositor animations rather than pull back to the |
1808 // main thread | 1811 // main thread |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 ComputedStyle::StylePropagationDiff(old_style.Get(), new_style.Get()); | 2012 ComputedStyle::StylePropagationDiff(old_style.Get(), new_style.Get()); |
2010 if (local_change == kNoChange) { | 2013 if (local_change == kNoChange) { |
2011 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(), | 2014 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(), |
2012 styles_unchanged, 1); | 2015 styles_unchanged, 1); |
2013 } else { | 2016 } else { |
2014 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(), | 2017 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(), |
2015 styles_changed, 1); | 2018 styles_changed, 1); |
2016 } | 2019 } |
2017 | 2020 |
2018 if (local_change == kReattach) { | 2021 if (local_change == kReattach) { |
2019 GetDocument().AddNonAttachedStyle(*this, std::move(new_style)); | 2022 SetNonAttachedStyle(std::move(new_style)); |
2020 SetNeedsReattachLayoutTree(); | 2023 SetNeedsReattachLayoutTree(); |
2021 return kReattach; | 2024 return kReattach; |
2022 } | 2025 } |
2023 | 2026 |
2024 DCHECK(old_style); | 2027 DCHECK(old_style); |
2025 | 2028 |
2026 if (local_change != kNoChange) | 2029 if (local_change != kNoChange) |
2027 UpdateCallbackSelectors(old_style.Get(), new_style.Get()); | 2030 UpdateCallbackSelectors(old_style.Get(), new_style.Get()); |
2028 | 2031 |
2029 if (LayoutObject* layout_object = this->GetLayoutObject()) { | 2032 if (LayoutObject* layout_object = this->GetLayoutObject()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 | 2068 |
2066 return local_change; | 2069 return local_change; |
2067 } | 2070 } |
2068 | 2071 |
2069 void Element::RebuildLayoutTree(Text* next_text_sibling) { | 2072 void Element::RebuildLayoutTree(Text* next_text_sibling) { |
2070 DCHECK(InActiveDocument()); | 2073 DCHECK(InActiveDocument()); |
2071 DCHECK(parentNode()); | 2074 DCHECK(parentNode()); |
2072 | 2075 |
2073 if (NeedsReattachLayoutTree()) { | 2076 if (NeedsReattachLayoutTree()) { |
2074 AttachContext reattach_context; | 2077 AttachContext reattach_context; |
2075 reattach_context.resolved_style = GetDocument().GetNonAttachedStyle(*this); | 2078 reattach_context.resolved_style = GetNonAttachedStyle(); |
2076 bool layout_object_will_change = NeedsAttach() || GetLayoutObject(); | 2079 bool layout_object_will_change = NeedsAttach() || GetLayoutObject(); |
2077 ReattachLayoutTree(reattach_context); | 2080 ReattachLayoutTree(reattach_context); |
2078 if (layout_object_will_change || GetLayoutObject()) | 2081 if (layout_object_will_change || GetLayoutObject()) |
2079 ReattachWhitespaceSiblingsIfNeeded(next_text_sibling); | 2082 ReattachWhitespaceSiblingsIfNeeded(next_text_sibling); |
| 2083 SetNonAttachedStyle(nullptr); |
2080 } else if (ChildNeedsReattachLayoutTree()) { | 2084 } else if (ChildNeedsReattachLayoutTree()) { |
2081 DCHECK(!NeedsReattachLayoutTree()); | 2085 DCHECK(!NeedsReattachLayoutTree()); |
2082 SelectorFilterParentScope filter_scope(*this); | 2086 SelectorFilterParentScope filter_scope(*this); |
2083 StyleSharingDepthScope sharing_scope(*this); | 2087 StyleSharingDepthScope sharing_scope(*this); |
2084 Text* next_text_sibling = nullptr; | 2088 Text* next_text_sibling = nullptr; |
2085 RebuildPseudoElementLayoutTree(kPseudoIdAfter); | 2089 RebuildPseudoElementLayoutTree(kPseudoIdAfter); |
2086 RebuildShadowRootLayoutTree(next_text_sibling); | 2090 RebuildShadowRootLayoutTree(next_text_sibling); |
2087 RebuildChildrenLayoutTrees(next_text_sibling); | 2091 RebuildChildrenLayoutTrees(next_text_sibling); |
2088 RebuildPseudoElementLayoutTree(kPseudoIdBefore, next_text_sibling); | 2092 RebuildPseudoElementLayoutTree(kPseudoIdBefore, next_text_sibling); |
2089 RebuildPseudoElementLayoutTree(kPseudoIdBackdrop); | 2093 RebuildPseudoElementLayoutTree(kPseudoIdBackdrop); |
(...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4336 } | 4340 } |
4337 | 4341 |
4338 DEFINE_TRACE_WRAPPERS(Element) { | 4342 DEFINE_TRACE_WRAPPERS(Element) { |
4339 if (HasRareData()) { | 4343 if (HasRareData()) { |
4340 visitor->TraceWrappers(GetElementRareData()); | 4344 visitor->TraceWrappers(GetElementRareData()); |
4341 } | 4345 } |
4342 ContainerNode::TraceWrappers(visitor); | 4346 ContainerNode::TraceWrappers(visitor); |
4343 } | 4347 } |
4344 | 4348 |
4345 } // namespace blink | 4349 } // namespace blink |
OLD | NEW |