Skip to content
Permalink
Browse files
Enable ability to prevent scrolling in Element.focus()
https://bugs.webkit.org/show_bug.cgi?id=178583

Patch by Rob Buis <rbuis@igalia.com> on 2021-03-22
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Update improved test result.

* web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements-expected.txt: Added.
* web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html: Added.
* web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt:

Source/WebCore:

Add FocusOptions parameter to the focus method [1] both
to the IDL as the C++ side. Change Element.focus to not
scroll if FocusOptions.preventScroll is true.

Behavior matches Chrome and Firefox.

Tests: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea.html
       imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html

Test: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/Element.cpp:
(WebCore::Element::focus):
* dom/Element.h:
(WebCore::Element::focus):
* dom/FocusOptions.h: Copied from Source/WebCore/html/HTMLOrForeignElement.idl.
* dom/FocusOptions.idl: Copied from Source/WebCore/html/HTMLOrForeignElement.idl.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::didAttachRenderers):
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::focus):
* html/HTMLLabelElement.h:
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::focus):
* html/HTMLLegendElement.h:
* html/HTMLOrForeignElement.idl:
* html/InputType.cpp:
(WebCore::InputType::accessKeyAction):
* page/FocusController.cpp:
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::FocusController::advanceFocusDirectionallyInContainer):

LayoutTests:

The test preventScroll-textarea.html now passes on all platforms.

* platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed.

Canonical link: https://commits.webkit.org/235610@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rwlbuis authored and webkit-commit-queue committed Mar 22, 2021
1 parent a39bd42 commit 6f15b9669d3951f1bfa46d52dab68a2ab168339e
Show file tree
Hide file tree
Showing 27 changed files with 246 additions and 28 deletions.
@@ -1,3 +1,15 @@
2021-03-22 Rob Buis <rbuis@igalia.com>

Enable ability to prevent scrolling in Element.focus()
https://bugs.webkit.org/show_bug.cgi?id=178583

Reviewed by Simon Fraser.

The test preventScroll-textarea.html now passes on all platforms.

* platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed.

2021-03-22 Devin Rousso <drousso@apple.com>

Remove unused JS and CSS files of media controls
@@ -1,3 +1,16 @@
2021-03-22 Rob Buis <rbuis@igalia.com>

Enable ability to prevent scrolling in Element.focus()
https://bugs.webkit.org/show_bug.cgi?id=178583

Reviewed by Simon Fraser.

Update improved test result.

* web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements-expected.txt: Added.
* web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html: Added.
* web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt:

2021-03-22 Chris Dumez <cdumez@apple.com>

imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/nan-param.html is failing
@@ -0,0 +1,12 @@
1_1
1_2
1_3
2_1
2_2
2_3
3_1
3_2
3_3

PASS focus(options) - preventScroll on nested scroll elements

