Closed Bug 375684 Opened 17 years ago Closed 17 years ago

assertion when dragging the source is the document root node

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: enndeakin, Unassigned)

Details

Attachments

(2 files)

The assertion at http://lxr.mozilla.org/mozilla/source/layout/base/nsPresShell.cpp#5090 shouldn't be used as the range can have the start and end as the document root node, and the ancestor becomes the document. See the attached testcase. 

nsINode* ancestor = nsContentUtils::GetCommonAncestor(range->GetStartParent(),
                      range->GetEndParent());
NS_ASSERTION(!ancestor || ancestor->IsNodeOfType(nsINode::eCONTENT),
             "common ancestor is not content");

roc, I guess in this case, we should just get the document root node and use that?
Why are we getting the common ancestor of the nodes' parents? Couldn't/shouldn't we just get the common ancestor of the nodes themselves?
If you're referring to GetStartParent/GetEndParent, they are just perhaps misnamed, they return the nodes themselves.
OK then, GetCommonAncestor should be returning the root node, right? The common ancestor of two references to the same node is that node.
This is because nsRange::SelectNode(node) gets the parent of node and then sets the end points based on that.

So I think if the start or end point is the root node, we should just use the root frame instead.
Status: NEW → ASSIGNED
Attachment #260013 - Flags: superreview?(roc)
Attachment #260013 - Flags: review?(roc)
Attachment #260013 - Flags: superreview?(roc)
Attachment #260013 - Flags: superreview+
Attachment #260013 - Flags: review?(roc)
Attachment #260013 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: