diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 59c5f87e32d1..dea5489818b0 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3446,6 +3446,28 @@ nsDocument::CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection) { if (NS_SUCCEEDED(aSelection->GetFocusNode(getter_AddRefs(focus)))) { + //check to see if these are text nodes if so there is still a chance at optimization + //from checking their respective parents + if (focus.get() != anchor.get()) + { + nsCOMPtr domText(do_QueryInterface(focus)); + if (domText) + { + nsCOMPtr parent; + result = focus->GetParentNode(getter_AddRefs(parent)); + if (NS_SUCCEEDED(result) && parent) + focus = parent; + } + domText = do_QueryInterface(anchor); + if (domText) + { + nsCOMPtr parent; + result = anchor->GetParentNode(getter_AddRefs(parent)); + if (NS_SUCCEEDED(result) && parent) + anchor = parent; + } + }//end parent checking + if (focus.get() == anchor.get()) { rootElement = do_QueryInterface(focus);//set root to top of selection diff --git a/layout/base/src/nsDocument.cpp b/layout/base/src/nsDocument.cpp index 59c5f87e32d1..dea5489818b0 100644 --- a/layout/base/src/nsDocument.cpp +++ b/layout/base/src/nsDocument.cpp @@ -3446,6 +3446,28 @@ nsDocument::CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection) { if (NS_SUCCEEDED(aSelection->GetFocusNode(getter_AddRefs(focus)))) { + //check to see if these are text nodes if so there is still a chance at optimization + //from checking their respective parents + if (focus.get() != anchor.get()) + { + nsCOMPtr domText(do_QueryInterface(focus)); + if (domText) + { + nsCOMPtr parent; + result = focus->GetParentNode(getter_AddRefs(parent)); + if (NS_SUCCEEDED(result) && parent) + focus = parent; + } + domText = do_QueryInterface(anchor); + if (domText) + { + nsCOMPtr parent; + result = anchor->GetParentNode(getter_AddRefs(parent)); + if (NS_SUCCEEDED(result) && parent) + anchor = parent; + } + }//end parent checking + if (focus.get() == anchor.get()) { rootElement = do_QueryInterface(focus);//set root to top of selection