Bug 1446533 part 6.5. Fix some old whitespace bits in range code. r=mystor

MozReview-Commit-ID: KTEgqc4Wzjd
This commit is contained in:
Boris Zbarsky 2018-03-19 15:35:38 -04:00
parent 4d10a59d53
commit c441152ca4

View File

@ -2289,19 +2289,15 @@ nsRange::CutContents(DocumentFragment** aFragment)
// XXX_kin: We need to also handle ProcessingInstruction
// XXX_kin: according to the spec.
if (auto charData = CharacterData::FromContent(node))
{
if (auto charData = CharacterData::FromContent(node)) {
uint32_t dataLength = 0;
if (node == startContainer)
{
if (node == endContainer)
{
if (node == startContainer) {
if (node == endContainer) {
// This range is completely contained within a single text node.
// Delete or extract the data between startOffset and endOffset.
if (endOffset > startOffset)
{
if (endOffset > startOffset) {
if (retval) {
nsAutoString cutValue;
ErrorResult err;
@ -2330,8 +2326,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
handled = true;
}
else
{
else {
// Delete or extract everything after startOffset.
dataLength = charData->Length();
@ -2365,8 +2360,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
handled = true;
}
}
else if (node == endContainer)
{
else if (node == endContainer) {
// Delete or extract everything before endOffset.
if (retval) {
nsAutoString cutValue;
@ -2395,8 +2389,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
}
}
if (!handled && (node == endContainer || node == startContainer))
{
if (!handled && (node == endContainer || node == startContainer)) {
if (node && node->IsElement() &&
((node == endContainer && endOffset == 0) ||
(node == startContainer &&
@ -2410,8 +2403,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
}
}
if (!handled)
{
if (!handled) {
// node was not handled above, so it must be completely contained
// within the range. Just remove it from the tree!
nodeToResult = node;
@ -2431,8 +2423,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
NS_ENSURE_STATE(commonAncestor);
nsCOMPtr<nsINode> parentCounterNode = node;
while (parentCounterNode && parentCounterNode != commonAncestor)
{
while (parentCounterNode && parentCounterNode != commonAncestor) {
++parentCount;
parentCounterNode = parentCounterNode->GetParentNode();
NS_ENSURE_STATE(parentCounterNode);
@ -2447,8 +2438,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
NS_ENSURE_SUCCESS(rv, rv);
ErrorResult res;
if (farthestAncestor)
{
if (farthestAncestor) {
nsCOMPtr<nsINode> n = do_QueryInterface(commonCloneAncestor);
n->AppendChild(*farthestAncestor, res);
res.WouldReportJSException();
@ -2486,8 +2476,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
if (!iter.IsDone() && retval) {
// Find the equivalent of commonAncestor in the cloned tree.
nsCOMPtr<nsINode> newCloneAncestor = nodeToResult;
for (uint32_t i = parentCount; i; --i)
{
for (uint32_t i = parentCount; i; --i) {
newCloneAncestor = newCloneAncestor->GetParentNode();
NS_ENSURE_STATE(newCloneAncestor);
}