[forms] Prevent contenteditable anchors from being stuck
https://bugs.webkit.org/show_bug.cgi?id=235438
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Update 1 WPT test expectation file as the test is now passing.
* web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt:
Source/WebCore:
Anchors can be stuck in the :active state if contenteditable is enabled before
:active is removed. With this patch setActive() can remove :active during
contenteditable in order to prevent anchors from navigating during contenteditable.
This is an import of Chromium CL at
https://chromium-review.googlesource.com/c/chromium/src/+/2595978
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::setActive):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288420 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 7d00e11..4d8c2a6 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-23 Ziran Sun <zsun@igalia.com>
+
+ [forms] Prevent contenteditable anchors from being stuck
+ https://bugs.webkit.org/show_bug.cgi?id=235438
+
+ Reviewed by Darin Adler.
+
+ Update 1 WPT test expectation file as the test is now passing.
+ * web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt:
+
2022-01-21 Antoine Quint <graouts@webkit.org>
Update css/css-animation WPT following animation-composition testing updates
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt
index f4b3e80..63469f9 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/anchor-active-contenteditable-expected.txt
@@ -1,4 +1,4 @@
anchor
-FAIL Anchor elements should not stay :active when contentEditable is enabled. assert_equals: expected null but got Element node <a id="anchorid" href="nonexistant" contenteditable="true...
+PASS Anchor elements should not stay :active when contentEditable is enabled.
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 00df1c0..5569409 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2022-01-23 Ziran Sun <zsun@igalia.com>
+
+ [forms] Prevent contenteditable anchors from being stuck
+ https://bugs.webkit.org/show_bug.cgi?id=235438
+
+ Reviewed by Darin Adler.
+
+ Anchors can be stuck in the :active state if contenteditable is enabled before
+ :active is removed. With this patch setActive() can remove :active during
+ contenteditable in order to prevent anchors from navigating during contenteditable.
+
+ This is an import of Chromium CL at
+ https://chromium-review.googlesource.com/c/chromium/src/+/2595978
+
+ * html/HTMLAnchorElement.cpp:
+ (WebCore::HTMLAnchorElement::setActive):
+
2022-01-23 Tyler Wilcock <tyler_w@apple.com>
AX: Refactor near-duplicate AXObjectCache::updateIsolatedTree implementations
diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
index ce784f0..d924391 100644
--- a/Source/WebCore/html/HTMLAnchorElement.cpp
+++ b/Source/WebCore/html/HTMLAnchorElement.cpp
@@ -213,7 +213,7 @@
void HTMLAnchorElement::setActive(bool down, bool pause, Style::InvalidationScope invalidationScope)
{
- if (hasEditableStyle()) {
+ if (down && hasEditableStyle()) {
switch (document().settings().editableLinkBehavior()) {
case EditableLinkBehavior::Default:
case EditableLinkBehavior::AlwaysLive: