Index: sky/engine/core/dom/Element.cpp |
diff --git a/sky/engine/core/dom/Element.cpp b/sky/engine/core/dom/Element.cpp |
index 78d958c9d31c2020761e7fe64a2f3fc8ef43ded8..7f5c889f401940e91fb6dec051288f8ac6291011 100644 |
--- a/sky/engine/core/dom/Element.cpp |
+++ b/sky/engine/core/dom/Element.cpp |
@@ -26,6 +26,7 @@ |
#include "sky/engine/config.h" |
#include "sky/engine/core/dom/Element.h" |
+#include "base/bind.h" |
#include "gen/sky/core/CSSValueKeywords.h" |
#include "gen/sky/core/HTMLNames.h" |
#include "gen/sky/platform/RuntimeEnabledFeatures.h" |
@@ -49,6 +50,7 @@ |
#include "sky/engine/core/dom/ElementRareData.h" |
#include "sky/engine/core/dom/ElementTraversal.h" |
#include "sky/engine/core/dom/ExceptionCode.h" |
+#include "sky/engine/core/dom/Microtask.h" |
#include "sky/engine/core/dom/MutationObserverInterestGroup.h" |
#include "sky/engine/core/dom/MutationRecord.h" |
#include "sky/engine/core/dom/NodeRenderStyle.h" |
@@ -75,6 +77,8 @@ |
#include "sky/engine/core/page/ChromeClient.h" |
#include "sky/engine/core/page/FocusController.h" |
#include "sky/engine/core/page/Page.h" |
+#include "sky/engine/core/painting/PaintingContext.h" |
+#include "sky/engine/core/painting/PaintingCallback.h" |
#include "sky/engine/core/rendering/RenderLayer.h" |
#include "sky/engine/core/rendering/RenderView.h" |
#include "sky/engine/platform/EventDispatchForbiddenScope.h" |
@@ -413,6 +417,38 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect() |
return ClientRect::create(result); |
} |
+// TODO(abarth): We should schedule this work at a more reasonable time. |
+static void handlePaintingCommit(RefPtr<Element> element, RefPtr<PaintingContext> context) |
+{ |
+ if (!element->document().isActive()) |
+ return; |
+ element->document().updateLayout(); |
ojan
2015/03/19 22:30:04
We should not need to do this. I guess that falls
|
+ RenderObject* renderer = element->renderer(); |
+ if (!renderer || !renderer->isBox()) |
+ return; |
+ toRenderBox(renderer)->setCustomPainting(context->takeDisplayList()); |
+ element->document().scheduleVisualUpdate(); |
+} |
+ |
+// TODO(abarth): We should schedule this work at a more reasonable time. |
+static void runPaintingCallback(RefPtr<Element> element, PassOwnPtr<PaintingCallback> callback) |
+{ |
+ if (!element->document().isActive()) |
+ return; |
+ element->document().updateLayout(); |
+ RenderObject* renderer = element->renderer(); |
+ if (!renderer || !renderer->isBox()) |
+ return; |
+ RefPtr<PaintingContext> context = PaintingContext::create( |
+ toRenderBox(renderer)->size(), base::Bind(&handlePaintingCommit, element)); |
+ callback->handleEvent(context.get()); |
+} |
+ |
+void Element::requestPaint(PassOwnPtr<PaintingCallback> callback) |
+{ |
+ Microtask::enqueueMicrotask(base::Bind(&runPaintingCallback, this, callback)); |
+} |
+ |
void Element::setAttribute(const AtomicString& localName, const AtomicString& value, ExceptionState& exceptionState) |
{ |
if (!Document::isValidName(localName)) { |