Title: [229079] trunk
Revision
229079
Author
[email protected]
Date
2018-02-27 14:35:47 -0800 (Tue, 27 Feb 2018)

Log Message

Standardize terminology for marked text
https://bugs.webkit.org/show_bug.cgi?id=180999

Reviewed by Zalan Bujtas.

The name MarkerSubrange is a misnomer for a data structure that associates a text subrange with a type
and optional document marker. In particular, a MarkerSubrange may not always correspond to a document
marker. For instance, selected text is represented using a MarkerSubrange that does not have a
corresponding document marker. Let's standardize on the phrase "marked text" as the canonical way to
describe these tagged text subranges.

Source/WebCore:

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::localSelectionRect const):
(WebCore::InlineTextBox::MarkedTextStyle::areBackgroundMarkedTextStylesEqual):
(WebCore::InlineTextBox::MarkedTextStyle::areForegroundMarkedTextStylesEqual):
(WebCore::InlineTextBox::MarkedTextStyle::areDecorationMarkedTextStylesEqual):
(WebCore::InlineTextBox::StyledMarkedText::StyledMarkedText):
(WebCore::createMarkedTextFromSelectionInBox):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::paintPlatformDocumentMarkers):
(WebCore::InlineTextBox::paintPlatformDocumentMarker):
(WebCore::InlineTextBox::computeStyleForUnmarkedMarkedText const):
(WebCore::InlineTextBox::resolveStyleForMarkedText):
(WebCore::InlineTextBox::subdivideAndResolveStyle):
(WebCore::InlineTextBox::coalesceAdjacentMarkedTexts):
(WebCore::InlineTextBox::collectMarkedTextsForDraggedContent):
(WebCore::InlineTextBox::collectMarkedTextsForDocumentMarkers):
(WebCore::InlineTextBox::paintMarkedTexts):
(WebCore::InlineTextBox::paintMarkedTextBackground):
(WebCore::InlineTextBox::paintMarkedTextForeground):
(WebCore::InlineTextBox::paintMarkedTextDecoration):
(WebCore::InlineTextBox::paintCompositionBackground):
(WebCore::InlineTextBox::MarkerSubrangeStyle::areBackgroundMarkerSubrangeStylesEqual): Deleted.
(WebCore::InlineTextBox::MarkerSubrangeStyle::areForegroundMarkerSubrangeStylesEqual): Deleted.
(WebCore::InlineTextBox::MarkerSubrangeStyle::areDecorationMarkerSubrangeStylesEqual): Deleted.
(WebCore::InlineTextBox::StyledMarkerSubrange::StyledMarkerSubrange): Deleted.
(WebCore::createMarkerSubrangeFromSelectionInBox): Deleted.
(WebCore::InlineTextBox::computeStyleForUnmarkedMarkerSubrange const): Deleted.
(WebCore::InlineTextBox::resolveStyleForSubrange): Deleted.
(WebCore::InlineTextBox::coalesceAdjacentSubranges): Deleted.
(WebCore::InlineTextBox::collectSubrangesForDraggedContent): Deleted.
(WebCore::InlineTextBox::collectSubrangesForDocumentMarkers): Deleted.
(WebCore::InlineTextBox::paintMarkerSubranges): Deleted.
(WebCore::InlineTextBox::paintTextSubrangeBackground): Deleted.
(WebCore::InlineTextBox::paintTextSubrangeForeground): Deleted.
(WebCore::InlineTextBox::paintTextSubrangeDecoration): Deleted.
* rendering/InlineTextBox.h:
(WebCore::InlineTextBox::paintMarkedTexts):
(WebCore::InlineTextBox::paintMarkerSubranges): Deleted.
* rendering/MarkedText.cpp: Renamed from Source/WebCore/rendering/MarkerSubrange.cpp.
(WebCore::subdivide):
* rendering/MarkedText.h: Renamed from Source/WebCore/rendering/MarkerSubrange.h.
(WebCore::MarkedText::MarkedText):
(WebCore::MarkedText::isEmpty const):
(WebCore::MarkedText::operator!= const):
(WebCore::MarkedText::operator== const):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/MarkedText.cpp: Added.
(WebCore::operator<<):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/MarkerSubrange.cpp: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229078 => 229079)


--- trunk/Source/WebCore/ChangeLog	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/ChangeLog	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1,3 +1,64 @@
+2018-02-27  Daniel Bates  <[email protected]>
+
+        Standardize terminology for marked text
+        https://bugs.webkit.org/show_bug.cgi?id=180999
+
+        Reviewed by Zalan Bujtas.
+
+        The name MarkerSubrange is a misnomer for a data structure that associates a text subrange with a type
+        and optional document marker. In particular, a MarkerSubrange may not always correspond to a document
+        marker. For instance, selected text is represented using a MarkerSubrange that does not have a
+        corresponding document marker. Let's standardize on the phrase "marked text" as the canonical way to
+        describe these tagged text subranges.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::localSelectionRect const):
+        (WebCore::InlineTextBox::MarkedTextStyle::areBackgroundMarkedTextStylesEqual):
+        (WebCore::InlineTextBox::MarkedTextStyle::areForegroundMarkedTextStylesEqual):
+        (WebCore::InlineTextBox::MarkedTextStyle::areDecorationMarkedTextStylesEqual):
+        (WebCore::InlineTextBox::StyledMarkedText::StyledMarkedText):
+        (WebCore::createMarkedTextFromSelectionInBox):
+        (WebCore::InlineTextBox::paint):
+        (WebCore::InlineTextBox::paintPlatformDocumentMarkers):
+        (WebCore::InlineTextBox::paintPlatformDocumentMarker):
+        (WebCore::InlineTextBox::computeStyleForUnmarkedMarkedText const):
+        (WebCore::InlineTextBox::resolveStyleForMarkedText):
+        (WebCore::InlineTextBox::subdivideAndResolveStyle):
+        (WebCore::InlineTextBox::coalesceAdjacentMarkedTexts):
+        (WebCore::InlineTextBox::collectMarkedTextsForDraggedContent):
+        (WebCore::InlineTextBox::collectMarkedTextsForDocumentMarkers):
+        (WebCore::InlineTextBox::paintMarkedTexts):
+        (WebCore::InlineTextBox::paintMarkedTextBackground):
+        (WebCore::InlineTextBox::paintMarkedTextForeground):
+        (WebCore::InlineTextBox::paintMarkedTextDecoration):
+        (WebCore::InlineTextBox::paintCompositionBackground):
+        (WebCore::InlineTextBox::MarkerSubrangeStyle::areBackgroundMarkerSubrangeStylesEqual): Deleted.
+        (WebCore::InlineTextBox::MarkerSubrangeStyle::areForegroundMarkerSubrangeStylesEqual): Deleted.
+        (WebCore::InlineTextBox::MarkerSubrangeStyle::areDecorationMarkerSubrangeStylesEqual): Deleted.
+        (WebCore::InlineTextBox::StyledMarkerSubrange::StyledMarkerSubrange): Deleted.
+        (WebCore::createMarkerSubrangeFromSelectionInBox): Deleted.
+        (WebCore::InlineTextBox::computeStyleForUnmarkedMarkerSubrange const): Deleted.
+        (WebCore::InlineTextBox::resolveStyleForSubrange): Deleted.
+        (WebCore::InlineTextBox::coalesceAdjacentSubranges): Deleted.
+        (WebCore::InlineTextBox::collectSubrangesForDraggedContent): Deleted.
+        (WebCore::InlineTextBox::collectSubrangesForDocumentMarkers): Deleted.
+        (WebCore::InlineTextBox::paintMarkerSubranges): Deleted.
+        (WebCore::InlineTextBox::paintTextSubrangeBackground): Deleted.
+        (WebCore::InlineTextBox::paintTextSubrangeForeground): Deleted.
+        (WebCore::InlineTextBox::paintTextSubrangeDecoration): Deleted.
+        * rendering/InlineTextBox.h:
+        (WebCore::InlineTextBox::paintMarkedTexts):
+        (WebCore::InlineTextBox::paintMarkerSubranges): Deleted.
+        * rendering/MarkedText.cpp: Renamed from Source/WebCore/rendering/MarkerSubrange.cpp.
+        (WebCore::subdivide):
+        * rendering/MarkedText.h: Renamed from Source/WebCore/rendering/MarkerSubrange.h.
+        (WebCore::MarkedText::MarkedText):
+        (WebCore::MarkedText::isEmpty const):
+        (WebCore::MarkedText::operator!= const):
+        (WebCore::MarkedText::operator== const):
+
 2018-02-27  Chris Dumez  <[email protected]>
 
         Unreviewed, roll out r228430.

Modified: trunk/Source/WebCore/Sources.txt (229078 => 229079)


--- trunk/Source/WebCore/Sources.txt	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/Sources.txt	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1792,7 +1792,7 @@
 rendering/LayoutDisallowedScope.cpp
 rendering/LayoutRepainter.cpp
 rendering/LayoutState.cpp
-rendering/MarkerSubrange.cpp
+rendering/MarkedText.cpp
 rendering/OrderIterator.cpp
 rendering/PointerEventsHitRules.cpp
 rendering/RenderAttachment.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (229078 => 229079)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-02-27 22:35:47 UTC (rev 229079)
@@ -4040,7 +4040,7 @@
 		CDFC360618CA61C20026E56F /* RemoteCommandListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFC360418CA61C20026E56F /* RemoteCommandListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE057FA41220731100A476D5 /* DocumentMarkerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
-		CE1866451F72E5B400A0CAB6 /* MarkerSubrange.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1866431F72E5B400A0CAB6 /* MarkerSubrange.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		CE1866451F72E5B400A0CAB6 /* MarkedText.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1866431F72E5B400A0CAB6 /* MarkedText.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE2849871CA360DF00B4A57F /* ContentSecurityPolicyDirectiveNames.h in Headers */ = {isa = PBXBuildFile; fileRef = CE2849861CA360DF00B4A57F /* ContentSecurityPolicyDirectiveNames.h */; };
 		CE6DADFA1C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = CE6DADF81C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE799F981C6A46BC0097B518 /* ContentSecurityPolicySourceList.h in Headers */ = {isa = PBXBuildFile; fileRef = CE799F961C6A46BC0097B518 /* ContentSecurityPolicySourceList.h */; };
@@ -13294,8 +13294,8 @@
 		CE057FA41220731100A476D5 /* DocumentMarkerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarkerController.h; sourceTree = "<group>"; };
 		CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlternativeTextController.cpp; sourceTree = "<group>"; };
 		CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextController.h; sourceTree = "<group>"; };
-		CE1866421F72E5B400A0CAB6 /* MarkerSubrange.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MarkerSubrange.cpp; sourceTree = "<group>"; };
-		CE1866431F72E5B400A0CAB6 /* MarkerSubrange.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarkerSubrange.h; sourceTree = "<group>"; };
+		CE1866421F72E5B400A0CAB6 /* MarkedText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedText.cpp; sourceTree = "<group>"; };
+		CE1866431F72E5B400A0CAB6 /* MarkedText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarkedText.h; sourceTree = "<group>"; };
 		CE2849861CA360DF00B4A57F /* ContentSecurityPolicyDirectiveNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ContentSecurityPolicyDirectiveNames.h; path = csp/ContentSecurityPolicyDirectiveNames.h; sourceTree = "<group>"; };
 		CE2849881CA3614600B4A57F /* ContentSecurityPolicyDirectiveNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ContentSecurityPolicyDirectiveNames.cpp; path = csp/ContentSecurityPolicyDirectiveNames.cpp; sourceTree = "<group>"; };
 		CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
@@ -25452,8 +25452,8 @@
 				2D9066040BE141D400956998 /* LayoutState.cpp */,
 				2D9066050BE141D400956998 /* LayoutState.h */,
 				9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */,
-				CE1866421F72E5B400A0CAB6 /* MarkerSubrange.cpp */,
-				CE1866431F72E5B400A0CAB6 /* MarkerSubrange.h */,
+				CE1866421F72E5B400A0CAB6 /* MarkedText.cpp */,
+				CE1866431F72E5B400A0CAB6 /* MarkedText.h */,
 				CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */,
 				CDE7FC43181904B1002BBB77 /* OrderIterator.h */,
 				3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */,
@@ -28879,7 +28879,7 @@
 				932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */,
 				7AE6C93C1BE0C60100E19E03 /* MainThreadSharedTimer.h in Headers */,
 				1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */,
-				CE1866451F72E5B400A0CAB6 /* MarkerSubrange.h in Headers */,
+				CE1866451F72E5B400A0CAB6 /* MarkedText.h in Headers */,
 				93309DF8099E64920056E581 /* markup.h in Headers */,
 				9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */,
 				00C60E3F13D76D7E0092A275 /* MarkupTokenizerInlines.h in Headers */,

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (229078 => 229079)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2018-02-27 22:35:47 UTC (rev 229079)
@@ -34,7 +34,7 @@
 #include "HitTestResult.h"
 #include "ImageBuffer.h"
 #include "InlineTextBoxStyle.h"
-#include "MarkerSubrange.h"
+#include "MarkedText.h"
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderBlock.h"
@@ -188,7 +188,7 @@
     return combinedText() ? combinedText()->textCombineFont() : lineStyle().fontCascade();
 }
 
-// FIXME: Share more code with paintTextSubrangeBackground().
+// FIXME: Share more code with paintMarkedTextBackground().
 LayoutRect InlineTextBox::localSelectionRect(unsigned startPos, unsigned endPos) const
 {
     unsigned sPos = clampedOffset(startPos);
@@ -208,7 +208,7 @@
     if (sPos || ePos != textRun.length())
         lineFont().adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
     // FIXME: The computation of the snapped selection rect differs from the computation of this rect
-    // in paintTextSubrangeBackground(). See <https://bugs.webkit.org/show_bug.cgi?id=138913>.
+    // in paintMarkedTextBackground(). See <https://bugs.webkit.org/show_bug.cgi?id=138913>.
     IntRect snappedSelectionRect = enclosingIntRect(selectionRect);
     LayoutUnit logicalWidth = snappedSelectionRect.width();
     if (snappedSelectionRect.x() > logicalRight())
@@ -392,18 +392,18 @@
     return !rubyText || !rubyText->hasLines();
 }
 
-struct InlineTextBox::MarkerSubrangeStyle {
-    bool operator==(const MarkerSubrangeStyle& other) const = delete;
-    bool operator!=(const MarkerSubrangeStyle& other) const = delete;
-    static bool areBackgroundMarkerSubrangeStylesEqual(const MarkerSubrangeStyle& a, const MarkerSubrangeStyle& b)
+struct InlineTextBox::MarkedTextStyle {
+    bool operator==(const MarkedTextStyle& other) const = delete;
+    bool operator!=(const MarkedTextStyle& other) const = delete;
+    static bool areBackgroundMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)
     {
         return a.backgroundColor == b.backgroundColor;
     }
-    static bool areForegroundMarkerSubrangeStylesEqual(const MarkerSubrangeStyle& a, const MarkerSubrangeStyle& b)
+    static bool areForegroundMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)
     {
         return a.textStyles == b.textStyles && a.textShadow == b.textShadow && a.alpha == b.alpha;
     }
-    static bool areDecorationMarkerSubrangeStylesEqual(const MarkerSubrangeStyle& a, const MarkerSubrangeStyle& b)
+    static bool areDecorationMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)
     {
         return a.textDecorationStyles == b.textDecorationStyles && a.textShadow == b.textShadow;
     }
@@ -415,22 +415,22 @@
     float alpha;
 };
 
-struct InlineTextBox::StyledMarkerSubrange : MarkerSubrange {
-    StyledMarkerSubrange(const MarkerSubrange& marker)
-        : MarkerSubrange { marker }
+struct InlineTextBox::StyledMarkedText : MarkedText {
+    StyledMarkedText(const MarkedText& marker)
+        : MarkedText { marker }
     {
     }
 
-    MarkerSubrangeStyle style;
+    MarkedTextStyle style;
 };
 
-static MarkerSubrange createMarkerSubrangeFromSelectionInBox(const InlineTextBox& box)
+static MarkedText createMarkedTextFromSelectionInBox(const InlineTextBox& box)
 {
     unsigned selectionStart;
     unsigned selectionEnd;
     std::tie(selectionStart, selectionEnd) = box.selectionStartEnd();
     if (selectionStart < selectionEnd)
-        return { selectionStart, selectionEnd, MarkerSubrange::Selection };
+        return { selectionStart, selectionEnd, MarkedText::Selection };
     return { };
 }
 
@@ -500,7 +500,7 @@
     bool containsComposition = renderer().textNode() && renderer().frame().editor().compositionNode() == renderer().textNode();
     bool useCustomUnderlines = containsComposition && renderer().frame().editor().compositionUsesCustomUnderlines();
 
-    MarkerSubrangeStyle unmarkedStyle = computeStyleForUnmarkedMarkerSubrange(paintInfo);
+    MarkedTextStyle unmarkedStyle = computeStyleForUnmarkedMarkedText(paintInfo);
 
     // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
     // and composition underlines.
@@ -508,20 +508,20 @@
         if (containsComposition && !useCustomUnderlines)
             paintCompositionBackground(context, boxOrigin);
 
-        Vector<MarkerSubrange> subranges = collectSubrangesForDocumentMarkers(TextPaintPhase::Background);
+        Vector<MarkedText> markedTexts = collectMarkedTextsForDocumentMarkers(TextPaintPhase::Background);
 #if ENABLE(TEXT_SELECTION)
         if (haveSelection && !useCustomUnderlines && !context.paintingDisabled()) {
-            auto selectionSubrange = createMarkerSubrangeFromSelectionInBox(*this);
-            if (!selectionSubrange.isEmpty())
-                subranges.append(WTFMove(selectionSubrange));
+            auto selectionMarkedText = createMarkedTextFromSelectionInBox(*this);
+            if (!selectionMarkedText.isEmpty())
+                markedTexts.append(WTFMove(selectionMarkedText));
         }
 #endif
-        auto styledSubranges = subdivideAndResolveStyle(subranges, unmarkedStyle, paintInfo);
+        auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, unmarkedStyle, paintInfo);
 
-        // Coalesce styles of adjacent subranges to minimize the number of drawing commands.
-        auto coalescedStyledSubranges = coalesceAdjacentSubranges(styledSubranges, &MarkerSubrangeStyle::areBackgroundMarkerSubrangeStylesEqual);
+        // Coalesce styles of adjacent marked texts to minimize the number of drawing commands.
+        auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areBackgroundMarkedTextStylesEqual);
 
-        paintMarkerSubranges(context, TextPaintPhase::Background, boxRect, coalescedStyledSubranges);
+        paintMarkedTexts(context, TextPaintPhase::Background, boxRect, coalescedStyledMarkedTexts);
     }
 
     // FIXME: Right now, InlineTextBoxes never call addRelevantUnpaintedObject() even though they might
@@ -533,41 +533,41 @@
 
     // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
     bool shouldPaintSelectionForeground = haveSelection && !useCustomUnderlines;
