Bug 1482389, remove methods of XULTreeElement that return unused nsresults. In addition, change GetView to return the nsITreeView instead of using an out-parameter, r=paolo

This commit is contained in:
Neil Deakin 2018-12-04 11:25:41 -05:00
Родитель 8a34b15d64
Коммит 52a756d064
11 изменённых файлов: 196 добавлений и 236 удалений

Просмотреть файл

@ -66,8 +66,7 @@ bool nsCoreUtils::HasClickListener(nsIContent *aContent) {
void nsCoreUtils::DispatchClickEvent(XULTreeElement *aTree,
int32_t aRowIndex, nsTreeColumn *aColumn,
const nsAString &aPseudoElt) {
RefPtr<dom::Element> tcElm;
aTree->GetTreeBody(getter_AddRefs(tcElm));
RefPtr<dom::Element> tcElm = aTree->GetTreeBody();
if (!tcElm) return;
Document *document = tcElm->GetUncomposedDoc();
@ -80,10 +79,12 @@ void nsCoreUtils::DispatchClickEvent(XULTreeElement *aTree,
aTree->EnsureRowIsVisible(aRowIndex);
// Calculate x and y coordinates.
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = aTree->GetCoordsForCellItem(aRowIndex, aColumn, aPseudoElt, &x,
&y, &width, &height);
if (NS_FAILED(rv)) return;
nsresult rv;
nsIntRect rect =
aTree->GetCoordsForCellItem(aRowIndex, aColumn, aPseudoElt, rv);
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIBoxObject> tcBoxObj =
nsXULElement::FromNode(tcElm)->GetBoxObject(IgnoreErrors());
@ -103,9 +104,9 @@ void nsCoreUtils::DispatchClickEvent(XULTreeElement *aTree,
RefPtr<nsPresContext> presContext = presShell->GetPresContext();
int32_t cnvdX = presContext->CSSPixelsToDevPixels(tcX + x + 1) +
int32_t cnvdX = presContext->CSSPixelsToDevPixels(tcX + int32_t(rect.x) + 1) +
presContext->AppUnitsToDevPixels(offset.x);
int32_t cnvdY = presContext->CSSPixelsToDevPixels(tcY + y + 1) +
int32_t cnvdY = presContext->CSSPixelsToDevPixels(tcY + int32_t(rect.y) + 1) +
presContext->AppUnitsToDevPixels(offset.y);
// XUL is just desktop, so there is no real reason for senfing touch events.
@ -426,8 +427,7 @@ void nsCoreUtils::GetLanguageFor(nsIContent *aContent, nsIContent *aRootContent,
already_AddRefed<nsIBoxObject> nsCoreUtils::GetTreeBodyBoxObject(
XULTreeElement *aTree) {
RefPtr<dom::Element> tcElm;
aTree->GetTreeBody(getter_AddRefs(tcElm));
RefPtr<dom::Element> tcElm = aTree->GetTreeBody();
RefPtr<nsXULElement> tcXULElm = nsXULElement::FromNodeOrNull(tcElm);
if (!tcXULElm) return nullptr;
@ -449,8 +449,7 @@ XULTreeElement *nsCoreUtils::GetTree(nsIContent *aContent) {
already_AddRefed<nsTreeColumn> nsCoreUtils::GetFirstSensibleColumn(
XULTreeElement *aTree) {
RefPtr<nsTreeColumns> cols;
aTree->GetColumns(getter_AddRefs(cols));
RefPtr<nsTreeColumns> cols = aTree->GetColumns();
if (!cols) return nullptr;
RefPtr<nsTreeColumn> column = cols->GetFirstColumn();
@ -462,8 +461,7 @@ already_AddRefed<nsTreeColumn> nsCoreUtils::GetFirstSensibleColumn(
uint32_t nsCoreUtils::GetSensibleColumnCount(XULTreeElement *aTree) {
uint32_t count = 0;
RefPtr<nsTreeColumns> cols;
aTree->GetColumns(getter_AddRefs(cols));
RefPtr<nsTreeColumns> cols = aTree->GetColumns();
if (!cols) return count;
nsTreeColumn *column = cols->GetFirstColumn();

Просмотреть файл

@ -31,6 +31,7 @@
#include "nsTreeBodyFrame.h"
#include "nsTreeColumns.h"
#include "nsTreeUtils.h"
#include "mozilla/dom/XULTreeElementBinding.h"
using namespace mozilla::a11y;
@ -113,8 +114,7 @@ void XULTreeAccessible::Value(nsString& aValue) const {
if (currentIndex >= 0) {
RefPtr<nsTreeColumn> keyCol;
RefPtr<nsTreeColumns> cols;
mTree->GetColumns(getter_AddRefs(cols));
RefPtr<nsTreeColumns> cols = mTree->GetColumns();
if (cols) keyCol = cols->GetKeyColumn();
mTreeView->GetCellText(currentIndex, keyCol, aValue);
@ -171,23 +171,21 @@ Accessible* XULTreeAccessible::ChildAtPoint(int32_t aX, int32_t aY,
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.X();
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
RefPtr<nsTreeColumn> column;
nsAutoString childEltUnused;
mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column),
childEltUnused);
ErrorResult rv;
dom::TreeCellInfo cellInfo;
mTree->GetCellAt(clientX, clientY, cellInfo, rv);
// If we failed to find tree cell for the given point then it might be
// tree columns.
if (row == -1 || !column)
if (cellInfo.mRow == -1 || !cellInfo.mCol)
return AccessibleWrap::ChildAtPoint(aX, aY, aWhichChild);
Accessible* child = GetTreeItemAccessible(row);
Accessible* child = GetTreeItemAccessible(cellInfo.mRow);
if (aWhichChild == eDeepestChild && child) {
// Look for accessible cell for the found item accessible.
RefPtr<XULTreeItemAccessibleBase> treeitem = do_QueryObject(child);
Accessible* cell = treeitem->GetCellAccessible(column);
Accessible* cell = treeitem->GetCellAccessible(cellInfo.mCol);
if (cell) child = cell;
}
@ -524,8 +522,7 @@ void XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow,
endRow = rowCount - 1;
}
RefPtr<nsTreeColumns> treeColumns;
mTree->GetColumns(getter_AddRefs(treeColumns));
RefPtr<nsTreeColumns> treeColumns = mTree->GetColumns();
if (!treeColumns) return;
int32_t endCol = aEndCol;
@ -625,23 +622,19 @@ nsIntRect XULTreeItemAccessibleBase::BoundsInCSSPixels() const {
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = mTree->GetCoordsForCellItem(mRow, column, EmptyString(), &x, &y,
&width, &height);
nsresult rv;
nsIntRect rect =
mTree->GetCoordsForCellItem(mRow, column, NS_LITERAL_STRING("cell"), rv);
if (NS_FAILED(rv)) {
return nsIntRect();
}
boxObj->GetWidth(&width);
boxObj->GetWidth(&rect.width);
int32_t tcX = 0, tcY = 0;
boxObj->GetScreenX(&tcX);
boxObj->GetScreenY(&tcY);
x = tcX;
y += tcY;
return nsIntRect(x, y, width, height);
return nsIntRect(tcX, rect.y + tcY, rect.width, rect.height);
}
nsRect XULTreeItemAccessibleBase::BoundsInAppUnits() const {
@ -806,9 +799,8 @@ uint64_t XULTreeItemAccessibleBase::NativeState() const {
if (FocusMgr()->IsFocused(this)) state |= states::FOCUSED;
// invisible state
int32_t firstVisibleRow, lastVisibleRow;
mTree->GetFirstVisibleRow(&firstVisibleRow);
mTree->GetLastVisibleRow(&lastVisibleRow);
int32_t firstVisibleRow = mTree->GetFirstVisibleRow();
int32_t lastVisibleRow = mTree->GetLastVisibleRow();
if (mRow < firstVisibleRow || mRow > lastVisibleRow)
state |= states::INVISIBLE;
@ -837,8 +829,7 @@ void XULTreeItemAccessibleBase::DispatchClickEvent(
nsIContent* aContent, uint32_t aActionIndex) const {
if (IsDefunct()) return;
RefPtr<nsTreeColumns> columns;
mTree->GetColumns(getter_AddRefs(columns));
RefPtr<nsTreeColumns> columns = mTree->GetColumns();
if (!columns) return;
// Get column and pseudo element.
@ -874,8 +865,7 @@ bool XULTreeItemAccessibleBase::IsExpandable() const {
bool isEmpty = false;
mTreeView->IsContainerEmpty(mRow, &isEmpty);
if (!isEmpty) {
RefPtr<nsTreeColumns> columns;
mTree->GetColumns(getter_AddRefs(columns));
RefPtr<nsTreeColumns> columns = mTree->GetColumns();
if (columns) {
nsTreeColumn* primaryColumn = columns->GetPrimaryColumn();
if (primaryColumn && !nsCoreUtils::IsColumnHidden(primaryColumn))
@ -946,8 +936,7 @@ void XULTreeItemAccessible::Shutdown() {
}
role XULTreeItemAccessible::NativeRole() const {
RefPtr<nsTreeColumns> columns;
mTree->GetColumns(getter_AddRefs(columns));
RefPtr<nsTreeColumns> columns = mTree->GetColumns();
if (!columns) {
NS_ERROR("No tree columns object in the tree!");
return roles::NOTHING;
@ -989,8 +978,7 @@ Accessible* XULTreeColumAccessible::GetSiblingAtOffset(int32_t aOffset,
RefPtr<dom::XULTreeElement> tree = nsCoreUtils::GetTree(mContent);
if (tree) {
nsCOMPtr<nsITreeView> treeView;
tree->GetView(getter_AddRefs(treeView));
nsCOMPtr<nsITreeView> treeView = tree->GetView();
if (treeView) {
int32_t rowCount = 0;
treeView->GetRowCount(&rowCount);

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsComponentManagerUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TreeColumnBinding.h"
#include "mozilla/dom/XULTreeElementBinding.h"
using namespace mozilla::a11y;
using namespace mozilla;
@ -169,8 +170,7 @@ void XULTreeGridAccessible::UnselectRow(uint32_t aRowIdx) {
// XULTreeGridAccessible: Accessible implementation
role XULTreeGridAccessible::NativeRole() const {
RefPtr<nsTreeColumns> treeColumns;
mTree->GetColumns(getter_AddRefs(treeColumns));
RefPtr<nsTreeColumns> treeColumns = mTree->GetColumns();
if (!treeColumns) {
NS_ERROR("No treecolumns object for tree!");
return roles::NOTHING;
@ -268,16 +268,14 @@ Accessible* XULTreeGridRowAccessible::ChildAtPoint(
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.X();
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
RefPtr<nsTreeColumn> column;
nsAutoString childEltUnused;
mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column),
childEltUnused);
ErrorResult rv;
dom::TreeCellInfo cellInfo;
mTree->GetCellAt(clientX, clientY, cellInfo, rv);
// Return if we failed to find tree cell in the row for the given point.
if (row != mRow || !column) return nullptr;
if (cellInfo.mRow != mRow || !cellInfo.mCol) return nullptr;
return GetCellAccessible(column);
return GetCellAccessible(cellInfo.mCol);
}
Accessible* XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex) const {
@ -314,8 +312,7 @@ XULTreeGridCellAccessible* XULTreeGridRowAccessible::GetCellAccessible(
void XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
int32_t aEndColIdx) {
RefPtr<nsTreeColumns> treeColumns;
mTree->GetColumns(getter_AddRefs(treeColumns));
RefPtr<nsTreeColumns> treeColumns = mTree->GetColumns();
if (!treeColumns) return;
bool nameChanged = false;
@ -410,9 +407,9 @@ nsIntRect XULTreeGridCellAccessible::BoundsInCSSPixels() const {
return nsIntRect();
}
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = mTree->GetCoordsForCellItem(
mRow, mColumn, NS_LITERAL_STRING("cell"), &x, &y, &width, &height);
nsresult rv;
nsIntRect rect =
mTree->GetCoordsForCellItem(mRow, mColumn, NS_LITERAL_STRING("cell"), rv);
if (NS_FAILED(rv)) {
return nsIntRect();
}
@ -420,10 +417,7 @@ nsIntRect XULTreeGridCellAccessible::BoundsInCSSPixels() const {
int32_t tcX = 0, tcY = 0;
boxObj->GetScreenX(&tcX);
boxObj->GetScreenY(&tcY);
x += tcX;
y += tcY;
return nsIntRect(x, y, width, height);
return nsIntRect(rect.x + tcX, rect.y + tcY, rect.width, rect.height);
}
nsRect XULTreeGridCellAccessible::BoundsInAppUnits() const {

Просмотреть файл

@ -110,41 +110,30 @@ nsTreeBodyFrame* XULTreeElement::GetTreeBodyFrame(bool aFlushLayout) {
return mTreeBody;
}
nsresult XULTreeElement::GetView(nsITreeView** aView) {
already_AddRefed<nsITreeView> XULTreeElement::GetView() {
if (!mTreeBody) {
if (!GetTreeBodyFrame()) {
// Don't return an uninitialised view
*aView = nullptr;
return NS_OK;
return nullptr;
}
if (mView) {
nsCOMPtr<nsITreeView> view;
// Our new frame needs to initialise itself
return mTreeBody->GetView(aView);
mTreeBody->GetView(getter_AddRefs(view));
return view.forget();
}
}
if (!mView) {
// No tree builder, create a tree content view.
nsresult rv = NS_NewTreeContentView(getter_AddRefs(mView));
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(NS_NewTreeContentView(getter_AddRefs(mView)))) {
return nullptr;
}
// Initialise the frame and view
mTreeBody->SetView(mView);
}
NS_IF_ADDREF(*aView = mView);
return NS_OK;
}
already_AddRefed<nsITreeView> XULTreeElement::GetView(CallerType /* unused */) {
nsCOMPtr<nsITreeView> view;
GetView(getter_AddRefs(view));
return view.forget();
}
nsresult XULTreeElement::SetView(nsITreeView* aView) {
ErrorResult rv;
SetView(aView, CallerType::System, rv);
return rv.StealNSResult();
return do_AddRef(mView);
}
void XULTreeElement::SetView(nsITreeView* aView, CallerType aCallerType,
@ -157,108 +146,98 @@ void XULTreeElement::SetView(nsITreeView* aView, CallerType aCallerType,
mView = aView;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->SetView(aView);
if (body) {
body->SetView(aView);
}
}
bool XULTreeElement::Focused() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->GetFocused();
if (body) {
return body->GetFocused();
}
return false;
}
nsresult XULTreeElement::GetFocused(bool* aFocused) {
*aFocused = Focused();
return NS_OK;
}
void XULTreeElement::SetFocused(bool aFocused) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->SetFocused(aFocused);
}
nsresult XULTreeElement::GetTreeBody(Element** aElement) {
*aElement = nullptr;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->GetTreeBody(aElement);
return NS_OK;
if (body) {
body->SetFocused(aFocused);
}
}
already_AddRefed<Element> XULTreeElement::GetTreeBody() {
RefPtr<Element> el;
GetTreeBody(getter_AddRefs(el));
return el.forget();
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) {
nsCOMPtr<Element> element;
body->GetTreeBody(getter_AddRefs(element));
return element.forget();
}
return nullptr;
}
already_AddRefed<nsTreeColumns> XULTreeElement::GetColumns() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->Columns();
if (body) {
return body->Columns();
}
return nullptr;
}
nsresult XULTreeElement::GetColumns(nsTreeColumns** aColumns) {
*aColumns = GetColumns().take();
return NS_OK;
}
int32_t XULTreeElement::RowHeight() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->RowHeight();
if (body) {
return body->RowHeight();
}
return 0;
}
int32_t XULTreeElement::RowWidth() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->RowWidth();
if (body) {
return body->RowWidth();
}
return 0;
}
nsresult XULTreeElement::GetRowHeight(int32_t* aRowHeight) {
*aRowHeight = RowHeight();
return NS_OK;
}
nsresult XULTreeElement::GetRowWidth(int32_t* aRowWidth) {
*aRowWidth = RowWidth();
return NS_OK;
}
int32_t XULTreeElement::GetFirstVisibleRow() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->FirstVisibleRow();
if (body) {
return body->FirstVisibleRow();
}
return 0;
}
nsresult XULTreeElement::GetFirstVisibleRow(int32_t* aFirstVisibleRow) {
*aFirstVisibleRow = GetFirstVisibleRow();
return NS_OK;
}
int32_t XULTreeElement::GetLastVisibleRow() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->LastVisibleRow();
if (body) {
return body->LastVisibleRow();
}
return 0;
}
nsresult XULTreeElement::GetLastVisibleRow(int32_t* aLastVisibleRow) {
*aLastVisibleRow = GetLastVisibleRow();
return NS_OK;
}
int32_t XULTreeElement::HorizontalPosition() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->GetHorizontalPosition();
if (body) {
return body->GetHorizontalPosition();
}
return 0;
}
int32_t XULTreeElement::GetPageLength() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->PageLength();
if (body) {
return body->PageLength();
}
return 0;
}
void XULTreeElement::EnsureRowIsVisible(int32_t aRow) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->EnsureRowIsVisible(aRow);
if (body) {
body->EnsureRowIsVisible(aRow);
}
}
void XULTreeElement::EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol,
@ -291,32 +270,44 @@ void XULTreeElement::ScrollByLines(int32_t aNumLines) {
void XULTreeElement::ScrollByPages(int32_t aNumPages) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->ScrollByPages(aNumPages);
if (body) {
body->ScrollByPages(aNumPages);
}
}
void XULTreeElement::Invalidate() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->Invalidate();
if (body) {
body->Invalidate();
}
}
void XULTreeElement::InvalidateColumn(nsTreeColumn* aCol) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->InvalidateColumn(aCol);
if (body) {
body->InvalidateColumn(aCol);
}
}
void XULTreeElement::InvalidateRow(int32_t aIndex) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->InvalidateRow(aIndex);
if (body) {
body->InvalidateRow(aIndex);
}
}
void XULTreeElement::InvalidateCell(int32_t aRow, nsTreeColumn* aCol) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->InvalidateCell(aRow, aCol);
if (body) {
body->InvalidateCell(aRow, aCol);
}
}
void XULTreeElement::InvalidateRange(int32_t aStart, int32_t aEnd) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->InvalidateRange(aStart, aEnd);
if (body) {
body->InvalidateRange(aStart, aEnd);
}
}
int32_t XULTreeElement::GetRowAt(int32_t x, int32_t y) {
@ -327,82 +318,86 @@ int32_t XULTreeElement::GetRowAt(int32_t x, int32_t y) {
return body->GetRowAt(x, y);
}
nsresult XULTreeElement::GetCellAt(int32_t aX, int32_t aY, int32_t* aRow,
nsTreeColumn** aCol, nsAString& aChildElt) {
*aRow = 0;
*aCol = nullptr;
void XULTreeElement::GetCellAt(int32_t aX, int32_t aY, TreeCellInfo& aRetVal,
ErrorResult& aRv) {
aRetVal.mRow = 0;
aRetVal.mCol = nullptr;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) {
nsAutoCString element;
nsresult retval = body->GetCellAt(aX, aY, aRow, aCol, element);
CopyUTF8toUTF16(element, aChildElt);
return retval;
body->GetCellAt(aX, aY, &aRetVal.mRow, getter_AddRefs(aRetVal.mCol),
element);
CopyUTF8toUTF16(element, aRetVal.mChildElt);
}
return NS_OK;
}
void XULTreeElement::GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal,
ErrorResult& aRv) {
GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(aRetVal.mCol),
aRetVal.mChildElt);
}
nsIntRect XULTreeElement::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
const nsAString& aElement,
nsresult& rv) {
rv = NS_OK;
nsIntRect rect;
nsresult XULTreeElement::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
const nsAString& aElement,
int32_t* aX, int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) {
*aX = *aY = *aWidth = *aHeight = 0;
nsTreeBodyFrame* body = GetTreeBodyFrame();
NS_ConvertUTF16toUTF8 element(aElement);
if (body)
return body->GetCoordsForCellItem(aRow, aCol, element, aX, aY, aWidth,
aHeight);
return NS_OK;
if (body) {
rv = body->GetCoordsForCellItem(aRow, aCol, element, &rect.x, &rect.y,
&rect.width, &rect.height);
}
return rect;
}
already_AddRefed<DOMRect> XULTreeElement::GetCoordsForCellItem(
int32_t row, nsTreeColumn& col, const nsAString& element,
int32_t aRow, nsTreeColumn& aCol, const nsAString& aElement,
ErrorResult& aRv) {
int32_t x, y, w, h;
GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h);
RefPtr<DOMRect> rect = new DOMRect(this, x, y, w, h);
return rect.forget();
nsresult rv;
nsIntRect rect = GetCoordsForCellItem(aRow, &aCol, aElement, rv);
aRv = rv;
RefPtr<DOMRect> domRect =
new DOMRect(this, rect.x, rect.y, rect.width, rect.height);
return domRect.forget();
}
nsresult XULTreeElement::IsCellCropped(int32_t aRow, nsTreeColumn* aCol,
bool* aIsCropped) {
*aIsCropped = false;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) return body->IsCellCropped(aRow, aCol, aIsCropped);
return NS_OK;
}
bool XULTreeElement::IsCellCropped(int32_t row, nsTreeColumn* col,
bool XULTreeElement::IsCellCropped(int32_t aRow, nsTreeColumn* aCol,
ErrorResult& aRv) {
bool ret;
aRv = IsCellCropped(row, col, &ret);
return ret;
bool cropped = false;
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) {
aRv = body->IsCellCropped(aRow, aCol, &cropped);
}
return cropped;
}
void XULTreeElement::RowCountChanged(int32_t aIndex, int32_t aDelta) {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->RowCountChanged(aIndex, aDelta);
if (body) {
body->RowCountChanged(aIndex, aDelta);
}
}
void XULTreeElement::BeginUpdateBatch() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->BeginUpdateBatch();
if (body) {
body->BeginUpdateBatch();
}
}
void XULTreeElement::EndUpdateBatch() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->EndUpdateBatch();
if (body) {
body->EndUpdateBatch();
}
}
void XULTreeElement::ClearStyleAndImageCaches() {
nsTreeBodyFrame* body = GetTreeBodyFrame();
if (body) body->ClearStyleAndImageCaches();
if (body) {
body->ClearStyleAndImageCaches();
}
}
void XULTreeElement::RemoveImageCacheEntry(int32_t aRowIndex,

Просмотреть файл

@ -38,12 +38,15 @@ class XULTreeElement final : public nsXULElement {
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeElement, nsXULElement)
nsTreeBodyFrame *GetTreeBodyFrame(bool aFlushLayout = false);
nsTreeBodyFrame *GetCachedTreeBodyFrame() { return mTreeBody; }
nsTreeBodyFrame* GetTreeBodyFrame(bool aFlushLayout = false);
nsTreeBodyFrame* GetCachedTreeBodyFrame() { return mTreeBody; }
already_AddRefed<nsTreeColumns> GetColumns();
already_AddRefed<nsITreeView> GetView(CallerType /* unused */);
already_AddRefed<nsITreeView> GetView(CallerType /* unused */) {
return GetView();
}
already_AddRefed<nsITreeView> GetView();
void SetView(nsITreeView* arg, CallerType aCallerType, ErrorResult& aRv);
@ -57,7 +60,7 @@ class XULTreeElement final : public nsXULElement {
int32_t HorizontalPosition();
void EnsureCellIsVisible(int32_t row, nsTreeColumn *col, ErrorResult &aRv);
void EnsureCellIsVisible(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
void ScrollToRow(int32_t aRow);
@ -73,42 +76,29 @@ class XULTreeElement final : public nsXULElement {
int32_t GetRowAt(int32_t x, int32_t y);
void GetCellAt(int32_t x, int32_t y, TreeCellInfo &aRetVal, ErrorResult &aRv);
void GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv);
already_AddRefed<DOMRect> GetCoordsForCellItem(int32_t row, nsTreeColumn &col,
const nsAString &element,
ErrorResult &aRv);
nsIntRect GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
const nsAString& aElement, nsresult& rv);
already_AddRefed<DOMRect> GetCoordsForCellItem(int32_t row, nsTreeColumn& col,
const nsAString& element,
ErrorResult& aRv);
bool IsCellCropped(int32_t row, nsTreeColumn *col, ErrorResult &aRv);
bool IsCellCropped(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
void RemoveImageCacheEntry(int32_t row, nsTreeColumn &col, ErrorResult &aRv);
void RemoveImageCacheEntry(int32_t row, nsTreeColumn& col, ErrorResult& aRv);
void SetFocused(bool aFocused);
void EnsureRowIsVisible(int32_t index);
void Invalidate(void);
void InvalidateColumn(nsTreeColumn *col);
void InvalidateColumn(nsTreeColumn* col);
void InvalidateRow(int32_t index);
void InvalidateCell(int32_t row, nsTreeColumn *col);
void InvalidateCell(int32_t row, nsTreeColumn* col);
void InvalidateRange(int32_t startIndex, int32_t endIndex);
void RowCountChanged(int32_t index, int32_t count);
void BeginUpdateBatch(void);
void EndUpdateBatch(void);
void ClearStyleAndImageCaches(void);
nsresult GetColumns(nsTreeColumns **aColumns);
nsresult GetView(nsITreeView **aView);
nsresult SetView(nsITreeView *aView);
nsresult GetFocused(bool *aFocused);
nsresult GetTreeBody(mozilla::dom::Element **aTreeBody);
nsresult GetRowHeight(int32_t *aRowHeight);
nsresult GetRowWidth(int32_t *aRowWidth);
nsresult GetFirstVisibleRow(int32_t *_retval);
nsresult GetLastVisibleRow(int32_t *_retval);
nsresult GetCellAt(int32_t x, int32_t y, int32_t *row, nsTreeColumn **col,
nsAString &childElt);
nsresult GetCoordsForCellItem(int32_t row, nsTreeColumn *col,
const nsAString &element, int32_t *x,
int32_t *y, int32_t *width, int32_t *height);
nsresult IsCellCropped(int32_t row, nsTreeColumn *col, bool *_retval);
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
virtual void DestroyContent() override;
@ -123,7 +113,7 @@ class XULTreeElement final : public nsXULElement {
protected:
int32_t mCachedFirstVisibleRow;
nsTreeBodyFrame *mTreeBody;
nsTreeBodyFrame* mTreeBody;
nsCOMPtr<nsITreeView> mView;
virtual ~XULTreeElement() {}

Просмотреть файл

@ -7984,16 +7984,14 @@ void PresShell::GetCurrentItemAndPositionForElement(
// which could provide the current focus coordinates?
if (tree) {
tree->EnsureRowIsVisible(currentIndex);
int32_t firstVisibleRow, rowHeight;
tree->GetFirstVisibleRow(&firstVisibleRow);
tree->GetRowHeight(&rowHeight);
int32_t firstVisibleRow = tree->GetFirstVisibleRow();
int32_t rowHeight = tree->RowHeight();
extraTreeY += nsPresContext::CSSPixelsToAppUnits(
(currentIndex - firstVisibleRow + 1) * rowHeight);
istree = true;
RefPtr<nsTreeColumns> cols;
tree->GetColumns(getter_AddRefs(cols));
RefPtr<nsTreeColumns> cols = tree->GetColumns();
if (cols) {
nsTreeColumn* col = cols->GetFirstColumn();
if (col) {

Просмотреть файл

@ -33,6 +33,7 @@
#include "mozilla/dom/BoxObject.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/TreeColumnBinding.h"
#include "mozilla/dom/XULTreeElementBinding.h"
#include "mozilla/TextEvents.h"
using namespace mozilla;
@ -337,10 +338,6 @@ void nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent) {
int32_t x = aMouseEvent->ScreenX(CallerType::System);
int32_t y = aMouseEvent->ScreenY(CallerType::System);
int32_t row;
RefPtr<nsTreeColumn> col;
nsAutoString obj;
// subtract off the documentElement's boxObject
int32_t boxX, boxY;
bx->GetScreenX(&boxX);
@ -348,7 +345,12 @@ void nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent) {
x -= boxX;
y -= boxY;
tree->GetCellAt(x, y, &row, getter_AddRefs(col), obj);
ErrorResult rv;
TreeCellInfo cellInfo;
tree->GetCellAt(x, y, cellInfo, rv);
int32_t row = cellInfo.mRow;
RefPtr<nsTreeColumn> col = cellInfo.mCol;
// determine if we are going to need a titletip
// XXX check the disabletitletips attribute on the tree content
@ -357,9 +359,9 @@ void nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent) {
if (col) {
colType = col->Type();
}
if (row >= 0 && obj.EqualsLiteral("text") &&
if (row >= 0 && cellInfo.mChildElt.EqualsLiteral("text") &&
colType != TreeColumn_Binding::TYPE_PASSWORD) {
tree->IsCellCropped(row, col, &mNeedTitletip);
mNeedTitletip = tree->IsCellCropped(row, col, rv);
}
nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
@ -435,8 +437,7 @@ nsresult nsXULTooltipListener::ShowTooltip() {
#ifdef MOZ_XUL
static void SetTitletipLabel(XULTreeElement* aTree, Element* aTooltip,
int32_t aRow, nsTreeColumn* aCol) {
nsCOMPtr<nsITreeView> view;
aTree->GetView(getter_AddRefs(view));
nsCOMPtr<nsITreeView> view = aTree->GetView();
if (view) {
nsAutoString label;
#ifdef DEBUG

Просмотреть файл

@ -277,8 +277,7 @@ void nsTreeBodyFrame::EnsureView() {
RefPtr<XULTreeElement> tree = GetBaseElement();
if (tree) {
nsCOMPtr<nsITreeView> treeView;
tree->GetView(getter_AddRefs(treeView));
nsCOMPtr<nsITreeView> treeView = tree->GetView();
if (treeView && weakFrame.IsAlive()) {
int32_t rowIndex = tree->GetCachedTopVisibleRow();

Просмотреть файл

@ -155,7 +155,7 @@ void nsTreeColFrame::InvalidateColumns(bool aCanWalkFrameTree) {
RefPtr<nsTreeColumns> columns;
if (aCanWalkFrameTree) {
tree->GetColumns(getter_AddRefs(columns));
columns = tree->GetColumns();
} else {
nsTreeBodyFrame* body = tree->GetCachedTreeBodyFrame();
if (body) {

Просмотреть файл

@ -518,8 +518,7 @@ nsTreeContentView::SetTree(XULTreeElement* aTree) {
mDocument = document;
}
RefPtr<dom::Element> bodyElement;
mTree->GetTreeBody(getter_AddRefs(bodyElement));
RefPtr<dom::Element> bodyElement = mTree->GetTreeBody();
if (bodyElement) {
mBody = bodyElement.forget();
int32_t index = 0;
@ -779,8 +778,7 @@ void nsTreeContentView::AttributeChanged(dom::Element* aElement,
if (aElement->IsXULElement(nsGkAtoms::treecol)) {
if (aAttribute == nsGkAtoms::properties) {
if (mTree) {
RefPtr<nsTreeColumns> cols;
mTree->GetColumns(getter_AddRefs(cols));
RefPtr<nsTreeColumns> cols = mTree->GetColumns();
if (cols) {
RefPtr<nsTreeColumn> col = cols->GetColumnFor(aElement);
mTree->InvalidateColumn(col);

Просмотреть файл

@ -466,8 +466,7 @@ NS_IMETHODIMP nsTreeSelection::InvertSelection() {
NS_IMETHODIMP nsTreeSelection::SelectAll() {
if (!mTree) return NS_OK;
nsCOMPtr<nsITreeView> view;
mTree->GetView(getter_AddRefs(view));
nsCOMPtr<nsITreeView> view = mTree->GetView();
if (!view) return NS_OK;
int32_t rowCount;