Diff
Modified: trunk/Source/WebCore/ChangeLog (219596 => 219597)
--- trunk/Source/WebCore/ChangeLog 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/ChangeLog 2017-07-18 02:43:07 UTC (rev 219597)
@@ -1,3 +1,73 @@
+2017-07-17 Daniel Bates <[email protected]>
+
+ Cleanup: Use OptionSet to represent marker types
+ https://bugs.webkit.org/show_bug.cgi?id=174594
+
+ Reviewed by Darin Adler.
+
+ Remove class DocumentMarker::MarkerTypes that duplicates most of functionality of OptionSet
+ and use OptionSet directly to represent a set of marker types.
+
+ No functionality changed. So, no new tests.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateLayout):
+ * dom/DocumentMarker.h:
+ (WebCore::DocumentMarker::MarkerTypes::MarkerTypes): Deleted.
+ (WebCore::DocumentMarker::MarkerTypes::contains): Deleted.
+ (WebCore::DocumentMarker::MarkerTypes::intersects): Deleted.
+ (WebCore::DocumentMarker::MarkerTypes::operator==): Deleted.
+ (WebCore::DocumentMarker::MarkerTypes::add): Deleted.
+ (WebCore::DocumentMarker::MarkerTypes::remove): Deleted.
+ (WebCore::DocumentMarker::AllMarkers::AllMarkers): Deleted.
+ * dom/DocumentMarkerController.cpp:
+ (WebCore::DocumentMarkerController::possiblyHasMarkers):
+ (WebCore::DocumentMarkerController::detach):
+ (WebCore::DocumentMarkerController::removeMarkers):
+ (WebCore::DocumentMarkerController::addMarker):
+ (WebCore::DocumentMarkerController::copyMarkers):
+ (WebCore::DocumentMarkerController::markersFor):
+ (WebCore::DocumentMarkerController::markersInRange):
+ (WebCore::DocumentMarkerController::removeMarkersFromList):
+ (WebCore::DocumentMarkerController::repaintMarkers):
+ (WebCore::DocumentMarkerController::shiftMarkers):
+ (DocumentMarkerController::setMarkersActive):
+ (DocumentMarkerController::hasMarkers):
+ (DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
+ Update code as needed.
+
+ * dom/DocumentMarkerController.h:
+ (WebCore::DocumentMarkerController::hasMarkers):
+ Update code as needed.
+
+ * editing/AlternativeTextController.cpp:
+ (WebCore::markerTypesForAutocorrection):
+ (WebCore::markerTypesForReplacement):
+ (WebCore::markerTypesForAppliedDictationAlternative):
+ Marked as inline and returns an OptionSet<DocumentMarker::MarkerType>. It is unnecessary to use NeverDestroyed
+ in these functions as constructing an OptionSet and copying/moving it is very efficient. Such operations are
+ effectively equivalent to an integral assignment and copy of an integral value, respectively.
+
+ (WebCore::AlternativeTextController::applyAlternativeTextToRange):
+ (WebCore::AlternativeTextController::respondToUnappliedSpellCorrection):
+ (WebCore::AlternativeTextController::markCorrection):
+ Update code as needed.
+
+ * editing/AlternativeTextController.h: While I am here, remove some unnecessary #includes and group
+ forward declarations of structs.
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers): Update code as needed.
+ * editing/Editor.cpp:
+ (WebCore::Editor::updateMarkersForWordsAffectedByEditing): Ditto.
+ * editing/SpellChecker.cpp:
+ (WebCore::SpellChecker::didCheckSucceed): Ditto.
+ * page/ios/FrameIOS.mm:
+ (WebCore::Frame::interpretationsForCurrentRoot): Ditto.
+ * testing/Internals.cpp:
+ (WebCore::markerTypesFrom): Ditto.
+ (WebCore::Internals::markerCountForNode): Ditto.
+ (WebCore::Internals::markerAt): Ditto.
+
2017-07-17 Devin Rousso <[email protected]>
Web Inspector: overlay page highlight doesn't disappear when a page is constantly updating
Modified: trunk/Source/WebCore/dom/DocumentMarker.h (219596 => 219597)
--- trunk/Source/WebCore/dom/DocumentMarker.h 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/dom/DocumentMarker.h 2017-07-18 02:43:07 UTC (rev 219597)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@
#include "Node.h"
#include <wtf/Forward.h>
+#include <wtf/OptionSet.h>
#include <wtf/Variant.h>
#include <wtf/text/WTFString.h>
@@ -81,50 +82,8 @@
DraggedContent = 1 << 14
};
- class MarkerTypes {
- public:
- // This constructor is left implicit to allow conversion from result of a bit-wise or of enumeration values.
- MarkerTypes(unsigned mask) : m_mask(mask) { }
+ static OptionSet<MarkerType> allMarkers();
- bool contains(MarkerType type) const { return m_mask & type; }
- bool intersects(MarkerTypes types) const { return m_mask & types.m_mask; }
- bool operator==(MarkerTypes other) const { return m_mask == other.m_mask; }
-
- void add(MarkerTypes types) { m_mask |= types.m_mask; }
- void remove(MarkerTypes types) { m_mask &= ~types.m_mask; }
-
- private:
- unsigned m_mask;
- };
-
- class AllMarkers : public MarkerTypes {
- public:
- AllMarkers()
- : MarkerTypes(0
- | AcceptedCandidate
- | Autocorrected
- | CorrectionIndicator
- | DeletedAutocorrection
- | DictationAlternatives
- | Grammar
- | RejectedCorrection
- | Replacement
- | SpellCheckingExemption
- | Spelling
- | TextMatch
-#if ENABLE(TELEPHONE_NUMBER_DETECTION)
- | TelephoneNumber
-#endif
-#if PLATFORM(IOS)
- | DictationPhraseWithAlternatives
- | DictationResult
-#endif
- | DraggedContent
- )
- {
- }
- };
-
using IsActiveMatchData = bool;
using DescriptionData = String;
struct DictationData {
@@ -181,6 +140,32 @@
Data m_data;
};
+inline auto DocumentMarker::allMarkers() -> OptionSet<MarkerType>
+{
+ OptionSet<MarkerType> markers {
+ AcceptedCandidate,
+ Autocorrected,
+ CorrectionIndicator,
+ DeletedAutocorrection,
+ DictationAlternatives,
+ DraggedContent,
+ Grammar,
+ RejectedCorrection,
+ Replacement,
+ SpellCheckingExemption,
+ Spelling,
+ TextMatch,
+#if ENABLE(TELEPHONE_NUMBER_DETECTION)
+ TelephoneNumber,
+#endif
+#if PLATFORM(IOS)
+ DictationPhraseWithAlternatives,
+ DictationResult,
+#endif
+ };
+ return markers;
+}
+
inline DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool isActiveMatch)
: m_type(TextMatch)
, m_startOffset(startOffset)
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.cpp (219596 => 219597)
--- trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -42,9 +42,9 @@
namespace WebCore {
-inline bool DocumentMarkerController::possiblyHasMarkers(DocumentMarker::MarkerTypes types)
+inline bool DocumentMarkerController::possiblyHasMarkers(OptionSet<DocumentMarker::MarkerType> types)
{
- return m_possiblyExistingMarkerTypes.intersects(types);
+ return m_possiblyExistingMarkerTypes.contains(types);
}
DocumentMarkerController::DocumentMarkerController(Document& document)
@@ -59,7 +59,7 @@
void DocumentMarkerController::detach()
{
m_markers.clear();
- m_possiblyExistingMarkerTypes = 0;
+ m_possiblyExistingMarkerTypes = { };
}
void DocumentMarkerController::addMarker(Range* range, DocumentMarker::MarkerType type, const String& description)
@@ -144,7 +144,7 @@
}
}
-void DocumentMarkerController::removeMarkers(Range* range, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMarkerOrNot shouldRemovePartiallyOverlappingMarker)
+void DocumentMarkerController::removeMarkers(Range* range, OptionSet<DocumentMarker::MarkerType> markerTypes, RemovePartiallyOverlappingMarkerOrNot shouldRemovePartiallyOverlappingMarker)
{
for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) {
if (!possiblyHasMarkers(markerTypes))
@@ -333,7 +333,7 @@
downcast<RenderBlockFlow>(*renderer).ensureLineBoxes();
}
- m_possiblyExistingMarkerTypes.add(newMarker.type());
+ m_possiblyExistingMarkerTypes |= newMarker.type();
std::unique_ptr<MarkerList>& list = m_markers.add(node, nullptr).iterator->value;
@@ -403,7 +403,7 @@
if (length <= 0)
return;
- if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
+ if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
return;
ASSERT(!m_markers.isEmpty());
@@ -437,7 +437,7 @@
dstNode->renderer()->repaint();
}
-void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, int length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMarkerOrNot shouldRemovePartiallyOverlappingMarker)
+void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, int length, OptionSet<DocumentMarker::MarkerType> markerTypes, RemovePartiallyOverlappingMarkerOrNot shouldRemovePartiallyOverlappingMarker)
{
if (length <= 0)
return;
@@ -495,7 +495,7 @@
if (list->isEmpty()) {
m_markers.remove(node);
if (m_markers.isEmpty())
- m_possiblyExistingMarkerTypes = 0;
+ m_possiblyExistingMarkerTypes = { };
}
if (docDirty && node->renderer())
@@ -523,7 +523,7 @@
return nullptr;
}
-Vector<RenderedDocumentMarker*> DocumentMarkerController::markersFor(Node* node, DocumentMarker::MarkerTypes markerTypes)
+Vector<RenderedDocumentMarker*> DocumentMarkerController::markersFor(Node* node, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return { };
@@ -541,7 +541,7 @@
return result;
}
-Vector<RenderedDocumentMarker*> DocumentMarkerController::markersInRange(Range& range, DocumentMarker::MarkerTypes markerTypes)
+Vector<RenderedDocumentMarker*> DocumentMarkerController::markersInRange(Range& range, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return Vector<RenderedDocumentMarker*>();
@@ -566,7 +566,7 @@
return foundMarkers;
}
-void DocumentMarkerController::removeMarkers(Node* node, DocumentMarker::MarkerTypes markerTypes)
+void DocumentMarkerController::removeMarkers(Node* node, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return;
@@ -577,7 +577,7 @@
removeMarkersFromList(iterator, markerTypes);
}
-void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerTypes)
+void DocumentMarkerController::removeMarkers(OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return;
@@ -591,15 +591,15 @@
removeMarkersFromList(iterator, markerTypes);
}
- m_possiblyExistingMarkerTypes.remove(markerTypes);
+ m_possiblyExistingMarkerTypes -= markerTypes;
}
-void DocumentMarkerController::removeMarkersFromList(MarkerMap::iterator iterator, DocumentMarker::MarkerTypes markerTypes)
+void DocumentMarkerController::removeMarkersFromList(MarkerMap::iterator iterator, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
bool needsRepainting = false;
bool listCanBeRemoved;
- if (markerTypes == DocumentMarker::AllMarkers()) {
+ if (markerTypes == DocumentMarker::allMarkers()) {
needsRepainting = true;
listCanBeRemoved = true;
} else {
@@ -631,11 +631,11 @@
if (listCanBeRemoved) {
m_markers.remove(iterator);
if (m_markers.isEmpty())
- m_possiblyExistingMarkerTypes = 0;
+ m_possiblyExistingMarkerTypes = { };
}
}
-void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes markerTypes)
+void DocumentMarkerController::repaintMarkers(OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return;
@@ -665,7 +665,7 @@
void DocumentMarkerController::shiftMarkers(Node* node, unsigned startOffset, int delta)
{
- if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
+ if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
return;
ASSERT(!m_markers.isEmpty());
@@ -716,7 +716,7 @@
void DocumentMarkerController::setMarkersActive(Range* range, bool active)
{
- if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
+ if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
return;
ASSERT(!m_markers.isEmpty());
@@ -756,7 +756,7 @@
node->renderer()->repaint();
}
-bool DocumentMarkerController::hasMarkers(Range& range, DocumentMarker::MarkerTypes markerTypes)
+bool DocumentMarkerController::hasMarkers(Range& range, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return false;
@@ -780,7 +780,7 @@
return false;
}
-void DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange(Range& range, DocumentMarker::MarkerTypes markerTypes)
+void DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange(Range& range, OptionSet<DocumentMarker::MarkerType> markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
return;
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.h (219596 => 219597)
--- trunk/Source/WebCore/dom/DocumentMarkerController.h 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.h 2017-07-18 02:43:07 UTC (rev 219597)
@@ -63,28 +63,28 @@
void copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta);
bool hasMarkers() const
{
- ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.intersects(DocumentMarker::AllMarkers()));
+ ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.contains(DocumentMarker::allMarkers()));
return !m_markers.isEmpty();
}
- bool hasMarkers(Range&, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
+ bool hasMarkers(Range&, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
// When a marker partially overlaps with range, if removePartiallyOverlappingMarkers is true, we completely
// remove the marker. If the argument is false, we will adjust the span of the marker so that it retains
// the portion that is outside of the range.
enum RemovePartiallyOverlappingMarkerOrNot { DoNotRemovePartiallyOverlappingMarker, RemovePartiallyOverlappingMarker };
- void removeMarkers(Range*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
- void removeMarkers(Node*, unsigned startOffset, int length, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
+ void removeMarkers(Range*, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
+ void removeMarkers(Node*, unsigned startOffset, int length, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePartiallyOverlappingMarker);
- WEBCORE_EXPORT void removeMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
- void removeMarkers(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
- void repaintMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
+ WEBCORE_EXPORT void removeMarkers(OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
+ void removeMarkers(Node*, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
+ void repaintMarkers(OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
void shiftMarkers(Node*, unsigned startOffset, int delta);
void setMarkersActive(Range*, bool);
void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
- WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersFor(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
- WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersInRange(Range&, DocumentMarker::MarkerTypes);
- void clearDescriptionOnMarkersIntersectingRange(Range&, DocumentMarker::MarkerTypes);
+ WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersFor(Node*, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
+ WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersInRange(Range&, OptionSet<DocumentMarker::MarkerType>);
+ void clearDescriptionOnMarkersIntersectingRange(Range&, OptionSet<DocumentMarker::MarkerType>);
WEBCORE_EXPORT void updateRectsForInvalidatedMarkersOfType(DocumentMarker::MarkerType);
@@ -103,12 +103,12 @@
typedef Vector<RenderedDocumentMarker> MarkerList;
typedef HashMap<RefPtr<Node>, std::unique_ptr<MarkerList>> MarkerMap;
- bool possiblyHasMarkers(DocumentMarker::MarkerTypes);
- void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes);
+ bool possiblyHasMarkers(OptionSet<DocumentMarker::MarkerType>);
+ void removeMarkersFromList(MarkerMap::iterator, OptionSet<DocumentMarker::MarkerType>);
MarkerMap m_markers;
// Provide a quick way to determine whether a particular marker type is absent without going through the map.
- DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes { 0 };
+ OptionSet<DocumentMarker::MarkerType> m_possiblyExistingMarkerTypes;
Document& m_document;
};
Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (219596 => 219597)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -45,7 +45,6 @@
#include "TextIterator.h"
#include "VisibleUnits.h"
#include "markup.h"
-#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -84,32 +83,19 @@
#if USE(AUTOCORRECTION_PANEL)
-static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection()
+static inline OptionSet<DocumentMarker::MarkerType> markerTypesForAutocorrection()
{
- static const auto markerTypesForAutoCorrection = makeNeverDestroyed(Vector<DocumentMarker::MarkerType> {
- DocumentMarker::Autocorrected,
- DocumentMarker::CorrectionIndicator,
- DocumentMarker::Replacement,
- DocumentMarker::SpellCheckingExemption,
- });
- return markerTypesForAutoCorrection;
+ return { DocumentMarker::Autocorrected, DocumentMarker::CorrectionIndicator, DocumentMarker::Replacement, DocumentMarker::SpellCheckingExemption };
}
-static const Vector<DocumentMarker::MarkerType>& markerTypesForReplacement()
+static inline OptionSet<DocumentMarker::MarkerType> markerTypesForReplacement()
{
- static const auto markerTypesForReplacement = makeNeverDestroyed(Vector<DocumentMarker::MarkerType> {
- DocumentMarker::Replacement,
- DocumentMarker::SpellCheckingExemption,
- });
- return markerTypesForReplacement;
+ return { DocumentMarker::Replacement, DocumentMarker::SpellCheckingExemption };
}
-static const Vector<DocumentMarker::MarkerType>& markerTypesForAppliedDictationAlternative()
+static inline OptionSet<DocumentMarker::MarkerType> markerTypesForAppliedDictationAlternative()
{
- static const auto markerTypesForAppliedDictationAlternative = makeNeverDestroyed(Vector<DocumentMarker::MarkerType> {
- DocumentMarker::SpellCheckingExemption,
- });
- return markerTypesForAppliedDictationAlternative;
+ return DocumentMarker::SpellCheckingExemption;
}
static bool markersHaveIdenticalDescription(const Vector<RenderedDocumentMarker*>& markers)
@@ -235,7 +221,7 @@
return String();
}
-void AlternativeTextController::applyAlternativeTextToRange(const Range& range, const String& alternative, AlternativeTextType alternativeType, const Vector<DocumentMarker::MarkerType>& markerTypesToAdd)
+void AlternativeTextController::applyAlternativeTextToRange(const Range& range, const String& alternative, AlternativeTextType alternativeType, OptionSet<DocumentMarker::MarkerType> markerTypesToAdd)
{
auto paragraphRangeContainingCorrection = range.cloneRange();
@@ -281,7 +267,7 @@
DocumentMarkerController& markers = replacementRange->startContainer().document().markers();
- for (auto& markerType : markerTypesToAdd)
+ for (auto markerType : markerTypesToAdd)
markers.addMarker(replacementRange.get(), markerType, markerDescriptionForAppliedAlternativeText(alternativeType, markerType));
}
@@ -317,7 +303,7 @@
RefPtr<Range> range = Range::create(*m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end());
DocumentMarkerController& markers = m_frame.document()->markers();
- markers.removeMarkers(range.get(), DocumentMarker::Spelling | DocumentMarker::Autocorrected, DocumentMarkerController::RemovePartiallyOverlappingMarker);
+ markers.removeMarkers(range.get(), OptionSet<DocumentMarker::MarkerType> { DocumentMarker::Spelling, DocumentMarker::Autocorrected }, DocumentMarkerController::RemovePartiallyOverlappingMarker);
markers.addMarker(range.get(), DocumentMarker::Replacement);
markers.addMarker(range.get(), DocumentMarker::SpellCheckingExemption);
}
@@ -526,7 +512,7 @@
void AlternativeTextController::markCorrection(Range& replacedRange, const String& replacedString)
{
DocumentMarkerController& markers = replacedRange.startContainer().document().markers();
- for (auto& markerType : markerTypesForAutocorrection()) {
+ for (auto markerType : markerTypesForAutocorrection()) {
if (markerType == DocumentMarker::Replacement || markerType == DocumentMarker::Autocorrected)
markers.addMarker(&replacedRange, markerType, replacedString);
else
Modified: trunk/Source/WebCore/editing/AlternativeTextController.h (219596 => 219597)
--- trunk/Source/WebCore/editing/AlternativeTextController.h 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/editing/AlternativeTextController.h 2017-07-18 02:43:07 UTC (rev 219597)
@@ -27,11 +27,8 @@
#include "AlternativeTextClient.h"
#include "DocumentMarker.h"
-#include "FrameSelection.h"
#include "Range.h"
-#include "TextChecking.h"
#include "Timer.h"
-#include "VisibleSelection.h"
#include <wtf/Noncopyable.h>
namespace WebCore {
@@ -43,7 +40,10 @@
class Event;
class Frame;
class TextCheckerClient;
+class VisibleSelection;
+
struct DictationAlternative;
+struct TextCheckingResult;
class AlternativeTextDetails : public RefCounted<AlternativeTextDetails> {
public:
@@ -58,8 +58,6 @@
RefPtr<AlternativeTextDetails> details;
};
-struct TextCheckingResult;
-
#if USE(AUTOCORRECTION_PANEL)
// These backslashes are for making style checker happy.
#define UNLESS_ENABLED(functionBody) \
@@ -117,7 +115,7 @@
private:
#if USE(AUTOCORRECTION_PANEL)
String dismissSoon(ReasonForDismissingAlternativeText);
- void applyAlternativeTextToRange(const Range&, const String& alternative, AlternativeTextType, const Vector<DocumentMarker::MarkerType>&);
+ void applyAlternativeTextToRange(const Range&, const String& alternative, AlternativeTextType, OptionSet<DocumentMarker::MarkerType>);
void timerFired();
void recordSpellcheckerResponseForModifiedCorrection(Range& rangeOfCorrection, const String& corrected, const String& correction);
String markerDescriptionForAppliedAlternativeText(AlternativeTextType, DocumentMarker::MarkerType);
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (219596 => 219597)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -766,7 +766,7 @@
{
Ref<Text> protectedNode(node);
DocumentMarkerController& markerController = document().markers();
- auto markers = copyMarkers(markerController.markersInRange(Range::create(document(), &node, offset, &node, offset + count), DocumentMarker::AllMarkers()));
+ auto markers = copyMarkers(markerController.markersInRange(Range::create(document(), &node, offset, &node, offset + count), DocumentMarker::allMarkers()));
replaceTextInNode(node, offset, count, replacementText);
RefPtr<Range> newRange = Range::create(document(), &node, offset, &node, offset + replacementText.length());
for (const auto& marker : markers)
Modified: trunk/Source/WebCore/editing/Editor.cpp (219596 => 219597)
--- trunk/Source/WebCore/editing/Editor.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/editing/Editor.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -2782,11 +2782,16 @@
for (auto* marker : markers)
m_alternativeTextController->removeDictationAlternativesForMarker(*marker);
-#if PLATFORM(IOS)
- document().markers().removeMarkers(wordRange.ptr(), DocumentMarker::Spelling | DocumentMarker::CorrectionIndicator | DocumentMarker::SpellCheckingExemption | DocumentMarker::DictationAlternatives | DocumentMarker::DictationPhraseWithAlternatives, DocumentMarkerController::RemovePartiallyOverlappingMarker);
-#else
- document().markers().removeMarkers(wordRange.ptr(), DocumentMarker::Spelling | DocumentMarker::Grammar | DocumentMarker::CorrectionIndicator | DocumentMarker::SpellCheckingExemption | DocumentMarker::DictationAlternatives, DocumentMarkerController::RemovePartiallyOverlappingMarker);
+ OptionSet<DocumentMarker::MarkerType> markerTypesToRemove {
+ DocumentMarker::CorrectionIndicator,
+ DocumentMarker::DictationAlternatives,
+ DocumentMarker::SpellCheckingExemption,
+ DocumentMarker::Spelling,
+#if !PLATFORM(IOS)
+ DocumentMarker::Grammar,
#endif
+ };
+ document().markers().removeMarkers(wordRange.ptr(), markerTypesToRemove, DocumentMarkerController::RemovePartiallyOverlappingMarker);
document().markers().clearDescriptionOnMarkersIntersectingRange(wordRange, DocumentMarker::Replacement);
}
Modified: trunk/Source/WebCore/editing/SpellChecker.cpp (219596 => 219597)
--- trunk/Source/WebCore/editing/SpellChecker.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/editing/SpellChecker.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -217,13 +217,13 @@
{
TextCheckingRequestData requestData = m_processingRequest->data();
if (requestData.sequence() == sequence) {
- unsigned markers = 0;
+ OptionSet<DocumentMarker::MarkerType> markerTypes;
if (requestData.mask() & TextCheckingTypeSpelling)
- markers |= DocumentMarker::Spelling;
+ markerTypes |= DocumentMarker::Spelling;
if (requestData.mask() & TextCheckingTypeGrammar)
- markers |= DocumentMarker::Grammar;
- if (markers)
- m_frame.document()->markers().removeMarkers(&m_processingRequest->checkingRange(), markers);
+ markerTypes |= DocumentMarker::Grammar;
+ if (!markerTypes.isEmpty())
+ m_frame.document()->markers().removeMarkers(&m_processingRequest->checkingRange(), markerTypes);
}
didCheck(sequence, results);
}
Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (219596 => 219597)
--- trunk/Source/WebCore/page/ios/FrameIOS.mm 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm 2017-07-18 02:43:07 UTC (rev 219597)
@@ -652,7 +652,7 @@
Node* pastLastNode = rangeOfRootContents->pastLastNode();
for (Node* node = rangeOfRootContents->firstNode(); node != pastLastNode; node = NodeTraversal::next(*node)) {
- for (auto* marker : document()->markers().markersFor(node, DocumentMarker::MarkerTypes(DocumentMarker::DictationPhraseWithAlternatives))) {
+ for (auto* marker : document()->markers().markersFor(node, DocumentMarker::DictationPhraseWithAlternatives)) {
// First, add text that precede the marker.
if (precedingTextStartPosition != createLegacyEditingPosition(node, marker->startOffset())) {
RefPtr<Range> precedingTextRange = Range::create(*document(), precedingTextStartPosition, createLegacyEditingPosition(node, marker->startOffset()));
Modified: trunk/Source/WebCore/testing/Internals.cpp (219596 => 219597)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-07-18 02:43:07 UTC (rev 219597)
@@ -361,12 +361,12 @@
return true;
}
-static bool markerTypesFrom(const String& markerType, DocumentMarker::MarkerTypes& result)
+static bool markerTypesFrom(const String& markerType, OptionSet<DocumentMarker::MarkerType>& result)
{
DocumentMarker::MarkerType singularResult;
if (markerType.isEmpty() || equalLettersIgnoringASCIICase(markerType, "all"))
- result = DocumentMarker::AllMarkers();
+ result = DocumentMarker::allMarkers();
else if (markerTypeFrom(markerType, singularResult))
result = singularResult;
else
@@ -1391,7 +1391,7 @@
ExceptionOr<unsigned> Internals::markerCountForNode(Node& node, const String& markerType)
{
- DocumentMarker::MarkerTypes markerTypes = 0;
+ OptionSet<DocumentMarker::MarkerType> markerTypes;
if (!markerTypesFrom(markerType, markerTypes))
return Exception { SYNTAX_ERR };
@@ -1403,7 +1403,7 @@
{
node.document().updateLayoutIgnorePendingStylesheets();
- DocumentMarker::MarkerTypes markerTypes = 0;
+ OptionSet<DocumentMarker::MarkerType> markerTypes;
if (!markerTypesFrom(markerType, markerTypes))
return Exception { SYNTAX_ERR };
Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (219596 => 219597)
--- trunk/Source/WebKitLegacy/ios/ChangeLog 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog 2017-07-18 02:43:07 UTC (rev 219597)
@@ -1,3 +1,19 @@
+2017-07-17 Daniel Bates <[email protected]>
+
+ Cleanup: Use OptionSet to represent marker types
+ https://bugs.webkit.org/show_bug.cgi?id=174594
+
+ Reviewed by Darin Adler.
+
+ Remove class DocumentMarker::MarkerTypes that duplicates most of functionality of OptionSet
+ and use OptionSet directly to represent a set of marker types.
+
+ No functionality changed. So, no new tests.
+
+ * WebCoreSupport/WebVisiblePosition.mm:
+ (-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]): Update code as needed.
+ (-[WebVisiblePosition enclosingRangeWithCorrectionIndicator]): Ditto.
+
2017-07-12 Daniel Bates <[email protected]>
Rename NavigationInitiatedByMainFrame to InitiatedByMainFrame
Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm (219596 => 219597)
--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm 2017-07-18 02:00:50 UTC (rev 219596)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm 2017-07-18 02:43:07 UTC (rev 219597)
@@ -423,7 +423,7 @@
Node* node = p.deepEquivalent().anchorNode();
Document& document = node->document();
- const auto& markers = document.markers().markersFor(node, DocumentMarker::MarkerTypes(DocumentMarker::DictationPhraseWithAlternatives));
+ const auto& markers = document.markers().markersFor(node, DocumentMarker::DictationPhraseWithAlternatives);
if (markers.isEmpty())
return nil;
@@ -457,7 +457,7 @@
Node* node = p.deepEquivalent().anchorNode();
Document& document = node->document();
- const auto& markers = document.markers().markersFor(node, DocumentMarker::MarkerTypes(DocumentMarker::Spelling));
+ const auto& markers = document.markers().markersFor(node, DocumentMarker::Spelling);
if (markers.isEmpty())
return nil;