Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1271)

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp

Issue 2755953004: Refactor DocumentMarkerController to use SynchronousMutationObserver (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
index 4b40f5a94cb0ea35b79d74107899df6fb22a2488..c0bc483065b3bbf6133f2e39d4a810aa13fa171c 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -82,8 +82,10 @@ inline bool DocumentMarkerController::possiblyHasMarkers(
return m_possiblyExistingMarkerTypes.intersects(types);
}
-DocumentMarkerController::DocumentMarkerController(const Document& document)
- : m_possiblyExistingMarkerTypes(0), m_document(&document) {}
+DocumentMarkerController::DocumentMarkerController(Document& document)
+ : m_possiblyExistingMarkerTypes(0), m_document(&document) {
+ setContext(&document);
+}
void DocumentMarkerController::clear() {
m_markers.clear();
@@ -591,6 +593,7 @@ void DocumentMarkerController::invalidateRectsForAllMarkers() {
DEFINE_TRACE(DocumentMarkerController) {
visitor->trace(m_markers);
visitor->trace(m_document);
+ SynchronousMutationObserver::trace(visitor);
}
void DocumentMarkerController::removeMarkers(
@@ -868,6 +871,17 @@ void DocumentMarkerController::showMarkers() const {
}
#endif
+// SynchronousMutationObserver
+void DocumentMarkerController::didUpdateCharacterData(CharacterData* node,
+ unsigned offset,
+ unsigned oldLength,
+ unsigned newLength) {
+ // Shift markers as if we first remove the old text, then insert the new text
+ removeMarkers(node, offset, oldLength);
+ shiftMarkers(node, offset + oldLength, 0 - oldLength);
+ shiftMarkers(node, offset, newLength);
+}
+
} // namespace blink
#ifndef NDEBUG
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698