Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
mozXMLTermStream Class Reference

#include <mozXMLTermStream.h>

Inheritance diagram for mozXMLTermStream:
Inheritance graph
[legend]
Collaboration diagram for mozXMLTermStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mozXMLTermStream ()
virtual ~mozXMLTermStream ()
void open (in nsIDOMWindowInternal aDOMWindow, in string frameName, in string contentURL, in string contentType, in long maxResizeHeight)
 Open stream in specified frame, or in current frame if frameName is null.
void write (in wstring buf)
 Write Unicode string to stream (blocks until write is completed)
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Protected Member Functions

NS_IMETHOD SizeToContentHeight (PRInt32 maxHeight)
 Adjusts height of frame displaying stream to fit content.

Protected Attributes

nsCString mUTF8Buffer
 UTF8 data buffer to hold to be read by rendering engine.
PRUint32 mUTF8Offset
 offset at which to start reading the UTF8 data buffer
PRInt32 mMaxResizeHeight
 maximum frame height for resizing
nsCOMPtr< nsIDOMWindowInternalmDOMWindow
 DOM window in which to display stream.
nsCOMPtr< nsIDOMElementmDOMIFrameElement
 Frame element in which to display stream.
nsCOMPtr< nsISupports > mContext
 Context for stream display.
nsCOMPtr< nsILoadGroupmLoadGroup
 Load group for stream display.
nsCOMPtr< nsIChannelmChannel
 Channel for stream display.
nsCOMPtr< nsIStreamListenermStreamListener
 Stream listener object.

Detailed Description

Definition at line 71 of file mozXMLTermStream.h.


Constructor & Destructor Documentation

Definition at line 100 of file mozXMLTermStream.cpp.

{
}

Member Function Documentation

unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsIInputStream::close ( ) [inherited]

Close the stream.

Returns:
true if stream is non-blocking
void mozIXMLTermStream::open ( in nsIDOMWindowInternal  aDOMWindow,
in string  frameName,
in string  contentURL,
in string  contentType,
in long  maxResizeHeight 
) [inherited]

Open stream in specified frame, or in current frame if frameName is null.

Parameters:
aDOMWindowparent window
frameNamename of child frame in which to display stream, or null to display in parent window
contentURLURL of stream content
contentTypeMIME type of stream content
maxResizeHeightmaximum resize height (0=> do not resize)
unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).

Adjusts height of frame displaying stream to fit content.

Parameters:
maxHeightmaximum height of resized frame (pixels) (zero value implies no maximum)

Definition at line 364 of file mozXMLTermStream.cpp.

{
  nsresult result;

  // Get docshell
  nsCOMPtr<nsIDocShell> docShell;
  result = mozXMLTermUtils::ConvertDOMWindowToDocShell(mDOMWindow,
                                                   getter_AddRefs(docShell));
  if (NS_FAILED(result) || !docShell)
    return NS_ERROR_FAILURE;

  // Get pres context
  nsCOMPtr<nsPresContext> presContext;
  result = docShell->GetPresContext(getter_AddRefs(presContext));
  if (NS_FAILED(result) || !presContext)
    return NS_ERROR_FAILURE;

  // Get scrollable view
  nsIScrollableView* scrollableView;
  result = mozXMLTermUtils::GetPresContextScrollableView(presContext,
                                                         &scrollableView);
  if (NS_FAILED(result) || !scrollableView)
    return NS_ERROR_FAILURE;

  // Get device context
  nsCOMPtr<nsIDeviceContext> deviceContext;
  result = mozXMLTermUtils::GetPresContextDeviceContext(presContext,
                                              getter_AddRefs(deviceContext));
  if (NS_FAILED(result) || !deviceContext)
    return NS_ERROR_FAILURE;

  // Determine twips to pixels conversion factor
  float pixelScale;
  pixelScale = presContext->TwipsToPixels();

  // Get scrollbar dimensions in pixels
  float sbWidth, sbHeight;
  deviceContext->GetScrollBarDimensions(sbWidth, sbHeight);
  PRInt32 scrollBarWidth = PRInt32(sbWidth*pixelScale);
  PRInt32 scrollBarHeight = PRInt32(sbHeight*pixelScale);

  // Determine docshell size in pixels
  nsRect shellArea = presContext->GetVisibleArea();

  PRInt32 shellWidth = PRInt32((float)shellArea.width * pixelScale);
  PRInt32 shellHeight = PRInt32((float)shellArea.height * pixelScale);

  // Determine page size in pixels
  nscoord contX, contY;
  scrollableView->GetContainerSize(&contX, &contY);

  PRInt32 pageWidth, pageHeight;
  pageWidth = PRInt32((float)contX*pixelScale);
  pageHeight = PRInt32((float)contY*pixelScale);

  XMLT_WARNING("mozXMLTermStream::SizeToContentHeight: scrollbar %d, %d\n",
         scrollBarWidth, scrollBarHeight);

  XMLT_WARNING("mozXMLTermStream::SizeToContentHeight: presShell %d, %d\n",
         shellWidth, shellHeight);

  XMLT_WARNING("mozXMLTermStream::SizeToContentHeight: page %d, %d, %e\n",
         pageWidth, pageHeight, pixelScale);

  if ((pageHeight > shellHeight) || (pageWidth > shellWidth)) {
    // Page larger than docshell
    nsAutoString attHeight(NS_LITERAL_STRING("height"));
    nsAutoString attWidth(NS_LITERAL_STRING("width"));
    nsAutoString attValue; attValue.SetLength(0);

    PRInt32 newPageHeight = pageHeight;
    PRInt32 excessWidth = (pageWidth+scrollBarWidth - shellWidth);

    XMLT_WARNING("mozXMLTermStream::SizeToContentHeight: excessWidth %d\n",
           excessWidth);

    if (excessWidth > 0) {
      // Widen IFRAME beyond page width by scrollbar width
      attValue.SetLength(0);
      attValue.AppendInt(shellWidth+scrollBarWidth);
      mDOMIFrameElement->SetAttribute(attWidth,attValue);

      // Recompute page dimensions
      scrollableView->GetContainerSize(&contX, &contY);
      pageWidth = PRInt32((float)contX*pixelScale);
      pageHeight = PRInt32((float)contY*pixelScale);

      newPageHeight = pageHeight;
      if (excessWidth > scrollBarWidth)
        newPageHeight += scrollBarHeight;

      XMLT_WARNING("mozXMLTermStream::SizeToContentHeight: page2 %d, %d, %d\n",
             pageWidth, pageHeight, newPageHeight);

      // Reset IFRAME width
      attValue.SetLength(0);
      attValue.AppendInt(shellWidth);
      mDOMIFrameElement->SetAttribute(attWidth,attValue);
    }

    // Resize IFRAME height to match page height (subject to a maximum)
    if (newPageHeight > maxHeight) newPageHeight = maxHeight;
    attValue.SetLength(0);
    attValue.AppendInt(newPageHeight);
    mDOMIFrameElement->SetAttribute(attHeight,attValue);
  }

  return NS_OK;
}

Here is the call graph for this function:

void mozIXMLTermStream::write ( in wstring  buf) [inherited]

Write Unicode string to stream (blocks until write is completed)

Parameters:
bufstring to write

Member Data Documentation

Channel for stream display.

Definition at line 113 of file mozXMLTermStream.h.

nsCOMPtr<nsISupports> mozXMLTermStream::mContext [protected]

Context for stream display.

Definition at line 107 of file mozXMLTermStream.h.

Frame element in which to display stream.

Definition at line 103 of file mozXMLTermStream.h.

DOM window in which to display stream.

Definition at line 100 of file mozXMLTermStream.h.

Load group for stream display.

Definition at line 110 of file mozXMLTermStream.h.

maximum frame height for resizing

Definition at line 97 of file mozXMLTermStream.h.

Stream listener object.

Definition at line 116 of file mozXMLTermStream.h.

UTF8 data buffer to hold to be read by rendering engine.

Definition at line 91 of file mozXMLTermStream.h.

offset at which to start reading the UTF8 data buffer

Definition at line 94 of file mozXMLTermStream.h.


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