Closed
Bug 1257208
Opened 9 years ago
Closed 9 years ago
Fix some confusing naming and casts in DirectionalityUtils.cpp
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: ehsan.akhgari, Unassigned)
Details
Attachments
(2 files)
3.12 KB,
patch
|
peterv
:
review-
|
Details | Diff | Splinter Review |
16.34 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
This node argument may point to any node type, and is not necessarily
an Element. Its value is only useful when it's pointing to a text node,
but calling it a text node before we have checked its type is confusing.
Reporter | ||
Comment 1•9 years ago
|
||
Attachment #8731276 -
Flags: review?(peterv)
Comment 2•9 years ago
|
||
I don't really understand this patch, since afaict we only ever pass a text node to aChangedNode for ResetTextNodeDirection. We always check HasTextNodeDirectionalityMap before calling it. HasTextNodeDirectionalityMap only returns true if a nsTextNodeDirectionalityMap was constructed for the node, which only ever happens from AddEntryToMap, which is only ever called with the result of WalkDescendantsSetDirectionFromText (which only returns a text node). Could we make HasTextNodeDirectionalityMap assert that the node type is nsIDOMNode::TEXT_NODE? Maybe we can also make WalkDescendantsSetDirectionFromText return a nsTextNode* and nsTextNodeDirectionalityMap and AddEntryToMap take one?
At that point we could make TextNodeChangedDirection take a nsTextNode* (nsGenericDOMDataNode::SetTextInternal checks the nodetype before calling it) and then all the callers of ResetTextNodeDirection pass in a nsTextNode* for aChangedNode afaict.
Flags: needinfo?(ehsan)
Reporter | ||
Comment 3•9 years ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #2)
> I don't really understand this patch, since afaict we only ever pass a text
> node to aChangedNode for ResetTextNodeDirection. We always check
> HasTextNodeDirectionalityMap before calling it. HasTextNodeDirectionalityMap
> only returns true if a nsTextNodeDirectionalityMap was constructed for the
> node, which only ever happens from AddEntryToMap, which is only ever called
> with the result of WalkDescendantsSetDirectionFromText (which only returns a
> text node).
D'oh, I was missing this part! Sorry...
> Could we make HasTextNodeDirectionalityMap assert that the node
> type is nsIDOMNode::TEXT_NODE? Maybe we can also make
> WalkDescendantsSetDirectionFromText return a nsTextNode* and
> nsTextNodeDirectionalityMap and AddEntryToMap take one?
>
> At that point we could make TextNodeChangedDirection take a nsTextNode*
> (nsGenericDOMDataNode::SetTextInternal checks the nodetype before calling
> it) and then all the callers of ResetTextNodeDirection pass in a nsTextNode*
> for aChangedNode afaict.
Will do!
Flags: needinfo?(ehsan)
Reporter | ||
Comment 4•9 years ago
|
||
Attachment #8732380 -
Flags: review?(peterv)
Comment 5•9 years ago
|
||
Comment on attachment 8731276 [details] [diff] [review]
Fix some confusing naming and casts in DirectionalityUtils.cpp
Review of attachment 8731276 [details] [diff] [review]:
-----------------------------------------------------------------
I don't really understand this patch, since afaict we only ever pass a text node to aChangedNode for ResetTextNodeDirection. We always check HasTextNodeDirectionalityMap before calling it. HasTextNodeDirectionalityMap only returns true if a nsTextNodeDirectionalityMap was constructed for the node, which only ever happens from AddEntryToMap, which is only ever called with the result of WalkDescendantsSetDirectionFromText (which only returns a text node). Could we make HasTextNodeDirectionalityMap assert that the node type is nsIDOMNode::TEXT_NODE, and maybe we can also make WalkDescendantsSetDirectionFromText return a nsTextNode* and nsTextNodeDirectionalityMap and AddEntryToMap take one?
At that point we could make TextNodeChangedDirection take a nsTextNode* (nsGenericDOMDataNode::SetTextInternal checks the nodetype before calling it) and then all the callers of ResetTextNodeDirection pass in a nsTextNode* for aChangedNode afaict.
Attachment #8731276 -
Flags: review?(peterv) → review-
Comment 6•9 years ago
|
||
Comment on attachment 8732380 [details] [diff] [review]
Use the nsTextNode concrete type in several places in DirectionalityUtils.cpp instead of nsINode and nsIContent
Review of attachment 8732380 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks for doing this.
Attachment #8732380 -
Flags: review?(peterv) → review+
![]() |
||
Comment 8•9 years ago
|
||
Backed out for Reftest failures at least on Linux x64 debug, e.g. dir_auto-set-contained-dir-L.html
Backout: https://hg.mozilla.org/integration/mozilla-inbound/rev/f112e7dad6f7
First non-busted run after push (which also shows the failures): https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=52195522dbac
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=24440903&repo=mozilla-inbound
17:10:46 INFO - REFTEST TEST-LOAD | file:///home/worker/workspace/build/tests/reftest/tests/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-L-ref.html | 531 / 1712 (31%)
17:10:46 INFO - ++DOMWINDOW == 54 (0x7f94d3023c00) [pid = 1128] [serial = 1144] [outer = 0x7f94d9455400]
17:10:46 INFO - REFTEST TEST-UNEXPECTED-FAIL | file:///home/worker/workspace/build/tests/reftest/tests/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-L.html | image comparison (==), max difference: 255, number of differing pixels: 3284
Flags: needinfo?(ehsan)
Reporter | ||
Comment 9•9 years ago
|
||
D'oh, I made such a rookie mistake: used IsNodeOfType() instead of NodeType(). Embarrassing!
Flags: needinfo?(ehsan)
Comment 10•9 years ago
|
||
Comment 11•9 years ago
|
||
(In reply to :Ehsan Akhgari from comment #9)
> D'oh, I made such a rookie mistake: used IsNodeOfType() instead of
> NodeType(). Embarrassing!
Hmpf, sorry for missing that.
Comment 12•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•