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

Unified Diff: Source/core/dom/Document.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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 1bd554bbe5db9a68d8d9713027d2200e44a82e83..61d138de1d3e763def04275bd63455727a847680 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -83,7 +83,6 @@
#include "core/dom/NodeRenderingTraversal.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/NodeWithIndex.h"
-#include "core/dom/PostAttachCallbacks.h"
#include "core/dom/ProcessingInstruction.h"
#include "core/dom/RequestAnimationFrameCallback.h"
#include "core/dom/ScriptRunner.h"
@@ -1533,7 +1532,17 @@ bool Document::shouldCallRecalcStyleForDocument()
{
if (!isActive() || !view())
return false;
- return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation();
+ if (needsStyleRecalc() || childNeedsStyleRecalc())
+ return true;
+ if (childNeedsDistributionRecalc())
+ return true;
+ if (!m_useElementsNeedingUpdate.isEmpty())
+ return true;
+ if (!m_layerUpdateElements.isEmpty())
+ return true;
+ if (childNeedsStyleInvalidation())
+ return true;
+ return false;
}
bool Document::shouldScheduleStyleRecalc()
@@ -1727,7 +1736,7 @@ void Document::updateStyle(StyleRecalcChange change)
RELEASE_ASSERT(!view()->isInPerformLayout());
RELEASE_ASSERT(!view()->isPainting());
- // Script can run below in PostAttachCallbacks or WidgetUpdates, so protect the LocalFrame.
+ // Script can run below in WidgetUpdates, so protect the LocalFrame.
RefPtr<LocalFrame> protect(m_frame);
TRACE_EVENT0("webkit", "Document::recalcStyle");
@@ -1755,7 +1764,6 @@ void Document::updateStyle(StyleRecalcChange change)
m_styleEngine->setUsesRemUnit(true);
{
- PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks;
RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates;
m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
@@ -1788,8 +1796,11 @@ void Document::updateStyle(StyleRecalcChange change)
if (Element* documentElement = this->documentElement()) {
inheritHtmlAndBodyElementStyles(change);
+ dirtyElementsForLayerUpdate();
if (documentElement->shouldCallRecalcStyle(change))
documentElement->recalcStyle(change);
+ while (dirtyElementsForLayerUpdate())
+ documentElement->recalcStyle(NoChange);
abarth-chromium 2014/03/24 17:47:09 Can we really spin an arbitrary number of times he
}
ensureStyleResolver().printStats();
@@ -1988,6 +1999,32 @@ void Document::setIsViewSource(bool isViewSource)
didUpdateSecurityOrigin();
}
+bool Document::dirtyElementsForLayerUpdate()
+{
+ if (m_layerUpdateElements.isEmpty())
+ return false;
+ HashSet<Element*>::iterator end = m_layerUpdateElements.end();
+ for (HashSet<Element*>::iterator it = m_layerUpdateElements.begin(); it != end; ++it)
+ (*it)->setNeedsStyleRecalc(LocalStyleChange);
+ m_layerUpdateElements.clear();
+ return true;
+}
+
+void Document::scheduleLayerUpdate(Element& element)
+{
+ if (element.styleChangeType() == NeedsReattachStyleChange)
+ return;
+ element.setNeedsLayerUpdate();
+ m_layerUpdateElements.add(&element);
+ scheduleStyleRecalc();
+}
+
+void Document::unscheduleLayerUpdate(Element& element)
+{
+ element.clearNeedsLayerUpdate();
+ m_layerUpdateElements.remove(&element);
+}
+
void Document::scheduleUseShadowTreeUpdate(SVGUseElement& element)
{
m_useElementsNeedingUpdate.add(&element);

Powered by Google App Engine
This is Rietveld 408576698