2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-10-15 00:15:21 +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/. */
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTreeContentView.h"
|
|
|
|
#include "nsITreeSelection.h"
|
|
|
|
#include "ChildIterator.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsTreeBodyFrame.h"
|
|
|
|
#include "mozilla/dom/DOMRect.h"
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#include "mozilla/dom/ToJSValue.h"
|
2018-12-04 19:25:30 +03:00
|
|
|
#include "mozilla/dom/XULTreeElement.h"
|
|
|
|
#include "mozilla/dom/XULTreeElementBinding.h"
|
2014-10-15 00:15:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(XULTreeElement, nsXULElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(XULTreeElement, nsXULElement, mView)
|
2014-10-15 00:15:21 +04:00
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
JSObject* XULTreeElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
|
|
|
return XULTreeElement_Binding::Wrap(aCx, this, aGivenProto);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::UnbindFromTree(bool aDeep, bool aNullParent) {
|
2014-10-15 00:15:21 +04:00
|
|
|
// Drop the view's ref to us.
|
|
|
|
if (mView) {
|
|
|
|
nsCOMPtr<nsITreeSelection> sel;
|
|
|
|
mView->GetSelection(getter_AddRefs(sel));
|
2018-12-04 19:25:30 +03:00
|
|
|
if (sel) {
|
|
|
|
sel->SetTree(nullptr);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
mView->SetTree(nullptr); // Break the circular ref between the view and us.
|
|
|
|
}
|
|
|
|
mView = nullptr;
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
nsXULElement::UnbindFromTree(aDeep, aNullParent);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::DestroyContent() {
|
|
|
|
// 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;
|
2014-10-15 00:15:21 +04:00
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
nsXULElement::DestroyContent();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
|
|
|
|
static nsIContent* FindBodyElement(nsIContent* aParent) {
|
|
|
|
mozilla::dom::FlattenedChildIterator iter(aParent);
|
|
|
|
for (nsIContent* content = iter.GetNextChild(); content;
|
|
|
|
content = iter.GetNextChild()) {
|
|
|
|
mozilla::dom::NodeInfo* ni = content->NodeInfo();
|
|
|
|
if (ni->Equals(nsGkAtoms::treechildren, kNameSpaceID_XUL)) {
|
|
|
|
return content;
|
|
|
|
} else if (ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)) {
|
|
|
|
// There are nesting tree elements. Only the innermost should
|
|
|
|
// find the treechilren.
|
|
|
|
return nullptr;
|
|
|
|
} else if (content->IsElement() &&
|
|
|
|
!ni->Equals(nsGkAtoms::_template, kNameSpaceID_XUL)) {
|
|
|
|
nsIContent* result = FindBodyElement(content);
|
|
|
|
if (result) return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-02-15 22:05:09 +03:00
|
|
|
nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(FlushType aFlushType) {
|
|
|
|
MOZ_ASSERT(aFlushType == FlushType::Frames ||
|
|
|
|
aFlushType == FlushType::Layout || aFlushType == FlushType::None);
|
2018-12-04 19:25:30 +03:00
|
|
|
nsCOMPtr<nsIContent> kungFuDeathGrip = this; // keep a reference
|
|
|
|
RefPtr<Document> doc = GetUncomposedDoc();
|
|
|
|
|
2014-10-15 00:15:21 +04:00
|
|
|
// 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.
|
2019-02-15 22:05:09 +03:00
|
|
|
if (aFlushType == FlushType::Layout && doc) {
|
2018-12-04 19:25:30 +03:00
|
|
|
doc->FlushPendingNotifications(FlushType::Layout);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mTreeBody) {
|
|
|
|
// Have one cached already.
|
|
|
|
return mTreeBody;
|
|
|
|
}
|
|
|
|
|
2019-02-15 22:05:09 +03:00
|
|
|
if (aFlushType == FlushType::Frames && doc) {
|
2018-12-04 19:25:30 +03:00
|
|
|
doc->FlushPendingNotifications(FlushType::Frames);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2019-02-15 22:05:09 +03:00
|
|
|
if (nsCOMPtr<nsIContent> tree = FindBodyElement(this)) {
|
2018-12-04 19:25:30 +03:00
|
|
|
mTreeBody = do_QueryFrame(tree->GetPrimaryFrame());
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
|
|
|
|
return mTreeBody;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
already_AddRefed<nsITreeView> XULTreeElement::GetView() {
|
2014-10-15 00:15:21 +04:00
|
|
|
if (!mTreeBody) {
|
|
|
|
if (!GetTreeBodyFrame()) {
|
2018-12-04 19:25:41 +03:00
|
|
|
return nullptr;
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
if (mView) {
|
2018-12-04 19:25:41 +03:00
|
|
|
nsCOMPtr<nsITreeView> view;
|
2014-10-15 00:15:21 +04:00
|
|
|
// Our new frame needs to initialise itself
|
2018-12-04 19:25:41 +03:00
|
|
|
mTreeBody->GetView(getter_AddRefs(view));
|
|
|
|
return view.forget();
|
2018-12-04 19:25:30 +03:00
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
if (!mView) {
|
2018-12-04 19:25:30 +03:00
|
|
|
// No tree builder, create a tree content view.
|
2018-12-04 19:25:41 +03:00
|
|
|
if (NS_FAILED(NS_NewTreeContentView(getter_AddRefs(mView)))) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2018-12-04 19:25:30 +03:00
|
|
|
|
|
|
|
// Initialise the frame and view
|
|
|
|
mTreeBody->SetView(mView);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
return do_AddRef(mView);
|
2018-02-15 17:41:50 +03:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::SetView(nsITreeView* aView, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) {
|
2018-02-13 21:53:52 +03:00
|
|
|
if (aCallerType != CallerType::System) {
|
|
|
|
// Don't trust views coming from random places.
|
|
|
|
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
|
|
|
return;
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mView = aView;
|
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->SetView(aView);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
bool XULTreeElement::Focused() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->GetFocused();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::SetFocused(bool aFocused) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->SetFocused(aFocused);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
already_AddRefed<Element> XULTreeElement::GetTreeBody() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
nsCOMPtr<Element> element;
|
|
|
|
body->GetTreeBody(getter_AddRefs(element));
|
|
|
|
return element.forget();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
return nullptr;
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
already_AddRefed<nsTreeColumns> XULTreeElement::GetColumns() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->Columns();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::RowHeight() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->RowHeight();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::RowWidth() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->RowWidth();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::GetFirstVisibleRow() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->FirstVisibleRow();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::GetLastVisibleRow() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->LastVisibleRow();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::HorizontalPosition() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->GetHorizontalPosition();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::GetPageLength() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
return body->PageLength();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::EnsureRowIsVisible(int32_t aRow) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->EnsureRowIsVisible(aRow);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol,
|
|
|
|
ErrorResult& aRv) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-06-06 06:01:55 +03:00
|
|
|
if (body) {
|
|
|
|
nsresult rv = body->EnsureCellIsVisible(aRow, aCol);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::ScrollToRow(int32_t aRow) {
|
2019-02-15 22:05:09 +03:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame(FlushType::Layout);
|
2018-06-06 06:01:55 +03:00
|
|
|
if (!body) {
|
|
|
|
return;
|
|
|
|
}
|
2018-09-07 17:47:51 +03:00
|
|
|
|
2018-06-06 06:01:55 +03:00
|
|
|
body->ScrollToRow(aRow);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::ScrollByLines(int32_t aNumLines) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-06-06 06:01:55 +03:00
|
|
|
if (!body) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
body->ScrollByLines(aNumLines);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::ScrollByPages(int32_t aNumPages) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->ScrollByPages(aNumPages);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::Invalidate() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->Invalidate();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::InvalidateColumn(nsTreeColumn* aCol) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->InvalidateColumn(aCol);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::InvalidateRow(int32_t aIndex) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->InvalidateRow(aIndex);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::InvalidateCell(int32_t aRow, nsTreeColumn* aCol) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->InvalidateCell(aRow, aCol);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::InvalidateRange(int32_t aStart, int32_t aEnd) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->InvalidateRange(aStart, aEnd);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
int32_t XULTreeElement::GetRowAt(int32_t x, int32_t y) {
|
2018-06-06 06:01:55 +03:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
|
|
|
if (!body) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return body->GetRowAt(x, y);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
void XULTreeElement::GetCellAt(int32_t aX, int32_t aY, TreeCellInfo& aRetVal,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
aRetVal.mRow = 0;
|
|
|
|
aRetVal.mCol = nullptr;
|
|
|
|
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
|
|
|
if (body) {
|
|
|
|
nsAutoCString element;
|
2018-12-04 19:25:41 +03:00
|
|
|
body->GetCellAt(aX, aY, &aRetVal.mRow, getter_AddRefs(aRetVal.mCol),
|
|
|
|
element);
|
|
|
|
CopyUTF8toUTF16(element, aRetVal.mChildElt);
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
nsIntRect XULTreeElement::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
|
|
|
|
const nsAString& aElement,
|
|
|
|
nsresult& rv) {
|
|
|
|
rv = NS_OK;
|
|
|
|
nsIntRect rect;
|
2014-10-15 00:15:21 +04:00
|
|
|
|
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
|
|
|
NS_ConvertUTF16toUTF8 element(aElement);
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
rv = body->GetCoordsForCellItem(aRow, aCol, element, &rect.x, &rect.y,
|
|
|
|
&rect.width, &rect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
already_AddRefed<DOMRect> XULTreeElement::GetCoordsForCellItem(
|
2018-12-04 19:25:41 +03:00
|
|
|
int32_t aRow, nsTreeColumn& aCol, const nsAString& aElement,
|
2014-10-17 13:13:41 +04:00
|
|
|
ErrorResult& aRv) {
|
2018-12-04 19:25:41 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsIntRect rect = GetCoordsForCellItem(aRow, &aCol, aElement, rv);
|
|
|
|
aRv = rv;
|
2014-10-15 00:15:21 +04:00
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
RefPtr<DOMRect> domRect =
|
|
|
|
new DOMRect(this, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
return domRect.forget();
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
bool XULTreeElement::IsCellCropped(int32_t aRow, nsTreeColumn* aCol,
|
2018-12-04 19:25:30 +03:00
|
|
|
ErrorResult& aRv) {
|
2018-12-04 19:25:41 +03:00
|
|
|
bool cropped = false;
|
|
|
|
|
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
|
|
|
if (body) {
|
|
|
|
aRv = body->IsCellCropped(aRow, aCol, &cropped);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cropped;
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::RowCountChanged(int32_t aIndex, int32_t aDelta) {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->RowCountChanged(aIndex, aDelta);
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::BeginUpdateBatch() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->BeginUpdateBatch();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::EndUpdateBatch() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->EndUpdateBatch();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::ClearStyleAndImageCaches() {
|
2014-10-15 00:15:21 +04:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
2018-12-04 19:25:41 +03:00
|
|
|
if (body) {
|
|
|
|
body->ClearStyleAndImageCaches();
|
|
|
|
}
|
2014-10-15 00:15:21 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:25:30 +03:00
|
|
|
void XULTreeElement::RemoveImageCacheEntry(int32_t aRowIndex,
|
|
|
|
nsTreeColumn& aCol,
|
|
|
|
ErrorResult& aRv) {
|
2018-06-06 06:01:55 +03:00
|
|
|
if (NS_WARN_IF(aRowIndex < 0)) {
|
|
|
|
aRv.Throw(NS_ERROR_INVALID_ARG);
|
|
|
|
return;
|
|
|
|
}
|
2017-04-19 12:41:49 +03:00
|
|
|
nsTreeBodyFrame* body = GetTreeBodyFrame();
|
|
|
|
if (body) {
|
2018-06-06 06:01:55 +03:00
|
|
|
body->RemoveImageCacheEntry(aRowIndex, &aCol);
|
2017-04-19 12:41:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-15 00:15:21 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|