Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends
nsObjectFrame Class Reference

#include <nsObjectFrame.h>

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

List of all members.

Public Member Functions

NS_IMETHOD QueryInterface (const nsIID &aIID, void **aInstancePtr)
NS_IMETHOD SetInitialChildList (nsPresContext *aPresContext, nsIAtom *aListName, nsIFrame *aChildList)
NS_IMETHOD Init (nsPresContext *aPresContext, nsIContent *aContent, nsIFrame *aParent, nsStyleContext *aContext, nsIFrame *aPrevInFlow)
NS_IMETHOD Reflow (nsPresContext *aPresContext, nsHTMLReflowMetrics &aDesiredSize, const nsHTMLReflowState &aReflowState, nsReflowStatus &aStatus)
NS_IMETHOD DidReflow (nsPresContext *aPresContext, const nsHTMLReflowState *aReflowState, nsDidReflowStatus aStatus)
NS_IMETHOD Paint (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect, nsFramePaintLayer aWhichLayer, PRUint32 aFlags=0)
NS_IMETHOD HandleEvent (nsPresContext *aPresContext, nsGUIEvent *aEvent, nsEventStatus *aEventStatus)
virtual nsIAtomGetType () const
virtual PRBool SupportsVisibilityHidden ()
virtual PRBool NeedsView ()
virtual nsresult CreateWidgetForView (nsIView *aView)
virtual PRBool IsLeaf () const
NS_IMETHOD Destroy (nsPresContext *aPresContext)
NS_IMETHOD GetPluginInstance (nsIPluginInstance *&aPluginInstance)
NS_IMETHOD GetCursor (const nsPoint &aPoint, nsIFrame::Cursor &aCursor)
nsresult MakeAbsoluteURL (nsIURI **aFullURI, nsString aSrc, nsIURI *aBaseURI)
nsresult CreateWidget (nscoord aWidth, nscoord aHeight, PRBool aViewOnly)
nsIURIGetFullURL ()
 NS_HIDDEN_ (nsresult) GetMIMEType(nsACString &aType)
 Get the MIME type used for rendering content for this frame.
void FixUpURLS (const nsString &name, nsAString &value)
void PluginNotAvailable (const char *aMimeType)
PRBool IsBroken () const
virtual PRBool IsContainingBlock () const

Static Public Member Functions

static nsIObjectFrameGetNextObjectFrame (nsPresContext *aPresContext, nsIFrame *aRoot)

Protected Member Functions

 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
virtual ~nsObjectFrame ()
virtual PRIntn GetSkipSides () const
void GetDesiredSize (nsPresContext *aPresContext, const nsHTMLReflowState &aReflowState, nsHTMLReflowMetrics &aDesiredSize)
nsresult InstantiateWidget (nsPresContext *aPresContext, nsHTMLReflowMetrics &aMetrics, const nsHTMLReflowState &aReflowState, nsCID aWidgetCID)
nsresult InstantiatePlugin (nsPresContext *aPresContext, nsHTMLReflowMetrics &aMetrics, const nsHTMLReflowState &aReflowState, nsIPluginHost *aPluginHost, const char *aMimetype, nsIURI *aURL)
nsresult ReinstantiatePlugin (nsPresContext *aPresContext, nsHTMLReflowMetrics &aMetrics, const nsHTMLReflowState &aReflowState)
nsresult HandleChild (nsPresContext *aPresContext, nsHTMLReflowMetrics &aMetrics, const nsHTMLReflowState &aReflowState, nsReflowStatus &aStatus, nsIFrame *child)
PRBool IsFocusable (PRInt32 *aTabIndex=nsnull, PRBool aWithMouse=PR_FALSE)
PRBool IsHidden (PRBool aCheckVisibilityStyle=PR_TRUE) const
void NotifyContentObjectWrapper ()
nsPoint GetWindowOriginInPixels (PRBool aWindowless)
void CreateDefaultFrames (nsPresContext *aPresContext, nsHTMLReflowMetrics &aMetrics, const nsHTMLReflowState &aReflowState)

Private Attributes

nsPluginInstanceOwnermInstanceOwner
nsCOMPtr< nsIURImFullURL
nsIFramemFirstChild
nsCOMPtr< nsIWidgetmWidget
nsRect mWindowlessRect
PRPackedBool mIsBrokenPlugin

Friends

class nsPluginInstanceOwner

Detailed Description

Definition at line 57 of file nsObjectFrame.h.


Constructor & Destructor Documentation

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

Definition at line 423 of file nsObjectFrame.cpp.

{
}

Member Function Documentation

void nsObjectFrame::CreateDefaultFrames ( nsPresContext aPresContext,
nsHTMLReflowMetrics aMetrics,
const nsHTMLReflowState aReflowState 
) [protected]

Definition at line 1532 of file nsObjectFrame.cpp.

{
  NS_ASSERTION(IsBroken(),
               "CreateDefaultFrames() called on non-broken plugin!");

  nsIFrame * child = mFrames.FirstChild();
  if (child) {
    NS_ERROR("Um, this should only be called once!");

    // We have a child already, don't do anything
    return;
  }

  // first, we need to get the document
  nsIDocument *doc = mContent->GetDocument();

  nsIPresShell *shell = aPresContext->GetPresShell();
  nsStyleSet *styleSet = shell->StyleSet();

  nsCOMPtr<nsIHTMLDocument> htmldoc(do_QueryInterface(doc));
  PRInt32 id;
  if (htmldoc && !doc->IsCaseSensitive())
    id = kNameSpaceID_None;
  else
    id = kNameSpaceID_XHTML;

  nsCOMPtr<nsIContent> anchor;
  nsresult rv = doc->CreateElem(nsHTMLAtoms::a, nsnull, id, htmldoc != nsnull,
                                getter_AddRefs(anchor));

  nsCOMPtr<nsIContent> img;
  rv |= doc->CreateElem(nsHTMLAtoms::img, nsnull, id, htmldoc != nsnull,
                        getter_AddRefs(img));

  nsCOMPtr<nsITextContent> text;
  rv |= NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());

  if (NS_FAILED(rv))
    return;

  // Mark the nodes anonymous
  anchor->SetNativeAnonymous(PR_TRUE);
  img->SetNativeAnonymous(PR_TRUE);
  text->SetNativeAnonymous(PR_TRUE);

  // Set up the anonymous tree.  Note that the binding parent for the anchor is
  // used to cut off style rules from the page so they won't apply to it.
  rv = anchor->BindToTree(doc, mContent, anchor, PR_TRUE);
  if (NS_FAILED(rv)) {
    anchor->UnbindFromTree();
    return;
  }

  anchor->AppendChildTo(img, PR_FALSE);
  anchor->AppendChildTo(text, PR_FALSE);

  nsAutoString style;
  CopyASCIItoUTF16("text-align: -moz-center;"
                   "overflow: -moz-hidden-unscrollable;"
                   "display: block;"
                   "border: 1px outset;"
                   "padding: 5px;"
                   "font-size: 12px;"
                   "font-family: sans-serif;"
                   "background: white;"
                   "-moz-user-select: none;"
                   "text-decoration: none;"
                   "color: black;", style);

  // Style things and load the image
  anchor->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style, style, PR_TRUE);
  anchor->SetAttr(kNameSpaceID_None, nsHTMLAtoms::href, NS_LITERAL_STRING("#"), PR_TRUE);

  NS_NAMED_LITERAL_STRING(src,
                          "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png");
  img->SetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src, PR_FALSE);
  NS_NAMED_LITERAL_STRING(imgStyle,
                          "display: block; border: 0px; width: 32px; height: 32px;");
  img->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style, imgStyle, PR_FALSE);

  // Kick off the image load.
  nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(img);
  imageLoader->ImageURIChanged(src);

  // get the localized text
  nsXPIDLString missingPluginLabel;

  nsCOMPtr<nsIStringBundleService> stringBundleService =
    do_GetService(NS_STRINGBUNDLE_CONTRACTID);

  if (stringBundleService) {
    nsCOMPtr<nsIStringBundle> stringBundle;
    stringBundleService->CreateBundle(
      "chrome://mozapps/locale/plugins/plugins.properties", 
      getter_AddRefs(stringBundle));

    if (stringBundle)
      rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("missingPlugin.label").get(), 
                                           getter_Copies(missingPluginLabel));
  }

  if (!stringBundleService || NS_FAILED(rv))
    missingPluginLabel = NS_LITERAL_STRING("Click here to download plugin.");

  text->SetText(missingPluginLabel, PR_FALSE);

  // Resolve style for the anchor, img, and text nodes.
  nsRefPtr<nsStyleContext> anchorStyleContext =
    styleSet->ResolveStyleFor(anchor, mStyleContext);
  nsRefPtr<nsStyleContext> imgStyleContext =
    styleSet->ResolveStyleFor(img, anchorStyleContext);
  nsRefPtr<nsStyleContext> textStyleContext =
    shell->StyleSet()->ResolveStyleForNonElement(anchorStyleContext);

  if (!anchorStyleContext || !imgStyleContext || !textStyleContext)
    return;

  nsIFrame *anchorFrame = nsnull;
  nsIFrame *imgFrame = nsnull;
  nsIFrame *textFrame = nsnull;

  do {
    rv = NS_NewBlockFrame(shell, &anchorFrame);
    if (NS_FAILED(rv))
      break;

    rv = anchorFrame->Init(aPresContext, anchor, this, anchorStyleContext, PR_FALSE);
    if (NS_FAILED(rv))
      break;

    // Give it a space manager, so it won't crash of ancestors don't have one
    anchorFrame->AddStateBits(NS_BLOCK_SPACE_MGR | NS_BLOCK_MARGIN_ROOT);
    
    nsHTMLContainerFrame::CreateViewForFrame(anchorFrame, this, PR_FALSE);

    rv = NS_NewImageFrame(shell, &imgFrame);
    if (NS_FAILED(rv))
      return;

    rv = imgFrame->Init(aPresContext, img, anchorFrame, imgStyleContext, PR_FALSE);
    if (NS_FAILED(rv))
      break;

    nsHTMLContainerFrame::CreateViewForFrame(imgFrame, anchorFrame, PR_FALSE);
    anchorFrame->AppendFrames(nsnull, imgFrame);

    rv = NS_NewTextFrame(shell, &textFrame);
    if (NS_FAILED(rv))
      break;

    rv = textFrame->Init(aPresContext, text, anchorFrame, textStyleContext,
                         PR_FALSE);
    if (NS_FAILED(rv))
      break;

    textFrame->SetInitialChildList(aPresContext, nsnull, nsnull);

    anchorFrame->AppendFrames(nsnull, textFrame);
  } while (0);

  if (NS_FAILED(rv)) {
    if (anchorFrame)
      anchorFrame->Destroy(aPresContext);

    if (imgFrame)
      imgFrame->Destroy(aPresContext);

    if (textFrame)
      textFrame->Destroy(aPresContext);
  } else {
    // Creation of all our anonymous content succeeded.
    mFrames.AppendFrame(this, anchorFrame);
  }

  nsCOMPtr<nsISupportsArray> array;
  NS_NewISupportsArray(getter_AddRefs(array));

  if (array) {
    array->AppendElement(anchor);
    array->AppendElement(img);
    array->AppendElement(text);

    shell->SetAnonymousContentFor(mContent, array);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsObjectFrame::CreateWidget ( nscoord  aWidth,
nscoord  aHeight,
PRBool  aViewOnly 
)

Definition at line 814 of file nsObjectFrame.cpp.

{
  nsIView* view = GetView();
  NS_ASSERTION(view, "Object frames must have views");  
  if (!view) {
    return NS_OK;       //XXX why OK? MMP
  }

  nsIViewManager* viewMan = view->GetViewManager();
  // make the view as hidden since we don't know the (x,y) until Paint
  // XXX is the above comment correct?
  viewMan->SetViewVisibility(view, nsViewVisibility_kHide);

  // Turn off double buffering on the Mac. This depends on bug 49743 and partially
  // fixes 32327, 19931 amd 51787
#if defined(XP_MAC) || defined(XP_MACOSX)
  PRBool doubleBuffer =
    nsContentUtils::GetBoolPref("plugin.enable_double_buffer");
  
  viewMan->AllowDoubleBuffering(doubleBuffer);
#endif
  
  //this is ugly. it was ripped off from didreflow(). MMP
  // Position and size view relative to its parent, not relative to our
  // parent frame (our parent frame may not have a view).
  
  nsIView* parentWithView;
  nsPoint origin;
  nsRect r(0, 0, mRect.width, mRect.height);

  GetOffsetFromView(origin, &parentWithView);
  viewMan->ResizeView(view, r);
  viewMan->MoveViewTo(view, origin.x, origin.y);

  if (!aViewOnly && !view->HasWidget()) {
    nsresult rv = CreateWidgetForView(view);
    if (NS_FAILED(rv)) {
      return NS_OK;       //XXX why OK? MMP
    }
  }

  {
    // Here we set the background color for this widget because some plugins will use 
    // the child window background color when painting. If it's not set, it may default to gray
    // Sometimes, a frame doesn't have a background color or is transparent. In this
    // case, walk up the frame tree until we do find a frame with a background color
    for (nsIFrame* frame = this; frame; frame = frame->GetParent()) {
      const nsStyleBackground* background = frame->GetStyleBackground();
      if (!background->IsTransparent()) {  // make sure we got an actual color
        nsIWidget* win = view->GetWidget();
        if (win)
          win->SetBackgroundColor(background->mBackgroundColor);
        break;
      }
    }

  }

  viewMan->SetViewVisibility(view, nsViewVisibility_kShow);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 795 of file nsObjectFrame.cpp.

{
  // Bug 179822: Create widget and allow non-unicode SubClass
  nsWidgetInitData initData;
  initData.mUnicode = PR_FALSE;
  return aView->CreateWidget(kWidgetCID, &initData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 709 of file nsObjectFrame.cpp.

{
  NS_ASSERTION(!mInstantiating, "about to crash due to bug 136927");

  // we need to finish with the plugin before native window is destroyed
  // doing this in the destructor is too late.
  if (mInstanceOwner != nsnull) {
    nsCOMPtr<nsIPluginInstance> inst;
    mInstanceOwner->GetInstance(*getter_AddRefs(inst));
    if (inst) {
      nsPluginWindow *win;
      mInstanceOwner->GetWindow(win);
      nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
      nsCOMPtr<nsIPluginInstance> nullinst;

      PRBool doCache = PR_TRUE;
      PRBool doCallSetWindowAfterDestroy = PR_FALSE;

      // first, determine if the plugin wants to be cached
      inst->GetValue(nsPluginInstanceVariable_DoCacheBool, 
                     (void *) &doCache);
      if (!doCache) {
        // then determine if the plugin wants Destroy to be called after
        // Set Window.  This is for bug 50547.
        inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool, 
                       (void *) &doCallSetWindowAfterDestroy);
        if (doCallSetWindowAfterDestroy) {
          inst->Stop();
          inst->Destroy();
          
          if (window) 
            window->CallSetWindow(nullinst);
          else 
            inst->SetWindow(nsnull);
        }
        else {
          if (window) 
            window->CallSetWindow(nullinst);
          else 
            inst->SetWindow(nsnull);

          inst->Stop();
          inst->Destroy();
        }
      }
      else {
        if (window) 
          window->CallSetWindow(nullinst);
        else 
          inst->SetWindow(nsnull);

        inst->Stop();
      }

      nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
      if (pluginHost)
        pluginHost->StopPluginInstance(inst);

      // the frame is going away along with its widget
      // so tell the window to forget its widget too
      if (window)
        window->SetPluginWidget(nsnull);
    }

    mInstanceOwner->Destroy();
    NS_RELEASE(mInstanceOwner);
  }
  
  return nsObjectFrameSuper::Destroy(aPresContext);
}

Here is the call graph for this function:

Definition at line 1721 of file nsObjectFrame.cpp.

{
  nsresult rv = nsObjectFrameSuper::DidReflow(aPresContext, aReflowState, aStatus);

  // The view is created hidden; once we have reflowed it and it has been
  // positioned then we show it.
  if (aStatus != NS_FRAME_REFLOW_FINISHED) 
    return rv;

  PRBool bHidden = IsHidden();

  if (HasView()) {
    nsIView* view = GetView();
    nsIViewManager* vm = view->GetViewManager();
    if (vm)
      vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
  }

  nsPluginWindow *win = nsnull;
 
  nsCOMPtr<nsIPluginInstance> pi; 
  if (!mInstanceOwner ||
      NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
      !pi ||
      NS_FAILED(rv = mInstanceOwner->GetWindow(win)) || 
      !win)
    return rv;

  nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;

#if defined(XP_MAC) || defined(XP_MACOSX) 
  mInstanceOwner->FixUpPluginWindow(ePluginPaintDisable);
#endif // XP_MAC || XP_MACOSX

  if (bHidden)
    return rv;

  PRBool windowless = (window->type == nsPluginWindowType_Drawable);
  if (windowless)
    return rv;

  nsPoint origin = GetWindowOriginInPixels(windowless);

  window->x = origin.x;
  window->y = origin.y;

  // refresh the plugin port as well
  window->window = mInstanceOwner->GetPluginPort();

  // this will call pi->SetWindow and take care of window subclassing
  // if needed, see bug 132759
  window->CallSetWindow(pi);

  mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);

  if (mWidget) {
    PRInt32 x = origin.x;
    PRInt32 y = origin.y;
    mWidget->Move(x, y);
  }

  return rv;
}

Here is the call graph for this function:

void nsObjectFrame::FixUpURLS ( const nsString name,
nsAString &  value 
)

Definition at line 3100 of file nsObjectFrame.cpp.

{
  if (name.LowerCaseEqualsLiteral("pluginurl") ||
      name.LowerCaseEqualsLiteral("pluginspage")) {        
    
    nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
    nsAutoString newURL;
    NS_MakeAbsoluteURI(newURL, value, baseURI);
    if (!newURL.IsEmpty())
      value = newURL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsObjectFrame::GetCursor ( const nsPoint aPoint,
nsIFrame::Cursor aCursor 
) [inline]

Definition at line 103 of file nsObjectFrame.h.

void nsObjectFrame::GetDesiredSize ( nsPresContext aPresContext,
const nsHTMLReflowState aReflowState,
nsHTMLReflowMetrics aDesiredSize 
) [protected]

Definition at line 883 of file nsObjectFrame.cpp.

{
  // By default, we have no area
  aMetrics.width = 0;
  aMetrics.height = 0;
  aMetrics.ascent = 0;
  aMetrics.descent = 0;

  if (IsHidden(PR_FALSE)) {
    if (aMetrics.mComputeMEW) {
      aMetrics.mMaxElementWidth = 0;
    }      
    return;
  }
  
  aMetrics.width = aReflowState.mComputedWidth;
  aMetrics.height = aReflowState.mComputedHeight;

  // for EMBED and APPLET, default to 240x200 for compatibility
  nsIAtom *atom = mContent->Tag();
  if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
    float p2t = aPresContext->ScaledPixelsToTwips();
    if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
      aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t),
                                     aReflowState.mComputedMinWidth),
                              aReflowState.mComputedMaxWidth);
    }
    if (aMetrics.height == NS_UNCONSTRAINEDSIZE) {
      aMetrics.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t),
                                      aReflowState.mComputedMinHeight),
                               aReflowState.mComputedMaxHeight);
    }

