зеркало из https://github.com/mozilla/gecko-dev.git
Bug 904602 - Optimize tree traversing in Range, r=mats
--HG-- extra : rebase_source : b223d822792e95c0b5bbd40046c32f1049b068d8
This commit is contained in:
Родитель
852acf63db
Коммит
5e0ba3b426
|
@ -643,16 +643,16 @@ nsRange::ContentRemoved(nsIDocument* aDocument,
|
|||
nsINode* container = NODE_FROM(aContainer, aDocument);
|
||||
bool gravitateStart = false;
|
||||
bool gravitateEnd = false;
|
||||
bool didCheckStartParentDescendant = false;
|
||||
|
||||
// Adjust position if a sibling was removed...
|
||||
if (container == mStartParent) {
|
||||
if (aIndexInContainer < mStartOffset) {
|
||||
--mStartOffset;
|
||||
}
|
||||
}
|
||||
// ...or gravitate if an ancestor was removed.
|
||||
else if (nsContentUtils::ContentIsDescendantOf(mStartParent, aChild)) {
|
||||
gravitateStart = true;
|
||||
} else { // ...or gravitate if an ancestor was removed.
|
||||
didCheckStartParentDescendant = true;
|
||||
gravitateStart = nsContentUtils::ContentIsDescendantOf(mStartParent, aChild);
|
||||
}
|
||||
|
||||
// Do same thing for end boundry.
|
||||
|
@ -660,9 +660,10 @@ nsRange::ContentRemoved(nsIDocument* aDocument,
|
|||
if (aIndexInContainer < mEndOffset) {
|
||||
--mEndOffset;
|
||||
}
|
||||
}
|
||||
else if (nsContentUtils::ContentIsDescendantOf(mEndParent, aChild)) {
|
||||
gravitateEnd = true;
|
||||
} else if (didCheckStartParentDescendant && mStartParent == mEndParent) {
|
||||
gravitateEnd = gravitateStart;
|
||||
} else {
|
||||
gravitateEnd = nsContentUtils::ContentIsDescendantOf(mEndParent, aChild);
|
||||
}
|
||||
|
||||
if (!mEnableGravitationOnElementRemoval) {
|
||||
|
@ -1091,20 +1092,11 @@ nsRange::IsValidBoundary(nsINode* aNode)
|
|||
return root;
|
||||
}
|
||||
|
||||
root = aNode;
|
||||
while ((aNode = aNode->GetParentNode())) {
|
||||
root = aNode;
|
||||
}
|
||||
root = aNode->SubtreeRoot();
|
||||
|
||||
NS_ASSERTION(!root->IsNodeOfType(nsINode::eDOCUMENT),
|
||||
"GetCurrentDoc should have returned a doc");
|
||||
|
||||
#ifdef DEBUG_smaug
|
||||
NS_WARN_IF_FALSE(root->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) ||
|
||||
root->IsNodeOfType(nsINode::eATTRIBUTE),
|
||||
"Creating a DOM Range using root which isn't in DOM!");
|
||||
#endif
|
||||
|
||||
// We allow this because of backward compatibility.
|
||||
return root;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче