Title: [275859] trunk/Source/WebCore
- Revision
- 275859
- Author
- [email protected]
- Date
- 2021-04-12 21:19:17 -0700 (Mon, 12 Apr 2021)
Log Message
TextManipulationController should use weak pointers to Node
https://bugs.webkit.org/show_bug.cgi?id=215913
Reviewed by Wenson Hsieh.
Use WeakHashSet for m_manipulatedTextsWithNewContent, m_textNodesWithNewRenderer, and m_manipulatedNodes.
Also made TextManipulationController::removeNode take Node& instead of Node*.
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
* editing/TextManipulationController.cpp:
(WebCore::TextManipulationController::observeParagraphs):
(WebCore::TextManipulationController::didCreateRendererForElement):
(WebCore::TextManipulationController::didUpdateContentForText):
(WebCore::TextManipulationController::didCreateRendererForTextNode):
(WebCore::TextManipulationController::scheduleObservationUpdate):
(WebCore::TextManipulationController::replace):
(WebCore::TextManipulationController::removeNode):
* editing/TextManipulationController.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275858 => 275859)
--- trunk/Source/WebCore/ChangeLog 2021-04-13 02:25:18 UTC (rev 275858)
+++ trunk/Source/WebCore/ChangeLog 2021-04-13 04:19:17 UTC (rev 275859)
@@ -1,3 +1,27 @@
+2021-04-12 Ryosuke Niwa <[email protected]>
+
+ TextManipulationController should use weak pointers to Node
+ https://bugs.webkit.org/show_bug.cgi?id=215913
+
+ Reviewed by Wenson Hsieh.
+
+ Use WeakHashSet for m_manipulatedTextsWithNewContent, m_textNodesWithNewRenderer, and m_manipulatedNodes.
+
+ Also made TextManipulationController::removeNode take Node& instead of Node*.
+
+ * dom/Node.cpp:
+ (WebCore::Node::~Node):
+ (WebCore::Node::moveNodeToNewDocument):
+ * editing/TextManipulationController.cpp:
+ (WebCore::TextManipulationController::observeParagraphs):
+ (WebCore::TextManipulationController::didCreateRendererForElement):
+ (WebCore::TextManipulationController::didUpdateContentForText):
+ (WebCore::TextManipulationController::didCreateRendererForTextNode):
+ (WebCore::TextManipulationController::scheduleObservationUpdate):
+ (WebCore::TextManipulationController::replace):
+ (WebCore::TextManipulationController::removeNode):
+ * editing/TextManipulationController.h:
+
2021-04-12 Don Olmstead <[email protected]>
Remove GraphicsContextGLOpenGLPrivate
Modified: trunk/Source/WebCore/dom/Node.cpp (275858 => 275859)
--- trunk/Source/WebCore/dom/Node.cpp 2021-04-13 02:25:18 UTC (rev 275858)
+++ trunk/Source/WebCore/dom/Node.cpp 2021-04-13 04:19:17 UTC (rev 275859)
@@ -371,7 +371,7 @@
auto* textManipulationController = document().textManipulationControllerIfExists();
if (UNLIKELY(textManipulationController))
- textManipulationController->removeNode(this);
+ textManipulationController->removeNode(*this);
if (!isContainerNode())
willBeDeletedFrom(document());
@@ -2066,7 +2066,7 @@
auto* textManipulationController = oldDocument.textManipulationControllerIfExists();
if (UNLIKELY(textManipulationController))
- textManipulationController->removeNode(this);
+ textManipulationController->removeNode(*this);
if (auto* eventTargetData = this->eventTargetData()) {
if (!eventTargetData->eventListenerMap.isEmpty()) {
Modified: trunk/Source/WebCore/editing/TextManipulationController.cpp (275858 => 275859)
--- trunk/Source/WebCore/editing/TextManipulationController.cpp 2021-04-13 02:25:18 UTC (rev 275858)
+++ trunk/Source/WebCore/editing/TextManipulationController.cpp 2021-04-13 04:19:17 UTC (rev 275859)
@@ -475,7 +475,7 @@
enclosingItemBoundaryElements.removeLast();
}
- if (m_manipulatedNodes.contains(contentNode)) {
+ if (m_manipulatedNodes.contains(*contentNode)) {
addItemIfPossible(std::exchange(unitsInCurrentParagraph, { }));
continue;
}
@@ -532,7 +532,7 @@
void TextManipulationController::didCreateRendererForElement(Element& element)
{
- if (m_manipulatedNodes.contains(&element))
+ if (m_manipulatedNodes.contains(element))
return;
scheduleObservationUpdate();
@@ -546,22 +546,22 @@
void TextManipulationController::didUpdateContentForText(Text& text)
{
- if (!m_manipulatedNodes.contains(&text))
+ if (!m_manipulatedNodes.contains(text))
return;
scheduleObservationUpdate();
- m_manipulatedTextsWithNewContent.add(&text);
+ m_manipulatedTextsWithNewContent.add(text);
}
void TextManipulationController::didCreateRendererForTextNode(Text& text)
{
- if (m_manipulatedNodes.contains(&text))
+ if (m_manipulatedNodes.contains(text))
return;
scheduleObservationUpdate();
- m_textNodesWithNewRenderer.add(&text);
+ m_textNodesWithNewRenderer.add(text);
}
void TextManipulationController::scheduleObservationUpdate()
@@ -586,16 +586,16 @@
nodesToObserve.add(weakElement);
controller->m_elementsWithNewRenderer.clear();
- for (auto* text : controller->m_manipulatedTextsWithNewContent) {
+ for (auto& text : controller->m_manipulatedTextsWithNewContent) {
if (!controller->m_manipulatedNodes.contains(text))
continue;
controller->m_manipulatedNodes.remove(text);
- nodesToObserve.add(*text);
+ nodesToObserve.add(text);
}
controller->m_manipulatedTextsWithNewContent.clear();
- for (auto* text : controller->m_textNodesWithNewRenderer)
- nodesToObserve.add(*text);
+ for (auto& text : controller->m_textNodesWithNewRenderer)
+ nodesToObserve.add(text);
controller->m_textNodesWithNewRenderer.clear();
if (nodesToObserve.isEmpty())
@@ -925,13 +925,13 @@
}
if (insertion.isChildManipulated == IsNodeManipulated::Yes)
- m_manipulatedNodes.add(insertion.child.ptr());
+ m_manipulatedNodes.add(insertion.child.get());
}
return WTF::nullopt;
}
-void TextManipulationController::removeNode(Node* node)
+void TextManipulationController::removeNode(Node& node)
{
m_manipulatedNodes.remove(node);
m_textNodesWithNewRenderer.remove(node);
Modified: trunk/Source/WebCore/editing/TextManipulationController.h (275858 => 275859)
--- trunk/Source/WebCore/editing/TextManipulationController.h 2021-04-13 02:25:18 UTC (rev 275858)
+++ trunk/Source/WebCore/editing/TextManipulationController.h 2021-04-13 04:19:17 UTC (rev 275859)
@@ -119,7 +119,7 @@
void didCreateRendererForElement(Element&);
void didCreateRendererForTextNode(Text&);
void didUpdateContentForText(Text&);
- void removeNode(Node*);
+ void removeNode(Node&);
enum class ManipulationFailureType : uint8_t {
ContentChanged,
@@ -182,9 +182,9 @@
WeakPtr<Document> m_document;
WeakHashSet<Element> m_elementsWithNewRenderer;
- HashSet<Text*> m_manipulatedTextsWithNewContent;
- HashSet<Node*> m_textNodesWithNewRenderer;
- HashSet<Node*> m_manipulatedNodes;
+ WeakHashSet<Text> m_manipulatedTextsWithNewContent;
+ WeakHashSet<Node> m_textNodesWithNewRenderer;
+ WeakHashSet<Node> m_manipulatedNodes;
HashMap<String, bool> m_cachedFontFamilyExclusionResults;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes