Impossible to select document root element

VERIFIED FIXED in mozilla0.9

Status

()

Core
Selection
P3
critical
VERIFIED FIXED
18 years ago
16 years ago

People

(Reporter: Heikki Toivonen (remove -bugzilla when emailing directly), Assigned: anthonyd)

Tracking

({crash, testcase})

Trunk
mozilla0.9
crash, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: FIX IN HAND)

Attachments

(1 attachment)

It seems to be impossible to select the root element (i.e. the whole document
barring prolog & epilog). As far as I understand all the ways of doing selection
require you to get the parent content of the content you would like to select.
The root content does not have parent content.

Also, we actually get a crash in nsContentSubtreeIterator::Init(), which is
called when you do:

range->SelectNode(rootNode);
selection->AddRange(range);

The crash happens because the code QIs a DOM node into nsIContent but does not
check the result of this QI. It is null if the DOM node is the document, because
the document does not implement nsIContent.

This is blocking bug 56858.
Keywords: crash
Summary: Impossible to select document root element → Impossible to select document root element, crash if you try

Comment 1

18 years ago
setting to moz0.9 and reassign to anthonyd
Assignee: mjudge → anthonyd
Target Milestone: --- → mozilla0.9
(Assignee)

Comment 2

18 years ago
accepting bug, would like to have a test case, i will  make one and hope it 
correctly repros bug.

anthonyd
Status: NEW → ASSIGNED
(Assignee)

Comment 3

18 years ago
i think i have a fix for this. but could the reporter (heikki) please post a 
test case?  thanks,
anthonyd
Hmm... I swear I posted a testcase... Seems like it didn't end up here.

Anyway, here is a test procedure you can try:

1. Apply my 2nd patch in bug 56858 and set the boolean pref layout.selectanchor
   to true.
2. Open http://bugzilla.mozilla.org/showattachment.cgi?attach_id=19084
   and try the links. It should select the target contents of the link.
   Also the last link ("root link") should work and select the complete
   document without crashing.

If you'd attach your fix here I could also try it out.
Keywords: testcase
(Assignee)

Comment 5

18 years ago
i applied your new patch, but the test case doesnt appear to do anything.
need some info

anthonyd
Did you add the following line to your all.js file?

pref("layout.selectanchor",true);
(Assignee)

Comment 7

18 years ago
heikki,
ok, sorry. i missed putting that pref in.  the test case now works, though im 
not seeing a crash.
(Assignee)

Comment 8

18 years ago
ok, changing status summary, this bug is supposed to be (im guessing here) to 
fix selection of root element, NOT the crasher.

anthonyd
Summary: Impossible to select document root element, crash if you try → Impossible to select document root element
(Assignee)

Comment 9

18 years ago
fixed, ill update in a bit to add the patch.

anthonyd
(Assignee)

Comment 10

18 years ago
Created attachment 28541 [details]
patch with fix for selecting root element
(Assignee)

Comment 11

18 years ago
changing status whiteboard.
got an r= from mjudge, but i need an sr= from attinasi since he owns layout, 
right?

anthonyd
Whiteboard: FIX IN HAND, NEED REVIEW

Comment 12

18 years ago
sr=attinasi
(Assignee)

Comment 13

18 years ago
fix checked in
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
Whiteboard: FIX IN HAND, NEED REVIEW → FIX IN HAND

Comment 14

16 years ago
catching up on verifications
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.