Change using array of nsINode to array of nsIContent in editor
Categories
(Core :: DOM: Editor, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox75 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
(Blocks 1 open bug)
Details
Attachments
(17 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 |
Currently, a lot of methods handle nodes with nsTArray<OwningNonNull<nsINode>>
, nsTArray<nsCOMPtr<nsINode>>
or nsTArray<nsINode*>
in editor module. However, editor does not handle non-nsIContent
nodes actually. So, we can make them use nsTArray<OwningNonNull<nsIContent>>
etc and make them be free from IsContent()
check.
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
TrivialFunctor
returns always true for DOMIterator::AppendList()
. That
means that DOMIterator
appends all nodes which are listed up by
ContentIterator
. So, it's reasonable to make DOMIterator
have
AppendAllNodesToArray()
because it's more self-documented and faster.
Additionally, BRNodeFunctor
always returns true when nodes with which
HTMLBRElement::FromNode()
returns non-nullptr. So, we can make
AppendAllNodesToArray()
a template class which just checks whether
every nodes are specific node type.
Assignee | ||
Comment 2•5 years ago
|
||
This patch creates DOMIterator::AppendNodesToArray()
which takes pointer to
a functor and removes DOMIterator::AppendList()
. This allows callers to use
lambda rather than the remaining functors, UniqueFunctor
and
EmptyEditableFunctor
, which are used only once. Therefore, writing them as
lambda makes the callers easier to understand. Finally, we can remove those
functor classes' base class, BoolDomIterFunctor
too.
Note that this patch avoids using std::function
even though if we'd use it
as functor, we could make each lambda can capture variables and each lambda
does not need to convert to point of a function with +
operator explicitly.
The reason is, std::function
is too slow if AppendNodesToArray()
is called
in a hot path.
Depends on D61968
Assignee | ||
Comment 3•5 years ago
|
||
Unless editor needs to treat document node, all nodes are sub-class of
nsIContent
. Therefore, we can make HTMLEditor::CollectEditTargetNodes()
return array of nsIContent
instead of array of nsINode
.
Depends on D61969
Assignee | ||
Comment 4•5 years ago
|
||
The content iterators always return nsIContent
even though the result of
GetCurrentNode()
is nsINode*
. Therefore, we can make
HTMLEditor::RemoveEmptyNodesIn()
use array of nsIContent
instead of
array of nsINode
.
Depends on D61970
Assignee | ||
Comment 5•5 years ago
|
||
Same as the previous patch, the content iterator won't return non-nsIContent
node. Therefore, HTMLEditor::HandleDeleteNonCollapsedSelection()
can treat
it with array of nsIContent
.
Depends on D61971
Assignee | ||
Comment 6•5 years ago
|
||
HTMLEditor::CollapseAdjacentTextNodes()
collects editable text nodes first so
that the array can be array of dom::Text
. Additionally, using
DOMSubtreeIterator
instead of ContentSubtreeIterator
makes the code easier
to understand.
Depends on D61972
Assignee | ||
Comment 7•5 years ago
|
||
Helper methods of HTMLEditor::DoInsertHTMLWithContext()
which uses array of
nsINode
is really messy and we can make them simpler. This is first
preparation of a series of refactoring patches of them.
Depends on D61973
Assignee | ||
Comment 8•5 years ago
|
||
HTMLEditor::ScanForListAndTableStructure()
is complicated because it has
2 modes, one is for handling list element, the other is for handling table
element. This patch splits them as 2 methods.
Depends on D61974
Assignee | ||
Comment 9•5 years ago
|
||
The name does not explain what it does. Additionally, it should be same style
as HTMLEditor::IsReplaceableListElement()
for making it easier to understand.
Depends on D61975
Assignee | ||
Comment 10•5 years ago
|
||
It can be a static method and does not make sense taking array of nodes as
input argument because it refers only first or last node of the array.
Depends on D61976
Assignee | ||
Comment 11•5 years ago
|
||
HTMLEditor::CreateListOfNodesToPaste()
can be static and it does not need to
take DocumentFragment
as an argument if the range is always specified.
For avoiding 2 input path to specify a range, we should make it take only
range boundaries and array of nodes to return the collected nodes.
Depends on D61977
Assignee | ||
Comment 12•5 years ago
|
||
HTMLEditor::DiscoverPartialListsAndTables()
can be static and we can make
its definition simpler. However, due to the odd logic, I'm still not sure
what it does. I'll update it after cleaning up its result user,
HTMLEditor::ReplaceOrphanedStructure()
.
Depends on D61978
Assignee | ||
Comment 13•5 years ago
|
||
Unfortunately, even with this cleaning up, I don't understand what it does
because existing comment and what actually it does seem different.
Depends on D61979
Assignee | ||
Comment 14•5 years ago
|
||
In these patches, we know that there are a lot of helper methods to fix node
list which is created by SubtreeContentIterator
and will be inserted into
the editor's DOM tree, and they are not used by other places. So, we can
encapsulate them into a stack only class for making their usage clearer.
Depends on D61980
Assignee | ||
Comment 15•5 years ago
|
||
For guaranteeing the meaning of list or <table>
element in
ReplaceOrphanedStructure()
, it should call DiscoverPartialListsAndTables()
.
Then, their meaning becomes clearer than coming from its parameter.
Depends on D61981
Assignee | ||
Comment 16•5 years ago
|
||
For guaranteeing the meaning of aArrayOfListAndTableRelatedElements
,
ReplaceOrphanedStructure()
should call
CollectListAndTableRelatedElementsAt()
by itself rather than taking as
a parameter.
Then, what it does becomes a little bit clearer. Therefore, this patch renames
ReplaceOrphanedStructure()
to EnsureBeginsOrEndsWithValidContent()
and
DiscoverPartialListsAndTables()
to GetMostAncestorListOrTableElement()
,
and adds a lot of comments.
As far as I've tested by my hand, the behavior is not changed even though
it's really buggy in some cases. We should fix them after writing automated
tests in another bug.
Depends on D61982
Assignee | ||
Comment 17•5 years ago
|
||
Finally, this patch makes HTMLEditor::DoInsertHTMLWithContext()
stop using
array of nsINode
.
Depends on D61983
Assignee | ||
Comment 18•5 years ago
|
||
I'll land each patch separately after the merge. So, feel free to put off to review them.
Assignee | ||
Comment 19•5 years ago
|
||
And also feel free to write any patches for editor because each patch does really simple things so that it's easy to rebase.
Comment 20•5 years ago
|
||
Comment 21•5 years ago
|
||
bugherder |
Comment 22•5 years ago
|
||
Updated•5 years ago
|
Comment 23•5 years ago
|
||
Comment 24•5 years ago
|
||
Comment 25•5 years ago
|
||
Comment 26•5 years ago
|
||
Comment 27•5 years ago
|
||
bugherder |
Comment 28•5 years ago
|
||
Comment 29•5 years ago
|
||
bugherder |
Comment 30•5 years ago
|
||
Comment 31•5 years ago
|
||
Comment 32•5 years ago
|
||
bugherder |
Comment 33•5 years ago
|
||
Comment 34•5 years ago
|
||
bugherder |
Comment 35•5 years ago
|
||
Comment 36•5 years ago
|
||
Comment 37•5 years ago
|
||
bugherder |
Comment 38•5 years ago
|
||
Comment 39•5 years ago
|
||
bugherder |
Comment 40•5 years ago
|
||
Comment 41•5 years ago
|
||
Comment 42•5 years ago
|
||
bugherder |
Comment 43•5 years ago
|
||
Comment 44•5 years ago
|
||
bugherder |
Assignee | ||
Updated•5 years ago
|
Description
•