`HTMLEditUtils::Get(Inclusive)?AncestorBlockElement` may cross editing host boundaries
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox93 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
(Blocks 2 open bugs, Regressed 1 open bug)
Details
Attachments
(21 files)
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details |
These utility methods take only ancestor limiter, but it does not check whether it meets another editing host boundary. E.g., when the start content is in a child editing host of focused editing host, they may return non-editable block element.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 1•3 years ago
|
||
There are a lot of ancestor scanners in HTMLEditUtils
. This is good thing
for the performance, but it makes us hard to maintain. Therefore, we should
merge them as far as possible.
Assignee | ||
Comment 2•3 years ago
|
||
It does not check whether it meets a non-editable parent or not. Therefore,
it may cross another editing host boundary when aContent
is in a nested
editing host.
So, this patch fixes some edge cases when editing hosts are nested and
scanning from inner editing host.
Depends on D122939
Assignee | ||
Comment 3•3 years ago
|
||
Depends on D122940
Assignee | ||
Comment 4•3 years ago
|
||
Depends on D122941
Assignee | ||
Comment 5•3 years ago
|
||
With the new tests, I see the implementation is completely broken. It tries
to return block level element's background color, but it assumes that inline
elements are never parent of block elements. Therefore, this patch fixes the
bug too.
Note that this feature (retrieving only block level background color) is
Gecko specific and not available from the web. Therefore, it tests this change
with XPCOM interfaces directly.
Depends on D122942
Assignee | ||
Comment 6•3 years ago
|
||
Depends on D122943
Assignee | ||
Comment 7•3 years ago
|
||
This patch fixes a bug of setting background color of block parent. It should
not work with contenteditable
in the comm-central applications, but we should
make it modify only editable block parent.
Depends on D122944
Assignee | ||
Comment 8•3 years ago
|
||
Depends on D122945
Assignee | ||
Comment 9•3 years ago
|
||
For keeping current behavior, the options should be set to
HTMLEditUtils::ClosestEditableBlockElement
, but it may cause returning
nullptr
if the text node is in an inline editing host, and also cause
returning true from the method even when the text nodes are in different
inline editing hosts. Therefore, this patch uses
HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost
instead.
Depends on D122946
Assignee | ||
Comment 10•3 years ago
|
||
The "state" is not limited by editing host nor editable nodes. Therefore, it
should keep scanning ancestor block element without checking editable state.
Depends on D122947
Assignee | ||
Comment 11•3 years ago
|
||
I have following patches for them, but I still don't add automated tests for them. I'll try to post them tomorrow.
Assignee | ||
Comment 12•3 years ago
|
||
I have no idea how to test this without making unrealistic cases with legacy
mutation event listeners because now, Gecko ignores selection ranges which
crosses editing host boundaries when it tries to delete selection.
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/HTMLEditorDeleteHandler.cpp#1120
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#137
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#119-125
So, aRangesToDelete.FirstRangeRef()
shouldn't be in different editing host.
Depends on D122948
Comment 13•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/df2b5e5da3b3 part 1: Redesign `HTMLEditUtils::ClosestEditableBlockElementOrEditingHost()` with `enum class` r=m_kato
Comment 14•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/ff0e2e535916 part 2: Get rid of `HTMLEditUtils::GetInclusiveAncestorBlockElementExceptHRElement` r=m_kato
Assignee | ||
Comment 15•3 years ago
|
||
I have no idea how to test this, but I believe that checking non-editable
block element must be correct here because it checks whether the block is
empty or not for merging lines.
Depends on D123029
Assignee | ||
Comment 16•3 years ago
|
||
Additionally, the given content may be in a nested editing host. Then, this
method may delete a nested-block editing host if it's empty. Therefore,
this patch get rid of aEditingHost
and check same thing with
HTMLEditUtils::IsRemovableFromParentNode()
.
Depends on D123066
Comment 17•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/117469e0f097 part 3: Make `HTMLEditor::MaybeCollapseSelectionAtFirstEditableNode()` use `HTMLEditUtils::GetAncestorElement()` r=m_kato
Assignee | ||
Comment 18•3 years ago
|
||
I have no idea how to test this without making unrealistic cases with legacy
mutation event listeners because now, Gecko ignores selection ranges which
crosses editing host boundaries when it tries to delete selection.
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/HTMLEditorDeleteHandler.cpp#1120
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#137
- https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#119-125
And invisible white-spaces appear end of a block or start of a block, i.e.,
both block parents in the range boundaries are always editable in normal cases.
So, such range should be ignored first.
Depends on D123067
Assignee | ||
Comment 19•3 years ago
|
||
The method assumes two wrong things:
- The padding
<br>
element flag may not be set (another bug) - There may be
<br>
element which is created by the web app
But its callers want to put caret at invisible <br>
element if selection
is collapsed after it. Therefore, this patch fixes the method for passing
the new tests and rename it.
And also this patch changes the expected result of some tests in inserthtml.js
because their expected result are based on Gecko, i.e., both Blink/WebKit
fail, but their result is better for keeping the invisible <br>
element
visibility.
https://wpt.fyi/results/editing/run/inserthtml.html?run_id=5747864689967104&run_id=5201845715730432&run_id=5735315550502912&run_id=5763864667881472
Depends on D123068
Assignee | ||
Comment 20•3 years ago
|
||
Comparing found editable block with editing host does not make sense if
focused editing host has another editing host and selection is in the
child editing host since the child editing host should be compared with the
found block element. Therefore, this patch makes it use IsSplittableNode()
instead of the comparing.
Depends on D123069
Assignee | ||
Comment 21•3 years ago
|
||
Depends on D123070
Assignee | ||
Comment 22•3 years ago
|
||
Depends on D123071
Assignee | ||
Comment 23•3 years ago
|
||
I have no idea how to write test for this kind of preparation method of
following range computation to do something.
Depends on D123072
Assignee | ||
Comment 24•3 years ago
|
||
Depends on D123073
Assignee | ||
Comment 25•3 years ago
|
||
I have no idea how to test this because this method is a clean up method
after handling everything. This patch just adds same editing host check,
but the others are not changed.
Finally, the legacy APIs are not used anymore. So, let's remove them!
Depends on D123074
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/30086 for changes under testing/web-platform/tests
Comment 27•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/ae7ce0245ffb part 4: Make `HTMLEditor::HandleKeyPressEvent()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 28•3 years ago
|
||
bugherder |
Comment 29•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/020ce29803ef part 5: Make `HTMLEditor::GetCSSBackgroundColorState()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 30•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/0bd2f11802ca part 6: Make `HTMLEditor::RemoveEmptyInclusiveAncestorInlineElements()` use `HTMLEditUtils::GetAncestorElement()` r=m_kato
Comment 31•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/82b658998176 part 7: Make `HTMLEditor::SetCSSBackgroundColorWithTransaction()` use `HTMLEditUtils::Get(Inclusive)AncestorElement()` r=m_kato
Comment 32•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/ae248eba41f4 part 8: Make `HTMLEditor::HTMLWithContextInserter::InsertContents()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
![]() |
||
Comment 33•3 years ago
|
||
bugherder |
Comment 34•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/d2c427de0939 part 9: Make `TextServicesDocument::HasSameBlockNodeParent()` use `HTMLEditUtils::GetAncestorElement()` r=m_kato
Comment 35•3 years ago
|
||
bugherder |
Upstream PR merged by moz-wptsync-bot
Comment 37•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/3b9b5769152e part 10: Make the constructor of `AlignStateAtSelection` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/30114 for changes under testing/web-platform/tests
Comment 39•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/7af78405aade part 11: Make `AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRanges()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 40•3 years ago
|
||
bugherder |
Comment 41•3 years ago
|
||
bugherder |
Comment 42•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/62290dcae04e part 12: Make `HTMLEditor::CanMoveOrDeleteSomethingInHardLine()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato https://hg.mozilla.org/integration/autoland/rev/30478b345a7e part 13: Make `AutoEmptyBlockAncestorDeleter::ScanEmptyBlockInclusiveAncestor()` use `HTMLEditUtils::Get(Inclusive)AncestorElement()` r=m_kato
Assignee | ||
Updated•3 years ago
|
Comment 43•3 years ago
|
||
bugherder |
Comment 44•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/b016b162fde1 part 14: Make `AutoDeleteRangesHandler::ExtendRangeToIncludeInvisibleNodes()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 45•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/61c466d08db1 part 15: Make `HTMLEditor::EnsureCaretNotAfterPaddingBRElement()` use `HTMLEditUtils::Get(Inclusive)AncestorElement()` r=m_kato
Comment 46•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/24080f662446 part 16: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction()` use `HTMLEditUtils::Get(Inclusive)AncestorElement()` and `HTMLEditUtils::IsSplittableNode()` r=m_kato
Comment 47•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/35c243277dad part 17: Make `HTMLEditor::FormatBlockContainerWithTransaction()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 48•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/ede71729f08c part 18: Make `HTMLEditor::HandleCSSIndentAtSelectionInternal()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 49•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/895581338857 part 19: Make `HTMLEditor::SelectBRElementIfCollapsedInEmptyBlock()` use `HTMLEditUtils::GetInclusiveAncestorElement()` r=m_kato
Comment 50•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/54ef3dd91e3d part 20: Make `HTMLEditor::RemoveBlockContainerElements()` use `HTMLEditUtils::GetAncestorElement()` r=m_kato
Comment 51•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/571fa8e5ae51 part 21: Make `HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement()` use `HTMLEditUtils::Get(Inclusive)AncestorElement()` r=m_kato
Assignee | ||
Updated•3 years ago
|
Comment 52•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b016b162fde1
https://hg.mozilla.org/mozilla-central/rev/61c466d08db1
https://hg.mozilla.org/mozilla-central/rev/24080f662446
https://hg.mozilla.org/mozilla-central/rev/35c243277dad
https://hg.mozilla.org/mozilla-central/rev/ede71729f08c
https://hg.mozilla.org/mozilla-central/rev/895581338857
Upstream PR merged by moz-wptsync-bot
Comment 54•3 years ago
|
||
bugherder |
Description
•