Closed Bug 585255 Opened 10 years ago Closed 9 years ago
Tree Walker usage from ns Focus Manager
nsFocusManager uses nsTreeWalker to locate next and previous nsIContents. This is overkill now that there are fast node traversal methods supported by nsINode. It should use GetNextNode and a new method to get the previous nsIContent. Patch coming soon.
I've added an GetPreviousContent method to nsIContent. I can move it to nsINode if that is preferred, but since it only knows how to return nsIContent* I think you need to be in an nsIContent to even bother wanting to find a previous content. (My knowledge of nsINode vs nsIContent is very bad.) Not entirely sure how to test this. Is focus stuff covered by one of the test systems? I did run the built browser and made sure it still seemed to move forwards and backwards correctly.
For what it's worth, the behavior of that function wrt aRoot doesn't match the documentation. Also, there's no problem using nsContentUtils methods in nsGenericElement; they just couldn't be used in nsINode....
Oops I was going to fix that and forgot. I'll post a new patch later today.
I think we want nsIContent* nsIContent::GetPreviousContent to be changed into nsIContent* nsINode::GetPreviousContent i.e. moved to the nsINode interface. We probably also want to keep it inlined such that it can be called from anywhere. This means that you won't be able to call nsContentUtils::ContentIsDescendantOf but unfortunately have to duplicate and inline it :( It's somewhat more ok though since it's DEBUG only.
If we want to inline it, the right way to do it is to put the decl in nsINode and the impl at the bottom of nsIContent.h.
Sounds good to me.
Comment on attachment 464710 [details] [diff] [review] Moved GetPreviousNode to nsINode Yay! Pretty!
Attachment #464710 - Flags: review?(jonas) → review+
Jonas, should I ask for 2.0 approval or wait til we branch?
I'd say that we should wait. There's not much value for users here, just value for our continued ease of working with this code, so doesn't give us much to put in FF4.
I don't want to land this tonight as the tree is in a crazy state. I'll try to remember to land this tomorrow, otherwise please remind me.
Attachment #525325 - Flags: review+
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
You need to log in before you can comment on or make changes to this bug.