From f266722bf9ce38da25becbf714f3955a70e7c52c Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Sat, 5 May 2012 15:25:45 +0200 Subject: [PATCH] Expose DocumentViewerImpl::CallChildren with an API that fills an array. (Bug 747231, patch 3) r=roc --HG-- extra : transplant_source : %FFc%40%AE%D6%22%40%1D%7F%F7%A8%BC%1A%ECG%98G%DCFf --- docshell/base/nsIMarkupDocumentViewer.idl | 24 ++++++++++++++++------- layout/base/nsDocumentViewer.cpp | 15 ++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/docshell/base/nsIMarkupDocumentViewer.idl b/docshell/base/nsIMarkupDocumentViewer.idl index 292a30440db..a124491c21c 100644 --- a/docshell/base/nsIMarkupDocumentViewer.idl +++ b/docshell/base/nsIMarkupDocumentViewer.idl @@ -37,10 +37,6 @@ * * ***** END LICENSE BLOCK ***** */ -/** - * The nsIContentViewerEdit - */ - /** * The nsIMarkupDocumentViewer * This interface describes the properties of a content viewer @@ -51,8 +47,16 @@ interface nsIDOMNode; +%{C++ +#include "nsCOMPtr.h" +#include "nsTArray.h" +%} -[scriptable, uuid(79286cd6-8293-4def-ba26-76422efc3d2a)] +interface nsIMarkupDocumentViewer; + +[ref] native nsIMarkupDocumentViewerTArray(nsTArray >); + +[scriptable, uuid(1016d5e8-690f-4d97-8ac5-d50ffa341c46)] interface nsIMarkupDocumentViewer : nsISupports { @@ -147,7 +151,13 @@ interface nsIMarkupDocumentViewer : nsISupports */ attribute PRUint32 bidiOptions; - /** The minimum font size */ - attribute long minFontSize; + /** The minimum font size */ + attribute long minFontSize; + + /** + * Append |this| and all of its descendants to the given array, + * in depth-first pre-order traversal. + */ + [noscript] void appendSubtree(in nsIMarkupDocumentViewerTArray array); }; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index c1bfeba43ef..4d6326195a7 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -3253,6 +3253,21 @@ NS_IMETHODIMP DocumentViewerImpl::GetBidiOptions(PRUint32* aBidiOptions) return NS_OK; } +static void +AppendChildSubtree(nsIMarkupDocumentViewer* aChild, void* aClosure) +{ + nsTArray >& array = + *static_cast >*>(aClosure); + aChild->AppendSubtree(array); +} + +NS_IMETHODIMP DocumentViewerImpl::AppendSubtree(nsTArray >& aArray) +{ + aArray.AppendElement(this); + CallChildren(AppendChildSubtree, &aArray); + return NS_OK; +} + NS_IMETHODIMP DocumentViewerImpl::SizeToContent() { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);