Title: [153734] trunk/Source/WebCore
Revision
153734
Author
rn...@webkit.org
Date
2013-08-05 19:02:03 -0700 (Mon, 05 Aug 2013)

Log Message

Editor::updateMarkersForWordsAffectedByEditing(bool) shouldn't compute start and end of words when there are nor markers
https://bugs.webkit.org/show_bug.cgi?id=119501

Reviewed by Enrica Casucci.

Exit early in updateMarkersForWordsAffectedByEditing before calling startOfWord and endOfWord if there are no document markers.

* dom/DocumentMarkerController.h:
(WebCore::DocumentMarkerController::hasMarkers): Added.
* editing/Editor.cpp:
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153733 => 153734)


--- trunk/Source/WebCore/ChangeLog	2013-08-06 01:13:15 UTC (rev 153733)
+++ trunk/Source/WebCore/ChangeLog	2013-08-06 02:02:03 UTC (rev 153734)
@@ -1,3 +1,17 @@
+2013-08-05  Ryosuke Niwa  <rn...@webkit.org>
+
+        Editor::updateMarkersForWordsAffectedByEditing(bool) shouldn't compute start and end of words when there are nor markers
+        https://bugs.webkit.org/show_bug.cgi?id=119501
+
+        Reviewed by Enrica Casucci.
+
+        Exit early in updateMarkersForWordsAffectedByEditing before calling startOfWord and endOfWord if there are no document markers.
+
+        * dom/DocumentMarkerController.h:
+        (WebCore::DocumentMarkerController::hasMarkers): Added.
+        * editing/Editor.cpp:
+        (WebCore::Editor::updateMarkersForWordsAffectedByEditing):
+
 2013-08-05  Dean Jackson  <d...@apple.com>
 
         Update HTMLPreloadScanner to handle img srcset

Modified: trunk/Source/WebCore/dom/DocumentMarkerController.h (153733 => 153734)


--- trunk/Source/WebCore/dom/DocumentMarkerController.h	2013-08-06 01:13:15 UTC (rev 153733)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.h	2013-08-06 02:02:03 UTC (rev 153734)
@@ -55,6 +55,11 @@
     void addTextMatchMarker(const Range*, bool activeMatch);
 
     void copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta);
+    bool hasMarkers() const
+    {
+        ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.intersects(DocumentMarker::AllMarkers()));
+        return !m_markers.isEmpty();
+    }
     bool hasMarkers(Range*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
 
     // When a marker partially overlaps with range, if removePartiallyOverlappingMarkers is true, we completely

Modified: trunk/Source/WebCore/editing/Editor.cpp (153733 => 153734)


--- trunk/Source/WebCore/editing/Editor.cpp	2013-08-06 01:13:15 UTC (rev 153733)
+++ trunk/Source/WebCore/editing/Editor.cpp	2013-08-06 02:02:03 UTC (rev 153734)
@@ -2376,6 +2376,10 @@
 
 void Editor::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSelectionAtWordBoundary)
 {
+    Document* document = m_frame->document();
+    if (!document || !document->markers()->hasMarkers())
+        return;
+
     if (!m_alternativeTextController->shouldRemoveMarkersUponEditing() && (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingTypeSpelling)))
         return;
 
@@ -2437,7 +2441,6 @@
     // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde,
     // we would like to remove the marker from word "avant" and whitespace as well. So we need to get the continous range of
     // of marker that contains the word in question, and remove marker on that whole range.
-    Document* document = m_frame->document();
     RefPtr<Range> wordRange = Range::create(document, startOfFirstWord.deepEquivalent(), endOfLastWord.deepEquivalent());
 
     Vector<DocumentMarker*> markers = document->markers()->markersInRange(wordRange.get(), DocumentMarker::DictationAlternatives);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to