#if defined (MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2) || defined (MOZ_WIDGET_XLIB)  
    // We need to make sure that the size of the object frame does not
    // exceed the maximum size of X coordinates.  See bug #225357 for
    // more information.  In theory Gtk2 can handle large coordinates,
    // but underlying plugins can't.
    aMetrics.height = PR_MIN(NSIntPixelsToTwips(PR_INT16_MAX, p2t), aMetrics.height);
    aMetrics.width = PR_MIN(NSIntPixelsToTwips(PR_INT16_MAX, p2t), aMetrics.width);
#endif
  }

  // At this point, the width has an unconstrained value only if we have
  // nothing to go on (no width set, no information from the plugin, nothing).
  // Make up a number.
  if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
    aMetrics.width =
      (aReflowState.mComputedMinWidth != NS_UNCONSTRAINEDSIZE) ?
        aReflowState.mComputedMinWidth : 0;
  }

  // At this point, the height has an unconstrained value only in two cases:
  // a) We are in standards mode with percent heights and parent is auto-height
  // b) We have no height information at all.
  // In either case, we have to make up a number.
  if (aMetrics.height == NS_UNCONSTRAINEDSIZE) {
    aMetrics.height =
      (aReflowState.mComputedMinHeight != NS_UNCONSTRAINEDSIZE) ?
        aReflowState.mComputedMinHeight : 0;
  }

  // XXXbz don't add in the border and padding, because we screw up our
  // plugin's size and positioning if we do...  Eventually we _do_ want to
  // paint borders, though!  At that point, we will need to adjust the desired
  // size either here or in Reflow....  Further, we will need to fix Paint() to
  // call the superclass in all cases.
  
  // ascent
  aMetrics.ascent = aMetrics.height;

  if (aMetrics.mComputeMEW) {
    aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file nsObjectFrame.h.

  {
    return mFullURL;
  }

Here is the caller graph for this function:

nsIObjectFrame * nsObjectFrame::GetNextObjectFrame ( nsPresContext aPresContext,
nsIFrame aRoot 
) [static]

Definition at line 2180 of file nsObjectFrame.cpp.

{
  nsIFrame* child = aRoot->GetFirstChild(nsnull);

  while (child) {
    nsIObjectFrame* outFrame = nsnull;
    CallQueryInterface(child, &outFrame);
    if (outFrame) {
      nsCOMPtr<nsIPluginInstance> pi;
      outFrame->GetPluginInstance(*getter_AddRefs(pi));  // make sure we have a REAL plugin
      if (pi)
        return outFrame;
    }

    outFrame = GetNextObjectFrame(aPresContext, child);
    if (outFrame)
      return outFrame;
    child = child->GetNextSibling();
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsObjectFrame::GetPluginInstance ( nsIPluginInstance *&  aPluginInstance) [virtual]

Implements nsIObjectFrame.

Definition at line 2114 of file nsObjectFrame.cpp.

{
  aPluginInstance = nsnull;

  if (!mInstanceOwner)
    return NS_OK;
  
  return mInstanceOwner->GetInstance(aPluginInstance);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRIntn nsObjectFrame::GetSkipSides ( ) const [protected, virtual]

Definition at line 492 of file nsObjectFrame.cpp.

{
  return 0;
}
nsIAtom * nsObjectFrame::GetType ( void  ) const [virtual]

Definition at line 781 of file nsObjectFrame.cpp.

{
  return nsLayoutAtoms::objectFrame; 
}

Definition at line 1498 of file nsObjectFrame.cpp.

{
  nsIView * parentWithView;
  nsPoint origin(0,0);

  GetOffsetFromView(origin, &parentWithView);

  // if it's windowless, let's make sure we have our origin set right
  // it may need to be corrected, like after scrolling
  if (aWindowless && parentWithView) {
    nsIViewManager* parentVM = parentWithView->GetViewManager();

    // Walk up all the views and add up their positions until we
    // reach the first view with a window (non-null widget). This will give us our
    // position relative to the containing window which is what we want to give the plugin
    nsIView* theView = parentWithView;
    while (theView && !theView->GetWidget()) {
      if (theView->GetViewManager() != parentVM)
        break;

      origin += theView->GetPosition();
      theView = theView->GetParent();
    }  
  }

  float t2p;
  t2p = GetPresContext()->TwipsToPixels();
  origin.x = NSTwipsToIntPixels(origin.x, t2p);
  origin.y = NSTwipsToIntPixels(origin.y, t2p);

  return origin;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsObjectFrame::HandleChild ( nsPresContext aPresContext,
nsHTMLReflowMetrics aMetrics,
const nsHTMLReflowState aReflowState,
nsReflowStatus aStatus,
nsIFrame child 
) [protected]

Definition at line 1416 of file nsObjectFrame.cpp.

{
  // Note that in the image and document cases the child shares our
  // style context, so we simply want to reflow the child with pretty
  // much our own reflow state, in the case of a broken plugin, the
  // child has its own style context, so we create a new reflow
  // state....
  // XXXbz maybe we should always have a different style context?
  // XXXroc no, that seems to break things. But as is, this causes
  // an assertion failure in nsContainerFrame because the reflow
  // state isn't built for the right frame.

  nsReflowStatus status;

  if (IsBroken()) {
    nsHTMLReflowState state(aPresContext, aReflowState, child,
                            nsSize(aReflowState.availableWidth,
                                   aReflowState.availableHeight));

    ReflowChild(child, aPresContext, aMetrics, state, 0, 0, 0, status);
    FinishReflowChild(child, aPresContext, &state, aMetrics, 0, 0, 0);
  } else {
    ReflowChild(child, aPresContext, aMetrics, aReflowState, 0, 0, 0, status);
    FinishReflowChild(child, aPresContext, &aReflowState, aMetrics, 0, 0, 0);
  }

  aStatus = NS_FRAME_COMPLETE;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsObjectFrame::HandleEvent ( nsPresContext aPresContext,
nsGUIEvent aEvent,
nsEventStatus aEventStatus 
)

Definition at line 2073 of file nsObjectFrame.cpp.

{
  NS_ENSURE_ARG_POINTER(anEventStatus);
  nsresult rv = NS_OK;

  //FIX FOR CRASHING WHEN NO INSTANCE OWVER
  if (!mInstanceOwner)
    return NS_ERROR_NULL_POINTER;

  if (anEvent->message == NS_PLUGIN_ACTIVATE) {
    nsIContent* content = GetContent();
    if (content) {
      content->SetFocus(aPresContext);
      return rv;
    }
  }

#ifdef XP_WIN
  rv = nsObjectFrameSuper::HandleEvent(aPresContext, anEvent, anEventStatus);
  return rv;
#endif

       switch (anEvent->message) {
       case NS_DESTROY:
              mInstanceOwner->CancelTimer();
              break;
       case NS_GOTFOCUS:
       case NS_LOSTFOCUS:
              *anEventStatus = mInstanceOwner->ProcessEvent(*anEvent);
              break;
              
       default:
              // instead of using an event listener, we can dispatch events to plugins directly.
              rv = nsObjectFrameSuper::HandleEvent(aPresContext, anEvent, anEventStatus);
       }
       
       return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsObjectFrame::Init ( nsPresContext aPresContext,
nsIContent aContent,
nsIFrame aParent,
nsStyleContext aContext,
nsIFrame aPrevInFlow 
)

Definition at line 617 of file nsObjectFrame.cpp.

{
#ifdef DEBUG
  mInstantiating = PR_FALSE;
#endif
  mIsBrokenPlugin = PR_FALSE;

  if (sDefaultPluginDisabled == (PRBool)0xffffffff) {
    sDefaultPluginDisabled =
      nsContentUtils::GetBoolPref("plugin.default_plugin_disabled");
  }

  nsresult rv = nsObjectFrameSuper::Init(aPresContext, aContent, aParent,
                                         aContext, aPrevInFlow);

  if (NS_FAILED(rv))
    return rv;

  // Find our content type
  nsCAutoString type;
  rv = GetMIMEType(type);
  // If that fails, just return and render nothing.
  if (NS_FAILED(rv))
    return NS_OK;

  // Ideally this should move to Reflow when the stream starts to come
  if (IsSupportedImage(type)) {
    // kick off the image load in the content node
    // XXX once this moves to somewhere where we have the data stream,
    // we should have a way to load images with a channel....
    nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
    if (!imageLoader) {
      NS_ERROR("Not an image loading content?");
      return NS_ERROR_UNEXPECTED;
    }

    nsAutoString data;

    // If this is an OBJECT tag, we should look for a DATA attribute.
    // If not, it's an EMBED tag, and so we should look for a SRC attribute.
    if (aContent->Tag() == nsHTMLAtoms::object)
      rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data);
    else
      rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data);

    imageLoader->ImageURIChanged(data);

    nsIFrame * aNewFrame = nsnull;
    rv = NS_NewImageFrame(aPresContext->PresShell(), &aNewFrame);
    if (NS_FAILED(rv))
      return rv;

    // XXX we're using the same style context for ourselves and the
    // image frame.  If this ever changes, please fix HandleChild() to deal.
    rv = aNewFrame->Init(aPresContext, aContent, this, aContext, aPrevInFlow);
    if (NS_SUCCEEDED(rv)) {
      nsHTMLContainerFrame::CreateViewForFrame(aNewFrame, nsnull, PR_FALSE);
      mFrames.AppendFrame(this, aNewFrame);
    }
    else
      aNewFrame->Destroy(aPresContext);

    return rv; // bail at this point
  }

  // for now, we should try to do the same for "document" types and
  // create an iframe-like sub-frame
  if (IsSupportedDocument(aContent, type)) {
    nsIFrame * aNewFrame = nsnull;
    rv = NS_NewSubDocumentFrame(aPresContext->PresShell(), &aNewFrame);
    if (NS_FAILED(rv))
      return rv;
    
    // XXX we're using the same style context for ourselves and the
    // iframe.  If this ever changes, please fix HandleChild() to deal.
    rv = aNewFrame->Init(aPresContext, aContent, this, aContext, aPrevInFlow);
    if (NS_SUCCEEDED(rv)) {
      nsHTMLContainerFrame::CreateViewForFrame(aNewFrame, nsnull, PR_FALSE);
      mFrames.AppendFrame(this, aNewFrame);
    } else {
      aNewFrame->Destroy(aPresContext);
    }
  }

  return rv;
}

Here is the call graph for this function:

nsresult nsObjectFrame::InstantiatePlugin ( nsPresContext aPresContext,
nsHTMLReflowMetrics aMetrics,
const nsHTMLReflowState aReflowState,
nsIPluginHost aPluginHost,
const char *  aMimetype,
nsIURI aURL 
) [protected]

Definition at line 1308 of file nsObjectFrame.cpp.

{
  nsIView *parentWithView;
  nsPoint origin;
  nsPluginWindow  *window;
  float           t2p;
  
  t2p = aPresContext->TwipsToPixels();

  mFullURL = aURI;

  // we need to recalculate this now that we have access to the nsPluginInstanceOwner
  // and its size info (as set in the tag)
  GetDesiredSize(aPresContext, aReflowState, aMetrics);

  mInstanceOwner->GetWindow(window);

  NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);

  GetOffsetFromView(origin, &parentWithView);
  window->x = NSTwipsToIntPixels(origin.x, t2p);
  window->y = NSTwipsToIntPixels(origin.y, t2p);
  window->width = NSTwipsToIntPixels(aMetrics.width, t2p);
  window->height = NSTwipsToIntPixels(aMetrics.height, t2p);

  // on the Mac we need to set the clipRect to { 0, 0, 0, 0 } for now. This will keep
  // us from drawing on screen until the widget is properly positioned, which will not
  // happen until we have finished the reflow process.
  window->clipRect.top = 0;
  window->clipRect.left = 0;
#if !(defined(XP_MAC) || defined(XP_MACOSX))
  window->clipRect.bottom = NSTwipsToIntPixels(aMetrics.height, t2p);
  window->clipRect.right = NSTwipsToIntPixels(aMetrics.width, t2p);
#else
  window->clipRect.bottom = 0;
  window->clipRect.right = 0;
#endif

#ifdef DEBUG
  mInstantiating = PR_TRUE;
#endif

  nsCOMPtr<nsIDocument> doc;
  nsresult rv = mInstanceOwner->GetDocument(getter_AddRefs(doc));
  nsCOMPtr<nsIPluginDocument> pDoc (do_QueryInterface(doc));

  if (pDoc) {  /* full-page mode */
    nsCOMPtr<nsIStreamListener> stream;
    rv = aPluginHost->InstantiateFullPagePlugin(aMimeType, aURI,
          /* resulting stream listener */       *getter_AddRefs(stream),
                                                mInstanceOwner);
    if (NS_SUCCEEDED(rv))
      pDoc->SetStreamListener(stream);
  } else {   /* embedded mode */
    rv = aPluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI,
                                                mInstanceOwner);
  }
#ifdef DEBUG
  mInstantiating = PR_FALSE;
#endif

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsObjectFrame::InstantiateWidget ( nsPresContext aPresContext,
nsHTMLReflowMetrics aMetrics,
const nsHTMLReflowState aReflowState,
nsCID  aWidgetCID 
) [protected]

Definition at line 1276 of file nsObjectFrame.cpp.

{
  nsresult rv;

  GetDesiredSize(aPresContext, aReflowState, aMetrics);
  nsIView *parentWithView;
  nsPoint origin;
  GetOffsetFromView(origin, &parentWithView);
  // Just make the frigging widget

  float           t2p;
  t2p = aPresContext->TwipsToPixels();
  PRInt32 x = NSTwipsToIntPixels(origin.x, t2p);
  PRInt32 y = NSTwipsToIntPixels(origin.y, t2p);
  PRInt32 width = NSTwipsToIntPixels(aMetrics.width, t2p);
  PRInt32 height = NSTwipsToIntPixels(aMetrics.height, t2p);
  nsRect r = nsRect(x, y, width, height);

  mWidget = do_CreateInstance(aWidgetCID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  mWidget->Create(parentWithView->GetNearestWidget(nsnull), r, nsnull, nsnull);
  mWidget->Show(PR_TRUE);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsObjectFrame::IsBroken ( ) const [inline]

Definition at line 144 of file nsObjectFrame.h.

  {
    return mIsBrokenPlugin;
  }

Here is the caller graph for this function:

virtual PRBool nsObjectFrame::IsContainingBlock ( ) const [inline, virtual]

Definition at line 149 of file nsObjectFrame.h.

  {
    // Broken plugins are containing blocks.

    return IsBroken();
  }

Here is the call graph for this function:

PRBool nsObjectFrame::IsFocusable ( PRInt32 aTabIndex = nsnull,
PRBool  aWithMouse = PR_FALSE 
) [protected]

Definition at line 1451 of file nsObjectFrame.cpp.

{
  if (aTabIndex)
    *aTabIndex = -1;
  if (IsBroken()) {
    // Inner anchor for "click to install plugin" is focusable,
    // but not the object frame itself
    return PR_FALSE;
  }
  return nsObjectFrameSuper::IsFocusable(aTabIndex, aWithMouse);
}

Here is the call graph for this function:

PRBool nsObjectFrame::IsHidden ( PRBool  aCheckVisibilityStyle = PR_TRUE) const [protected]

Definition at line 1464 of file nsObjectFrame.cpp.

{
  if (aCheckVisibilityStyle) {
    if (!GetStyleVisibility()->IsVisibleOrCollapsed())
      return PR_TRUE;    
  }

  // only <embed> tags support the HIDDEN attribute
  if (mContent->Tag() == nsHTMLAtoms::embed) {
    nsAutoString hidden;
    nsresult result = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden);

    // Yes, these are really the kooky ways that you could tell 4.x
    // not to hide the <embed> once you'd put the 'hidden' attribute
    // on the tag...

    // these |NS_ConvertASCIItoUCS2|s can't be |NS_LITERAL_STRING|s
    // until |EqualsIgnoreCase| get's fixed

    // HIDDEN w/ no attributes gets translated as we are hidden for
    // compatibility w/ 4.x and IE so we don't create a non-painting
    // widget in layout. See bug 188959.
    if (NS_CONTENT_ATTR_NOT_THERE != result &&
       (hidden.IsEmpty() ||
        !hidden.LowerCaseEqualsLiteral("false") &&
        !hidden.LowerCaseEqualsLiteral("no") &&
        !hidden.LowerCaseEqualsLiteral("off"))) {
      return PR_TRUE;
    }
  }

  return PR_FALSE;
}

Here is the caller graph for this function:

PRBool nsObjectFrame::IsLeaf ( ) const [virtual]

Definition at line 804 of file nsObjectFrame.cpp.

{
  // We're actually a leaf.  We inherit from nsContainerFrame for
  // convenience for now, but we construct our own kids and the frame
  // constructor shouldn't be messing with them.
  // XXXbz ideally, we wouldn't have this child frame thing at all.
  return PR_TRUE;
}
nsresult nsObjectFrame::MakeAbsoluteURL ( nsIURI **  aFullURI,
nsString  aSrc,
nsIURI aBaseURI 
)

Definition at line 962 of file nsObjectFrame.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIDocument> document;
  rv = mInstanceOwner->GetDocument(getter_AddRefs(document));

  // get document charset
  nsCAutoString originCharset;
  if (document)
    originCharset = document->GetDocumentCharacterSet();

  return NS_NewURI(aFullURI, aSrc, originCharset.get(), aBaseURI);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual PRBool nsObjectFrame::NeedsView ( ) [inline, virtual]

Definition at line 89 of file nsObjectFrame.h.

{ return PR_TRUE; }

Definition at line 2125 of file nsObjectFrame.cpp.

{
  nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
  if (!doc)
    return;

  nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
  if (!sgo)
    return;

  nsIScriptContext *scx = sgo->GetContext();
  if (!scx)
    return;

  JSContext *cx = (JSContext *)scx->GetNativeContext();

  nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
  nsContentUtils::XPConnect()->
    GetWrappedNativeOfNativeObject(cx, sgo->GetGlobalJSObject(), mContent,
                                   NS_GET_IID(nsISupports),
                                   getter_AddRefs(wrapper));

  if (!wrapper) {
    // Nothing to do here if there's no wrapper for mContent
    return;
  }

  nsCOMPtr<nsIClassInfo> ci(do_QueryInterface(mContent));
  if (!ci)
    return;

  nsCOMPtr<nsISupports> s;
  ci->GetHelperForLanguage(nsIProgrammingLanguage::JAVASCRIPT,
                           getter_AddRefs(s));

  nsCOMPtr<nsIXPCScriptable> helper(do_QueryInterface(s));

  if (!helper) {
    // There's nothing we can do if there's no helper
    return;
  }

  JSObject *obj = nsnull;
  nsresult rv = wrapper->GetJSObject(&obj);
  if (NS_FAILED(rv))
    return;

  // Abuse the scriptable helper to trigger prototype setup for the
  // wrapper for mContent so that this plugin becomes part of the DOM
  // object.
  helper->PostCreate(wrapper, cx, obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the MIME type used for rendering content for this frame.

This may get the type via the URL's extension.

NS_IMETHODIMP nsObjectFrame::Paint ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect,
nsFramePaintLayer  aWhichLayer,
PRUint32  aFlags = 0 
)

Definition at line 1788 of file nsObjectFrame.cpp.

{
  if (!GetStyleVisibility()->IsVisibleOrCollapsed())
    return NS_OK;
  
  nsIFrame * child = mFrames.FirstChild();
  if (child) {    // if we have children, we are probably not really a plugin
    nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
    return NS_OK;
  }

  // If we are painting in Print Preview do nothing....
  if (aPresContext->Type() == nsPresContext::eContext_PrintPreview) {
    return NS_OK;
  }

  // determine if we are printing
  if (aPresContext->Type() == nsPresContext::eContext_Print) {
    // UNIX Plugins can't PP at this time, so draw an empty box
    // we only want to print on the content layer pass
    if (eFramePaintLayer_Content != aWhichLayer)
      return NS_OK;

    // if we are printing, we need to get the correct nsIPluginInstance
    // for THIS content node in order to call ->Print() on the right plugin

    // first, we need to get the document
    nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
    NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);

    // now we need to get the shell for the screen
    // XXX assuming that the shell at zero will always be the screen one
    nsIPresShell *shell = doc->GetShellAt(0);
    NS_ENSURE_TRUE(shell, NS_ERROR_NULL_POINTER);

    // then the shell can give us the screen frame for this content node
    nsIFrame* frame = nsnull;
    shell->GetPrimaryFrameFor(mContent, &frame);
    NS_ENSURE_TRUE(frame, NS_ERROR_NULL_POINTER);

    // make sure this is REALLY an nsIObjectFrame
    // we may need to go through the children to get it
    nsIObjectFrame* objectFrame = nsnull;
    CallQueryInterface(frame,&objectFrame);
    if (!objectFrame)
      objectFrame = GetNextObjectFrame(aPresContext,frame);
    NS_ENSURE_TRUE(objectFrame,NS_ERROR_FAILURE);

    // finally we can get our plugin instance
    nsCOMPtr<nsIPluginInstance> pi;
    if (NS_FAILED(objectFrame->GetPluginInstance(*getter_AddRefs(pi))) || !pi)
      return NS_ERROR_FAILURE;

    // now we need to setup the correct location for printing
    nsresult rv;
    nsPluginWindow    window;
    nsPoint           origin;
    float             t2p;
    window.window =   nsnull;

    // prepare embedded mode printing struct
    nsPluginPrint npprint;
    npprint.mode = nsPluginMode_Embedded;

    // we need to find out if we are windowless or not
    PRBool windowless = PR_FALSE;
    pi->GetValue(nsPluginInstanceVariable_WindowlessBool, (void *)&windowless);
    window.type  =  windowless ? nsPluginWindowType_Drawable : nsPluginWindowType_Window;

    // Get the offset of the DC
    nsTransform2D* rcTransform;
    aRenderingContext.GetCurrentTransform(rcTransform);
    rcTransform->GetTranslationCoord(&origin.x, &origin.y);
    
    // Get the conversion factor between pixels and twips
    t2p = aPresContext->TwipsToPixels();

    // set it all up
    // XXX is windowless different?
    window.x = origin.x;
    window.y = origin.y;
    window.width = NSToCoordRound(mRect.width * t2p);
    window.height= NSToCoordRound(mRect.height * t2p);
    window.clipRect.bottom = 0; window.clipRect.top = 0;
    window.clipRect.left = 0; window.clipRect.right = 0;
    
// XXX platform specific printing code
#if defined(XP_MAC) && !TARGET_CARBON
    // Mac does things a little differently.
    GrafPtr curPort;
    ::GetPort(&curPort);  // get the current port

    nsPluginPort port;
    port.port = (CGrafPort*)curPort;
    port.portx = window.x;
    port.porty = window.y;

    RgnHandle curClip = ::NewRgn();
    NS_ENSURE_TRUE(curClip, NS_ERROR_NULL_POINTER);
    ::GetClip(curClip); // save old clip
    
    ::SetOrigin(-window.x,-window.y); // port must be set correctly prior to telling plugin to print
    Rect r = {0,0,window.height,window.width};
    ::ClipRect(&r);  // also set the clip
    
    window.window = &port;
    npprint.print.embedPrint.platformPrint = (void*)window.window;
    npprint.print.embedPrint.window = window;
    // send off print info to plugin
    rv = pi->Print(&npprint);
#elif defined(XP_UNIX) && !defined(XP_MACOSX)
    /* UNIX does things completely differently:
     * We call the plugin and it sends generated PostScript data into a
     * file handle we provide. If the plugin returns with success we embed
     * this PostScript code fragment into the PostScript job we send to the
     * printer.
     */

    PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("nsObjectFrame::Paint() start for X11 platforms\n"));
           
    FILE *plugintmpfile = tmpfile();
    if (!plugintmpfile) {
      PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("error: could not open tmp. file, errno=%d\n", errno));
      return NS_ERROR_FAILURE;
    }
 
    /* Send off print info to plugin */
    NPPrintCallbackStruct npPrintInfo;
    npPrintInfo.type = NP_PRINT;
    npPrintInfo.fp   = plugintmpfile;
    npprint.print.embedPrint.platformPrint = (void *)&npPrintInfo;
    /* aDirtyRect contains the right information for ps print */
    window.x =   aDirtyRect.x;
    window.y =   aDirtyRect.y;
    window.width =   aDirtyRect.width;
    window.height =   aDirtyRect.height;
    npprint.print.embedPrint.window        = window;
    rv = pi->Print(&npprint);
    if (NS_FAILED(rv)) {
      PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("error: plugin returned failure %lx\n", (long)rv));
      fclose(plugintmpfile);
      return rv;
    }

    /* Send data to printer */
    rv = aRenderingContext.RenderEPS(aDirtyRect, plugintmpfile);

    fclose(plugintmpfile);

    PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("plugin printing done, return code is %lx\n", (long)rv));

#else  // Windows and non-UNIX, non-Mac(Classic) cases

    // we need the native printer device context to pass to plugin
    // On Windows, this will be the HDC
    void *pDC = 0;
    aRenderingContext.RetrieveCurrentNativeGraphicData(&pDC);

    if (!pDC)
      return NS_OK;  // no dc implemented so quit

    npprint.print.embedPrint.platformPrint = (void*)pDC;
    npprint.print.embedPrint.window = window;
    // send off print info to plugin
    rv = pi->Print(&npprint);

#endif

#if defined(XP_MAC) && !TARGET_CARBON
    // Clean-up on Mac
    ::SetOrigin(0,0);
    ::SetClip(curClip);  // restore previous clip
    ::DisposeRgn(curClip);
#endif

    // XXX Nav 4.x always sent a SetWindow call after print. Should we do the same?
    nsDidReflowStatus status = NS_FRAME_REFLOW_FINISHED; // should we use a special status?
    frame->DidReflow(shell->GetPresContext(),
                     nsnull, status);  // DidReflow will take care of it

    return rv;  // done with printing
  }

// Screen painting code
#if defined(XP_MAC) || defined(XP_MACOSX)
  // delegate all painting to the plugin instance.
  if ((NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) && mInstanceOwner)
      mInstanceOwner->Paint(aDirtyRect);
#elif defined (XP_WIN) || defined(XP_OS2)
  if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
    nsCOMPtr<nsIPluginInstance> inst;
    GetPluginInstance(*getter_AddRefs(inst));
    if (inst) {
      // Look if it's windowless
      nsPluginWindow * window;
      mInstanceOwner->GetWindow(window);

      if (window->type == nsPluginWindowType_Drawable) {
        // check if we need to call SetWindow with updated parameters
        PRBool doupdatewindow = PR_FALSE;

        // check if we need to update hdc
        void *data;
        aRenderingContext.RetrieveCurrentNativeGraphicData((void**)&data);
        PRUint32 hdc = (PRUint32) data;
        if (NS_REINTERPRET_CAST(PRUint32, window->window) != hdc) {
          window->window = NS_REINTERPRET_CAST(nsPluginPort*, hdc);
          doupdatewindow = PR_TRUE;
        }

        /*
         * Layout now has an optimized way of painting. Now we always get
         * a new drawing surface, sized to be just what's needed. Windowsless
         * plugins need a transform applied to their origin so they paint
         * in the right place. Since |SetWindow| is no longer being used
         * to tell the plugin where it is, we dispatch a NPWindow through
         * |HandleEvent| to tell the plugin when its window moved
         */

        // Get the offset of the DC
        nsTransform2D* rcTransform;
        aRenderingContext.GetCurrentTransform(rcTransform);
        nsPoint origin;
        rcTransform->GetTranslationCoord(&origin.x, &origin.y);

        if ((window->x != origin.x) || (window->y != origin.y)) {
          window->x = origin.x;
          window->y = origin.y;
          doupdatewindow = PR_TRUE;
        }

        // if our location or visible area has changed, we need to tell the plugin
        if (doupdatewindow) {
#ifdef XP_WIN    // Windowless plugins on windows need a special event to update their location, see bug 135737
           // bug 271442: note, the rectangle we send is now purely the bounds of the plugin
           // relative to the window it is contained in, which is useful for the plugin to correctly translate mouse coordinates
           //
           // this does not mesh with the comments for bug 135737 which imply that the rectangle
           // must be clipped in some way to prevent the plugin attempting to paint over areas it shouldn't;
           //
           // since the two uses of the rectangle are mutually exclusive in some cases,
           // and since I don't see any incorrect painting (at least with Flash and ViewPoint - the originator of 135737),
           // it seems that windowless plugins are not relying on information here for clipping their drawing,
           // and we can safely use this message to tell the plugin exactly where it is in all cases.

           origin = GetWindowOriginInPixels(PR_TRUE);
           nsRect winlessRect = nsRect(origin, nsSize(window->width, window->height));
           if (mWindowlessRect != winlessRect) {
             mWindowlessRect = winlessRect;

             WINDOWPOS winpos;
             memset(&winpos, 0, sizeof(winpos));
             winpos.x = mWindowlessRect.x;
             winpos.y = mWindowlessRect.y;
             winpos.cx = mWindowlessRect.width;
             winpos.cy = mWindowlessRect.height;

             // finally, update the plugin by sending it a WM_WINDOWPOSCHANGED event
             nsPluginEvent pluginEvent;
             pluginEvent.event = WM_WINDOWPOSCHANGED;
             pluginEvent.wParam = 0;
             pluginEvent.lParam = (uint32)&winpos;
             PRBool eventHandled = PR_FALSE;

             inst->HandleEvent(&pluginEvent, &eventHandled);
          }
#endif

          inst->SetWindow(window);        
        }

        mInstanceOwner->Paint(aDirtyRect, hdc);
      }
    }
  }
#endif /* !XP_MAC */
  DO_GLOBAL_REFLOW_COUNT_DSP("nsObjectFrame", &aRenderingContext);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 3114 of file nsObjectFrame.cpp.

{
  if (!aMimeType) {
    NS_ERROR("bogus type... behavior will be broken");
    return;
  }
  
  nsDependentCString type(aMimeType);

  // Tell mContent about the mime type

  nsCOMPtr<nsIPluginElement> pluginElement(do_QueryInterface(mContent));

  if (pluginElement) {
    pluginElement->SetActualType(type);
  }

  if (!sDefaultPluginDisabled) {
    // The default plugin is enabled, don't fire events etc.
    return;
  }

  // For non-image and non-document mime types, fire the plugin not
  // found event and mark this plugin as broken.
  if (!IsSupportedImage(type) &&
      !IsSupportedDocument(mContent, type)) {
    mIsBrokenPlugin = PR_TRUE;

    nsIDocument *doc = mContent->GetDocument();
    if (!doc) {
      return;
    }

    mState |= NS_FRAME_HAS_DIRTY_CHILDREN;

    GetParent()->ReflowDirtyChild(doc->GetShellAt(0), this);

    // Make sure to fire the event AFTER we've finished touching out members.

    // Hold a strong ref to our content across this event dispatch.
    nsCOMPtr<nsIContent> kungFuDeathGrip(mContent);
    
    FirePluginNotFoundEvent(mContent);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsObjectFrame::QueryInterface ( const nsIID aIID,
void **  aInstancePtr 
)

Definition at line 428 of file nsObjectFrame.cpp.

{
  NS_ENSURE_ARG_POINTER(aInstancePtr);
  *aInstancePtr = nsnull;

#ifdef DEBUG
  if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) {
    *aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this);
    return NS_OK;
  }
#endif

  if (aIID.Equals(NS_GET_IID(nsIObjectFrame))) {
    *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this);
    return NS_OK;
  } else if (aIID.Equals(NS_GET_IID(nsIFrame))) {
    *aInstancePtr = NS_STATIC_CAST(nsIFrame*,this);
    return NS_OK;
  } else if (aIID.Equals(NS_GET_IID(nsISupports))) {
    *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this);
    return NS_OK;
  }
  return NS_NOINTERFACE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsObjectFrame::Reflow ( nsPresContext aPresContext,
nsHTMLReflowMetrics aDesiredSize,
const nsHTMLReflowState aReflowState,
nsReflowStatus aStatus 
)

Definition at line 1007 of file nsObjectFrame.cpp.

{
  DO_GLOBAL_REFLOW_COUNT("nsObjectFrame", aReflowState.reason);
  DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
  nsresult rv = NS_OK;

  // If we have a child, we toss the reflow over to it.
  nsIFrame * child = mFrames.FirstChild();

  if (IsBroken()) {
    // This is a broken plugin, if we don't already have a child
    // frame, create the child frames manually. If any of this frame
    // construction code ever changes to use the frame constructor, or
    // any other change, this probably needs some changes too.
    if (!child) {
      CreateDefaultFrames(aPresContext, aMetrics, aReflowState);

      child = mFrames.FirstChild();
    }

    if (child) {
      GetDesiredSize(aPresContext, aReflowState, aMetrics);

      // Build a reflow state so we can see what the child's border and
      // padding are going to be
      nsHTMLReflowState state(aPresContext, aReflowState, child,
                              nsSize(aReflowState.availableWidth,
                                     aReflowState.availableHeight));

      float t2p = aPresContext->TwipsToPixels();
      PRInt32 width = NSTwipsToIntPixels(aMetrics.width - state.mComputedBorderPadding.LeftRight(), t2p);
      PRInt32 height = NSTwipsToIntPixels(aMetrics.height - state.mComputedBorderPadding.TopBottom(), t2p);

      // Set the child's content width and height
      SizeAnchor(child->GetContent(), width, height);

      // SizeAnchor() is seriously evil as it ends up setting an
      // attribute (through the style changes that it does) while
      // we're in reflow. This is also seriously evil, as it pulls
      // that reflow command out of the reflow queue, as leaving it
      // there can get us into infinite loops while reflowing object
      // frames for missing plugins.
      nsReflowType reflowType(eReflowType_StyleChanged);
      aPresContext->PresShell()->CancelReflowCommand(child, &reflowType);
    }
  }

  if (child) {
    // Reflow the child; our size just depends on that of the child,
    // pure and simple
    return HandleChild(aPresContext, aMetrics, aReflowState, aStatus, child);
  }

  // Get our desired size
  GetDesiredSize(aPresContext, aReflowState, aMetrics);

  // delay plugin instantiation until all children have
  // arrived. Otherwise there may be PARAMs or other stuff that the
  // plugin needs to see that haven't arrived yet.
  if (!GetContent()->IsDoneAddingChildren()) {
    aStatus = NS_FRAME_COMPLETE;
    return rv;
  }

  // if we are printing or print previewing, bail for now
  if (aPresContext->Medium() == nsLayoutAtoms::print) {
    aStatus = NS_FRAME_COMPLETE;
    return rv;
  }

  // if mInstance is null, we need to determine what kind of object we are and instantiate ourselves
  if (!mInstanceOwner) {
    // XXX - do we need to create this for widgets as well?
    mInstanceOwner = new nsPluginInstanceOwner();
    if (!mInstanceOwner)
      return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(mInstanceOwner);
    mInstanceOwner->Init(aPresContext, this);

    // get the nsIPluginHost service
    nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(kCPluginManagerCID));

    nsCOMPtr<nsISupports> container;
    nsCOMPtr<nsIURI> fullURL;

    nsAutoString classid;

    nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
    nsAutoString codeBase;
    if ((NS_CONTENT_ATTR_HAS_VALUE ==
         mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&
        !codeBase.IsEmpty()) {
      nsCOMPtr<nsIURI> codeBaseURL;
      rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURI);
      if (NS_SUCCEEDED(rv)) {
        baseURI = codeBaseURL;
      }
    }

    // if we have a clsid, we're either an internal widget, an ActiveX control, or an applet
    if (mContent->Tag() == nsHTMLAtoms::object &&
        NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid)) {
      PRBool bJavaObject;

      bJavaObject = StringBeginsWith(classid, NS_LITERAL_STRING("java:"));

      // if we find "java:" in the class id, we have a java applet
      if (bJavaObject) {
        if (!baseURI) {
          rv = NS_ERROR_FAILURE;
        }
        else {
          fullURL = baseURI;

          if (pluginHost) {
            mInstanceOwner->SetPluginHost(pluginHost);
            rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,
                                   pluginHost, "application/x-java-vm",
                                   fullURL);
          }
        }
      }
      else { // otherwise, we're either an ActiveX control or an internal widget
        // These are some builtin types that we know about for now.
        // (Eventually this will move somewhere else.)
        if (classid.EqualsLiteral("browser")) {
          rv = InstantiateWidget(aPresContext, aMetrics,
                                 aReflowState, kCAppShellCID);
        }
        else {
          // if we haven't matched to an internal type, check to see if
          // we have an ActiveX handler
          // if not, create the default plugin
          if (!baseURI) {
            rv = NS_ERROR_FAILURE;
          }
          else {
            fullURL = baseURI;

            if (pluginHost) {
              mInstanceOwner->SetPluginHost(pluginHost);
              if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/x-oleobject"))) {
                rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,
                                       pluginHost, "application/x-oleobject",
                                       fullURL);
              } else if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/oleobject"))) {
                rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,
                                       pluginHost, "application/oleobject",
                                       fullURL);
              } else {
                rv = NS_ERROR_FAILURE;
              }
            }
          }
        }
      }

      // finish up
      if (NS_SUCCEEDED(rv)) {
        aStatus = NS_FRAME_COMPLETE;
        return NS_OK;
      }
    }
    else { // no clsid - the object is either an applet or a plugin
      nsAutoString    src;
      if (!baseURI) {
        rv = NS_ERROR_FAILURE;
      }
      else {
        if (pluginHost) {
          mInstanceOwner->SetPluginHost(pluginHost);

          nsIAtom *tag = mContent->Tag();
          if (tag == nsHTMLAtoms::applet) {
            if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, src)) {
              // Create an absolute URL
              rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURI);
            }
            else
              fullURL = baseURI;

            rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,
                                  pluginHost, "application/x-java-vm", fullURL);
          } else { // traditional plugin
            nsXPIDLCString mimeTypeStr;
            nsAutoString type;
            mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type);

            if (type.Length()) {
              mimeTypeStr.Adopt(ToNewCString(type));
            }
            // Stream in the object source if there is one...
            // If this is an OBJECT tag, we should look for a DATA attribute.
            // If not, it's an EMBED tag, and so we should look for a SRC attribute.
            if (tag == nsHTMLAtoms::object)
              rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, src);
            else
              rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src);
            
            if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
              // Create an absolute URL
              rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURI);
              if (NS_FAILED(rv)) {
                // Failed to create URI, maybe because we didn't
                // reconize the protocol handler ==> treat like
                // no 'src'/'data' was specified in the embed/object tag
                fullURL = baseURI;
              }
            }
            else {
              // we didn't find a src or data param, so just set the url
              // to the base

              fullURL = baseURI;
            }

            // now try to instantiate a plugin instance based on a mime type
            const char* mimeType = mimeTypeStr.get();
            if (mimeType || !src.IsEmpty()) {
              if (!mimeType) {
                // we don't have a mime type, try to figure it out
                // from extension
                PRInt32 offset = src.RFindChar(PRUnichar('.'));
                if (offset != kNotFound)
                  pluginHost->IsPluginEnabledForExtension(NS_ConvertUTF16toUTF8(Substring(src, offset + 1, src.Length())).get(), mimeType);
              }
              // if we fail to get a mime type from extension we can
              // still try to instantiate plugin as it can be possible
              // to determine it later
              rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,
                                     pluginHost, mimeType, fullURL);
            }
            else // if we have neither we should not bother
              rv = NS_ERROR_FAILURE;
          }
        }
      }
    }
  }
  else { // if (!mInstanceOwner)
    rv = ReinstantiatePlugin(aPresContext, aMetrics, aReflowState);
  }

  // finish up
  if (NS_FAILED(rv)) {
    // if we got an error, we are probably going to be replaced

    // for a replaced object frame, clear our vertical alignment style info, see bug 36997
    nsStyleTextReset* text = NS_STATIC_CAST(nsStyleTextReset*,
      mStyleContext->GetUniqueStyleData(eStyleStruct_TextReset));
    text->mVerticalAlign.SetNormalValue();

    //check for alternative content with CantRenderReplacedElement()
    rv = aPresContext->PresShell()->CantRenderReplacedElement(this);
  } else {
    NotifyContentObjectWrapper();
  }

  aStatus = NS_FRAME_COMPLETE;

  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
  return rv;
}

Here is the call graph for this function:

nsresult nsObjectFrame::ReinstantiatePlugin ( nsPresContext aPresContext,
nsHTMLReflowMetrics aMetrics,
const nsHTMLReflowState aReflowState 
) [protected]

Definition at line 1380 of file nsObjectFrame.cpp.

{
  nsIView *parentWithView;
  nsPoint origin;
  nsPluginWindow  *window;
  float           t2p;
  t2p = aPresContext->TwipsToPixels();

  // we need to recalculate this now that we have access to the nsPluginInstanceOwner
  // and its size info (as set in the tag)
  GetDesiredSize(aPresContext, aReflowState, aMetrics);

  mInstanceOwner->GetWindow(window);
  
  NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);

  GetOffsetFromView(origin, &parentWithView);

  window->x = NSTwipsToIntPixels(origin.x, t2p);
  window->y = NSTwipsToIntPixels(origin.y, t2p);
  window->width = NSTwipsToIntPixels(aMetrics.width, t2p);
  window->height = NSTwipsToIntPixels(aMetrics.height, t2p);

  // ignore this for now on the Mac because the widget is not properly positioned
  // yet and won't be until we have finished the reflow process.
#if defined(XP_MAC) || defined(XP_MACOSX)
  window->clipRect.top = 0;
  window->clipRect.left = 0;
  window->clipRect.bottom = NSTwipsToIntPixels(aMetrics.height, t2p);
  window->clipRect.right = NSTwipsToIntPixels(aMetrics.width, t2p);
#endif

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsObjectFrame::SetInitialChildList ( nsPresContext aPresContext,
nsIAtom aListName,
nsIFrame aChildList 
)

Definition at line 580 of file nsObjectFrame.cpp.

{
  // we don't want to call this if it is already set (image)
  nsresult rv = NS_OK;
  if (mFrames.IsEmpty())
    rv = nsObjectFrameSuper::SetInitialChildList(aPresContext, aListName, aChildList);
  return rv;
}
virtual PRBool nsObjectFrame::SupportsVisibilityHidden ( ) [inline, virtual]

Definition at line 88 of file nsObjectFrame.h.

{ return PR_FALSE; }

Friends And Related Function Documentation

friend class nsPluginInstanceOwner [friend]

Definition at line 206 of file nsObjectFrame.h.


Member Data Documentation

Definition at line 210 of file nsObjectFrame.h.

Definition at line 209 of file nsObjectFrame.h.

Definition at line 208 of file nsObjectFrame.h.

Definition at line 220 of file nsObjectFrame.h.

Definition at line 211 of file nsObjectFrame.h.

Definition at line 212 of file nsObjectFrame.h.


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