diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index e36a4fe4eb087..bab100649ec5e 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,32 @@ +2018-09-26 Ryosuke Niwa + + Selection should work across shadow boundary when initiated by a mouse drag + https://bugs.webkit.org/show_bug.cgi?id=151380 + + + Reviewed by Antti Koivisto and Wenson Hsieh. + + Added regression tests using ref tests since getSelection() doesn't expose any node inside a shadow tree. + + * editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-1.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-2.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-readonly-3.html: Added. + * editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html: Added. + * editing/selection/selection-across-shadow-boundaries-user-select-all-1.html: Added. + 2018-09-26 Alicia Boya GarcĂ­a [GTK] Unreviewed test gardening diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html new file mode 100644 index 0000000000000..78ea1720162a3 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html @@ -0,0 +1,12 @@ + + + +

This tests selecting content starting in an editable element to a shadow tree.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html new file mode 100644 index 0000000000000..e0f0d9df06638 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in an editable element to a shadow tree.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
hello
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html new file mode 100644 index 0000000000000..de2113d78c47b --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html @@ -0,0 +1,12 @@ + + + +

This tests selecting content starting in a shadow tree out to an editable element.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html new file mode 100644 index 0000000000000..d36773903fce9 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in a shadow tree out to an editable element.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html new file mode 100644 index 0000000000000..c9574a4c471c7 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html @@ -0,0 +1,12 @@ + + + +

This tests selecting content starting in an editable region in a shadow tree to an editable region in the document tree.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html new file mode 100644 index 0000000000000..0dd3e8cbff66a --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in an editable region in a shadow tree to an editable region in the document tree.
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".

+
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html new file mode 100644 index 0000000000000..145fa5f03a51d --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html @@ -0,0 +1,13 @@ + + + +

This tests selecting content starting in a shadow tree inside an editable region to the outside.
+To manually test, select "hello world" below by a mouse drag from the bottom right to the top left.
+WebKit should not extend the selection to the editable region outside the shadow tree.

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html new file mode 100644 index 0000000000000..b5ac9b62dd1f8 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html @@ -0,0 +1,33 @@ + + + +

This tests selecting content starting in a shadow tree inside an editable region to the outside.
+To manually test, select "hello world" below by a mouse drag from the bottom right to the top left.
+WebKit should not extend the selection to the editable region outside the shadow tree.

+
hello
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html new file mode 100644 index 0000000000000..e71c59267bdee --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html @@ -0,0 +1,13 @@ + + + +

This tests selecting content starting in a shadow tree inside a non-editable region in an editable region to outside the editable region.
+To manually test, select "hello world WebKit" below by a mouse drag from the bottom right to the top left.
+WebKit should not extend the selection to outside the shadow tree.

+
hello
world
WebKit
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html new file mode 100644 index 0000000000000..5dc315d6b617c --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html @@ -0,0 +1,33 @@ + + + +

This tests selecting content starting in a shadow tree inside a non-editable region in an editable region to outside the editable region.
+To manually test, select "hello world WebKit" below by a mouse drag from the bottom right to the top left.
+WebKit should not extend the selection to outside the shadow tree.

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html new file mode 100644 index 0000000000000..cf72f78ddb059 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html @@ -0,0 +1,11 @@ + + + +

This tests selecting content starting in the document into a shadow tree.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html new file mode 100644 index 0000000000000..e0422fc932c98 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in the document into a shadow tree.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
hello
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html new file mode 100644 index 0000000000000..c1ac796855d8a --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html @@ -0,0 +1,11 @@ + + + +

This tests selecting content starting in a shadow tree out to the document.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html new file mode 100644 index 0000000000000..94cb7bd292a24 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in a shadow tree out to the document.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html new file mode 100644 index 0000000000000..11dbdaa67e6a7 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html @@ -0,0 +1,11 @@ + + + +

This tests selecting content starting in one shadow tree and ending another shadow tree.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
hello
world
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html new file mode 100644 index 0000000000000..5d536921f374f --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html @@ -0,0 +1,36 @@ + + + +

This tests selecting content starting in one shadow tree and ending another shadow tree.
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.

+
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html new file mode 100644 index 0000000000000..b92dea0273ba8 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html @@ -0,0 +1,11 @@ + + + +

This tests selecting content starting in a shadow tree inside a user-select: all in an editable region in to outside the editable region.
+To manually test, select "hello world WebKit rocks" below by a mouse drag from "h" to "s". WebKit should select "hello".

+
hello
world
WebKit
rocks
+ + + diff --git a/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html b/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html new file mode 100644 index 0000000000000..4eba0a2150bd7 --- /dev/null +++ b/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html @@ -0,0 +1,32 @@ + + + +

This tests selecting content starting in a shadow tree inside a user-select: all in an editable region in to outside the editable region.
+To manually test, select "hello world WebKit rocks" below by a mouse drag from "h" to "s". WebKit should select "hello".

+
world
WebKit
rocks
+ + + diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations index b9993fcb9f84e..f6eb44d014d59 100644 --- a/LayoutTests/platform/win/TestExpectations +++ b/LayoutTests/platform/win/TestExpectations @@ -101,6 +101,15 @@ webkit.org/b/173281 http/tests/security/mixedContent/secure-redirect-to-secure-r webkit.org/b/173281 editing/style/set-foreColor-with-color-filter.html [ Skip ] webkit.org/b/173281 editing/style/set-backColor-with-color-filter.html [ Skip ] webkit.org/b/173281 editing/style/inverse-color-filter.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-1.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-2.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-3.html [ Skip ] +webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-user-select-all-1.html [ Skip ] # TODO HW filters not yet supported on Windows webkit.org/b/74716 css3/filters/effect-blur-hw.html [ Skip ] diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index a9f8d6f4dff06..3ab9c90199c40 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,46 @@ +2018-09-26 Ryosuke Niwa + + Selection should work across shadow boundary when initiated by a mouse drag + https://bugs.webkit.org/show_bug.cgi?id=151380 + + + Reviewed by Antti Koivisto and Wenson Hsieh. + + This patch adds the basic support for selecting content across shadow DOM boundaries to VisibleSelection, + which is enough to allow users to select content across shadow DOM boundaries via a mouse drag. + + This is the first step in allowing users to select, copy and paste content across shadow DOM boundaries, + which is a serious user experience regression right now. The new behavior is disabled by default under + an interal debug feature flag: selectionAcrossShadowBoundariesEnabled. + + Like Chrome, we are not going to support selecting editable content across shadow DOM boundaries since + we'd have to generalize every editing commands to make that work, and there aren't any HTML editors that + use shadow DOM boundaries within an editable region yet. For simplicity, we also don't support extending + a selection out of a shadow root which resides inside an editing region. + + The keyboard based navigation & manipulation of selection as well as allowing copy & paste of content + across shadow DOM boundaries will be implemented by separate patches. DOMSelection will not expose this new + behavior either. This is tracked in the spec as https://github.com/w3c/webcomponents/issues/79 + + Tests: editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html + editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html + editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html + editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html + editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html + editing/selection/selection-across-shadow-boundaries-readonly-1.html + editing/selection/selection-across-shadow-boundaries-readonly-2.html + editing/selection/selection-across-shadow-boundaries-readonly-3.html + editing/selection/selection-across-shadow-boundaries-user-select-all-1.html + + * editing/VisibleSelection.cpp: + (WebCore::isInUserAgentShadowRootOrHasEditableShadowAncestor): Added. + (WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries): When the feature is enabled, + allow crossing shadow DOM boundaries except when either end is inside an user agent shadow root, or one of + its shadow includign ancestor is inside an editable region. The latter check is needed to disallow + an extension of a selection starting in a shadow tree inside a non-editable region inside an editable region + to outside the editable region. The rest of the editing code is not ready to deal with selection like that. + * page/Settings.yaml: Added an internal debug feature to enable this new behavior. + 2018-09-26 Chris Dumez Ignore-opens-during-unload counter of a parent should apply to its children during beforeunload event diff --git a/Source/WebCore/editing/VisibleSelection.cpp b/Source/WebCore/editing/VisibleSelection.cpp index 3d9bfba6a054c..f6bb6559ea014 100644 --- a/Source/WebCore/editing/VisibleSelection.cpp +++ b/Source/WebCore/editing/VisibleSelection.cpp @@ -30,6 +30,7 @@ #include "Editing.h" #include "Element.h" #include "HTMLInputElement.h" +#include "Settings.h" #include "TextIterator.h" #include "VisibleUnits.h" #include @@ -504,23 +505,45 @@ Position VisibleSelection::adjustPositionForStart(const Position& currentPositio return Position(); } +static bool isInUserAgentShadowRootOrHasEditableShadowAncestor(Node& node) +{ + auto* shadowRoot = node.containingShadowRoot(); + if (!shadowRoot) + return false; + + if (shadowRoot->mode() == ShadowRootMode::UserAgent) + return true; + + for (RefPtr currentNode = &node; currentNode; currentNode = currentNode->parentOrShadowHostNode()) { + if (currentNode->hasEditableStyle()) + return true; + } + return false; +} + void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries() { if (m_base.isNull() || m_start.isNull() || m_end.isNull()) return; - if (&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope()) + auto startNode = makeRef(*m_start.anchorNode()); + auto endNode = makeRef(*m_end.anchorNode()); + if (&startNode->treeScope() == &endNode->treeScope()) return; + if (startNode->document().settings().selectionAcrossShadowBoundariesEnabled()) { + if (!isInUserAgentShadowRootOrHasEditableShadowAncestor(startNode) + && !isInUserAgentShadowRootOrHasEditableShadowAncestor(endNode)) + return; + } + if (m_baseIsFirst) { - m_extent = adjustPositionForEnd(m_end, m_start.containerNode()); + m_extent = adjustPositionForEnd(m_end, startNode.ptr()); m_end = m_extent; } else { - m_extent = adjustPositionForStart(m_start, m_end.containerNode()); + m_extent = adjustPositionForStart(m_start, endNode.ptr()); m_start = m_extent; } - - ASSERT(&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope()); } void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() diff --git a/Source/WebCore/page/Settings.yaml b/Source/WebCore/page/Settings.yaml index 96c69f6161dcc..531657b48ad34 100644 --- a/Source/WebCore/page/Settings.yaml +++ b/Source/WebCore/page/Settings.yaml @@ -389,6 +389,8 @@ smartInsertDeleteEnabled: initial: defaultSmartInsertDeleteEnabled selectTrailingWhitespaceEnabled: initial: defaultSelectTrailingWhitespaceEnabled +selectionAcrossShadowBoundariesEnabled: + initial: false useLegacyBackgroundSizeShorthandBehavior: initial: false diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index f20cc911aba8c..edd0df494bb2b 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,16 @@ +2018-09-26 Ryosuke Niwa + + Selection should work across shadow boundary when initiated by a mouse drag + https://bugs.webkit.org/show_bug.cgi?id=151380 + + + Reviewed by Antti Koivisto. + + Added SelectionAcrossShadowBoundariesEnabled as an internal debug feature, + and moved CSSCustomPropertiesAndValuesEnabled to where other experimental features are located. + + * Shared/WebPreferences.yaml: + 2018-09-26 Chris Dumez Unreviewed, apply post-landing review comments after r236512. diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml index d3e1f4028462c..564db4477b287 100644 --- a/Source/WebKit/Shared/WebPreferences.yaml +++ b/Source/WebKit/Shared/WebPreferences.yaml @@ -1257,6 +1257,14 @@ ServerTimingEnabled: webcoreBinding: RuntimeEnabledFeatures webcoreName: serverTimingEnabled +CSSCustomPropertiesAndValuesEnabled: + type: bool + defaultValue: false + humanReadableName: "CSS Custom Properties and Values API" + humanReadableDescription: "Enable CSS Custom Properties and Values API" + webcoreBinding: RuntimeEnabledFeatures + category: experimental + # For internal features: # The type should be boolean. # You must provide a humanReadableName and humanReadableDescription for all debug features. They @@ -1341,7 +1349,7 @@ FullScreenEnabled: AriaReflectionEnabled: type: bool - defaultValue: true + defaultValue: false humanReadableName: "ARIA Reflection" humanReadableDescription: "ARIA Reflection support" category: internal @@ -1355,10 +1363,10 @@ WebAPIStatisticsEnabled: webcoreBinding: RuntimeEnabledFeatures category: internal -CSSCustomPropertiesAndValuesEnabled: +SelectionAcrossShadowBoundariesEnabled: type: bool - defaultValue: false - humanReadableName: "CSS Custom Properties and Values API" - humanReadableDescription: "Enable CSS Custom Properties and Values API" - webcoreBinding: RuntimeEnabledFeatures - category: experimental + defaultValue: true + humanReadableName: "Selection across shadow DOM" + humanReadableDescription: "Allow user-initiated selection across shadow DOM boundaries" + category: internal + webcoreName: selectionAcrossShadowBoundariesEnabled diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index 61d3a6d11ff6e..8f778105a9290 100644 --- a/Source/WebKitLegacy/mac/ChangeLog +++ b/Source/WebKitLegacy/mac/ChangeLog @@ -1,3 +1,22 @@ +2018-09-26 Ryosuke Niwa + + Selection should work across shadow boundary when initiated by a mouse drag + https://bugs.webkit.org/show_bug.cgi?id=151380 + + + Reviewed by Wenson Hsieh. + + Added selectionAcrossShadowBoundariesEnabled as a preference to be used in DumpRenderTree. + + * WebView/WebPreferenceKeysPrivate.h: + * WebView/WebPreferences.mm: + (+[WebPreferences initialize]): + (-[WebPreferences selectionAcrossShadowBoundariesEnabled]): + (-[WebPreferences setSelectionAcrossShadowBoundariesEnabled:]): + * WebView/WebPreferencesPrivate.h: + * WebView/WebView.mm: + (-[WebView _preferencesChanged:]): + 2018-09-24 Wenson Hsieh Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h index 2e022e658c1ff..2ff6f6e78c5fc 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h @@ -262,3 +262,4 @@ #define WebKitAriaReflectionEnabledPreferenceKey @"WebKitAriaReflectionEnabled" #define WebKitMediaCapabilitiesEnabledPreferenceKey @"WebKitMediaCapabilitiesEnabled" #define WebKitServerTimingEnabledPreferenceKey @"WebKitServerTimingEnabled" +#define WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey @"WebKitSelectionAcrossShadowBoundariesEnabled" diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm index 2221732e5fea6..bd1c6cb9ebfd7 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm +++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm @@ -664,6 +664,7 @@ + (void)initialize #if ENABLE(WEB_RTC) [NSNumber numberWithBool:YES], WebKitPeerConnectionEnabledPreferenceKey, #endif + [NSNumber numberWithBool:NO], WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey, #if ENABLE(INTERSECTION_OBSERVER) @NO, WebKitIntersectionObserverEnabledPreferenceKey, #endif @@ -3365,6 +3366,16 @@ - (void)setServerTimingEnabled:(BOOL)flag [self _setBoolValue:flag forKey:WebKitServerTimingEnabledPreferenceKey]; } +- (BOOL)selectionAcrossShadowBoundariesEnabled +{ + return [self _boolValueForKey:WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey]; +} + +- (void)setSelectionAcrossShadowBoundariesEnabled:(BOOL)flag +{ + [self _setBoolValue:flag forKey:WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey]; +} + @end @implementation WebPreferences (WebInternal) diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h index 3076ad24137c6..f288fe29c922d 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h @@ -582,6 +582,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification WEBKIT_DEPR - (void)setServerTimingEnabled:(BOOL)flag; - (BOOL)serverTimingEnabled; +- (void)setSelectionAcrossShadowBoundariesEnabled:(BOOL)flag; +- (BOOL)selectionAcrossShadowBoundariesEnabled; + @property (nonatomic) BOOL visualViewportEnabled; @property (nonatomic) BOOL visualViewportAPIEnabled; @property (nonatomic) BOOL CSSOMViewScrollingAPIEnabled; diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm index 467c0e3dcbb81..0e4a675bb8de3 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm @@ -3170,6 +3170,8 @@ - (void)_preferencesChanged:(WebPreferences *)preferences settings.setMediaCapabilitiesEnabled([preferences mediaCapabilitiesEnabled]); RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled([preferences serverTimingEnabled]); + + settings.setSelectionAcrossShadowBoundariesEnabled(preferences.selectionAcrossShadowBoundariesEnabled); } static inline IMP getMethod(id o, SEL s) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index cae8646fefe34..eac6d843f7baf 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,20 @@ +2018-09-26 Ryosuke Niwa + + Selection should work across shadow boundary when initiated by a mouse drag + https://bugs.webkit.org/show_bug.cgi?id=151380 + + + Reviewed by Wenson Hsieh. + + Added the support for internal:selectionAcrossShadowBoundariesEnabled test option. + + * DumpRenderTree/TestOptions.cpp: + (TestOptions::TestOptions): + * DumpRenderTree/TestOptions.h: + * DumpRenderTree/mac/DumpRenderTree.mm: + (resetWebPreferencesToConsistentValues): + (setWebPreferencesForTestOptions): + 2018-09-26 Ryosuke Niwa MiniBrowser doesn't respect default enabled-ness of experimental and internal debug features diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp index c6c7bd8c34071..87106ca1a9ccf 100644 --- a/Tools/DumpRenderTree/TestOptions.cpp +++ b/Tools/DumpRenderTree/TestOptions.cpp @@ -101,6 +101,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu allowCrossOriginSubresourcesToAskForCredentials = parseBooleanTestHeaderValue(value); else if (key == "experimental:WebAnimationsCSSIntegrationEnabled") enableWebAnimationsCSSIntegration = parseBooleanTestHeaderValue(value); + else if (key == "internal:selectionAcrossShadowBoundariesEnabled") + enableSelectionAcrossShadowBoundaries = parseBooleanTestHeaderValue(value); else if (key == "enableColorFilter") enableColorFilter = parseBooleanTestHeaderValue(value); else if (key == "jscOptions") diff --git a/Tools/DumpRenderTree/TestOptions.h b/Tools/DumpRenderTree/TestOptions.h index 3ecaf22993cc4..d91390cd6bacf 100644 --- a/Tools/DumpRenderTree/TestOptions.h +++ b/Tools/DumpRenderTree/TestOptions.h @@ -43,6 +43,7 @@ struct TestOptions { bool dumpJSConsoleLogInStdErr { false }; bool allowCrossOriginSubresourcesToAskForCredentials { false }; bool enableColorFilter { false }; + bool enableSelectionAcrossShadowBoundaries { false }; std::string jscOptions; TestOptions(const std::string& pathOrURL, const std::string& absolutePath); diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm index efb43c169292b..27d01ac5b46c0 100644 --- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm @@ -990,6 +990,8 @@ static void resetWebPreferencesToConsistentValues() [preferences setCacheAPIEnabled:NO]; preferences.mediaCapabilitiesEnabled = YES; + preferences.selectionAcrossShadowBoundariesEnabled = NO; + [WebPreferences _clearNetworkLoaderSession]; [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain]; } @@ -1008,6 +1010,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options) preferences.allowCrossOriginSubresourcesToAskForCredentials = options.allowCrossOriginSubresourcesToAskForCredentials; preferences.webAnimationsCSSIntegrationEnabled = options.enableWebAnimationsCSSIntegration; preferences.colorFilterEnabled = options.enableColorFilter; + preferences.selectionAcrossShadowBoundariesEnabled = options.enableSelectionAcrossShadowBoundaries; } // Called once on DumpRenderTree startup.