2001-12-16 12:13:48 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-12-16 12:13:48 +03:00
|
|
|
|
2006-03-30 09:56:38 +04:00
|
|
|
/*
|
|
|
|
* used by nsCSSFrameConstructor to determine and iterate the child list
|
|
|
|
* used to construct frames (normal children or something from XBL)
|
|
|
|
*/
|
|
|
|
|
2001-12-16 12:13:48 +03:00
|
|
|
#include "nsChildIterator.h"
|
|
|
|
#include "nsIDocument.h"
|
2007-02-17 02:02:08 +03:00
|
|
|
#include "nsBindingManager.h"
|
2001-12-16 12:13:48 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
ChildIterator::Init(nsIContent* aContent,
|
|
|
|
ChildIterator* aFirst,
|
|
|
|
ChildIterator* aLast)
|
|
|
|
{
|
2002-06-21 05:55:14 +04:00
|
|
|
// Initialize out parameters to be equal, in case of failure.
|
2012-07-30 18:20:58 +04:00
|
|
|
aFirst->mContent = aLast->mContent = nullptr;
|
|
|
|
aFirst->mChild = aLast->mChild = nullptr;
|
2002-06-21 05:55:14 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(aContent != nullptr, "no content");
|
2001-12-16 12:13:48 +03:00
|
|
|
if (! aContent)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = aContent->OwnerDoc();
|
2001-12-16 12:13:48 +03:00
|
|
|
|
|
|
|
// If this node has XBL children, then use them. Otherwise, just use
|
|
|
|
// the vanilla content APIs.
|
2009-01-29 22:46:20 +03:00
|
|
|
nsINodeList* nodes = doc->BindingManager()->GetXBLChildNodesFor(aContent);
|
2001-12-16 12:13:48 +03:00
|
|
|
|
|
|
|
aFirst->mContent = aContent;
|
|
|
|
aLast->mContent = aContent;
|
|
|
|
aFirst->mNodes = nodes;
|
|
|
|
aLast->mNodes = nodes;
|
|
|
|
|
2010-07-15 08:38:21 +04:00
|
|
|
if (nodes) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t length;
|
2010-07-15 08:38:21 +04:00
|
|
|
nodes->GetLength(&length);
|
|
|
|
aFirst->mIndex = 0;
|
|
|
|
aLast->mIndex = length;
|
|
|
|
} else {
|
|
|
|
aFirst->mChild = aContent->GetFirstChild();
|
2012-07-30 18:20:58 +04:00
|
|
|
aLast->mChild = nullptr;
|
2010-07-15 08:38:21 +04:00
|
|
|
}
|
|
|
|
|
2001-12-16 12:13:48 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|