Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
DocumentViewerImpl Class Reference
Inheritance diagram for DocumentViewerImpl:
Inheritance graph
[legend]
Collaboration diagram for DocumentViewerImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DocumentViewerImpl (nsPresContext *aPresContext)
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTVIEWER
NS_DECL_NSICONTENTVIEWER_MOZILLA_1_8_BRANCH
NS_DECL_NSICONTENTVIEWER_MOZILLA_1_8_BRANCH2
NS_IMETHOD 
SetUAStyleSheet (nsIStyleSheet *aUAStyleSheet)
NS_IMETHOD GetDocument (nsIDocument **aResult)
NS_IMETHOD GetPresShell (nsIPresShell **aResult)
NS_IMETHOD GetPresContext (nsPresContext **aResult)
NS_IMETHOD CreateDocumentViewerUsing (nsPresContext *aPresContext, nsIDocumentViewer **aResult)
void CallChildren (CallChildFunc aFunc, void *aClosure)
void init (in nsIWidgetPtr aParentWidget, in nsIDeviceContextPtr aDeviceContext,[const ] in nsRectRef aBounds)
void loadStart (in nsISupports aDoc)
void loadComplete (in unsigned long aStatus)
boolean permitUnload ()
void pageHide (in boolean isUnload)
void close (in nsISHEntry historyEntry)
 All users of a content viewer are responsible for calling both close() and destroy(), in that order.
void destroy ()
void stop ()
void getBounds (in nsRectRef aBounds)
void setBounds ([const ] in nsRectRef aBounds)
void move (in long aX, in long aY)
void show ()
void hide ()
boolean requestWindowClose ()
void open (in nsISupports aState)
 Attach the content viewer to its DOM window and docshell.
void clearHistoryEntry ()
 Clears the current history entry.
void openWithEntry (in nsISupports aState, in nsISHEntry aSHEntry)
 Attach the content viewer to its DOM window and docshell.
void search ()
void clearSelection ()
void selectAll ()
void copySelection ()
void copyLinkLocation ()
void copyImage (in long aCopyFlags)
void cutSelection ()
void paste ()
AString getContents (in string aMimeType, in boolean aSelectionOnly)
void print (in boolean aSilent, in FILE aDebugFile, in nsIPrintSettings aPrintSettings)
void printWithParent (in nsIDOMWindowInternal aParentWin, in nsIPrintSettings aThePrintSettings, in nsIWebProgressListener aWPListener)
void scrollToNode (in nsIDOMNode node)
void sizeToContent ()
 Tell the container to shrink-to-fit or grow-to-fit its contents.
void print (in nsIPrintSettings aThePrintSettings, in nsIWebProgressListener aWPListener)
 Print the specified DOM window.
void printPreview (in nsIPrintSettings aThePrintSettings, in nsIDOMWindow aChildDOMWin, in nsIWebProgressListener aWPListener)
 Print Preview the specified DOM window.
void printPreviewNavigate (in short aNavType, in long aPageNum)
 Print Preview - Navigates within the window.
void cancel ()
 Cancels the current print.
void enumerateDocumentNames (out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult)
 Returns an array of the names of all documents names (Title or URL) and sub-documents.
void exitPrintPreview ()
 This exists PrintPreview mode and returns browser window to galley mode.
virtual void SetIsPrinting (PRBool aIsPrinting)=0
virtual PRBool GetIsPrinting ()=0
virtual void SetIsPrintPreview (PRBool aIsPrintPreview)=0
virtual PRBool GetIsPrintPreview ()=0
virtual PRBool GetIsCreatingPrintPreview ()=0
virtual nsresult CreateStyleSet (nsIDocument *aDocument, nsStyleSet **aStyleSet)=0
virtual nsresult GetDocumentSelection (nsISelection **aSelection, nsIPresShell *aPresShell=nsnull)=0
virtual void IncrementDestroyRefCount ()=0
virtual void ReturnToGalleyPresentation ()=0
virtual void InstallNewPresentation ()=0
virtual void OnDonePrinting ()=0

Public Attributes

NS_DECL_NSICONTENTVIEWEREDIT
NS_DECL_NSICONTENTVIEWERFILE
NS_DECL_NSIMARKUPDOCUMENTVIEWER
NS_DECL_NSIWEBBROWSERPRINT
typedef void(* 
CallChildFunc )(nsIMarkupDocumentViewer *aViewer, void *aClosure)
attribute nsISupports container
attribute nsIDOMDocument DOMDocument
attribute nsIContentViewer previousViewer
 The previous content viewer, which has been |close|d but not |destroy|ed.
attribute boolean enableRendering
attribute boolean sticky
readonly attribute nsISHEntry historyEntry
 Get the history entry that this viewer will save itself into when destroyed.
readonly attribute boolean searchable
readonly attribute boolean copyable
readonly attribute boolean inLink
const long COPY_IMAGE_TEXT = 0x0001
const long COPY_IMAGE_HTML = 0x0002
const long COPY_IMAGE_DATA = 0x0004
const long COPY_IMAGE_ALL = -1
readonly attribute boolean inImage
readonly attribute boolean cutable
readonly attribute boolean pasteable
readonly attribute boolean canGetContents
readonly attribute boolean printable
attribute float textZoom
 The amount by which to scale all text.
attribute boolean authorStyleDisabled
 Disable entire author style level (including HTML presentation hints)
attribute ACString defaultCharacterSet
attribute ACString forceCharacterSet
attribute ACString hintCharacterSet
attribute PRInt32 hintCharacterSetSource
attribute ACString prevDocCharacterSet
attribute octet bidiTextDirection
 Options for Bidi presentation.
attribute octet bidiTextType
 bidiTextType: the ordering of bidirectional text.
