gecko/layout/xul/tree/nsTreeBoxObject.cpp
Alex Vincent 46b6a18189 Bug 833879 - Move layout/xul/base/src/tree/ to layout/xul/tree, layout/xul/base/src/grid to layout/xul/grid. r=roc
--HG--
rename : layout/xul/base/src/grid/Makefile.in => layout/xul/grid/Makefile.in
rename : layout/xul/base/src/grid/crashtests/306911-crash.xul => layout/xul/grid/crashtests/306911-crash.xul
rename : layout/xul/base/src/grid/crashtests/306911-grid-testcases.xul => layout/xul/grid/crashtests/306911-grid-testcases.xul
rename : layout/xul/base/src/grid/crashtests/306911-grid-testcases2.xul => layout/xul/grid/crashtests/306911-grid-testcases2.xul
rename : layout/xul/base/src/grid/crashtests/311710-1.xul => layout/xul/grid/crashtests/311710-1.xul
rename : layout/xul/base/src/grid/crashtests/312784-1.xul => layout/xul/grid/crashtests/312784-1.xul
rename : layout/xul/base/src/grid/crashtests/313173-1-inner.xul => layout/xul/grid/crashtests/313173-1-inner.xul
rename : layout/xul/base/src/grid/crashtests/313173-1.html => layout/xul/grid/crashtests/313173-1.html
rename : layout/xul/base/src/grid/crashtests/321066-1.xul => layout/xul/grid/crashtests/321066-1.xul
rename : layout/xul/base/src/grid/crashtests/321073-1.xul => layout/xul/grid/crashtests/321073-1.xul
rename : layout/xul/base/src/grid/crashtests/382750-1.xul => layout/xul/grid/crashtests/382750-1.xul
rename : layout/xul/base/src/grid/crashtests/400790-1.xul => layout/xul/grid/crashtests/400790-1.xul
rename : layout/xul/base/src/grid/crashtests/423802-crash.xul => layout/xul/grid/crashtests/423802-crash.xul
rename : layout/xul/base/src/grid/crashtests/crashtests.list => layout/xul/grid/crashtests/crashtests.list
rename : layout/xul/base/src/grid/examples/borderedcolumns.xul => layout/xul/grid/examples/borderedcolumns.xul
rename : layout/xul/base/src/grid/examples/borderedrowscolumns.xul => layout/xul/grid/examples/borderedrowscolumns.xul
rename : layout/xul/base/src/grid/examples/borderedrowscolumns2.xul => layout/xul/grid/examples/borderedrowscolumns2.xul
rename : layout/xul/base/src/grid/examples/borderedrowscolumns3.xul => layout/xul/grid/examples/borderedrowscolumns3.xul
rename : layout/xul/base/src/grid/examples/bordermargincolumns1.xul => layout/xul/grid/examples/bordermargincolumns1.xul
rename : layout/xul/base/src/grid/examples/collapsetest.xul => layout/xul/grid/examples/collapsetest.xul
rename : layout/xul/base/src/grid/examples/divcolumngrid.xul => layout/xul/grid/examples/divcolumngrid.xul
rename : layout/xul/base/src/grid/examples/divrowgrid.xul => layout/xul/grid/examples/divrowgrid.xul
rename : layout/xul/base/src/grid/examples/dynamicgrid.xul => layout/xul/grid/examples/dynamicgrid.xul
rename : layout/xul/base/src/grid/examples/flexgroupgrid.xul => layout/xul/grid/examples/flexgroupgrid.xul
rename : layout/xul/base/src/grid/examples/javascriptappend.xul => layout/xul/grid/examples/javascriptappend.xul
rename : layout/xul/base/src/grid/examples/jumpygrid.xul => layout/xul/grid/examples/jumpygrid.xul
rename : layout/xul/base/src/grid/examples/nestedrows.xul => layout/xul/grid/examples/nestedrows.xul
rename : layout/xul/base/src/grid/examples/rowspan.xul => layout/xul/grid/examples/rowspan.xul
rename : layout/xul/base/src/grid/examples/scrollingcolumns.xul => layout/xul/grid/examples/scrollingcolumns.xul
rename : layout/xul/base/src/grid/examples/scrollingrows.xul => layout/xul/grid/examples/scrollingrows.xul
rename : layout/xul/base/src/grid/examples/splitter.xul => layout/xul/grid/examples/splitter.xul
rename : layout/xul/base/src/grid/nsGrid.cpp => layout/xul/grid/nsGrid.cpp
rename : layout/xul/base/src/grid/nsGrid.h => layout/xul/grid/nsGrid.h
rename : layout/xul/base/src/grid/nsGridCell.cpp => layout/xul/grid/nsGridCell.cpp
rename : layout/xul/base/src/grid/nsGridCell.h => layout/xul/grid/nsGridCell.h
rename : layout/xul/base/src/grid/nsGridLayout2.cpp => layout/xul/grid/nsGridLayout2.cpp
rename : layout/xul/base/src/grid/nsGridLayout2.h => layout/xul/grid/nsGridLayout2.h
rename : layout/xul/base/src/grid/nsGridRow.cpp => layout/xul/grid/nsGridRow.cpp
rename : layout/xul/base/src/grid/nsGridRow.h => layout/xul/grid/nsGridRow.h
rename : layout/xul/base/src/grid/nsGridRowGroupFrame.cpp => layout/xul/grid/nsGridRowGroupFrame.cpp
rename : layout/xul/base/src/grid/nsGridRowGroupFrame.h => layout/xul/grid/nsGridRowGroupFrame.h
rename : layout/xul/base/src/grid/nsGridRowGroupLayout.cpp => layout/xul/grid/nsGridRowGroupLayout.cpp
rename : layout/xul/base/src/grid/nsGridRowGroupLayout.h => layout/xul/grid/nsGridRowGroupLayout.h
rename : layout/xul/base/src/grid/nsGridRowLayout.cpp => layout/xul/grid/nsGridRowLayout.cpp
rename : layout/xul/base/src/grid/nsGridRowLayout.h => layout/xul/grid/nsGridRowLayout.h
rename : layout/xul/base/src/grid/nsGridRowLeafFrame.cpp => layout/xul/grid/nsGridRowLeafFrame.cpp
rename : layout/xul/base/src/grid/nsGridRowLeafFrame.h => layout/xul/grid/nsGridRowLeafFrame.h
rename : layout/xul/base/src/grid/nsGridRowLeafLayout.cpp => layout/xul/grid/nsGridRowLeafLayout.cpp
rename : layout/xul/base/src/grid/nsGridRowLeafLayout.h => layout/xul/grid/nsGridRowLeafLayout.h
rename : layout/xul/base/src/grid/nsIGridPart.h => layout/xul/grid/nsIGridPart.h
rename : layout/xul/base/src/grid/reftests/column-sizing-1-ref.xul => layout/xul/grid/reftests/column-sizing-1-ref.xul
rename : layout/xul/base/src/grid/reftests/column-sizing-1.xul => layout/xul/grid/reftests/column-sizing-1.xul
rename : layout/xul/base/src/grid/reftests/not-full-basic-ref.xhtml => layout/xul/grid/reftests/not-full-basic-ref.xhtml
rename : layout/xul/base/src/grid/reftests/not-full-basic.xul => layout/xul/grid/reftests/not-full-basic.xul
rename : layout/xul/base/src/grid/reftests/not-full-grid-pack-align.xul => layout/xul/grid/reftests/not-full-grid-pack-align.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-group-align-ref.xhtml => layout/xul/grid/reftests/not-full-row-group-align-ref.xhtml
rename : layout/xul/base/src/grid/reftests/not-full-row-group-align.xul => layout/xul/grid/reftests/not-full-row-group-align.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-group-direction-ref.xhtml => layout/xul/grid/reftests/not-full-row-group-direction-ref.xhtml
rename : layout/xul/base/src/grid/reftests/not-full-row-group-direction.xul => layout/xul/grid/reftests/not-full-row-group-direction.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-group-pack-ref.xhtml => layout/xul/grid/reftests/not-full-row-group-pack-ref.xhtml
rename : layout/xul/base/src/grid/reftests/not-full-row-group-pack.xul => layout/xul/grid/reftests/not-full-row-group-pack.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-leaf-align.xul => layout/xul/grid/reftests/not-full-row-leaf-align.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-leaf-direction.xul => layout/xul/grid/reftests/not-full-row-leaf-direction.xul
rename : layout/xul/base/src/grid/reftests/not-full-row-leaf-pack-ref.xhtml => layout/xul/grid/reftests/not-full-row-leaf-pack-ref.xhtml
rename : layout/xul/base/src/grid/reftests/not-full-row-leaf-pack.xul => layout/xul/grid/reftests/not-full-row-leaf-pack.xul
rename : layout/xul/base/src/grid/reftests/reftest.list => layout/xul/grid/reftests/reftest.list
rename : layout/xul/base/src/grid/reftests/row-or-column-sizing-1.xul => layout/xul/grid/reftests/row-or-column-sizing-1.xul
rename : layout/xul/base/src/grid/reftests/row-or-column-sizing-2.xul => layout/xul/grid/reftests/row-or-column-sizing-2.xul
rename : layout/xul/base/src/grid/reftests/row-or-column-sizing-3.xul => layout/xul/grid/reftests/row-or-column-sizing-3.xul
rename : layout/xul/base/src/grid/reftests/row-or-column-sizing-4.xul => layout/xul/grid/reftests/row-or-column-sizing-4.xul
rename : layout/xul/base/src/grid/reftests/row-sizing-1-ref.xul => layout/xul/grid/reftests/row-sizing-1-ref.xul
rename : layout/xul/base/src/grid/reftests/row-sizing-1.xul => layout/xul/grid/reftests/row-sizing-1.xul
rename : layout/xul/base/src/grid/reftests/scrollable-columns-ref.xhtml => layout/xul/grid/reftests/scrollable-columns-ref.xhtml
rename : layout/xul/base/src/grid/reftests/scrollable-columns.xul => layout/xul/grid/reftests/scrollable-columns.xul
rename : layout/xul/base/src/grid/reftests/scrollable-rows-ref.xhtml => layout/xul/grid/reftests/scrollable-rows-ref.xhtml
rename : layout/xul/base/src/grid/reftests/scrollable-rows.xul => layout/xul/grid/reftests/scrollable-rows.xul
rename : layout/xul/base/src/grid/reftests/sizing-2d-ref.xul => layout/xul/grid/reftests/sizing-2d-ref.xul
rename : layout/xul/base/src/grid/reftests/sizing-2d.xul => layout/xul/grid/reftests/sizing-2d.xul
rename : layout/xul/base/src/grid/reftests/z-order-1-ref.xul => layout/xul/grid/reftests/z-order-1-ref.xul
rename : layout/xul/base/src/grid/reftests/z-order-1.xul => layout/xul/grid/reftests/z-order-1.xul
rename : layout/xul/base/src/grid/reftests/z-order-2-ref.xul => layout/xul/grid/reftests/z-order-2-ref.xul
rename : layout/xul/base/src/grid/reftests/z-order-2.xul => layout/xul/grid/reftests/z-order-2.xul
rename : layout/xul/base/src/tree/src/Makefile.in => layout/xul/tree/Makefile.in
rename : layout/xul/base/src/tree/src/crashtests/307298-1.xul => layout/xul/tree/crashtests/307298-1.xul
rename : layout/xul/base/src/tree/src/crashtests/309732-1.xul => layout/xul/tree/crashtests/309732-1.xul
rename : layout/xul/base/src/tree/src/crashtests/309732-2.xul => layout/xul/tree/crashtests/309732-2.xul
rename : layout/xul/base/src/tree/src/crashtests/366583-1.xul => layout/xul/tree/crashtests/366583-1.xul
rename : layout/xul/base/src/tree/src/crashtests/380217-1.xul => layout/xul/tree/crashtests/380217-1.xul
rename : layout/xul/base/src/tree/src/crashtests/382444-1-inner.html => layout/xul/tree/crashtests/382444-1-inner.html
rename : layout/xul/base/src/tree/src/crashtests/382444-1.html => layout/xul/tree/crashtests/382444-1.html
rename : layout/xul/base/src/tree/src/crashtests/391178-1.xhtml => layout/xul/tree/crashtests/391178-1.xhtml
rename : layout/xul/base/src/tree/src/crashtests/391178-2.xul => layout/xul/tree/crashtests/391178-2.xul
rename : layout/xul/base/src/tree/src/crashtests/393665-1.xul => layout/xul/tree/crashtests/393665-1.xul
rename : layout/xul/base/src/tree/src/crashtests/399227-1.xul => layout/xul/tree/crashtests/399227-1.xul
rename : layout/xul/base/src/tree/src/crashtests/399227-2.xul => layout/xul/tree/crashtests/399227-2.xul
rename : layout/xul/base/src/tree/src/crashtests/399692-1.xhtml => layout/xul/tree/crashtests/399692-1.xhtml
rename : layout/xul/base/src/tree/src/crashtests/399715-1.xhtml => layout/xul/tree/crashtests/399715-1.xhtml
rename : layout/xul/base/src/tree/src/crashtests/409807-1.xul => layout/xul/tree/crashtests/409807-1.xul
rename : layout/xul/base/src/tree/src/crashtests/414170-1.xul => layout/xul/tree/crashtests/414170-1.xul
rename : layout/xul/base/src/tree/src/crashtests/430394-1.xul => layout/xul/tree/crashtests/430394-1.xul
rename : layout/xul/base/src/tree/src/crashtests/454186-1.xul => layout/xul/tree/crashtests/454186-1.xul
rename : layout/xul/base/src/tree/src/crashtests/479931-1.xhtml => layout/xul/tree/crashtests/479931-1.xhtml
rename : layout/xul/base/src/tree/src/crashtests/509602-1-overlay.xul => layout/xul/tree/crashtests/509602-1-overlay.xul
rename : layout/xul/base/src/tree/src/crashtests/509602-1.xul => layout/xul/tree/crashtests/509602-1.xul
rename : layout/xul/base/src/tree/src/crashtests/601427.html => layout/xul/tree/crashtests/601427.html
rename : layout/xul/base/src/tree/src/crashtests/crashtests.list => layout/xul/tree/crashtests/crashtests.list
rename : layout/xul/base/src/tree/public/nsITreeBoxObject.idl => layout/xul/tree/nsITreeBoxObject.idl
rename : layout/xul/base/src/tree/public/nsITreeColumns.idl => layout/xul/tree/nsITreeColumns.idl
rename : layout/xul/base/src/tree/public/nsITreeContentView.idl => layout/xul/tree/nsITreeContentView.idl
rename : layout/xul/base/src/tree/public/nsITreeSelection.idl => layout/xul/tree/nsITreeSelection.idl
rename : layout/xul/base/src/tree/public/nsITreeView.idl => layout/xul/tree/nsITreeView.idl
rename : layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp => layout/xul/tree/nsTreeBodyFrame.cpp
rename : layout/xul/base/src/tree/src/nsTreeBodyFrame.h => layout/xul/tree/nsTreeBodyFrame.h
rename : layout/xul/base/src/tree/src/nsTreeBoxObject.cpp => layout/xul/tree/nsTreeBoxObject.cpp
rename : layout/xul/base/src/tree/src/nsTreeBoxObject.h => layout/xul/tree/nsTreeBoxObject.h
rename : layout/xul/base/src/tree/src/nsTreeColFrame.cpp => layout/xul/tree/nsTreeColFrame.cpp
rename : layout/xul/base/src/tree/src/nsTreeColFrame.h => layout/xul/tree/nsTreeColFrame.h
rename : layout/xul/base/src/tree/src/nsTreeColumns.cpp => layout/xul/tree/nsTreeColumns.cpp
rename : layout/xul/base/src/tree/src/nsTreeColumns.h => layout/xul/tree/nsTreeColumns.h
rename : layout/xul/base/src/tree/src/nsTreeContentView.cpp => layout/xul/tree/nsTreeContentView.cpp
rename : layout/xul/base/src/tree/src/nsTreeContentView.h => layout/xul/tree/nsTreeContentView.h
rename : layout/xul/base/src/tree/src/nsTreeImageListener.cpp => layout/xul/tree/nsTreeImageListener.cpp
rename : layout/xul/base/src/tree/src/nsTreeImageListener.h => layout/xul/tree/nsTreeImageListener.h
rename : layout/xul/base/src/tree/src/nsTreeSelection.cpp => layout/xul/tree/nsTreeSelection.cpp
rename : layout/xul/base/src/tree/src/nsTreeSelection.h => layout/xul/tree/nsTreeSelection.h
rename : layout/xul/base/src/tree/src/nsTreeStyleCache.cpp => layout/xul/tree/nsTreeStyleCache.cpp
rename : layout/xul/base/src/tree/src/nsTreeStyleCache.h => layout/xul/tree/nsTreeStyleCache.h
rename : layout/xul/base/src/tree/src/nsTreeUtils.cpp => layout/xul/tree/nsTreeUtils.cpp
rename : layout/xul/base/src/tree/src/nsTreeUtils.h => layout/xul/tree/nsTreeUtils.h
2013-02-04 07:11:49 -05:00

498 lines
12 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsTreeBoxObject.h"
#include "nsCOMPtr.h"
#include "nsIDOMXULElement.h"
#include "nsIXULTemplateBuilder.h"
#include "nsTreeContentView.h"
#include "nsITreeSelection.h"
#include "nsChildIterator.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsTreeBodyFrame.h"
NS_IMPL_CYCLE_COLLECTION_1(nsTreeBoxObject, mView)
NS_IMPL_ADDREF_INHERITED(nsTreeBoxObject, nsBoxObject)
NS_IMPL_RELEASE_INHERITED(nsTreeBoxObject, nsBoxObject)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsTreeBoxObject)
NS_INTERFACE_MAP_ENTRY(nsITreeBoxObject)
NS_INTERFACE_MAP_END_INHERITING(nsBoxObject)
void
nsTreeBoxObject::Clear()
{
ClearCachedValues();
// Drop the view's ref to us.
if (mView) {
nsCOMPtr<nsITreeSelection> sel;
mView->GetSelection(getter_AddRefs(sel));
if (sel)
sel->SetTree(nullptr);
mView->SetTree(nullptr); // Break the circular ref between the view and us.
}
mView = nullptr;
nsBoxObject::Clear();
}
nsTreeBoxObject::nsTreeBoxObject()
: mTreeBody(nullptr)
{
}
nsTreeBoxObject::~nsTreeBoxObject()
{
/* destructor code */
}
static void FindBodyElement(nsIContent* aParent, nsIContent** aResult)
{
*aResult = nullptr;
ChildIterator iter, last;
for (ChildIterator::Init(aParent, &iter, &last); iter != last; ++iter) {
nsCOMPtr<nsIContent> content = *iter;
nsINodeInfo *ni = content->NodeInfo();
if (ni->Equals(nsGkAtoms::treechildren, kNameSpaceID_XUL)) {
*aResult = content;
NS_ADDREF(*aResult);
break;
} else if (ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)) {
// There are nesting tree elements. Only the innermost should
// find the treechilren.
break;
} else if (content->IsElement() &&
!ni->Equals(nsGkAtoms::_template, kNameSpaceID_XUL)) {
FindBodyElement(content, aResult);
if (*aResult)
break;
}
}
}
nsTreeBodyFrame*
nsTreeBoxObject::GetTreeBody(bool aFlushLayout)
{
// Make sure our frames are up to date, and layout as needed. We
// have to do this before checking for our cached mTreeBody, since
// it might go away on style flush, and in any case if aFlushLayout
// is true we need to make sure to flush no matter what.
// XXXbz except that flushing style when we were not asked to flush
// layout here breaks things. See bug 585123.
nsIFrame* frame;
if (aFlushLayout) {
frame = GetFrame(aFlushLayout);
if (!frame)
return nullptr;
}
if (mTreeBody) {
// Have one cached already.
return mTreeBody;
}
if (!aFlushLayout) {
frame = GetFrame(aFlushLayout);
if (!frame)
return nullptr;
}
// Iterate over our content model children looking for the body.
nsCOMPtr<nsIContent> content;
FindBodyElement(frame->GetContent(), getter_AddRefs(content));
if (!content)
return nullptr;
frame = content->GetPrimaryFrame();
if (!frame)
return nullptr;
// Make sure that the treebodyframe has a pointer to |this|.
nsTreeBodyFrame *treeBody = do_QueryFrame(frame);
NS_ENSURE_TRUE(treeBody && treeBody->GetTreeBoxObject() == this, nullptr);
mTreeBody = treeBody;
return mTreeBody;
}
NS_IMETHODIMP nsTreeBoxObject::GetView(nsITreeView * *aView)
{
if (!mTreeBody) {
if (!GetTreeBody()) {
// Don't return an uninitialised view
*aView = nullptr;
return NS_OK;
}
if (mView)
// Our new frame needs to initialise itself
return mTreeBody->GetView(aView);
}
if (!mView) {
nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(mContent);
if (xulele) {
// See if there is a XUL tree builder associated with the element
nsCOMPtr<nsIXULTemplateBuilder> builder;
xulele->GetBuilder(getter_AddRefs(builder));
mView = do_QueryInterface(builder);
if (!mView) {
// No tree builder, create a tree content view.
nsresult rv = NS_NewTreeContentView(getter_AddRefs(mView));
NS_ENSURE_SUCCESS(rv, rv);
}
// Initialise the frame and view
mTreeBody->SetView(mView);
}
}
NS_IF_ADDREF(*aView = mView);
return NS_OK;
}
static bool
CanTrustView(nsISupports* aValue)
{
// Untrusted content is only allowed to specify known-good views
if (nsContentUtils::IsCallerChrome())
return true;
nsCOMPtr<nsINativeTreeView> nativeTreeView = do_QueryInterface(aValue);
if (!nativeTreeView || NS_FAILED(nativeTreeView->EnsureNative())) {
// XXX ERRMSG need a good error here for developers
return false;
}
return true;
}
NS_IMETHODIMP nsTreeBoxObject::SetView(nsITreeView * aView)
{
if (!CanTrustView(aView))
return NS_ERROR_DOM_SECURITY_ERR;
mView = aView;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
body->SetView(aView);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetFocused(bool* aFocused)
{
*aFocused = false;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetFocused(aFocused);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::SetFocused(bool aFocused)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->SetFocused(aFocused);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetTreeBody(nsIDOMElement** aElement)
{
*aElement = nullptr;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetTreeBody(aElement);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetColumns(nsITreeColumns** aColumns)
{
*aColumns = nullptr;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetColumns(aColumns);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetRowHeight(int32_t* aRowHeight)
{
*aRowHeight = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetRowHeight(aRowHeight);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetRowWidth(int32_t *aRowWidth)
{
*aRowWidth = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetRowWidth(aRowWidth);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetFirstVisibleRow(int32_t *aFirstVisibleRow)
{
*aFirstVisibleRow = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetFirstVisibleRow(aFirstVisibleRow);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetLastVisibleRow(int32_t *aLastVisibleRow)
{
*aLastVisibleRow = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetLastVisibleRow(aLastVisibleRow);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetHorizontalPosition(int32_t *aHorizontalPosition)
{
*aHorizontalPosition = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetHorizontalPosition(aHorizontalPosition);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetPageLength(int32_t *aPageLength)
{
*aPageLength = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetPageLength(aPageLength);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetSelectionRegion(nsIScriptableRegion **aRegion)
{
*aRegion = nullptr;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetSelectionRegion(aRegion);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::EnsureRowIsVisible(int32_t aRow)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->EnsureRowIsVisible(aRow);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->EnsureCellIsVisible(aRow, aCol);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollToRow(int32_t aRow)
{
nsTreeBodyFrame* body = GetTreeBody(true);
if (body)
return body->ScrollToRow(aRow);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollByLines(int32_t aNumLines)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ScrollByLines(aNumLines);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollByPages(int32_t aNumPages)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ScrollByPages(aNumPages);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollToCell(int32_t aRow, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ScrollToCell(aRow, aCol);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollToColumn(nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ScrollToColumn(aCol);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::ScrollToHorizontalPosition(int32_t aHorizontalPosition)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ScrollToHorizontalPosition(aHorizontalPosition);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::Invalidate()
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->Invalidate();
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::InvalidateColumn(nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->InvalidateColumn(aCol);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::InvalidateRow(int32_t aIndex)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->InvalidateRow(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::InvalidateCell(int32_t aRow, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->InvalidateCell(aRow, aCol);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::InvalidateRange(int32_t aStart, int32_t aEnd)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->InvalidateRange(aStart, aEnd);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn* aCol)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->InvalidateColumnRange(aStart, aEnd, aCol);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetRowAt(int32_t x, int32_t y, int32_t *aRow)
{
*aRow = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetRowAt(x, y, aRow);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::GetCellAt(int32_t aX, int32_t aY, int32_t *aRow, nsITreeColumn** aCol,
nsACString& aChildElt)
{
*aRow = 0;
*aCol = nullptr;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetCellAt(aX, aY, aRow, aCol, aChildElt);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsACString& aElement,
int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight)
{
*aX = *aY = *aWidth = *aHeight = 0;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->GetCoordsForCellItem(aRow, aCol, aElement, aX, aY, aWidth, aHeight);
return NS_OK;
}
NS_IMETHODIMP
nsTreeBoxObject::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *aIsCropped)
{
*aIsCropped = false;
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->IsCellCropped(aRow, aCol, aIsCropped);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::RowCountChanged(int32_t aIndex, int32_t aDelta)
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->RowCountChanged(aIndex, aDelta);
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::BeginUpdateBatch()
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->BeginUpdateBatch();
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::EndUpdateBatch()
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->EndUpdateBatch();
return NS_OK;
}
NS_IMETHODIMP nsTreeBoxObject::ClearStyleAndImageCaches()
{
nsTreeBodyFrame* body = GetTreeBody();
if (body)
return body->ClearStyleAndImageCaches();
return NS_OK;
}
void
nsTreeBoxObject::ClearCachedValues()
{
mTreeBody = nullptr;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewTreeBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsTreeBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}