Title: [254952] trunk/Source/WebKitLegacy/mac
- Revision
- 254952
- Author
- [email protected]
- Date
- 2020-01-22 16:24:24 -0800 (Wed, 22 Jan 2020)
Log Message
Legacy WebKit: Add SPI variant of -setSelectedDOMRange that can perform the selection as if triggered by the user
https://bugs.webkit.org/show_bug.cgi?id=206622
Reviewed by Wenson Hsieh.
Add a new -setSelectedDOMRange SPI variant that takes a boolean to indicate whether the selection
was triggered by the user.
While I am here, I simplified and modernized the code. This includes moving the null check of
Frame::page() to the top of the function. This let me eliminate the null check for Frame::view()
because every frame that has a page must have a non-null view. I imported WebEditorClient.h
to get WebKit::core(NSSelectionAffinity) and remove a C-style cast to WebCore::EAffinity.
I also used more "auto".
* WebView/WebFrame.mm:
(-[WebFrame setSelectedDOMRange:affinity:closeTyping:]): Modified to call the newly added variant,
passing "userTriggered:NO" to keep the current behavior.
(-[WebFrame setSelectedDOMRange:affinity:closeTyping:userTriggered:]): Added.
* WebView/WebFramePrivate.h:
Modified Paths
Diff
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (254951 => 254952)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-01-23 00:20:24 UTC (rev 254951)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-01-23 00:24:24 UTC (rev 254952)
@@ -1,3 +1,25 @@
+2020-01-22 Daniel Bates <[email protected]>
+
+ Legacy WebKit: Add SPI variant of -setSelectedDOMRange that can perform the selection as if triggered by the user
+ https://bugs.webkit.org/show_bug.cgi?id=206622
+
+ Reviewed by Wenson Hsieh.
+
+ Add a new -setSelectedDOMRange SPI variant that takes a boolean to indicate whether the selection
+ was triggered by the user.
+
+ While I am here, I simplified and modernized the code. This includes moving the null check of
+ Frame::page() to the top of the function. This let me eliminate the null check for Frame::view()
+ because every frame that has a page must have a non-null view. I imported WebEditorClient.h
+ to get WebKit::core(NSSelectionAffinity) and remove a C-style cast to WebCore::EAffinity.
+ I also used more "auto".
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame setSelectedDOMRange:affinity:closeTyping:]): Modified to call the newly added variant,
+ passing "userTriggered:NO" to keep the current behavior.
+ (-[WebFrame setSelectedDOMRange:affinity:closeTyping:userTriggered:]): Added.
+ * WebView/WebFramePrivate.h:
+
2020-01-22 Zalan Bujtas <[email protected]>
REGRESSION (r254923): [mac-wk1] http/tests/inspector/network/har/har-page.html crashing in WebCore::Display::Box::contentBox()
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (254951 => 254952)
--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm 2020-01-23 00:20:24 UTC (rev 254951)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm 2020-01-23 00:24:24 UTC (rev 254952)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-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
@@ -40,6 +40,7 @@
#import "WebDataSourceInternal.h"
#import "WebDocumentLoaderMac.h"
#import "WebDynamicScrollBarsView.h"
+#import "WebEditorClient.h"
#import "WebElementDictionary.h"
#import "WebFrameLoaderClient.h"
#import "WebFrameViewInternal.h"
@@ -111,7 +112,6 @@
#import "WebResource.h"
#import "WebUIKitDelegate.h"
#import <WebCore/Document.h>
-#import <WebCore/EditorClient.h>
#import <WebCore/FocusController.h>
#import <WebCore/Font.h>
#import <WebCore/FrameSelection.h>
@@ -1465,23 +1465,27 @@
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)affinity closeTyping:(BOOL)closeTyping
{
- WebCore::Frame *frame = core(self);
+ [self setSelectedDOMRange:range affinity:affinity closeTyping:closeTyping userTriggered:NO];
+}
- // Ensure the view becomes first responder.
- // This does not happen automatically on iOS because we don't forward
- // all the click events to WebKit.
- if (auto* frameView = frame->view()) {
- if (NSView *documentView = frameView->documentView()) {
- auto* page = frame->page();
- if (!page)
- return;
- page->chrome().focusNSView(documentView);
- }
- }
+- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)affinity closeTyping:(BOOL)closeTyping userTriggered:(BOOL)userTriggered
+{
+ using namespace WebCore;
- frame->selection().setSelectedRange(core(range), (WebCore::EAffinity)affinity, closeTyping ? WebCore::FrameSelection::ShouldCloseTyping::Yes : WebCore::FrameSelection::ShouldCloseTyping::No);
+ auto& frame = *core(self);
+ if (!frame.page())
+ return;
+
+ // Ensure the view becomes first responder. This does not happen automatically on iOS because
+ // we don't forward all the click events to WebKit.
+ if (NSView *documentView = frame.view()->documentView())
+ frame.page()->chrome().focusNSView(documentView);
+
+ auto coreCloseTyping = closeTyping ? FrameSelection::ShouldCloseTyping::Yes : FrameSelection::ShouldCloseTyping::No;
+ auto coreUserTriggered = userTriggered ? UserTriggered : NotUserTriggered;
+ frame.selection().setSelectedRange(core(range), core(affinity), coreCloseTyping, coreUserTriggered);
if (!closeTyping)
- frame->editor().ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
+ frame.editor().ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
}
- (NSSelectionAffinity)selectionAffinity
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFramePrivate.h (254951 => 254952)
--- trunk/Source/WebKitLegacy/mac/WebView/WebFramePrivate.h 2020-01-23 00:20:24 UTC (rev 254951)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFramePrivate.h 2020-01-23 00:24:24 UTC (rev 254952)
@@ -150,6 +150,7 @@
- (DOMRange *)selectedDOMRange;
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)affinity closeTyping:(BOOL)closeTyping;
+- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)affinity closeTyping:(BOOL)closeTyping userTriggered:(BOOL)userTriggered;
- (NSSelectionAffinity)selectionAffinity;
- (void)expandSelectionToElementContainingCaretSelection;
- (DOMRange *)elementRangeContainingCaretSelection;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes