Diff
Modified: trunk/Source/WebCore/ChangeLog (129405 => 129406)
--- trunk/Source/WebCore/ChangeLog 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/ChangeLog 2012-09-24 20:34:35 UTC (rev 129406)
@@ -1,3 +1,37 @@
+2012-09-24 Ryosuke Niwa <[email protected]>
+
+ suspend/resumeWidgetHierarchyUpdates should be a RAII object
+ https://bugs.webkit.org/show_bug.cgi?id=96706
+
+ Reviewed by Simon Fraser.
+
+ Replaced suspendWidgetHierarchyUpdates and resumeWidgetHierarchyUpdates by WidgetHierarchyUpdatesSuspensionScope.
+
+ * WebCore.exp.in: Export new symbols.
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::removeChild):
+ (WebCore::ContainerNode::removeChildren):
+ * dom/Document.cpp:
+ (WebCore::Document::recalcStyle):
+ * dom/Element.cpp:
+ (WebCore::Element::attach):
+ (WebCore::Element::detach):
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::EventHandler::passMouseDownEventToWidget):
+ * rendering/RenderWidget.cpp:
+ (WebCore):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::widgetNewParentMap):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::moveWidgets):
+ (WebCore::moveWidgetToParentSoon):
+ * rendering/RenderWidget.h:
+ (WidgetHierarchyUpdatesSuspensionScope):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::WidgetHierarchyUpdatesSuspensionScope):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::~WidgetHierarchyUpdatesSuspensionScope):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::isSuspended):
+ (WebCore::WidgetHierarchyUpdatesSuspensionScope::scheduleWidgetToMove):
+ (WebCore):
+ (RenderWidget):
+
2012-09-24 Otto Derek Cheung <[email protected]>
[BlackBerry] Reverting implementation for 407 error pages
Modified: trunk/Source/WebCore/WebCore.exp.in (129405 => 129406)
--- trunk/Source/WebCore/WebCore.exp.in 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-09-24 20:34:35 UTC (rev 129406)
@@ -186,8 +186,6 @@
__ZN7WebCore12PrintContextD1Ev
__ZNK7WebCore12RenderObject16repaintRectangleERKNS_20FractionalLayoutRectEb
__ZN7WebCore12RenderObject19scrollRectToVisibleERKNS_20FractionalLayoutRectERKNS_15ScrollAlignmentES6_
-__ZN7WebCore12RenderWidget28resumeWidgetHierarchyUpdatesEv
-__ZN7WebCore12RenderWidget29suspendWidgetHierarchyUpdatesEv
__ZN7WebCore12SharedBuffer10wrapCFDataEPK8__CFData
__ZN7WebCore12SharedBuffer10wrapNSDataEP6NSData
__ZN7WebCore12SharedBuffer12createNSDataEv
@@ -638,6 +636,8 @@
__ZN7WebCore31CrossOriginPreflightResultCache6sharedEv
__ZN7WebCore32plainTextToMallocAllocatedBufferEPKNS_5RangeERjbNS_20TextIteratorBehaviorE
__ZN7WebCore33stripLeadingAndTrailingHTMLSpacesERKN3WTF6StringE
+__ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope11moveWidgetsEv
+__ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope35s_widgetHierarchyUpdateSuspendCountE
__ZN7WebCore3macERKNS_10CredentialE
__ZN7WebCore3macERKNS_23AuthenticationChallengeE
__ZN7WebCore40restrictMinimumScaleFactorToViewportSizeERNS_18ViewportAttributesENS_7IntSizeE
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (129405 => 129406)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-09-24 20:34:35 UTC (rev 129406)
@@ -419,15 +419,15 @@
return false;
}
- RenderWidget::suspendWidgetHierarchyUpdates();
+ {
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
- Node* prev = child->previousSibling();
- Node* next = child->nextSibling();
- removeBetween(prev, next, child.get());
- childrenChanged(false, prev, next, -1);
- ChildNodeRemovalNotifier(this).notify(child.get());
-
- RenderWidget::resumeWidgetHierarchyUpdates();
+ Node* prev = child->previousSibling();
+ Node* next = child->nextSibling();
+ removeBetween(prev, next, child.get());
+ childrenChanged(false, prev, next, -1);
+ ChildNodeRemovalNotifier(this).notify(child.get());
+ }
dispatchSubtreeModifiedEvent();
return child;
@@ -497,49 +497,50 @@
// and remove... e.g. stop loading frames, fire unload events.
willRemoveChildren(protect.get());
- RenderWidget::suspendWidgetHierarchyUpdates();
- forbidEventDispatch();
Vector<RefPtr<Node>, 10> removedChildren;
- removedChildren.reserveInitialCapacity(childNodeCount());
- while (RefPtr<Node> n = m_firstChild) {
- Node* next = n->nextSibling();
+ {
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
+ forbidEventDispatch();
+ removedChildren.reserveInitialCapacity(childNodeCount());
+ while (RefPtr<Node> n = m_firstChild) {
+ Node* next = n->nextSibling();
- // Remove the node from the tree before calling detach or removedFromDocument (4427024, 4129744).
- // removeChild() does this after calling detach(). There is no explanation for
- // this discrepancy between removeChild() and its optimized version removeChildren().
- n->setPreviousSibling(0);
- n->setNextSibling(0);
- n->setParentOrHostNode(0);
- document()->adoptIfNeeded(n.get());
+ // Remove the node from the tree before calling detach or removedFromDocument (4427024, 4129744).
+ // removeChild() does this after calling detach(). There is no explanation for
+ // this discrepancy between removeChild() and its optimized version removeChildren().
+ n->setPreviousSibling(0);
+ n->setNextSibling(0);
+ n->setParentOrHostNode(0);
+ document()->adoptIfNeeded(n.get());
- m_firstChild = next;
- if (n == m_lastChild)
- m_lastChild = 0;
- removedChildren.append(n.release());
- }
+ m_firstChild = next;
+ if (n == m_lastChild)
+ m_lastChild = 0;
+ removedChildren.append(n.release());
+ }
- size_t removedChildrenCount = removedChildren.size();
- size_t i;
+ size_t removedChildrenCount = removedChildren.size();
+ size_t i;
- // Detach the nodes only after properly removed from the tree because
- // a. detaching requires a proper DOM tree (for counters and quotes for
- // example) and during the previous loop the next sibling still points to
- // the node being removed while the node being removed does not point back
- // and does not point to the same parent as its next sibling.
- // b. destroying Renderers of standalone nodes is sometimes faster.
- for (i = 0; i < removedChildrenCount; ++i) {
- Node* removedChild = removedChildren[i].get();
- if (removedChild->attached())
- removedChild->detach();
- }
+ // Detach the nodes only after properly removed from the tree because
+ // a. detaching requires a proper DOM tree (for counters and quotes for
+ // example) and during the previous loop the next sibling still points to
+ // the node being removed while the node being removed does not point back
+ // and does not point to the same parent as its next sibling.
+ // b. destroying Renderers of standalone nodes is sometimes faster.
+ for (i = 0; i < removedChildrenCount; ++i) {
+ Node* removedChild = removedChildren[i].get();
+ if (removedChild->attached())
+ removedChild->detach();
+ }
- childrenChanged(false, 0, 0, -static_cast<int>(removedChildrenCount));
+ childrenChanged(false, 0, 0, -static_cast<int>(removedChildrenCount));
- for (i = 0; i < removedChildrenCount; ++i)
- ChildNodeRemovalNotifier(this).notify(removedChildren[i].get());
+ for (i = 0; i < removedChildrenCount; ++i)
+ ChildNodeRemovalNotifier(this).notify(removedChildren[i].get());
- allowEventDispatch();
- RenderWidget::resumeWidgetHierarchyUpdates();
+ allowEventDispatch();
+ }
dispatchSubtreeModifiedEvent();
}
Modified: trunk/Source/WebCore/dom/Document.cpp (129405 => 129406)
--- trunk/Source/WebCore/dom/Document.cpp 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/dom/Document.cpp 2012-09-24 20:34:35 UTC (rev 129406)
@@ -1832,65 +1832,66 @@
m_inStyleRecalc = true;
suspendPostAttachCallbacks();
- RenderWidget::suspendWidgetHierarchyUpdates();
-
- RefPtr<FrameView> frameView = view();
- if (frameView) {
- frameView->pauseScheduledEvents();
- frameView->beginDeferredRepaints();
- }
+ {
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
- ASSERT(!renderer() || renderArena());
- if (!renderer() || !renderArena())
- goto bail_out;
+ RefPtr<FrameView> frameView = view();
+ if (frameView) {
+ frameView->pauseScheduledEvents();
+ frameView->beginDeferredRepaints();
+ }
- if (m_pendingStyleRecalcShouldForce)
- change = Force;
+ ASSERT(!renderer() || renderArena());
+ if (!renderer() || !renderArena())
+ goto bailOut;
- // Recalculating the root style (on the document) is not needed in the common case.
- if ((change == Force) || (shouldDisplaySeamlesslyWithParent() && (change >= Inherit))) {
- // style selector may set this again during recalc
- m_hasNodesWithPlaceholderStyle = false;
-
- RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(this, m_styleResolver ? m_styleResolver->fontSelector() : 0);
- StyleChange ch = Node::diff(documentStyle.get(), renderer()->style(), this);
- if (ch != NoChange)
- renderer()->setStyle(documentStyle.release());
- }
+ if (m_pendingStyleRecalcShouldForce)
+ change = Force;
- for (Node* n = firstChild(); n; n = n->nextSibling()) {
- if (!n->isElementNode())
- continue;
- Element* element = static_cast<Element*>(n);
- if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc())
- element->recalcStyle(change);
- }
+ // Recalculating the root style (on the document) is not needed in the common case.
+ if ((change == Force) || (shouldDisplaySeamlesslyWithParent() && (change >= Inherit))) {
+ // style selector may set this again during recalc
+ m_hasNodesWithPlaceholderStyle = false;
+
+ RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(this, m_styleResolver ? m_styleResolver->fontSelector() : 0);
+ StyleChange ch = Node::diff(documentStyle.get(), renderer()->style(), this);
+ if (ch != NoChange)
+ renderer()->setStyle(documentStyle.release());
+ }
-#if USE(ACCELERATED_COMPOSITING)
- if (view()) {
- bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
- // If we didn't update compositing layers because of layout(), we need to do so here.
- if (!layoutPending)
- view()->updateCompositingLayersAfterStyleChange();
- }
-#endif
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ if (!n->isElementNode())
+ continue;
+ Element* element = static_cast<Element*>(n);
+ if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc())
+ element->recalcStyle(change);
+ }
-bail_out:
- clearNeedsStyleRecalc();
- clearChildNeedsStyleRecalc();
- unscheduleStyleRecalc();
+ #if USE(ACCELERATED_COMPOSITING)
+ if (view()) {
+ bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
+ // If we didn't update compositing layers because of layout(), we need to do so here.
+ if (!layoutPending)
+ view()->updateCompositingLayersAfterStyleChange();
+ }
+ #endif
- m_inStyleRecalc = false;
-
- // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
- if (m_styleResolver)
- resetCSSFeatureFlags();
+ bailOut:
+ clearNeedsStyleRecalc();
+ clearChildNeedsStyleRecalc();
+ unscheduleStyleRecalc();
- if (frameView) {
- frameView->resumeScheduledEvents();
- frameView->endDeferredRepaints();
+ m_inStyleRecalc = false;
+
+ // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
+ if (m_styleResolver)
+ resetCSSFeatureFlags();
+
+ if (frameView) {
+ frameView->resumeScheduledEvents();
+ frameView->endDeferredRepaints();
+ }
}
- RenderWidget::resumeWidgetHierarchyUpdates();
resumePostAttachCallbacks();
// If we wanted to call implicitClose() during recalcStyle, do so now that we're finished.
Modified: trunk/Source/WebCore/dom/Element.cpp (129405 => 129406)
--- trunk/Source/WebCore/dom/Element.cpp 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-09-24 20:34:35 UTC (rev 129406)
@@ -999,7 +999,7 @@
void Element::attach()
{
suspendPostAttachCallbacks();
- RenderWidget::suspendWidgetHierarchyUpdates();
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
createRendererIfNeeded();
StyleResolverParentPusher parentPusher(this);
@@ -1028,7 +1028,6 @@
}
}
- RenderWidget::resumeWidgetHierarchyUpdates();
resumePostAttachCallbacks();
}
@@ -1042,7 +1041,7 @@
void Element::detach()
{
- RenderWidget::suspendWidgetHierarchyUpdates();
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
unregisterNamedFlowContentNode();
cancelFocusAppearanceUpdate();
if (hasRareData()) {
@@ -1055,8 +1054,6 @@
shadow->detach();
}
ContainerNode::detach();
-
- RenderWidget::resumeWidgetHierarchyUpdates();
}
bool Element::pseudoStyleCacheIsInvalid(const RenderStyle* currentStyle, RenderStyle* newStyle)
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (129405 => 129406)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2012-09-24 20:34:35 UTC (rev 129406)
@@ -225,9 +225,10 @@
ASSERT(!m_sendingEventToSubview);
m_sendingEventToSubview = true;
- RenderWidget::suspendWidgetHierarchyUpdates();
- [view mouseDown:currentNSEvent()];
- RenderWidget::resumeWidgetHierarchyUpdates();
+ {
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
+ [view mouseDown:currentNSEvent()];
+ }
m_sendingEventToSubview = false;
Modified: trunk/Source/WebCore/rendering/RenderWidget.cpp (129405 => 129406)
--- trunk/Source/WebCore/rendering/RenderWidget.cpp 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/rendering/RenderWidget.cpp 2012-09-24 20:34:35 UTC (rev 129406)
@@ -47,53 +47,42 @@
return *staticWidgetRendererMap;
}
-static unsigned widgetHierarchyUpdateSuspendCount;
+unsigned WidgetHierarchyUpdatesSuspensionScope::s_widgetHierarchyUpdateSuspendCount = 0;
-typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap;
-
-static WidgetToParentMap& widgetNewParentMap()
+WidgetHierarchyUpdatesSuspensionScope::WidgetToParentMap& WidgetHierarchyUpdatesSuspensionScope::widgetNewParentMap()
{
DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ());
return map;
}
-void RenderWidget::suspendWidgetHierarchyUpdates()
+void WidgetHierarchyUpdatesSuspensionScope::moveWidgets()
{
- widgetHierarchyUpdateSuspendCount++;
-}
-
-void RenderWidget::resumeWidgetHierarchyUpdates()
-{
- ASSERT(widgetHierarchyUpdateSuspendCount);
- if (widgetHierarchyUpdateSuspendCount == 1) {
- WidgetToParentMap map = widgetNewParentMap();
- widgetNewParentMap().clear();
- WidgetToParentMap::iterator end = map.end();
- for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
- Widget* child = it->first.get();
- ScrollView* currentParent = child->parent();
- FrameView* newParent = it->second;
- if (newParent != currentParent) {
- if (currentParent)
- currentParent->removeChild(child);
- if (newParent)
- newParent->addChild(child);
- }
+ WidgetToParentMap map = widgetNewParentMap();
+ widgetNewParentMap().clear();
+ WidgetToParentMap::iterator end = map.end();
+ for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
+ Widget* child = it->first.get();
+ ScrollView* currentParent = child->parent();
+ FrameView* newParent = it->second;
+ if (newParent != currentParent) {
+ if (currentParent)
+ currentParent->removeChild(child);
+ if (newParent)
+ newParent->addChild(child);
}
}
- widgetHierarchyUpdateSuspendCount--;
}
static void moveWidgetToParentSoon(Widget* child, FrameView* parent)
{
- if (!widgetHierarchyUpdateSuspendCount) {
+ if (!WidgetHierarchyUpdatesSuspensionScope::isSuspended()) {
if (parent)
parent->addChild(child);
else
child->removeFromParent();
return;
}
- widgetNewParentMap().set(child, parent);
+ WidgetHierarchyUpdatesSuspensionScope::scheduleWidgetToMove(child, parent);
}
RenderWidget::RenderWidget(Node* node)
Modified: trunk/Source/WebCore/rendering/RenderWidget.h (129405 => 129406)
--- trunk/Source/WebCore/rendering/RenderWidget.h 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebCore/rendering/RenderWidget.h 2012-09-24 20:34:35 UTC (rev 129406)
@@ -28,6 +28,32 @@
namespace WebCore {
+class WidgetHierarchyUpdatesSuspensionScope {
+public:
+ WidgetHierarchyUpdatesSuspensionScope()
+ {
+ s_widgetHierarchyUpdateSuspendCount++;
+ }
+ ~WidgetHierarchyUpdatesSuspensionScope()
+ {
+ ASSERT(s_widgetHierarchyUpdateSuspendCount);
+ if (s_widgetHierarchyUpdateSuspendCount == 1)
+ moveWidgets();
+ s_widgetHierarchyUpdateSuspendCount--;
+ }
+
+ static bool isSuspended() { return s_widgetHierarchyUpdateSuspendCount; }
+ static void scheduleWidgetToMove(Widget* widget, FrameView* frame) { widgetNewParentMap().set(widget, frame); }
+
+private:
+ typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap;
+ static WidgetToParentMap& widgetNewParentMap();
+
+ void moveWidgets();
+
+ static unsigned s_widgetHierarchyUpdateSuspendCount;
+};
+
class RenderWidget : public RenderReplaced, private OverlapTestRequestClient {
public:
virtual ~RenderWidget();
@@ -42,9 +68,6 @@
IntRect windowClipRect() const;
void notifyWidget(WidgetNotification);
-
- static void suspendWidgetHierarchyUpdates();
- static void resumeWidgetHierarchyUpdates();
RenderArena* ref() { ++m_refCount; return renderArena(); }
void deref(RenderArena*);
Modified: trunk/Source/WebKit/mac/ChangeLog (129405 => 129406)
--- trunk/Source/WebKit/mac/ChangeLog 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebKit/mac/ChangeLog 2012-09-24 20:34:35 UTC (rev 129406)
@@ -1,3 +1,13 @@
+2012-09-24 Ryosuke Niwa <[email protected]>
+
+ suspend/resumeWidgetHierarchyUpdates should be a RAII object
+ https://bugs.webkit.org/show_bug.cgi?id=96706
+
+ Reviewed by Simon Fraser.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _invalidateGStatesForTree]):
+
2012-09-21 Chris Rogers <[email protected]>
Add Web Audio support for deprecated/legacy APIs
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (129405 => 129406)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2012-09-24 20:23:25 UTC (rev 129405)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2012-09-24 20:34:35 UTC (rev 129406)
@@ -3376,9 +3376,8 @@
// descendants, including plug-in views. This can result in calls out to plug-in code and back into
// WebCore via _javascript_, which could normally mutate the NSView tree while it is being traversed.
// Defer those mutations while descendants are being traveresed.
- RenderWidget::suspendWidgetHierarchyUpdates();
+ WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
[super _invalidateGStatesForTree];
- RenderWidget::resumeWidgetHierarchyUpdates();
}
- (BOOL)isFlipped