Diff
Modified: trunk/Source/WebCore/ChangeLog (261980 => 261981)
--- trunk/Source/WebCore/ChangeLog 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/ChangeLog 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1,3 +1,60 @@
+2020-05-20 Darin Adler <[email protected]>
+
+ Dictation context should be an object identifier, not a type-punned pointer
+ https://bugs.webkit.org/show_bug.cgi?id=212174
+
+ Reviewed by Anders Carlsson.
+
+ * Headers.cmake: Added DictationContext.h.
+ * Sources.txt: Removed DictationAlternative.cpp.
+ * WebCore.xcodeproj/project.pbxproj: Added DictationContext.h, removed DictationAlternative.cpp.
+
+ * dom/DocumentMarker.h: Use DictationContext instead of uint64_t.
+ * editing/AlternativeTextController.cpp:
+ (WebCore::AlternativeTextController::timerFired): Ditto.
+ * editing/AlternativeTextController.h: Ditto.
+
+ * editing/DictationAlternative.h: Use DictationContext instead of uint64_t, but also
+ use CharacterRange rather than two "unsigned" values. Also convert into a simple
+ struct without constructors; don't really need those.
+
+ * editing/DictationAlternative.cpp: Removed.
+
+ * editing/DictationCommand.cpp:
+ (WebCore::DictationCommand::collectDictationAlternativesInRange): Updated for
+ changes to DictationAlternative.
+
+ * editing/DictationContext.h: Added.
+
+ * editing/Editor.h: Forward declare DictationAlternative rather than including
+ its header.
+
+ * editing/cocoa/AlternativeTextContextController.h: Use a pair of maps to bind NSTextAlternatives
+ objects to object identifiers. Remove unnecessary explicit constructor and destructor. Also removed
+ unnecessary use of WTF_MAKE_FAST_ALLOCATED, since this is only used as a data member of another
+ class. Removed unused invalidContext constant.
+ * editing/cocoa/AlternativeTextContextController.mm: Removed the unneeded includes.
+ This file treats NSTextAlternatives as an opaque Objective-C type and so doesn't need
+ any details of that class.
+ (WebCore::AlternativeTextContextController::addAlternatives): Changed to return a
+ DictationContext and use two maps, using HashMap::ensure to avoid double hashing.
+ (WebCore::AlternativeTextContextController::alternativesForContext): Added a null check.
+ (WebCore::AlternativeTextContextController::removeAlternativesForContext): Ditto. Also
+ updated to remove from both maps.
+ (WebCore::AlternativeTextContextController::clear): Clear both maps.
+
+ * editing/cocoa/AlternativeTextUIController.h: Since this header is used only from Objective-C,
+ removed use of OBJC_CLASS. Put showAlternatives inside a macOS-specific block. Use DictationContext
+ instead of uint64_t.
+ * editing/cocoa/AlternativeTextUIController.mm:
+ (WebCore::AlternativeTextUIController::addAlternatives): Use DictationContext instead of uint64_t.
+ (WebCore::AlternativeTextUIController::alternativesForContext): Ditto.
+ (WebCore::AlternativeTextUIController::showAlternatives): Ditto.
+ (WebCore::AlternativeTextUIController::handleAcceptedAlternative): Ditto.
+ (WebCore::AlternativeTextUIController::removeAlternatives): Ditto.
+
+ * page/AlternativeTextClient.h: Use DictationContext instead of uint64_t.
+
2020-05-20 Zalan Bujtas <[email protected]>
[LFC][TFC] Preferred width computation should take border collapsing into account
Modified: trunk/Source/WebCore/Headers.cmake (261980 => 261981)
--- trunk/Source/WebCore/Headers.cmake 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/Headers.cmake 2020-05-21 01:59:23 UTC (rev 261981)
@@ -495,6 +495,7 @@
editing/CompositionHighlight.h
editing/CompositionUnderline.h
editing/DictationAlternative.h
+ editing/DictationContext.h
editing/DictionaryPopupInfo.h
editing/EditAction.h
editing/Editing.h
Modified: trunk/Source/WebCore/Sources.txt (261980 => 261981)
--- trunk/Source/WebCore/Sources.txt 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/Sources.txt 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1040,7 +1040,6 @@
editing/CustomUndoStep.cpp
editing/DeleteFromTextNodeCommand.cpp
editing/DeleteSelectionCommand.cpp
-editing/DictationAlternative.cpp
editing/DictationCommand.cpp
editing/EditAction.cpp
editing/EditCommand.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (261980 => 261981)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-05-21 01:59:23 UTC (rev 261981)
@@ -2683,6 +2683,7 @@
9380F47409A11AB4001FDB34 /* Widget.h in Headers */ = {isa = PBXBuildFile; fileRef = 9380F47209A11AB4001FDB34 /* Widget.h */; settings = {ATTRIBUTES = (Private, ); }; };
9382AAB40D8C386100F357A6 /* NodeWithIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 9382AAB10D8C386100F357A6 /* NodeWithIndex.h */; };
9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 9382DF5710A8D5C900925652 /* ColorSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 938430B42475DE40003F9617 /* DictationContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 938430B22475DE3F003F9617 /* DictationContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
938E65F109F09840008A48EC /* JSHTMLElementWrapperFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */; };
938E666209F09B87008A48EC /* JSHTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 938E666109F09B87008A48EC /* JSHTMLCanvasElement.h */; };
9391A991162746CB00297330 /* ScrollingCoordinatorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 9391A990162746CB00297330 /* ScrollingCoordinatorMac.h */; };
@@ -10893,6 +10894,7 @@
9381B94123F9B0E0007118B4 /* RadioNodeList.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RadioNodeList.idl; sourceTree = "<group>"; };
9382AAB10D8C386100F357A6 /* NodeWithIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeWithIndex.h; sourceTree = "<group>"; };
9382DF5710A8D5C900925652 /* ColorSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorSpace.h; sourceTree = "<group>"; };
+ 938430B22475DE3F003F9617 /* DictationContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictationContext.h; sourceTree = "<group>"; };
938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JSHTMLElementWrapperFactory.h; path = DerivedSources/WebCore/JSHTMLElementWrapperFactory.h; sourceTree = BUILT_PRODUCTS_DIR; };
938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = JSHTMLElementWrapperFactory.cpp; path = DerivedSources/WebCore/JSHTMLElementWrapperFactory.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
938E662509F09956008A48EC /* HTMLCanvasElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLCanvasElement.idl; sourceTree = "<group>"; };
@@ -14327,7 +14329,6 @@
CEA84720212622AD00940809 /* TextCheckingMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckingMac.mm; sourceTree = "<group>"; };
CEBB8C3120786DCB00039547 /* FetchIdioms.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FetchIdioms.h; sourceTree = "<group>"; };
CEBB8C3220786DCB00039547 /* FetchIdioms.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FetchIdioms.cpp; sourceTree = "<group>"; };
- CECADFC2153778FF00E37068 /* DictationAlternative.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictationAlternative.cpp; sourceTree = "<group>"; };
CECADFC3153778FF00E37068 /* DictationAlternative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictationAlternative.h; sourceTree = "<group>"; };
CECADFC4153778FF00E37068 /* DictationCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictationCommand.cpp; sourceTree = "<group>"; };
CECADFC5153778FF00E37068 /* DictationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictationCommand.h; sourceTree = "<group>"; };
@@ -21957,10 +21958,10 @@
93309D90099E64910056E581 /* DeleteFromTextNodeCommand.h */,
93309D91099E64910056E581 /* DeleteSelectionCommand.cpp */,
93309D92099E64910056E581 /* DeleteSelectionCommand.h */,
- CECADFC2153778FF00E37068 /* DictationAlternative.cpp */,
CECADFC3153778FF00E37068 /* DictationAlternative.h */,
CECADFC4153778FF00E37068 /* DictationCommand.cpp */,
CECADFC5153778FF00E37068 /* DictationCommand.h */,
+ 938430B22475DE3F003F9617 /* DictationContext.h */,
2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */,
F49E98E421DEE6C1009AE55E /* EditAction.cpp */,
93309D93099E64910056E581 /* EditAction.h */,
@@ -30252,6 +30253,7 @@
CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */,
CECADFC9153778FF00E37068 /* DictationCommand.h in Headers */,
D0BD4F5D1408850F006839B6 /* DictationCommandIOS.h in Headers */,
+ 938430B42475DE40003F9617 /* DictationContext.h in Headers */,
937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */,
2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */,
FDAF19991513D131008DB0C3 /* DirectConvolver.h in Headers */,
Modified: trunk/Source/WebCore/dom/DocumentMarker.h (261980 => 261981)
--- trunk/Source/WebCore/dom/DocumentMarker.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/dom/DocumentMarker.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -20,6 +20,7 @@
#pragma once
+#include "DictationContext.h"
#include "SimpleRange.h"
#include <wtf/Forward.h>
#include <wtf/OptionSet.h>
@@ -85,7 +86,7 @@
static constexpr OptionSet<MarkerType> allMarkers();
struct DictationData {
- uint64_t context;
+ DictationContext context;
String originalText;
};
#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (261980 => 261981)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -286,13 +286,13 @@
#if USE(DICTATION_ALTERNATIVES)
if (!m_rangeWithAlternative)
return;
- uint64_t dictationContext = WTF::get<AlternativeDictationContext>(m_details);
+ auto dictationContext = WTF::get<DictationContext>(m_details);
if (!dictationContext)
return;
auto boundingBox = rootViewRectForRange(*m_rangeWithAlternative);
m_isActive = true;
if (!boundingBox.isEmpty()) {
- if (AlternativeTextClient* client = alternativeTextClient())
+ if (auto client = alternativeTextClient())
client->showDictationAlternativeUI(boundingBox, dictationContext);
}
#endif
Modified: trunk/Source/WebCore/editing/AlternativeTextController.h (261980 => 261981)
--- trunk/Source/WebCore/editing/AlternativeTextController.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/AlternativeTextController.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -105,7 +105,6 @@
private:
#if USE(AUTOCORRECTION_PANEL)
using AutocorrectionReplacement = String;
- using AlternativeDictationContext = uint64_t;
struct AlternativeTextInfo {
RefPtr<Range> rangeWithAlternative;
@@ -112,7 +111,7 @@
bool isActive;
AlternativeTextType type;
String originalText;
- Variant<AutocorrectionReplacement, AlternativeDictationContext> details;
+ Variant<AutocorrectionReplacement, DictationContext> details;
};
String dismissSoon(ReasonForDismissingAlternativeText);
@@ -134,7 +133,7 @@
bool m_isDismissedByEditing;
AlternativeTextType m_type;
String m_originalText;
- Variant<AutocorrectionReplacement, AlternativeDictationContext> m_details;
+ Variant<AutocorrectionReplacement, DictationContext> m_details;
String m_originalStringForLastDeletedAutocorrection;
Position m_positionForLastDeletedAutocorrection;
Deleted: trunk/Source/WebCore/editing/DictationAlternative.cpp (261980 => 261981)
--- trunk/Source/WebCore/editing/DictationAlternative.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/DictationAlternative.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 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. ``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
- * 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 "DictationAlternative.h"
-
-namespace WebCore {
-
-DictationAlternative::DictationAlternative(unsigned start, unsigned length, uint64_t context)
- : rangeStart(start)
- , rangeLength(length)
- , dictationContext(context)
-{
-}
-
-DictationAlternative::DictationAlternative()
- : rangeStart(0)
- , rangeLength(0)
- , dictationContext(0)
-{
-}
-
-}
Modified: trunk/Source/WebCore/editing/DictationAlternative.h (261980 => 261981)
--- trunk/Source/WebCore/editing/DictationAlternative.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/DictationAlternative.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -25,17 +25,14 @@
#pragma once
-#include <stdint.h>
+#include "CharacterRange.h"
+#include "DictationContext.h"
namespace WebCore {
+
struct DictationAlternative {
- WEBCORE_EXPORT DictationAlternative(unsigned start, unsigned length, uint64_t context);
- WEBCORE_EXPORT DictationAlternative();
- unsigned rangeStart;
- unsigned rangeLength;
-
- // This need to be 64 bit becauese it actually holds a pointer in WebKit.
- uint64_t dictationContext;
+ CharacterRange range;
+ DictationContext context;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/DictationCommand.cpp (261980 => 261981)
--- trunk/Source/WebCore/editing/DictationCommand.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/DictationCommand.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -65,9 +65,9 @@
{
auto& markerController = textNode.document().markers();
for (auto& alternative : m_alternatives) {
- DocumentMarker::DictationData data { alternative.dictationContext, textToBeInserted.substring(alternative.rangeStart, alternative.rangeLength) };
- markerController.addMarker(textNode, alternative.rangeStart + offsetOfInsertion, alternative.rangeLength, DocumentMarker::DictationAlternatives, WTFMove(data));
- markerController.addMarker(textNode, alternative.rangeStart + offsetOfInsertion, alternative.rangeLength, DocumentMarker::SpellCheckingExemption);
+ DocumentMarker::DictationData data { alternative.context, textToBeInserted.substring(alternative.range.location, alternative.range.length) };
+ markerController.addMarker(textNode, alternative.range.location + offsetOfInsertion, alternative.range.length, DocumentMarker::DictationAlternatives, WTFMove(data));
+ markerController.addMarker(textNode, alternative.range.location + offsetOfInsertion, alternative.range.length, DocumentMarker::SpellCheckingExemption);
}
}
@@ -132,8 +132,8 @@
void DictationCommand::collectDictationAlternativesInRange(size_t rangeStart, size_t rangeLength, Vector<DictationAlternative>& alternatives)
{
for (auto& alternative : m_alternatives) {
- if (alternative.rangeStart >= rangeStart && (alternative.rangeStart + alternative.rangeLength) <= rangeStart + rangeLength)
- alternatives.append(DictationAlternative(alternative.rangeStart - rangeStart, alternative.rangeLength, alternative.dictationContext));
+ if (alternative.range.location >= rangeStart && (alternative.range.location + alternative.range.length) <= rangeStart + rangeLength)
+ alternatives.append({ { alternative.range.location - rangeStart, alternative.range.length }, alternative.context });
}
}
Copied: trunk/Source/WebCore/editing/DictationContext.h (from rev 261980, trunk/Source/WebCore/editing/DictationAlternative.cpp) (0 => 261981)
--- trunk/Source/WebCore/editing/DictationContext.h (rev 0)
+++ trunk/Source/WebCore/editing/DictationContext.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 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. ``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
+ * 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/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum class DictationContextType { };
+using DictationContext = ObjectIdentifier<DictationContextType>;
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/editing/Editor.h (261980 => 261981)
--- trunk/Source/WebCore/editing/Editor.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/Editor.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -26,7 +26,6 @@
#pragma once
#include "CompositionUnderline.h"
-#include "DictationAlternative.h"
#include "DocumentMarker.h"
#include "EditAction.h"
#include "EditingBehavior.h"
@@ -86,6 +85,7 @@
class TextPlaceholderElement;
struct CompositionHighlight;
+struct DictationAlternative;
struct FontAttributes;
struct PasteboardPlainText;
struct PasteboardURL;
Modified: trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.h (261980 => 261981)
--- trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -23,8 +23,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <wtf/Forward.h>
+#import "DictationContext.h"
#import <wtf/HashMap.h>
+#import <wtf/RetainPtr.h>
@class NSTextAlternatives;
@@ -31,23 +32,16 @@
namespace WebCore {
class AlternativeTextContextController {
- WTF_MAKE_FAST_ALLOCATED;
public:
- WEBCORE_EXPORT AlternativeTextContextController();
- WEBCORE_EXPORT ~AlternativeTextContextController();
-
- uint64_t addAlternatives(NSTextAlternatives *);
-
+ DictationContext addAlternatives(NSTextAlternatives *);
+ void removeAlternativesForContext(DictationContext);
void clear();
- NSTextAlternatives *alternativesForContext(uint64_t context);
+ NSTextAlternatives *alternativesForContext(DictationContext) const;
- void removeAlternativesForContext(uint64_t context);
-
- static constexpr uint64_t invalidContext = 0;
-
private:
- HashMap<uint64_t, RetainPtr<NSTextAlternatives>> m_alternativesObjectMap;
+ HashMap<DictationContext, RetainPtr<NSTextAlternatives>> m_alternatives;
+ HashMap<RetainPtr<NSTextAlternatives>, DictationContext> m_contexts;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.mm (261980 => 261981)
--- trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/cocoa/AlternativeTextContextController.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -26,45 +26,38 @@
#import "config.h"
#import "AlternativeTextContextController.h"
-#import <wtf/RetainPtr.h>
-
-#if USE(APPKit)
-#import <AppKit/NSTextAlternatives.h>
-#elif PLATFORM(IOS_FAMILY)
-#import <pal/spi/ios/UIKitSPI.h>
-#endif
-
namespace WebCore {
-AlternativeTextContextController::AlternativeTextContextController() = default;
-
-AlternativeTextContextController::~AlternativeTextContextController() = default;
-
-uint64_t AlternativeTextContextController::addAlternatives(NSTextAlternatives *alternatives)
+DictationContext AlternativeTextContextController::addAlternatives(NSTextAlternatives *alternatives)
{
- // FIXME: Turning a pointer into an integer is a flawed algorithm to generate a unique ID. Can lead to aliasing to a new object that happens to occupy the same memory as an old one.
- uint64_t context = reinterpret_cast<uint64_t>(alternatives);
- if (!context)
- return invalidContext;
- if (alternativesForContext(context))
+ if (!alternatives)
+ return { };
+ return m_contexts.ensure(alternatives, [&] {
+ auto context = DictationContext::generate();
+ m_alternatives.add(context, alternatives);
return context;
- auto result = m_alternativesObjectMap.add(context, alternatives);
- return result.isNewEntry ? context : invalidContext;
+ }).iterator->value;
}
-NSTextAlternatives *AlternativeTextContextController::alternativesForContext(uint64_t context)
+NSTextAlternatives *AlternativeTextContextController::alternativesForContext(DictationContext context) const
{
- return m_alternativesObjectMap.get(context).get();
+ if (!context)
+ return nil;
+ return m_alternatives.get(context).get();
}
-void AlternativeTextContextController::removeAlternativesForContext(uint64_t context)
+void AlternativeTextContextController::removeAlternativesForContext(DictationContext context)
{
- m_alternativesObjectMap.remove(context);
+ if (!context)
+ return;
+ if (auto alternatives = m_alternatives.take(context))
+ m_contexts.remove(alternatives);
}
void AlternativeTextContextController::clear()
{
- m_alternativesObjectMap.clear();
+ m_alternatives.clear();
+ m_contexts.clear();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.h (261980 => 261981)
--- trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -24,10 +24,8 @@
*/
#import "AlternativeTextContextController.h"
-#import <wtf/RetainPtr.h>
-OBJC_CLASS NSTextAlternatives;
-OBJC_CLASS NSView;
+@class NSView;
namespace WebCore {
@@ -36,27 +34,27 @@
class AlternativeTextUIController {
WTF_MAKE_FAST_ALLOCATED;
public:
- AlternativeTextUIController() = default;
+ WEBCORE_EXPORT DictationContext addAlternatives(NSTextAlternatives *);
+ WEBCORE_EXPORT void removeAlternatives(DictationContext);
+ WEBCORE_EXPORT void clear();
- WEBCORE_EXPORT uint64_t addAlternatives(NSTextAlternatives *); // Returns a context ID.
+ WEBCORE_EXPORT Vector<String> alternativesForContext(DictationContext);
- WEBCORE_EXPORT void clear();
-
+#if USE(APPKIT)
using AcceptanceHandler = void (^)(NSString *);
- WEBCORE_EXPORT void showAlternatives(NSView *, const FloatRect& boundingBoxOfPrimaryString, uint64_t context, AcceptanceHandler);
+ WEBCORE_EXPORT void showAlternatives(NSView *, const FloatRect& boundingBoxOfPrimaryString, DictationContext, AcceptanceHandler);
+#endif
- void WEBCORE_EXPORT removeAlternatives(uint64_t context);
-
- WEBCORE_EXPORT Vector<String> alternativesForContext(uint64_t context);
-
private:
#if USE(APPKIT)
- void handleAcceptedAlternative(NSString *, uint64_t context, NSTextAlternatives *);
+ void handleAcceptedAlternative(NSString *, DictationContext, NSTextAlternatives *);
void dismissAlternatives();
+#endif
+ AlternativeTextContextController m_contextController;
+#if USE(APPKIT)
RetainPtr<NSView> m_view;
#endif
- AlternativeTextContextController m_contextController;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.mm (261980 => 261981)
--- trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/editing/cocoa/AlternativeTextUIController.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -41,12 +41,12 @@
namespace WebCore {
-uint64_t AlternativeTextUIController::addAlternatives(NSTextAlternatives *alternatives)
+DictationContext AlternativeTextUIController::addAlternatives(NSTextAlternatives *alternatives)
{
return m_contextController.addAlternatives(alternatives);
}
-Vector<String> AlternativeTextUIController::alternativesForContext(uint64_t context)
+Vector<String> AlternativeTextUIController::alternativesForContext(DictationContext context)
{
return makeVector<String>(m_contextController.alternativesForContext(context).alternativeStrings);
}
@@ -56,9 +56,10 @@
return m_contextController.clear();
}
-void AlternativeTextUIController::showAlternatives(NSView *view, const FloatRect& boundingBoxOfPrimaryString, uint64_t context, AcceptanceHandler acceptanceHandler)
+#if USE(APPKIT)
+
+void AlternativeTextUIController::showAlternatives(NSView *view, const FloatRect& boundingBoxOfPrimaryString, DictationContext context, AcceptanceHandler acceptanceHandler)
{
-#if USE(APPKIT)
dismissAlternatives();
if (!view)
return;
@@ -75,17 +76,9 @@
acceptanceHandler(acceptedString);
}
}];
-#else
- UNUSED_PARAM(view);
- UNUSED_PARAM(boundingBoxOfPrimaryString);
- UNUSED_PARAM(context);
- UNUSED_PARAM(acceptanceHandler);
-#endif
}
-#if USE(APPKIT)
-
-void AlternativeTextUIController::handleAcceptedAlternative(NSString *acceptedAlternative, uint64_t context, NSTextAlternatives *alternatives)
+void AlternativeTextUIController::handleAcceptedAlternative(NSString *acceptedAlternative, DictationContext context, NSTextAlternatives *alternatives)
{
[alternatives noteSelectedAlternativeString:acceptedAlternative];
m_contextController.removeAlternativesForContext(context);
@@ -100,7 +93,7 @@
#endif
-void AlternativeTextUIController::removeAlternatives(uint64_t context)
+void AlternativeTextUIController::removeAlternatives(DictationContext context)
{
m_contextController.removeAlternativesForContext(context);
}
Modified: trunk/Source/WebCore/page/AlternativeTextClient.h (261980 => 261981)
--- trunk/Source/WebCore/page/AlternativeTextClient.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebCore/page/AlternativeTextClient.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -25,6 +25,7 @@
#pragma once
+#include "DictationContext.h"
#include "FloatRect.h"
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -60,9 +61,9 @@
virtual void recordAutocorrectionResponse(AutocorrectionResponse, const String& replacedString, const String& replacementString) = 0;
#endif
#if USE(DICTATION_ALTERNATIVES)
- virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) = 0;
- virtual void removeDictationAlternatives(uint64_t dictationContext) = 0;
- virtual Vector<String> dictationAlternatives(uint64_t dictationContext) = 0;
+ virtual void showDictationAlternativeUI(const FloatRect& boundingBoxOfDictatedText, DictationContext) = 0;
+ virtual void removeDictationAlternatives(DictationContext) = 0;
+ virtual Vector<String> dictationAlternatives(DictationContext) = 0;
#endif
};
Modified: trunk/Source/WebKit/ChangeLog (261980 => 261981)
--- trunk/Source/WebKit/ChangeLog 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/ChangeLog 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1,3 +1,49 @@
+2020-05-20 Darin Adler <[email protected]>
+
+ Dictation context should be an object identifier, not a type-punned pointer
+ https://bugs.webkit.org/show_bug.cgi?id=212174
+
+ Reviewed by Anders Carlsson.
+
+ * Scripts/webkit/messages.py: Added DictationContext to the list of types that are
+ not C++ classes.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<DictationAlternative>::encode): Updated for change to
+ DictationAlternative structure.
+ (IPC::ArgumentCoder<DictationAlternative>::decode): Ditto.
+
+ * UIProcess/Cocoa/PageClientImplCocoa.h: Use DictationContext instead of uint64_t.
+ * UIProcess/Cocoa/PageClientImplCocoa.mm:
+ (WebKit::PageClientImplCocoa::addDictationAlternatives): Ditto.
+ (WebKit::PageClientImplCocoa::removeDictationAlternatives): Ditto.
+ (WebKit::PageClientImplCocoa::dictationAlternatives): Ditto.
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::insertDictatedTextAsync): Ditto.
+ * UIProcess/PageClient.h: Ditto.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::showDictationAlternativeUI): Ditto.
+ (WebKit::WebPageProxy::removeDictationAlternatives): Ditto.
+ (WebKit::WebPageProxy::dictationAlternatives): Ditto.
+ * UIProcess/WebPageProxy.h: Ditto.
+ * UIProcess/WebPageProxy.messages.in: Ditto.
+ * UIProcess/ios/PageClientImplIOS.h: Ditto.
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::showDictationAlternativeUI): Ditto.
+ * UIProcess/mac/PageClientImplMac.h: Ditto.
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::showDictationAlternativeUI): Ditto.
+
+ * UIProcess/mac/WebPageProxyMac.mm: Removed unneeded include of
+ DictationAlternative.h.
+
+ * WebProcess/WebCoreSupport/WebAlternativeTextClient.h: Use DictationContext
+ instead of uint64_t. Also marked class final and made everything private.
+ * WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp:
+ (WebKit::WebAlternativeTextClient::removeDictationAlternatives): Ditto.
+ (WebKit::WebAlternativeTextClient::showDictationAlternativeUI): Ditto.
+ (WebKit::WebAlternativeTextClient::dictationAlternatives): Ditto.
+
2020-05-20 Tim Horton <[email protected]>
WKMouseGestureRecognizer should be implemented without using UIKit internals
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (261980 => 261981)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2020-05-21 01:59:23 UTC (rev 261981)
@@ -206,6 +206,7 @@
'MediaTime',
'String',
'WebCore::ColorSpace',
+ 'WebCore::DictationContext',
'WebCore::DocumentIdentifier',
'WebCore::DocumentOrWorkerIdentifier',
'WebCore::FetchIdentifier',
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (261980 => 261981)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1962,31 +1962,24 @@
}
#endif // USE(LIBWPE)
-void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative)
+void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& alternative)
{
- encoder << dictationAlternative.rangeStart;
- encoder << dictationAlternative.rangeLength;
- encoder << dictationAlternative.dictationContext;
+ encoder << alternative.range << alternative.context;
}
Optional<DictationAlternative> ArgumentCoder<DictationAlternative>::decode(Decoder& decoder)
{
- Optional<unsigned> rangeStart;
- decoder >> rangeStart;
- if (!rangeStart)
+ Optional<CharacterRange> range;
+ decoder >> range;
+ if (!range)
return WTF::nullopt;
-
- Optional<unsigned> rangeLength;
- decoder >> rangeLength;
- if (!rangeLength)
+
+ Optional<DictationContext> context;
+ decoder >> context;
+ if (!context)
return WTF::nullopt;
-
- Optional<uint64_t> dictationContext;
- decoder >> dictationContext;
- if (!dictationContext)
- return WTF::nullopt;
-
- return {{ WTFMove(*rangeStart), WTFMove(*rangeLength), WTFMove(*dictationContext) }};
+
+ return {{ *range, *context }};
}
void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -62,9 +62,9 @@
NSSet *serializableFileWrapperClasses() const final;
#endif
- uint64_t addDictationAlternatives(NSTextAlternatives *) final;
- void removeDictationAlternatives(uint64_t dictationContext) final;
- Vector<String> dictationAlternatives(uint64_t dictationContext) final;
+ WebCore::DictationContext addDictationAlternatives(NSTextAlternatives *) final;
+ void removeDictationAlternatives(WebCore::DictationContext) final;
+ Vector<String> dictationAlternatives(WebCore::DictationContext) final;
protected:
WeakObjCPtr<WKWebView> m_webView;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -96,17 +96,17 @@
m_alternativeTextUIController->clear();
}
-uint64_t PageClientImplCocoa::addDictationAlternatives(NSTextAlternatives *alternatives)
+WebCore::DictationContext PageClientImplCocoa::addDictationAlternatives(NSTextAlternatives *alternatives)
{
return m_alternativeTextUIController->addAlternatives(alternatives);
}
-void PageClientImplCocoa::removeDictationAlternatives(uint64_t dictationContext)
+void PageClientImplCocoa::removeDictationAlternatives(WebCore::DictationContext dictationContext)
{
m_alternativeTextUIController->removeAlternatives(dictationContext);
}
-Vector<String> PageClientImplCocoa::dictationAlternatives(uint64_t dictationContext)
+Vector<String> PageClientImplCocoa::dictationAlternatives(WebCore::DictationContext dictationContext)
{
return m_alternativeTextUIController->alternativesForContext(dictationContext);
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -249,9 +249,8 @@
Vector<DictationAlternative> dictationAlternatives;
for (const auto& alternativeWithRange : dictationAlternativesWithRange) {
- uint64_t dictationContext = pageClient().addDictationAlternatives(alternativeWithRange.alternatives.get());
- if (dictationContext)
- dictationAlternatives.append(DictationAlternative(alternativeWithRange.range.location, alternativeWithRange.range.length, dictationContext));
+ if (auto context = pageClient().addDictationAlternatives(alternativeWithRange.alternatives.get()))
+ dictationAlternatives.append({ alternativeWithRange.range, context });
}
if (dictationAlternatives.isEmpty()) {
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -361,10 +361,10 @@
virtual void takeFocus(WebCore::FocusDirection) { }
#if USE(DICTATION_ALTERNATIVES)
- virtual uint64_t addDictationAlternatives(NSTextAlternatives *) = 0;
- virtual void removeDictationAlternatives(uint64_t dictationContext) = 0;
- virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) = 0;
- virtual Vector<String> dictationAlternatives(uint64_t dictationContext) = 0;
+ virtual WebCore::DictationContext addDictationAlternatives(NSTextAlternatives *) = 0;
+ virtual void removeDictationAlternatives(WebCore::DictationContext) = 0;
+ virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext) = 0;
+ virtual Vector<String> dictationAlternatives(WebCore::DictationContext) = 0;
#endif
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -8534,17 +8534,17 @@
#if USE(DICTATION_ALTERNATIVES)
-void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext dictationContext)
{
pageClient().showDictationAlternativeUI(boundingBoxOfDictatedText, dictationContext);
}
-void WebPageProxy::removeDictationAlternatives(uint64_t dictationContext)
+void WebPageProxy::removeDictationAlternatives(WebCore::DictationContext dictationContext)
{
pageClient().removeDictationAlternatives(dictationContext);
}
-void WebPageProxy::dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+void WebPageProxy::dictationAlternatives(WebCore::DictationContext dictationContext, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
{
completionHandler(pageClient().dictationAlternatives(dictationContext));
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -75,6 +75,7 @@
#include <WebCore/AutoplayEvent.h>
#include <WebCore/Color.h>
#include <WebCore/DiagnosticLoggingClient.h>
+#include <WebCore/DictationContext.h>
#include <WebCore/DragActions.h>
#include <WebCore/EventTrackingRegions.h>
#include <WebCore/ExceptionDetails.h>
@@ -2128,9 +2129,9 @@
#endif
#if USE(DICTATION_ALTERNATIVES)
- void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext);
- void removeDictationAlternatives(uint64_t dictationContext);
- void dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&&);
+ void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext);
+ void removeDictationAlternatives(WebCore::DictationContext);
+ void dictationAlternatives(WebCore::DictationContext, CompletionHandler<void(Vector<String>&&)>&&);
#endif
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2020-05-21 01:59:23 UTC (rev 261981)
@@ -387,9 +387,9 @@
#endif
#if USE(DICTATION_ALTERNATIVES)
- ShowDictationAlternativeUI(WebCore::FloatRect boundingBoxOfDictatedText, uint64_t dictationContext)
- RemoveDictationAlternatives(uint64_t dictationContext)
- DictationAlternatives(uint64_t dictationContext) -> (Vector<String> alternatives) Synchronous
+ ShowDictationAlternativeUI(WebCore::FloatRect boundingBoxOfDictatedText, WebCore::DictationContext dictationContext)
+ RemoveDictationAlternatives(WebCore::DictationContext dictationContext)
+ DictationAlternatives(WebCore::DictationContext dictationContext) -> (Vector<String> alternatives) Synchronous
#endif
#if PLATFORM(X11) && ENABLE(NETSCAPE_PLUGIN_API)
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -45,7 +45,7 @@
enum class UndoOrRedo : bool;
-class PageClientImpl : public PageClientImplCocoa
+class PageClientImpl final : public PageClientImplCocoa
#if ENABLE(FULLSCREEN_API)
, public WebFullScreenManagerProxyClient
#endif
@@ -267,7 +267,7 @@
void cancelPointersForGestureRecognizer(UIGestureRecognizer*) override;
WTF::Optional<unsigned> activeTouchIdentifierForGestureRecognizer(UIGestureRecognizer*) override;
- void showDictationAlternativeUI(const WebCore::FloatRect&, uint64_t dictationContext) override;
+ void showDictationAlternativeUI(const WebCore::FloatRect&, WebCore::DictationContext) final;
WeakObjCPtr<WKContentView> m_contentView;
RetainPtr<WKEditorUndoTarget> m_undoTarget;
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -942,7 +942,7 @@
[m_contentView _handleAutocorrectionContext:context];
}
-void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect&, uint64_t)
+void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect&, WebCore::DictationContext)
{
notImplemented();
}
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -180,7 +180,7 @@
void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
- void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
+ void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext) final;
void setEditableElementIsFocused(bool) override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -680,7 +680,7 @@
return m_impl->executeSavedCommandBySelector(NSSelectorFromString(selectorString));
}
-void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext dictationContext)
{
if (!isViewVisible() || !isViewInWindow())
return;
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (261980 => 261981)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -50,7 +50,6 @@
#import "WebPageMessages.h"
#import "WebProcessProxy.h"
#import <WebCore/AttributedString.h>
-#import <WebCore/DictationAlternative.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/DragItem.h>
#import <WebCore/GraphicsLayer.h>
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebAlternativeTextClient.h (261980 => 261981)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebAlternativeTextClient.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebAlternativeTextClient.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -31,11 +31,13 @@
class WebPage;
-class WebAlternativeTextClient : public WebCore::AlternativeTextClient {
+class WebAlternativeTextClient final : public WebCore::AlternativeTextClient {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit WebAlternativeTextClient(WebPage*);
virtual ~WebAlternativeTextClient();
+
+private:
#if USE(AUTOCORRECTION_PANEL)
void showCorrectionAlternative(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
void dismissAlternative(WebCore::ReasonForDismissingAlternativeText) override;
@@ -42,13 +44,13 @@
String dismissAlternativeSoon(WebCore::ReasonForDismissingAlternativeText) override;
void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
#endif
+
#if USE(DICTATION_ALTERNATIVES)
- void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
- void removeDictationAlternatives(uint64_t dictationContext) override;
- Vector<String> dictationAlternatives(uint64_t dictationContext) override;
+ void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext) final;
+ void removeDictationAlternatives(WebCore::DictationContext) final;
+ Vector<String> dictationAlternatives(WebCore::DictationContext) final;
#endif
-private:
#if !(USE(AUTOCORRECTION_PANEL) || USE(DICTATION_ALTERNATIVES))
IGNORE_CLANG_WARNINGS_BEGIN("unused-private-field")
#endif
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp (261980 => 261981)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp 2020-05-21 01:59:23 UTC (rev 261981)
@@ -69,17 +69,17 @@
}
#endif
-void WebAlternativeTextClient::removeDictationAlternatives(uint64_t dictationContext)
+void WebAlternativeTextClient::removeDictationAlternatives(WebCore::DictationContext dictationContext)
{
m_page->send(Messages::WebPageProxy::RemoveDictationAlternatives(dictationContext));
}
-void WebAlternativeTextClient::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+void WebAlternativeTextClient::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext dictationContext)
{
m_page->send(Messages::WebPageProxy::ShowDictationAlternativeUI(boundingBoxOfDictatedText, dictationContext));
}
-Vector<String> WebAlternativeTextClient::dictationAlternatives(uint64_t dictationContext)
+Vector<String> WebAlternativeTextClient::dictationAlternatives(WebCore::DictationContext dictationContext)
{
Vector<String> result;
m_page->sendSync(Messages::WebPageProxy::DictationAlternatives(dictationContext), Messages::WebPageProxy::DictationAlternatives::Reply(result));
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-05-21 01:59:23 UTC (rev 261981)
@@ -1,3 +1,27 @@
+2020-05-20 Darin Adler <[email protected]>
+
+ Dictation context should be an object identifier, not a type-punned pointer
+ https://bugs.webkit.org/show_bug.cgi?id=212174
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/WebAlternativeTextClient.h: Use DictationContext instead of uint64_t.
+ * WebCoreSupport/WebAlternativeTextClient.mm:
+ (WebAlternativeTextClient::removeDictationAlternatives): Ditto.
+ (WebAlternativeTextClient::showDictationAlternativeUI): Ditto.
+ (WebAlternativeTextClient::dictationAlternatives): Ditto.
+
+ * WebView/WebHTMLView.mm: Added include of DictationAlternative.h, now needed because
+ it's forward declared in Editor.h.
+ * WebView/WebView.mm: Ditto.
+ (-[WebView _getWebCoreDictationAlternatives:fromTextAlternatives:]): Updated for change
+ to DictationAlternative.
+ (-[WebView _showDictationAlternativeUI:forDictationContext:]): Use DictationContext
+ instead of uint64_t.
+ (-[WebView _removeDictationAlternatives:]): Ditto.
+ (-[WebView _dictationAlternatives:]): Ditto.
+ * WebView/WebViewInternal.h: Updated for the above.
+
2020-05-20 Alex Christensen <[email protected]>
Remove implicit URL->String conversion operators
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.h (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -39,9 +39,9 @@
String dismissAlternativeSoon(WebCore::ReasonForDismissingAlternativeText) override;
void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
#endif
- void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
- void removeDictationAlternatives(uint64_t dictationContext) override;
- Vector<String> dictationAlternatives(uint64_t dictationContext) override;
+ void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, WebCore::DictationContext) override;
+ void removeDictationAlternatives(WebCore::DictationContext) override;
+ Vector<String> dictationAlternatives(WebCore::DictationContext) override;
private:
WebView *m_webView;
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.mm (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebAlternativeTextClient.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -78,17 +78,17 @@
}
#endif
-void WebAlternativeTextClient::removeDictationAlternatives(uint64_t dictationContext)
+void WebAlternativeTextClient::removeDictationAlternatives(DictationContext dictationContext)
{
[m_webView _removeDictationAlternatives:dictationContext];
}
-void WebAlternativeTextClient::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+void WebAlternativeTextClient::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, DictationContext dictationContext)
{
[m_webView _showDictationAlternativeUI:boundingBoxOfDictatedText forDictationContext:dictationContext];
}
-Vector<String> WebAlternativeTextClient::dictationAlternatives(uint64_t dictationContext)
+Vector<String> WebAlternativeTextClient::dictationAlternatives(DictationContext dictationContext)
{
return [m_webView _dictationAlternatives:dictationContext];
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -83,6 +83,7 @@
#import <WebCore/CompositionHighlight.h>
#import <WebCore/ContextMenu.h>
#import <WebCore/ContextMenuController.h>
+#import <WebCore/DictationAlternative.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/Document.h>
#import <WebCore/DocumentFragment.h>
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-05-21 01:59:23 UTC (rev 261981)
@@ -140,6 +140,7 @@
#import <WebCore/CookieJar.h>
#import <WebCore/DatabaseManager.h>
#import <WebCore/DeprecatedGlobalSettings.h>
+#import <WebCore/DictationAlternative.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/Document.h>
#import <WebCore/DocumentLoader.h>
@@ -9422,11 +9423,11 @@
{
for (auto& alternativeWithRange : alternativesWithRange) {
if (auto dictationContext = _private->m_alternativeTextUIController->addAlternatives(alternativeWithRange.alternatives.get()))
- alternatives.append(WebCore::DictationAlternative(alternativeWithRange.range.location, alternativeWithRange.range.length, dictationContext));
+ alternatives.append({ alternativeWithRange.range, dictationContext });
}
}
-- (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(uint64_t)dictationContext
+- (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(WebCore::DictationContext)dictationContext
{
#if USE(AUTOCORRECTION_PANEL)
_private->m_alternativeTextUIController->showAlternatives(self, [self _convertRectFromRootView:boundingBoxOfDictatedText], dictationContext, ^(NSString* acceptedAlternative) {
@@ -9435,12 +9436,12 @@
#endif
}
-- (void)_removeDictationAlternatives:(uint64_t)dictationContext
+- (void)_removeDictationAlternatives:(WebCore::DictationContext)dictationContext
{
_private->m_alternativeTextUIController->removeAlternatives(dictationContext);
}
-- (Vector<String>)_dictationAlternatives:(uint64_t)dictationContext
+- (Vector<String>)_dictationAlternatives:(WebCore::DictationContext)dictationContext
{
return _private->m_alternativeTextUIController->alternativesForContext(dictationContext);
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h (261980 => 261981)
--- trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2020-05-21 01:58:33 UTC (rev 261980)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2020-05-21 01:59:23 UTC (rev 261981)
@@ -134,9 +134,9 @@
#endif
- (void)_getWebCoreDictationAlternatives:(Vector<WebCore::DictationAlternative>&)alternatives fromTextAlternatives:(const Vector<WebCore::TextAlternativeWithRange>&)alternativesWithRange;
-- (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(uint64_t)dictationContext;
-- (void)_removeDictationAlternatives:(uint64_t)dictationContext;
-- (Vector<String>)_dictationAlternatives:(uint64_t)dictationContext;
+- (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(WebCore::DictationContext)dictationContext;
+- (void)_removeDictationAlternatives:(WebCore::DictationContext)dictationContext;
+- (Vector<String>)_dictationAlternatives:(WebCore::DictationContext)dictationContext;
#if ENABLE(SERVICE_CONTROLS)
- (WebSelectionServiceController&)_selectionServiceController;