Modified: trunk/Source/WebCore/ChangeLog (208825 => 208826)
--- trunk/Source/WebCore/ChangeLog 2016-11-17 00:35:32 UTC (rev 208825)
+++ trunk/Source/WebCore/ChangeLog 2016-11-17 00:35:57 UTC (rev 208826)
@@ -1,3 +1,27 @@
+2016-11-16 Chris Dumez <[email protected]>
+
+ Use more references for Document::removeFocusedNodeOfSubtree()
+ https://bugs.webkit.org/show_bug.cgi?id=164839
+
+ Reviewed by Andreas Kling.
+
+ Use more references for Document::removeFocusedNodeOfSubtree().
+
+ No new tests, no Web-exposed behavior change.
+
+ * dom/Document.cpp:
+ (WebCore::isNodeInSubtree):
+ (WebCore::Document::removeFocusedNodeOfSubtree):
+ (WebCore::Document::nodeChildrenWillBeRemoved):
+ (WebCore::Document::nodeWillBeRemoved):
+ (WebCore::Document::removeFocusNavigationNodeOfSubtree):
+ (WebCore::Document::removeFullScreenElementOfSubtree):
+ * dom/Document.h:
+ * dom/Element.cpp:
+ (WebCore::Element::removeShadowRoot):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::clear):
+
2016-11-16 Brent Fulgham <[email protected]>
Clear track client when removing a track
Modified: trunk/Source/WebCore/dom/Document.cpp (208825 => 208826)
--- trunk/Source/WebCore/dom/Document.cpp 2016-11-17 00:35:32 UTC (rev 208825)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-11-17 00:35:57 UTC (rev 208826)
@@ -3531,27 +3531,24 @@
audioProducer->pageMutedStateDidChange();
}
-static bool isNodeInSubtree(Node* node, Node* container, bool amongChildrenOnly)
+static bool isNodeInSubtree(Node& node, Node& container, bool amongChildrenOnly)
{
- bool nodeInSubtree = false;
if (amongChildrenOnly)
- nodeInSubtree = node->isDescendantOf(container);
+ return node.isDescendantOf(&container);
else
- nodeInSubtree = (node == container) || node->isDescendantOf(container);
-
- return nodeInSubtree;
+ return &node == &container || node.isDescendantOf(&container);
}
-void Document::removeFocusedNodeOfSubtree(Node* node, bool amongChildrenOnly)
+void Document::removeFocusedNodeOfSubtree(Node& node, bool amongChildrenOnly)
{
if (!m_focusedElement || pageCacheState() != NotInPageCache) // If the document is in the page cache, then we don't need to clear out the focused node.
return;
- Element* focusedElement = node->treeScope().focusedElement();
+ Element* focusedElement = node.treeScope().focusedElement();
if (!focusedElement)
return;
- if (isNodeInSubtree(focusedElement, node, amongChildrenOnly)) {
+ if (isNodeInSubtree(*focusedElement, node, amongChildrenOnly)) {
setFocusedElement(nullptr, FocusDirectionNone, FocusRemovalEventsMode::DoNotDispatch);
// Set the focus navigation starting node to the previous focused element so that
// we can fallback to the siblings or parent node for the next search.
@@ -3890,11 +3887,11 @@
{
NoEventDispatchAssertion assertNoEventDispatch;
- removeFocusedNodeOfSubtree(&container, true /* amongChildrenOnly */);
+ removeFocusedNodeOfSubtree(container, true /* amongChildrenOnly */);
removeFocusNavigationNodeOfSubtree(container, true /* amongChildrenOnly */);
#if ENABLE(FULLSCREEN_API)
- removeFullScreenElementOfSubtree(&container, true /* amongChildrenOnly */);
+ removeFullScreenElementOfSubtree(container, true /* amongChildrenOnly */);
#endif
for (auto* range : m_ranges)
@@ -3919,31 +3916,31 @@
}
}
-void Document::nodeWillBeRemoved(Node& n)
+void Document::nodeWillBeRemoved(Node& node)
{
NoEventDispatchAssertion assertNoEventDispatch;
- removeFocusedNodeOfSubtree(&n);
- removeFocusNavigationNodeOfSubtree(n);
+ removeFocusedNodeOfSubtree(node);
+ removeFocusNavigationNodeOfSubtree(node);
#if ENABLE(FULLSCREEN_API)
- removeFullScreenElementOfSubtree(&n);
+ removeFullScreenElementOfSubtree(node);
#endif
for (auto* it : m_nodeIterators)
- it->nodeWillBeRemoved(n);
+ it->nodeWillBeRemoved(node);
for (auto* range : m_ranges)
- range->nodeWillBeRemoved(n);
+ range->nodeWillBeRemoved(node);
if (Frame* frame = this->frame()) {
- frame->eventHandler().nodeWillBeRemoved(n);
- frame->selection().nodeWillBeRemoved(n);
- frame->page()->dragCaretController().nodeWillBeRemoved(n);
+ frame->eventHandler().nodeWillBeRemoved(node);
+ frame->selection().nodeWillBeRemoved(node);
+ frame->page()->dragCaretController().nodeWillBeRemoved(node);
}
- if (is<Text>(n))
- m_markers->removeMarkers(&n);
+ if (is<Text>(node))
+ m_markers->removeMarkers(&node);
}
static Node* fallbackFocusNavigationStartingNodeAfterRemoval(Node& node)
@@ -3956,7 +3953,7 @@
if (!m_focusNavigationStartingNode)
return;
- if (isNodeInSubtree(m_focusNavigationStartingNode.get(), &node, amongChildrenOnly)) {
+ if (isNodeInSubtree(*m_focusNavigationStartingNode, node, amongChildrenOnly)) {
m_focusNavigationStartingNode = amongChildrenOnly ? &node : fallbackFocusNavigationStartingNodeAfterRemoval(node);
m_focusNavigationStartingNodeIsRemoved = true;
}
@@ -5959,7 +5956,7 @@
webkitCancelFullScreen();
}
-void Document::removeFullScreenElementOfSubtree(Node* node, bool amongChildrenOnly)
+void Document::removeFullScreenElementOfSubtree(Node& node, bool amongChildrenOnly)
{
if (!m_fullScreenElement)
return;
@@ -5966,9 +5963,9 @@
bool elementInSubtree = false;
if (amongChildrenOnly)
- elementInSubtree = m_fullScreenElement->isDescendantOf(node);
+ elementInSubtree = m_fullScreenElement->isDescendantOf(&node);
else
- elementInSubtree = (m_fullScreenElement == node) || m_fullScreenElement->isDescendantOf(node);
+ elementInSubtree = (m_fullScreenElement == &node) || m_fullScreenElement->isDescendantOf(&node);
if (elementInSubtree)
fullScreenElementRemoved();
Modified: trunk/Source/WebCore/dom/Document.h (208825 => 208826)
--- trunk/Source/WebCore/dom/Document.h 2016-11-17 00:35:32 UTC (rev 208825)
+++ trunk/Source/WebCore/dom/Document.h 2016-11-17 00:35:57 UTC (rev 208826)
@@ -707,7 +707,7 @@
void setFocusNavigationStartingNode(Node*);
Element* focusNavigationStartingNode(FocusDirection) const;
- void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
+ void removeFocusedNodeOfSubtree(Node&, bool amongChildrenOnly = false);
void hoveredElementDidDetach(Element*);
void elementInActiveChainDidDetach(Element*);
@@ -1109,7 +1109,7 @@
void fullScreenChangeDelayTimerFired();
bool fullScreenIsAllowedForElement(Element*) const;
void fullScreenElementRemoved();
- void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
+ void removeFullScreenElementOfSubtree(Node&, bool amongChildrenOnly = false);
bool isAnimatingFullScreen() const;
WEBCORE_EXPORT void setAnimatingFullScreen(bool);
Modified: trunk/Source/WebCore/dom/Element.cpp (208825 => 208826)
--- trunk/Source/WebCore/dom/Element.cpp 2016-11-17 00:35:32 UTC (rev 208825)
+++ trunk/Source/WebCore/dom/Element.cpp 2016-11-17 00:35:57 UTC (rev 208826)
@@ -1768,7 +1768,7 @@
return;
InspectorInstrumentation::willPopShadowRoot(*this, *oldRoot);
- document().removeFocusedNodeOfSubtree(oldRoot.get());
+ document().removeFocusedNodeOfSubtree(*oldRoot);
ASSERT(!oldRoot->renderer());
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (208825 => 208826)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2016-11-17 00:35:32 UTC (rev 208825)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2016-11-17 00:35:57 UTC (rev 208826)
@@ -586,7 +586,7 @@
bool hadLivingRenderTree = m_frame.document()->hasLivingRenderTree();
m_frame.document()->prepareForDestruction();
if (hadLivingRenderTree)
- m_frame.document()->removeFocusedNodeOfSubtree(m_frame.document());
+ m_frame.document()->removeFocusedNodeOfSubtree(*m_frame.document());
}
// Do this after detaching the document so that the unload event works.