Changeset 274812 in webkit
- Timestamp:
- Mar 22, 2021 3:29:52 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 21 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r274810 r274812 1 2021-03-22 Rob Buis <rbuis@igalia.com> 2 3 Enable ability to prevent scrolling in Element.focus() 4 https://bugs.webkit.org/show_bug.cgi?id=178583 5 6 Reviewed by Simon Fraser. 7 8 The test preventScroll-textarea.html now passes on all platforms. 9 10 * platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed. 11 * platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: Removed. 12 1 13 2021-03-22 Devin Rousso <drousso@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r274794 r274812 1 2021-03-22 Rob Buis <rbuis@igalia.com> 2 3 Enable ability to prevent scrolling in Element.focus() 4 https://bugs.webkit.org/show_bug.cgi?id=178583 5 6 Reviewed by Simon Fraser. 7 8 Update improved test result. 9 10 * web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements-expected.txt: Added. 11 * web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html: Added. 12 * web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt: 13 1 14 2021-03-22 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea-expected.txt
r267646 r274812 1 1 2 2 3 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 3 PASS preventScroll: true on a textarea element 4 4 -
trunk/Source/WebCore/CMakeLists.txt
r274557 r274812 849 849 dom/EventTarget.idl 850 850 dom/FocusEvent.idl 851 dom/FocusOptions.idl 851 852 dom/GlobalEventHandlers+PointerEvents.idl 852 853 dom/GlobalEventHandlers+Selection.idl -
trunk/Source/WebCore/ChangeLog
r274810 r274812 1 2021-03-22 Rob Buis <rbuis@igalia.com> 2 3 Enable ability to prevent scrolling in Element.focus() 4 https://bugs.webkit.org/show_bug.cgi?id=178583 5 6 Reviewed by Simon Fraser. 7 8 Add FocusOptions parameter to the focus method [1] both 9 to the IDL as the C++ side. Change Element.focus to not 10 scroll if FocusOptions.preventScroll is true. 11 12 Behavior matches Chrome and Firefox. 13 14 Tests: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-textarea.html 15 imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html 16 17 Test: imported/w3c/web-platform-tests/html/interaction/focus/processing-model/preventScroll-nested-scroll-elements.html 18 19 * CMakeLists.txt: 20 * DerivedSources-input.xcfilelist: 21 * DerivedSources-output.xcfilelist: 22 * DerivedSources.make: 23 * Headers.cmake: 24 * Sources.txt: 25 * WebCore.xcodeproj/project.pbxproj: 26 * dom/Element.cpp: 27 (WebCore::Element::focus): 28 * dom/Element.h: 29 (WebCore::Element::focus): 30 * dom/FocusOptions.h: Copied from Source/WebCore/html/HTMLOrForeignElement.idl. 31 * dom/FocusOptions.idl: Copied from Source/WebCore/html/HTMLOrForeignElement.idl. 32 * html/HTMLFormControlElement.cpp: 33 (WebCore::HTMLFormControlElement::didAttachRenderers): 34 * html/HTMLLabelElement.cpp: 35 (WebCore::HTMLLabelElement::focus): 36 * html/HTMLLabelElement.h: 37 * html/HTMLLegendElement.cpp: 38 (WebCore::HTMLLegendElement::focus): 39 * html/HTMLLegendElement.h: 40 * html/HTMLOrForeignElement.idl: 41 * html/InputType.cpp: 42 (WebCore::InputType::accessKeyAction): 43 * page/FocusController.cpp: 44 (WebCore::FocusController::advanceFocusInDocumentOrder): 45 (WebCore::FocusController::advanceFocusDirectionallyInContainer): 46 1 47 2021-03-22 Devin Rousso <drousso@apple.com> 2 48 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r274613 r274812 856 856 $(PROJECT_DIR)/dom/EventTargetFactory.in 857 857 $(PROJECT_DIR)/dom/FocusEvent.idl 858 $(PROJECT_DIR)/dom/FocusOptions.idl 858 859 $(PROJECT_DIR)/dom/GlobalEventHandlers+PointerEvents.idl 859 860 $(PROJECT_DIR)/dom/GlobalEventHandlers+Selection.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r274613 r274812 831 831 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusEvent.cpp 832 832 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusEvent.h 833 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusOptions.cpp 834 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFocusOptions.h 833 835 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFace.cpp 834 836 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSFontFace.h -
trunk/Source/WebCore/DerivedSources.make
r274625 r274812 728 728 $(WebCore)/dom/EventTarget.idl \ 729 729 $(WebCore)/dom/FocusEvent.idl \ 730 $(WebCore)/dom/FocusOptions.idl \ 730 731 $(WebCore)/dom/GlobalEventHandlers+PointerEvents.idl \ 731 732 $(WebCore)/dom/GlobalEventHandlers+Selection.idl \ -
trunk/Source/WebCore/Headers.cmake
r274758 r274812 468 468 dom/ExceptionData.h 469 469 dom/ExceptionOr.h 470 dom/FocusOptions.h 470 471 dom/FragmentScriptingPermission.h 471 472 dom/FullscreenManager.h -
trunk/Source/WebCore/Sources.txt
r274758 r274812 3025 3025 JSFillMode.cpp 3026 3026 JSFocusEvent.cpp 3027 JSFocusOptions.cpp 3027 3028 JSFontFace.cpp 3028 3029 JSFontFaceSet.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r274810 r274812 3608 3608 AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA728F116D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h */; }; 3609 3609 AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC08CF115F941FC00F1E188 /* AccessibilitySVGRoot.h */; }; 3610 AADEFE4525AF4FD60040DD67 /* FocusOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3610 3611 AB23A32809BBA7D00067CC53 /* BeforeTextInsertedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */; }; 3611 3612 AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = AB247A6B0AFD6383003FA5FD /* RenderSlider.h */; }; … … 13174 13175 AA2A5AC716A485D500975A25 /* SpeechSynthesisVoice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisVoice.h; sourceTree = "<group>"; }; 13175 13176 AA2A5AC816A485D500975A25 /* SpeechSynthesisVoice.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisVoice.idl; sourceTree = "<group>"; }; 13177 AA2E0D0925AF5104007693BA /* FocusOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = FocusOptions.idl; sourceTree = "<group>"; }; 13176 13178 AA478A7D16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAccessibilityObjectWrapperMac.h; sourceTree = "<group>"; }; 13177 13179 AA478A7E16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = WebAccessibilityObjectWrapperMac.mm; sourceTree = "<group>"; }; … … 13198 13200 AAD9D0B121DFA80C001B11C7 /* LazyLoadImageObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LazyLoadImageObserver.cpp; sourceTree = "<group>"; }; 13199 13201 AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LazyLoadImageObserver.h; sourceTree = "<group>"; }; 13202 AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FocusOptions.h; sourceTree = "<group>"; }; 13200 13203 AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesizerMock.cpp; sourceTree = "<group>"; }; 13201 13204 AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizerMock.h; sourceTree = "<group>"; }; … … 30330 30333 B6D9D23314EABD260090D75E /* FocusEvent.h */, 30331 30334 B6D9D27214EABF030090D75E /* FocusEvent.idl */, 30335 AADEFE4325AF4FCB0040DD67 /* FocusOptions.h */, 30336 AA2E0D0925AF5104007693BA /* FocusOptions.idl */, 30332 30337 A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */, 30333 30338 CD92F5172261038200F87BB3 /* FullscreenManager.cpp */, … … 32318 32323 062287840B4DB322000C34DF /* FocusDirection.h in Headers */, 32319 32324 B6D9D23514EABD260090D75E /* FocusEvent.h in Headers */, 32325 AADEFE4525AF4FD60040DD67 /* FocusOptions.h in Headers */, 32320 32326 B2C3DA650D006CD600EF6F26 /* Font.h in Headers */, 32321 32327 1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */, -
trunk/Source/WebCore/dom/Element.cpp
r274746 r274812 3041 3041 } 3042 3042 3043 void Element::focus( SelectionRestorationMode restorationMode, FocusDirection direction)3043 void Element::focus(const FocusOptions& options) 3044 3044 { 3045 3045 if (!isConnected()) … … 3085 3085 // If a focus event handler changes the focus to a different node it 3086 3086 // does not make sense to continue and update appearence. 3087 if (!page->focusController().setFocusedElement(newTarget.get(), *document->frame(), direction))3087 if (!page->focusController().setFocusedElement(newTarget.get(), *document->frame(), options.direction)) 3088 3088 return; 3089 3089 } 3090 3090 3091 newTarget->revealFocusedElement(restorationMode); 3091 if (!options.preventScroll) 3092 newTarget->revealFocusedElement(options.selectionRestorationMode); 3092 3093 } 3093 3094 -
trunk/Source/WebCore/dom/Element.h
r274173 r274812 28 28 #include "Document.h" 29 29 #include "ElementData.h" 30 #include "FocusOptions.h" 30 31 #include "HTMLNames.h" 31 32 #include "ScrollTypes.h" … … 402 403 403 404 static AXTextStateChangeIntent defaultFocusTextStateChangeIntent() { return AXTextStateChangeIntent(AXTextStateChangeTypeSelectionMove, AXTextSelection { AXTextSelectionDirectionDiscontiguous, AXTextSelectionGranularityUnknown, true }); } 404 virtual void focus( SelectionRestorationMode = SelectionRestorationMode::RestoreOrSelectAll, FocusDirection = FocusDirection::None);405 virtual void focus(const FocusOptions& = { }); 405 406 void revealFocusedElement(SelectionRestorationMode); 406 407 virtual RefPtr<Element> focusAppearanceUpdateTarget(); -
trunk/Source/WebCore/dom/FocusOptions.h
r274810 r274812 1 1 /* 2 * Copyright (C) 20 19Igalia S.L. All rights reserved.2 * Copyright (C) 2020 Igalia S.L. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // https://html.spec.whatwg.org/multipage/dom.html#htmlorsvgelement 27 // FIXME: update above link when this change has been implemented: 28 // https://github.com/whatwg/html/issues/4702 29 interface mixin HTMLOrForeignElement { 30 [SameObject] readonly attribute DOMStringMap dataset; 31 // FIXME: Implement 'nonce'. 32 // attribute DOMString nonce; // intentionally no [CEReactions] 26 #pragma once 33 27 34 // FIXME: Implement 'autofocus'. 35 // [CEReactions] attribute boolean autofocus; 36 [CEReactions, ImplementedAs=tabIndexForBindings] attribute long tabIndex; 37 // FIMXE: focus() is specified to take an optional FocusOptions. Implement that. 38 undefined focus(); 39 undefined blur(); 28 #include "FocusDirection.h" 29 30 namespace WebCore { 31 32 struct FocusOptions { 33 SelectionRestorationMode selectionRestorationMode { SelectionRestorationMode::RestoreOrSelectAll }; 34 FocusDirection direction { FocusDirection::None }; 35 bool preventScroll { false }; 40 36 }; 37 38 } // namespace WebCore -
trunk/Source/WebCore/dom/FocusOptions.idl
r274810 r274812 1 1 /* 2 * Copyright (C) 20 19Igalia S.L. All rights reserved.2 * Copyright (C) 2020 Igalia S.L. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // https://html.spec.whatwg.org/multipage/dom.html#htmlorsvgelement 27 // FIXME: update above link when this change has been implemented: 28 // https://github.com/whatwg/html/issues/4702 29 interface mixin HTMLOrForeignElement { 30 [SameObject] readonly attribute DOMStringMap dataset; 31 // FIXME: Implement 'nonce'. 32 // attribute DOMString nonce; // intentionally no [CEReactions] 33 34 // FIXME: Implement 'autofocus'. 35 // [CEReactions] attribute boolean autofocus; 36 [CEReactions, ImplementedAs=tabIndexForBindings] attribute long tabIndex; 37 // FIMXE: focus() is specified to take an optional FocusOptions. Implement that. 38 undefined focus(); 39 undefined blur(); 26 dictionary FocusOptions { 27 boolean preventScroll = false; 40 28 }; -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r274029 r274812 255 255 if (frameView && frameView->layoutContext().isInLayout()) { 256 256 frameView->queuePostLayoutCallback([element] { 257 element->focus( SelectionRestorationMode::PlaceCaretAtStart);257 element->focus({ SelectionRestorationMode::PlaceCaretAtStart }); 258 258 }); 259 259 } else { 260 260 Style::queuePostResolutionCallback([element] { 261 element->focus( SelectionRestorationMode::PlaceCaretAtStart);261 element->focus({ SelectionRestorationMode::PlaceCaretAtStart }); 262 262 }); 263 263 } -
trunk/Source/WebCore/html/HTMLLabelElement.cpp
r271930 r274812 173 173 } 174 174 175 void HTMLLabelElement::focus( SelectionRestorationMode restorationMode, FocusDirection direction)175 void HTMLLabelElement::focus(const FocusOptions& options) 176 176 { 177 177 Ref<HTMLLabelElement> protectedThis(*this); … … 180 180 if (isFocusable()) { 181 181 // The value of restorationMode is not used for label elements as it doesn't override updateFocusAppearance. 182 Element::focus( restorationMode, direction);182 Element::focus(options); 183 183 return; 184 184 } … … 187 187 // To match other browsers, always restore previous selection. 188 188 if (auto element = control()) 189 element->focus( SelectionRestorationMode::RestoreOrSelectAll, direction);189 element->focus({ SelectionRestorationMode::RestoreOrSelectAll, options.direction }); 190 190 } 191 191 -
trunk/Source/WebCore/html/HTMLLabelElement.h
r271930 r274812 52 52 void defaultEventHandler(Event&) final; 53 53 54 void focus( SelectionRestorationMode, FocusDirection) final;54 void focus(const FocusOptions&) final; 55 55 56 56 bool isInteractiveContent() const final { return true; } -
trunk/Source/WebCore/html/HTMLLegendElement.cpp
r269587 r274812 58 58 } 59 59 60 void HTMLLegendElement::focus( SelectionRestorationMode restorationMode, FocusDirection direction)60 void HTMLLegendElement::focus(const FocusOptions& options) 61 61 { 62 62 if (document().haveStylesheetsLoaded()) { 63 63 document().updateLayoutIgnorePendingStylesheets(); 64 64 if (isFocusable()) { 65 Element::focus( restorationMode, direction);65 Element::focus({ options.selectionRestorationMode, options.direction }); 66 66 return; 67 67 } … … 70 70 // To match other browsers' behavior, never restore previous selection. 71 71 if (auto control = associatedControl()) 72 control->focus( SelectionRestorationMode::SelectAll, direction);72 control->focus({ SelectionRestorationMode::SelectAll, options.direction }); 73 73 } 74 74 -
trunk/Source/WebCore/html/HTMLLegendElement.h
r269587 r274812 44 44 45 45 bool accessKeyAction(bool sendMouseEvents) final; 46 void focus( SelectionRestorationMode, FocusDirection) final;46 void focus(const FocusOptions&) final; 47 47 }; 48 48 -
trunk/Source/WebCore/html/HTMLOrForeignElement.idl
r267953 r274812 35 35 // [CEReactions] attribute boolean autofocus; 36 36 [CEReactions, ImplementedAs=tabIndexForBindings] attribute long tabIndex; 37 // FIMXE: focus() is specified to take an optional FocusOptions. Implement that. 38 undefined focus(); 37 undefined focus(optional FocusOptions options); 39 38 undefined blur(); 40 39 }; 40 -
trunk/Source/WebCore/html/InputType.cpp
r272180 r274812 639 639 { 640 640 ASSERT(element()); 641 element()->focus( SelectionRestorationMode::SelectAll);641 element()->focus({ SelectionRestorationMode::SelectAll }); 642 642 return false; 643 643 } -
trunk/Source/WebCore/page/FocusController.cpp
r273812 r274812 535 535 536 536 element->setHasFocusVisible(true); 537 element->focus( SelectionRestorationMode::SelectAll, direction);537 element->focus({ SelectionRestorationMode::SelectAll, direction }); 538 538 return true; 539 539 } … … 1109 1109 ASSERT(element); 1110 1110 1111 element->focus( SelectionRestorationMode::SelectAll, direction);1111 element->focus({ SelectionRestorationMode::SelectAll, direction }); 1112 1112 return true; 1113 1113 }
Note: See TracChangeset
for help on using the changeset viewer.