-    Vector<MarkerSubrange> subranges;
+    Vector<MarkedText> markedTexts;
     if (paintInfo.phase != PaintPhaseSelection) {
-        // The subranges for the gaps between document markers and selection are implicitly created by subdividing the entire line.
-        subranges.append({ clampedOffset(m_start), clampedOffset(end() + 1), MarkerSubrange::Unmarked });
+        // The marked texts for the gaps between document markers and selection are implicitly created by subdividing the entire line.
+        markedTexts.append({ clampedOffset(m_start), clampedOffset(end() + 1), MarkedText::Unmarked });
         if (!isPrinting) {
-            subranges.appendVector(collectSubrangesForDocumentMarkers(TextPaintPhase::Foreground));
+            markedTexts.appendVector(collectMarkedTextsForDocumentMarkers(TextPaintPhase::Foreground));
 
             bool shouldPaintDraggedContent = !(paintInfo.paintBehavior & PaintBehaviorExcludeSelection);
             if (shouldPaintDraggedContent) {
-                auto subrangesForDraggedContent = collectSubrangesForDraggedContent();
-                if (!subrangesForDraggedContent.isEmpty()) {
+                auto markedTextsForDraggedContent = collectMarkedTextsForDraggedContent();
+                if (!markedTextsForDraggedContent.isEmpty()) {
                     shouldPaintSelectionForeground = false;
-                    subranges.appendVector(subrangesForDraggedContent);
+                    markedTexts.appendVector(markedTextsForDraggedContent);
                 }
             }
         }
     }
-    // The selection subrange acts as a placeholder when computing the subranges for the gaps...
+    // The selection marked text acts as a placeholder when computing the marked texts for the gaps...
     if (shouldPaintSelectionForeground) {
         ASSERT(!isPrinting);
-        auto selectionSubrange = createMarkerSubrangeFromSelectionInBox(*this);
-        if (!selectionSubrange.isEmpty())
-            subranges.append(WTFMove(selectionSubrange));
+        auto selectionMarkedText = createMarkedTextFromSelectionInBox(*this);
+        if (!selectionMarkedText.isEmpty())
+            markedTexts.append(WTFMove(selectionMarkedText));
     }
 
-    auto styledSubranges = subdivideAndResolveStyle(subranges, unmarkedStyle, paintInfo);
+    auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, unmarkedStyle, paintInfo);
 
-    // ... now remove the selection subrange if we are excluding selection.
+    // ... now remove the selection marked text if we are excluding selection.
     if (!isPrinting && paintInfo.paintBehavior & PaintBehaviorExcludeSelection)
-        styledSubranges.removeAllMatching([] (const StyledMarkerSubrange& subrange) { return subrange.type == MarkerSubrange::Selection; });
+        styledMarkedTexts.removeAllMatching([] (const StyledMarkedText& markedText) { return markedText.type == MarkedText::Selection; });
 
-    // Coalesce styles of adjacent subranges to minimize the number of drawing commands.
-    auto coalescedStyledSubranges = coalesceAdjacentSubranges(styledSubranges, &MarkerSubrangeStyle::areForegroundMarkerSubrangeStylesEqual);
+    // Coalesce styles of adjacent marked texts to minimize the number of drawing commands.
+    auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areForegroundMarkedTextStylesEqual);
 
-    paintMarkerSubranges(context, TextPaintPhase::Foreground, boxRect, coalescedStyledSubranges);
+    paintMarkedTexts(context, TextPaintPhase::Foreground, boxRect, coalescedStyledMarkedTexts);
 
     // Paint decorations
     TextDecoration textDecorations = lineStyle.textDecorationsInEffect();
@@ -602,10 +602,10 @@
             }
         }
 
-        // Coalesce styles of adjacent subranges to minimize the number of drawing commands.
-        auto coalescedStyledSubranges = coalesceAdjacentSubranges(styledSubranges, &MarkerSubrangeStyle::areDecorationMarkerSubrangeStylesEqual);
+        // Coalesce styles of adjacent marked texts to minimize the number of drawing commands.
+        auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areDecorationMarkedTextStylesEqual);
 
-        paintMarkerSubranges(context, TextPaintPhase::Decoration, boxRect, coalescedStyledSubranges, textDecorationSelectionClipOutRect);
+        paintMarkedTexts(context, TextPaintPhase::Decoration, boxRect, coalescedStyledMarkedTexts, textDecorationSelectionClipOutRect);
     }
 
     // 3. Paint fancy decorations, including composition underlines and platform-specific underlines for spelling errors, grammar errors, et cetera.
@@ -656,11 +656,11 @@
 
 void InlineTextBox::paintPlatformDocumentMarkers(GraphicsContext& context, const FloatPoint& boxOrigin)
 {
-    for (auto& subrange : subdivide(collectSubrangesForDocumentMarkers(TextPaintPhase::Foreground), OverlapStrategy::Frontmost))
-        paintPlatformDocumentMarker(context, boxOrigin, subrange);
+    for (auto& markedText : subdivide(collectMarkedTextsForDocumentMarkers(TextPaintPhase::Foreground), OverlapStrategy::Frontmost))
+        paintPlatformDocumentMarker(context, boxOrigin, markedText);
 }
 
