Closed Bug 1798379 Opened 3 years ago Closed 1 year ago

Caret doesn't disappear when designMode turns off

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

VERIFIED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: dholbert, Assigned: masayuki)

References

Details

Attachments

(3 files)

Attached file testcase 1

STR:

  1. Load attached testcase.
  2. Wait for document to change color from green to red back to green.

ACTUAL RESULTS:
The blinking caret (from when the document was red and editable) remains and continues blinking after the document changes back to green/non-editable.

EXPECTED RESULTS:
Caret should disappear when document becomes non-editable.

This seems to be the underlying issue behind intermittent bug 1788320. As noted in bug 1788320 comment 19, I can actually reproduce this at least as far back as Nightly 2011-01-01 (4.0 prerelease) with the old-build-friendly "testcase 2" attached on that bug.

ni=masayuki to take a look if he's interested, though this probably isn't super urgent given that this feature's probably not frequently used and the bad-outcome isn't too bad, and we've had this bug ~forever.

Flags: needinfo?(masayuki)
Blocks: 1788320
Attached video screencast of bug
Severity: -- → S3
Priority: -- → P3

Talked with Masayuki - this is a nice bug for people who want to learn how editor is initialized and finalized.

Hmm, fixing bug 1807495 didn't fix this...

Okay, I got it. When HTMLEditor is notified of the blur, the state in the ducument may have already been updated. Therefore, it fails to call its OnBlur.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Flags: needinfo?(masayuki)

HTMLEditor currently checks whether it's in the designMode or not with
checking the Document node is in the designMode. I.e., it checks the
real-time state of the Document node. However, if an instance was in the
designMode, it needs to finalize Selection even after the Document node
becomes not in the designMode. Additionally, elements in a shadow DOM in the
designMode can have contenteditable to make it editable. Then, the editable
elements should works as in the contenteditable mode rather than in the
designMode. Therefore, current HTMLEditor::IsInDesignMode() returns
wrong state when the finalization is called asynchronously or when an editing
host in a shadow DOM whose composed document is in the designMode.

This patch fixes known cases of these issues with improving the finalization
(and re-initialization with the new editing mode) and the caller side in
Document.

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/71abd7d91e8f Make `HTMLEditor` store whether it has/had focus and is/was in the `designMode` by itself r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47103 for changes under testing/web-platform/tests

Backed out for causing for causing bustages related to HTMLEditor.cpp

[task 2024-07-12T00:25:39.998Z] 00:25:39     INFO -  gfx/skia/SkBitmapProcState.o
[task 2024-07-12T00:25:39.998Z] 00:25:39     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/skia'
[task 2024-07-12T00:25:40.091Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/editor/libeditor'
[task 2024-07-12T00:25:40.094Z] 00:25:40     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -o Unified_cpp_editor_libeditor1.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DMOZ_SUPPORT_LEAKCHECKING -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/editor/libeditor -I/builds/worker/workspace/obj-build/editor/libeditor -I/builds/worker/checkouts/gecko/dom/base -I/builds/worker/checkouts/gecko/dom/html -I/builds/worker/checkouts/gecko/extensions/spellcheck/src -I/builds/worker/checkouts/gecko/layout/generic -I/builds/worker/checkouts/gecko/layout/style -I/builds/worker/checkouts/gecko/layout/tables -I/builds/worker/checkouts/gecko/layout/xul -I/builds/worker/workspace/obj-build/ipc/ipdl/_ipdlheaders -I/builds/worker/checkouts/gecko/ipc/chromium/src -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -D_GLIBCXX_USE_CXX11_ABI=0 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Werror -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/Unified_cpp_editor_libeditor1.o.pp   Unified_cpp_editor_libeditor1.cpp
[task 2024-07-12T00:25:40.095Z] 00:25:40     INFO -  In file included from Unified_cpp_editor_libeditor1.cpp:56:
[task 2024-07-12T00:25:40.096Z] 00:25:40    ERROR -  /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditor.cpp:758:18: error: unused variable 'rv' [-Werror,-Wunused-variable]
[task 2024-07-12T00:25:40.096Z] 00:25:40     INFO -    758 |         nsresult rv = FinalizeSelection();
[task 2024-07-12T00:25:40.096Z] 00:25:40     INFO -        |                  ^~
[task 2024-07-12T00:25:40.096Z] 00:25:40     INFO -  1 error generated.
[task 2024-07-12T00:25:40.096Z] 00:25:40    ERROR -  gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:676: Unified_cpp_editor_libeditor1.o] Error 1
[task 2024-07-12T00:25:40.096Z] 00:25:40     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/editor/libeditor'
[task 2024-07-12T00:25:40.101Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/skia'
[task 2024-07-12T00:25:40.102Z] 00:25:40     INFO -  gfx/skia/SkBitmapProcState_matrixProcs.o
[task 2024-07-12T00:25:40.102Z] 00:25:40     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/skia'
[task 2024-07-12T00:25:40.213Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.217Z] 00:25:40     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu99 -o cairo-xlib-xcb-surface.o -c  -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DHAVE_FT_LOAD_SFNT_TABLE '-DPACKAGE_VERSION="moz"' '-DPACKAGE_BUGREPORT="http://bugzilla.mozilla.org/"' -DCAIRO_HAS_PTHREAD -D_GNU_SOURCE -DMOZ_TREE_PIXMAN -DSIZEOF_VOID_P=__SIZEOF_POINTER__ -DSIZEOF_INT=__SIZEOF_INT__ -DSIZEOF_LONG=__SIZEOF_LONG__ -DSIZEOF_LONG_LONG=__SIZEOF_LONG_LONG__ -DHAVE_UINT64_T -DHAVE_CXX11_ATOMIC_PRIMITIVES -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DMOZ_SUPPORT_LEAKCHECKING -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/gfx/cairo/cairo/src -I/builds/worker/workspace/obj-build/gfx/cairo/cairo/src -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -pthread -ffunction-sections -fdata-sections -fno-math-errno -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wclass-varargs -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wstring-conversion -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Werror=implicit-function-declaration -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Wno-enum-compare -Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-sign-compare -Wno-type-limits -Wno-missing-field-initializers -Wno-conversion -Wno-narrowing -Wno-switch -Wno-unused -Wno-unused-variable -Wno-error=uninitialized -Wno-absolute-value -Wno-deprecated-register -Wno-incompatible-pointer-types -Wno-macro-redefined -Wno-shift-negative-value -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-unreachable-code -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/cairo-xlib-xcb-surface.o.pp   /builds/worker/checkouts/gecko/gfx/cairo/cairo/src/cairo-xlib-xcb-surface.c
[task 2024-07-12T00:25:40.218Z] 00:25:40     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.218Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.218Z] 00:25:40     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.218Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.219Z] 00:25:40     INFO -  gfx/cairo/cairo/src/Unified_c_gfx_cairo_cairo_src0.o
[task 2024-07-12T00:25:40.219Z] 00:25:40     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/cairo/cairo/src'
[task 2024-07-12T00:25:40.281Z] 00:25:40     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/angle/targets/translator'
[task 2024-07-12T00:25:40.285Z] 00:25:40     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -o Operator.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DANGLE_PLATFORM_EXPORT= -D__NDK_FPABI__= -DANGLE_SKIP_DXGI_1_2_CHECK -DANGLE_ENABLE_KEYEDMUTEX -DANGLE_TRANSLATOR_ESSL_ONLY -DANGLE_DISABLE_POOL_ALLOC -DANGLE_ENABLE_APPLE_WORKAROUNDS -DANGLE_ENABLE_ESSL -DANGLE_ENABLE_GLSL -DANGLE_ENABLE_HLSL -DANGLE_ENABLE_SHARE_CONTEXT_LOCK=1 -DANGLE_VMA_VERSION=2003000 '-DCR_CLANG_REVISION="llvmorg-16-init-6578-g0d30e92f-2"' -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DNOMINMAX -DUNICODE -DWINVER=0x0A00 -D_ATL_NO_OPENGL -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SECURE_ATL -D_UNICODE -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/builds/worker/checkouts/gecko/gfx/angle/targets/translator -I/builds/worker/workspace/obj-build/gfx/angle/targets/translator -I/builds/worker/checkouts/gecko/gfx/angle/checkout/include -I/builds/worker/checkouts/gecko/gfx/angle/checkout/src -I/builds/worker/checkouts/gecko/gfx/angle/checkout/src/common/third_party/base -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -D_GLIBCXX_USE_CXX11_ABI=0 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-final-dtor-non-final-class -Wno-implicit-const-int-float-conversion -Wno-range-loop-construct -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -msse2 -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/Operator.o.pp   /builds/worker/checkouts/gecko/gfx/angle/checkout/src/compiler/translator/Operator.cpp
Flags: needinfo?(masayuki)
Upstream PR was closed without merging
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/f0b82b83f263 Make `HTMLEditor` store whether it has/had focus and is/was in the `designMode` by itself r=m_kato
Flags: needinfo?(masayuki)
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
Upstream PR merged by moz-wptsync-bot
No longer regressed by: 1910800
Regressions: 1910800
Flags: qe-verify+

Reproduced the issue with Firefox 108.0a1 (2022-10-31) on macOS 14.
The issue is verified fixed with Firefox 131.0a1 (20240807215007) and Firefox 130.0b2 (20240807091924) onWindows 10, macOS 14 and Ubuntu 22.

Status: RESOLVED → VERIFIED
Has STR: --- → yes
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: