Skip to content

Commit

Permalink
Move onbeforematch to GlobalEventHandlers
Browse files Browse the repository at this point in the history
Most event handlers like this should be in GlobalEventHandlers:
whatwg/html#7475 (comment)

R=vmpstr@chromium.org

Bug: 1055002
Change-Id: I30fbf99b17db3703d8fb133bb3c581de2fa02141
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3530434
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#983452}
NOKEYCHECK=True
GitOrigin-RevId: 695d94e6e2196d7fa86678a9a388fd679ef30fd4
  • Loading branch information
josepharhar authored and copybara-github committed Mar 21, 2022
1 parent e9dfcb5 commit 82b8b65
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 4 deletions.
1 change: 0 additions & 1 deletion blink/renderer/core/dom/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class CORE_EXPORT Element : public ContainerNode, public Animatable {
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut, kBeforecut)
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste, kBeforepaste)
DEFINE_ATTRIBUTE_EVENT_LISTENER(search, kSearch)
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforematch, kBeforematch)

bool hasAttribute(const QualifiedName&) const;
const AtomicString& getAttribute(const QualifiedName&) const;
Expand Down
1 change: 0 additions & 1 deletion blink/renderer/core/dom/element.idl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ callback ScrollStateCallback = void (ScrollState scrollState);
attribute EventHandler onbeforecut;
attribute EventHandler onbeforepaste;
attribute EventHandler onsearch;
[RuntimeEnabled=BeforeMatchEvent] attribute EventHandler onbeforematch;

// Element Timing
[CEReactions, Reflect=elementtiming] attribute DOMString elementTiming;
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/core/dom/global_event_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class GlobalEventHandlers {
kAnimationiteration)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(animationstart, kAnimationstart)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(auxclick, kAuxclick)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(beforematch, kBeforematch)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(blur, kBlur)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(cancel, kCancel)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(canplay, kCanplay)
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/core/dom/global_event_handlers.idl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
LegacyTreatAsPartialInterface
] interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
[RuntimeEnabled=BeforeMatchEvent] attribute EventHandler onbeforematch;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
Expand Down
16 changes: 16 additions & 0 deletions blink/web_tests/editing/text-iterator/onbeforematch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/pull/7475#issuecomment-1068519935">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<div id=target hidden=until-found>hello</div>

<script>
test(() => {
let beforematchHandled = false;
target.onbeforematch = () => beforematchHandled = true;
testRunner.findString('hello', []);
assert_true(beforematchHandled);
}, `Verifies that element.onbeforematch registers a beforematch event handler.`);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ PASS oldChildWindow.onanimationstart is newChildWindow.onanimationstart
PASS oldChildWindow.onappinstalled is newChildWindow.onappinstalled
PASS oldChildWindow.onauxclick is newChildWindow.onauxclick
PASS oldChildWindow.onbeforeinstallprompt is newChildWindow.onbeforeinstallprompt
PASS oldChildWindow.onbeforematch is newChildWindow.onbeforematch
PASS oldChildWindow.onbeforeprint is newChildWindow.onbeforeprint
PASS oldChildWindow.onbeforeunload is newChildWindow.onbeforeunload
PASS oldChildWindow.onbeforexrselect is newChildWindow.onbeforexrselect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PASS childWindow.onanimationstart is null
PASS childWindow.onappinstalled is null
PASS childWindow.onauxclick is null
PASS childWindow.onbeforeinstallprompt is null
PASS childWindow.onbeforematch is null
PASS childWindow.onbeforeprint is null
PASS childWindow.onbeforeunload is null
PASS childWindow.onbeforexrselect is null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PASS childWindow.onanimationstart is null
PASS childWindow.onappinstalled is null
PASS childWindow.onauxclick is null
PASS childWindow.onbeforeinstallprompt is null
PASS childWindow.onbeforematch is null
PASS childWindow.onbeforeprint is null
PASS childWindow.onbeforeunload is null
PASS childWindow.onbeforexrselect is null
Expand Down
12 changes: 10 additions & 2 deletions blink/web_tests/webexposed/global-interface-listing-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ interface Document : Node
getter onauxclick
getter onbeforecopy
getter onbeforecut
getter onbeforematch
getter onbeforepaste
getter onbeforexrselect
getter onblur
Expand Down Expand Up @@ -1980,6 +1981,7 @@ interface Document : Node
setter onauxclick
setter onbeforecopy
setter onbeforecut
setter onbeforematch
setter onbeforepaste
setter onbeforexrselect
setter onblur
Expand Down Expand Up @@ -2239,7 +2241,6 @@ interface Element : Node
getter nextElementSibling
getter onbeforecopy
getter onbeforecut
getter onbeforematch
getter onbeforepaste
getter onfullscreenchange
getter onfullscreenerror
Expand Down Expand Up @@ -2368,7 +2369,6 @@ interface Element : Node
setter innerHTML
setter onbeforecopy
setter onbeforecut
setter onbeforematch
setter onbeforepaste
setter onfullscreenchange
setter onfullscreenerror
Expand Down Expand Up @@ -3170,6 +3170,7 @@ interface HTMLElement : Element
getter onanimationiteration
getter onanimationstart
getter onauxclick
getter onbeforematch
getter onbeforexrselect
getter onblur
getter oncancel
Expand Down Expand Up @@ -3294,6 +3295,7 @@ interface HTMLElement : Element
setter onanimationiteration
setter onanimationstart
setter onauxclick
setter onbeforematch
setter onbeforexrselect
setter onblur
setter oncancel
Expand Down Expand Up @@ -5071,6 +5073,7 @@ interface MathMLElement : Element
getter onanimationiteration
getter onanimationstart
getter onauxclick
getter onbeforematch
getter onbeforexrselect
getter onblur
getter oncancel
Expand Down Expand Up @@ -5177,6 +5180,7 @@ interface MathMLElement : Element
setter onanimationiteration
setter onanimationstart
setter onauxclick
setter onbeforematch
setter onbeforexrselect
setter onblur
setter oncancel
Expand Down Expand Up @@ -7271,6 +7275,7 @@ interface SVGElement : Element
getter onanimationiteration
getter onanimationstart
getter onauxclick
getter onbeforematch
getter onbeforexrselect
getter onblur
getter oncancel
Expand Down Expand Up @@ -7379,6 +7384,7 @@ interface SVGElement : Element
setter onanimationiteration
setter onanimationstart
setter onauxclick
setter onbeforematch
setter onbeforexrselect
setter onblur
setter oncancel
Expand Down Expand Up @@ -11520,6 +11526,7 @@ namespace CSS
getter onappinstalled
getter onauxclick
getter onbeforeinstallprompt
getter onbeforematch
getter onbeforeprint
getter onbeforeunload
getter onbeforexrselect
Expand Down Expand Up @@ -11741,6 +11748,7 @@ namespace CSS
setter onappinstalled
setter onauxclick
setter onbeforeinstallprompt
setter onbeforematch
setter onbeforeprint
setter onbeforeunload
setter onbeforexrselect
Expand Down

0 comments on commit 82b8b65

Please sign in to comment.