@@ -0,0 +1,62 @@
<!doctype html>
<title>focus(options) - preventScroll on nested scroll elements</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style>
.scrollBox { width: 400px; height: 300px; border: 1px solid }
.bigbox { width: 380px; height: 300px; border: 1px solid }
.box { width: 380px; height: 150px; border: 1px solid }
</style>
<div class="scrollBox" style="overflow-y: scroll;">
<div class="bigbox" id="1" style="overflow-y: scroll;" tabindex=1>
<div class="box" id="1_1" tabindex=1>1_1</div>
<div class="box" id="1_2" tabindex=1>1_2</div>
<div class="box" id="1_3" tabindex=1>1_3</div>
</div>
<div class="bigbox" id="2" style="overflow-y: scroll;" tabindex=1>
<div class="box" id="2_1" tabindex=1>2_1</div>
<div class="box" id="2_2" tabindex=1>2_2</div>
<div class="box" id="2_3" tabindex=1>2_3</div>
</div>
<div class="bigbox" id="3" style="overflow-y: scroll;" tabindex=1>
<div class="box" id="3_1" tabindex=1>3_1</div>
<div class="box" id="3_2" tabindex=1>3_2</div>
<div class="box" id="3_3" tabindex=1>3_3</div>
</div>
</div>
<script>
promise_test(async function(t) {
await new Promise(resolve => window.addEventListener("load", resolve));
let div2_2 = document.getElementById("2_2");
div2_2.focus({ preventScroll: true });

await new Promise(resolve => {
requestAnimationFrame(() => requestAnimationFrame(resolve));
});

assert_equals(document.activeElement, div2_2, `box 2_2: should have been focused`);
assert_equals(div2_2.scrollTop, 0, "box 2_2: should not have scrolled");
assert_equals(div2_2.parentNode.scrollTop, 0, "box 2_2: should not have scrolled ancestor");

// Reset focus
let div1_1 = document.getElementById("1_1");
div1_1.focus();

await new Promise(resolve => {
requestAnimationFrame(() => requestAnimationFrame(resolve));
});
assert_equals(document.activeElement, div1_1, `box 1_1: should have been focused`);

let div2 = document.getElementById("2");
div2.focus({ preventScroll: true });

await new Promise(resolve => {
requestAnimationFrame(() => requestAnimationFrame(resolve));
});

assert_equals(document.activeElement, div2, `box 2: should have been focused`);
assert_equals(div2.scrollTop, 0, "box 2: should not have scrolled");
assert_equals(div2_2.scrollTop, 0, "box 2_2: should not have scrolled");
assert_equals(div2.parentNode.scrollTop, 0, "box 2: should not have scrolled ancestor");
});
</script>
@@ -1,4 +1,4 @@


FAIL preventScroll: true on a textarea element assert_equals: TEXTAREA: Should not have scrolled after a couple event loop ticks expected 0 but got 920
PASS preventScroll: true on a textarea element

This file was deleted.

This file was deleted.

@@ -848,6 +848,7 @@ set(WebCore_NON_SVG_IDL_FILES
dom/EventModifierInit.idl
dom/EventTarget.idl
dom/FocusEvent.idl
dom/FocusOptions.idl
dom/GlobalEventHandlers+PointerEvents.idl
dom/GlobalEventHandlers+Selection.idl
dom/GlobalEventHandlers.idl
@@ -1,3 +1,49 @@
2021-03-22 Rob Buis <rbuis@igalia.com>

Enable ability to prevent scrolling in Element.focus()
https://bugs.webkit.org/show_bug.cgi?id=178583

Reviewed by Simon Fraser.

Add FocusOptions parameter to the focus method [1] both
to the IDL as the C++ side. Change Element.focus to not
scroll if FocusOptions.preventScroll is true.

Behavior matches Chrome and Firefox.

Tests: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea.html
imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html

Test: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/Element.cpp:
(WebCore::Element::focus):
* dom/Element.h:
(WebCore::Element::focus):
* dom/FocusOptions.h: Copied from Source/WebCore/html/HTMLOrForeignElement.idl.
* dom/FocusOptions.idl: Copied from Source/WebCore/html/HTMLOrForeignElement.idl.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::didAttachRenderers):
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::focus):
* html/HTMLLabelElement.h:
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::focus):
* html/HTMLLegendElement.h:
* html/HTMLOrForeignElement.idl:
* html/InputType.cpp:
(WebCore::InputType::accessKeyAction):
* page/FocusController.cpp:
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::FocusController::advanceFocusDirectionallyInContainer):

2021-03-22 Devin Rousso <drousso@apple.com>

Remove unused JS and CSS files of media controls
@@ -855,6 +855,7 @@ $(PROJECT_DIR)/dom/EventNames.in
$(PROJECT_DIR)/dom/EventTarget.idl
$(PROJECT_DIR)/dom/EventTargetFactory.in
$(PROJECT_DIR)/dom/FocusEvent.idl
$(PROJECT_DIR)/dom/FocusOptions.idl
$(PROJECT_DIR)/dom/GlobalEventHandlers+PointerEvents.idl
$(PROJECT_DIR)/dom/GlobalEventHandlers+Selection.idl
$(PROJECT_DIR)/dom/GlobalEventHandlers.idl
@@ -830,6 +830,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFillMode.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFillMode.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusEvent.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusEvent.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusOptions.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFace.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFace.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFaceSet.cpp
@@ -727,6 +727,7 @@ JS_BINDING_IDLS := \
$(WebCore)/dom/EventModifierInit.idl \
$(WebCore)/dom/EventTarget.idl \
$(WebCore)/dom/FocusEvent.idl \
$(WebCore)/dom/FocusOptions.idl \
$(WebCore)/dom/GlobalEventHandlers+PointerEvents.idl \
$(WebCore)/dom/GlobalEventHandlers+Selection.idl \
$(WebCore)/dom/GlobalEventHandlers.idl \
@@ -467,6 +467,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
dom/ExceptionCode.h
dom/ExceptionData.h
dom/ExceptionOr.h
dom/FocusOptions.h
dom/FragmentScriptingPermission.h
dom/FullscreenManager.h
dom/GCReachableRef.h
@@ -3024,6 +3024,7 @@ JSFileSystemEntryCallback.cpp
JSFileSystemFileEntry.cpp
JSFillMode.cpp
JSFocusEvent.cpp
JSFocusOptions.cpp
JSFontFace.cpp
JSFontFaceSet.cpp
JSGPUBindGroupLayoutBinding.cpp
@@ -3607,6 +3607,7 @@
AA7FEEAD16A4E74B004C0C33 /* JSSpeechSynthesis.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7FEEAC16A4E74B004C0C33 /* JSSpeechSynthesis.h */; };
AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA728F116D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h */; };
AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC08CF115F941FC00F1E188 /* AccessibilitySVGRoot.h */; };
AADEFE4525AF4FD60040DD67 /* FocusOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
AB23A32809BBA7D00067CC53 /* BeforeTextInsertedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */; };
AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = AB247A6B0AFD6383003FA5FD /* RenderSlider.h */; };
AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AB31C91D10AE1B8E000C7B92 /* LineClampValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13173,6 +13174,7 @@
AA2A5AC616A485D500975A25 /* SpeechSynthesisVoice.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SpeechSynthesisVoice.cpp; sourceTree = "<group>"; };
AA2A5AC716A485D500975A25 /* SpeechSynthesisVoice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisVoice.h; sourceTree = "<group>"; };
AA2A5AC816A485D500975A25 /* SpeechSynthesisVoice.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisVoice.idl; sourceTree = "<group>"; };
AA2E0D0925AF5104007693BA /* FocusOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = FocusOptions.idl; sourceTree = "<group>"; };
AA478A7D16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAccessibilityObjectWrapperMac.h; sourceTree = "<group>"; };
AA478A7E16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = WebAccessibilityObjectWrapperMac.mm; sourceTree = "<group>"; };
AA4C3A740B2B1679002334A2 /* InlineStyleSheetOwner.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InlineStyleSheetOwner.cpp; sourceTree = "<group>"; };
@@ -13197,6 +13199,7 @@
AACC83D82316576B00EB6BF5 /* JSHTMLOrForeignElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOrForeignElement.cpp; sourceTree = "<group>"; };
AAD9D0B121DFA80C001B11C7 /* LazyLoadImageObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LazyLoadImageObserver.cpp; sourceTree = "<group>"; };
AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LazyLoadImageObserver.h; sourceTree = "<group>"; };
AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FocusOptions.h; sourceTree = "<group>"; };
AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesizerMock.cpp; sourceTree = "<group>"; };
AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizerMock.h; sourceTree = "<group>"; };
AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSpeechSynthesizerIOS.mm; sourceTree = "<group>"; };
@@ -30329,6 +30332,8 @@
B6D9D23414EABD260090D75E /* FocusEvent.cpp */,
B6D9D23314EABD260090D75E /* FocusEvent.h */,
B6D9D27214EABF030090D75E /* FocusEvent.idl */,
AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */,
AA2E0D0925AF5104007693BA /* FocusOptions.idl */,
A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */,
CD92F5172261038200F87BB3 /* FullscreenManager.cpp */,
CD92F5162261038200F87BB3 /* FullscreenManager.h */,
@@ -32317,6 +32322,7 @@
14993BE60B2F2B1C0050497F /* FocusController.h in Headers */,
062287840B4DB322000C34DF /* FocusDirection.h in Headers */,
B6D9D23514EABD260090D75E /* FocusEvent.h in Headers */,
AADEFE4525AF4FD60040DD67 /* FocusOptions.h in Headers */,
B2C3DA650D006CD600EF6F26 /* Font.h in Headers */,
1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */,
F4E57EDC213F3F5F004EA98E /* FontAttributeChanges.h in Headers */,
@@ -3040,7 +3040,7 @@ static RefPtr<Element> findFirstProgramaticallyFocusableElementInComposedTree(El
return nullptr;
}

void Element::focus(SelectionRestorationMode restorationMode, FocusDirection direction)
void Element::focus(const FocusOptions& options)
{
if (!isConnected())
return;
@@ -3084,11 +3084,12 @@ void Element::focus(SelectionRestorationMode restorationMode, FocusDirection dir
// Focus and change event handlers can cause us to lose our last ref.
// If a focus event handler changes the focus to a different node it
// does not make sense to continue and update appearence.
if (!page->focusController().setFocusedElement(newTarget.get(), *document->frame(), direction))
if (!page->focusController().setFocusedElement(newTarget.get(), *document->frame(), options.direction))
return;
}

newTarget->revealFocusedElement(restorationMode);
if (!options.preventScroll)
newTarget->revealFocusedElement(options.selectionRestorationMode);
}

void Element::revealFocusedElement(SelectionRestorationMode selectionMode)
@@ -27,6 +27,7 @@
#include "AXTextStateChangeIntent.h"
#include "Document.h"
#include "ElementData.h"
#include "FocusOptions.h"
#include "HTMLNames.h"
#include "ScrollTypes.h"
#include "ShadowRootInit.h"
@@ -401,7 +402,7 @@ class Element : public ContainerNode {
virtual String target() const { return String(); }

static AXTextStateChangeIntent defaultFocusTextStateChangeIntent() { return AXTextStateChangeIntent(AXTextStateChangeTypeSelectionMove, AXTextSelection { AXTextSelectionDirectionDiscontiguous, AXTextSelectionGranularityUnknown, true }); }
virtual void focus(SelectionRestorationMode = SelectionRestorationMode::RestoreOrSelectAll, FocusDirection = FocusDirection::None);
virtual void focus(const FocusOptions& = { });
void revealFocusedElement(SelectionRestorationMode);
virtual RefPtr<Element> focusAppearanceUpdateTarget();
virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal);
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 Igalia S.L. 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 "FocusDirection.h"

namespace WebCore {

struct FocusOptions {
SelectionRestorationMode selectionRestorationMode { SelectionRestorationMode::RestoreOrSelectAll };
FocusDirection direction { FocusDirection::None };
bool preventScroll { false };
};

} // namespace WebCore
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 Igalia S.L. 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.
*/

dictionary FocusOptions {
boolean preventScroll = false;
};
@@ -254,11 +254,11 @@ void HTMLFormControlElement::didAttachRenderers()
auto frameView = makeRefPtr(document().view());
if (frameView && frameView->layoutContext().isInLayout()) {
frameView->queuePostLayoutCallback([element] {
element->focus(SelectionRestorationMode::PlaceCaretAtStart);
element->focus({ SelectionRestorationMode::PlaceCaretAtStart });
});
} else {
Style::queuePostResolutionCallback([element] {
element->focus(SelectionRestorationMode::PlaceCaretAtStart);
element->focus({ SelectionRestorationMode::PlaceCaretAtStart });
});
}
}

0 comments on commit 6f15b96

Please sign in to comment.