attribute octet bidiControlsTextMode
 bidiControlsTextMode: the order of bidirectional text in form controls.
attribute octet bidiNumeral
 bidiNumeral: the type of numerals to display.
attribute octet bidiSupport
 bidiSupport: whether to use platform bidi support or Mozilla's bidi support 1 - Use Mozilla's bidi support 2 - Use the platform bidi support 3 - Disable bidi support
attribute octet bidiCharacterSet
 bidiCharacterSet: whether to force the user's character set 1 - use the document character set 2 - use the character set chosen by the user
attribute PRUint32 bidiOptions
 Use this attribute to access all the Bidi options in one operation.
const short PRINTPREVIEW_GOTO_PAGENUM = 0
 PrintPreview Navigation Constants.
const short PRINTPREVIEW_PREV_PAGE = 1
const short PRINTPREVIEW_NEXT_PAGE = 2
const short PRINTPREVIEW_HOME = 3
const short PRINTPREVIEW_END = 4
readonly attribute nsIPrintSettings globalPrintSettings
 Returns a "global" PrintSettings object Creates a new the first time, if one doesn't exist.
readonly attribute nsIPrintSettings currentPrintSettings
 Returns a pointer to the PrintSettings object that that was passed into either "print" or "print preview".
readonly attribute nsIDOMWindow currentChildDOMWindow
 Returns a pointer to the current child DOMWindow that is being print previewed.
readonly attribute boolean doingPrint
 Returns whether it is in Print mode.
readonly attribute boolean doingPrintPreview
 Returns whether it is in Print Preview mode.
readonly attribute boolean isFramesetDocument
 This returns whether the current document is a frameset document.
readonly attribute boolean isFramesetFrameSelected
 This returns whether the current document is a frameset document.
readonly attribute boolean isIFrameSelected
 This returns whether there is an IFrame selected.
readonly attribute boolean isRangeSelection
 This returns whether there is a "range" selection.
readonly attribute long printPreviewNumPages
 This returns the total number of pages for the Print Preview.

Protected Member Functions

virtual ~DocumentViewerImpl ()

Protected Attributes

nsWeakPtr mContainer
nsCOMPtr< nsIDeviceContextmDeviceContext
nsCOMPtr< nsIDocumentmDocument
nsCOMPtr< nsIWidgetmWindow
nsCOMPtr< nsIViewManagermViewManager
nsCOMPtr< nsPresContextmPresContext
nsCOMPtr< nsIPresShellmPresShell
nsCOMPtr< nsIStyleSheetmUAStyleSheet
nsCOMPtr< nsISelectionListenermSelectionListener
nsCOMPtr< nsIDOMFocusListenermFocusListener
nsCOMPtr< nsIContentViewermPreviousViewer
nsCOMPtr< nsISHEntrymSHEntry
nsIWidgetmParentWidget
PRInt16 mNumURLStarts
PRInt16 mDestroyRefCount
unsigned mEnableRendering: 1
unsigned mStopped: 1
unsigned mLoaded: 1
unsigned mDeferredWindowClose: 1
unsigned mIsSticky: 1
unsigned mInPermitUnload: 1
PRInt32 mHintCharsetSource
nsCString mHintCharset
nsCString mDefaultCharacterSet
nsCString mForceCharacterSet
nsCString mPrevDocCharacterSet

Private Member Functions

nsresult MakeWindow (nsIWidget *aParentWidget, const nsRect &aBounds)
nsresult InitInternal (nsIWidget *aParentWidget, nsISupports *aState, nsIDeviceContext *aDeviceContext, const nsRect &aBounds, PRBool aDoCreation, PRBool aInPrintPreview)
nsresult InitPresentationStuff (PRBool aDoInitialReflow)
nsresult GetPopupNode (nsIDOMNode **aNode)
nsresult GetPopupLinkNode (nsIDOMNode **aNode)
nsresult GetPopupImageNode (nsIImageLoadingContent **aNode)
void DumpContentToPPM (const char *aFileName)
void PrepareToStartLoad (void)
nsresult SyncParentSubDocMap ()

Friends

class nsDocViewerSelectionListener
class nsPagePrintTimer
class nsPrintEngine

Detailed Description

Definition at line 301 of file nsDocumentViewer.cpp.


Constructor & Destructor Documentation

Definition at line 507 of file nsDocumentViewer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual DocumentViewerImpl::~DocumentViewerImpl ( ) [protected, virtual]

Member Function Documentation

Definition at line 2667 of file nsDocumentViewer.cpp.

{
  nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryReferent(mContainer));
  if (docShellNode)
  {
    PRInt32 i;
    PRInt32 n;
    docShellNode->GetChildCount(&n);
    for (i=0; i < n; i++)
    {
      nsCOMPtr<nsIDocShellTreeItem> child;
      docShellNode->GetChildAt(i, getter_AddRefs(child));
      nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
      NS_ASSERTION(childAsShell, "null child in docshell");
      if (childAsShell)
      {
        nsCOMPtr<nsIContentViewer> childCV;
        childAsShell->GetContentViewer(getter_AddRefs(childCV));
        if (childCV)
        {
          nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
          if (markupCV) {
            (*aFunc)(markupCV, aClosure);
          }
        }
      }
    }
  }
}

Here is the call graph for this function:

Cancels the current print.

Returns:
void

Clears the current history entry.

This is used if we need to clear out the saved presentation state.

void nsIContentViewer::close ( in nsISHEntry  historyEntry) [inherited]

All users of a content viewer are responsible for calling both close() and destroy(), in that order.

close() should be called when the load of a new page for the next content viewer begins, and destroy() should be called when the next content viewer replaces this one.

