Skip to content

Commit f1208f6

Browse files
committed
Remove some DocumentMarker.h includes
https://bugs.webkit.org/show_bug.cgi?id=283629 rdar://140476862 Reviewed by Timothy Hatcher. DocumentMarker.h ends up pulling in Node.h, which in turn pulls in JSC headers via EventTarget.h. Remove DocumentMarker.h includes by making it possible to forward-declare DocumentMarker::Type. In most compilation units, other files pull in EventTarget.h so this probably isn't yet a build time improvement. * Source/WebCore/dom/Document.cpp: (WebCore::Document::textInserted): * Source/WebCore/dom/DocumentMarker.h: (WebCore::DocumentMarker::DocumentMarker): (WebCore::DocumentMarker::type const): (WebCore::DocumentMarker::allMarkers): * Source/WebCore/dom/DocumentMarkerController.cpp: (WebCore::DocumentMarkerController::possiblyHasMarkers const): (WebCore::DocumentMarkerController::addMarker): (WebCore::DocumentMarkerController::addDraggedContentMarker): (WebCore::DocumentMarkerController::addTransparentContentMarker): (WebCore::DocumentMarkerController::removeMarkers): (WebCore::DocumentMarkerController::filterMarkers): (WebCore::DocumentMarkerController::updateRectsForInvalidatedMarkersOfType): (WebCore::DocumentMarkerController::renderedRectsForMarkers): (WebCore::shouldInsertAsSeparateMarker): (WebCore::canMergeMarkers): (WebCore::DocumentMarkerController::markerContainingPoint): (WebCore::DocumentMarkerController::markersFor const): (WebCore::DocumentMarkerController::forEach<DocumentMarkerController::IterationDirection::Forwards>): (WebCore::DocumentMarkerController::forEach<DocumentMarkerController::IterationDirection::Backwards>): (WebCore::DocumentMarkerController::forEachOfTypes): (WebCore::DocumentMarkerController::markersInRange): (WebCore::DocumentMarkerController::rangesForMarkersInRange): (WebCore::DocumentMarkerController::removeMarkersFromList): (WebCore::DocumentMarkerController::repaintMarkers): (WebCore::DocumentMarkerController::dismissMarkers): (WebCore::DocumentMarkerController::writingToolsTextSuggestionAnimationTimerFired): (WebCore::DocumentMarkerController::hasMarkers): (WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange): (WebCore::addMarker): (WebCore::removeMarkers): * Source/WebCore/dom/DocumentMarkerController.h: (WebCore::addMarker): * Source/WebCore/editing/AlternativeTextController.cpp: (WebCore::markerTypesForAppliedDictationAlternative): (WebCore::markerTypesForAutocorrection): (WebCore::markerTypesForReplacement): (WebCore::AlternativeTextController::isSpellingMarkerAllowed const): (WebCore::AlternativeTextController::respondToUnappliedSpellCorrection): (WebCore::AlternativeTextController::timerFired): (WebCore::AlternativeTextController::handleAlternativeTextUIResult): (WebCore::AlternativeTextController::respondToUnappliedEditing): (WebCore::AlternativeTextController::markReversed): (WebCore::AlternativeTextController::markCorrection): (WebCore::AlternativeTextController::recordSpellcheckerResponseForModifiedCorrection): (WebCore::AlternativeTextController::markPrecedingWhitespaceForDeletedAutocorrectionAfterCommand): (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult): (WebCore::AlternativeTextController::shouldStartTimerFor const): (WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): (WebCore::AlternativeTextController::markerDescriptionForAppliedAlternativeText): (WebCore::AlternativeTextController::applyAlternativeTextToRange): (WebCore::AlternativeTextController::removeCorrectionIndicatorMarkers): (WebCore::AlternativeTextController::applyDictationAlternative): * Source/WebCore/editing/AlternativeTextController.h: * Source/WebCore/editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection): * Source/WebCore/editing/DictationCommand.cpp: * Source/WebCore/editing/Editor.cpp: (WebCore::didApplyAutocorrection): (WebCore::adjustMarkerTypesToRemoveForWordsAffectedByEditing): (WebCore::Editor::ignoreSpelling): (WebCore::Editor::learnSpelling): (WebCore::Editor::advanceToNextMisspelling): (WebCore::Editor::clearMisspellingsAndBadGrammar): (WebCore::Editor::markMisspellingsAfterTypingToWord): (WebCore::Editor::markAndReplaceFor): (WebCore::Editor::changeBackToReplacedString): (WebCore::Editor::updateMarkersForWordsAffectedByEditing): (WebCore::Editor::countMatchesForText): (WebCore::Editor::setMarkedTextMatchesAreHighlighted): (WebCore::Editor::scanSelectionForTelephoneNumbers): (WebCore::Editor::editorUIUpdateTimerFired): (WebCore::Editor::selectionStartHasMarkerFor const): (WebCore::Editor::selectionStartSetMarkerForTesting): (WebCore::Editor::handleAcceptedCandidate): * Source/WebCore/editing/Editor.h: * Source/WebCore/editing/SpellChecker.cpp: (WebCore::SpellChecker::didCheckSucceed): * Source/WebCore/editing/TextCheckingHelper.cpp: (WebCore::TextCheckingHelper::findMisspelledWords const): (WebCore::TextCheckingHelper::findUngrammaticalPhrases const): * Source/WebCore/editing/ios/DictationCommandIOS.cpp: (WebCore::DictationCommandIOS::doApply): * Source/WebCore/editing/ios/EditorIOS.mm: (WebCore::Editor::setDictationPhrasesAsChildOfElement): * Source/WebCore/page/EventHandler.cpp: (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage): * Source/WebCore/page/IntelligenceTextEffectsSupport.cpp: (WebCore::IntelligenceTextEffectsSupport::writingToolsTextSuggestionRectsInRootViewCoordinates): (WebCore::IntelligenceTextEffectsSupport::updateTextVisibility): (WebCore::IntelligenceTextEffectsSupport::decorateWritingToolsTextReplacements): * Source/WebCore/page/Page.cpp: (WebCore::Page::unmarkAllTextMatches): * Source/WebCore/page/ios/FrameIOS.mm: (WebCore::LocalFrame::interpretationsForCurrentRoot const): * Source/WebCore/page/writing-tools/WritingToolsController.mm: (WebCore::WritingToolsController::proofreadingSessionDidReceiveSuggestions): (WebCore::WritingToolsController::proofreadingSessionDidUpdateStateForSuggestion): (WebCore::WritingToolsController::writingToolsSessionDidReceiveAction<WritingTools::Session::Type::Proofreading>): (WebCore::WritingToolsController::willEndWritingToolsSession<WritingTools::Session::Type::Proofreading>): (WebCore::WritingToolsController::findTextSuggestionMarkerByID const): (WebCore::WritingToolsController::findTextSuggestionMarkerContainingRange const): * Source/WebCore/rendering/HitTestResult.cpp: (WebCore::HitTestResult::spellingToolTip const): (WebCore::HitTestResult::replacedString const): (WebCore::HitTestResult::dictationAlternatives const): * Source/WebCore/rendering/MarkedText.cpp: (WebCore::MarkedText::collectForDocumentMarkers): (WebCore::MarkedText::collectForDraggedAndTransparentContent): * Source/WebCore/rendering/MarkedText.h: * Source/WebCore/rendering/RenderReplaced.cpp: (WebCore::contentContainsReplacedElement): (WebCore::RenderReplaced::paint): * Source/WebCore/rendering/RenderText.cpp: (WebCore::RenderText::contentRangesBetweenOffsetsForType const): * Source/WebCore/rendering/RenderText.h: * Source/WebCore/rendering/TextBoxPainter.cpp: (WebCore::TextBoxPainter::paintForegroundAndDecorations): (WebCore::TextBoxPainter::paintPlatformDocumentMarkers): * Source/WebCore/testing/Internals.cpp: (WebCore::markerTypeFrom): (WebCore::markerTypesFrom): (WebCore::Internals::markerCountForNode): (WebCore::Internals::dumpMarkerRects): (WebCore::Internals::hasMarkerFor): (WebCore::Internals::setMarkerFor): (WebCore::Internals::hasSpellingMarker): (WebCore::Internals::hasGrammarMarker): (WebCore::Internals::hasAutocorrectedMarker): (WebCore::Internals::hasDictationAlternativesMarker): (WebCore::Internals::hasCorrectionIndicatorMarker): (WebCore::Internals::hasWritingToolsTextSuggestionMarker): (WebCore::Internals::hasTransparentContentMarker): * Source/WebCore/testing/Internals.h: * Source/WebKit/WebProcess/WebPage/Cocoa/TextAnimationController.mm: (WebKit::TextAnimationController::removeTransparentMarkersForTextAnimationID): * Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: (WebKit::relevantMarkerTypes): (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): (WebKit::TextCheckingControllerProxy::removeAnnotationRelativeToSelection): (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::addDictationAlternative): (WebKit::WebPage::dictationAlternativesAtSelection): (WebKit::WebPage::clearDictationAlternatives): * Source/WebKit/WebProcess/WebPage/FindController.cpp: (WebKit::FindController::rectsForTextMatchesInRect): * Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp: (WebKit::WebFoundTextRangeController::decorateTextRangeWithStyle): (WebKit::WebFoundTextRangeController::rectsForTextMatchesInRect): * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::unmarkAllMisspellings): (WebKit::WebPage::unmarkAllBadGrammar): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::adjustCandidateAutocorrectionInFrame): (WebKit::WebPage::getPlatformEditorState const): (WebKit::WebPage::extendSelectionForReplacement): (WebKit::WebPage::requestDocumentEditingContext): * Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm: (-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]): (-[WebVisiblePosition enclosingRangeWithCorrectionIndicator]): * Source/WebKitLegacy/mac/WebView/WebFrame.mm: (-[WebFrame _unmarkAllBadGrammar]): (-[WebFrame _unmarkAllMisspellings]): (-[WebFrame getDictationResultRanges:andMetadatas:]): (-[WebFrame dictationResultMetadataForRange:]): * Source/WebKitLegacy/mac/WebView/WebHTMLView.mm: (-[WebHTMLView resignFirstResponder]): (-[WebHTMLView unmarkAllTextMatches]): (-[WebHTMLView rectsForTextMatches]): * Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp: (TestWebKitAPI::TEST(MarkedText, SubdivideSpellingAndGrammarSimple)): Canonical link: https://commits.webkit.org/287042@main
1 parent 997ee98 commit f1208f6

