Closed
Bug 1153629
Opened 9 years ago
Closed 9 years ago
Clean up nsHTMLEditRules::GetListActionNodes, GetParagraphFormatNodes, GeNodesFromPoint, ListIsEmptyLine, GetChildNodesForOperation, MakeBlockquote, RemoveBlockStyle, RemovePartOfBlock, ApplyBlockStyle, MakeTransitionList, AlignInnerBlocks, etc.
Categories
(Core :: DOM: Editor, enhancement)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla40
Tracking | Status | |
---|---|---|
firefox40 | --- | fixed |
People
(Reporter: ayg, Assigned: ayg)
References
Details
Attachments
(12 files)
16.79 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
11.57 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
7.08 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
18.50 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
6.87 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
7.64 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
14.28 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
14.34 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
8.57 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
6.78 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
5.01 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
11.24 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
This patchset will remove all nsCOMArray from nsHTMLEditRules.
Flags: in-testsuite-
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8592776 -
Flags: review?(ehsan)
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8592780 -
Flags: review?(ehsan)
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8592781 -
Flags: review?(ehsan)
Assignee | ||
Comment 4•9 years ago
|
||
Attachment #8592783 -
Flags: review?(ehsan)
Assignee | ||
Comment 5•9 years ago
|
||
Attachment #8592784 -
Flags: review?(ehsan)
Assignee | ||
Comment 6•9 years ago
|
||
Attachment #8592786 -
Flags: review?(ehsan)
Assignee | ||
Comment 7•9 years ago
|
||
I removed the out params from RemovePartOfBlock since nothing was using them. I've been replacing (Content)IsDescendantOf calls with Contains(), because it's nicer to read. Recently I became a bit unsure when I realized that Contains() silently returns false if passed a null pointer, instead of asserting. Does it make sense to use it?
Attachment #8592789 -
Flags: review?(ehsan)
Assignee | ||
Comment 8•9 years ago
|
||
Attachment #8592790 -
Flags: review?(ehsan)
Assignee | ||
Comment 9•9 years ago
|
||
There was an incorrect comment: "Different parents, or separated by <br>: transition point". The function doesn't check for <br>, but maybe it was supposed to? I fixed the comment to match the function.
Attachment #8592791 -
Flags: review?(ehsan)
Assignee | ||
Comment 10•9 years ago
|
||
Attachment #8592792 -
Flags: review?(ehsan)
Assignee | ||
Comment 11•9 years ago
|
||
Attachment #8592795 -
Flags: review?(ehsan)
Assignee | ||
Comment 12•9 years ago
|
||
Attachment #8592798 -
Flags: review?(ehsan)
Assignee | ||
Comment 13•9 years ago
|
||
Green try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=5c8bc8694cf2
Updated•9 years ago
|
Attachment #8592776 -
Flags: review?(ehsan) → review+
Comment 14•9 years ago
|
||
Comment on attachment 8592780 [details] [diff] [review] Part 2 - Clean up nsHTMLEditRules::GetParagraphFormatNodes Review of attachment 8592780 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/libeditor/nsHTMLEditRules.cpp @@ +1067,5 @@ > // post process list. We need to replace any block nodes that are not format > // nodes with their content. This is so we only have to look "up" the hierarchy > // to find format nodes, instead of both up and down. > + for (int32_t i = arrayOfNodes.Length() - 1; i >= 0; i--) { > + auto& curNode = arrayOfNodes[i]; Couldn't you do: for (auto& curNode : Reversed(arrayOfNodes)) { ?
Attachment #8592780 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592781 -
Flags: review?(ehsan) → review+
Comment 15•9 years ago
|
||
Comment on attachment 8592783 [details] [diff] [review] Part 4 - Clean up nsHTMLEditRules::ListIsEmptyLine Review of attachment 8592783 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/libeditor/nsHTMLEditRules.cpp @@ +3515,5 @@ > NS_ENSURE_STATE(theBlock); > // remember our new block for postprocessing > mNewBlock = theBlock; > // delete anything that was in the list of nodes > + for (int32_t j = arrayOfNodes.Length() - 1; j >= 0; j--) { Nit: Can you please rewrite this as: while (!arrayOfNodes.IsEmpty()) { The current structure of the loop kind of suggests that there's a bug in it. @@ +3659,5 @@ > // remember our new block for postprocessing > mNewBlock = theBlock->AsDOMNode(); > RelativeChangeIndentationOfElementNode(theBlock->AsDOMNode(), +1); > // delete anything that was in the list of nodes > + for (int32_t j = arrayOfNodes.Length() - 1; j >= 0; j--) { Here too. @@ +3845,5 @@ > // remember our new block for postprocessing > mNewBlock = theBlock->AsDOMNode(); > // delete anything that was in the list of nodes > + for (int32_t j = arrayOfNodes.Length() - 1; j >= 0; j--) { > + nsCOMPtr<nsINode> curNode = arrayOfNodes[0]; And here. @@ +8929,5 @@ > // remember our new block for postprocessing > mNewBlock = thePositionedDiv->AsDOMNode(); > // delete anything that was in the list of nodes > + for (int32_t j = arrayOfNodes.Length() - 1; j >= 0; j--) { > + nsCOMPtr<nsINode> curNode = arrayOfNodes[0]; Ditto.
Attachment #8592783 -
Flags: review?(ehsan) → review+
Comment 16•9 years ago
|
||
Comment on attachment 8592784 [details] [diff] [review] Part 5 - Clean up nsHTMLEditRules::GetChildNodesForOperation Review of attachment 8592784 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/libeditor/nsHTMLEditRules.h @@ +274,5 @@ > nsresult GetNodesForOperation(nsTArray<nsRefPtr<nsRange>>& aArrayOfRanges, > nsTArray<nsCOMPtr<nsINode>>& outArrayOfNodes, > EditAction aOperationType, > TouchContent aTouchContent = TouchContent::yes); > + void GetChildNodesForOperation(nsINode& aNode, Nit: trailing whitespace!
Attachment #8592784 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592786 -
Flags: review?(ehsan) → review+
Comment 17•9 years ago
|
||
Comment on attachment 8592789 [details] [diff] [review] Part 7 - Clean up nsHTMLEditRules::RemoveBlockStyle, RemovePartOfBlock Review of attachment 8592789 [details] [diff] [review]: ----------------------------------------------------------------- r=me with the below fixed. ::: editor/libeditor/nsHTMLEditRules.cpp @@ +6907,5 @@ > NS_ENSURE_SUCCESS(res, res); > + } else if (IsInlineNode(GetAsDOMNode(curNode))) { > + if (curBlock) { > + // If so, is this node a descendant? > + if (curBlock != curNode && curBlock->Contains(curNode)) { nsINode::Contains <https://dxr.mozilla.org/mozilla-central/source/dom/base/nsINode.cpp#2333> and nsEditorUtils::IsDescendantOf do vastly different things. Please do not use Contains() instead here and elsewhere in other patches.
Attachment #8592789 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592790 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592791 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592792 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592795 -
Flags: review?(ehsan) → review+
Updated•9 years ago
|
Attachment #8592798 -
Flags: review?(ehsan) → review+
Assignee | ||
Comment 18•9 years ago
|
||
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #14) > Couldn't you do: > > for (auto& curNode : Reversed(arrayOfNodes)) { > > ? I don't think so, because AppendInnerFormatNodes appends nodes to the array, and range-based for isn't guaranteed to work if the loop body modifies the array. (In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #17) > nsINode::Contains > <https://dxr.mozilla.org/mozilla-central/source/dom/base/nsINode.cpp#2333> > and nsEditorUtils::IsDescendantOf do vastly different things. Please do not > use Contains() instead here and elsewhere in other patches. Okay -- what do they do differently in practice, other than Contains() returning true if the nodes are the same? And Contains silently returning false on a null input (ack!). And not having the extra index argument.
Flags: needinfo?(ehsan)
Comment 19•9 years ago
|
||
(In reply to :Aryeh Gregor from comment #18) > (In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from > comment #14) > > Couldn't you do: > > > > for (auto& curNode : Reversed(arrayOfNodes)) { > > > > ? > > I don't think so, because AppendInnerFormatNodes appends nodes to the array, > and range-based for isn't guaranteed to work if the loop body modifies the > array. Ah, yes... This is so confusing. :( > (In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from > comment #17) > > nsINode::Contains > > <https://dxr.mozilla.org/mozilla-central/source/dom/base/nsINode.cpp#2333> > > and nsEditorUtils::IsDescendantOf do vastly different things. Please do not > > use Contains() instead here and elsewhere in other patches. > > Okay -- what do they do differently in practice, other than Contains() > returning true if the nodes are the same? And Contains silently returning > false on a null input (ack!). And not having the extra index argument. Well, nsContentUtils::ContentIsDescendantOf and nsEditorUtils::IsDescendantOf have the same behavior, but nsINode::Contains does a whole bunch of checks before calling nsContentUtils::ContentIsDescendantOf which would not have been performed by nsEditorUtils::IsDescendantOf, such as whether the nodes are in a document, the special case of the parent being a document, etc. Now, it may very well be the case that none of those checks matter for our needs, but that's not obvious to me without investigation, and I don't really think that switching to nsINode::Contains is worth that investigation. If anything, I would like us to nuke nsEditorUtils::IsDescendantOf in favor of nsContentUtils::ContentIsDescendantOf. :-)
Flags: needinfo?(ehsan)
Assignee | ||
Comment 20•9 years ago
|
||
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #19) > Well, nsContentUtils::ContentIsDescendantOf and > nsEditorUtils::IsDescendantOf have the same behavior, but nsINode::Contains > does a whole bunch of checks before calling > nsContentUtils::ContentIsDescendantOf which would not have been performed by > nsEditorUtils::IsDescendantOf, such as whether the nodes are in a document, > the special case of the parent being a document, etc. > > Now, it may very well be the case that none of those checks matter for our > needs, but that's not obvious to me without investigation, and I don't > really think that switching to nsINode::Contains is worth that investigation. It's specced: https://dom.spec.whatwg.org/#dom-node-containsother > If anything, I would like us to nuke nsEditorUtils::IsDescendantOf in favor > of nsContentUtils::ContentIsDescendantOf. :-) We can't do so entirely because it doesn't have the aIndex argument.
Comment 21•9 years ago
|
||
(In reply to :Aryeh Gregor from comment #20) > (In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from > comment #19) > > Well, nsContentUtils::ContentIsDescendantOf and > > nsEditorUtils::IsDescendantOf have the same behavior, but nsINode::Contains > > does a whole bunch of checks before calling > > nsContentUtils::ContentIsDescendantOf which would not have been performed by > > nsEditorUtils::IsDescendantOf, such as whether the nodes are in a document, > > the special case of the parent being a document, etc. > > > > Now, it may very well be the case that none of those checks matter for our > > needs, but that's not obvious to me without investigation, and I don't > > really think that switching to nsINode::Contains is worth that investigation. > > It's specced: https://dom.spec.whatwg.org/#dom-node-containsother Sure. But I'm not sure what you mean, are you arguing that switching to nsINode::Contains is worth it? If yes, I don't think the fact that it is specced is a good enough reason, I care more about not breaking stuff that we don't have tests for... > > If anything, I would like us to nuke nsEditorUtils::IsDescendantOf in favor > > of nsContentUtils::ContentIsDescendantOf. :-) > > We can't do so entirely because it doesn't have the aIndex argument. That's true.
Comment 22•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/394ba1703c08 https://hg.mozilla.org/integration/mozilla-inbound/rev/ecdfdce695b5 https://hg.mozilla.org/integration/mozilla-inbound/rev/ee256b6f62ec https://hg.mozilla.org/integration/mozilla-inbound/rev/cb266456a948 https://hg.mozilla.org/integration/mozilla-inbound/rev/87ff1d4bb056 https://hg.mozilla.org/integration/mozilla-inbound/rev/9a62d4ec4542 https://hg.mozilla.org/integration/mozilla-inbound/rev/b0b609c3da83 https://hg.mozilla.org/integration/mozilla-inbound/rev/42f5d3fc71b3 https://hg.mozilla.org/integration/mozilla-inbound/rev/af47b386bea7 https://hg.mozilla.org/integration/mozilla-inbound/rev/1f0fdf67005d https://hg.mozilla.org/integration/mozilla-inbound/rev/a9d071f07242 https://hg.mozilla.org/integration/mozilla-inbound/rev/25bc426c8c0e
Comment 23•9 years ago
|
||
Hi, this changes got in backout in https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=329dd852c06b since one of this changes caused memory leaks in linux/OS X m2,m4, M-e10s m4 and Crashtests like: https://treeherder.mozilla.org/logviewer.html#?job_id=9178717&repo=mozilla-inbound 06:21:14 WARNING - TEST-UNEXPECTED-FAIL | leakcheck | default process: 1483211 bytes leaked (AsyncLatencyLogger, AsyncStatement, AtomImpl, BodyRule, CSSStyleSheet, ...) 06:21:14 INFO - == BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, plugin process 1044 06:21:14 INFO - |<----------------Class--------------->|<-----Bytes------>|<----Objects---->| 06:21:14 INFO - Per-Inst Leaked Total Rem 06:21:14 INFO - 0 TOTAL 57 0 301 0 06:21:14 INFO - nsTraceRefcnt::DumpStatistics: 26 entries
Flags: needinfo?(ayg)
Assignee | ||
Comment 24•9 years ago
|
||
Almost certain this is caused by bug 1157848. Will reland with that if it passes the try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7d3eb6ab4913
Flags: needinfo?(ayg)
Comment 25•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/152ade0072cc https://hg.mozilla.org/integration/mozilla-inbound/rev/b028d352877d https://hg.mozilla.org/integration/mozilla-inbound/rev/21318cef2ac4 https://hg.mozilla.org/integration/mozilla-inbound/rev/77f01af28007 https://hg.mozilla.org/integration/mozilla-inbound/rev/33634e2476cd https://hg.mozilla.org/integration/mozilla-inbound/rev/55060c30180e https://hg.mozilla.org/integration/mozilla-inbound/rev/9c27dad8a22d https://hg.mozilla.org/integration/mozilla-inbound/rev/e50601e79b5e https://hg.mozilla.org/integration/mozilla-inbound/rev/37cc8d9fa845 https://hg.mozilla.org/integration/mozilla-inbound/rev/af542a26cc53 https://hg.mozilla.org/integration/mozilla-inbound/rev/6c1aa3a03afe https://hg.mozilla.org/integration/mozilla-inbound/rev/ce645a33477a
Comment 26•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/152ade0072cc https://hg.mozilla.org/mozilla-central/rev/b028d352877d https://hg.mozilla.org/mozilla-central/rev/21318cef2ac4 https://hg.mozilla.org/mozilla-central/rev/77f01af28007 https://hg.mozilla.org/mozilla-central/rev/33634e2476cd https://hg.mozilla.org/mozilla-central/rev/55060c30180e https://hg.mozilla.org/mozilla-central/rev/9c27dad8a22d https://hg.mozilla.org/mozilla-central/rev/e50601e79b5e https://hg.mozilla.org/mozilla-central/rev/37cc8d9fa845 https://hg.mozilla.org/mozilla-central/rev/af542a26cc53 https://hg.mozilla.org/mozilla-central/rev/6c1aa3a03afe https://hg.mozilla.org/mozilla-central/rev/ce645a33477a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox40:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in
before you can comment on or make changes to this bug.
Description
•