Avoid setting and clearing :active state when dispatching synthetic click events when possible
https://bugs.webkit.org/show_bug.cgi?id=235672
<rdar://problem/88095418>
Reviewed by Simon Fraser.
Source/WebCore:
Simulated click events are dispatched with two options:
- whether to send associated events mouseover, mouseup, mousedown
- whether to repaint the target element with its pressed look
We currently always set the element's :active state just after when we'd
send the mousedown event, and clear it just after that.
When we dispatch a simulated click event with neither of the above
options set, there's no way to observe the temporary :active state on
the element. We can skip it in that case.
We need to continue clearing clearing the :active state regardless,
because some callers have already set :active and are relying on
simulateClick to clear it.
This patch is a 0.3-0.4% improvement on Speedometer 2.
* dom/SimulatedClick.cpp:
(WebCore::simulateClick):
LayoutTests:
* platform/gtk/inspector/timeline/line-column-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0a91f6f..6a12375 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-27 Cameron McCormack <heycam@apple.com>
+
+ Avoid setting and clearing :active state when dispatching synthetic click events when possible
+ https://bugs.webkit.org/show_bug.cgi?id=235672
+ <rdar://problem/88095418>
+
+ Reviewed by Simon Fraser.
+
+ * platform/gtk/inspector/timeline/line-column-expected.txt:
+
2022-01-26 ChangSeok Oh <changseok@webkit.org>
[GTK] WTR: Native HTML form validation popover is not supported
diff --git a/LayoutTests/platform/gtk/inspector/timeline/line-column-expected.txt b/LayoutTests/platform/gtk/inspector/timeline/line-column-expected.txt
index b0a18cf..25f930e 100644
--- a/LayoutTests/platform/gtk/inspector/timeline/line-column-expected.txt
+++ b/LayoutTests/platform/gtk/inspector/timeline/line-column-expected.txt
@@ -8,49 +8,6 @@
PASS: Capturing started.
{
"startTime": "<filtered>",
- "stackTrace": [
- {
- "functionName": "click",
- "url": "[native code]",
- "scriptId": "<filtered>",
- "lineNumber": 0,
- "columnNumber": 0
- },
- {
- "functionName": "willCallFunctionTest",
- "url": "timeline/line-column.html",
- "scriptId": "<filtered>",
- "lineNumber": 26,
- "columnNumber": 44
- },
- {
- "functionName": "global code",
- "url": "",
- "scriptId": "<filtered>",
- "lineNumber": 1,
- "columnNumber": 21
- },
- {
- "functionName": "evaluateWithScopeExtension",
- "url": "[native code]",
- "scriptId": "<filtered>",
- "lineNumber": 0,
- "columnNumber": 0
- },
- {
- "functionName": "",
- "url": "",
- "scriptId": "<filtered>",
- "lineNumber": 142,
- "columnNumber": 97
- }
- ],
- "data": {},
- "frameId": "<filtered>",
- "type": "ScheduleStyleRecalculation"
-}
-{
- "startTime": "<filtered>",
"frameId": "<filtered>",
"data": {
"type": "click",
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index add7cda..f1bfded 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2022-01-27 Cameron McCormack <heycam@apple.com>
+
+ Avoid setting and clearing :active state when dispatching synthetic click events when possible
+ https://bugs.webkit.org/show_bug.cgi?id=235672
+ <rdar://problem/88095418>
+
+ Reviewed by Simon Fraser.
+
+ Simulated click events are dispatched with two options:
+
+ - whether to send associated events mouseover, mouseup, mousedown
+ - whether to repaint the target element with its pressed look
+
+ We currently always set the element's :active state just after when we'd
+ send the mousedown event, and clear it just after that.
+
+ When we dispatch a simulated click event with neither of the above
+ options set, there's no way to observe the temporary :active state on
+ the element. We can skip it in that case.
+
+ We need to continue clearing clearing the :active state regardless,
+ because some callers have already set :active and are relying on
+ simulateClick to clear it.
+
+ This patch is a 0.3-0.4% improvement on Speedometer 2.
+
+ * dom/SimulatedClick.cpp:
+ (WebCore::simulateClick):
+
2022-01-26 Jean-Yves Avenard <jya@apple.com>
REGRESSION(r287684) speedtest.net uses many GB of memory
diff --git a/Source/WebCore/dom/SimulatedClick.cpp b/Source/WebCore/dom/SimulatedClick.cpp
index c9c38d9..52e61a0 100644
--- a/Source/WebCore/dom/SimulatedClick.cpp
+++ b/Source/WebCore/dom/SimulatedClick.cpp
@@ -95,7 +95,8 @@
if (mouseEventOptions != SendNoEvents)
simulateMouseEvent(eventNames().mousedownEvent, element, underlyingEvent, creationOptions);
- element.setActive(true, visualOptions == ShowPressedLook);
+ if (mouseEventOptions != SendNoEvents || visualOptions == ShowPressedLook)
+ element.setActive(true, true);
if (mouseEventOptions != SendNoEvents)
simulateMouseEvent(eventNames().mouseupEvent, element, underlyingEvent, creationOptions);
element.setActive(false);