TreeBoxObject.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/dom/TreeBoxObject.h"
  6. #include "nsCOMPtr.h"
  7. #include "nsIDOMXULElement.h"
  8. #include "nsIScriptableRegion.h"
  9. #include "nsIXULTemplateBuilder.h"
  10. #include "nsTreeContentView.h"
  11. #include "nsITreeSelection.h"
  12. #include "ChildIterator.h"
  13. #include "nsContentUtils.h"
  14. #include "nsError.h"
  15. #include "nsTreeBodyFrame.h"
  16. #include "mozilla/dom/TreeBoxObjectBinding.h"
  17. #include "nsITreeColumns.h"
  18. #include "mozilla/dom/DOMRect.h"
  19. #include "mozilla/dom/BindingUtils.h"
  20. #include "mozilla/dom/Element.h"
  21. #include "mozilla/dom/ToJSValue.h"
  22. namespace mozilla {
  23. namespace dom {
  24. NS_IMPL_CYCLE_COLLECTION_INHERITED(TreeBoxObject, BoxObject,
  25. mView)
  26. NS_IMPL_ADDREF_INHERITED(TreeBoxObject, BoxObject)
  27. NS_IMPL_RELEASE_INHERITED(TreeBoxObject, BoxObject)
  28. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TreeBoxObject)
  29. NS_INTERFACE_MAP_ENTRY(nsITreeBoxObject)
  30. NS_INTERFACE_MAP_END_INHERITING(BoxObject)
  31. void
  32. TreeBoxObject::Clear()
  33. {
  34. ClearCachedValues();
  35. // Drop the view's ref to us.
  36. if (mView) {
  37. nsCOMPtr<nsITreeSelection> sel;
  38. mView->GetSelection(getter_AddRefs(sel));
  39. if (sel)
  40. sel->SetTree(nullptr);
  41. mView->SetTree(nullptr); // Break the circular ref between the view and us.
  42. }
  43. mView = nullptr;
  44. BoxObject::Clear();
  45. }
  46. TreeBoxObject::TreeBoxObject()
  47. : mTreeBody(nullptr)
  48. {
  49. }
  50. TreeBoxObject::~TreeBoxObject()
  51. {
  52. }
  53. static nsIContent* FindBodyElement(nsIContent* aParent)
  54. {
  55. mozilla::dom::FlattenedChildIterator iter(aParent);
  56. for (nsIContent* content = iter.GetNextChild(); content; content = iter.GetNextChild()) {
  57. mozilla::dom::NodeInfo *ni = content->NodeInfo();
  58. if (ni->Equals(nsGkAtoms::treechildren, kNameSpaceID_XUL)) {
  59. return content;
  60. } else if (ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)) {
  61. // There are nesting tree elements. Only the innermost should
  62. // find the treechilren.
  63. return nullptr;
  64. } else if (content->IsElement() &&
  65. !ni->Equals(nsGkAtoms::_template, kNameSpaceID_XUL)) {
  66. nsIContent* result = FindBodyElement(content);
  67. if (result)
  68. return result;
  69. }
  70. }
  71. return nullptr;
  72. }
  73. nsTreeBodyFrame*
  74. TreeBoxObject::GetTreeBodyFrame(bool aFlushLayout)
  75. {
  76. // Make sure our frames are up to date, and layout as needed. We
  77. // have to do this before checking for our cached mTreeBody, since
  78. // it might go away on style flush, and in any case if aFlushLayout
  79. // is true we need to make sure to flush no matter what.
  80. // XXXbz except that flushing style when we were not asked to flush
  81. // layout here breaks things. See bug 585123.
  82. nsIFrame* frame = nullptr;
  83. if (aFlushLayout) {
  84. frame = GetFrame(aFlushLayout);
  85. if (!frame)
  86. return nullptr;
  87. }
  88. if (mTreeBody) {
  89. // Have one cached already.
  90. return mTreeBody;
  91. }
  92. if (!aFlushLayout) {
  93. frame = GetFrame(aFlushLayout);
  94. if (!frame)
  95. return nullptr;
  96. }
  97. // Iterate over our content model children looking for the body.
  98. nsCOMPtr<nsIContent> content = FindBodyElement(frame->GetContent());
  99. if (!content)
  100. return nullptr;
  101. frame = content->GetPrimaryFrame();
  102. if (!frame)
  103. return nullptr;
  104. // Make sure that the treebodyframe has a pointer to |this|.
  105. nsTreeBodyFrame *treeBody = do_QueryFrame(frame);
  106. NS_ENSURE_TRUE(treeBody && treeBody->GetTreeBoxObject() == this, nullptr);
  107. mTreeBody = treeBody;
  108. return mTreeBody;
  109. }
  110. NS_IMETHODIMP
  111. TreeBoxObject::GetView(nsITreeView * *aView)
  112. {
  113. if (!mTreeBody) {
  114. if (!GetTreeBodyFrame()) {
  115. // Don't return an uninitialised view
  116. *aView = nullptr;
  117. return NS_OK;
  118. }
  119. if (mView)
  120. // Our new frame needs to initialise itself
  121. return mTreeBody->GetView(aView);
  122. }
  123. if (!mView) {
  124. nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(mContent);
  125. if (xulele) {
  126. // See if there is a XUL tree builder associated with the element
  127. nsCOMPtr<nsIXULTemplateBuilder> builder;
  128. xulele->GetBuilder(getter_AddRefs(builder));
  129. mView = do_QueryInterface(builder);
  130. if (!mView) {
  131. // No tree builder, create a tree content view.
  132. nsresult rv = NS_NewTreeContentView(getter_AddRefs(mView));
  133. NS_ENSURE_SUCCESS(rv, rv);
  134. }
  135. // Initialise the frame and view
  136. mTreeBody->SetView(mView);
  137. }
  138. }
  139. NS_IF_ADDREF(*aView = mView);
  140. return NS_OK;
  141. }
  142. already_AddRefed<nsITreeView>
  143. TreeBoxObject::GetView() {
  144. nsCOMPtr<nsITreeView> view;
  145. GetView(getter_AddRefs(view));
  146. return view.forget();
  147. }
  148. static bool
  149. CanTrustView(nsISupports* aValue)
  150. {
  151. // Untrusted content is only allowed to specify known-good views
  152. if (nsContentUtils::IsCallerChrome())
  153. return true;
  154. nsCOMPtr<nsINativeTreeView> nativeTreeView = do_QueryInterface(aValue);
  155. if (!nativeTreeView || NS_FAILED(nativeTreeView->EnsureNative())) {
  156. // XXX ERRMSG need a good error here for developers
  157. return false;
  158. }
  159. return true;
  160. }
  161. NS_IMETHODIMP TreeBoxObject::SetView(nsITreeView * aView)
  162. {
  163. if (!CanTrustView(aView))
  164. return NS_ERROR_DOM_SECURITY_ERR;
  165. mView = aView;
  166. nsTreeBodyFrame* body = GetTreeBodyFrame();
  167. if (body)
  168. body->SetView(aView);
  169. return NS_OK;
  170. }
  171. void TreeBoxObject::SetView(nsITreeView* aView, ErrorResult& aRv)
  172. {
  173. aRv = SetView(aView);
  174. }
  175. bool TreeBoxObject::Focused()
  176. {
  177. nsTreeBodyFrame* body = GetTreeBodyFrame();
  178. if (body)
  179. return body->GetFocused();
  180. return false;
  181. }
  182. NS_IMETHODIMP TreeBoxObject::GetFocused(bool* aFocused)
  183. {
  184. *aFocused = Focused();
  185. return NS_OK;
  186. }
  187. NS_IMETHODIMP TreeBoxObject::SetFocused(bool aFocused)
  188. {
  189. nsTreeBodyFrame* body = GetTreeBodyFrame();
  190. if (body)
  191. return body->SetFocused(aFocused);
  192. return NS_OK;
  193. }
  194. NS_IMETHODIMP TreeBoxObject::GetTreeBody(nsIDOMElement** aElement)
  195. {
  196. *aElement = nullptr;
  197. nsTreeBodyFrame* body = GetTreeBodyFrame();
  198. if (body)
  199. return body->GetTreeBody(aElement);
  200. return NS_OK;
  201. }
  202. already_AddRefed<Element>
  203. TreeBoxObject::GetTreeBody()
  204. {
  205. nsCOMPtr<nsIDOMElement> el;
  206. GetTreeBody(getter_AddRefs(el));
  207. nsCOMPtr<Element> ret(do_QueryInterface(el));
  208. return ret.forget();
  209. }
  210. already_AddRefed<nsTreeColumns>
  211. TreeBoxObject::GetColumns()
  212. {
  213. nsTreeBodyFrame* body = GetTreeBodyFrame();
  214. if (body)
  215. return body->Columns();
  216. return nullptr;
  217. }
  218. NS_IMETHODIMP TreeBoxObject::GetColumns(nsITreeColumns** aColumns)
  219. {
  220. *aColumns = GetColumns().take();
  221. return NS_OK;
  222. }
  223. int32_t TreeBoxObject::RowHeight()
  224. {
  225. nsTreeBodyFrame* body = GetTreeBodyFrame();
  226. if (body)
  227. return body->RowHeight();
  228. return 0;
  229. }
  230. int32_t TreeBoxObject::RowWidth()
  231. {
  232. nsTreeBodyFrame* body = GetTreeBodyFrame();
  233. if (body)
  234. return body->RowWidth();
  235. return 0;
  236. }
  237. NS_IMETHODIMP TreeBoxObject::GetRowHeight(int32_t* aRowHeight)
  238. {
  239. *aRowHeight = RowHeight();
  240. return NS_OK;
  241. }
  242. NS_IMETHODIMP TreeBoxObject::GetRowWidth(int32_t *aRowWidth)
  243. {
  244. *aRowWidth = RowWidth();
  245. return NS_OK;
  246. }
  247. int32_t TreeBoxObject::GetFirstVisibleRow()
  248. {
  249. nsTreeBodyFrame* body = GetTreeBodyFrame();
  250. if (body)
  251. return body->FirstVisibleRow();
  252. return 0;
  253. }
  254. NS_IMETHODIMP TreeBoxObject::GetFirstVisibleRow(int32_t *aFirstVisibleRow)
  255. {
  256. *aFirstVisibleRow = GetFirstVisibleRow();
  257. return NS_OK;
  258. }
  259. int32_t TreeBoxObject::GetLastVisibleRow()
  260. {
  261. nsTreeBodyFrame* body = GetTreeBodyFrame();
  262. if (body)
  263. return body->LastVisibleRow();
  264. return 0;
  265. }
  266. NS_IMETHODIMP TreeBoxObject::GetLastVisibleRow(int32_t *aLastVisibleRow)
  267. {
  268. *aLastVisibleRow = GetLastVisibleRow();
  269. return NS_OK;
  270. }
  271. int32_t TreeBoxObject::HorizontalPosition()
  272. {
  273. nsTreeBodyFrame* body = GetTreeBodyFrame();
  274. if (body)
  275. return body->GetHorizontalPosition();
  276. return 0;
  277. }
  278. NS_IMETHODIMP TreeBoxObject::GetHorizontalPosition(int32_t *aHorizontalPosition)
  279. {
  280. *aHorizontalPosition = HorizontalPosition();
  281. return NS_OK;
  282. }
  283. int32_t TreeBoxObject::GetPageLength()
  284. {
  285. nsTreeBodyFrame* body = GetTreeBodyFrame();
  286. if (body)
  287. return body->PageLength();
  288. return 0;
  289. }
  290. NS_IMETHODIMP TreeBoxObject::GetPageLength(int32_t *aPageLength)
  291. {
  292. *aPageLength = GetPageLength();
  293. return NS_OK;
  294. }
  295. NS_IMETHODIMP TreeBoxObject::GetSelectionRegion(nsIScriptableRegion **aRegion)
  296. {
  297. *aRegion = nullptr;
  298. nsTreeBodyFrame* body = GetTreeBodyFrame();
  299. if (body)
  300. return body->GetSelectionRegion(aRegion);
  301. return NS_OK;
  302. }
  303. already_AddRefed<nsIScriptableRegion>
  304. TreeBoxObject::SelectionRegion()
  305. {
  306. nsCOMPtr<nsIScriptableRegion> region;
  307. GetSelectionRegion(getter_AddRefs(region));
  308. return region.forget();
  309. }
  310. NS_IMETHODIMP
  311. TreeBoxObject::EnsureRowIsVisible(int32_t aRow)
  312. {
  313. nsTreeBodyFrame* body = GetTreeBodyFrame();
  314. if (body)
  315. return body->EnsureRowIsVisible(aRow);
  316. return NS_OK;
  317. }
  318. NS_IMETHODIMP
  319. TreeBoxObject::EnsureCellIsVisible(int32_t aRow, nsITreeColumn* aCol)
  320. {
  321. nsTreeBodyFrame* body = GetTreeBodyFrame();
  322. if (body)
  323. return body->EnsureCellIsVisible(aRow, aCol);
  324. return NS_OK;
  325. }
  326. NS_IMETHODIMP
  327. TreeBoxObject::ScrollToRow(int32_t aRow)
  328. {
  329. nsTreeBodyFrame* body = GetTreeBodyFrame(true);
  330. if (body)
  331. return body->ScrollToRow(aRow);
  332. return NS_OK;
  333. }
  334. NS_IMETHODIMP
  335. TreeBoxObject::ScrollByLines(int32_t aNumLines)
  336. {
  337. nsTreeBodyFrame* body = GetTreeBodyFrame();
  338. if (body)
  339. return body->ScrollByLines(aNumLines);
  340. return NS_OK;
  341. }
  342. NS_IMETHODIMP
  343. TreeBoxObject::ScrollByPages(int32_t aNumPages)
  344. {
  345. nsTreeBodyFrame* body = GetTreeBodyFrame();
  346. if (body)
  347. return body->ScrollByPages(aNumPages);
  348. return NS_OK;
  349. }
  350. NS_IMETHODIMP
  351. TreeBoxObject::ScrollToCell(int32_t aRow, nsITreeColumn* aCol)
  352. {
  353. nsTreeBodyFrame* body = GetTreeBodyFrame();
  354. if (body)
  355. return body->ScrollToCell(aRow, aCol);
  356. return NS_OK;
  357. }
  358. NS_IMETHODIMP
  359. TreeBoxObject::ScrollToColumn(nsITreeColumn* aCol)
  360. {
  361. nsTreeBodyFrame* body = GetTreeBodyFrame();
  362. if (body)
  363. return body->ScrollToColumn(aCol);
  364. return NS_OK;
  365. }
  366. NS_IMETHODIMP
  367. TreeBoxObject::ScrollToHorizontalPosition(int32_t aHorizontalPosition)
  368. {
  369. nsTreeBodyFrame* body = GetTreeBodyFrame();
  370. if (body)
  371. return body->ScrollToHorizontalPosition(aHorizontalPosition);
  372. return NS_OK;
  373. }
  374. NS_IMETHODIMP TreeBoxObject::Invalidate()
  375. {
  376. nsTreeBodyFrame* body = GetTreeBodyFrame();
  377. if (body)
  378. return body->Invalidate();
  379. return NS_OK;
  380. }
  381. NS_IMETHODIMP
  382. TreeBoxObject::InvalidateColumn(nsITreeColumn* aCol)
  383. {
  384. nsTreeBodyFrame* body = GetTreeBodyFrame();
  385. if (body)
  386. return body->InvalidateColumn(aCol);
  387. return NS_OK;
  388. }
  389. NS_IMETHODIMP
  390. TreeBoxObject::InvalidateRow(int32_t aIndex)
  391. {
  392. nsTreeBodyFrame* body = GetTreeBodyFrame();
  393. if (body)
  394. return body->InvalidateRow(aIndex);
  395. return NS_OK;
  396. }
  397. NS_IMETHODIMP
  398. TreeBoxObject::InvalidateCell(int32_t aRow, nsITreeColumn* aCol)
  399. {
  400. nsTreeBodyFrame* body = GetTreeBodyFrame();
  401. if (body)
  402. return body->InvalidateCell(aRow, aCol);
  403. return NS_OK;
  404. }
  405. NS_IMETHODIMP
  406. TreeBoxObject::InvalidateRange(int32_t aStart, int32_t aEnd)
  407. {
  408. nsTreeBodyFrame* body = GetTreeBodyFrame();
  409. if (body)
  410. return body->InvalidateRange(aStart, aEnd);
  411. return NS_OK;
  412. }
  413. NS_IMETHODIMP
  414. TreeBoxObject::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn* aCol)
  415. {
  416. nsTreeBodyFrame* body = GetTreeBodyFrame();
  417. if (body)
  418. return body->InvalidateColumnRange(aStart, aEnd, aCol);
  419. return NS_OK;
  420. }
  421. NS_IMETHODIMP
  422. TreeBoxObject::GetRowAt(int32_t x, int32_t y, int32_t *aRow)
  423. {
  424. *aRow = 0;
  425. nsTreeBodyFrame* body = GetTreeBodyFrame();
  426. if (body)
  427. return body->GetRowAt(x, y, aRow);
  428. return NS_OK;
  429. }
  430. int32_t
  431. TreeBoxObject::GetRowAt(int32_t x, int32_t y)
  432. {
  433. int32_t row;
  434. GetRowAt(x, y, &row);
  435. return row;
  436. }
  437. NS_IMETHODIMP
  438. TreeBoxObject::GetCellAt(int32_t aX, int32_t aY, int32_t *aRow,
  439. nsITreeColumn** aCol, nsAString& aChildElt)
  440. {
  441. *aRow = 0;
  442. *aCol = nullptr;
  443. nsTreeBodyFrame* body = GetTreeBodyFrame();
  444. if (body) {
  445. nsAutoCString element;
  446. nsresult retval = body->GetCellAt(aX, aY, aRow, aCol, element);
  447. CopyUTF8toUTF16(element, aChildElt);
  448. return retval;
  449. }
  450. return NS_OK;
  451. }
  452. void
  453. TreeBoxObject::GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv)
  454. {
  455. nsCOMPtr<nsITreeColumn> col;
  456. GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(col), aRetVal.mChildElt);
  457. aRetVal.mCol = col.forget().downcast<nsTreeColumn>();
  458. }
  459. void
  460. TreeBoxObject::GetCellAt(JSContext* cx,
  461. int32_t x, int32_t y,
  462. JS::Handle<JSObject*> rowOut,
  463. JS::Handle<JSObject*> colOut,
  464. JS::Handle<JSObject*> childEltOut,
  465. ErrorResult& aRv)
  466. {
  467. int32_t row;
  468. nsITreeColumn* col;
  469. nsAutoString childElt;
  470. GetCellAt(x, y, &row, &col, childElt);
  471. JS::Rooted<JS::Value> v(cx);
  472. if (!ToJSValue(cx, row, &v) ||
  473. !JS_SetProperty(cx, rowOut, "value", v)) {
  474. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  475. return;
  476. }
  477. if (!dom::WrapObject(cx, col, &v) ||
  478. !JS_SetProperty(cx, colOut, "value", v)) {
  479. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  480. return;
  481. }
  482. if (!ToJSValue(cx, childElt, &v) ||
  483. !JS_SetProperty(cx, childEltOut, "value", v)) {
  484. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  485. return;
  486. }
  487. }
  488. NS_IMETHODIMP
  489. TreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsAString& aElement,
  490. int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight)
  491. {
  492. *aX = *aY = *aWidth = *aHeight = 0;
  493. nsTreeBodyFrame* body = GetTreeBodyFrame();
  494. NS_ConvertUTF16toUTF8 element(aElement);
  495. if (body)
  496. return body->GetCoordsForCellItem(aRow, aCol, element, aX, aY, aWidth, aHeight);
  497. return NS_OK;
  498. }
  499. already_AddRefed<DOMRect>
  500. TreeBoxObject::GetCoordsForCellItem(int32_t row, nsTreeColumn& col, const nsAString& element, ErrorResult& aRv)
  501. {
  502. int32_t x, y, w, h;
  503. GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h);
  504. RefPtr<DOMRect> rect = new DOMRect(mContent, x, y, w, h);
  505. return rect.forget();
  506. }
  507. void
  508. TreeBoxObject::GetCoordsForCellItem(JSContext* cx,
  509. int32_t row,
  510. nsTreeColumn& col,
  511. const nsAString& element,
  512. JS::Handle<JSObject*> xOut,
  513. JS::Handle<JSObject*> yOut,
  514. JS::Handle<JSObject*> widthOut,
  515. JS::Handle<JSObject*> heightOut,
  516. ErrorResult& aRv)
  517. {
  518. int32_t x, y, w, h;
  519. GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h);
  520. JS::Rooted<JS::Value> v(cx, JS::Int32Value(x));
  521. if (!JS_SetProperty(cx, xOut, "value", v)) {
  522. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  523. return;
  524. }
  525. v.setInt32(y);
  526. if (!JS_SetProperty(cx, yOut, "value", v)) {
  527. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  528. return;
  529. }
  530. v.setInt32(w);
  531. if (!JS_SetProperty(cx, widthOut, "value", v)) {
  532. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  533. return;
  534. }
  535. v.setInt32(h);
  536. if (!JS_SetProperty(cx, heightOut, "value", v)) {
  537. aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
  538. return;
  539. }
  540. }
  541. NS_IMETHODIMP
  542. TreeBoxObject::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *aIsCropped)
  543. {
  544. *aIsCropped = false;
  545. nsTreeBodyFrame* body = GetTreeBodyFrame();
  546. if (body)
  547. return body->IsCellCropped(aRow, aCol, aIsCropped);
  548. return NS_OK;
  549. }
  550. bool
  551. TreeBoxObject::IsCellCropped(int32_t row, nsITreeColumn* col, ErrorResult& aRv)
  552. {
  553. bool ret;
  554. aRv = IsCellCropped(row, col, &ret);
  555. return ret;
  556. }
  557. NS_IMETHODIMP
  558. TreeBoxObject::RowCountChanged(int32_t aIndex, int32_t aDelta)
  559. {
  560. nsTreeBodyFrame* body = GetTreeBodyFrame();
  561. if (body)
  562. return body->RowCountChanged(aIndex, aDelta);
  563. return NS_OK;
  564. }
  565. NS_IMETHODIMP
  566. TreeBoxObject::BeginUpdateBatch()
  567. {
  568. nsTreeBodyFrame* body = GetTreeBodyFrame();
  569. if (body)
  570. return body->BeginUpdateBatch();
  571. return NS_OK;
  572. }
  573. NS_IMETHODIMP
  574. TreeBoxObject::EndUpdateBatch()
  575. {
  576. nsTreeBodyFrame* body = GetTreeBodyFrame();
  577. if (body)
  578. return body->EndUpdateBatch();
  579. return NS_OK;
  580. }
  581. NS_IMETHODIMP
  582. TreeBoxObject::ClearStyleAndImageCaches()
  583. {
  584. nsTreeBodyFrame* body = GetTreeBodyFrame();
  585. if (body)
  586. return body->ClearStyleAndImageCaches();
  587. return NS_OK;
  588. }
  589. void
  590. TreeBoxObject::ClearCachedValues()
  591. {
  592. mTreeBody = nullptr;
  593. }
  594. JSObject*
  595. TreeBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
  596. {
  597. return TreeBoxObjectBinding::Wrap(aCx, this, aGivenProto);
  598. }
  599. } // namespace dom
  600. } // namespace mozilla
  601. // Creation Routine ///////////////////////////////////////////////////////////////////////
  602. using namespace mozilla::dom;
  603. nsresult
  604. NS_NewTreeBoxObject(nsIBoxObject** aResult)
  605. {
  606. NS_ADDREF(*aResult = new TreeBoxObject());
  607. return NS_OK;
  608. }