Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 143983007: Remove PostAttachCallbacks and replace with something more specialized (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/dom/DatasetDOMStringMap.h" 50 #include "core/dom/DatasetDOMStringMap.h"
51 #include "core/dom/ElementDataCache.h" 51 #include "core/dom/ElementDataCache.h"
52 #include "core/dom/ElementRareData.h" 52 #include "core/dom/ElementRareData.h"
53 #include "core/dom/ElementTraversal.h" 53 #include "core/dom/ElementTraversal.h"
54 #include "core/dom/ExceptionCode.h" 54 #include "core/dom/ExceptionCode.h"
55 #include "core/dom/FullscreenElementStack.h" 55 #include "core/dom/FullscreenElementStack.h"
56 #include "core/dom/MutationObserverInterestGroup.h" 56 #include "core/dom/MutationObserverInterestGroup.h"
57 #include "core/dom/MutationRecord.h" 57 #include "core/dom/MutationRecord.h"
58 #include "core/dom/NamedNodeMap.h" 58 #include "core/dom/NamedNodeMap.h"
59 #include "core/dom/NodeRenderStyle.h" 59 #include "core/dom/NodeRenderStyle.h"
60 #include "core/dom/PostAttachCallbacks.h"
61 #include "core/dom/PresentationAttributeStyle.h" 60 #include "core/dom/PresentationAttributeStyle.h"
62 #include "core/dom/PseudoElement.h" 61 #include "core/dom/PseudoElement.h"
63 #include "core/dom/RenderTreeBuilder.h" 62 #include "core/dom/RenderTreeBuilder.h"
64 #include "core/dom/ScriptableDocumentParser.h" 63 #include "core/dom/ScriptableDocumentParser.h"
65 #include "core/dom/SelectorQuery.h" 64 #include "core/dom/SelectorQuery.h"
66 #include "core/dom/Text.h" 65 #include "core/dom/Text.h"
67 #include "core/dom/custom/CustomElement.h" 66 #include "core/dom/custom/CustomElement.h"
68 #include "core/dom/custom/CustomElementRegistrationContext.h" 67 #include "core/dom/custom/CustomElementRegistrationContext.h"
69 #include "core/dom/shadow/InsertionPoint.h" 68 #include "core/dom/shadow/InsertionPoint.h"
70 #include "core/dom/shadow/ShadowRoot.h" 69 #include "core/dom/shadow/ShadowRoot.h"
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 } 1461 }
1463 1462
1464 InspectorInstrumentation::didRecalculateStyleForElement(this); 1463 InspectorInstrumentation::didRecalculateStyleForElement(this);
1465 } 1464 }
1466 1465
1467 void Element::detach(const AttachContext& context) 1466 void Element::detach(const AttachContext& context)
1468 { 1467 {
1469 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1468 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1470 cancelFocusAppearanceUpdate(); 1469 cancelFocusAppearanceUpdate();
1471 removeCallbackSelectors(); 1470 removeCallbackSelectors();
1471 if (needsLayerUpdate())
1472 document().unscheduleLayerUpdate(*this);
1472 if (hasRareData()) { 1473 if (hasRareData()) {
1473 ElementRareData* data = elementRareData(); 1474 ElementRareData* data = elementRareData();
1474 data->clearPseudoElements(); 1475 data->clearPseudoElements();
1475 1476
1476 // attach() will perform the below steps for us when inside recalcStyle. 1477 // attach() will perform the below steps for us when inside recalcStyle.
1477 if (!document().inStyleRecalc()) { 1478 if (!document().inStyleRecalc()) {
1478 data->resetStyleState(); 1479 data->resetStyleState();
1479 data->clearComputedStyle(); 1480 data->clearComputedStyle();
1480 data->clearRestyleFlags(); 1481 data->clearRestyleFlags();
1481 } 1482 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 } 1630 }
1630 1631
1631 ASSERT(oldStyle); 1632 ASSERT(oldStyle);
1632 1633
1633 InspectorInstrumentation::didRecalculateStyleForElement(this); 1634 InspectorInstrumentation::didRecalculateStyleForElement(this);
1634 1635
1635 if (localChange != NoChange) 1636 if (localChange != NoChange)
1636 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1637 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1637 1638
1638 if (RenderObject* renderer = this->renderer()) { 1639 if (RenderObject* renderer = this->renderer()) {
1639 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || shouldNotifyRendererWithIdenticalStyles()) { 1640 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || needsLayerUpdate()) {
1640 renderer->setStyle(newStyle.get()); 1641 renderer->setStyle(newStyle.get());
1641 } else { 1642 } else {
1642 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get 1643 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get
1643 // fooled into believing this style is the same. 1644 // fooled into believing this style is the same.
1644 // FIXME: We may be able to remove this hack, see discussion in 1645 // FIXME: We may be able to remove this hack, see discussion in
1645 // https://codereview.chromium.org/30453002/ 1646 // https://codereview.chromium.org/30453002/
1646 renderer->setStyleInternal(newStyle.get()); 1647 renderer->setStyleInternal(newStyle.get());
1647 } 1648 }
1648 } 1649 }
1649 1650
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 } else if (type == SelectOptions) { 3024 } else if (type == SelectOptions) {
3024 ASSERT(isHTMLSelectElement(this)); 3025 ASSERT(isHTMLSelectElement(this));
3025 return ensureRareData().ensureNodeLists().addCache<HTMLOptionsCollection >(*this, type); 3026 return ensureRareData().ensureNodeLists().addCache<HTMLOptionsCollection >(*this, type);
3026 } else if (type == FormControls) { 3027 } else if (type == FormControls) {
3027 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); 3028 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this));
3028 return ensureRareData().ensureNodeLists().addCache<HTMLFormControlsColle ction>(*this, type); 3029 return ensureRareData().ensureNodeLists().addCache<HTMLFormControlsColle ction>(*this, type);
3029 } 3030 }
3030 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, ty pe); 3031 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, ty pe);
3031 } 3032 }
3032 3033
3033 static void scheduleLayerUpdateCallback(Node* node)
3034 {
3035 // Notify the renderer even is the styles are identical since it may need to
3036 // create or destroy a RenderLayer.
3037 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer);
3038 }
3039
3040 void Element::scheduleLayerUpdate() 3034 void Element::scheduleLayerUpdate()
3041 { 3035 {
3042 if (document().inStyleRecalc()) 3036 document().scheduleLayerUpdate(*this);
3043 PostAttachCallbacks::queueCallback(scheduleLayerUpdateCallback, this);
3044 else
3045 scheduleLayerUpdateCallback(this);
3046 } 3037 }
3047 3038
3048 HTMLCollection* Element::cachedHTMLCollection(CollectionType type) 3039 HTMLCollection* Element::cachedHTMLCollection(CollectionType type)
3049 { 3040 {
3050 return hasRareData() && rareData()->nodeLists() ? rareData()->nodeLists()->c ached<HTMLCollection>(type) : 0; 3041 return hasRareData() && rareData()->nodeLists() ? rareData()->nodeLists()->c ached<HTMLCollection>(type) : 0;
3051 } 3042 }
3052 3043
3053 IntSize Element::savedLayerScrollOffset() const 3044 IntSize Element::savedLayerScrollOffset() const
3054 { 3045 {
3055 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize (); 3046 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize ();
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3405 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3415 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3406 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3416 if (isHTMLOptionElement(*this) || isHTMLOptGroupElement(*this)) 3407 if (isHTMLOptionElement(*this) || isHTMLOptGroupElement(*this))
3417 return false; 3408 return false;
3418 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3409 if (FullscreenElementStack::isActiveFullScreenElement(this))
3419 return false; 3410 return false;
3420 return true; 3411 return true;
3421 } 3412 }
3422 3413
3423 } // namespace WebCore 3414 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698