Title: [246226] trunk/Source
Revision
246226
Author
megan_gard...@apple.com
Date
2019-06-07 17:48:42 -0700 (Fri, 07 Jun 2019)

Log Message

Extend quirks to emulate bold/italic/underline in hidden editable areas
https://bugs.webkit.org/show_bug.cgi?id=198681

Reviewed by Wenson Hsieh.

Source/WebCore:

Rename only.

Rename quirks to be more accurate for new extended use.

* page/Quirks.cpp:
(WebCore::shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreasForHost):
(WebCore::Quirks::shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreas const):
(WebCore::shouldEmulateUndoRedoInHiddenEditableAreasForHost): Deleted.
(WebCore::Quirks::shouldEmulateUndoRedoInHiddenEditableAreas const): Deleted.
* page/Quirks.h:

Source/WebKit:

* Shared/FocusedElementInformation.cpp:
(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):
* Shared/FocusedElementInformation.h:
* Shared/SyntheticEditingCommandType.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView undoManager]):
* UIProcess/ios/WKContentViewInteraction.mm:
(shouldSynthezieKeyEvents):
(-[WKContentView toggleBoldfaceForWebView:]):
(-[WKContentView toggleItalicsForWebView:]):
(-[WKContentView toggleUnderlineForWebView:]):
(-[WKContentView _elementDidBlur]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::generateSyntheticEditingCommand):
(WebKit::WebPage::getFocusedElementInformation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (246225 => 246226)


--- trunk/Source/WebCore/ChangeLog	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebCore/ChangeLog	2019-06-08 00:48:42 UTC (rev 246226)
@@ -1,3 +1,21 @@
+2019-06-07  Megan Gardner  <megan_gard...@apple.com>
+
+        Extend quirks to emulate bold/italic/underline in hidden editable areas
+        https://bugs.webkit.org/show_bug.cgi?id=198681
+
+        Reviewed by Wenson Hsieh.
+
+        Rename only.
+
+        Rename quirks to be more accurate for new extended use.
+
+        * page/Quirks.cpp:
+        (WebCore::shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreasForHost):
+        (WebCore::Quirks::shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreas const):
+        (WebCore::shouldEmulateUndoRedoInHiddenEditableAreasForHost): Deleted.
+        (WebCore::Quirks::shouldEmulateUndoRedoInHiddenEditableAreas const): Deleted.
+        * page/Quirks.h:
+
 2019-06-07  Truitt Savell  <tsav...@apple.com>
 
         Unreviewed, rolling out r246138.

Modified: trunk/Source/WebCore/page/Quirks.cpp (246225 => 246226)


--- trunk/Source/WebCore/page/Quirks.cpp	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebCore/page/Quirks.cpp	2019-06-08 00:48:42 UTC (rev 246226)
@@ -238,7 +238,7 @@
 #endif
 }
 
-static bool shouldEmulateUndoRedoInHiddenEditableAreasForHost(const StringView& host)
+static bool shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreasForHost(const StringView& host)
 {
 #if PLATFORM(IOS_FAMILY)
     return equalLettersIgnoringASCIICase(host, "docs.google.com");
@@ -266,12 +266,12 @@
     return false;
 }
 
-bool Quirks::shouldEmulateUndoRedoInHiddenEditableAreas() const
+bool Quirks::shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreas() const
 {
     if (!needsQuirks())
         return false;
 
-    return shouldEmulateUndoRedoInHiddenEditableAreasForHost(m_document->topDocument().url().host());
+    return shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreasForHost(m_document->topDocument().url().host());
 }
 
 bool Quirks::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const

Modified: trunk/Source/WebCore/page/Quirks.h (246225 => 246226)


--- trunk/Source/WebCore/page/Quirks.h	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebCore/page/Quirks.h	2019-06-08 00:48:42 UTC (rev 246226)
@@ -58,7 +58,7 @@
 
     WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
     WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const;
-    WEBCORE_EXPORT bool shouldEmulateUndoRedoInHiddenEditableAreas() const;
+    WEBCORE_EXPORT bool shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreas() const;
     WEBCORE_EXPORT bool isTouchBarUpdateSupressedForHiddenContentEditable() const;
     WEBCORE_EXPORT bool isNeverRichlyEditableForTouchBar() const;
 

Modified: trunk/Source/WebKit/ChangeLog (246225 => 246226)


--- trunk/Source/WebKit/ChangeLog	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/ChangeLog	2019-06-08 00:48:42 UTC (rev 246226)
@@ -1,3 +1,27 @@
+2019-06-07  Megan Gardner  <megan_gard...@apple.com>
+
+        Extend quirks to emulate bold/italic/underline in hidden editable areas
+        https://bugs.webkit.org/show_bug.cgi?id=198681
+
+        Reviewed by Wenson Hsieh.
+
+        * Shared/FocusedElementInformation.cpp:
+        (WebKit::FocusedElementInformation::encode const):
+        (WebKit::FocusedElementInformation::decode):
+        * Shared/FocusedElementInformation.h:
+        * Shared/SyntheticEditingCommandType.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView undoManager]):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (shouldSynthezieKeyEvents):
+        (-[WKContentView toggleBoldfaceForWebView:]):
+        (-[WKContentView toggleItalicsForWebView:]):
+        (-[WKContentView toggleUnderlineForWebView:]):
+        (-[WKContentView _elementDidBlur]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::generateSyntheticEditingCommand):
+        (WebKit::WebPage::getFocusedElementInformation):
+
 2019-06-05  Alex Christensen  <achristen...@webkit.org>
 
         Introduce new SPI for context menus on iOS

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.cpp (246225 => 246226)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-06-08 00:48:42 UTC (rev 246226)
@@ -104,7 +104,7 @@
     encoder << suggestedColors;
 #endif
 #endif
-    encoder << shouldSynthesizeKeyEventsForUndoAndRedo;
+    encoder << shouldSynthesizeKeyEventsForEditing;
 }
 
 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result)
@@ -223,7 +223,7 @@
         return false;
 #endif
 #endif
-    if (!decoder.decode(result.shouldSynthesizeKeyEventsForUndoAndRedo))
+    if (!decoder.decode(result.shouldSynthesizeKeyEventsForEditing))
         return false;
 
     return true;

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.h (246225 => 246226)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-06-08 00:48:42 UTC (rev 246226)
@@ -136,7 +136,7 @@
     Vector<WebCore::Color> suggestedColors;
 #endif
 #endif
-    bool shouldSynthesizeKeyEventsForUndoAndRedo { false };
+    bool shouldSynthesizeKeyEventsForEditing { false };
 
     FocusedElementIdentifier focusedElementIdentifier { 0 };
 

Modified: trunk/Source/WebKit/Shared/SyntheticEditingCommandType.h (246225 => 246226)


--- trunk/Source/WebKit/Shared/SyntheticEditingCommandType.h	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/Shared/SyntheticEditingCommandType.h	2019-06-08 00:48:42 UTC (rev 246226)
@@ -29,7 +29,10 @@
     
 enum class SyntheticEditingCommandType : uint8_t  {
     Undo,
-    Redo
+    Redo,
+    ToggleBoldface,
+    ToggleItalic,
+    ToggleUnderline
 };
 
 } // namespace WebKit
@@ -40,7 +43,10 @@
     using values = EnumValues <
     WebKit::SyntheticEditingCommandType,
     WebKit::SyntheticEditingCommandType::Undo,
-    WebKit::SyntheticEditingCommandType::Redo
+    WebKit::SyntheticEditingCommandType::Redo,
+    WebKit::SyntheticEditingCommandType::ToggleBoldface,
+    WebKit::SyntheticEditingCommandType::ToggleItalic,
+    WebKit::SyntheticEditingCommandType::ToggleUnderline
     >;
 };
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (246225 => 246226)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-06-08 00:48:42 UTC (rev 246226)
@@ -443,7 +443,7 @@
 
 - (NSUndoManager *)undoManager
 {
-    if (self.focusedElementInformation.shouldSynthesizeKeyEventsForUndoAndRedo && self.hasHiddenContentEditable) {
+    if (self.focusedElementInformation.shouldSynthesizeKeyEventsForEditing && self.hasHiddenContentEditable) {
         if (!_quirkyUndoManager)
             _quirkyUndoManager = adoptNS([[WKQuirkyNSUndoManager alloc] initWithContentView:self]);
         return _quirkyUndoManager.get();

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (246225 => 246226)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-08 00:48:42 UTC (rev 246226)
@@ -3118,6 +3118,13 @@
     _page->selectAll();
 }
 
+- (BOOL)shouldSynthesizeKeyEvents
+{
+    if (_focusedElementInformation.shouldSynthesizeKeyEventsForEditing && self.hasHiddenContentEditable)
+        return true;
+    return false;
+}
+
 - (void)toggleBoldfaceForWebView:(id)sender
 {
     if (!_page->editorState().isContentRichlyEditable)
@@ -3124,6 +3131,9 @@
         return;
 
     [self executeEditCommandWithCallback:@"toggleBold"];
+
+    if (self.shouldSynthesizeKeyEvents)
+        _page->generateSyntheticEditingCommand(WebKit::SyntheticEditingCommandType::ToggleBoldface);
 }
 
 - (void)toggleItalicsForWebView:(id)sender
@@ -3132,6 +3142,9 @@
         return;
 
     [self executeEditCommandWithCallback:@"toggleItalic"];
+
+    if (self.shouldSynthesizeKeyEvents)
+        _page->generateSyntheticEditingCommand(WebKit::SyntheticEditingCommandType::ToggleItalic);
 }
 
 - (void)toggleUnderlineForWebView:(id)sender
@@ -3140,6 +3153,9 @@
         return;
 
     [self executeEditCommandWithCallback:@"toggleUnderline"];
+
+    if (self.shouldSynthesizeKeyEvents)
+        _page->generateSyntheticEditingCommand(WebKit::SyntheticEditingCommandType::ToggleUnderline);
 }
 
 - (void)_showTextStyleOptionsForWebView:(id)sender
@@ -5224,7 +5240,7 @@
     BOOL editableChanged = [self setIsEditable:NO];
 
     _focusedElementInformation.elementType = WebKit::InputType::None;
-    _focusedElementInformation.shouldSynthesizeKeyEventsForUndoAndRedo = false;
+    _focusedElementInformation.shouldSynthesizeKeyEventsForEditing = false;
     _inputPeripheral = nil;
     _focusRequiresStrongPasswordAssistance = NO;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (246225 => 246226)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-08 00:03:58 UTC (rev 246225)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-08 00:48:42 UTC (rev 246226)
@@ -615,6 +615,36 @@
 #endif
         @"U+0059", 89, false, false, false, modifiers, WallTime::now());
         break;
+    case SyntheticEditingCommandType::ToggleBoldface:
+        keyEvent = PlatformKeyboardEvent(PlatformEvent::KeyDown, "b", "b",
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+        "b",
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        "KeyB"_s,
+#endif
+        @"U+0042", 66, false, false, false, modifiers, WallTime::now());
+        break;
+    case SyntheticEditingCommandType::ToggleItalic:
+        keyEvent = PlatformKeyboardEvent(PlatformEvent::KeyDown, "i", "i",
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+        "i",
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        "KeyI"_s,
+#endif
+        @"U+0049", 73, false, false, false, modifiers, WallTime::now());
+        break;
+    case SyntheticEditingCommandType::ToggleUnderline:
+        keyEvent = PlatformKeyboardEvent(PlatformEvent::KeyDown, "u", "u",
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+        "u",
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        "KeyU"_s,
+#endif
+        @"U+0055", 85, false, false, false, modifiers, WallTime::now());
+        break;
     default:
         break;
     }
@@ -2877,7 +2907,7 @@
             information.isAutocorrect = focusedElement.shouldAutocorrect();
             information.autocapitalizeType = focusedElement.autocapitalizeType();
             information.inputMode = focusedElement.canonicalInputMode();
-            information.shouldSynthesizeKeyEventsForUndoAndRedo = focusedElement.document().quirks().shouldEmulateUndoRedoInHiddenEditableAreas();
+            information.shouldSynthesizeKeyEventsForEditing = focusedElement.document().quirks().shouldEmulateEditingButtonsAndGesturesInHiddenEditableAreas();
         } else {
             information.isAutocorrect = true;
             information.autocapitalizeType = AutocapitalizeTypeDefault;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to