-void InlineTextBox::paintPlatformDocumentMarker(GraphicsContext& context, const FloatPoint& boxOrigin, const MarkerSubrange& subrange)
+void InlineTextBox::paintPlatformDocumentMarker(GraphicsContext& context, const FloatPoint& boxOrigin, const MarkedText& markedText)
 {
     // Never print spelling/grammar markers (5327887)
     if (renderer().document().printing())
@@ -673,7 +673,7 @@
     float width = m_logicalWidth; // how much line to draw
 
     // Avoid measuring the text when the entire line box is selected as an optimization.
-    if (subrange.startOffset || subrange.endOffset != clampedOffset(end() + 1)) {
+    if (markedText.startOffset || markedText.endOffset != clampedOffset(end() + 1)) {
         // Calculate start & width
         int deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
         int selHeight = selectionHeight();
@@ -682,24 +682,24 @@
         TextRun run = createTextRun(text);
 
         LayoutRect selectionRect = LayoutRect(startPoint, FloatSize(0, selHeight));
-        lineFont().adjustSelectionRectForText(run, selectionRect, subrange.startOffset, subrange.endOffset);
+        lineFont().adjustSelectionRectForText(run, selectionRect, markedText.startOffset, markedText.endOffset);
         IntRect markerRect = enclosingIntRect(selectionRect);
         start = markerRect.x() - startPoint.x();
         width = markerRect.width();
     }
 
-    auto lineStyleForSubrangeType = [] (MarkerSubrange::Type type) {
+    auto lineStyleForMarkedTextType = [] (MarkedText::Type type) {
         switch (type) {
-        case MarkerSubrange::SpellingError:
+        case MarkedText::SpellingError:
             return GraphicsContext::DocumentMarkerSpellingLineStyle;
-        case MarkerSubrange::GrammarError:
+        case MarkedText::GrammarError:
             return GraphicsContext::DocumentMarkerGrammarLineStyle;
-        case MarkerSubrange::Correction:
+        case MarkedText::Correction:
             return GraphicsContext::DocumentMarkerAutocorrectionReplacementLineStyle;
-        case MarkerSubrange::DictationAlternatives:
+        case MarkedText::DictationAlternatives:
             return GraphicsContext::DocumentMarkerDictationAlternativesLineStyle;
 #if PLATFORM(IOS)
-        case MarkerSubrange::DictationPhraseWithAlternatives:
+        case MarkedText::DictationPhraseWithAlternatives:
             // FIXME: Rename TextCheckingDictationPhraseWithAlternativesLineStyle and remove the PLATFORM(IOS)-guard.
             return GraphicsContext::TextCheckingDictationPhraseWithAlternativesLineStyle;
 #endif
@@ -726,14 +726,14 @@
         // In larger fonts, though, place the underline up near the baseline to prevent a big gap.
         underlineOffset = baseline + 2;
     }
-    context.drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForSubrangeType(subrange.type));
+    context.drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForMarkedTextType(markedText.type));
 }
 
-auto InlineTextBox::computeStyleForUnmarkedMarkerSubrange(const PaintInfo& paintInfo) const -> MarkerSubrangeStyle
+auto InlineTextBox::computeStyleForUnmarkedMarkedText(const PaintInfo& paintInfo) const -> MarkedTextStyle
 {
     auto& lineStyle = this->lineStyle();
 
-    MarkerSubrangeStyle style;
+    MarkedTextStyle style;
     style.textDecorationStyles = TextDecorationPainter::stylesForRenderer(renderer(), lineStyle.textDecorationsInEffect(), isFirstLine());
     style.textStyles = computeTextPaintStyle(renderer().frame(), lineStyle, paintInfo);
     style.textShadow = paintInfo.forceTextColor() ? nullptr : lineStyle.textShadow();
@@ -741,24 +741,24 @@
     return style;
 }
 
-auto InlineTextBox::resolveStyleForSubrange(const MarkerSubrange& subrange, const MarkerSubrangeStyle& baseStyle, const PaintInfo& paintInfo) -> StyledMarkerSubrange
+auto InlineTextBox::resolveStyleForMarkedText(const MarkedText& markedText, const MarkedTextStyle& baseStyle, const PaintInfo& paintInfo) -> StyledMarkedText
 {
-    MarkerSubrangeStyle style = baseStyle;
-    switch (subrange.type) {
-    case MarkerSubrange::Correction:
-    case MarkerSubrange::DictationAlternatives:
+    MarkedTextStyle style = baseStyle;
+    switch (markedText.type) {
+    case MarkedText::Correction:
+    case MarkedText::DictationAlternatives:
 #if PLATFORM(IOS)
     // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
-    case MarkerSubrange::DictationPhraseWithAlternatives:
+    case MarkedText::DictationPhraseWithAlternatives:
 #endif
-    case MarkerSubrange::GrammarError:
-    case MarkerSubrange::SpellingError:
-    case MarkerSubrange::Unmarked:
+    case MarkedText::GrammarError:
+    case MarkedText::SpellingError:
+    case MarkedText::Unmarked:
         break;
-    case MarkerSubrange::DraggedContent:
+    case MarkedText::DraggedContent:
         style.alpha = 0.25;
         break;
-    case MarkerSubrange::Selection: {
+    case MarkedText::Selection: {
         const ShadowData* selectionShadow = nullptr;
         style.textStyles = computeTextSelectionPaintStyle(style.textStyles, renderer(), lineStyle(), paintInfo, selectionShadow);
         style.textShadow = selectionShadow;
@@ -769,74 +769,74 @@
             style.backgroundColor = { 0xff - selectionBackgroundColor.red(), 0xff - selectionBackgroundColor.green(), 0xff - selectionBackgroundColor.blue() };
         break;
     }
-    case MarkerSubrange::TextMatch:
-        style.backgroundColor = subrange.marker->isActiveMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
+    case MarkedText::TextMatch:
+        style.backgroundColor = markedText.marker->isActiveMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
         break;
     }
-    StyledMarkerSubrange styledSubrange = subrange;
-    styledSubrange.style = WTFMove(style);
-    return styledSubrange;
+    StyledMarkedText styledMarkedText = markedText;
+    styledMarkedText.style = WTFMove(style);
+    return styledMarkedText;
 }
 
-auto InlineTextBox::subdivideAndResolveStyle(const Vector<MarkerSubrange>& subrangesToSubdivide, const MarkerSubrangeStyle& baseStyle, const PaintInfo& paintInfo) -> Vector<StyledMarkerSubrange>
+auto InlineTextBox::subdivideAndResolveStyle(const Vector<MarkedText>& textsToSubdivide, const MarkedTextStyle& baseStyle, const PaintInfo& paintInfo) -> Vector<StyledMarkedText>
 {
-    if (subrangesToSubdivide.isEmpty())
+    if (textsToSubdivide.isEmpty())
         return { };
 
-    auto subranges = subdivide(subrangesToSubdivide);
+    auto markedTexts = subdivide(textsToSubdivide);
 
-    // Compute frontmost overlapping styled subranges.
-    Vector<StyledMarkerSubrange> frontmostSubranges;
-    frontmostSubranges.reserveInitialCapacity(subranges.size());
-    frontmostSubranges.uncheckedAppend(resolveStyleForSubrange(subranges[0], baseStyle, paintInfo));
-    for (auto it = subranges.begin() + 1, end = subranges.end(); it != end; ++it) {
-        StyledMarkerSubrange& previousStyledSubrange = frontmostSubranges.last();
-        if (previousStyledSubrange.startOffset == it->startOffset && previousStyledSubrange.endOffset == it->endOffset) {
-            // Subranges completely cover each other.
-            previousStyledSubrange = resolveStyleForSubrange(*it, previousStyledSubrange.style, paintInfo);
+    // Compute frontmost overlapping styled marked texts.
+    Vector<StyledMarkedText> frontmostMarkedTexts;
+    frontmostMarkedTexts.reserveInitialCapacity(markedTexts.size());
+    frontmostMarkedTexts.uncheckedAppend(resolveStyleForMarkedText(markedTexts[0], baseStyle, paintInfo));
+    for (auto it = markedTexts.begin() + 1, end = markedTexts.end(); it != end; ++it) {
+        StyledMarkedText& previousStyledMarkedText = frontmostMarkedTexts.last();
+        if (previousStyledMarkedText.startOffset == it->startOffset && previousStyledMarkedText.endOffset == it->endOffset) {
+            // Marked texts completely cover each other.
+            previousStyledMarkedText = resolveStyleForMarkedText(*it, previousStyledMarkedText.style, paintInfo);
             continue;
         }
-        frontmostSubranges.uncheckedAppend(resolveStyleForSubrange(*it, baseStyle, paintInfo));
+        frontmostMarkedTexts.uncheckedAppend(resolveStyleForMarkedText(*it, baseStyle, paintInfo));
     }
 
-    return frontmostSubranges;
+    return frontmostMarkedTexts;
 }
 
-auto InlineTextBox::coalesceAdjacentSubranges(const Vector<StyledMarkerSubrange>& subrangesToCoalesce, MarkerSubrangeStylesEqualityFunction areMarkerSubrangeStylesEqual) -> Vector<StyledMarkerSubrange>
+auto InlineTextBox::coalesceAdjacentMarkedTexts(const Vector<StyledMarkedText>& textsToCoalesce, MarkedTextStylesEqualityFunction areMarkedTextStylesEqual) -> Vector<StyledMarkedText>
 {
-    if (subrangesToCoalesce.isEmpty())
+    if (textsToCoalesce.isEmpty())
         return { };
 
-    auto areAdjacentSubrangesWithSameStyle = [&] (const StyledMarkerSubrange& a, const StyledMarkerSubrange& b) {
-        return a.endOffset == b.startOffset && areMarkerSubrangeStylesEqual(a.style, b.style);
+    auto areAdjacentMarkedTextsWithSameStyle = [&] (const StyledMarkedText& a, const StyledMarkedText& b) {
+        return a.endOffset == b.startOffset && areMarkedTextStylesEqual(a.style, b.style);
     };
 
-    Vector<StyledMarkerSubrange> styledSubranges;
-    styledSubranges.reserveInitialCapacity(subrangesToCoalesce.size());
-    styledSubranges.uncheckedAppend(subrangesToCoalesce[0]);
-    for (auto it = subrangesToCoalesce.begin() + 1, end = subrangesToCoalesce.end(); it != end; ++it) {
-        StyledMarkerSubrange& previousStyledSubrange = styledSubranges.last();
-        if (areAdjacentSubrangesWithSameStyle(previousStyledSubrange, *it)) {
-            previousStyledSubrange.endOffset = it->endOffset;
+    Vector<StyledMarkedText> styledMarkedTexts;
+    styledMarkedTexts.reserveInitialCapacity(textsToCoalesce.size());
+    styledMarkedTexts.uncheckedAppend(textsToCoalesce[0]);
+    for (auto it = textsToCoalesce.begin() + 1, end = textsToCoalesce.end(); it != end; ++it) {
+        StyledMarkedText& previousStyledMarkedText = styledMarkedTexts.last();
+        if (areAdjacentMarkedTextsWithSameStyle(previousStyledMarkedText, *it)) {
+            previousStyledMarkedText.endOffset = it->endOffset;
             continue;
         }
-        styledSubranges.uncheckedAppend(*it);
+        styledMarkedTexts.uncheckedAppend(*it);
     }
 
-    return styledSubranges;
+    return styledMarkedTexts;
 }
 
-Vector<MarkerSubrange> InlineTextBox::collectSubrangesForDraggedContent()
+Vector<MarkedText> InlineTextBox::collectMarkedTextsForDraggedContent()
 {
     using DraggendContentRange = std::pair<unsigned, unsigned>;
     auto draggedContentRanges = renderer().draggedContentRangesBetweenOffsets(m_start, m_start + m_len);
-    Vector<MarkerSubrange> result = draggedContentRanges.map([this] (const DraggendContentRange& range) -> MarkerSubrange {
-        return { clampedOffset(range.first), clampedOffset(range.second), MarkerSubrange::DraggedContent };
+    Vector<MarkedText> result = draggedContentRanges.map([this] (const DraggendContentRange& range) -> MarkedText {
+        return { clampedOffset(range.first), clampedOffset(range.second), MarkedText::DraggedContent };
     });
     return result;
 }
 
-Vector<MarkerSubrange> InlineTextBox::collectSubrangesForDocumentMarkers(TextPaintPhase phase)
+Vector<MarkedText> InlineTextBox::collectMarkedTextsForDocumentMarkers(TextPaintPhase phase)
 {
     ASSERT(phase == TextPaintPhase::Background || phase == TextPaintPhase::Foreground);
     if (!renderer().textNode())
@@ -844,29 +844,29 @@
 
     Vector<RenderedDocumentMarker*> markers = renderer().document().markers().markersFor(renderer().textNode());
 
-    auto markerTypeForSubrangeType = [] (DocumentMarker::MarkerType type) {
+    auto markedTextTypeForMarkerType = [] (DocumentMarker::MarkerType type) {
         switch (type) {
         case DocumentMarker::Spelling:
-            return MarkerSubrange::SpellingError;
+            return MarkedText::SpellingError;
         case DocumentMarker::Grammar:
-            return MarkerSubrange::GrammarError;
+            return MarkedText::GrammarError;
         case DocumentMarker::CorrectionIndicator:
-            return MarkerSubrange::Correction;
+            return MarkedText::Correction;
         case DocumentMarker::TextMatch:
-            return MarkerSubrange::TextMatch;
+            return MarkedText::TextMatch;
         case DocumentMarker::DictationAlternatives:
-            return MarkerSubrange::DictationAlternatives;
+            return MarkedText::DictationAlternatives;
 #if PLATFORM(IOS)
         case DocumentMarker::DictationPhraseWithAlternatives:
-            return MarkerSubrange::DictationPhraseWithAlternatives;
+            return MarkedText::DictationPhraseWithAlternatives;
 #endif
         default:
-            return MarkerSubrange::Unmarked;
+            return MarkedText::Unmarked;
         }
     };
 
-    Vector<MarkerSubrange> subranges;
-    subranges.reserveInitialCapacity(markers.size());
+    Vector<MarkedText> markedTexts;
+    markedTexts.reserveInitialCapacity(markers.size());
 
     // Give any document markers that touch this run a chance to draw before the text has been drawn.
     // Note end() points at the last char, not one past it like endOffset and ranges do.
@@ -921,7 +921,7 @@
         case DocumentMarker::DictationPhraseWithAlternatives:
 #endif
         case DocumentMarker::TextMatch:
-            subranges.uncheckedAppend({ clampedOffset(marker->startOffset()), clampedOffset(marker->endOffset()), markerTypeForSubrangeType(marker->type()), marker });
+            markedTexts.uncheckedAppend({ clampedOffset(marker->startOffset()), clampedOffset(marker->endOffset()), markedTextTypeForMarkerType(marker->type()), marker });
             break;
         case DocumentMarker::Replacement:
             break;
@@ -933,7 +933,7 @@
             ASSERT_NOT_REACHED();
         }
     }
-    return subranges;
+    return markedTexts;
 }
 
 FloatPoint InlineTextBox::textOriginFromBoxRect(const FloatRect& boxRect) const
@@ -950,25 +950,25 @@
     return textOrigin;
 }
 
-void InlineTextBox::paintMarkerSubranges(GraphicsContext& context, TextPaintPhase phase, const FloatRect& boxRect, const Vector<StyledMarkerSubrange>& subranges, const FloatRect& decorationClipOutRect)
+void InlineTextBox::paintMarkedTexts(GraphicsContext& context, TextPaintPhase phase, const FloatRect& boxRect, const Vector<StyledMarkedText>& markedTexts, const FloatRect& decorationClipOutRect)
 {
     switch (phase) {
     case TextPaintPhase::Background:
-        for (auto& subrange : subranges)
-            paintTextSubrangeBackground(context, boxRect.location(), subrange.style.backgroundColor, subrange.startOffset, subrange.endOffset);
+        for (auto& markedText : markedTexts)
+            paintMarkedTextBackground(context, boxRect.location(), markedText.style.backgroundColor, markedText.startOffset, markedText.endOffset);
         return;
     case TextPaintPhase::Foreground:
-        for (auto& subrange : subranges)
-            paintTextSubrangeForeground(context, boxRect, subrange);
+        for (auto& markedText : markedTexts)
+            paintMarkedTextForeground(context, boxRect, markedText);
         return;
     case TextPaintPhase::Decoration:
-        for (auto& subrange : subranges)
-            paintTextSubrangeDecoration(context, boxRect, decorationClipOutRect, subrange);
+        for (auto& markedText : markedTexts)
+            paintMarkedTextDecoration(context, boxRect, decorationClipOutRect, markedText);
         return;
     }
 }
 
-void InlineTextBox::paintTextSubrangeBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const Color& color, unsigned clampedStartOffset, unsigned clampedEndOffset)
+void InlineTextBox::paintMarkedTextBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const Color& color, unsigned clampedStartOffset, unsigned clampedEndOffset)
 {
     if (clampedStartOffset >= clampedEndOffset)
         return;
@@ -997,9 +997,9 @@
     context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), color);
 }
 
-void InlineTextBox::paintTextSubrangeForeground(GraphicsContext& context, const FloatRect& boxRect, const StyledMarkerSubrange& subrange)
+void InlineTextBox::paintMarkedTextForeground(GraphicsContext& context, const FloatRect& boxRect, const StyledMarkedText& markedText)
 {
-    if (subrange.startOffset >= subrange.endOffset)
+    if (markedText.startOffset >= markedText.endOffset)
         return;
 
     const FontCascade& font = lineFont();
@@ -1014,27 +1014,27 @@
 
     TextPainter textPainter { context };
     textPainter.setFont(font);
-    textPainter.setStyle(subrange.style.textStyles);
+    textPainter.setStyle(markedText.style.textStyles);
     textPainter.setIsHorizontal(isHorizontal());
-    textPainter.setShadow(subrange.style.textShadow);
+    textPainter.setShadow(markedText.style.textShadow);
     textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, combinedText());
 
     GraphicsContextStateSaver stateSaver { context, false };
-    if (subrange.type == MarkerSubrange::DraggedContent) {
+    if (markedText.type == MarkedText::DraggedContent) {
         stateSaver.save();
-        context.setAlpha(subrange.style.alpha);
+        context.setAlpha(markedText.style.alpha);
     }
     // TextPainter wants the box rectangle and text origin of the entire line box.
     auto text = this->text();
-    textPainter.paintRange(createTextRun(text), boxRect, textOriginFromBoxRect(boxRect), subrange.startOffset, subrange.endOffset);
+    textPainter.paintRange(createTextRun(text), boxRect, textOriginFromBoxRect(boxRect), markedText.startOffset, markedText.endOffset);
 }
 
-void InlineTextBox::paintTextSubrangeDecoration(GraphicsContext& context, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkerSubrange& subrange)
+void InlineTextBox::paintMarkedTextDecoration(GraphicsContext& context, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText& markedText)
 {
     if (m_truncation == cFullTruncation)
         return;
 
-    updateGraphicsContext(context, subrange.style.textStyles);
+    updateGraphicsContext(context, markedText.style.textStyles);
 
     bool isCombinedText = combinedText();
     if (isCombinedText)
@@ -1041,8 +1041,8 @@
         context.concatCTM(rotation(boxRect, Clockwise));
 
     // 1. Compute text selection
-    unsigned startOffset = subrange.startOffset;
-    unsigned endOffset = subrange.endOffset;
+    unsigned startOffset = markedText.startOffset;
+    unsigned endOffset = markedText.endOffset;
     if (startOffset >= endOffset)
         return;
 
@@ -1060,13 +1060,13 @@
     }
 
     // 2. Paint
-    TextDecorationPainter decorationPainter { context, static_cast<unsigned>(lineStyle().textDecorationsInEffect()), renderer(), isFirstLine(), subrange.style.textDecorationStyles };
+    TextDecorationPainter decorationPainter { context, static_cast<unsigned>(lineStyle().textDecorationsInEffect()), renderer(), isFirstLine(), markedText.style.textDecorationStyles };
     decorationPainter.setInlineTextBox(this);
     decorationPainter.setFont(lineFont());
     decorationPainter.setWidth(snappedSelectionRect.width());
     decorationPainter.setBaseline(lineStyle().fontMetrics().ascent());
     decorationPainter.setIsHorizontal(isHorizontal());
-    decorationPainter.addTextShadow(subrange.style.textShadow);
+    decorationPainter.addTextShadow(markedText.style.textShadow);
 
     {
         GraphicsContextStateSaver stateSaver { context, false };
@@ -1083,7 +1083,7 @@
 
 void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin)
 {
-    paintTextSubrangeBackground(context, boxOrigin, Color::compositionFill, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd()));
+    paintMarkedTextBackground(context, boxOrigin, Color::compositionFill, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd()));
 }
 
 void InlineTextBox::paintCompositionUnderlines(GraphicsContext& context, const FloatPoint& boxOrigin) const

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (229078 => 229079)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2018-02-27 22:35:47 UTC (rev 229079)
@@ -32,7 +32,7 @@
 class RenderedDocumentMarker;
 class TextPainter;
 struct CompositionUnderline;
-struct MarkerSubrange;
+struct MarkedText;
 struct TextPaintStyle;
 
 const unsigned short cNoTruncation = USHRT_MAX;
@@ -151,26 +151,26 @@
     virtual float positionForOffset(unsigned offset) const;
 
 private:
-    struct MarkerSubrangeStyle;
-    struct StyledMarkerSubrange;
+    struct MarkedTextStyle;
+    struct StyledMarkedText;
 
     enum class TextPaintPhase { Background, Foreground, Decoration };
 
-    Vector<MarkerSubrange> collectSubrangesForDraggedContent();
-    Vector<MarkerSubrange> collectSubrangesForDocumentMarkers(TextPaintPhase);
+    Vector<MarkedText> collectMarkedTextsForDraggedContent();
+    Vector<MarkedText> collectMarkedTextsForDocumentMarkers(TextPaintPhase);
 
-    MarkerSubrangeStyle computeStyleForUnmarkedMarkerSubrange(const PaintInfo&) const;
-    StyledMarkerSubrange resolveStyleForSubrange(const MarkerSubrange&, const MarkerSubrangeStyle& baseStyle, const PaintInfo&);
-    Vector<StyledMarkerSubrange> subdivideAndResolveStyle(const Vector<MarkerSubrange>&, const MarkerSubrangeStyle& baseStyle, const PaintInfo&);
+    MarkedTextStyle computeStyleForUnmarkedMarkedText(const PaintInfo&) const;
+    StyledMarkedText resolveStyleForMarkedText(const MarkedText&, const MarkedTextStyle& baseStyle, const PaintInfo&);
+    Vector<StyledMarkedText> subdivideAndResolveStyle(const Vector<MarkedText>&, const MarkedTextStyle& baseStyle, const PaintInfo&);
 
-    using MarkerSubrangeStylesEqualityFunction = bool (*)(const MarkerSubrangeStyle&, const MarkerSubrangeStyle&);
-    Vector<StyledMarkerSubrange> coalesceAdjacentSubranges(const Vector<StyledMarkerSubrange>&, MarkerSubrangeStylesEqualityFunction);
+    using MarkedTextStylesEqualityFunction = bool (*)(const MarkedTextStyle&, const MarkedTextStyle&);
+    Vector<StyledMarkedText> coalesceAdjacentMarkedTexts(const Vector<StyledMarkedText>&, MarkedTextStylesEqualityFunction);
 
     FloatPoint textOriginFromBoxRect(const FloatRect&) const;
 
-    void paintMarkerSubranges(GraphicsContext&, TextPaintPhase, const FloatRect& boxRect, const Vector<StyledMarkerSubrange>&, const FloatRect& decorationClipOutRect = { });
+    void paintMarkedTexts(GraphicsContext&, TextPaintPhase, const FloatRect& boxRect, const Vector<StyledMarkedText>&, const FloatRect& decorationClipOutRect = { });
 
-    void paintPlatformDocumentMarker(GraphicsContext&, const FloatPoint& boxOrigin, const MarkerSubrange&);
+    void paintPlatformDocumentMarker(GraphicsContext&, const FloatPoint& boxOrigin, const MarkedText&);
     void paintPlatformDocumentMarkers(GraphicsContext&, const FloatPoint& boxOrigin);
 
     void paintCompositionBackground(GraphicsContext&, const FloatPoint& boxOrigin);
@@ -177,9 +177,9 @@
     void paintCompositionUnderlines(GraphicsContext&, const FloatPoint& boxOrigin) const;
     void paintCompositionUnderline(GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&) const;
 
-    void paintTextSubrangeBackground(GraphicsContext&, const FloatPoint& boxOrigin, const Color&, unsigned clampedStartOffset, unsigned clampedEndOffset);
-    void paintTextSubrangeForeground(GraphicsContext&, const FloatRect& boxRect, const StyledMarkerSubrange&);
-    void paintTextSubrangeDecoration(GraphicsContext&, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkerSubrange&);
+    void paintMarkedTextBackground(GraphicsContext&, const FloatPoint& boxOrigin, const Color&, unsigned clampedStartOffset, unsigned clampedEndOffset);
+    void paintMarkedTextForeground(GraphicsContext&, const FloatRect& boxRect, const StyledMarkedText&);
+    void paintMarkedTextDecoration(GraphicsContext&, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText&);
 
     const RenderCombineText* combinedText() const;
     const FontCascade& lineFont() const;

Copied: trunk/Source/WebCore/rendering/MarkedText.cpp (from rev 229075, trunk/Source/WebCore/rendering/MarkerSubrange.cpp) (0 => 229079)


--- trunk/Source/WebCore/rendering/MarkedText.cpp	                        (rev 0)
+++ trunk/Source/WebCore/rendering/MarkedText.cpp	2018-02-27 22:35:47 UTC (rev 229079)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MarkedText.h"
+
+#include <algorithm>
+#include <wtf/HashSet.h>
+
+namespace WebCore {
+
+Vector<MarkedText> subdivide(const Vector<MarkedText>& markedTexts, OverlapStrategy overlapStrategy)
+{
+    if (markedTexts.isEmpty())
+        return { };
+
+    struct Offset {
+        enum Kind { Begin, End };
+        Kind kind;
+        unsigned value; // Copy of markedText.startOffset/endOffset to avoid the need to branch based on kind.
+        const MarkedText* markedText;
+    };
+
+    // 1. Build table of all offsets.
+    Vector<Offset> offsets;
+    ASSERT(markedTexts.size() < std::numeric_limits<unsigned>::max() / 2);
+    unsigned numberOfMarkedTexts = markedTexts.size();
+    unsigned numberOfOffsets = 2 * numberOfMarkedTexts;
+    offsets.reserveInitialCapacity(numberOfOffsets);
+    for (auto& markedText : markedTexts) {
+        offsets.uncheckedAppend({ Offset::Begin, markedText.startOffset, &markedText });
+        offsets.uncheckedAppend({ Offset::End, markedText.endOffset, &markedText });
+    }
+
+    // 2. Sort offsets such that begin offsets are in paint order and end offsets are in reverse paint order.
+    std::sort(offsets.begin(), offsets.end(), [] (const Offset& a, const Offset& b) {
+        return a.value < b.value || (a.value == b.value && a.kind == b.kind && a.kind == Offset::Begin && a.markedText->type < b.markedText->type)
+        || (a.value == b.value && a.kind == b.kind && a.kind == Offset::End && a.markedText->type > b.markedText->type);
+    });
+
+    // 3. Compute intersection.
+    Vector<MarkedText> result;
+    result.reserveInitialCapacity(numberOfMarkedTexts);
+    HashSet<const MarkedText*> processedMarkedTexts;
+    unsigned offsetSoFar = offsets[0].value;
+    for (unsigned i = 1; i < numberOfOffsets; ++i) {
+        if (offsets[i].value > offsets[i - 1].value) {
+            if (overlapStrategy == OverlapStrategy::Frontmost) {
+                std::optional<unsigned> frontmost;
+                for (unsigned j = 0; j < i; ++j) {
+                    if (!processedMarkedTexts.contains(offsets[j].markedText) && (!frontmost || offsets[j].markedText->type > offsets[*frontmost].markedText->type))
+                        frontmost = j;
+                }
+                if (frontmost)
+                    result.append({ offsetSoFar, offsets[i].value, offsets[*frontmost].markedText->type, offsets[*frontmost].markedText->marker });
+            } else {
+                // The appended marked texts may not be in paint order. We will fix this up at the end of this function.
+                for (unsigned j = 0; j < i; ++j) {
+                    if (!processedMarkedTexts.contains(offsets[j].markedText))
+                        result.append({ offsetSoFar, offsets[i].value, offsets[j].markedText->type, offsets[j].markedText->marker });
+                }
+            }
+            offsetSoFar = offsets[i].value;
+        }
+        if (offsets[i].kind == Offset::End)
+            processedMarkedTexts.add(offsets[i].markedText);
+    }
+    // Fix up; sort the marked texts so that they are in paint order.
+    if (overlapStrategy == OverlapStrategy::None)
+        std::sort(result.begin(), result.end(), [] (const MarkedText& a, const MarkedText& b) { return a.startOffset < b.startOffset || (a.startOffset == b.startOffset && a.type < b.type); });
+    return result;
+}
+
+}
+
+

Copied: trunk/Source/WebCore/rendering/MarkedText.h (from rev 229075, trunk/Source/WebCore/rendering/MarkerSubrange.h) (0 => 229079)


--- trunk/Source/WebCore/rendering/MarkedText.h	                        (rev 0)
+++ trunk/Source/WebCore/rendering/MarkedText.h	2018-02-27 22:35:47 UTC (rev 229079)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class RenderedDocumentMarker;
+
+struct MarkedText {
+    // Sorted by paint order
+    enum Type {
+        Unmarked,
+        GrammarError,
+        Correction,
+        SpellingError,
+        TextMatch,
+        DictationAlternatives,
+#if PLATFORM(IOS)
+        // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
+        DictationPhraseWithAlternatives,
+#endif
+        Selection,
+        DraggedContent,
+    };
+#if !COMPILER_SUPPORTS(NSDMI_FOR_AGGREGATES)
+    MarkedText() = default;
+    MarkedText(unsigned startOffset, unsigned endOffset, Type type, const RenderedDocumentMarker* marker = nullptr)
+        : startOffset { startOffset }
+        , endOffset { endOffset }
+        , type { type }
+        , marker { marker }
+    {
+    }
+#endif
+    unsigned startOffset;
+    unsigned endOffset;
+    Type type;
+    const RenderedDocumentMarker* marker { nullptr };
+
+    bool isEmpty() const { return endOffset <= startOffset; }
+    bool operator!=(const MarkedText& other) const { return !(*this == other); }
+    bool operator==(const MarkedText& other) const
+    {
+        return startOffset == other.startOffset && endOffset == other.endOffset && type == other.type && marker == other.marker;
+    }
+};
+
+enum class OverlapStrategy { None, Frontmost };
+WEBCORE_EXPORT Vector<MarkedText> subdivide(const Vector<MarkedText>&, OverlapStrategy = OverlapStrategy::None);
+
+}
+

Deleted: trunk/Source/WebCore/rendering/MarkerSubrange.cpp (229078 => 229079)


--- trunk/Source/WebCore/rendering/MarkerSubrange.cpp	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/rendering/MarkerSubrange.cpp	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MarkerSubrange.h"
-
-#include <wtf/HashSet.h>
-#include <algorithm>
-
-namespace WebCore {
-
-Vector<MarkerSubrange> subdivide(const Vector<MarkerSubrange>& subranges, OverlapStrategy overlapStrategy)
-{
-    if (subranges.isEmpty())
-        return { };
-
-    struct Offset {
-        enum Kind { Begin, End };
-        Kind kind;
-        unsigned value; // Copy of subrange.startOffset/endOffset to avoid the need to branch based on kind.
-        const MarkerSubrange* subrange;
-    };
-
-    // 1. Build table of all offsets.
-    Vector<Offset> offsets;
-    ASSERT(subranges.size() < std::numeric_limits<unsigned>::max() / 2);
-    unsigned numberOfSubranges = subranges.size();
-    unsigned numberOfOffsets = 2 * numberOfSubranges;
-    offsets.reserveInitialCapacity(numberOfOffsets);
-    for (auto& subrange : subranges) {
-        offsets.uncheckedAppend({ Offset::Begin, subrange.startOffset, &subrange });
-        offsets.uncheckedAppend({ Offset::End, subrange.endOffset, &subrange });
-    }
-
-    // 2. Sort offsets such that begin offsets are in paint order and end offsets are in reverse paint order.
-    std::sort(offsets.begin(), offsets.end(), [] (const Offset& a, const Offset& b) {
-        return a.value < b.value || (a.value == b.value && a.kind == b.kind && a.kind == Offset::Begin && a.subrange->type < b.subrange->type)
-        || (a.value == b.value && a.kind == b.kind && a.kind == Offset::End && a.subrange->type > b.subrange->type);
-    });
-
-    // 3. Compute intersection.
-    Vector<MarkerSubrange> result;
-    result.reserveInitialCapacity(numberOfSubranges);
-    HashSet<const MarkerSubrange*> processedSubranges;
-    unsigned offsetSoFar = offsets[0].value;
-    for (unsigned i = 1; i < numberOfOffsets; ++i) {
-        if (offsets[i].value > offsets[i - 1].value) {
-            if (overlapStrategy == OverlapStrategy::Frontmost) {
-                std::optional<unsigned> frontmost;
-                for (unsigned j = 0; j < i; ++j) {
-                    if (!processedSubranges.contains(offsets[j].subrange) && (!frontmost || offsets[j].subrange->type > offsets[*frontmost].subrange->type))
-                        frontmost = j;
-                }
-                if (frontmost)
-                    result.append({ offsetSoFar, offsets[i].value, offsets[*frontmost].subrange->type, offsets[*frontmost].subrange->marker });
-            } else {
-                // The appended subranges may not be in paint order. We will fix this up at the end of this function.
-                for (unsigned j = 0; j < i; ++j) {
-                    if (!processedSubranges.contains(offsets[j].subrange))
-                        result.append({ offsetSoFar, offsets[i].value, offsets[j].subrange->type, offsets[j].subrange->marker });
-                }
-            }
-            offsetSoFar = offsets[i].value;
-        }
-        if (offsets[i].kind == Offset::End)
-            processedSubranges.add(offsets[i].subrange);
-    }
-    // Fix up; sort the subranges so that they are in paint order.
-    if (overlapStrategy == OverlapStrategy::None)
-        std::sort(result.begin(), result.end(), [] (const MarkerSubrange& a, const MarkerSubrange& b) { return a.startOffset < b.startOffset || (a.startOffset == b.startOffset && a.type < b.type); });
-    return result;
-}
-
-}
-
-

Deleted: trunk/Source/WebCore/rendering/MarkerSubrange.h (229078 => 229079)


--- trunk/Source/WebCore/rendering/MarkerSubrange.h	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Source/WebCore/rendering/MarkerSubrange.h	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class RenderedDocumentMarker;
-
-struct MarkerSubrange {
-    // Sorted by paint order
-    enum Type {
-        Unmarked,
-        GrammarError,
-        Correction,
-        SpellingError,
-        TextMatch,
-        DictationAlternatives,
-#if PLATFORM(IOS)
-        // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
-        DictationPhraseWithAlternatives,
-#endif
-        Selection,
-        DraggedContent,
-    };
-#if !COMPILER_SUPPORTS(NSDMI_FOR_AGGREGATES)
-    MarkerSubrange() = default;
-    MarkerSubrange(unsigned startOffset, unsigned endOffset, Type type, const RenderedDocumentMarker* marker = nullptr)
-        : startOffset { startOffset }
-        , endOffset { endOffset }
-        , type { type }
-        , marker { marker }
-    {
-    }
-#endif
-    unsigned startOffset;
-    unsigned endOffset;
-    Type type;
-    const RenderedDocumentMarker* marker { nullptr };
-
-    bool isEmpty() const { return endOffset <= startOffset; }
-    bool operator!=(const MarkerSubrange& other) const { return !(*this == other); }
-    bool operator==(const MarkerSubrange& other) const
-    {
-        return startOffset == other.startOffset && endOffset == other.endOffset && type == other.type && marker == other.marker;
-    }
-};
-
-enum class OverlapStrategy { None, Frontmost };
-WEBCORE_EXPORT Vector<MarkerSubrange> subdivide(const Vector<MarkerSubrange>&, OverlapStrategy = OverlapStrategy::None);
-
-}
-

Modified: trunk/Tools/ChangeLog (229078 => 229079)


--- trunk/Tools/ChangeLog	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Tools/ChangeLog	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1,3 +1,22 @@
+2018-02-27  Daniel Bates  <[email protected]>
+
+        Standardize terminology for marked text
+        https://bugs.webkit.org/show_bug.cgi?id=180999
+
+        Reviewed by Zalan Bujtas.
+
+        The name MarkerSubrange is a misnomer for a data structure that associates a text subrange with a type
+        and optional document marker. In particular, a MarkerSubrange may not always correspond to a document
+        marker. For instance, selected text is represented using a MarkerSubrange that does not have a
+        corresponding document marker. Let's standardize on the phrase "marked text" as the canonical way to
+        describe these tagged text subranges.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/MarkedText.cpp: Added.
+        (WebCore::operator<<):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/MarkerSubrange.cpp: Removed.
+
 2018-02-27  Aakash Jain  <[email protected]>
 
         webkitpy Bugzilla transactions should retry on URLError

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (229078 => 229079)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-02-27 22:35:47 UTC (rev 229079)
@@ -702,7 +702,7 @@
 		CDE195B51CFE0B880053D256 /* FullscreenTopContentInset.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */; };
 		CE06DF9B1E1851F200E570C9 /* SecurityOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */; };
 		CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
-		CE1866491F72E8F100A0CAB6 /* MarkerSubrange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE1866471F72E8F100A0CAB6 /* MarkerSubrange.cpp */; };
+		CE1866491F72E8F100A0CAB6 /* MarkedText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE1866471F72E8F100A0CAB6 /* MarkedText.cpp */; };
 		CE3524F81B1431F60028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */; };
 		CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */; };
 		CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */; };
@@ -1820,7 +1820,7 @@
 		CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenTopContentInset.mm; sourceTree = "<group>"; };
 		CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityOrigin.cpp; sourceTree = "<group>"; };
 		CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = "<group>"; };
-		CE1866471F72E8F100A0CAB6 /* MarkerSubrange.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MarkerSubrange.cpp; sourceTree = "<group>"; };
+		CE1866471F72E8F100A0CAB6 /* MarkedText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedText.cpp; sourceTree = "<group>"; };
 		CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillPerformClientRedirectToURLCrash.mm; sourceTree = "<group>"; };
 		CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing.cpp; sourceTree = "<group>"; };
 		CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing_Bundle.cpp; sourceTree = "<group>"; };
@@ -2275,7 +2275,7 @@
 				7A909A751D877475007E10F8 /* IntSize.cpp */,
 				14464012167A8305000BD218 /* LayoutUnit.cpp */,
 				076E507E1F45031E006E9F5A /* Logging.cpp */,
-				CE1866471F72E8F100A0CAB6 /* MarkerSubrange.cpp */,
+				CE1866471F72E8F100A0CAB6 /* MarkedText.cpp */,
 				A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */,
 				CD225C071C45A69200140761 /* ParsedContentRange.cpp */,
 				F418BE141F71B7DC001970E6 /* RoundedRectTests.cpp */,
@@ -3542,7 +3542,7 @@
 				46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,
 				7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */,
 				076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */,
-				CE1866491F72E8F100A0CAB6 /* MarkerSubrange.cpp in Sources */,
+				CE1866491F72E8F100A0CAB6 /* MarkedText.cpp in Sources */,
 				CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */,
 				CDC9442E1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm in Sources */,
 				7CCE7EB21A411A5100447C4C /* MemoryCacheAddImageToCacheIOS.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp (0 => 229079)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp	2018-02-27 22:35:47 UTC (rev 229079)
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "Test.h"
+#include <WebCore/MarkedText.h>
+#include <WebCore/RenderedDocumentMarker.h>
+
+using namespace WebCore;
+
+namespace WebCore {
+
+std::ostream& operator<<(std::ostream& os, MarkedText::Type type)
+{
+    switch (type) {
+    case MarkedText::Correction:
+        return os << "Correction";
+    case MarkedText::DictationAlternatives:
+        return os << "DictationAlternatives";
+#if PLATFORM(IOS)
+    // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
+    case MarkedText::DictationPhraseWithAlternatives:
+        return os << "DictationPhraseWithAlternatives";
+#endif
+    case MarkedText::DraggedContent:
+        return os << "DraggedContent";
+    case MarkedText::GrammarError:
+        return os << "GrammarError";
+    case MarkedText::Selection:
+        return os << "Selection";
+    case MarkedText::SpellingError:
+        return os << "SpellingError";
+    case MarkedText::TextMatch:
+        return os << "TextMatch";
+    case MarkedText::Unmarked:
+        return os << "Unmarked";
+    }
+}
+
+std::ostream& operator<<(std::ostream& os, const MarkedText& markedText)
+{
+    os << "(" << markedText.startOffset << ", " << markedText.endOffset << ", " << markedText.type;
+    if (markedText.marker)
+        os << static_cast<const void*>(markedText.marker);
+    return os << ")";
+}
+
+}
+
+namespace TestWebKitAPI {
+
+TEST(MarkedText, SubdivideEmpty)
+{
+    EXPECT_EQ(0U, subdivide({ }).size());
+    EXPECT_EQ(0U, subdivide({ }, OverlapStrategy::Frontmost).size());
+}
+
+TEST(MarkedText, SubdivideSimple)
+{
+    MarkedText markedText { 0, 9, MarkedText::SpellingError };
+    auto results = subdivide({ markedText });
+    ASSERT_EQ(1U, results.size());
+    EXPECT_EQ(markedText, results[0]);
+}
+
+TEST(MarkedText, SubdivideSpellingAndGrammarSimple)
+{
+    RenderedDocumentMarker grammarErrorMarker { DocumentMarker { DocumentMarker::Grammar, 7, 8 } };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { grammarErrorMarker.startOffset(), grammarErrorMarker.endOffset(), MarkedText::GrammarError, &grammarErrorMarker },
+        MarkedText { 22, 32, MarkedText::SpellingError },
+    };
+    auto results = subdivide(expectedMarkedTexts);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+TEST(MarkedText, SubdivideSpellingAndGrammarOverlap)
+{
+    Vector<MarkedText> markedTexts {
+        MarkedText { 0, 40, MarkedText::GrammarError },
+        MarkedText { 2, 17, MarkedText::SpellingError },
+        MarkedText { 20, 40, MarkedText::SpellingError },
+        MarkedText { 41, 45, MarkedText::SpellingError },
+    };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { 0, 2, MarkedText::GrammarError },
+        MarkedText { 2, 17, MarkedText::GrammarError },
+        MarkedText { 2, 17, MarkedText::SpellingError },
+        MarkedText { 17, 20, MarkedText::GrammarError },
+        MarkedText { 20, 40, MarkedText::GrammarError },
+        MarkedText { 20, 40, MarkedText::SpellingError },
+        MarkedText { 41, 45, MarkedText::SpellingError },
+    };
+    auto results = subdivide(markedTexts);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+TEST(MarkedText, SubdivideSpellingAndGrammarOverlapFrontmost)
+{
+    Vector<MarkedText> markedTexts {
+        MarkedText { 0, 40, MarkedText::GrammarError },
+        MarkedText { 2, 17, MarkedText::SpellingError },
+        MarkedText { 20, 40, MarkedText::SpellingError },
+        MarkedText { 41, 45, MarkedText::SpellingError },
+    };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { 0, 2, MarkedText::GrammarError },
+        MarkedText { 2, 17, MarkedText::SpellingError },
+        MarkedText { 17, 20, MarkedText::GrammarError },
+        MarkedText { 20, 40, MarkedText::SpellingError },
+        MarkedText { 41, 45, MarkedText::SpellingError },
+    };
+    auto results = subdivide(markedTexts, OverlapStrategy::Frontmost);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+TEST(MarkedText, SubdivideSpellingAndGrammarComplicatedFrontmost)
+{
+    Vector<MarkedText> markedTexts {
+        MarkedText { 0, 6, MarkedText::SpellingError },
+        MarkedText { 0, 46, MarkedText::GrammarError },
+        MarkedText { 7, 16, MarkedText::SpellingError },
+        MarkedText { 22, 27, MarkedText::SpellingError },
+        MarkedText { 34, 44, MarkedText::SpellingError },
+        MarkedText { 46, 50, MarkedText::SpellingError },
+        MarkedText { 51, 58, MarkedText::SpellingError },
+        MarkedText { 59, 63, MarkedText::GrammarError },
+    };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { 0, 6, MarkedText::SpellingError },
+        MarkedText { 6, 7, MarkedText::GrammarError },
+        MarkedText { 7, 16, MarkedText::SpellingError },
+        MarkedText { 16, 22, MarkedText::GrammarError },
+        MarkedText { 22, 27, MarkedText::SpellingError },
+        MarkedText { 27, 34, MarkedText::GrammarError },
+        MarkedText { 34, 44, MarkedText::SpellingError },
+        MarkedText { 44, 46, MarkedText::GrammarError },
+        MarkedText { 46, 50, MarkedText::SpellingError },
+        MarkedText { 51, 58, MarkedText::SpellingError },
+        MarkedText { 59, 63, MarkedText::GrammarError },
+    };
+    auto results = subdivide(markedTexts, OverlapStrategy::Frontmost);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+TEST(MarkedText, SubdivideGrammarAndSelectionOverlap)
+{
+    Vector<MarkedText> markedTexts {
+        MarkedText { 0, 40, MarkedText::GrammarError },
+        MarkedText { 2, 60, MarkedText::Selection },
+        MarkedText { 50, 60, MarkedText::GrammarError },
+    };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { 0, 2, MarkedText::GrammarError },
+        MarkedText { 2, 40, MarkedText::GrammarError },
+        MarkedText { 2, 40, MarkedText::Selection },
+        MarkedText { 40, 50, MarkedText::Selection },
+        MarkedText { 50, 60, MarkedText::GrammarError },
+        MarkedText { 50, 60, MarkedText::Selection },
+    };
+    auto results = subdivide(markedTexts);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+TEST(MarkedText, SubdivideGrammarAndSelectionOverlapFrontmost)
+{
+    Vector<MarkedText> markedTexts {
+        MarkedText { 0, 40, MarkedText::GrammarError },
+        MarkedText { 2, 60, MarkedText::Selection },
+        MarkedText { 50, 60, MarkedText::GrammarError },
+    };
+    Vector<MarkedText> expectedMarkedTexts {
+        MarkedText { 0, 2, MarkedText::GrammarError },
+        MarkedText { 2, 40, MarkedText::Selection },
+        MarkedText { 40, 50, MarkedText::Selection },
+        MarkedText { 50, 60, MarkedText::Selection },
+    };
+    auto results = subdivide(markedTexts, OverlapStrategy::Frontmost);
+    ASSERT_EQ(expectedMarkedTexts.size(), results.size());
+    for (size_t i = 0; i < expectedMarkedTexts.size(); ++i)
+        EXPECT_EQ(expectedMarkedTexts[i], results[i]);
+}
+
+}

Deleted: trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkerSubrange.cpp (229078 => 229079)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkerSubrange.cpp	2018-02-27 22:23:07 UTC (rev 229078)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkerSubrange.cpp	2018-02-27 22:35:47 UTC (rev 229079)
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Test.h"
-#include <WebCore/MarkerSubrange.h>
-#include <WebCore/RenderedDocumentMarker.h>
-
-using namespace WebCore;
-
-namespace WebCore {
-
-std::ostream& operator<<(std::ostream& os, MarkerSubrange::Type type)
-{
-    switch (type) {
-    case MarkerSubrange::Correction:
-        return os << "Correction";
-    case MarkerSubrange::DictationAlternatives:
-        return os << "DictationAlternatives";
-#if PLATFORM(IOS)
-    // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
-    case MarkerSubrange::DictationPhraseWithAlternatives:
-        return os << "DictationPhraseWithAlternatives";
-#endif
-    case MarkerSubrange::DraggedContent:
-        return os << "DraggedContent";
-    case MarkerSubrange::GrammarError:
-        return os << "GrammarError";
-    case MarkerSubrange::Selection:
-        return os << "Selection";
-    case MarkerSubrange::SpellingError:
-        return os << "SpellingError";
-    case MarkerSubrange::TextMatch:
-        return os << "TextMatch";
-    case MarkerSubrange::Unmarked:
-        return os << "Unmarked";
-    }
-}
-
-std::ostream& operator<<(std::ostream& os, const MarkerSubrange& subrange)
-{
-    os << "(" << subrange.startOffset << ", " << subrange.endOffset << ", " << subrange.type;
-    if (subrange.marker)
-        os << static_cast<const void*>(subrange.marker);
-    return os << ")";
-}
-
-}
-
-namespace TestWebKitAPI {
-
-TEST(MarkerSubrange, SubdivideEmpty)
-{
-    EXPECT_EQ(0U, subdivide({ }).size());
-    EXPECT_EQ(0U, subdivide({ }, OverlapStrategy::Frontmost).size());
-}
-
-TEST(MarkerSubrange, SubdivideSimple)
-{
-    MarkerSubrange subrange { 0, 9, MarkerSubrange::SpellingError };
-    auto results = subdivide({ subrange });
-    ASSERT_EQ(1U, results.size());
-    EXPECT_EQ(subrange, results[0]);
-}
-
-TEST(MarkerSubrange, SubdivideSpellingAndGrammarSimple)
-{
-    RenderedDocumentMarker grammarErrorMarker { DocumentMarker { DocumentMarker::Grammar, 7, 8 } };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { grammarErrorMarker.startOffset(), grammarErrorMarker.endOffset(), MarkerSubrange::GrammarError, &grammarErrorMarker },
-        MarkerSubrange { 22, 32, MarkerSubrange::SpellingError },
-    };
-    auto results = subdivide(expectedSubranges);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-TEST(MarkerSubrange, SubdivideSpellingAndGrammarOverlap)
-{
-    Vector<MarkerSubrange> subranges {
-        MarkerSubrange { 0, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 17, MarkerSubrange::SpellingError },
-        MarkerSubrange { 20, 40, MarkerSubrange::SpellingError },
-        MarkerSubrange { 41, 45, MarkerSubrange::SpellingError },
-    };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { 0, 2, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 17, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 17, MarkerSubrange::SpellingError },
-        MarkerSubrange { 17, 20, MarkerSubrange::GrammarError },
-        MarkerSubrange { 20, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 20, 40, MarkerSubrange::SpellingError },
-        MarkerSubrange { 41, 45, MarkerSubrange::SpellingError },
-    };
-    auto results = subdivide(subranges);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-TEST(MarkerSubrange, SubdivideSpellingAndGrammarOverlapFrontmost)
-{
-    Vector<MarkerSubrange> subranges {
-        MarkerSubrange { 0, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 17, MarkerSubrange::SpellingError },
-        MarkerSubrange { 20, 40, MarkerSubrange::SpellingError },
-        MarkerSubrange { 41, 45, MarkerSubrange::SpellingError },
-    };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { 0, 2, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 17, MarkerSubrange::SpellingError },
-        MarkerSubrange { 17, 20, MarkerSubrange::GrammarError },
-        MarkerSubrange { 20, 40, MarkerSubrange::SpellingError },
-        MarkerSubrange { 41, 45, MarkerSubrange::SpellingError },
-    };
-    auto results = subdivide(subranges, OverlapStrategy::Frontmost);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-TEST(MarkerSubrange, SubdivideSpellingAndGrammarComplicatedFrontmost)
-{
-    Vector<MarkerSubrange> subranges {
-        MarkerSubrange { 0, 6, MarkerSubrange::SpellingError },
-        MarkerSubrange { 0, 46, MarkerSubrange::GrammarError },
-        MarkerSubrange { 7, 16, MarkerSubrange::SpellingError },
-        MarkerSubrange { 22, 27, MarkerSubrange::SpellingError },
-        MarkerSubrange { 34, 44, MarkerSubrange::SpellingError },
-        MarkerSubrange { 46, 50, MarkerSubrange::SpellingError },
-        MarkerSubrange { 51, 58, MarkerSubrange::SpellingError },
-        MarkerSubrange { 59, 63, MarkerSubrange::GrammarError },
-    };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { 0, 6, MarkerSubrange::SpellingError },
-        MarkerSubrange { 6, 7, MarkerSubrange::GrammarError },
-        MarkerSubrange { 7, 16, MarkerSubrange::SpellingError },
-        MarkerSubrange { 16, 22, MarkerSubrange::GrammarError },
-        MarkerSubrange { 22, 27, MarkerSubrange::SpellingError },
-        MarkerSubrange { 27, 34, MarkerSubrange::GrammarError },
-        MarkerSubrange { 34, 44, MarkerSubrange::SpellingError },
-        MarkerSubrange { 44, 46, MarkerSubrange::GrammarError },
-        MarkerSubrange { 46, 50, MarkerSubrange::SpellingError },
-        MarkerSubrange { 51, 58, MarkerSubrange::SpellingError },
-        MarkerSubrange { 59, 63, MarkerSubrange::GrammarError },
-    };
-    auto results = subdivide(subranges, OverlapStrategy::Frontmost);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-TEST(MarkerSubrange, SubdivideGrammarAndSelectionOverlap)
-{
-    Vector<MarkerSubrange> subranges {
-        MarkerSubrange { 0, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 60, MarkerSubrange::Selection },
-        MarkerSubrange { 50, 60, MarkerSubrange::GrammarError },
-    };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { 0, 2, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 40, MarkerSubrange::Selection },
-        MarkerSubrange { 40, 50, MarkerSubrange::Selection },
-        MarkerSubrange { 50, 60, MarkerSubrange::GrammarError },
-        MarkerSubrange { 50, 60, MarkerSubrange::Selection },
-    };
-    auto results = subdivide(subranges);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-TEST(MarkerSubrange, SubdivideGrammarAndSelectionOverlapFrontmost)
-{
-    Vector<MarkerSubrange> subranges {
-        MarkerSubrange { 0, 40, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 60, MarkerSubrange::Selection },
-        MarkerSubrange { 50, 60, MarkerSubrange::GrammarError },
-    };
-    Vector<MarkerSubrange> expectedSubranges {
-        MarkerSubrange { 0, 2, MarkerSubrange::GrammarError },
-        MarkerSubrange { 2, 40, MarkerSubrange::Selection },
-        MarkerSubrange { 40, 50, MarkerSubrange::Selection },
-        MarkerSubrange { 50, 60, MarkerSubrange::Selection },
-    };
-    auto results = subdivide(subranges, OverlapStrategy::Frontmost);
-    ASSERT_EQ(expectedSubranges.size(), results.size());
-    for (size_t i = 0; i < expectedSubranges.size(); ++i)
-        EXPECT_EQ(expectedSubranges[i], results[i]);
-}
-
-}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to