39 files changed

+358
-355
lines changed

Source/WebCore/dom/Document.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6203,7 +6203,7 @@ void Document::textInserted(Node& text, unsigned offset, unsigned length)
62036203

62046204
#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
62056205
// Freshly inserted text is expected to not inherit PlatformTextChecking markers.
6206-
m_markers->removeMarkers(text, { offset, offset + length }, DocumentMarker::Type::PlatformTextChecking);
6206+
m_markers->removeMarkers(text, { offset, offset + length }, DocumentMarkerType::PlatformTextChecking);
62076207
#endif
62086208
}
62096209

Source/WebCore/dom/DocumentMarker.h

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -51,61 +51,61 @@ template<> struct IsDeprecatedWeakRefSmartPointerException<WebCore::DocumentMark
5151

5252
namespace WebCore {
5353

54-
// A range of a node within a document that is "marked", such as the range of a misspelled word.
55-
// It optionally includes a description that could be displayed in the user interface.
56-
class DocumentMarker : public CanMakeWeakPtr<DocumentMarker> {
57-
public:
58-
enum class Type : uint32_t {
59-
Spelling = 1 << 0,
60-
Grammar = 1 << 1,
61-
TextMatch = 1 << 2,
62-
// Text has been modified by spell correction, reversion of spell correction or other type of substitution.
63-
// On some platforms, this prevents the text from being autocorrected again. On post Snow Leopard Mac OS X,
64-
// if a Replacement marker contains non-empty description, a reversion UI will be shown.
65-
Replacement = 1 << 3,
66-
// Renderer needs to add underline indicating that the text has been modified by spell
67-
// correction. Text with Replacement marker doesn't necessarily has CorrectionIndicator
68-
// marker. For instance, after some text has been corrected, it will have both Replacement
69-
// and CorrectionIndicator. However, if user further modifies such text, we would remove
70-
// CorrectionIndicator marker, but retain Replacement marker.
71-
CorrectionIndicator = 1 << 4,
72-
// Correction suggestion has been offered, but got rejected by user.
73-
RejectedCorrection = 1 << 5,
74-
// Text has been modified by autocorrection. The description of this marker is the original text before autocorrection.
75-
Autocorrected = 1 << 6,
76-
// On some platforms, this prevents the text from being spellchecked again.
77-
SpellCheckingExemption = 1 << 7,
78-
// This marker indicates user has deleted an autocorrection starting at the end of the
79-
// range that bears this marker. In some platforms, if the user later inserts the same original
80-
// word again at this position, it will not be autocorrected again. The description of this
81-
// marker is the original word before autocorrection was applied.
82-
DeletedAutocorrection = 1 << 8,
83-
// This marker indicates that the range of text spanned by the marker is entered by voice dictation,
84-
// and it has alternative text.
85-
DictationAlternatives = 1 << 9,
54+
enum class DocumentMarkerType : uint32_t {
55+
Spelling = 1 << 0,
56+
Grammar = 1 << 1,
57+
TextMatch = 1 << 2,
58+
// Text has been modified by spell correction, reversion of spell correction or other type of substitution.
59+
// On some platforms, this prevents the text from being autocorrected again. On post Snow Leopard Mac OS X,
60+
// if a Replacement marker contains non-empty description, a reversion UI will be shown.
61+
Replacement = 1 << 3,
62+
// Renderer needs to add underline indicating that the text has been modified by spell
63+
// correction. Text with Replacement marker doesn't necessarily has CorrectionIndicator
64+
// marker. For instance, after some text has been corrected, it will have both Replacement
65+
// and CorrectionIndicator. However, if user further modifies such text, we would remove
66+
// CorrectionIndicator marker, but retain Replacement marker.
67+
CorrectionIndicator = 1 << 4,
68+
// Correction suggestion has been offered, but got rejected by user.
69+
RejectedCorrection = 1 << 5,
70+
// Text has been modified by autocorrection. The description of this marker is the original text before autocorrection.
71+
Autocorrected = 1 << 6,
72+
// On some platforms, this prevents the text from being spellchecked again.
73+
SpellCheckingExemption = 1 << 7,
74+
// This marker indicates user has deleted an autocorrection starting at the end of the
75+
// range that bears this marker. In some platforms, if the user later inserts the same original
76+
// word again at this position, it will not be autocorrected again. The description of this
77+
// marker is the original word before autocorrection was applied.
78+
DeletedAutocorrection = 1 << 8,
79+
// This marker indicates that the range of text spanned by the marker is entered by voice dictation,
80+
// and it has alternative text.
81+
DictationAlternatives = 1 << 9,
8682
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
87-
TelephoneNumber = 1 << 10,
83+
TelephoneNumber = 1 << 10,
8884
#endif
8985
#if PLATFORM(IOS_FAMILY)
90-
// FIXME: iOS should share the same dictation mark system with the other platforms.
91-
DictationPhraseWithAlternatives = 1 << 11,
92-
DictationResult = 1 << 12,
86+
// FIXME: iOS should share the same dictation mark system with the other platforms.
87+
DictationPhraseWithAlternatives = 1 << 11,
88+
DictationResult = 1 << 12,
9389
#endif
94-
// This marker indicates that the user has selected a text candidate.
95-
AcceptedCandidate = 1 << 13,
96-
// This marker indicates that the user has initiated a drag with this content.
97-
DraggedContent = 1 << 14,
90+
// This marker indicates that the user has selected a text candidate.
91+
AcceptedCandidate = 1 << 13,
92+
// This marker indicates that the user has initiated a drag with this content.
93+
DraggedContent = 1 << 14,
9894
#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
99-
// This marker maintains state for the platform text checker.
100-
PlatformTextChecking = 1 << 15,
95+
// This marker maintains state for the platform text checker.
96+
PlatformTextChecking = 1 << 15,
10197
#endif
10298
#if ENABLE(WRITING_TOOLS)
103-
WritingToolsTextSuggestion = 1 << 16,
99+
WritingToolsTextSuggestion = 1 << 16,
104100
#endif
105-
TransparentContent = 1 << 17,
106-
};
101+
TransparentContent = 1 << 17,
102+
};
107103

108-
static constexpr OptionSet<Type> allMarkers();
104+
// A range of a node within a document that is "marked", such as the range of a misspelled word.
105+
// It optionally includes a description that could be displayed in the user interface.
106+
class DocumentMarker : public CanMakeWeakPtr<DocumentMarker> {
107+
public:
108+
static constexpr OptionSet<DocumentMarkerType> allMarkers();
109109

110110
struct DictationData {
111111
DictationContext context;
@@ -159,9 +159,9 @@ class DocumentMarker : public CanMakeWeakPtr<DocumentMarker> {
159159
, TransparentContentData // TransparentContent
160160
>;
161161

162-
DocumentMarker(Type, OffsetRange, Data&& = { });
162+
DocumentMarker(DocumentMarkerType, OffsetRange, Data&& = { });
163163

164-
Type type() const { return m_type; }
164+
DocumentMarkerType type() const { return m_type; }
165165
unsigned startOffset() const { return m_range.start; }
166166
unsigned endOffset() const { return m_range.end; }
167167

@@ -177,44 +177,44 @@ class DocumentMarker : public CanMakeWeakPtr<DocumentMarker> {
177177
void shiftOffsets(int delta);
178178

179179
private:
180-
Type m_type;
180+
DocumentMarkerType m_type;
181181
OffsetRange m_range;
182182
Data m_data;
183183
};
184184

185-
constexpr auto DocumentMarker::allMarkers() -> OptionSet<Type>
185+
constexpr auto DocumentMarker::allMarkers() -> OptionSet<DocumentMarkerType>
186186
{
187187
return {
188-
Type::AcceptedCandidate,
189-
Type::Autocorrected,
190-
Type::CorrectionIndicator,
191-
Type::DeletedAutocorrection,
192-
Type::DictationAlternatives,
193-
Type::DraggedContent,
194-
Type::Grammar,
195-
Type::RejectedCorrection,
196-
Type::Replacement,
197-
Type::SpellCheckingExemption,
198-
Type::Spelling,
199-
Type::TextMatch,
188+
DocumentMarkerType::AcceptedCandidate,
189+
DocumentMarkerType::Autocorrected,
190+
DocumentMarkerType::CorrectionIndicator,
191+
DocumentMarkerType::DeletedAutocorrection,
192+
DocumentMarkerType::DictationAlternatives,
193+
DocumentMarkerType::DraggedContent,
194+
DocumentMarkerType::Grammar,
195+
DocumentMarkerType::RejectedCorrection,
196+
DocumentMarkerType::Replacement,
197+
DocumentMarkerType::SpellCheckingExemption,
198+
DocumentMarkerType::Spelling,
199+
DocumentMarkerType::TextMatch,
200200
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
201-
Type::TelephoneNumber,
201+
DocumentMarkerType::TelephoneNumber,
202202
#endif
203203
#if PLATFORM(IOS_FAMILY)
204-
Type::DictationPhraseWithAlternatives,
205-
Type::DictationResult,
204+
DocumentMarkerType::DictationPhraseWithAlternatives,
205+
DocumentMarkerType::DictationResult,
206206
#endif
207207
#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
208-
Type::PlatformTextChecking,
208+
DocumentMarkerType::PlatformTextChecking,
209209
#endif
210210
#if ENABLE(WRITING_TOOLS)
211-
Type::WritingToolsTextSuggestion,
211+
DocumentMarkerType::WritingToolsTextSuggestion,
212212
#endif
213-
Type::TransparentContent,
213+
DocumentMarkerType::TransparentContent,
214214
};
215215
}
216216

217-
inline DocumentMarker::DocumentMarker(Type type, OffsetRange range, Data&& data)
217+
inline DocumentMarker::DocumentMarker(DocumentMarkerType type, OffsetRange range, Data&& data)
218218
: m_type(type)
219219
, m_range(range)
220220
, m_data(WTFMove(data))

0 commit comments

Comments
 (0)