Diff
Modified: trunk/Source/WebCore/ChangeLog (88569 => 88570)
--- trunk/Source/WebCore/ChangeLog 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/ChangeLog 2011-06-10 21:53:49 UTC (rev 88570)
@@ -1,3 +1,38 @@
+2011-06-10 Simon Fraser <simon.fra...@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ Add a scheduleSetNeedsStyleRecalc() method to ContainerNode for use by RenderLayerCompositor
+ https://bugs.webkit.org/show_bug.cgi?id=62471
+
+ RenderLayerCompositor had some code that did a setNeedsStyleRecalc(), but
+ in a way that was safe to call during existing style recalc or layout.
+
+ Move this code to ContainerElement so it can be called elsewhere.
+ Also add a param to the node callback so we can pass the style change type.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::queuePostAttachCallback):
+ (WebCore::ContainerNode::dispatchPostAttachCallbacks):
+ (WebCore::needsStyleRecalcCallback):
+ (WebCore::ContainerNode::scheduleSetNeedsStyleRecalc):
+ * dom/ContainerNode.h:
+ * dom/Node.h:
+ (WebCore::Node::scheduleSetNeedsStyleRecalc):
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::focusPostAttach):
+ (WebCore::updateFromElementCallback):
+ * html/HTMLPlugInImageElement.cpp:
+ (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
+ * html/HTMLPlugInImageElement.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::attachRootPlatformLayer):
+ (WebCore::RenderLayerCompositor::detachRootPlatformLayer):
+ (WebCore::RenderLayerCompositor::notifyIFramesOfCompositingChange):
+ * rendering/RenderLayerCompositor.h:
+ * svg/SVGUseElement.cpp:
+ (WebCore::updateFromElementCallback):
+
2011-06-10 Mark Pilgrim <pilg...@chromium.org>
Reviewed by Tony Chang.
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (88569 => 88570)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2011-06-10 21:53:49 UTC (rev 88570)
@@ -43,13 +43,18 @@
#include <wtf/CurrentTime.h>
#include <wtf/Vector.h>
+using namespace std;
+
namespace WebCore {
static void notifyChildInserted(Node*);
static void dispatchChildInsertionEvents(Node*);
static void dispatchChildRemovalEvents(Node*);
-typedef Vector<std::pair<NodeCallback, RefPtr<Node> > > NodeCallbackQueue;
+typedef pair<RefPtr<Node>, unsigned> CallbackParameters;
+typedef pair<NodeCallback, CallbackParameters> CallbackInfo;
+typedef Vector<CallbackInfo> NodeCallbackQueue;
+
typedef Vector<RefPtr<Node>, 1> NodeVector;
static NodeCallbackQueue* s_postAttachCallbackQueue;
@@ -716,12 +721,12 @@
--s_attachDepth;
}
-void ContainerNode::queuePostAttachCallback(NodeCallback callback, Node* node)
+void ContainerNode::queuePostAttachCallback(NodeCallback callback, Node* node, unsigned callbackData)
{
if (!s_postAttachCallbackQueue)
s_postAttachCallbackQueue = new NodeCallbackQueue;
- s_postAttachCallbackQueue->append(std::pair<NodeCallback, RefPtr<Node> >(callback, node));
+ s_postAttachCallbackQueue->append(CallbackInfo(callback, CallbackParameters(node, callbackData)));
}
bool ContainerNode::postAttachCallbacksAreSuspended()
@@ -734,15 +739,28 @@
// We recalculate size() each time through the loop because a callback
// can add more callbacks to the end of the queue.
for (size_t i = 0; i < s_postAttachCallbackQueue->size(); ++i) {
- std::pair<NodeCallback, RefPtr<Node> >& pair = (*s_postAttachCallbackQueue)[i];
- NodeCallback callback = pair.first;
- Node* node = pair.second.get();
+ const CallbackInfo& info = (*s_postAttachCallbackQueue)[i];
+ NodeCallback callback = info.first;
+ CallbackParameters params = info.second;
- callback(node);
+ callback(params.first.get(), params.second);
}
s_postAttachCallbackQueue->clear();
}
+static void needsStyleRecalcCallback(Node* node, unsigned data)
+{
+ node->setNeedsStyleRecalc(static_cast<StyleChangeType>(data));
+}
+
+void ContainerNode::scheduleSetNeedsStyleRecalc(StyleChangeType changeType)
+{
+ if (postAttachCallbacksAreSuspended())
+ queuePostAttachCallback(needsStyleRecalcCallback, this, static_cast<unsigned>(changeType));
+ else
+ setNeedsStyleRecalc(changeType);
+}
+
void ContainerNode::attach()
{
for (Node* child = m_firstChild; child; child = child->nextSibling())
Modified: trunk/Source/WebCore/dom/ContainerNode.h (88569 => 88570)
--- trunk/Source/WebCore/dom/ContainerNode.h 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2011-06-10 21:53:49 UTC (rev 88570)
@@ -30,7 +30,7 @@
class FloatPoint;
-typedef void (*NodeCallback)(Node*);
+typedef void (*NodeCallback)(Node*, unsigned);
namespace Private {
template<class GenericNode, class GenericNodeContainer>
@@ -83,7 +83,9 @@
bool dispatchBeforeLoadEvent(const String& sourceURL);
- static void queuePostAttachCallback(NodeCallback, Node*);
+ virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange);
+
+ static void queuePostAttachCallback(NodeCallback, Node*, unsigned = 0);
static bool postAttachCallbacksAreSuspended();
protected:
Modified: trunk/Source/WebCore/dom/Node.h (88569 => 88570)
--- trunk/Source/WebCore/dom/Node.h 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/dom/Node.h 2011-06-10 21:53:49 UTC (rev 88570)
@@ -310,6 +310,7 @@
void setNeedsStyleRecalc(StyleChangeType changeType = FullStyleChange);
void clearNeedsStyleRecalc() { m_nodeFlags &= ~StyleChangeMask; }
+ virtual void scheduleSetNeedsStyleRecalc(StyleChangeType changeType = FullStyleChange) { setNeedsStyleRecalc(changeType); }
void setIsLink(bool f) { setFlag(f, IsLinkFlag); }
void setIsLink() { setFlag(IsLinkFlag); }
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (88569 => 88570)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2011-06-10 21:53:49 UTC (rev 88570)
@@ -147,7 +147,7 @@
return false;
}
-static void focusPostAttach(Node* element)
+static void focusPostAttach(Node* element, unsigned)
{
static_cast<Element*>(element)->focus();
element->deref();
@@ -256,7 +256,7 @@
return m_required;
}
-static void updateFromElementCallback(Node* node)
+static void updateFromElementCallback(Node* node, unsigned)
{
ASSERT_ARG(node, node->isElementNode());
ASSERT_ARG(node, static_cast<Element*>(node)->isFormControlElement());
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (88569 => 88570)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2011-06-10 21:53:49 UTC (rev 88570)
@@ -187,7 +187,7 @@
HTMLPlugInElement::willMoveToNewOwnerDocument();
}
-void HTMLPlugInImageElement::updateWidgetCallback(Node* n)
+void HTMLPlugInImageElement::updateWidgetCallback(Node* n, unsigned)
{
static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();
}
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (88569 => 88570)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2011-06-10 21:53:49 UTC (rev 88570)
@@ -59,7 +59,7 @@
String m_serviceType;
String m_url;
- static void updateWidgetCallback(Node*);
+ static void updateWidgetCallback(Node*, unsigned = 0);
virtual void attach();
virtual void detach();
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (88569 => 88570)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2011-06-10 21:53:49 UTC (rev 88570)
@@ -1654,7 +1654,7 @@
case RootLayerAttachedViaEnclosingFrame: {
// The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration()
// for the frame's renderer in the parent document.
- scheduleNeedsStyleRecalc(m_renderView->document()->ownerElement());
+ m_renderView->document()->ownerElement()->scheduleSetNeedsStyleRecalc(SyntheticStyleChange);
break;
}
}
@@ -1678,7 +1678,7 @@
m_rootPlatformLayer->removeFromParent();
if (HTMLFrameOwnerElement* ownerElement = m_renderView->document()->ownerElement())
- scheduleNeedsStyleRecalc(ownerElement);
+ ownerElement->scheduleSetNeedsStyleRecalc(SyntheticStyleChange);
break;
}
case RootLayerAttachedViaChromeClient: {
@@ -1712,19 +1712,6 @@
backing->updateDrawsContent();
}
-static void needsStyleRecalcCallback(Node* node)
-{
- node->setNeedsStyleRecalc(SyntheticStyleChange);
-}
-
-void RenderLayerCompositor::scheduleNeedsStyleRecalc(Element* element)
-{
- if (ContainerNode::postAttachCallbacksAreSuspended())
- ContainerNode::queuePostAttachCallback(needsStyleRecalcCallback, element);
- else
- element->setNeedsStyleRecalc(SyntheticStyleChange);
-}
-
// IFrames are special, because we hook compositing layers together across iframe boundaries
// when both parent and iframe content are composited. So when this frame becomes composited, we have
// to use a synthetic style change to get the iframes into RenderLayers in order to allow them to composite.
@@ -1736,13 +1723,13 @@
for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->traverseNext(frame)) {
if (child->document() && child->document()->ownerElement())
- scheduleNeedsStyleRecalc(child->document()->ownerElement());
+ child->document()->ownerElement()->scheduleSetNeedsStyleRecalc(SyntheticStyleChange);
}
// Compositing also affects the answer to RenderIFrame::requiresAcceleratedCompositing(), so
// we need to schedule a style recalc in our parent document.
if (HTMLFrameOwnerElement* ownerElement = m_renderView->document()->ownerElement())
- scheduleNeedsStyleRecalc(ownerElement);
+ ownerElement->scheduleSetNeedsStyleRecalc(SyntheticStyleChange);
}
bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (88569 => 88570)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2011-06-10 21:53:49 UTC (rev 88570)
@@ -243,7 +243,6 @@
void updateOverflowControlsLayers();
- void scheduleNeedsStyleRecalc(Element*);
void notifyIFramesOfCompositingChange();
// Whether a running transition or animation enforces the need for a compositing layer.
Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (88569 => 88570)
--- trunk/Source/WebCore/svg/SVGUseElement.cpp 2011-06-10 21:42:29 UTC (rev 88569)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp 2011-06-10 21:53:49 UTC (rev 88570)
@@ -717,7 +717,7 @@
return new (arena) RenderSVGShadowTreeRootContainer(this);
}
-static void updateFromElementCallback(Node* node)
+static void updateFromElementCallback(Node* node, unsigned)
{
if (RenderObject* renderer = node->renderer())
renderer->updateFromElement();