Commit b051b7aa authored by L. David Baron's avatar L. David Baron
Browse files

Expose DocumentViewerImpl::CallChildren with an API that fills an array. (Bug...

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
parent 87599f79
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -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"
%}

interface nsIMarkupDocumentViewer;

[scriptable, uuid(79286cd6-8293-4def-ba26-76422efc3d2a)]
[ref] native nsIMarkupDocumentViewerTArray(nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> >);

[scriptable, uuid(1016d5e8-690f-4d97-8ac5-d50ffa341c46)]
interface nsIMarkupDocumentViewer : nsISupports
{

@@ -150,4 +154,10 @@ interface nsIMarkupDocumentViewer : nsISupports
  /** 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);

};
+15 −0
Original line number Diff line number Diff line
@@ -3253,6 +3253,21 @@ NS_IMETHODIMP DocumentViewerImpl::GetBidiOptions(PRUint32* aBidiOptions)
  return NS_OK;
}

static void
AppendChildSubtree(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
  nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> >& array =
    *static_cast<nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> >*>(aClosure);
  aChild->AppendSubtree(array);
}

NS_IMETHODIMP DocumentViewerImpl::AppendSubtree(nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> >& aArray)
{
  aArray.AppendElement(this);
  CallChildren(AppendChildSubtree, &aArray);
  return NS_OK;
}

NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
{
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);