|historyEntry| sets the session history entry for the content viewer. If this is null, then Destroy() will be called on the document by close(). If it is non-null, the document will not be destroyed, and the following actions will happen when destroy() is called (*):

  • Sanitize() will be called on the viewer's document
  • The content viewer will set the contentViewer property on the history entry, and release its reference (ownership reversal).
  • hide() will be called, and no further destruction will happen.

(*) unless the document is currently being printed, in which case it will never be saved in session history.

Here is the caller graph for this function:

void nsIContentViewerEdit::copyImage ( in long  aCopyFlags) [inherited]

Implements nsIDocumentViewer.

Definition at line 2376 of file nsDocumentViewer.cpp.

{
  if (!mDocument) {
    // XXX better error
    return NS_ERROR_NULL_POINTER;
  }
  if (!aPresContext) {
    return NS_ERROR_NULL_POINTER;
  }

  // Create new viewer
  DocumentViewerImpl* viewer = new DocumentViewerImpl(aPresContext);
  if (!viewer) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  NS_ADDREF(viewer);

  // XXX make sure the ua style sheet is used (for now; need to be
  // able to specify an alternate)
  viewer->SetUAStyleSheet(mUAStyleSheet);

  // Bind the new viewer to the old document
  nsresult rv = viewer->LoadStart(mDocument);

  *aResult = viewer;

  return rv;
}

Here is the call graph for this function:

virtual nsresult nsIDocumentViewerPrint::CreateStyleSet ( nsIDocument aDocument,
nsStyleSet **  aStyleSet 
) [pure virtual, inherited]

Here is the caller graph for this function:

void DocumentViewerImpl::DumpContentToPPM ( const char *  aFileName) [private]

Definition at line 871 of file nsDocumentViewer.cpp.

{
  mDocument->FlushPendingNotifications(Flush_Display);

  nsIScrollableView* scrollableView;
  mViewManager->GetRootScrollableView(&scrollableView);
  nsIView* view;
  if (scrollableView) {
    scrollableView->GetScrolledView(view);
  } else {
    mViewManager->GetRootView(view);
  }
  nsRect r = view->GetBounds() - view->GetPosition();
  float p2t = mPresContext->PixelsToTwips();
  // Limit the bitmap size to 5000x5000
  nscoord twipLimit = NSIntPixelsToTwips(5000, p2t);
  if (r.height > twipLimit)
    r.height = twipLimit;
  if (r.width > twipLimit)
    r.width = twipLimit;

  const char* status;

  if (r.IsEmpty()) {
    status = "EMPTY";
  } else {
    nsCOMPtr<nsIRenderingContext> context;
    nsresult rv = mViewManager->RenderOffscreen(view, r,
                                                PR_FALSE, PR_TRUE,
                                                NS_RGB(255, 255, 255),
                                                getter_AddRefs(context));

    if (NS_FAILED(rv)) {
      status = "FAILEDRENDER";
    } else {
      nsIDrawingSurface* surface;
      context->GetDrawingSurface(&surface);
      if (!surface) {
        status = "NOSURFACE";
      } else {
        float t2p = mPresContext->TwipsToPixels();
        PRUint32 width = NSTwipsToIntPixels(view->GetBounds().width, t2p);
        PRUint32 height = NSTwipsToIntPixels(view->GetBounds().height, t2p);

        PRUint8* data;
        PRInt32 rowLen, rowSpan;
        rv = surface->Lock(0, 0, width, height, (void**)&data, &rowSpan, &rowLen,
                           NS_LOCK_SURFACE_READ_ONLY);
        if (NS_FAILED(rv)) {
          status = "FAILEDLOCK";
        } else {
          PRUint32 bytesPerPix = rowLen/width;
          nsPixelFormat format;
          surface->GetPixelFormat(&format);

          PRUint8* buf = new PRUint8[3*width];
          if (buf) {
            FILE* f = fopen(aFileName, "wb");
            if (f) {
              fprintf(f, "P6\n%d\n%d\n255\n", width, height);
              for (PRUint32 i = 0; i < height; ++i) {
                PRUint8* src = data + i*rowSpan;
                PRUint8* dest = buf;
                for (PRUint32 j = 0; j < width; ++j) {
                  /* v is the pixel value */
#ifdef IS_BIG_ENDIAN
                  PRUint32 v = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
                  v >>= (32 - 8*bytesPerPix);
#else
                  PRUint32 v = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
#endif
                  dest[0] = ((v & format.mRedMask) >> format.mRedShift) << (8 - format.mRedCount);
                  dest[1] = ((v & format.mGreenMask) >> format.mGreenShift) << (8 - format.mGreenCount);
                  dest[2] = ((v & format.mBlueMask) >> format.mBlueShift) << (8 - format.mBlueCount);
                  src += bytesPerPix;
                  dest += 3;
                }
                fwrite(buf, 3, width, f);
              }
              fclose(f);
              status = "OK";
            }
            
            delete[] buf;
          }
          surface->Unlock();
        }
        context->DestroyDrawingSurface(surface);
      }
    }
  }

  nsIURI *uri = mDocument->GetDocumentURI();
  nsCAutoString spec;
  if (uri) {
    uri->GetAsciiSpec(spec);
  }
  printf("GECKO: PAINT FORCED AFTER ONLOAD: %s %s (%s)\n", spec.get(), aFileName, status);
  fflush(stdout);
}

Here is the call graph for this function:

void nsIWebBrowserPrint::enumerateDocumentNames ( out PRUint32  aCount,
[retval, array, size_is(aCount)] out wstring  aResult 
) [inherited]

Returns an array of the names of all documents names (Title or URL) and sub-documents.

This will return a single item if the attr "isFramesetDocument" is false and may return any number of items is "isFramesetDocument" is true

Parameters:
aCount- returns number of printers returned
aResult- returns array of names
Returns:
void

This exists PrintPreview mode and returns browser window to galley mode.

Returns:
void
void nsIContentViewer::getBounds ( in nsRectRef  aBounds) [inherited]
AString nsIContentViewerEdit::getContents ( in string  aMimeType,
in boolean  aSelectionOnly 
) [inherited]

Implements nsIDocumentViewer.

Definition at line 1726 of file nsDocumentViewer.cpp.

{
  NS_IF_ADDREF(*aResult = mDocument);

  return NS_OK;
}

Here is the caller graph for this function:

virtual nsresult nsIDocumentViewerPrint::GetDocumentSelection ( nsISelection **  aSelection,
nsIPresShell aPresShell = nsnull 
) [pure virtual, inherited]

Here is the caller graph for this function:

virtual PRBool nsIDocumentViewerPrint::GetIsCreatingPrintPreview ( ) [pure virtual, inherited]

Here is the caller graph for this function:

virtual PRBool nsIDocumentViewerPrint::GetIsPrinting ( ) [pure virtual, inherited]
virtual PRBool nsIDocumentViewerPrint::GetIsPrintPreview ( ) [pure virtual, inherited]

Here is the caller graph for this function:

Definition at line 3242 of file nsDocumentViewer.cpp.

{
  NS_ENSURE_ARG_POINTER(aNode);

  // you get null unless i say so
  *aNode = nsnull;

  // find popup node
  nsCOMPtr<nsIDOMNode> node;
  nsresult rv = GetPopupNode(getter_AddRefs(node));
  NS_ENSURE_SUCCESS(rv, rv);

  if (node)
    CallQueryInterface(node, aNode);

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 3188 of file nsDocumentViewer.cpp.

{
  NS_ENSURE_ARG_POINTER(aNode);

  // you get null unless i say so
  *aNode = nsnull;

  // find popup node
  nsCOMPtr<nsIDOMNode> node;
  nsresult rv = GetPopupNode(getter_AddRefs(node));
  NS_ENSURE_SUCCESS(rv, rv);

  // find out if we have a link in our ancestry
  while (node) {

    // are we an anchor?
    nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(node));
    nsCOMPtr<nsIDOMHTMLAreaElement> area;
    nsCOMPtr<nsIDOMHTMLLinkElement> link;
    nsAutoString xlinkType;
    if (!anchor) {
      // area?
      area = do_QueryInterface(node);
      if (!area) {
        // link?
        link = do_QueryInterface(node);
        if (!link) {
          // XLink?
          nsCOMPtr<nsIDOMElement> element(do_QueryInterface(node));
          if (element) {
            element->GetAttributeNS(NS_LITERAL_STRING("http://www.w3.org/1999/xlink"),NS_LITERAL_STRING("type"),xlinkType);
          }
        }
      }
    }
    if (anchor || area || link || xlinkType.EqualsLiteral("simple")) {
      *aNode = node;
      NS_IF_ADDREF(*aNode); // addref
      return NS_OK;
    }
    else {
      // if not, get our parent and keep trying...
      nsCOMPtr<nsIDOMNode> parentNode;
      node->GetParentNode(getter_AddRefs(parentNode));
      node = parentNode;
    }
  }

  // if we have no node, fail
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Definition at line 3159 of file nsDocumentViewer.cpp.

{
  NS_ENSURE_ARG_POINTER(aNode);

  nsresult rv;

  // get the document
  nsCOMPtr<nsIDocument> document;
  rv = GetDocument(getter_AddRefs(document));
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);


  // get the private dom window
  nsCOMPtr<nsPIDOMWindow> privateWin(do_QueryInterface(document->GetScriptGlobalObject(), &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  // get the focus controller
  nsIFocusController *focusController = privateWin->GetRootFocusController();
  NS_ENSURE_TRUE(focusController, NS_ERROR_FAILURE);

  // get the popup node
  focusController->GetPopupNode(aNode); // addref happens here

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIDocumentViewer.

Definition at line 1742 of file nsDocumentViewer.cpp.

{
  NS_IF_ADDREF(*aResult = mPresContext);

  return NS_OK;
}

Implements nsIDocumentViewer.

Definition at line 1734 of file nsDocumentViewer.cpp.

{
  NS_IF_ADDREF(*aResult = mPresShell);

  return NS_OK;
}

Here is the caller graph for this function:

void nsIContentViewer::hide ( ) [inherited]
virtual void nsIDocumentViewerPrint::IncrementDestroyRefCount ( ) [pure virtual, inherited]

Here is the caller graph for this function:

void nsIContentViewer::init ( in nsIWidgetPtr  aParentWidget,
in nsIDeviceContextPtr  aDeviceContext,
[const ] in nsRectRef  aBounds 
) [inherited]
nsresult DocumentViewerImpl::InitInternal ( nsIWidget aParentWidget,
nsISupports *  aState,
nsIDeviceContext aDeviceContext,
const nsRect aBounds,
PRBool  aDoCreation,
PRBool  aInPrintPreview 
) [private]

Definition at line 774 of file nsDocumentViewer.cpp.

{
  mParentWidget = aParentWidget; // not ref counted

  nsresult rv = NS_OK;
  NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);

  mDeviceContext = aDeviceContext;

#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
  // Clear PrintPreview Alternate Device
  if (mDeviceContext) {
    mDeviceContext->SetAltDevice(nsnull);
    mDeviceContext->SetCanonicalPixelScale(1.0);
  }
#endif

  PRBool makeCX = PR_FALSE;
  if (aDoCreation) {
    if (aParentWidget && !mPresContext) {
      // Create presentation context
      mPresContext = new nsPresContext(GetIsCreatingPrintPreview() ?
                                        nsPresContext::eContext_PrintPreview :
                                        nsPresContext::eContext_Galley);
      NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);

      nsresult rv = mPresContext->Init(aDeviceContext); 
      if (NS_FAILED(rv)) {
        mPresContext = nsnull;
        return rv;
      }

#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
      makeCX = !GetIsPrintPreview(); // needs to be true except when we are already in PP
#else
      makeCX = PR_TRUE;
#endif
    }

    if (mPresContext) {
      // Create the ViewManager and Root View...

      // We must do this before we tell the script global object about
      // this new document since doing that will cause us to re-enter
      // into nsSubDocumentFrame code through reflows caused by
      // FlushPendingNotifications() calls down the road...

      rv = MakeWindow(aParentWidget, aBounds);
      NS_ENSURE_SUCCESS(rv, rv);
      Hide();
    }
  }

  nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryReferent(mContainer));
  if (requestor) {
    if (mPresContext) {
      nsCOMPtr<nsILinkHandler> linkHandler;
      requestor->GetInterface(NS_GET_IID(nsILinkHandler),
                              getter_AddRefs(linkHandler));

      mPresContext->SetContainer(requestor);
      mPresContext->SetLinkHandler(linkHandler);
    }

    if (!aInPrintPreview) {
      // Set script-context-owner in the document

      nsCOMPtr<nsIScriptGlobalObject> global;
      requestor->GetInterface(NS_GET_IID(nsIScriptGlobalObject),
                              getter_AddRefs(global));

      if (global) {
        nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));

        if (domdoc) {
          global->SetNewDocument(domdoc, aState, PR_TRUE, PR_TRUE);
        }
      }
    }
  }

  if (aDoCreation && mPresContext) {
    // The ViewManager and Root View was created above (in
    // MakeWindow())...

    rv = InitPresentationStuff(!makeCX);
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 641 of file nsDocumentViewer.cpp.

{
  // Create the style set...
  nsStyleSet *styleSet;
  nsresult rv = CreateStyleSet(mDocument, &styleSet);
  NS_ENSURE_SUCCESS(rv, rv);

  // Now make the shell for the document
  rv = mDocument->CreateShell(mPresContext, mViewManager, styleSet,
                              getter_AddRefs(mPresShell));
  if (NS_FAILED(rv)) {
    delete styleSet;
    return rv;
  }

  // We're done creating the style set
  styleSet->EndUpdate();

  if (aDoInitialReflow) {
    // Since InitialReflow() will create frames for *all* items
    // that are currently in the document tree, we need to flush
    // any pending notifications to prevent the content sink from
    // duplicating layout frames for content it has added to the tree
    // but hasn't notified the document about. (Bug 154018)
    //
    // Note that we are flushing before we add mPresShell as an observer
    // to avoid bogus notifications.

    mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
  }

  mPresShell->BeginObservingDocument();

  // Initialize our view manager
  nsRect bounds;
  mWindow->GetBounds(bounds);

  float p2t;

  p2t = mPresContext->PixelsToTwips();

  nscoord width = NSIntPixelsToTwips(bounds.width, p2t);
  nscoord height = NSIntPixelsToTwips(bounds.height, p2t);

  mViewManager->DisableRefresh();
  mViewManager->SetWindowDimensions(width, height);

  // Setup default view manager background color

  // This may be overridden by the docshell with the background color
  // for the last document loaded into the docshell
  mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor());

  if (aDoInitialReflow) {
    nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
    if (htmlDoc) {
      nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
        do_QueryInterface(mDocument->GetRootContent());
      htmlDoc->SetIsFrameset(frameset != nsnull);
    }

    // Initial reflow
    mPresShell->InitialReflow(width, height);

    // Now trigger a refresh
    if (mEnableRendering) {
      mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
    }
  } else {
    // Store the visible area so it's available for other callers of
    // InitialReflow, like nsContentSink::StartLayout.
    mPresContext->SetVisibleArea(nsRect(0, 0, width, height));
  }

  // now register ourselves as a selection listener, so that we get
  // called when the selection changes in the window
  nsDocViewerSelectionListener *selectionListener =
    new nsDocViewerSelectionListener();
  NS_ENSURE_TRUE(selectionListener, NS_ERROR_OUT_OF_MEMORY);

  selectionListener->Init(this);

  // mSelectionListener is a owning reference
  mSelectionListener = selectionListener;

  nsCOMPtr<nsISelection> selection;
  rv = GetDocumentSelection(getter_AddRefs(selection));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
  rv = selPrivate->AddSelectionListener(mSelectionListener);
  if (NS_FAILED(rv))
    return rv;

  // Save old listener so we can unregister it
  nsCOMPtr<nsIDOMFocusListener> mOldFocusListener = mFocusListener;

  // focus listener
  //
  // now register ourselves as a focus listener, so that we get called
  // when the focus changes in the window
  nsDocViewerFocusListener *focusListener;
  NS_NEWXPCOM(focusListener, nsDocViewerFocusListener);
  NS_ENSURE_TRUE(focusListener, NS_ERROR_OUT_OF_MEMORY);

  focusListener->Init(this);

  // mFocusListener is a strong reference
  mFocusListener = focusListener;

  // get the DOM event receiver
  nsCOMPtr<nsIDOMEventReceiver> erP(do_QueryInterface(mDocument));
  NS_WARN_IF_FALSE(erP, "No event receiver in document!");

  if (erP) {
    rv = erP->AddEventListenerByIID(mFocusListener,
                                    NS_GET_IID(nsIDOMFocusListener));
    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register focus listener");
    if (mOldFocusListener) {
      rv = erP->RemoveEventListenerByIID(mOldFocusListener,
                                      NS_GET_IID(nsIDOMFocusListener));
      NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remove focus listener");
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void nsIDocumentViewerPrint::InstallNewPresentation ( ) [pure virtual, inherited]

Here is the caller graph for this function:

void nsIContentViewer::loadComplete ( in unsigned long  aStatus) [inherited]
void nsIContentViewer::loadStart ( in nsISupports  aDoc) [inherited]
nsresult DocumentViewerImpl::MakeWindow ( nsIWidget aParentWidget,
const nsRect aBounds 
) [private]

Definition at line 2258 of file nsDocumentViewer.cpp.

{
  nsresult rv;

  mViewManager = do_CreateInstance(kViewManagerCID, &rv);
  if (NS_FAILED(rv))
    return rv;

  nsIDeviceContext *dx = mPresContext->DeviceContext();

  nsRect tbounds = aBounds;
  float p2t;
  p2t = mPresContext->PixelsToTwips();
  tbounds *= p2t;

   // Initialize the view manager with an offset. This allows the viewmanager
   // to manage a coordinate space offset from (0,0)
  rv = mViewManager->Init(dx);
  if (NS_FAILED(rv))
    return rv;

  // Reset the bounds offset so the root view is set to 0,0. The
  // offset is specified in nsIViewManager::Init above.
  // Besides, layout will reset the root view to (0,0) during reflow,
  // so changing it to 0,0 eliminates placing the root view in the
  // wrong place initially.
  tbounds.x = 0;
  tbounds.y = 0;

  // Create a child window of the parent that is our "root view/window"
  // if aParentWidget has a view, we'll hook our view manager up to its view tree
  nsIView* containerView = nsView::GetViewFor(aParentWidget);

  if (containerView) {
    // see if the containerView has already been hooked into a foreign view manager hierarchy
    // if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
    nsIViewManager* containerVM = containerView->GetViewManager();
    nsIView* pView = containerView;
    do {
      pView = pView->GetParent();
    } while (pView && pView->GetViewManager() == containerVM);

    if (!pView) {
      // OK, so the container is not already hooked up into a foreign view manager hierarchy.
      // That means we can choose not to hook ourselves up.
      //
      // If the parent container is a chrome shell then we won't hook into its view
      // tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)
      // but is really just for peace of mind. This check can be removed if we want to support fancy
      // chrome effects like transparent controls floating over content, transparent Web browsers, and
      // things like that, and the perf bugs are fixed.
      nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
      nsCOMPtr<nsIDocShellTreeItem> parentContainer;
      PRInt32 itemType;
      if (nsnull == container
          || NS_FAILED(container->GetParent(getter_AddRefs(parentContainer)))
          || nsnull == parentContainer
          || NS_FAILED(parentContainer->GetItemType(&itemType))
          || itemType != nsIDocShellTreeItem::typeContent) {
        containerView = nsnull;
      }
    }
  }

  // Create a view
  nsIView* view = mViewManager->CreateView(tbounds, containerView);
  if (!view)
    return NS_ERROR_OUT_OF_MEMORY;

  // pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone.
  // otherwise the view will find its own parent widget and "do the right thing" to
  // establish a parent/child widget relationship
  rv = view->CreateWidget(kWidgetCID, nsnull,
                          containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET),
                          PR_TRUE, PR_FALSE);
  if (NS_FAILED(rv))
    return rv;

  // Setup hierarchical relationship in view manager
  mViewManager->SetRootView(view);

  mWindow = view->GetWidget();

  // This SetFocus is necessary so the Arrow Key and Page Key events
  // go to the scrolled view as soon as the Window is created instead of going to
  // the browser window (this enables keyboard scrolling of the document)
  // mWindow->SetFocus();

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIContentViewer::move ( in long  aX,
in long  aY 
) [inherited]
virtual void nsIDocumentViewerPrint::OnDonePrinting ( ) [pure virtual, inherited]

Here is the caller graph for this function:

void nsIContentViewer::open ( in nsISupports  aState) [inherited]

Attach the content viewer to its DOM window and docshell.

Parameters:
aStateA state object that might be useful in attaching the DOM window.
void nsIContentViewer_MOZILLA_1_8_BRANCH::openWithEntry ( in nsISupports  aState,
in nsISHEntry  aSHEntry 
) [inherited]

Attach the content viewer to its DOM window and docshell.

Parameters:
aStateA state object that might be useful in attaching the DOM window.
aSHEntryThe history entry that the content viewer was stored in. The entry must have the docshells for all of the child documents stored in its child shell list.
void nsIContentViewer::pageHide ( in boolean  isUnload) [inherited]

Definition at line 477 of file nsDocumentViewer.cpp.

{
  mEnableRendering  = PR_TRUE;
  mStopped          = PR_FALSE;
  mLoaded           = PR_FALSE;
  mDeferredWindowClose = PR_FALSE;

#ifdef NS_PRINTING
  mPrintIsPending        = PR_FALSE;
  mPrintDocIsFullyLoaded = PR_FALSE;
  mClosingWhilePrinting  = PR_FALSE;

  // Make sure we have destroyed it and cleared the data member
  if (mPrintEngine) {
    mPrintEngine->Destroy();
    NS_RELEASE(mPrintEngine);
  }

#ifdef NS_PRINT_PREVIEW
  SetIsPrintPreview(PR_FALSE);
#endif

#ifdef NS_DEBUG
  mDebugFile = nsnull;
#endif

#endif // NS_PRINTING
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIContentViewerFile::print ( in boolean  aSilent,
in FILE  aDebugFile,
in nsIPrintSettings  aPrintSettings 
) [inherited]
void nsIWebBrowserPrint::print ( in nsIPrintSettings  aThePrintSettings,
in nsIWebProgressListener  aWPListener 
) [inherited]

Print the specified DOM window.

Parameters:
aThePrintSettings- Printer Settings for the print job, if aThePrintSettings is null then the global PS will be used.
aWPListener- is updated during the print
Returns:
void
void nsIWebBrowserPrint::printPreview ( in nsIPrintSettings  aThePrintSettings,
in nsIDOMWindow  aChildDOMWin,
in nsIWebProgressListener  aWPListener 
) [inherited]

Print Preview the specified DOM window.

Parameters:
aThePrintSettings- Printer Settings for the print preview, if aThePrintSettings is null then the global PS will be used.
aChildDOMWin- DOM Window of the child document to be PP (FrameSet frames)
aWPListener- is updated during the printpreview
Returns:
void
void nsIWebBrowserPrint::printPreviewNavigate ( in short  aNavType,
in long  aPageNum 
) [inherited]

Print Preview - Navigates within the window.

Parameters:
aNavType- navigation enum
aPageNum- page num to navigate to when aNavType = ePrintPreviewGoToPageNum
Returns:
void
void nsIContentViewerFile::printWithParent ( in nsIDOMWindowInternal  aParentWin,
in nsIPrintSettings  aThePrintSettings,
in nsIWebProgressListener  aWPListener 
) [inherited]
virtual void nsIDocumentViewerPrint::ReturnToGalleyPresentation ( ) [pure virtual, inherited]
void nsIContentViewer::setBounds ( [const ] in nsRectRef  aBounds) [inherited]
virtual void nsIDocumentViewerPrint::SetIsPrinting ( PRBool  aIsPrinting) [pure virtual, inherited]

Here is the caller graph for this function:

virtual void nsIDocumentViewerPrint::SetIsPrintPreview ( PRBool  aIsPrintPreview) [pure virtual, inherited]

Here is the caller graph for this function:

Implements nsIDocumentViewer.

Definition at line 1713 of file nsDocumentViewer.cpp.

{
  NS_ASSERTION(aUAStyleSheet, "unexpected null pointer");
  nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(aUAStyleSheet));
  if (sheet) {
    nsCOMPtr<nsICSSStyleSheet> newSheet;
    sheet->Clone(nsnull, nsnull, nsnull, nsnull, getter_AddRefs(newSheet));
    mUAStyleSheet = newSheet;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIContentViewer::show ( ) [inherited]

Tell the container to shrink-to-fit or grow-to-fit its contents.

void nsIContentViewer::stop ( ) [inherited]

Definition at line 575 of file nsDocumentViewer.cpp.

{
  nsCOMPtr<nsIDocShellTreeItem> item(do_QueryReferent(mContainer));
  nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(item));
  nsCOMPtr<nsIContent> content;

  if (mDocument && pwin) {
    content = do_QueryInterface(pwin->GetFrameElementInternal());
  }

  if (content) {
    nsCOMPtr<nsIDocShellTreeItem> parent;
    item->GetParent(getter_AddRefs(parent));

    nsCOMPtr<nsIDOMWindow> parent_win(do_GetInterface(parent));

    if (parent_win) {
      nsCOMPtr<nsIDOMDocument> dom_doc;
      parent_win->GetDocument(getter_AddRefs(dom_doc));

      nsCOMPtr<nsIDocument> parent_doc(do_QueryInterface(dom_doc));

      if (parent_doc) {
        return parent_doc->SetSubDocumentFor(content, mDocument);
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class nsDocViewerSelectionListener [friend]

Definition at line 310 of file nsDocumentViewer.cpp.

friend class nsPagePrintTimer [friend]

Definition at line 311 of file nsDocumentViewer.cpp.

friend class nsPrintEngine [friend]

Definition at line 312 of file nsDocumentViewer.cpp.


Member Data Documentation

Disable entire author style level (including HTML presentation hints)

Definition at line 68 of file nsIMarkupDocumentViewer.idl.

bidiCharacterSet: whether to force the user's character set 1 - use the document character set 2 - use the character set chosen by the user

Definition at line 155 of file nsIMarkupDocumentViewer.idl.

bidiControlsTextMode: the order of bidirectional text in form controls.

1 - logical 2 - visual 3 - like the containing document

Definition at line 131 of file nsIMarkupDocumentViewer.idl.

bidiNumeral: the type of numerals to display.

1 - depending on context, default is Arabic numerals 2 - depending on context, default is Hindi numerals 3 - Arabic numerals 4 - Hindi numerals

Definition at line 140 of file nsIMarkupDocumentViewer.idl.

Use this attribute to access all the Bidi options in one operation.

Definition at line 160 of file nsIMarkupDocumentViewer.idl.

bidiSupport: whether to use platform bidi support or Mozilla's bidi support 1 - Use Mozilla's bidi support 2 - Use the platform bidi support 3 - Disable bidi support

Definition at line 148 of file nsIMarkupDocumentViewer.idl.

Options for Bidi presentation.

Use these attributes to access the individual Bidi options. bidiTextDirection: the default direction for the layout of bidirectional text. 1 - left to right 2 - right to left

Definition at line 113 of file nsIMarkupDocumentViewer.idl.

bidiTextType: the ordering of bidirectional text.

This may be either "logical" or "visual". Logical text will be reordered for presentation using the Unicode Bidi Algorithm. Visual text will be displayed without reordering. 1 - the default order for the charset 2 - logical order 3 - visual order

Definition at line 123 of file nsIMarkupDocumentViewer.idl.

NS_DECL_NSICONTENTVIEWEREDIT NS_DECL_NSICONTENTVIEWERFILE NS_DECL_NSIMARKUPDOCUMENTVIEWER NS_DECL_NSIWEBBROWSERPRINT typedef void(* DocumentViewerImpl::CallChildFunc)(nsIMarkupDocumentViewer *aViewer, void *aClosure)

Definition at line 347 of file nsDocumentViewer.cpp.

Definition at line 72 of file nsIContentViewerEdit.idl.

attribute nsISupports nsIContentViewer::container [inherited]

Definition at line 25 of file nsIContentViewer.idl.

Definition at line 61 of file nsIContentViewerEdit.idl.

Definition at line 60 of file nsIContentViewerEdit.idl.

Definition at line 59 of file nsIContentViewerEdit.idl.

Definition at line 58 of file nsIContentViewerEdit.idl.

Definition at line 53 of file nsIContentViewerEdit.idl.

Returns a pointer to the current child DOMWindow that is being print previewed.

(FrameSet Frames)

Returns null if parent document is not a frameset or the entire FrameSet document is being print previewed

This enables any consumers of the interface to have access to the "current" child DOMWindow at later points in the execution

Definition at line 94 of file nsIWebBrowserPrint.idl.

Returns a pointer to the PrintSettings object that that was passed into either "print" or "print preview".

This enables any consumers of the interface to have access to the "current" PrintSetting at later points in the execution

Definition at line 82 of file nsIWebBrowserPrint.idl.

Definition at line 66 of file nsIContentViewerEdit.idl.

Definition at line 73 of file nsIMarkupDocumentViewer.idl.

Returns whether it is in Print mode.

Definition at line 99 of file nsIWebBrowserPrint.idl.

Returns whether it is in Print Preview mode.

Definition at line 104 of file nsIWebBrowserPrint.idl.

Definition at line 58 of file nsIContentViewer.idl.

Definition at line 74 of file nsIContentViewer.idl.

Definition at line 78 of file nsIMarkupDocumentViewer.idl.

Returns a "global" PrintSettings object Creates a new the first time, if one doesn't exist.

Then returns the same object each time after that.

Initializes the globalPrintSettings from the default printer

Definition at line 73 of file nsIWebBrowserPrint.idl.

Definition at line 83 of file nsIMarkupDocumentViewer.idl.

Definition at line 88 of file nsIMarkupDocumentViewer.idl.

Get the history entry that this viewer will save itself into when destroyed.

Can return null

Definition at line 122 of file nsIContentViewer.idl.

Definition at line 63 of file nsIContentViewerEdit.idl.

Definition at line 56 of file nsIContentViewerEdit.idl.

This returns whether the current document is a frameset document.

Definition at line 109 of file nsIWebBrowserPrint.idl.

This returns whether the current document is a frameset document.

Definition at line 114 of file nsIWebBrowserPrint.idl.

This returns whether there is an IFrame selected.

Definition at line 119 of file nsIWebBrowserPrint.idl.

This returns whether there is a "range" selection.

Definition at line 124 of file nsIWebBrowserPrint.idl.

Definition at line 393 of file nsDocumentViewer.cpp.

Definition at line 449 of file nsDocumentViewer.cpp.

Definition at line 420 of file nsDocumentViewer.cpp.

Definition at line 415 of file nsDocumentViewer.cpp.

Definition at line 394 of file nsDocumentViewer.cpp.

Definition at line 398 of file nsDocumentViewer.cpp.

Definition at line 417 of file nsDocumentViewer.cpp.

Definition at line 407 of file nsDocumentViewer.cpp.

Definition at line 450 of file nsDocumentViewer.cpp.

Definition at line 448 of file nsDocumentViewer.cpp.

Definition at line 447 of file nsDocumentViewer.cpp.

Definition at line 425 of file nsDocumentViewer.cpp.

unsigned DocumentViewerImpl::mIsSticky [protected]

Definition at line 424 of file nsDocumentViewer.cpp.

unsigned DocumentViewerImpl::mLoaded [protected]

Definition at line 419 of file nsDocumentViewer.cpp.

Definition at line 414 of file nsDocumentViewer.cpp.

Definition at line 412 of file nsDocumentViewer.cpp.

Definition at line 401 of file nsDocumentViewer.cpp.

Definition at line 402 of file nsDocumentViewer.cpp.

Definition at line 451 of file nsDocumentViewer.cpp.

Definition at line 409 of file nsDocumentViewer.cpp.

Definition at line 406 of file nsDocumentViewer.cpp.

Definition at line 410 of file nsDocumentViewer.cpp.

unsigned DocumentViewerImpl::mStopped [protected]

Definition at line 418 of file nsDocumentViewer.cpp.

Definition at line 404 of file nsDocumentViewer.cpp.

Definition at line 400 of file nsDocumentViewer.cpp.

Definition at line 399 of file nsDocumentViewer.cpp.

Definition at line 69 of file nsIContentViewerEdit.idl.

Definition at line 93 of file nsIMarkupDocumentViewer.idl.

The previous content viewer, which has been |close|d but not |destroy|ed.

Definition at line 67 of file nsIContentViewer.idl.

Definition at line 60 of file nsIContentViewerFile.idl.

Definition at line 63 of file nsIWebBrowserPrint.idl.

PrintPreview Navigation Constants.

Definition at line 59 of file nsIWebBrowserPrint.idl.

Definition at line 62 of file nsIWebBrowserPrint.idl.

Definition at line 61 of file nsIWebBrowserPrint.idl.

Definition at line 60 of file nsIWebBrowserPrint.idl.

This returns the total number of pages for the Print Preview.

Definition at line 129 of file nsIWebBrowserPrint.idl.

Definition at line 47 of file nsIContentViewerEdit.idl.

Definition at line 76 of file nsIContentViewer.idl.

The amount by which to scale all text.

Default is 1.0.

Definition at line 65 of file nsIMarkupDocumentViewer.idl.


The documentation for this class was generated from the following file: