mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
The traversal range end points are always part of the range. b=327694 r=jst
This commit is contained in:
parent
c3fc1722e9
commit
da420547bc
17
content/base/crashtests/327694.html
Normal file
17
content/base/crashtests/327694.html
Normal file
@ -0,0 +1,17 @@
|
||||
<html>
<head>
|
||||
|
||||
<script>
|
||||
|
||||
function init()
|
||||
{
|
||||
var y = document.getElementById("tt");
|
||||
var z = y.firstChild;
|
||||
y.removeChild(z);
|
||||
z.text;
|
||||
}
|
||||
|
||||
window.addEventListener("load", init, false);
|
||||
|
||||
</script>
|
||||
</head>
<body>
<div id="tt"><a href="http://www.mozilla.org">Foo</a></div>
|
||||
</body>
</html>
|
@ -11,6 +11,7 @@ load 326618-1.html
|
||||
load 326646-1.html
|
||||
load 326778-1.xul
|
||||
load 326865-1.html
|
||||
load 327694.html
|
||||
load 330925-1.xhtml
|
||||
load 336381-1.xhtml
|
||||
load 336715-1.xhtml
|
||||
|
@ -44,15 +44,10 @@
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsINode.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
// couple of utility static functs
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -1046,9 +1041,13 @@ nsContentIterator::PositionAt(nsINode* aCurNode)
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstNode || !lastNode ||
|
||||
!NodeIsInTraversalRange(mCurNode, mPre, firstNode, firstOffset,
|
||||
lastNode, lastOffset))
|
||||
// The end positions are always in the range even if it has no parent.
|
||||
// We need to allow that or 'iter->Init(root)' would assert in Last()
|
||||
// or First() for example, bug 327694.
|
||||
if (mFirst != mCurNode && mLast != mCurNode &&
|
||||
(!firstNode || !lastNode ||
|
||||
!NodeIsInTraversalRange(mCurNode, mPre, firstNode, firstOffset,
|
||||
lastNode, lastOffset)))
|
||||
{
|
||||
mIsDone = PR_TRUE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -36,37 +36,27 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMNSHTMLAnchorElement2.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
// For GetText().
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
nsresult NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
|
||||
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLAnchorElement,
|
||||
@ -378,19 +368,17 @@ nsHTMLAnchorElement::GetText(nsAString& aText)
|
||||
// The nsIContentIterator does exactly what we want, if we start the
|
||||
// iteration from the end.
|
||||
nsCOMPtr<nsIContentIterator> iter;
|
||||
nsresult rv = NS_NewContentIterator(getter_AddRefs(iter));
|
||||
nsresult rv = NS_NewPreContentIterator(getter_AddRefs(iter));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Initialize the content iterator with the children of the anchor
|
||||
iter->Init(this);
|
||||
|
||||
// Position the iterator. Last() is the anchor itself, this is not what we
|
||||
// want. Prev() positions the iterator to the last child of the anchor,
|
||||
// Last() positions the iterator to the last child of the anchor,
|
||||
// starting at the deepest level of children, just like NS4 does.
|
||||
iter->Last();
|
||||
iter->Prev();
|
||||
|
||||
while(!iter->IsDone()) {
|
||||
while (!iter->IsDone()) {
|
||||
nsCOMPtr<nsIDOMText> textNode(do_QueryInterface(iter->GetCurrentNode()));
|
||||
if(textNode) {
|
||||
// The current node is a text node. Get its value and break the loop.
|
||||
|
Loading…
Reference in New Issue
Block a user