2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-03-10 17:57:32 +03:00
|
|
|
// vim:set ts=2 sts=2 sw=2 et cin:
|
2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-07-07 06:33:17 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-07-07 06:33:17 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-07-07 06:33:17 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-06-22 11:06:24 +04:00
|
|
|
* Jacek Piskozub <piskozub@iopan.gda.pl>
|
2003-07-23 18:10:12 +04:00
|
|
|
* Leon Sha <leon.sha@sun.com>
|
|
|
|
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
2004-04-18 18:30:37 +04:00
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2005-09-21 23:14:30 +04:00
|
|
|
* Christian Biesinger <cbiesinger@web.de>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-08-14 11:59:59 +04:00
|
|
|
#include "nscore.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsAutoPtr.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsIPresShell.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsStyleSet.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
2001-01-18 01:16:09 +03:00
|
|
|
#include "nsIDOMKeyListener.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsIPluginHost.h"
|
|
|
|
#include "nsplugin.h"
|
|
|
|
#include "nsString.h"
|
2001-03-10 06:17:40 +03:00
|
|
|
#include "nsReadableUtils.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "prmem.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIDocument.h"
|
2005-04-02 19:47:13 +04:00
|
|
|
#include "nsIHTMLDocument.h"
|
2002-06-21 22:28:46 +04:00
|
|
|
#include "nsINodeInfo.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsIURL.h"
|
1999-11-30 07:50:42 +03:00
|
|
|
#include "nsNetUtil.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsIPluginInstanceOwner.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "plstr.h"
|
|
|
|
#include "nsILinkHandler.h"
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef OJI
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsIJVMPluginTagInfo.h"
|
2003-03-25 09:54:52 +03:00
|
|
|
#endif
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIEventListener.h"
|
2002-01-18 23:12:29 +03:00
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsIScrollPositionListener.h"
|
2000-08-24 23:49:08 +04:00
|
|
|
#include "nsIStringStream.h" // for NS_NewCharInputStream
|
1999-07-07 06:33:17 +04:00
|
|
|
#include "nsITimer.h"
|
1999-09-14 01:26:05 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-12-18 05:09:29 +03:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2000-03-11 03:41:57 +03:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2005-02-27 21:33:27 +03:00
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsIWebNavigationInfo.h"
|
|
|
|
#include "nsDocShellCID.h"
|
2000-03-11 03:41:57 +03:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
2000-01-05 04:18:38 +03:00
|
|
|
#include "nsIDOMElement.h"
|
2001-12-11 18:53:07 +03:00
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsIDOMHTMLObjectElement.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsIDOMHTMLEmbedElement.h"
|
2001-12-11 18:53:07 +03:00
|
|
|
#include "nsIDOMHTMLAppletElement.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsIDOMElementCSSInlineStyle.h"
|
|
|
|
#include "nsIDOMCSSStyleDeclaration.h"
|
|
|
|
#include "nsIDOMCSS2Properties.h"
|
2000-05-25 17:32:42 +04:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2001-05-22 02:40:10 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsIDOMDocumentEvent.h"
|
2000-10-18 03:13:30 +04:00
|
|
|
#include "nsIDOMMouseListener.h"
|
2001-08-07 05:48:14 +04:00
|
|
|
#include "nsIDOMMouseMotionListener.h"
|
2001-03-20 02:26:41 +03:00
|
|
|
#include "nsIDOMFocusListener.h"
|
2002-01-16 01:45:26 +03:00
|
|
|
#include "nsIDOMContextMenuListener.h"
|
2002-07-02 17:52:05 +04:00
|
|
|
#include "nsIDOMDragListener.h"
|
2000-10-18 03:13:30 +04:00
|
|
|
#include "nsIDOMEventReceiver.h"
|
2001-12-06 09:57:03 +03:00
|
|
|
#include "nsIDOMNSEvent.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsITextContent.h"
|
2000-10-18 03:13:30 +04:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
2000-10-19 05:37:53 +04:00
|
|
|
#include "nsIDocumentEncoder.h"
|
2001-03-10 06:17:40 +03:00
|
|
|
#include "nsXPIDLString.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsIDOMRange.h"
|
2003-02-28 02:35:47 +03:00
|
|
|
#include "nsIPluginWidget.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
2001-09-18 06:11:09 +04:00
|
|
|
#include "npapi.h"
|
|
|
|
#include "nsGfxCIID.h"
|
2001-11-14 04:33:42 +03:00
|
|
|
#include "nsUnicharUtils.h"
|
2002-03-08 18:49:43 +03:00
|
|
|
#include "nsTransform2D.h"
|
2003-03-19 06:47:09 +03:00
|
|
|
#include "nsIImageLoadingContent.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIObjectLoadingContent.h"
|
2003-04-03 01:26:29 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2004-04-30 04:57:06 +04:00
|
|
|
#include "nsContentUtils.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
#include "nsIStringBundle.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
// headers for plugin scriptability
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
2005-09-18 22:05:40 +04:00
|
|
|
#include "nsCSSPseudoClasses.h"
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
// XXX For temporary paint code
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-18 06:11:09 +04:00
|
|
|
// For mime types
|
2000-07-10 11:13:31 +04:00
|
|
|
#include "nsMimeTypes.h"
|
2001-08-16 07:02:05 +04:00
|
|
|
#include "nsIMIMEService.h"
|
|
|
|
#include "nsCExternalHandlerService.h"
|
2002-03-23 16:21:33 +03:00
|
|
|
#include "imgILoader.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2000-04-15 02:48:30 +04:00
|
|
|
#include "nsObjectFrame.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsIObjectFrame.h"
|
2002-09-26 06:53:27 +04:00
|
|
|
#include "nsPluginNativeWindow.h"
|
|
|
|
#include "nsPIPluginHost.h"
|
2003-03-22 06:20:23 +03:00
|
|
|
#include "nsIPluginDocument.h"
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-05-11 02:34:53 +04:00
|
|
|
// accessibility support
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2003-07-23 18:10:12 +04:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
#define FORCE_PR_LOG 1 /* Allow logging in the release build */
|
|
|
|
#endif /* MOZ_LOGGING */
|
|
|
|
#include "prlog.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2005-01-05 03:21:06 +03:00
|
|
|
static NS_DEFINE_CID(kRangeCID, NS_RANGE_CID);
|
2001-04-14 01:30:14 +04:00
|
|
|
|
2001-01-18 01:16:09 +03:00
|
|
|
/* X headers suck */
|
|
|
|
#ifdef KeyPress
|
|
|
|
#undef KeyPress
|
|
|
|
#endif
|
2000-10-18 03:13:30 +04:00
|
|
|
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <wtypes.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#endif
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
#ifdef CreateEvent // Thank you MS.
|
|
|
|
#undef CreateEvent
|
|
|
|
#endif
|
|
|
|
|
2003-07-23 18:10:12 +04:00
|
|
|
#ifdef PR_LOGGING
|
|
|
|
static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
|
|
|
|
#endif /* PR_LOGGING */
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
// True if the default plugin is disabled. Initialize to non-boolean
|
|
|
|
// value so that we know if we've checked the pref or not.
|
|
|
|
static PRBool sDefaultPluginDisabled = 0xffffffff;
|
|
|
|
|
|
|
|
// special class for handeling DOM context menu events because for
|
|
|
|
// some reason it starves other mouse events if implemented on the
|
|
|
|
// same class
|
2002-01-16 01:45:26 +03:00
|
|
|
class nsPluginDOMContextMenuListener : public nsIDOMContextMenuListener,
|
|
|
|
public nsIEventListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsPluginDOMContextMenuListener();
|
|
|
|
virtual ~nsPluginDOMContextMenuListener();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2004-04-10 04:25:01 +04:00
|
|
|
NS_IMETHOD ContextMenu(nsIDOMEvent* aContextMenuEvent);
|
2002-01-16 01:45:26 +03:00
|
|
|
|
|
|
|
nsresult Init(nsObjectFrame *aFrame);
|
|
|
|
nsresult Destroy(nsObjectFrame *aFrame);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsEventStatus ProcessEvent(const nsGUIEvent& anEvent)
|
|
|
|
{
|
|
|
|
return nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
2002-01-16 01:45:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
|
|
|
|
public nsIPluginTagInfo2,
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef OJI
|
1999-07-07 06:33:17 +04:00
|
|
|
public nsIJVMPluginTagInfo,
|
2003-03-25 09:54:52 +03:00
|
|
|
#endif
|
1999-07-07 06:33:17 +04:00
|
|
|
public nsIEventListener,
|
2000-10-18 03:13:30 +04:00
|
|
|
public nsITimerCallback,
|
2001-01-17 23:04:09 +03:00
|
|
|
public nsIDOMMouseListener,
|
2001-08-07 05:48:14 +04:00
|
|
|
public nsIDOMMouseMotionListener,
|
2001-03-20 02:26:41 +03:00
|
|
|
public nsIDOMKeyListener,
|
2002-01-18 23:12:29 +03:00
|
|
|
public nsIDOMFocusListener,
|
2002-07-02 17:52:05 +04:00
|
|
|
public nsIScrollPositionListener,
|
|
|
|
public nsIDOMDragListener
|
2002-01-16 01:45:26 +03:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsPluginInstanceOwner();
|
|
|
|
virtual ~nsPluginInstanceOwner();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
//nsIPluginInstanceOwner interface
|
|
|
|
|
|
|
|
NS_IMETHOD SetInstance(nsIPluginInstance *aInstance);
|
|
|
|
|
|
|
|
NS_IMETHOD GetInstance(nsIPluginInstance *&aInstance);
|
|
|
|
|
|
|
|
NS_IMETHOD GetWindow(nsPluginWindow *&aWindow);
|
|
|
|
|
|
|
|
NS_IMETHOD GetMode(nsPluginMode *aMode);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateWidget(void);
|
|
|
|
|
2000-08-24 23:49:08 +04:00
|
|
|
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
|
2000-09-05 23:03:56 +04:00
|
|
|
PRUint32 aPostDataLen, void *aHeadersData,
|
2001-11-07 06:03:04 +03:00
|
|
|
PRUint32 aHeadersDataLen, PRBool isFile = PR_FALSE);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
2001-09-05 07:58:34 +04:00
|
|
|
|
|
|
|
NS_IMETHOD ShowStatus(const PRUnichar *aStatusMsg);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetDocument(nsIDocument* *aDocument);
|
|
|
|
|
2001-06-19 01:41:57 +04:00
|
|
|
NS_IMETHOD InvalidateRect(nsPluginRect *invalidRect);
|
|
|
|
|
|
|
|
NS_IMETHOD InvalidateRegion(nsPluginRegion invalidRegion);
|
|
|
|
|
|
|
|
NS_IMETHOD ForceRedraw();
|
|
|
|
|
|
|
|
NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
NS_IMETHOD PluginNotAvailable(const char *aMimeType);
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
//nsIPluginTagInfo interface
|
|
|
|
|
|
|
|
NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names,
|
|
|
|
const char*const*& values);
|
|
|
|
|
|
|
|
NS_IMETHOD GetAttribute(const char* name, const char* *result);
|
|
|
|
|
|
|
|
//nsIPluginTagInfo2 interface
|
|
|
|
|
|
|
|
NS_IMETHOD GetTagType(nsPluginTagType *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetTagText(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetParameters(PRUint16& n, const char*const*& names, const char*const*& values);
|
|
|
|
|
|
|
|
NS_IMETHOD GetParameter(const char* name, const char* *result);
|
|
|
|
|
1999-08-03 06:51:39 +04:00
|
|
|
NS_IMETHOD GetDocumentBase(const char* *result);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetDocumentEncoding(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetAlignment(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetWidth(PRUint32 *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetHeight(PRUint32 *result);
|
2000-05-23 01:36:35 +04:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHOD GetBorderVertSpace(PRUint32 *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetBorderHorizSpace(PRUint32 *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetUniqueID(PRUint32 *result);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
NS_IMETHOD GetDOMElement(nsIDOMElement* *result);
|
|
|
|
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef OJI
|
1999-07-07 06:33:17 +04:00
|
|
|
//nsIJVMPluginTagInfo interface
|
|
|
|
|
|
|
|
NS_IMETHOD GetCode(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetCodeBase(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetArchive(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetName(const char* *result);
|
|
|
|
|
|
|
|
NS_IMETHOD GetMayScript(PRBool *result);
|
2000-10-18 03:13:30 +04:00
|
|
|
|
2003-03-25 09:54:52 +03:00
|
|
|
#endif /* OJI */
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
/** nsIDOMMouseListener interfaces
|
|
|
|
* @see nsIDOMMouseListener
|
|
|
|
*/
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
2000-10-18 03:13:30 +04:00
|
|
|
/* END interfaces from nsIDOMMouseListener*/
|
2001-01-17 23:04:09 +03:00
|
|
|
|
2001-08-07 05:48:14 +04:00
|
|
|
// nsIDOMMouseListener intefaces
|
|
|
|
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; }
|
|
|
|
|
|
|
|
// nsIDOMKeyListener interfaces
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
|
|
|
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
|
|
|
|
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
2001-01-17 23:04:09 +03:00
|
|
|
// end nsIDOMKeyListener interfaces
|
2000-10-18 03:13:30 +04:00
|
|
|
|
2001-03-20 02:26:41 +03:00
|
|
|
// nsIDOMFocuListener interfaces
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
NS_IMETHOD Focus(nsIDOMEvent * aFocusEvent);
|
|
|
|
NS_IMETHOD Blur(nsIDOMEvent * aFocusEvent);
|
2002-07-02 17:52:05 +04:00
|
|
|
|
|
|
|
// nsIDOMDragListener interfaces
|
|
|
|
NS_IMETHOD DragEnter(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragOver(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragExit(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragDrop(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragGesture(nsIDOMEvent* aMouseEvent);
|
|
|
|
|
2001-03-20 02:26:41 +03:00
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
nsresult Destroy();
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
//nsIEventListener interface
|
|
|
|
nsEventStatus ProcessEvent(const nsGUIEvent & anEvent);
|
|
|
|
|
2004-02-10 19:57:00 +03:00
|
|
|
void Paint(const nsRect& aDirtyRect, PRUint32 ndc = 0);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
// nsITimerCallback interface
|
2002-09-07 09:38:16 +04:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
void CancelTimer();
|
2002-11-06 04:24:57 +03:00
|
|
|
void StartTimer();
|
|
|
|
|
2002-01-18 23:12:29 +03:00
|
|
|
// nsIScrollPositionListener interface
|
|
|
|
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
|
|
|
|
NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
//locals
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Init(nsPresContext *aPresContext, nsObjectFrame *aFrame);
|
2000-05-23 01:36:35 +04:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
nsPluginPort* GetPluginPort();
|
2001-09-18 06:11:09 +04:00
|
|
|
void ReleasePluginPort(nsPluginPort * pluginPort);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
void SetPluginHost(nsIPluginHost* aHost);
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2003-02-28 02:35:47 +03:00
|
|
|
nsPluginPort* FixUpPluginWindow(PRInt32 inPaintState);
|
|
|
|
void GUItoMacEvent(const nsGUIEvent& anEvent, EventRecord* origEvent, EventRecord& aMacEvent);
|
2001-01-12 02:56:35 +03:00
|
|
|
#endif
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
private:
|
2003-04-12 08:55:07 +04:00
|
|
|
nsPluginNativeWindow *mPluginWindow;
|
|
|
|
nsCOMPtr<nsIPluginInstance> mInstance;
|
|
|
|
nsObjectFrame *mOwner;
|
|
|
|
nsCString mDocumentBase;
|
|
|
|
char *mTagText;
|
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
|
|
|
nsCOMPtr<nsITimer> mPluginTimer;
|
|
|
|
nsCOMPtr<nsIPluginHost> mPluginHost;
|
|
|
|
PRPackedBool mContentFocused;
|
|
|
|
PRPackedBool mWidgetVisible; // used on Mac to store our widget's visible state
|
2001-12-11 18:53:07 +03:00
|
|
|
PRUint16 mNumCachedAttrs;
|
|
|
|
PRUint16 mNumCachedParams;
|
|
|
|
char **mCachedAttrParamNames;
|
|
|
|
char **mCachedAttrParamValues;
|
2001-01-17 23:04:09 +03:00
|
|
|
|
2002-01-16 01:45:26 +03:00
|
|
|
nsPluginDOMContextMenuListener * mCXMenuListener; // pointer to wrapper for nsIDOMContextMenuListener
|
|
|
|
|
2001-01-17 23:04:09 +03:00
|
|
|
nsresult DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent);
|
2001-01-28 03:37:48 +03:00
|
|
|
nsresult DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent);
|
2001-03-20 02:26:41 +03:00
|
|
|
nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
|
2001-12-11 18:53:07 +03:00
|
|
|
|
|
|
|
nsresult EnsureCachedAttrParamArrays();
|
1999-07-07 06:33:17 +04:00
|
|
|
};
|
|
|
|
|
2004-11-15 21:12:35 +03:00
|
|
|
#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && (defined(XP_MAC) || defined(XP_MACOSX)))
|
2004-08-01 03:15:21 +04:00
|
|
|
static void ConvertTwipsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect);
|
2003-05-24 02:14:21 +04:00
|
|
|
#endif
|
2001-12-22 03:25:25 +03:00
|
|
|
|
2000-09-29 03:29:26 +04:00
|
|
|
// Mac specific code to fix up port position and clip during paint
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2003-02-28 02:35:47 +03:00
|
|
|
|
|
|
|
#ifdef DO_DIRTY_INTERSECT
|
2000-10-18 01:45:39 +04:00
|
|
|
// convert relative coordinates to absolute
|
2004-12-26 22:48:54 +03:00
|
|
|
static void ConvertRelativeToWindowAbsolute(nsIFrame* aFrame, nsPoint& aRel, nsPoint& aAbs, nsIWidget *&aContainerWidget);
|
2003-02-28 02:35:47 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
enum { ePluginPaintIgnore, ePluginPaintEnable, ePluginPaintDisable };
|
|
|
|
|
2001-01-12 02:56:35 +03:00
|
|
|
#endif // XP_MAC
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
nsObjectFrame::~nsObjectFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-05-11 02:34:53 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
NS_IMETHODIMP nsObjectFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
2003-04-15 12:45:55 +04:00
|
|
|
return accService->CreateHTMLObjectFrameAccessible(this, aAccessible);
|
2002-05-11 02:34:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
NS_IMETHODIMP nsObjectFrame::GetPluginPort(HWND *aPort)
|
|
|
|
{
|
|
|
|
*aPort = (HWND) mInstanceOwner->GetPluginPort();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
|
|
|
|
static NS_DEFINE_CID(kCAppShellCID, NS_APPSHELL_CID);
|
|
|
|
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsObjectFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-18 01:45:39 +04:00
|
|
|
// #define DO_DIRTY_INTERSECT 1 // enable dirty rect intersection during paint
|
2005-01-05 03:21:06 +03:00
|
|
|
static PRBool
|
2005-03-10 17:57:32 +03:00
|
|
|
IsSupportedImage(const nsCString& aMimeType)
|
2005-01-05 03:21:06 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<imgILoader> loader(do_GetService("@mozilla.org/image/loader;1"));
|
|
|
|
|
|
|
|
PRBool supported;
|
2005-03-10 17:57:32 +03:00
|
|
|
nsresult rv = loader->SupportImageWithMimeType(aMimeType.get(), &supported);
|
2000-10-18 01:45:39 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
return NS_SUCCEEDED(rv) && supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool
|
2005-03-10 17:57:32 +03:00
|
|
|
IsSupportedDocument(nsIContent* aOurContent,
|
|
|
|
const nsCString& aMimeType)
|
2005-01-05 03:21:06 +03:00
|
|
|
{
|
2005-02-27 21:33:27 +03:00
|
|
|
nsresult rv;
|
2005-03-10 17:57:32 +03:00
|
|
|
|
|
|
|
// only allow browser to handle content of <embed> for svg (bug 240408)
|
|
|
|
if (aOurContent->Tag() == nsHTMLAtoms::embed)
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
if (!aMimeType.LowerCaseEqualsLiteral("image/svg+xml"))
|
|
|
|
#endif
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
|
2005-02-27 21:33:27 +03:00
|
|
|
nsCOMPtr<nsIWebNavigationInfo> info(
|
|
|
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv));
|
|
|
|
PRUint32 supported;
|
|
|
|
if (info) {
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav =
|
|
|
|
do_GetInterface(aOurContent->GetCurrentDoc()->GetScriptGlobalObject());
|
|
|
|
rv = info->IsTypeSupported(aMimeType, webNav, &supported);
|
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-02-27 21:33:27 +03:00
|
|
|
return NS_SUCCEEDED(rv) &&
|
|
|
|
supported != nsIWebNavigationInfo::UNSUPPORTED &&
|
|
|
|
supported != nsIWebNavigationInfo::PLUGIN;
|
2005-01-05 03:21:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectFrame::SetInitialChildList(nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
|
|
|
// we don't want to call this if it is already set (image)
|
|
|
|
nsresult rv = NS_OK;
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mFrames.IsEmpty())
|
1999-07-07 06:33:17 +04:00
|
|
|
rv = nsObjectFrameSuper::SetInitialChildList(aPresContext, aListName, aChildList);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
static void
|
|
|
|
FirePluginNotFoundEvent(nsIContent *aTarget)
|
|
|
|
{
|
2005-10-10 22:38:57 +04:00
|
|
|
nsContentUtils::DispatchTrustedEvent(aTarget->GetDocument(), aTarget,
|
|
|
|
NS_LITERAL_STRING("PluginNotFound"),
|
|
|
|
PR_TRUE, PR_TRUE);
|
2005-01-05 03:21:06 +03:00
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP
|
2005-01-05 03:21:06 +03:00
|
|
|
nsObjectFrame::Init(nsPresContext* aPresContext,
|
1999-07-07 06:33:17 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-07-07 06:33:17 +04:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2005-04-15 01:50:46 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInstantiating = PR_FALSE;
|
|
|
|
#endif
|
2005-01-05 03:21:06 +03:00
|
|
|
mIsBrokenPlugin = PR_FALSE;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (sDefaultPluginDisabled == (PRBool)0xffffffff) {
|
|
|
|
sDefaultPluginDisabled =
|
|
|
|
nsContentUtils::GetBoolPref("plugin.default_plugin_disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = nsObjectFrameSuper::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
2005-09-21 23:14:30 +04:00
|
|
|
nsCOMPtr<nsIObjectLoadingContent> objContent(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(objContent, "Why not an object loading content?");
|
|
|
|
objContent->HasNewFrame(this);
|
1999-07-07 06:33:17 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-02-25 04:02:53 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsObjectFrame::Destroy(nsPresContext* aPresContext)
|
2000-02-25 04:02:53 +03:00
|
|
|
{
|
2005-04-15 01:50:46 +04:00
|
|
|
NS_ASSERTION(!mInstantiating, "about to crash due to bug 136927");
|
|
|
|
|
2000-02-25 04:02:53 +03:00
|
|
|
// we need to finish with the plugin before native window is destroyed
|
|
|
|
// doing this in the destructor is too late.
|
2005-10-31 21:28:56 +03:00
|
|
|
StopPlugin();
|
2004-05-07 01:15:33 +04:00
|
|
|
|
2000-02-25 04:02:53 +03:00
|
|
|
return nsObjectFrameSuper::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsObjectFrame::GetType() const
|
1999-09-14 01:26:05 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::objectFrame;
|
1999-09-14 01:26:05 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsObjectFrame::GetFrameName(nsAString& aResult) const
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ObjectFrame"), aResult);
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-04-07 07:59:02 +04:00
|
|
|
nsresult
|
|
|
|
nsObjectFrame::CreateWidgetForView(nsIView* aView)
|
|
|
|
{
|
|
|
|
// Bug 179822: Create widget and allow non-unicode SubClass
|
|
|
|
nsWidgetInitData initData;
|
|
|
|
initData.mUnicode = PR_FALSE;
|
|
|
|
return aView->CreateWidget(kWidgetCID, &initData);
|
|
|
|
}
|
|
|
|
|
2005-08-17 02:52:48 +04:00
|
|
|
PRBool
|
|
|
|
nsObjectFrame::IsLeaf() const
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
nsresult
|
2004-12-26 22:48:54 +03:00
|
|
|
nsObjectFrame::CreateWidget(nscoord aWidth,
|
1999-10-26 08:44:41 +04:00
|
|
|
nscoord aHeight,
|
2004-12-26 22:48:54 +03:00
|
|
|
PRBool aViewOnly)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2005-01-27 23:49:47 +03:00
|
|
|
nsIView* view = GetView();
|
|
|
|
NS_ASSERTION(view, "Object frames must have views");
|
2004-11-04 18:06:50 +03:00
|
|
|
if (!view) {
|
2003-06-30 14:46:59 +04:00
|
|
|
return NS_OK; //XXX why OK? MMP
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-27 23:49:47 +03:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
2005-09-21 23:14:30 +04:00
|
|
|
// mark the view as hidden since we don't know the (x,y) until Paint
|
2005-01-27 23:49:47 +03:00
|
|
|
// XXX is the above comment correct?
|
|
|
|
viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
// Turn off double buffering on the Mac. This depends on bug 49743 and partially
|
|
|
|
// fixes 32327, 19931 amd 51787
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2004-04-30 03:34:19 +04:00
|
|
|
PRBool doubleBuffer =
|
|
|
|
nsContentUtils::GetBoolPref("plugin.enable_double_buffer");
|
2003-06-30 14:46:59 +04:00
|
|
|
|
|
|
|
viewMan->AllowDoubleBuffering(doubleBuffer);
|
2000-09-29 03:29:26 +04:00
|
|
|
#endif
|
2003-06-30 14:46:59 +04:00
|
|
|
|
2005-04-29 02:17:40 +04:00
|
|
|
//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);
|
|
|
|
|
2005-04-07 07:59:02 +04:00
|
|
|
if (!aViewOnly && !view->HasWidget()) {
|
|
|
|
nsresult rv = CreateWidgetForView(view);
|
|
|
|
if (NS_FAILED(rv)) {
|
2003-06-30 14:46:59 +04:00
|
|
|
return NS_OK; //XXX why OK? MMP
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2001-11-07 02:46:13 +03:00
|
|
|
// 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
|
2003-06-30 14:46:59 +04:00
|
|
|
for (nsIFrame* frame = this; frame; frame = frame->GetParent()) {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleBackground* background = frame->GetStyleBackground();
|
2003-01-17 12:33:52 +03:00
|
|
|
if (!background->IsTransparent()) { // make sure we got an actual color
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIWidget* win = view->GetWidget();
|
2001-11-07 02:46:13 +03:00
|
|
|
if (win)
|
2003-01-17 12:33:52 +03:00
|
|
|
win->SetBackgroundColor(background->mBackgroundColor);
|
2001-11-07 02:46:13 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2005-04-29 02:17:40 +04:00
|
|
|
viewMan->SetViewVisibility(view, nsViewVisibility_kShow);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2004-11-04 18:06:50 +03:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2000-08-08 08:45:03 +04:00
|
|
|
#define EMBED_DEF_WIDTH 240
|
|
|
|
#define EMBED_DEF_HEIGHT 200
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsObjectFrame::GetDesiredSize(nsPresContext* aPresContext,
|
1999-07-07 06:33:17 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics)
|
|
|
|
{
|
2001-09-18 06:11:09 +04:00
|
|
|
// By default, we have no area
|
|
|
|
aMetrics.width = 0;
|
|
|
|
aMetrics.height = 0;
|
|
|
|
aMetrics.ascent = 0;
|
|
|
|
aMetrics.descent = 0;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
if (IsHidden(PR_FALSE)) {
|
|
|
|
if (aMetrics.mComputeMEW) {
|
|
|
|
aMetrics.mMaxElementWidth = 0;
|
|
|
|
}
|
2002-04-13 05:53:23 +04:00
|
|
|
return;
|
2003-04-12 08:55:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aMetrics.width = aReflowState.mComputedWidth;
|
|
|
|
aMetrics.height = aReflowState.mComputedHeight;
|
2002-04-13 05:53:23 +04:00
|
|
|
|
2001-09-18 06:11:09 +04:00
|
|
|
// for EMBED and APPLET, default to 240x200 for compatibility
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *atom = mContent->Tag();
|
2003-04-12 08:55:07 +04:00
|
|
|
if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
|
2004-07-29 23:41:39 +04:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
2003-04-12 08:55:07 +04:00
|
|
|
if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
|
2003-04-15 23:28:06 +04:00
|
|
|
aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t),
|
|
|
|
aReflowState.mComputedMinWidth),
|
|
|
|
aReflowState.mComputedMaxWidth);
|
2003-04-12 08:55:07 +04:00
|
|
|
}
|
|
|
|
if (aMetrics.height == NS_UNCONSTRAINEDSIZE) {
|
2003-04-15 23:28:06 +04:00
|
|
|
aMetrics.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t),
|
|
|
|
aReflowState.mComputedMinHeight),
|
|
|
|
aReflowState.mComputedMaxHeight);
|
2003-04-12 08:55:07 +04:00
|
|
|
}
|
2003-11-13 19:33:52 +03:00
|
|
|
|
|
|
|
#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
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
// 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) {
|
2003-04-15 23:28:06 +04:00
|
|
|
aMetrics.width =
|
|
|
|
(aReflowState.mComputedMinWidth != NS_UNCONSTRAINEDSIZE) ?
|
|
|
|
aReflowState.mComputedMinWidth : 0;
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
// 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) {
|
2003-04-15 23:28:06 +04:00
|
|
|
aMetrics.height =
|
|
|
|
(aReflowState.mComputedMinHeight != NS_UNCONSTRAINEDSIZE) ?
|
|
|
|
aReflowState.mComputedMinHeight : 0;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
// 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.
|
2002-03-07 18:22:24 +03:00
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
// ascent
|
1999-07-07 06:33:17 +04:00
|
|
|
aMetrics.ascent = aMetrics.height;
|
2001-09-18 06:11:09 +04:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aMetrics.mComputeMEW) {
|
|
|
|
aMetrics.mMaxElementWidth = aMetrics.width;
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
static void
|
2005-03-31 05:38:04 +04:00
|
|
|
SizeAnchor(nsIContent *aAnchor, PRInt32 aWidth, PRInt32 aHeight)
|
2005-01-05 03:21:06 +03:00
|
|
|
{
|
2005-03-31 05:38:04 +04:00
|
|
|
nsCOMPtr<nsIDOMElementCSSInlineStyle> element(do_QueryInterface(aAnchor));
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (!element)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> style;
|
|
|
|
element->GetStyle(getter_AddRefs(style));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMCSS2Properties> css2props(do_QueryInterface(style));
|
|
|
|
|
|
|
|
if (!css2props) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
tmp.AppendInt(aWidth);
|
2005-09-21 23:14:30 +04:00
|
|
|
tmp.AppendLiteral("px");
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
css2props->SetWidth(tmp);
|
|
|
|
|
|
|
|
tmp.Truncate();
|
|
|
|
tmp.AppendInt(aHeight);
|
2005-09-21 23:14:30 +04:00
|
|
|
tmp.AppendLiteral("px");
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
css2props->SetHeight(tmp);
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP
|
2005-01-05 03:21:06 +03:00
|
|
|
nsObjectFrame::Reflow(nsPresContext* aPresContext,
|
1999-07-07 06:33:17 +04:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 18:59:47 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsObjectFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
1999-07-07 06:33:17 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
// If we have a child, we toss the reflow over to it.
|
|
|
|
nsIFrame * child = mFrames.FirstChild();
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2005-07-21 21:40:03 +04:00
|
|
|
// 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));
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-07-21 21:40:03 +04:00
|
|
|
float t2p = aPresContext->TwipsToPixels();
|
|
|
|
PRInt32 width = NSTwipsToIntPixels(aMetrics.width - state.mComputedBorderPadding.LeftRight(), t2p);
|
|
|
|
PRInt32 height = NSTwipsToIntPixels(aMetrics.height - state.mComputedBorderPadding.TopBottom(), t2p);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-07-21 21:40:03 +04:00
|
|
|
// Set the child's content width and height
|
2005-03-31 05:38:04 +04:00
|
|
|
SizeAnchor(child->GetContent(), width, height);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
// SizeAnchor() is seriously evil as it ends up setting an
|
2005-01-05 03:21:06 +03:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-12 08:55:07 +04:00
|
|
|
if (child) {
|
|
|
|
// Reflow the child; our size just depends on that of the child,
|
|
|
|
// pure and simple
|
|
|
|
return HandleChild(aPresContext, aMetrics, aReflowState, aStatus, child);
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
// Get our desired size
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aMetrics);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2004-06-02 04:25:00 +04:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2002-03-26 14:43:40 +03:00
|
|
|
// if we are printing or print previewing, bail for now
|
2004-07-29 23:41:39 +04:00
|
|
|
if (aPresContext->Medium() == nsLayoutAtoms::print) {
|
2001-09-05 06:45:48 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return rv;
|
|
|
|
}
|
2001-03-30 07:07:52 +04:00
|
|
|
|
2001-12-20 09:49:16 +03:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
FixupWindow(nsSize(aMetrics.width, aMetrics.height));
|
2004-06-02 04:25:00 +04:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
2001-05-19 06:45:21 +04:00
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2005-09-21 23:14:30 +04:00
|
|
|
nsObjectFrame::InstantiatePlugin(nsIPluginHost* aPluginHost,
|
2005-01-05 03:21:06 +03:00
|
|
|
const char* aMimeType,
|
2001-05-22 02:40:10 +04:00
|
|
|
nsIURI* aURI)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
mFullURL = aURI;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-04-15 01:50:46 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInstantiating = PR_TRUE;
|
|
|
|
#endif
|
|
|
|
|
2003-03-22 06:20:23 +03:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
nsresult rv = mInstanceOwner->GetDocument(getter_AddRefs(doc));
|
|
|
|
nsCOMPtr<nsIPluginDocument> pDoc (do_QueryInterface(doc));
|
|
|
|
|
|
|
|
if (pDoc) { /* full-page mode */
|
2005-04-29 16:11:45 +04:00
|
|
|
nsCOMPtr<nsIStreamListener> stream;
|
|
|
|
rv = aPluginHost->InstantiateFullPagePlugin(aMimeType, aURI,
|
|
|
|
/* resulting stream listener */ *getter_AddRefs(stream),
|
|
|
|
mInstanceOwner);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
pDoc->SetStreamListener(stream);
|
2003-03-22 06:20:23 +03:00
|
|
|
} else { /* embedded mode */
|
2005-06-09 03:42:15 +04:00
|
|
|
rv = aPluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI,
|
|
|
|
mInstanceOwner);
|
2003-03-22 06:20:23 +03:00
|
|
|
}
|
2005-04-15 01:50:46 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInstantiating = PR_FALSE;
|
|
|
|
#endif
|
2003-03-22 06:20:23 +03:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// XXX having to do this sucks. it'd be better to move the code from DidReflow
|
|
|
|
// to FixupWindow or something.
|
|
|
|
nsIPresShell *shell = GetPresContext()->GetPresShell();
|
|
|
|
shell->AppendReflowCommand(this, eReflowType_StyleChanged, nsnull);
|
2003-03-22 06:20:23 +03:00
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
void
|
|
|
|
nsObjectFrame::FixupWindow(const nsSize& aSize)
|
1999-09-30 12:07:23 +04:00
|
|
|
{
|
2005-09-21 23:14:30 +04:00
|
|
|
nsPresContext* presContext = GetPresContext();
|
1999-09-30 12:07:23 +04:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
float t2p = presContext->TwipsToPixels();
|
|
|
|
|
|
|
|
if (!mInstanceOwner)
|
|
|
|
return;
|
1999-09-30 12:07:23 +04:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
nsPluginWindow *window;
|
1999-09-30 12:07:23 +04:00
|
|
|
mInstanceOwner->GetWindow(window);
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_ENSURE_TRUE(window, /**/);
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
nsPoint origin;
|
|
|
|
nsIView *parentWithView;
|
|
|
|
GetOffsetFromView(origin, &parentWithView);
|
1999-09-30 12:07:23 +04:00
|
|
|
window->x = NSTwipsToIntPixels(origin.x, t2p);
|
|
|
|
window->y = NSTwipsToIntPixels(origin.y, t2p);
|
2005-09-21 23:14:30 +04:00
|
|
|
window->width = NSTwipsToIntPixels(aSize.width, t2p);
|
|
|
|
window->height = NSTwipsToIntPixels(aSize.height, t2p);
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// 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.
|
1999-09-30 12:07:23 +04:00
|
|
|
window->clipRect.top = 0;
|
|
|
|
window->clipRect.left = 0;
|
2005-09-21 23:14:30 +04:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
|
|
|
window->clipRect.bottom = NSTwipsToIntPixels(aSize.height, t2p);
|
|
|
|
window->clipRect.right = NSTwipsToIntPixels(aSize.width, t2p);
|
|
|
|
#else
|
|
|
|
window->clipRect.bottom = 0;
|
|
|
|
window->clipRect.right = 0;
|
2001-01-12 02:56:35 +03:00
|
|
|
#endif
|
1999-09-30 12:07:23 +04:00
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
nsresult
|
2005-01-05 03:21:06 +03:00
|
|
|
nsObjectFrame::HandleChild(nsPresContext* aPresContext,
|
2001-01-12 02:56:35 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* child)
|
|
|
|
{
|
2005-01-05 03:21:06 +03:00
|
|
|
// 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
|
2005-04-29 01:57:22 +04:00
|
|
|
// 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.
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-01-24 04:30:50 +03:00
|
|
|
nsReflowStatus status;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
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);
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2003-02-15 21:25:02 +03:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
PRBool
|
|
|
|
nsObjectFrame::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse)
|
|
|
|
{
|
2005-04-01 20:41:55 +04:00
|
|
|
if (aTabIndex)
|
|
|
|
*aTabIndex = -1;
|
2005-03-31 05:38:04 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2000-07-20 03:46:43 +04:00
|
|
|
PRBool
|
2002-04-13 05:53:23 +04:00
|
|
|
nsObjectFrame::IsHidden(PRBool aCheckVisibilityStyle) const
|
2000-07-20 03:46:43 +04:00
|
|
|
{
|
2002-04-13 05:53:23 +04:00
|
|
|
if (aCheckVisibilityStyle) {
|
2003-05-15 07:42:21 +04:00
|
|
|
if (!GetStyleVisibility()->IsVisibleOrCollapsed())
|
2002-04-13 05:53:23 +04:00
|
|
|
return PR_TRUE;
|
2000-09-04 00:54:26 +04:00
|
|
|
}
|
|
|
|
|
2002-04-13 05:53:23 +04:00
|
|
|
// only <embed> tags support the HIDDEN attribute
|
2003-11-19 04:20:56 +03:00
|
|
|
if (mContent->Tag() == nsHTMLAtoms::embed) {
|
2000-07-20 03:46:43 +04:00
|
|
|
// 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...
|
2003-11-19 04:20:56 +03:00
|
|
|
|
|
|
|
// 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.
|
2005-10-28 15:25:24 +04:00
|
|
|
nsAutoString hidden;
|
|
|
|
if (mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden) &&
|
2003-01-29 00:59:28 +03:00
|
|
|
(hidden.IsEmpty() ||
|
2004-06-17 04:13:25 +04:00
|
|
|
!hidden.LowerCaseEqualsLiteral("false") &&
|
|
|
|
!hidden.LowerCaseEqualsLiteral("no") &&
|
|
|
|
!hidden.LowerCaseEqualsLiteral("off"))) {
|
2000-07-20 03:46:43 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
nsPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless)
|
2001-12-22 03:00:44 +03:00
|
|
|
{
|
|
|
|
nsIView * parentWithView;
|
2002-01-15 02:16:37 +03:00
|
|
|
nsPoint origin(0,0);
|
2001-12-22 03:00:44 +03:00
|
|
|
|
2004-12-26 22:48:54 +03:00
|
|
|
GetOffsetFromView(origin, &parentWithView);
|
2001-12-22 03:00:44 +03:00
|
|
|
|
2002-05-03 00:46:22 +04:00
|
|
|
// 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) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIViewManager* parentVM = parentWithView->GetViewManager();
|
2002-05-03 00:46:22 +04:00
|
|
|
|
|
|
|
// Walk up all the views and add up their positions. This will give us our
|
|
|
|
// absolute position which is what we want to give the plugin
|
|
|
|
nsIView* theView = parentWithView;
|
|
|
|
while (theView) {
|
2003-06-30 14:46:59 +04:00
|
|
|
if (theView->GetViewManager() != parentVM)
|
2002-05-03 00:46:22 +04:00
|
|
|
break;
|
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
origin += theView->GetPosition();
|
|
|
|
theView = theView->GetParent();
|
2002-05-03 00:46:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-22 03:00:44 +03:00
|
|
|
float t2p;
|
2004-12-26 22:48:54 +03:00
|
|
|
t2p = GetPresContext()->TwipsToPixels();
|
2004-02-09 20:33:45 +03:00
|
|
|
origin.x = NSTwipsToIntPixels(origin.x, t2p);
|
|
|
|
origin.y = NSTwipsToIntPixels(origin.y, t2p);
|
2001-12-22 03:00:44 +03:00
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
return origin;
|
2001-12-22 03:00:44 +03:00
|
|
|
}
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
void
|
|
|
|
nsObjectFrame::CreateDefaultFrames(nsPresContext *aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2005-04-02 19:47:13 +04:00
|
|
|
nsCOMPtr<nsIHTMLDocument> htmldoc(do_QueryInterface(doc));
|
|
|
|
PRInt32 id;
|
|
|
|
if (htmldoc && !doc->IsCaseSensitive())
|
|
|
|
id = kNameSpaceID_None;
|
|
|
|
else
|
|
|
|
id = kNameSpaceID_XHTML;
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
nsCOMPtr<nsIContent> anchor;
|
2005-06-30 05:30:34 +04:00
|
|
|
nsresult rv = doc->CreateElem(nsHTMLAtoms::a, nsnull, id, htmldoc != nsnull,
|
|
|
|
getter_AddRefs(anchor));
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> img;
|
2005-06-30 05:30:34 +04:00
|
|
|
rv |= doc->CreateElem(nsHTMLAtoms::img, nsnull, id, htmldoc != nsnull,
|
2005-01-05 03:21:06 +03:00
|
|
|
getter_AddRefs(img));
|
|
|
|
|
|
|
|
nsCOMPtr<nsITextContent> text;
|
2005-09-24 22:43:15 +04:00
|
|
|
rv |= NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Mark the nodes anonymous
|
2005-03-31 05:38:04 +04:00
|
|
|
anchor->SetNativeAnonymous(PR_TRUE);
|
2005-01-05 03:21:06 +03:00
|
|
|
img->SetNativeAnonymous(PR_TRUE);
|
|
|
|
text->SetNativeAnonymous(PR_TRUE);
|
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
// 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();
|
2005-04-06 04:42:41 +04:00
|
|
|
return;
|
2005-04-06 03:54:35 +04:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-04-19 02:58:35 +04:00
|
|
|
anchor->AppendChildTo(img, PR_FALSE);
|
|
|
|
anchor->AppendChildTo(text, PR_FALSE);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
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;"
|
2005-03-31 05:38:04 +04:00
|
|
|
"text-decoration: none;"
|
2005-01-05 03:21:06 +03:00
|
|
|
"color: black;", style);
|
|
|
|
|
|
|
|
// Style things and load the image
|
2005-03-31 05:38:04 +04:00
|
|
|
anchor->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style, style, PR_TRUE);
|
|
|
|
anchor->SetAttr(kNameSpaceID_None, nsHTMLAtoms::href, NS_LITERAL_STRING("#"), PR_TRUE);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(src,
|
|
|
|
"chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png");
|
|
|
|
img->SetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src, PR_FALSE);
|
2005-03-31 05:38:04 +04:00
|
|
|
NS_NAMED_LITERAL_STRING(imgStyle,
|
|
|
|
"display: block; border: 0px; width: 32px; height: 32px;");
|
|
|
|
img->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style, imgStyle, PR_FALSE);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
// Kick off the image load.
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(img);
|
2005-09-21 23:14:30 +04:00
|
|
|
// XXX imageLoader->ImageURIChanged(src);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
// 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))
|
2005-09-21 23:14:30 +04:00
|
|
|
missingPluginLabel.AssignLiteral("Click here to download plugin.");
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
text->SetText(missingPluginLabel, PR_FALSE);
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
// Resolve style for the anchor, img, and text nodes.
|
|
|
|
nsRefPtr<nsStyleContext> anchorStyleContext =
|
|
|
|
styleSet->ResolveStyleFor(anchor, mStyleContext);
|
2005-01-05 03:21:06 +03:00
|
|
|
nsRefPtr<nsStyleContext> imgStyleContext =
|
2005-03-31 05:38:04 +04:00
|
|
|
styleSet->ResolveStyleFor(img, anchorStyleContext);
|
2005-01-05 03:21:06 +03:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext =
|
2005-03-31 05:38:04 +04:00
|
|
|
shell->StyleSet()->ResolveStyleForNonElement(anchorStyleContext);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
if (!anchorStyleContext || !imgStyleContext || !textStyleContext)
|
2005-01-05 03:21:06 +03:00
|
|
|
return;
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
nsIFrame *anchorFrame = nsnull;
|
2005-01-05 03:21:06 +03:00
|
|
|
nsIFrame *imgFrame = nsnull;
|
|
|
|
nsIFrame *textFrame = nsnull;
|
|
|
|
|
|
|
|
do {
|
2005-11-04 05:38:33 +03:00
|
|
|
anchorFrame = NS_NewBlockFrame(shell);
|
|
|
|
if (NS_UNLIKELY(!anchorFrame)) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2005-01-05 03:21:06 +03:00
|
|
|
break;
|
2005-11-04 05:38:33 +03:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
rv = anchorFrame->Init(aPresContext, anchor, this, anchorStyleContext, PR_FALSE);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
2005-03-18 07:13:05 +03:00
|
|
|
// Give it a space manager, so it won't crash of ancestors don't have one
|
2005-03-31 05:38:04 +04:00
|
|
|
anchorFrame->AddStateBits(NS_BLOCK_SPACE_MGR | NS_BLOCK_MARGIN_ROOT);
|
2005-03-18 07:13:05 +03:00
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
nsHTMLContainerFrame::CreateViewForFrame(anchorFrame, this, PR_FALSE);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
imgFrame = NS_NewImageFrame(shell);
|
|
|
|
if (NS_UNLIKELY(!imgFrame))
|
2005-01-05 03:21:06 +03:00
|
|
|
return;
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
rv = imgFrame->Init(aPresContext, img, anchorFrame, imgStyleContext, PR_FALSE);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
nsHTMLContainerFrame::CreateViewForFrame(imgFrame, anchorFrame, PR_FALSE);
|
|
|
|
anchorFrame->AppendFrames(nsnull, imgFrame);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
textFrame = NS_NewTextFrame(shell);
|
|
|
|
if (NS_UNLIKELY(!textFrame)) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2005-01-05 03:21:06 +03:00
|
|
|
break;
|
2005-11-04 05:38:33 +03:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
rv = textFrame->Init(aPresContext, text, anchorFrame, textStyleContext,
|
2005-01-05 03:21:06 +03:00
|
|
|
PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
textFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
|
|
|
|
|
2005-03-31 05:38:04 +04:00
|
|
|
anchorFrame->AppendFrames(nsnull, textFrame);
|
2005-01-05 03:21:06 +03:00
|
|
|
} while (0);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2005-03-31 05:38:04 +04:00
|
|
|
if (anchorFrame)
|
|
|
|
anchorFrame->Destroy(aPresContext);
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (imgFrame)
|
|
|
|
imgFrame->Destroy(aPresContext);
|
|
|
|
|
|
|
|
if (textFrame)
|
|
|
|
textFrame->Destroy(aPresContext);
|
2005-05-06 07:14:31 +04:00
|
|
|
} else {
|
|
|
|
// Creation of all our anonymous content succeeded.
|
|
|
|
mFrames.AppendFrame(this, anchorFrame);
|
2005-01-05 03:21:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> array;
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(array));
|
|
|
|
|
|
|
|
if (array) {
|
2005-03-31 05:38:04 +04:00
|
|
|
array->AppendElement(anchor);
|
2005-01-05 03:21:06 +03:00
|
|
|
array->AppendElement(img);
|
|
|
|
array->AppendElement(text);
|
|
|
|
|
|
|
|
shell->SetAnonymousContentFor(mContent, array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP
|
2005-01-05 03:21:06 +03:00
|
|
|
nsObjectFrame::DidReflow(nsPresContext* aPresContext,
|
2001-12-07 17:51:12 +03:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2001-12-07 17:51:12 +03:00
|
|
|
nsresult rv = nsObjectFrameSuper::DidReflow(aPresContext, aReflowState, aStatus);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
// The view is created hidden; once we have reflowed it and it has been
|
|
|
|
// positioned then we show it.
|
2002-04-13 06:43:58 +04:00
|
|
|
if (aStatus != NS_FRAME_REFLOW_FINISHED)
|
2001-12-22 03:00:44 +03:00
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-04-13 06:43:58 +04:00
|
|
|
PRBool bHidden = IsHidden();
|
|
|
|
|
2003-06-20 03:44:01 +04:00
|
|
|
if (HasView()) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIView* view = GetView();
|
|
|
|
nsIViewManager* vm = view->GetViewManager();
|
2001-12-22 03:00:44 +03:00
|
|
|
if (vm)
|
2002-04-13 06:43:58 +04:00
|
|
|
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
|
2001-12-22 03:00:44 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
nsPluginWindow *win = nsnull;
|
2002-05-03 02:47:49 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginInstance> pi;
|
|
|
|
if (!mInstanceOwner ||
|
|
|
|
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
|
|
|
|
!pi ||
|
2004-09-04 01:49:13 +04:00
|
|
|
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
|
2002-09-26 06:53:27 +04:00
|
|
|
!win)
|
2001-12-22 03:00:44 +03:00
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2003-02-28 02:35:47 +03:00
|
|
|
mInstanceOwner->FixUpPluginWindow(ePluginPaintDisable);
|
2002-11-06 04:24:57 +03:00
|
|
|
#endif // XP_MAC || XP_MACOSX
|
2001-08-07 05:50:32 +04:00
|
|
|
|
2002-05-03 02:47:49 +04:00
|
|
|
if (bHidden)
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
PRBool windowless = (window->type == nsPluginWindowType_Drawable);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (windowless)
|
2001-12-22 03:00:44 +03:00
|
|
|
return rv;
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
nsPoint origin = GetWindowOriginInPixels(windowless);
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2001-12-22 03:00:44 +03:00
|
|
|
window->x = origin.x;
|
|
|
|
window->y = origin.y;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-22 03:00:44 +03:00
|
|
|
// refresh the plugin port as well
|
|
|
|
window->window = mInstanceOwner->GetPluginPort();
|
2002-09-26 06:53:27 +04:00
|
|
|
|
|
|
|
// this will call pi->SetWindow and take care of window subclassing
|
|
|
|
// if needed, see bug 132759
|
|
|
|
window->CallSetWindow(pi);
|
|
|
|
|
2001-12-22 03:00:44 +03:00
|
|
|
mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-01-05 03:21:06 +03:00
|
|
|
nsObjectFrame::Paint(nsPresContext* aPresContext,
|
1999-07-07 06:33:17 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2003-05-15 07:42:21 +04:00
|
|
|
if (!GetStyleVisibility()->IsVisibleOrCollapsed())
|
2001-03-30 07:07:52 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsIFrame * child = mFrames.FirstChild();
|
2001-09-18 06:11:09 +04:00
|
|
|
if (child) { // if we have children, we are probably not really a plugin
|
2001-03-30 07:07:52 +04:00
|
|
|
nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-03-26 14:43:40 +03:00
|
|
|
// If we are painting in Print Preview do nothing....
|
2004-08-01 03:15:21 +04:00
|
|
|
if (aPresContext->Type() == nsPresContext::eContext_PrintPreview) {
|
2002-03-26 14:43:40 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-18 06:11:09 +04:00
|
|
|
// determine if we are printing
|
2004-08-01 03:15:21 +04:00
|
|
|
if (aPresContext->Type() == nsPresContext::eContext_Print) {
|
2002-03-26 14:43:40 +03:00
|
|
|
// UNIX Plugins can't PP at this time, so draw an empty box
|
2001-09-18 06:11:09 +04:00
|
|
|
// 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
|
2003-07-29 01:25:13 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
2001-09-18 06:11:09 +04:00
|
|
|
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
|
2003-09-27 08:18:26 +04:00
|
|
|
nsIPresShell *shell = doc->GetShellAt(0);
|
2001-09-18 06:11:09 +04:00
|
|
|
NS_ENSURE_TRUE(shell, NS_ERROR_NULL_POINTER);
|
|
|
|
|
|
|
|
// then the shell can give us the screen frame for this content node
|
2005-08-23 02:24:29 +04:00
|
|
|
nsIFrame* frame = shell->GetPrimaryFrameFor(mContent);
|
2001-09-18 06:11:09 +04:00
|
|
|
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)
|
2004-02-09 20:33:45 +03:00
|
|
|
objectFrame = GetNextObjectFrame(aPresContext,frame);
|
2001-09-18 06:11:09 +04:00
|
|
|
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
|
2002-03-22 07:19:10 +03:00
|
|
|
PRBool windowless = PR_FALSE;
|
2001-09-18 06:11:09 +04:00
|
|
|
pi->GetValue(nsPluginInstanceVariable_WindowlessBool, (void *)&windowless);
|
|
|
|
window.type = windowless ? nsPluginWindowType_Drawable : nsPluginWindowType_Window;
|
|
|
|
|
2003-11-19 05:00:51 +03:00
|
|
|
// Get the offset of the DC
|
|
|
|
nsTransform2D* rcTransform;
|
|
|
|
aRenderingContext.GetCurrentTransform(rcTransform);
|
|
|
|
rcTransform->GetTranslationCoord(&origin.x, &origin.y);
|
2002-02-16 08:12:45 +03:00
|
|
|
|
2003-11-19 05:00:51 +03:00
|
|
|
// Get the conversion factor between pixels and twips
|
2004-02-11 07:57:07 +03:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
2001-09-18 06:11:09 +04:00
|
|
|
|
|
|
|
// set it all up
|
|
|
|
// XXX is windowless different?
|
2003-11-19 05:00:51 +03:00
|
|
|
window.x = origin.x;
|
|
|
|
window.y = origin.y;
|
2001-09-18 06:11:09 +04:00
|
|
|
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
|
2005-09-21 23:14:30 +04:00
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
2003-07-23 18:10:12 +04:00
|
|
|
/* 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();
|
2005-01-05 03:21:06 +03:00
|
|
|
if (!plugintmpfile) {
|
2003-07-23 18:10:12 +04:00
|
|
|
PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("error: could not open tmp. file, errno=%d\n", errno));
|
|
|
|
return NS_ERROR_FAILURE;
|
2002-01-01 15:58:53 +03:00
|
|
|
}
|
2003-07-23 18:10:12 +04:00
|
|
|
|
|
|
|
/* Send off print info to plugin */
|
2001-09-18 06:11:09 +04:00
|
|
|
NPPrintCallbackStruct npPrintInfo;
|
|
|
|
npPrintInfo.type = NP_PRINT;
|
2003-07-23 18:10:12 +04:00
|
|
|
npPrintInfo.fp = plugintmpfile;
|
|
|
|
npprint.print.embedPrint.platformPrint = (void *)&npPrintInfo;
|
2004-09-20 10:46:16 +04:00
|
|
|
/* aDirtyRect contains the right information for ps print */
|
|
|
|
window.x = aDirtyRect.x;
|
|
|
|
window.y = aDirtyRect.y;
|
|
|
|
window.width = aDirtyRect.width;
|
|
|
|
window.height = aDirtyRect.height;
|
2003-07-23 18:10:12 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-09-20 10:46:16 +04:00
|
|
|
/* Send data to printer */
|
|
|
|
rv = aRenderingContext.RenderEPS(aDirtyRect, plugintmpfile);
|
2003-07-23 18:10:12 +04:00
|
|
|
|
|
|
|
fclose(plugintmpfile);
|
|
|
|
|
|
|
|
PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("plugin printing done, return code is %lx\n", (long)rv));
|
2001-09-18 06:11:09 +04:00
|
|
|
|
|
|
|
#else // Windows and non-UNIX, non-Mac(Classic) cases
|
2003-07-23 18:10:12 +04:00
|
|
|
|
2001-09-18 06:11:09 +04:00
|
|
|
// we need the native printer device context to pass to plugin
|
|
|
|
// On Windows, this will be the HDC
|
2005-08-23 06:11:54 +04:00
|
|
|
void* dc;
|
|
|
|
dc = aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC);
|
2001-09-18 06:11:09 +04:00
|
|
|
|
2005-08-23 06:11:54 +04:00
|
|
|
npprint.print.embedPrint.platformPrint = dc;
|
2001-09-18 06:11:09 +04:00
|
|
|
npprint.print.embedPrint.window = window;
|
|
|
|
// send off print info to plugin
|
|
|
|
rv = pi->Print(&npprint);
|
|
|
|
|
2003-07-23 18:10:12 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-18 06:11:09 +04:00
|
|
|
// 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?
|
2004-08-21 00:34:37 +04:00
|
|
|
frame->DidReflow(shell->GetPresContext(),
|
|
|
|
nsnull, status); // DidReflow will take care of it
|
2001-09-18 06:11:09 +04:00
|
|
|
|
|
|
|
return rv; // done with printing
|
|
|
|
}
|
|
|
|
|
|
|
|
// Screen painting code
|
2003-02-28 02:35:47 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2001-11-13 03:30:44 +03:00
|
|
|
// delegate all painting to the plugin instance.
|
2002-06-21 22:28:46 +04:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) && mInstanceOwner)
|
2001-11-13 03:30:44 +03:00
|
|
|
mInstanceOwner->Paint(aDirtyRect);
|
2003-04-03 02:45:08 +04:00
|
|
|
#elif defined (XP_WIN) || defined(XP_OS2)
|
2001-11-13 03:30:44 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
2004-09-04 01:49:13 +04:00
|
|
|
nsCOMPtr<nsIPluginInstance> inst;
|
|
|
|
GetPluginInstance(*getter_AddRefs(inst));
|
|
|
|
if (inst) {
|
2001-11-13 03:30:44 +03:00
|
|
|
// Look if it's windowless
|
|
|
|
nsPluginWindow * window;
|
|
|
|
mInstanceOwner->GetWindow(window);
|
|
|
|
|
|
|
|
if (window->type == nsPluginWindowType_Drawable) {
|
2001-12-22 03:21:12 +03:00
|
|
|
// check if we need to call SetWindow with updated parameters
|
|
|
|
PRBool doupdatewindow = PR_FALSE;
|
|
|
|
|
|
|
|
// check if we need to update hdc
|
2005-08-23 06:11:54 +04:00
|
|
|
void* hdc;
|
|
|
|
hdc = aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC);
|
|
|
|
if (NS_REINTERPRET_CAST(PRUint32, window->window) != (PRUint32)(HDC)hdc) {
|
2001-11-13 03:30:44 +03:00
|
|
|
window->window = NS_REINTERPRET_CAST(nsPluginPort*, hdc);
|
2001-12-22 03:21:12 +03:00
|
|
|
doupdatewindow = PR_TRUE;
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
2001-12-22 03:21:12 +03:00
|
|
|
|
2002-05-03 00:46:22 +04:00
|
|
|
/*
|
|
|
|
* Layout now has an optimized way of painting. Now we always get
|
2005-10-29 16:56:44 +04:00
|
|
|
* a new drawing surface, sized to be just what's needed. Windowless
|
2002-05-03 00:46:22 +04:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2002-03-08 18:49:43 +03:00
|
|
|
// Get the offset of the DC
|
|
|
|
nsTransform2D* rcTransform;
|
|
|
|
aRenderingContext.GetCurrentTransform(rcTransform);
|
2001-12-22 03:21:12 +03:00
|
|
|
nsPoint origin;
|
2002-03-08 18:49:43 +03:00
|
|
|
rcTransform->GetTranslationCoord(&origin.x, &origin.y);
|
2001-12-22 03:21:12 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if ((window->x != origin.x) || (window->y != origin.y)) {
|
2001-12-22 03:21:12 +03:00
|
|
|
window->x = origin.x;
|
|
|
|
window->y = origin.y;
|
|
|
|
doupdatewindow = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-03 00:46:22 +04:00
|
|
|
// if our location or visible area has changed, we need to tell the plugin
|
2005-01-05 03:21:06 +03:00
|
|
|
if (doupdatewindow) {
|
2002-05-03 00:46:22 +04:00
|
|
|
#ifdef XP_WIN // Windowless plugins on windows need a special event to update their location, see bug 135737
|
|
|
|
|
|
|
|
// first, lets find out how big the window is, in pixels
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIViewManager* vm = aPresContext->GetViewManager();
|
|
|
|
if (vm) {
|
2004-05-17 20:29:13 +04:00
|
|
|
nsIView* view;
|
|
|
|
vm->GetRootView(view);
|
|
|
|
if (view) {
|
|
|
|
nsIWidget* win = view->GetWidget();
|
2002-05-03 00:46:22 +04:00
|
|
|
if (win) {
|
|
|
|
nsRect visibleRect;
|
|
|
|
win->GetBounds(visibleRect);
|
|
|
|
|
|
|
|
// next, get our plugin's rect so we can intersect it with the visible rect so we
|
|
|
|
// can tell the plugin where and how much to paint
|
2004-02-09 20:33:45 +03:00
|
|
|
origin = GetWindowOriginInPixels(window->type);
|
2002-05-03 00:46:22 +04:00
|
|
|
nsRect winlessRect = nsRect(origin, nsSize(window->width, window->height));
|
|
|
|
winlessRect.IntersectRect(winlessRect, visibleRect);
|
|
|
|
|
|
|
|
// now check our cached window and only update plugin if something has changed
|
|
|
|
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;
|
2005-09-28 18:29:45 +04:00
|
|
|
pluginEvent.event = WM_WINDOWPOSCHANGED;
|
2002-05-03 00:46:22 +04:00
|
|
|
pluginEvent.wParam = 0;
|
|
|
|
pluginEvent.lParam = (uint32)&winpos;
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
|
|
|
|
inst->HandleEvent(&pluginEvent, &eventHandled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-17 20:29:13 +04:00
|
|
|
}
|
2002-05-03 00:46:22 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
inst->SetWindow(window);
|
|
|
|
}
|
2001-12-22 03:21:12 +03:00
|
|
|
|
2005-08-23 06:11:54 +04:00
|
|
|
mInstanceOwner->Paint(aDirtyRect, (PRUint32)(HDC)hdc);
|
2001-11-13 03:30:44 +03:00
|
|
|
}
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
2001-11-13 03:30:44 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif /* !XP_MAC */
|
2001-11-13 03:30:44 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsObjectFrame", &aRenderingContext);
|
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsObjectFrame::HandleEvent(nsPresContext* aPresContext,
|
2004-04-13 05:51:00 +04:00
|
|
|
nsGUIEvent* anEvent,
|
|
|
|
nsEventStatus* anEventStatus)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2004-04-10 04:25:01 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(anEventStatus);
|
|
|
|
nsresult rv = NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
1999-09-28 04:13:19 +04:00
|
|
|
//FIX FOR CRASHING WHEN NO INSTANCE OWVER
|
|
|
|
if (!mInstanceOwner)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-04-25 01:03:27 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (anEvent->message == NS_PLUGIN_ACTIVATE) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = GetContent();
|
2005-01-05 03:21:06 +03:00
|
|
|
if (content) {
|
2001-04-25 01:03:27 +04:00
|
|
|
content->SetFocus(aPresContext);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
rv = nsObjectFrameSuper::HandleEvent(aPresContext, anEvent, anEventStatus);
|
|
|
|
return rv;
|
|
|
|
#endif
|
|
|
|
|
2005-09-28 18:29:45 +04:00
|
|
|
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;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance)
|
|
|
|
{
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
aPluginInstance = nsnull;
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mInstanceOwner == nsnull)
|
2000-02-16 04:49:42 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2004-09-04 01:49:13 +04:00
|
|
|
|
|
|
|
return mInstanceOwner->GetInstance(aPluginInstance);
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
nsresult
|
|
|
|
nsObjectFrame::PrepareInstanceOwner()
|
|
|
|
{
|
2005-10-31 21:28:56 +03:00
|
|
|
// First, have to stop any possibly running plugins.
|
|
|
|
StopPlugin();
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2005-10-31 21:28:56 +03:00
|
|
|
NS_ASSERTION(!mInstanceOwner, "Must not have an instance owner here");
|
|
|
|
|
|
|
|
mInstanceOwner = new nsPluginInstanceOwner();
|
|
|
|
if (!mInstanceOwner)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(mInstanceOwner);
|
|
|
|
mInstanceOwner->Init(GetPresContext(), this);
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsObjectFrame::Instantiate(nsIChannel* aChannel, nsIStreamListener** aStreamListener)
|
|
|
|
{
|
|
|
|
nsresult rv = PrepareInstanceOwner();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(kCPluginManagerCID, &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
mInstanceOwner->SetPluginHost(pluginHost);
|
|
|
|
|
|
|
|
// This must be done before instantiating the plugin
|
|
|
|
FixupWindow(mRect.Size());
|
|
|
|
|
|
|
|
aChannel->GetURI(getter_AddRefs(mFullURL));
|
|
|
|
|
|
|
|
rv = pluginHost->InstantiatePluginForChannel(aChannel, mInstanceOwner, aStreamListener);
|
|
|
|
|
|
|
|
// XXX having to do this sucks. it'd be better to move the code from DidReflow
|
|
|
|
// to FixupWindow.
|
|
|
|
nsIPresShell *shell = GetPresContext()->GetPresShell();
|
|
|
|
shell->AppendReflowCommand(this, eReflowType_StyleChanged, nsnull);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI)
|
|
|
|
{
|
2005-10-29 16:56:44 +04:00
|
|
|
NS_ASSERTION(aMimeType || aURI, "Need a type or a URI!");
|
2005-09-21 23:14:30 +04:00
|
|
|
nsresult rv = PrepareInstanceOwner();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// This must be done before instantiating the plugin
|
|
|
|
FixupWindow(mRect.Size());
|
|
|
|
|
|
|
|
// get the nsIPluginHost service
|
|
|
|
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(kCPluginManagerCID, &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
mInstanceOwner->SetPluginHost(pluginHost);
|
|
|
|
|
2005-10-29 16:56:44 +04:00
|
|
|
rv = InstantiatePlugin(pluginHost, aMimeType, aURI);
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
// finish up
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
NotifyContentObjectWrapper();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-10-31 21:28:56 +03:00
|
|
|
void
|
|
|
|
nsObjectFrame::StopPlugin()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
void
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
nsObjectFrame::NotifyContentObjectWrapper()
|
|
|
|
{
|
2003-07-29 01:25:13 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
2004-02-09 20:33:45 +03:00
|
|
|
if (!doc)
|
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
|
2004-02-09 20:33:45 +03:00
|
|
|
if (!sgo)
|
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2004-02-10 01:48:53 +03:00
|
|
|
nsIScriptContext *scx = sgo->GetContext();
|
2004-02-09 20:33:45 +03:00
|
|
|
if (!scx)
|
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
|
|
|
JSContext *cx = (JSContext *)scx->GetNativeContext();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
2004-09-01 20:50:12 +04:00
|
|
|
nsContentUtils::XPConnect()->
|
2005-08-12 08:11:00 +04:00
|
|
|
GetWrappedNativeOfNativeObject(cx, sgo->GetGlobalJSObject(), mContent,
|
2004-09-01 20:50:12 +04:00
|
|
|
NS_GET_IID(nsISupports),
|
|
|
|
getter_AddRefs(wrapper));
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
|
|
|
if (!wrapper) {
|
|
|
|
// Nothing to do here if there's no wrapper for mContent
|
2004-02-09 20:33:45 +03:00
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIClassInfo> ci(do_QueryInterface(mContent));
|
2004-02-09 20:33:45 +03:00
|
|
|
if (!ci)
|
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
|
|
|
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
|
2004-02-09 20:33:45 +03:00
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject *obj = nsnull;
|
2004-09-01 20:50:12 +04:00
|
|
|
nsresult rv = wrapper->GetJSObject(&obj);
|
2004-02-09 20:33:45 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
|
|
|
// Abuse the scriptable helper to trigger prototype setup for the
|
|
|
|
// wrapper for mContent so that this plugin becomes part of the DOM
|
|
|
|
// object.
|
2004-02-09 20:33:45 +03:00
|
|
|
helper->PostCreate(wrapper, cx, obj);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
}
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
// static
|
|
|
|
nsIObjectFrame *
|
|
|
|
nsObjectFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot)
|
2001-09-18 06:11:09 +04:00
|
|
|
{
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* child = aRoot->GetFirstChild(nsnull);
|
2001-09-18 06:11:09 +04:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
while (child) {
|
2004-02-09 20:33:45 +03:00
|
|
|
nsIObjectFrame* outFrame = nsnull;
|
|
|
|
CallQueryInterface(child, &outFrame);
|
|
|
|
if (outFrame) {
|
2001-09-18 06:11:09 +04:00
|
|
|
nsCOMPtr<nsIPluginInstance> pi;
|
2004-02-09 20:33:45 +03:00
|
|
|
outFrame->GetPluginInstance(*getter_AddRefs(pi)); // make sure we have a REAL plugin
|
2005-01-05 03:21:06 +03:00
|
|
|
if (pi)
|
|
|
|
return outFrame;
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
outFrame = GetNextObjectFrame(aPresContext, child);
|
|
|
|
if (outFrame)
|
|
|
|
return outFrame;
|
2003-06-30 14:46:59 +04:00
|
|
|
child = child->GetNextSibling();
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
|
|
|
|
2004-02-09 20:33:45 +03:00
|
|
|
return nsnull;
|
2001-09-18 06:11:09 +04:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewObjectFrame(nsIPresShell* aPresShell)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2005-11-01 23:40:54 +03:00
|
|
|
return new (aPresShell) nsObjectFrame;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2002-01-16 01:45:26 +03:00
|
|
|
|
|
|
|
// nsPluginDOMContextMenuListener class implementation
|
|
|
|
|
|
|
|
nsPluginDOMContextMenuListener::nsPluginDOMContextMenuListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginDOMContextMenuListener::~nsPluginDOMContextMenuListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-09-08 02:37:27 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsPluginDOMContextMenuListener, nsIDOMContextMenuListener, nsIEventListener)
|
2002-01-16 01:45:26 +03:00
|
|
|
|
2004-04-10 04:25:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginDOMContextMenuListener::ContextMenu(nsIDOMEvent* aContextMenuEvent)
|
|
|
|
{
|
2004-04-13 07:57:12 +04:00
|
|
|
aContextMenuEvent->PreventDefault(); // consume event
|
2004-04-10 04:25:01 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:45:26 +03:00
|
|
|
nsresult nsPluginDOMContextMenuListener::Init(nsObjectFrame *aFrame)
|
|
|
|
{
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2002-01-16 01:45:26 +03:00
|
|
|
|
|
|
|
// Register context menu listener
|
|
|
|
if (content) {
|
2004-05-04 01:32:54 +04:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> receiver(do_QueryInterface(content));
|
2002-01-16 01:45:26 +03:00
|
|
|
if (receiver) {
|
|
|
|
nsCOMPtr<nsIDOMContextMenuListener> cxMenuListener;
|
|
|
|
QueryInterface(NS_GET_IID(nsIDOMContextMenuListener), getter_AddRefs(cxMenuListener));
|
|
|
|
if (cxMenuListener) {
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("contextmenu"), cxMenuListener, PR_TRUE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginDOMContextMenuListener::Destroy(nsObjectFrame *aFrame)
|
|
|
|
{
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2002-01-16 01:45:26 +03:00
|
|
|
|
|
|
|
// Unregister context menu listener
|
|
|
|
if (content) {
|
2004-05-04 01:32:54 +04:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> receiver(do_QueryInterface(content));
|
2002-01-16 01:45:26 +03:00
|
|
|
if (receiver) {
|
|
|
|
nsCOMPtr<nsIDOMContextMenuListener> cxMenuListener;
|
|
|
|
QueryInterface(NS_GET_IID(nsIDOMContextMenuListener), getter_AddRefs(cxMenuListener));
|
|
|
|
if (cxMenuListener) {
|
2004-05-04 01:32:54 +04:00
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), cxMenuListener, PR_TRUE);
|
2002-01-16 01:45:26 +03:00
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "Unable to remove event listener for plugin");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "plugin was not an event listener");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "plugin had no content");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
//plugin instance owner
|
|
|
|
|
|
|
|
nsPluginInstanceOwner::nsPluginInstanceOwner()
|
|
|
|
{
|
2002-09-26 06:53:27 +04:00
|
|
|
// create nsPluginNativeWindow object, it is derived from nsPluginWindow
|
|
|
|
// struct and allows to manipulate native window procedure
|
|
|
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
|
|
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
|
|
|
if (pph)
|
|
|
|
pph->NewPluginNativeWindow(&mPluginWindow);
|
|
|
|
else
|
|
|
|
mPluginWindow = nsnull;
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
mOwner = nsnull;
|
2000-10-19 05:37:53 +04:00
|
|
|
mTagText = nsnull;
|
2001-10-09 02:58:59 +04:00
|
|
|
mContentFocused = PR_FALSE;
|
2002-05-03 02:47:49 +04:00
|
|
|
mWidgetVisible = PR_TRUE;
|
2001-12-11 18:53:07 +03:00
|
|
|
mNumCachedAttrs = 0;
|
|
|
|
mNumCachedParams = 0;
|
|
|
|
mCachedAttrParamNames = nsnull;
|
|
|
|
mCachedAttrParamValues = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
|
|
|
{
|
|
|
|
PRInt32 cnt;
|
|
|
|
|
|
|
|
// shut off the timer.
|
|
|
|
if (mPluginTimer != nsnull) {
|
2001-07-11 06:29:45 +04:00
|
|
|
CancelTimer();
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mOwner = nsnull;
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
for (cnt = 0; cnt < (mNumCachedAttrs + 1 + mNumCachedParams); cnt++) {
|
2002-06-21 22:28:46 +04:00
|
|
|
if (mCachedAttrParamNames && mCachedAttrParamNames[cnt]) {
|
2001-12-11 18:53:07 +03:00
|
|
|
PR_Free(mCachedAttrParamNames[cnt]);
|
|
|
|
mCachedAttrParamNames[cnt] = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
if (mCachedAttrParamValues && mCachedAttrParamValues[cnt]) {
|
2001-12-11 18:53:07 +03:00
|
|
|
PR_Free(mCachedAttrParamValues[cnt]);
|
|
|
|
mCachedAttrParamValues[cnt] = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
if (mCachedAttrParamNames) {
|
2001-12-11 18:53:07 +03:00
|
|
|
PR_Free(mCachedAttrParamNames);
|
|
|
|
mCachedAttrParamNames = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
if (mCachedAttrParamValues) {
|
2001-12-11 18:53:07 +03:00
|
|
|
PR_Free(mCachedAttrParamValues);
|
|
|
|
mCachedAttrParamValues = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
if (mTagText) {
|
2000-10-19 05:37:53 +04:00
|
|
|
nsCRT::free(mTagText);
|
|
|
|
mTagText = nsnull;
|
|
|
|
}
|
1999-08-03 06:51:39 +04:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
2002-04-11 07:27:00 +04:00
|
|
|
// the mem for this struct is allocated
|
|
|
|
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
|
2002-09-26 06:53:27 +04:00
|
|
|
if (mPluginWindow && mPluginWindow->ws_info) {
|
|
|
|
PR_Free(mPluginWindow->ws_info);
|
|
|
|
mPluginWindow->ws_info = nsnull;
|
2002-04-11 07:27:00 +04:00
|
|
|
}
|
|
|
|
#endif
|
2002-09-26 06:53:27 +04:00
|
|
|
|
|
|
|
// clean up plugin native window object
|
|
|
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
|
|
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
|
|
|
if (pph) {
|
|
|
|
pph->DeletePluginNativeWindow(mPluginWindow);
|
|
|
|
mPluginWindow = nsnull;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2002-01-18 23:12:29 +03:00
|
|
|
/*
|
|
|
|
* nsISupports Implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsPluginInstanceOwner)
|
|
|
|
NS_IMPL_RELEASE(nsPluginInstanceOwner)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsPluginInstanceOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIPluginInstanceOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIPluginTagInfo)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIPluginTagInfo2)
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef OJI
|
2002-01-18 23:12:29 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIJVMPluginTagInfo)
|
2003-03-25 09:54:52 +03:00
|
|
|
#endif
|
2002-01-18 23:12:29 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEventListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScrollPositionListener)
|
2002-07-02 17:52:05 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDragListener)
|
2003-04-02 07:35:58 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMMouseListener)
|
2002-01-18 23:12:29 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPluginInstanceOwner)
|
|
|
|
NS_INTERFACE_MAP_END
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::SetInstance(nsIPluginInstance *aInstance)
|
|
|
|
{
|
|
|
|
mInstance = aInstance;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetWindow(nsPluginWindow *&aWindow)
|
|
|
|
{
|
2002-09-26 06:53:27 +04:00
|
|
|
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
|
|
|
|
aWindow = mPluginWindow;
|
1999-07-07 06:33:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetMode(nsPluginMode *aMode)
|
|
|
|
{
|
2003-03-22 06:20:23 +03:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
nsresult rv = GetDocument(getter_AddRefs(doc));
|
|
|
|
nsCOMPtr<nsIPluginDocument> pDoc (do_QueryInterface(doc));
|
|
|
|
|
|
|
|
if (pDoc) {
|
|
|
|
*aMode = nsPluginMode_Full;
|
|
|
|
} else {
|
|
|
|
*aMode = nsPluginMode_Embedded;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(PRUint16& n,
|
|
|
|
const char*const*& names,
|
|
|
|
const char*const*& values)
|
|
|
|
{
|
2001-12-11 18:53:07 +03:00
|
|
|
nsresult rv = EnsureCachedAttrParamArrays();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
n = mNumCachedAttrs;
|
|
|
|
names = (const char **)mCachedAttrParamNames;
|
|
|
|
values = (const char **)mCachedAttrParamValues;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetAttribute(const char* name, const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(name);
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2001-12-11 18:53:07 +03:00
|
|
|
|
|
|
|
nsresult rv = EnsureCachedAttrParamArrays();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
*result = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
for (int i = 0; i < mNumCachedAttrs; i++) {
|
|
|
|
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
|
|
|
|
*result = mCachedAttrParamValues[i];
|
1999-07-07 06:33:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-01-05 04:18:38 +03:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetDOMElement(nsIDOMElement* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2000-01-05 04:18:38 +03:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*result = nsnull;
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (nsnull != mOwner) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* cont = mOwner->GetContent();
|
2005-01-05 03:21:06 +03:00
|
|
|
if (cont) {
|
2005-09-21 23:14:30 +04:00
|
|
|
rv = CallQueryInterface(cont, result);
|
2000-01-05 04:18:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
|
|
|
|
{
|
2004-09-04 01:49:13 +04:00
|
|
|
NS_IF_ADDREF(aInstance = mInstance);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2004-09-04 01:49:13 +04:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 23:03:56 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
2001-11-07 06:03:04 +03:00
|
|
|
PRUint32 aHeadersDataLen, PRBool isFile)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2001-09-26 06:45:20 +04:00
|
|
|
NS_ENSURE_TRUE(mOwner,NS_ERROR_NULL_POINTER);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-26 06:45:20 +04:00
|
|
|
// the container of the pres context will give us the link handler
|
2005-10-12 06:15:26 +04:00
|
|
|
nsCOMPtr<nsISupports> container = mOwner->GetPresContext()->GetContainer();
|
2001-09-26 06:45:20 +04:00
|
|
|
NS_ENSURE_TRUE(container,NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(container);
|
|
|
|
NS_ENSURE_TRUE(lh, NS_ERROR_FAILURE);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2004-07-25 16:18:04 +04:00
|
|
|
nsAutoString unitarget; unitarget.AssignASCII(aTarget); // XXX could this be nonascii?
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-26 06:45:20 +04:00
|
|
|
nsCOMPtr<nsIURI> baseURL;
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
2004-02-01 13:09:07 +03:00
|
|
|
nsresult rv = GetDocument(getter_AddRefs(doc));
|
2001-09-26 06:45:20 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && doc) {
|
2003-07-03 06:45:34 +04:00
|
|
|
// XXX should this really be the document base URL? Or the
|
|
|
|
// content's base URL?
|
2004-01-10 02:54:21 +03:00
|
|
|
baseURL = doc->GetBaseURI(); // gets the document's url
|
2001-09-26 06:45:20 +04:00
|
|
|
} else {
|
2004-02-09 20:33:45 +03:00
|
|
|
baseURL = mOwner->GetFullURL(); // gets the plugin's content url
|
2001-09-26 06:45:20 +04:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-26 06:45:20 +04:00
|
|
|
// Create an absolute URL
|
2002-11-20 03:44:26 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), aURL, baseURL);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-11-20 03:44:26 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2001-09-26 06:45:20 +04:00
|
|
|
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-26 06:45:20 +04:00
|
|
|
nsCOMPtr<nsIInputStream> postDataStream;
|
|
|
|
nsCOMPtr<nsIInputStream> headersDataStream;
|
2001-11-07 06:03:04 +03:00
|
|
|
|
|
|
|
// deal with post data, either in a file or raw data, and any headers
|
2001-09-26 06:45:20 +04:00
|
|
|
if (aPostData) {
|
2001-11-07 06:03:04 +03:00
|
|
|
|
2002-01-30 05:40:46 +03:00
|
|
|
rv = NS_NewPluginPostDataStream(getter_AddRefs(postDataStream), (const char *)aPostData, aPostDataLen, isFile);
|
2001-12-12 04:38:02 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),"failed in creating plugin post data stream");
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2001-12-12 04:38:02 +03:00
|
|
|
|
|
|
|
if (aHeadersData) {
|
|
|
|
rv = NS_NewPluginPostDataStream(getter_AddRefs(headersDataStream),
|
|
|
|
(const char *) aHeadersData,
|
|
|
|
aHeadersDataLen,
|
|
|
|
PR_FALSE,
|
|
|
|
PR_TRUE); // last arg says we are headers, no /r/n/r/n fixup!
|
|
|
|
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),"failed in creating plugin header data stream");
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
2001-09-26 06:45:20 +04:00
|
|
|
|
2004-09-09 22:53:21 +04:00
|
|
|
PRInt32 blockPopups =
|
|
|
|
nsContentUtils::GetIntPref("privacy.popups.disable_from_plugins");
|
|
|
|
nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups);
|
2004-09-04 23:28:46 +04:00
|
|
|
|
2001-09-26 06:45:20 +04:00
|
|
|
rv = lh->OnLinkClick(content, eLinkVerb_Replace,
|
2002-11-20 03:44:26 +03:00
|
|
|
uri, unitarget.get(),
|
2001-09-26 06:45:20 +04:00
|
|
|
postDataStream, headersDataStream);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2001-09-05 07:58:34 +04:00
|
|
|
|
|
|
|
rv = this->ShowStatus(NS_ConvertUTF8toUCS2(aStatusMsg).get());
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-05 07:58:34 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-10-12 06:15:26 +04:00
|
|
|
if (!mOwner) {
|
2001-09-05 07:58:34 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2005-10-12 06:15:26 +04:00
|
|
|
nsCOMPtr<nsISupports> cont = mOwner->GetPresContext()->GetContainer();
|
2004-02-01 13:09:07 +03:00
|
|
|
if (!cont) {
|
|
|
|
return NS_OK;
|
2001-09-05 07:58:34 +04:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-05 07:58:34 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont, &rv));
|
|
|
|
if (NS_FAILED(rv) || !docShellItem) {
|
|
|
|
return rv;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2004-02-01 13:09:07 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
2001-09-05 07:58:34 +04:00
|
|
|
rv = docShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
if (NS_FAILED(rv) || !treeOwner) {
|
|
|
|
return rv;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-09-05 07:58:34 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner, &rv));
|
|
|
|
if (NS_FAILED(rv) || !browserChrome) {
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2001-09-05 07:58:34 +04:00
|
|
|
rv = browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT,
|
|
|
|
aStatusMsg);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
|
|
|
|
{
|
2004-08-02 08:52:55 +04:00
|
|
|
if (!aDocument)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aDocument = nsnull;
|
2005-10-12 06:15:26 +04:00
|
|
|
if (mOwner) {
|
|
|
|
nsIPresShell *shell = mOwner->GetPresContext()->GetPresShell();
|
2002-07-11 23:32:44 +04:00
|
|
|
if (shell)
|
2004-08-02 08:52:55 +04:00
|
|
|
NS_IF_ADDREF(*aDocument = shell->GetDocument());
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2004-08-02 08:52:55 +04:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
2001-06-19 01:41:57 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2005-10-12 06:15:26 +04:00
|
|
|
if (mOwner && invalidRect) {
|
2001-06-19 01:41:57 +04:00
|
|
|
//no reference count on view
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIView* view = mOwner->GetView();
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (view) {
|
2001-06-19 01:41:57 +04:00
|
|
|
float ptot;
|
2005-10-12 06:15:26 +04:00
|
|
|
ptot = mOwner->GetPresContext()->PixelsToTwips();
|
2001-06-19 01:41:57 +04:00
|
|
|
|
|
|
|
nsRect rect((int)(ptot * invalidRect->left),
|
|
|
|
(int)(ptot * invalidRect->top),
|
|
|
|
(int)(ptot * (invalidRect->right - invalidRect->left)),
|
|
|
|
(int)(ptot * (invalidRect->bottom - invalidRect->top)));
|
|
|
|
|
|
|
|
//set flags to not do a synchronous update, force update does the redraw
|
2003-06-30 14:46:59 +04:00
|
|
|
view->GetViewManager()->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
|
2001-06-19 01:41:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegion)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
|
|
|
|
{
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIView* view = mOwner->GetView();
|
2005-01-05 03:21:06 +03:00
|
|
|
if (view) {
|
2003-06-30 14:46:59 +04:00
|
|
|
return view->GetViewManager()->Composite();
|
2001-06-19 01:41:57 +04:00
|
|
|
}
|
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
return NS_OK;
|
2001-06-19 01:41:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetValue(nsPluginInstancePeerVariable variable, void *value)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
switch(variable) {
|
2001-06-19 01:41:57 +04:00
|
|
|
case nsPluginInstancePeerVariable_NetscapeWindow:
|
2002-02-02 03:07:20 +03:00
|
|
|
{
|
|
|
|
// get the document's widget from the view manager
|
|
|
|
// get the view manager from the pres shell, not from the view!
|
|
|
|
// we may not have a view if we are hidden
|
2005-10-12 06:15:26 +04:00
|
|
|
if (mOwner) {
|
|
|
|
nsIViewManager* vm = mOwner->GetPresContext()->GetViewManager();
|
2002-02-02 03:07:20 +03:00
|
|
|
if (vm) {
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
rv = vm->GetWidget(getter_AddRefs(widget));
|
2005-01-05 03:21:06 +03:00
|
|
|
if (widget) {
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2002-02-02 03:07:20 +03:00
|
|
|
void** pvalue = (void**)value;
|
|
|
|
*pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW);
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2005-10-12 06:15:26 +04:00
|
|
|
} else NS_ERROR("couldn't get doc's widget in getting doc's window handle");
|
|
|
|
} else NS_ERROR("couldn't get view manager in getting doc's window handle");
|
|
|
|
} else NS_ERROR("plugin owner has no owner in getting doc's window handle");
|
2001-06-19 01:41:57 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-02-02 03:07:20 +03:00
|
|
|
|
2001-06-19 01:41:57 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginInstanceOwner::PluginNotAvailable(const char *aMimeType)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
|
|
|
mOwner->PluginNotAvailable(aMimeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
1999-07-07 06:33:17 +04:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*result = nsPluginTagType_Unknown;
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mOwner) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* cont = mOwner->GetContent();
|
2005-01-05 03:21:06 +03:00
|
|
|
if (cont) {
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *atom = cont->Tag();
|
|
|
|
|
|
|
|
if (atom == nsHTMLAtoms::applet)
|
|
|
|
*result = nsPluginTagType_Applet;
|
|
|
|
else if (atom == nsHTMLAtoms::embed)
|
|
|
|
*result = nsPluginTagType_Embed;
|
|
|
|
else if (atom == nsHTMLAtoms::object)
|
|
|
|
*result = nsPluginTagType_Object;
|
|
|
|
|
|
|
|
rv = NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetTagText(const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2000-10-19 05:37:53 +04:00
|
|
|
if (nsnull == mTagText) {
|
|
|
|
nsresult rv;
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
|
|
|
|
2000-10-19 05:37:53 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content, &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
rv = GetDocument(getter_AddRefs(document));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
nsCOMPtr<nsIDocumentEncoder> docEncoder(do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/html", &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2002-12-14 01:12:10 +03:00
|
|
|
rv = docEncoder->Init(document, NS_LITERAL_STRING("text/html"), nsIDocumentEncoder::OutputEncodeBasicEntities);
|
2000-10-19 05:37:53 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
nsCOMPtr<nsIDOMRange> range(do_CreateInstance(kRangeCID,&rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2000-10-19 05:37:53 +04:00
|
|
|
|
|
|
|
rv = range->SelectNode(node);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
docEncoder->SetRange(range);
|
|
|
|
nsString elementHTML;
|
|
|
|
rv = docEncoder->EncodeToString(elementHTML);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2001-09-29 12:28:41 +04:00
|
|
|
mTagText = ToNewUTF8String(elementHTML);
|
2000-10-19 05:37:53 +04:00
|
|
|
if (!mTagText)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*result = mTagText;
|
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values)
|
|
|
|
{
|
2001-12-11 18:53:07 +03:00
|
|
|
nsresult rv = EnsureCachedAttrParamArrays();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
n = mNumCachedParams;
|
2001-12-14 06:52:12 +03:00
|
|
|
if (n) {
|
|
|
|
names = (const char **)(mCachedAttrParamNames + mNumCachedAttrs + 1);
|
|
|
|
values = (const char **)(mCachedAttrParamValues + mNumCachedAttrs + 1);
|
|
|
|
} else
|
|
|
|
names = values = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetParameter(const char* name, const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(name);
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2001-12-11 18:53:07 +03:00
|
|
|
|
|
|
|
nsresult rv = EnsureCachedAttrParamArrays();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
*result = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
for (int i = mNumCachedAttrs + 1; i < (mNumCachedParams + 1 + mNumCachedAttrs); i++) {
|
|
|
|
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
|
|
|
|
*result = mCachedAttrParamValues[i];
|
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
1999-08-03 06:51:39 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
1999-08-03 06:51:39 +04:00
|
|
|
nsresult rv = NS_OK;
|
2002-03-06 10:48:55 +03:00
|
|
|
if (mDocumentBase.IsEmpty()) {
|
2005-10-12 06:15:26 +04:00
|
|
|
if (!mOwner) {
|
1999-08-03 06:51:39 +04:00
|
|
|
*result = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2005-10-12 06:15:26 +04:00
|
|
|
|
|
|
|
nsIPresShell* shell = mOwner->GetPresContext()->PresShell();
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
if (shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (doc) {
|
|
|
|
rv = doc->GetBaseURI()->GetSpec(mDocumentBase);
|
|
|
|
}
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_SUCCEEDED(rv))
|
2002-03-06 10:48:55 +03:00
|
|
|
*result = ToNewCString(mDocumentBase);
|
1999-08-03 06:51:39 +04:00
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
1999-08-03 06:51:39 +04:00
|
|
|
|
2002-03-26 09:33:48 +03:00
|
|
|
static nsHashtable *gCharsetMap = nsnull;
|
|
|
|
typedef struct {
|
2003-12-21 07:04:09 +03:00
|
|
|
char mozName[16];
|
|
|
|
char javaName[12];
|
2002-03-26 09:33:48 +03:00
|
|
|
} moz2javaCharset;
|
|
|
|
|
2003-12-21 07:04:09 +03:00
|
|
|
/* XXX If you add any strings longer than
|
|
|
|
* {"x-mac-cyrillic", "MacCyrillic"},
|
|
|
|
* {"x-mac-ukrainian", "MacUkraine"},
|
|
|
|
* to the following array then you MUST update the
|
|
|
|
* sizes of the arrays in the moz2javaCharset struct
|
|
|
|
*/
|
|
|
|
|
2002-03-26 09:33:48 +03:00
|
|
|
static const moz2javaCharset charsets[] =
|
|
|
|
{
|
|
|
|
{"windows-1252", "Cp1252"},
|
|
|
|
{"IBM850", "Cp850"},
|
|
|
|
{"IBM852", "Cp852"},
|
|
|
|
{"IBM855", "Cp855"},
|
|
|
|
{"IBM857", "Cp857"},
|
|
|
|
{"IBM828", "Cp862"},
|
|
|
|
{"IBM864", "Cp864"},
|
|
|
|
{"IBM866", "Cp866"},
|
|
|
|
{"windows-1250", "Cp1250"},
|
|
|
|
{"windows-1251", "Cp1251"},
|
|
|
|
{"windows-1253", "Cp1253"},
|
|
|
|
{"windows-1254", "Cp1254"},
|
|
|
|
{"windows-1255", "Cp1255"},
|
|
|
|
{"windows-1256", "Cp1256"},
|
|
|
|
{"windows-1257", "Cp1257"},
|
|
|
|
{"windows-1258", "Cp1258"},
|
|
|
|
{"EUC-JP", "EUC_JP"},
|
|
|
|
{"EUC-KR", "EUC_KR"},
|
|
|
|
{"x-euc-tw", "EUC_TW"},
|
|
|
|
{"gb18030", "GB18030"},
|
|
|
|
{"x-gbk", "GBK"},
|
|
|
|
{"ISO-2022-JP", "ISO2022JP"},
|
|
|
|
{"ISO-2022-KR", "ISO2022KR"},
|
|
|
|
{"ISO-8859-2", "ISO8859_2"},
|
|
|
|
{"ISO-8859-3", "ISO8859_3"},
|
|
|
|
{"ISO-8859-4", "ISO8859_4"},
|
|
|
|
{"ISO-8859-5", "ISO8859_5"},
|
|
|
|
{"ISO-8859-6", "ISO8859_6"},
|
|
|
|
{"ISO-8859-7", "ISO8859_7"},
|
|
|
|
{"ISO-8859-8", "ISO8859_8"},
|
|
|
|
{"ISO-8859-9", "ISO8859_9"},
|
|
|
|
{"ISO-8859-13", "ISO8859_13"},
|
|
|
|
{"x-johab", "Johab"},
|
|
|
|
{"KOI8-R", "KOI8_R"},
|
|
|
|
{"TIS-620", "MS874"},
|
|
|
|
{"windows-936", "MS936"},
|
|
|
|
{"x-windows-949", "MS949"},
|
|
|
|
{"x-mac-arabic", "MacArabic"},
|
|
|
|
{"x-mac-croatian", "MacCroatia"},
|
|
|
|
{"x-mac-cyrillic", "MacCyrillic"},
|
|
|
|
{"x-mac-greek", "MacGreek"},
|
|
|
|
{"x-mac-hebrew", "MacHebrew"},
|
|
|
|
{"x-mac-icelandic", "MacIceland"},
|
|
|
|
{"x-mac-roman", "MacRoman"},
|
|
|
|
{"x-mac-romanian", "MacRomania"},
|
|
|
|
{"x-mac-ukrainian", "MacUkraine"},
|
|
|
|
{"Shift_JIS", "SJIS"},
|
|
|
|
{"TIS-620", "TIS620"}
|
|
|
|
};
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
|
|
|
|
{
|
2002-03-26 09:33:48 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
|
|
|
*result = nsnull;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
rv = GetDocument(getter_AddRefs(doc));
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document");
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2002-03-26 09:33:48 +03:00
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
const nsACString &charset = doc->GetDocumentCharacterSet();
|
2002-03-26 09:33:48 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (charset.IsEmpty())
|
|
|
|
return NS_OK;
|
2002-03-26 09:33:48 +03:00
|
|
|
|
|
|
|
// common charsets and those not requiring conversion first
|
2004-04-28 21:48:02 +04:00
|
|
|
if (charset.EqualsLiteral("us-ascii")) {
|
2002-03-26 09:33:48 +03:00
|
|
|
*result = PL_strdup("US_ASCII");
|
2004-04-28 21:48:02 +04:00
|
|
|
} else if (charset.EqualsLiteral("ISO-8859-1") ||
|
2003-10-22 10:09:48 +04:00
|
|
|
!nsCRT::strncmp(PromiseFlatCString(charset).get(), "UTF", 3)) {
|
2003-06-17 20:40:34 +04:00
|
|
|
*result = ToNewCString(charset);
|
2002-03-26 09:33:48 +03:00
|
|
|
} else {
|
|
|
|
if (!gCharsetMap) {
|
|
|
|
gCharsetMap = new nsHashtable(sizeof(charsets)/sizeof(moz2javaCharset));
|
2005-01-05 03:21:06 +03:00
|
|
|
if (!gCharsetMap)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-03-26 09:33:48 +03:00
|
|
|
|
|
|
|
for (PRUint16 i = 0; i < sizeof(charsets)/sizeof(moz2javaCharset); i++) {
|
|
|
|
nsCStringKey key(charsets[i].mozName);
|
|
|
|
gCharsetMap->Put(&key, (void *)(charsets[i].javaName));
|
|
|
|
}
|
|
|
|
}
|
2003-06-17 20:40:34 +04:00
|
|
|
nsCStringKey mozKey(charset);
|
2002-03-26 09:33:48 +03:00
|
|
|
// if found mapping, return it; otherwise return original charset
|
|
|
|
char *mapping = (char *)gCharsetMap->Get(&mozKey);
|
2003-06-17 20:40:34 +04:00
|
|
|
*result = mapping ? PL_strdup(mapping) : ToNewCString(charset);
|
2002-03-26 09:33:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2002-03-26 09:33:48 +03:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetAlignment(const char* *result)
|
|
|
|
{
|
|
|
|
return GetAttribute("ALIGN", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(PRUint32 *result)
|
|
|
|
{
|
2002-03-19 18:39:45 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
|
|
|
|
|
|
|
*result = mPluginWindow->width;
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2002-03-19 18:39:45 +03:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(PRUint32 *result)
|
|
|
|
{
|
2002-03-19 18:39:45 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
|
|
|
|
|
|
|
*result = mPluginWindow->height;
|
1999-11-11 03:00:07 +03:00
|
|
|
|
2002-03-19 18:39:45 +03:00
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2000-05-23 01:36:35 +04:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetBorderVertSpace(PRUint32 *result)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
const char *vspace;
|
|
|
|
|
|
|
|
rv = GetAttribute("VSPACE", &vspace);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_OK == rv) {
|
1999-07-07 06:33:17 +04:00
|
|
|
if (*result != 0)
|
|
|
|
*result = (PRUint32)atol(vspace);
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetBorderHorizSpace(PRUint32 *result)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
const char *hspace;
|
|
|
|
|
|
|
|
rv = GetAttribute("HSPACE", &hspace);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_OK == rv) {
|
1999-07-07 06:33:17 +04:00
|
|
|
if (*result != 0)
|
|
|
|
*result = (PRUint32)atol(hspace);
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetUniqueID(PRUint32 *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2005-10-12 06:15:26 +04:00
|
|
|
*result = NS_PTR_TO_INT32(mOwner);
|
1999-07-07 06:33:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-25 09:54:52 +03:00
|
|
|
#ifdef OJI
|
1999-07-07 06:33:17 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetCode(const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsPluginTagType tagType;
|
|
|
|
NS_ENSURE_SUCCESS(rv = GetTagType(&tagType), rv);
|
|
|
|
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
if (nsPluginTagType_Object != tagType)
|
|
|
|
rv = GetAttribute("CODE", result);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = GetParameter("CODE", result);
|
|
|
|
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetCodeBase(const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
nsresult rv;
|
|
|
|
if (NS_FAILED(rv = GetAttribute("CODEBASE", result)))
|
|
|
|
rv = GetParameter("CODEBASE", result);
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetArchive(const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
nsresult rv;
|
|
|
|
if (NS_FAILED(rv = GetAttribute("ARCHIVE", result)))
|
|
|
|
rv = GetParameter("ARCHIVE", result);
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetName(const char* *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsPluginTagType tagType;
|
|
|
|
NS_ENSURE_SUCCESS(rv = GetTagType(&tagType), rv);
|
|
|
|
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
if (nsPluginTagType_Object != tagType)
|
|
|
|
rv = GetAttribute("NAME", result);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = GetParameter("NAME", result);
|
|
|
|
|
|
|
|
return rv;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::GetMayScript(PRBool *result)
|
|
|
|
{
|
2001-11-20 05:17:21 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
|
|
|
nsPluginTagType tagType;
|
|
|
|
NS_ENSURE_SUCCESS(GetTagType(&tagType), NS_ERROR_FAILURE);
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
const char* unused;
|
2001-11-20 05:17:21 +03:00
|
|
|
if (nsPluginTagType_Object == tagType)
|
|
|
|
*result = NS_SUCCEEDED(GetParameter("MAYSCRIPT", &unused));
|
|
|
|
else
|
|
|
|
*result = NS_SUCCEEDED(GetAttribute("MAYSCRIPT", &unused));
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-03-25 09:54:52 +03:00
|
|
|
#endif /* OJI */
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2003-01-11 00:48:56 +03:00
|
|
|
// Little helper function to resolve relative URL in
|
|
|
|
// |value| for certain inputs of |name|
|
2004-02-09 20:33:45 +03:00
|
|
|
void nsObjectFrame::FixUpURLS(const nsString &name, nsAString &value)
|
2003-01-11 00:48:56 +03:00
|
|
|
{
|
2004-06-17 04:13:25 +04:00
|
|
|
if (name.LowerCaseEqualsLiteral("pluginurl") ||
|
|
|
|
name.LowerCaseEqualsLiteral("pluginspage")) {
|
2003-01-11 00:48:56 +03:00
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
2003-07-03 06:45:34 +04:00
|
|
|
nsAutoString newURL;
|
2004-01-10 02:54:21 +03:00
|
|
|
NS_MakeAbsoluteURI(newURL, value, baseURI);
|
2003-07-03 06:45:34 +04:00
|
|
|
if (!newURL.IsEmpty())
|
|
|
|
value = newURL;
|
2003-01-11 00:48:56 +03:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 18:53:07 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
void
|
|
|
|
nsObjectFrame::PluginNotAvailable(const char *aMimeType)
|
|
|
|
{
|
2005-02-27 21:33:27 +03:00
|
|
|
if (!aMimeType) {
|
|
|
|
NS_ERROR("bogus type... behavior will be broken");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-30 05:23:12 +04:00
|
|
|
nsDependentCString type(aMimeType);
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
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.
|
2005-03-10 17:57:32 +03:00
|
|
|
if (!IsSupportedImage(type) &&
|
|
|
|
!IsSupportedDocument(mContent, type)) {
|
2005-01-05 03:21:06 +03:00
|
|
|
FirePluginNotFoundEvent(mContent);
|
|
|
|
|
|
|
|
mIsBrokenPlugin = PR_TRUE;
|
|
|
|
|
|
|
|
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
|
|
|
|
|
|
|
GetParent()->ReflowDirtyChild(mContent->GetDocument()->GetShellAt(0),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
// Cache the attributes and/or parameters of our tag into a single set
|
|
|
|
// of arrays to be compatible with 4.x. The attributes go first,
|
|
|
|
// followed by a PARAM/null and then any PARAM tags. Also, hold the
|
|
|
|
// cached array around for the duration of the life of the instance
|
|
|
|
// because 4.x did. See bug 111008.
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
|
|
|
|
{
|
|
|
|
if (mCachedAttrParamValues)
|
|
|
|
return NS_OK;
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
NS_PRECONDITION(((mNumCachedAttrs + mNumCachedParams) == 0) &&
|
|
|
|
!mCachedAttrParamNames,
|
|
|
|
"re-cache of attrs/params not implemented! use the DOM "
|
|
|
|
"node directy instead");
|
2001-12-11 18:53:07 +03:00
|
|
|
NS_ENSURE_TRUE(mOwner, NS_ERROR_NULL_POINTER);
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
// first, we need to find out how much we need to allocate for our
|
|
|
|
// arrays count up attributes
|
2001-12-11 18:53:07 +03:00
|
|
|
mNumCachedAttrs = 0;
|
2002-06-21 22:28:46 +04:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
|
|
|
nsresult rv = NS_OK;
|
2001-12-11 18:53:07 +03:00
|
|
|
NS_ENSURE_TRUE(content, rv);
|
2002-06-21 22:28:46 +04:00
|
|
|
|
2003-09-27 08:18:26 +04:00
|
|
|
PRUint32 cattrs = content->GetAttrCount();
|
2002-06-21 22:28:46 +04:00
|
|
|
|
|
|
|
if (cattrs < 0x0000FFFF) {
|
2003-09-27 08:18:26 +04:00
|
|
|
// unsigned 32 bits to unsigned 16 bits conversion
|
2002-06-21 22:28:46 +04:00
|
|
|
mNumCachedAttrs = NS_STATIC_CAST(PRUint16, cattrs);
|
2003-09-27 08:18:26 +04:00
|
|
|
} else {
|
2002-06-27 05:51:34 +04:00
|
|
|
mNumCachedAttrs = 0xFFFE; // minus one in case we add an extra "src" entry below
|
2002-06-21 22:28:46 +04:00
|
|
|
}
|
2001-12-11 18:53:07 +03:00
|
|
|
|
|
|
|
// now, we need to find all the PARAM tags that are children of us
|
2002-06-21 22:28:46 +04:00
|
|
|
// however, be carefull NOT to include any PARAMs that don't have us
|
|
|
|
// as a direct parent. For nested object (or applet) tags, be sure
|
|
|
|
// to only round up the param tags that coorespond with THIS
|
|
|
|
// instance. And also, weed out any bogus tags that may get in the
|
|
|
|
// way, see bug 39609. Then, with any param tag that meet our
|
|
|
|
// qualification, temporarly cache them in an nsISupportsArray until
|
|
|
|
// we can figure out what size to make our fixed char* array.
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
mNumCachedParams = 0;
|
|
|
|
nsCOMPtr<nsISupportsArray> ourParams;
|
|
|
|
rv = NS_NewISupportsArray(getter_AddRefs(ourParams));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2002-06-21 22:28:46 +04:00
|
|
|
// use the DOM to get us ALL our dependant PARAM tags, even if not
|
|
|
|
// ours
|
|
|
|
nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(content);
|
2001-12-11 18:53:07 +03:00
|
|
|
NS_ENSURE_TRUE(mydomElement, NS_ERROR_NO_INTERFACE);
|
2002-06-21 22:28:46 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
nsCOMPtr<nsIDOMNodeList> allParams;
|
2002-06-21 22:28:46 +04:00
|
|
|
|
2005-09-24 22:43:15 +04:00
|
|
|
nsINodeInfo *ni = content->NodeInfo();
|
2002-06-21 22:28:46 +04:00
|
|
|
|
|
|
|
if (ni->NamespaceEquals(kNameSpaceID_XHTML)) {
|
|
|
|
// For XHTML elements we need to take the namespace URI into
|
|
|
|
// account when looking for param elements.
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
|
|
|
|
|
|
|
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
|
|
|
|
getter_AddRefs(allParams));
|
|
|
|
} else {
|
|
|
|
// If content is not XHTML, it must be HTML, no need to worry
|
|
|
|
// about namespaces then...
|
|
|
|
|
|
|
|
mydomElement->GetElementsByTagName(NS_LITERAL_STRING("param"),
|
|
|
|
getter_AddRefs(allParams));
|
|
|
|
}
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
if (allParams) {
|
|
|
|
PRUint32 numAllParams;
|
|
|
|
allParams->GetLength(&numAllParams);
|
2002-06-21 22:28:46 +04:00
|
|
|
// loop through every so called dependant PARAM tag to check if it
|
|
|
|
// "belongs" to us
|
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
for (PRUint32 i = 0; i < numAllParams; i++) {
|
|
|
|
nsCOMPtr<nsIDOMNode> pnode;
|
|
|
|
allParams->Item(i, getter_AddRefs(pnode));
|
2002-06-21 22:28:46 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);
|
|
|
|
if (domelement) {
|
|
|
|
// let's NOT count up param tags that don't have a name attribute
|
|
|
|
nsAutoString name;
|
|
|
|
domelement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
2003-05-24 01:34:47 +04:00
|
|
|
if (!name.IsEmpty()) {
|
2002-06-21 22:28:46 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> parent;
|
|
|
|
nsCOMPtr<nsIDOMHTMLObjectElement> domobject;
|
|
|
|
nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;
|
|
|
|
pnode->GetParentNode(getter_AddRefs(parent));
|
|
|
|
// walk up the parents of this PARAM until we find an object
|
|
|
|
// (or applet) tag
|
|
|
|
|
|
|
|
while (!(domobject || domapplet) && parent) {
|
|
|
|
domobject = do_QueryInterface(parent);
|
|
|
|
domapplet = do_QueryInterface(parent);
|
|
|
|
nsCOMPtr<nsIDOMNode> temp;
|
|
|
|
parent->GetParentNode(getter_AddRefs(temp));
|
|
|
|
parent = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (domapplet || domobject) {
|
|
|
|
if (domapplet)
|
|
|
|
parent = do_QueryInterface(domapplet);
|
|
|
|
else
|
|
|
|
parent = do_QueryInterface(domobject);
|
|
|
|
|
|
|
|
// now check to see if this PARAM's parent is us. if so,
|
|
|
|
// cache it for later
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(mydomElement);
|
|
|
|
if (parent == mydomNode) {
|
|
|
|
ourParams->AppendElement(pnode);
|
2001-12-11 18:53:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-21 22:28:46 +04:00
|
|
|
|
2001-12-12 07:15:12 +03:00
|
|
|
PRUint32 cparams;
|
|
|
|
ourParams->Count(&cparams); // unsigned 32 bits to unsigned 16 bits conversion
|
2001-12-12 07:17:15 +03:00
|
|
|
if (cparams < 0x0000FFFF)
|
2001-12-12 07:15:12 +03:00
|
|
|
mNumCachedParams = NS_STATIC_CAST(PRUint16, cparams);
|
|
|
|
else
|
2001-12-12 07:18:36 +03:00
|
|
|
mNumCachedParams = 0xFFFF;
|
2001-12-11 18:53:07 +03:00
|
|
|
|
2002-06-27 05:51:34 +04:00
|
|
|
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
|
|
|
|
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
|
|
|
|
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
|
|
|
|
// look for "data", lets instead copy the "data" attribute and add another entry
|
|
|
|
// to the bottom of the array if there isn't already a "src" specified.
|
|
|
|
PRInt16 numRealAttrs = mNumCachedAttrs;
|
|
|
|
nsAutoString data;
|
2005-10-28 15:25:24 +04:00
|
|
|
if (content->Tag() == nsHTMLAtoms::object
|
2002-07-11 23:32:44 +04:00
|
|
|
&& !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src)
|
2005-10-28 15:25:24 +04:00
|
|
|
&& content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data)) {
|
2002-07-11 23:32:44 +04:00
|
|
|
mNumCachedAttrs++;
|
|
|
|
}
|
2002-06-27 05:51:34 +04:00
|
|
|
|
2001-12-11 18:53:07 +03:00
|
|
|
// now lets make the arrays
|
|
|
|
mCachedAttrParamNames = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1);
|
|
|
|
NS_ENSURE_TRUE(mCachedAttrParamNames, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
mCachedAttrParamValues = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1);
|
|
|
|
NS_ENSURE_TRUE(mCachedAttrParamValues, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
// let's fill in our attributes
|
|
|
|
PRInt16 c = 0;
|
2004-02-24 05:44:33 +03:00
|
|
|
|
|
|
|
// Some plugins (eg Flash, see bug 234675.) are actually sensitive to the
|
|
|
|
// attribute order. So we want to make sure we give the plugin the
|
|
|
|
// attributes in the order they came in in the source, to be compatible with
|
|
|
|
// other browsers. Now in HTML, the storage order is the reverse of the
|
|
|
|
// source order, while in XML and XHTML it's the same as the source order
|
|
|
|
// (see the AddAttributes functions in the HTML and XML content sinks).
|
|
|
|
PRInt16 start, end, increment;
|
|
|
|
if (content->IsContentOfType(nsIContent::eHTML) &&
|
2005-09-24 22:43:15 +04:00
|
|
|
content->NodeInfo()->NamespaceEquals(kNameSpaceID_None)) {
|
2004-02-24 05:44:33 +03:00
|
|
|
// HTML. Walk attributes in reverse order.
|
|
|
|
start = numRealAttrs - 1;
|
|
|
|
end = -1;
|
|
|
|
increment = -1;
|
|
|
|
} else {
|
|
|
|
// XHTML or XML. Walk attributes in forward order.
|
|
|
|
start = 0;
|
|
|
|
end = numRealAttrs;
|
|
|
|
increment = 1;
|
|
|
|
}
|
|
|
|
for (PRInt16 index = start; index != end; index += increment) {
|
2001-12-11 18:53:07 +03:00
|
|
|
PRInt32 nameSpaceID;
|
|
|
|
nsCOMPtr<nsIAtom> atom;
|
|
|
|
nsCOMPtr<nsIAtom> prefix;
|
2003-06-14 00:10:01 +04:00
|
|
|
content->GetAttrNameAt(index, &nameSpaceID,
|
|
|
|
getter_AddRefs(atom),
|
|
|
|
getter_AddRefs(prefix));
|
2001-12-11 18:53:07 +03:00
|
|
|
nsAutoString value;
|
2005-10-28 15:25:24 +04:00
|
|
|
content->GetAttr(nameSpaceID, atom, value);
|
|
|
|
nsAutoString name;
|
|
|
|
atom->ToString(name);
|
|
|
|
|
|
|
|
mOwner->FixUpURLS(name, value);
|
|
|
|
|
|
|
|
mCachedAttrParamNames [c] = ToNewUTF8String(name);
|
|
|
|
mCachedAttrParamValues[c] = ToNewUTF8String(value);
|
|
|
|
c++;
|
2001-12-11 18:53:07 +03:00
|
|
|
}
|
|
|
|
|
2002-06-27 05:51:34 +04:00
|
|
|
// if the conditions above were met, copy the "data" attribute to a "src" array entry
|
|
|
|
if (data.Length()) {
|
|
|
|
mCachedAttrParamNames [mNumCachedAttrs-1] = ToNewUTF8String(NS_LITERAL_STRING("SRC"));
|
|
|
|
mCachedAttrParamValues[mNumCachedAttrs-1] = ToNewUTF8String(data);
|
|
|
|
}
|
|
|
|
|
2003-03-24 07:15:34 +03:00
|
|
|
// add our PARAM and null separator
|
2001-12-12 08:39:46 +03:00
|
|
|
mCachedAttrParamNames [mNumCachedAttrs] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
|
|
|
|
mCachedAttrParamValues[mNumCachedAttrs] = nsnull;
|
2001-12-11 18:53:07 +03:00
|
|
|
|
|
|
|
// now fill in the PARAM name/value pairs from the cached DOM nodes
|
|
|
|
c = 0;
|
|
|
|
for (PRInt16 idx = 0; idx < mNumCachedParams; idx++) {
|
2002-03-12 00:52:32 +03:00
|
|
|
nsCOMPtr<nsIDOMElement> param = do_QueryElementAt(ourParams, idx);
|
|
|
|
if (param) {
|
|
|
|
nsAutoString name;
|
|
|
|
nsAutoString value;
|
|
|
|
param->GetAttribute(NS_LITERAL_STRING("name"), name); // check for empty done above
|
|
|
|
param->GetAttribute(NS_LITERAL_STRING("value"), value);
|
2003-01-11 00:48:56 +03:00
|
|
|
|
|
|
|
mOwner->FixUpURLS(name, value);
|
|
|
|
|
2002-03-12 00:52:32 +03:00
|
|
|
/*
|
|
|
|
* According to the HTML 4.01 spec, at
|
|
|
|
* http://www.w3.org/TR/html4/types.html#type-cdata
|
|
|
|
* ''User agents may ignore leading and trailing
|
|
|
|
* white space in CDATA attribute values (e.g., "
|
|
|
|
* myval " may be interpreted as "myval"). Authors
|
|
|
|
* should not declare attribute values with
|
|
|
|
* leading or trailing white space.''
|
2002-06-12 20:41:25 +04:00
|
|
|
* However, do not trim consecutive spaces as in bug 122119
|
2002-03-12 00:52:32 +03:00
|
|
|
*/
|
2002-06-12 20:41:25 +04:00
|
|
|
name.Trim(" \n\r\t\b", PR_TRUE, PR_TRUE, PR_FALSE);
|
|
|
|
value.Trim(" \n\r\t\b", PR_TRUE, PR_TRUE, PR_FALSE);
|
2002-03-12 00:52:32 +03:00
|
|
|
mCachedAttrParamNames [mNumCachedAttrs + 1 + c] = ToNewUTF8String(name);
|
|
|
|
mCachedAttrParamValues[mNumCachedAttrs + 1 + c] = ToNewUTF8String(value);
|
|
|
|
c++; // rules!
|
2001-12-11 18:53:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
// Here's where we forward events to plugins.
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2000-06-21 03:10:06 +04:00
|
|
|
|
|
|
|
#if TARGET_CARBON
|
2002-03-20 01:10:45 +03:00
|
|
|
static void InitializeEventRecord(EventRecord* event)
|
|
|
|
{
|
|
|
|
memset(event, 0, sizeof(EventRecord));
|
2002-11-06 04:24:57 +03:00
|
|
|
::GetGlobalMouse(&event->where);
|
|
|
|
event->when = ::TickCount();
|
|
|
|
event->modifiers = ::GetCurrentKeyModifiers();
|
2002-03-20 01:10:45 +03:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
inline void InitializeEventRecord(EventRecord* event) { ::OSEventAvail(0, event); }
|
2000-06-21 03:10:06 +04:00
|
|
|
#endif
|
|
|
|
|
2003-02-28 02:35:47 +03:00
|
|
|
void nsPluginInstanceOwner::GUItoMacEvent(const nsGUIEvent& anEvent, EventRecord* origEvent, EventRecord& aMacEvent)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* presContext = mOwner ? mOwner->GetPresContext() : nsnull;
|
2003-02-28 02:35:47 +03:00
|
|
|
InitializeEventRecord(&aMacEvent);
|
2005-01-05 03:21:06 +03:00
|
|
|
switch (anEvent.message) {
|
2002-03-20 01:10:45 +03:00
|
|
|
case NS_FOCUS_EVENT_START: // this is the same as NS_FOCUS_CONTENT
|
|
|
|
aMacEvent.what = nsPluginEventType_GetFocusEvent;
|
2004-02-09 20:33:45 +03:00
|
|
|
if (presContext) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2002-03-20 01:10:45 +03:00
|
|
|
if (content)
|
2004-02-09 20:33:45 +03:00
|
|
|
content->SetFocus(presContext);
|
2002-03-20 01:10:45 +03:00
|
|
|
}
|
|
|
|
break;
|
2003-02-28 02:35:47 +03:00
|
|
|
|
2002-03-20 01:10:45 +03:00
|
|
|
case NS_BLUR_CONTENT:
|
|
|
|
aMacEvent.what = nsPluginEventType_LoseFocusEvent;
|
2004-02-09 20:33:45 +03:00
|
|
|
if (presContext) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2002-03-20 01:10:45 +03:00
|
|
|
if (content)
|
2004-02-09 20:33:45 +03:00
|
|
|
content->RemoveFocus(presContext);
|
2002-03-20 01:10:45 +03:00
|
|
|
}
|
|
|
|
break;
|
2003-02-28 02:35:47 +03:00
|
|
|
|
2002-03-20 01:10:45 +03:00
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
case NS_MOUSE_ENTER:
|
2003-02-28 02:35:47 +03:00
|
|
|
if (origEvent)
|
|
|
|
aMacEvent = *origEvent;
|
2002-03-20 01:10:45 +03:00
|
|
|
aMacEvent.what = nsPluginEventType_AdjustCursorEvent;
|
|
|
|
break;
|
2003-02-28 02:35:47 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
2001-10-09 02:58:59 +04:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
|
|
|
|
2002-01-18 23:12:29 +03:00
|
|
|
nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2003-02-28 02:35:47 +03:00
|
|
|
CancelTimer();
|
2002-11-06 04:24:57 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mInstance) {
|
2003-02-28 02:35:47 +03:00
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
2003-02-28 02:35:47 +03:00
|
|
|
EventRecord scrollEvent;
|
|
|
|
InitializeEventRecord(&scrollEvent);
|
|
|
|
scrollEvent.what = nsPluginEventType_ScrollingBeginsEvent;
|
|
|
|
|
|
|
|
nsPluginPort* pluginPort = FixUpPluginWindow(ePluginPaintDisable);
|
|
|
|
if (pluginPort) {
|
|
|
|
nsPluginEvent pluginEvent = { &scrollEvent, nsPluginPlatformWindowRef(GetWindowFromPort(pluginPort->port)) };
|
|
|
|
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
|
|
|
}
|
|
|
|
pluginWidget->EndDrawPlugin();
|
2002-11-06 04:24:57 +03:00
|
|
|
}
|
2002-01-18 23:12:29 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
|
|
|
|
{
|
2005-09-29 02:40:49 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mInstance) {
|
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
|
|
|
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
|
|
|
EventRecord scrollEvent;
|
|
|
|
InitializeEventRecord(&scrollEvent);
|
|
|
|
scrollEvent.what = nsPluginEventType_ScrollingEndsEvent;
|
2003-02-28 02:35:47 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
nsPluginPort* pluginPort = FixUpPluginWindow(ePluginPaintEnable);
|
|
|
|
if (pluginPort) {
|
|
|
|
nsPluginEvent pluginEvent =
|
|
|
|
{ &scrollEvent,
|
|
|
|
nsPluginPlatformWindowRef(GetWindowFromPort(pluginPort->port))
|
|
|
|
};
|
|
|
|
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
2002-01-18 23:12:29 +03:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
pluginWidget->EndDrawPlugin();
|
|
|
|
}
|
2003-02-28 02:35:47 +03:00
|
|
|
|
|
|
|
// FIXME - Only invalidate the newly revealed amount.
|
2005-09-29 02:40:49 +04:00
|
|
|
// XXX necessary?
|
2005-02-03 08:31:42 +03:00
|
|
|
if (mWidget)
|
|
|
|
mWidget->Invalidate(PR_TRUE);
|
2002-01-18 23:12:29 +03:00
|
|
|
}
|
|
|
|
#endif
|
2003-02-28 02:35:47 +03:00
|
|
|
|
|
|
|
StartTimer();
|
2002-01-18 23:12:29 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-20 02:26:41 +03:00
|
|
|
/*=============== nsIFocusListener ======================*/
|
|
|
|
nsresult nsPluginInstanceOwner::Focus(nsIDOMEvent * aFocusEvent)
|
|
|
|
{
|
2001-10-09 02:58:59 +04:00
|
|
|
mContentFocused = PR_TRUE;
|
2001-03-20 02:26:41 +03:00
|
|
|
return DispatchFocusToPlugin(aFocusEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
|
|
|
|
{
|
2001-10-09 02:58:59 +04:00
|
|
|
mContentFocused = PR_FALSE;
|
2001-03-20 02:26:41 +03:00
|
|
|
return DispatchFocusToPlugin(aFocusEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
2004-04-13 05:51:00 +04:00
|
|
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type) {
|
|
|
|
// continue only for cases without child window
|
|
|
|
return aFocusEvent->PreventDefault(); // consume event
|
|
|
|
}
|
2001-08-07 05:48:14 +04:00
|
|
|
#endif
|
|
|
|
|
2001-03-20 02:26:41 +03:00
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aFocusEvent));
|
|
|
|
if (privateEvent) {
|
2001-07-10 06:52:50 +04:00
|
|
|
nsEvent * theEvent;
|
|
|
|
privateEvent->GetInternalNSEvent(&theEvent);
|
|
|
|
if (theEvent) {
|
2005-04-29 03:48:28 +04:00
|
|
|
// we only care about the message in ProcessEvent
|
|
|
|
nsGUIEvent focusEvent(NS_IS_TRUSTED_EVENT(theEvent), theEvent->message,
|
|
|
|
nsnull);
|
2001-07-14 05:36:45 +04:00
|
|
|
nsEventStatus rv = ProcessEvent(focusEvent);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == rv) {
|
|
|
|
aFocusEvent->PreventDefault();
|
2001-12-06 09:57:03 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aFocusEvent));
|
|
|
|
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
2001-03-20 02:26:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchFocusToPlugin failed, focusEvent null");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchFocusToPlugin failed, privateEvent null");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
/*=============== nsIDOMDragListener ======================*/
|
|
|
|
nsresult nsPluginInstanceOwner::DragEnter(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (mInstance) {
|
2004-09-27 22:56:07 +04:00
|
|
|
// Let the plugin handle drag events.
|
2002-07-02 17:52:05 +04:00
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 22:56:07 +04:00
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DragOver(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (mInstance) {
|
2004-09-27 22:56:07 +04:00
|
|
|
// Let the plugin handle drag events.
|
2002-07-02 17:52:05 +04:00
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 22:56:07 +04:00
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DragExit(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (mInstance) {
|
2004-09-27 22:56:07 +04:00
|
|
|
// Let the plugin handle drag events.
|
2002-07-02 17:52:05 +04:00
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 22:56:07 +04:00
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DragDrop(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (mInstance) {
|
2004-09-27 22:56:07 +04:00
|
|
|
// Let the plugin handle drag events.
|
2002-07-02 17:52:05 +04:00
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 22:56:07 +04:00
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DragGesture(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
if (mInstance) {
|
2004-09-27 22:56:07 +04:00
|
|
|
// Let the plugin handle drag events.
|
2002-07-02 17:52:05 +04:00
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 22:56:07 +04:00
|
|
|
|
2002-07-02 17:52:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-20 02:26:41 +03:00
|
|
|
|
|
|
|
|
2001-01-17 23:04:09 +03:00
|
|
|
/*=============== nsIKeyListener ======================*/
|
|
|
|
nsresult nsPluginInstanceOwner::KeyDown(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
return DispatchKeyToPlugin(aKeyEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::KeyUp(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
|
|
|
return DispatchKeyToPlugin(aKeyEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
2003-02-28 02:35:47 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX) // send KeyPress events only on Mac
|
2003-06-18 18:41:44 +04:00
|
|
|
|
|
|
|
// KeyPress events are really synthesized keyDown events.
|
|
|
|
// Here we check the native message of the event so that
|
|
|
|
// we won't send the plugin two keyDown events.
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aKeyEvent));
|
|
|
|
if (privateEvent) {
|
|
|
|
nsEvent *theEvent;
|
|
|
|
privateEvent->GetInternalNSEvent(&theEvent);
|
|
|
|
const nsGUIEvent *guiEvent = (nsGUIEvent*)theEvent;
|
|
|
|
const EventRecord *ev = (EventRecord*)(guiEvent->nativeMsg);
|
|
|
|
if (guiEvent &&
|
|
|
|
guiEvent->message == NS_KEY_PRESS &&
|
|
|
|
ev &&
|
|
|
|
ev->what == keyDown)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aKeyEvent->PreventDefault(); // consume event
|
2003-06-18 18:41:44 +04:00
|
|
|
}
|
|
|
|
|
2003-02-28 02:35:47 +03:00
|
|
|
// Nasty hack to avoid recursive event dispatching with Java. Java can
|
|
|
|
// dispatch key events to a TSM handler, which comes back and calls
|
|
|
|
// [ChildView insertText:] on the cocoa widget, which sends a key
|
|
|
|
// event back down.
|
|
|
|
static PRBool sInKeyDispatch = PR_FALSE;
|
|
|
|
|
|
|
|
if (sInKeyDispatch)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aKeyEvent->PreventDefault(); // consume event
|
2003-02-28 02:35:47 +03:00
|
|
|
|
|
|
|
sInKeyDispatch = PR_TRUE;
|
|
|
|
nsresult rv = DispatchKeyToPlugin(aKeyEvent);
|
|
|
|
sInKeyDispatch = PR_FALSE;
|
|
|
|
return rv;
|
2002-02-20 06:23:50 +03:00
|
|
|
#else
|
2002-02-02 03:23:30 +03:00
|
|
|
if (mInstance) {
|
|
|
|
// If this event is going to the plugin, we want to kill it.
|
|
|
|
// Not actually sending keypress to the plugin, since we didn't before.
|
|
|
|
aKeyEvent->PreventDefault();
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2002-02-20 06:23:50 +03:00
|
|
|
#endif
|
2001-01-17 23:04:09 +03:00
|
|
|
}
|
2002-02-02 03:23:30 +03:00
|
|
|
|
2001-01-17 23:04:09 +03:00
|
|
|
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
2002-09-26 06:53:27 +04:00
|
|
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aKeyEvent->PreventDefault(); // consume event
|
2001-12-30 01:32:55 +03:00
|
|
|
// continue only for cases without child window
|
|
|
|
#endif
|
|
|
|
|
2001-03-06 06:31:29 +03:00
|
|
|
if (mInstance) {
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aKeyEvent));
|
|
|
|
if (privateEvent) {
|
|
|
|
nsKeyEvent* keyEvent = nsnull;
|
|
|
|
privateEvent->GetInternalNSEvent((nsEvent**)&keyEvent);
|
|
|
|
if (keyEvent) {
|
|
|
|
nsEventStatus rv = ProcessEvent(*keyEvent);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == rv) {
|
|
|
|
aKeyEvent->PreventDefault();
|
2001-12-06 09:57:03 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
|
|
|
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
2001-03-06 06:31:29 +03:00
|
|
|
}
|
2001-01-17 23:04:09 +03:00
|
|
|
}
|
2001-03-06 06:31:29 +03:00
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchKeyToPlugin failed, keyEvent null");
|
2001-01-17 23:04:09 +03:00
|
|
|
}
|
2001-03-06 06:31:29 +03:00
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchKeyToPlugin failed, privateEvent null");
|
2001-01-17 23:04:09 +03:00
|
|
|
}
|
2001-12-30 01:32:55 +03:00
|
|
|
|
2001-01-17 23:04:09 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-10-18 03:13:30 +04:00
|
|
|
|
2001-08-07 05:48:14 +04:00
|
|
|
/*=============== nsIMouseMotionListener ======================*/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
2002-09-26 06:53:27 +04:00
|
|
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aMouseEvent->PreventDefault(); // consume event
|
2001-08-07 05:48:14 +04:00
|
|
|
// continue only for cases without child window
|
|
|
|
#endif
|
|
|
|
|
2002-05-20 07:29:48 +04:00
|
|
|
// don't send mouse events if we are hiddden
|
|
|
|
if (!mWidgetVisible)
|
|
|
|
return NS_OK;
|
|
|
|
|
2001-08-07 05:48:14 +04:00
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (privateEvent) {
|
|
|
|
nsMouseEvent* mouseEvent = nsnull;
|
|
|
|
privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent);
|
|
|
|
if (mouseEvent) {
|
|
|
|
nsEventStatus rv = ProcessEvent(*mouseEvent);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == rv) {
|
2004-04-13 05:51:00 +04:00
|
|
|
return aMouseEvent->PreventDefault(); // consume event
|
2001-08-07 05:48:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseMove failed, mouseEvent null");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseMove failed, privateEvent null");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
/*=============== nsIMouseListener ======================*/
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
2002-09-26 06:53:27 +04:00
|
|
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aMouseEvent->PreventDefault(); // consume event
|
2001-08-07 05:48:14 +04:00
|
|
|
// continue only for cases without child window
|
|
|
|
#endif
|
|
|
|
|
2002-02-02 03:23:30 +03:00
|
|
|
// if the plugin is windowless, we need to set focus ourselves
|
|
|
|
// otherwise, we might not get key events
|
2005-10-12 06:15:26 +04:00
|
|
|
if (mOwner && mPluginWindow &&
|
|
|
|
mPluginWindow->type == nsPluginWindowType_Drawable) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2002-02-02 03:23:30 +03:00
|
|
|
if (content)
|
2005-10-12 06:15:26 +04:00
|
|
|
content->SetFocus(mOwner->GetPresContext());
|
2002-02-02 03:23:30 +03:00
|
|
|
}
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (privateEvent) {
|
|
|
|
nsMouseEvent* mouseEvent = nsnull;
|
|
|
|
privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent);
|
|
|
|
if (mouseEvent) {
|
|
|
|
nsEventStatus rv = ProcessEvent(*mouseEvent);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == rv) {
|
2004-04-13 05:51:00 +04:00
|
|
|
return aMouseEvent->PreventDefault(); // consume event
|
2000-10-18 03:13:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseDown failed, mouseEvent null");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseDown failed, privateEvent null");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseUp(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2001-01-28 03:37:48 +03:00
|
|
|
return DispatchMouseToPlugin(aMouseEvent);
|
2000-10-18 03:13:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mOwner->IsBroken()) {
|
|
|
|
FirePluginNotFoundEvent(mOwner->GetContent());
|
|
|
|
|
|
|
|
aMouseEvent->PreventDefault();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-28 03:37:48 +03:00
|
|
|
return DispatchMouseToPlugin(aMouseEvent);
|
2000-10-18 03:13:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2001-01-28 03:37:48 +03:00
|
|
|
return DispatchMouseToPlugin(aMouseEvent);
|
2000-10-18 03:13:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseOver(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2001-01-28 03:37:48 +03:00
|
|
|
return DispatchMouseToPlugin(aMouseEvent);
|
2000-10-18 03:13:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2001-01-28 03:37:48 +03:00
|
|
|
return DispatchMouseToPlugin(aMouseEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if !(defined(XP_MAC) || defined(XP_MACOSX))
|
2002-09-26 06:53:27 +04:00
|
|
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
2004-04-13 05:51:00 +04:00
|
|
|
return aMouseEvent->PreventDefault(); // consume event
|
2001-08-07 05:48:14 +04:00
|
|
|
// continue only for cases without child window
|
|
|
|
#endif
|
|
|
|
|
2002-05-20 07:29:48 +04:00
|
|
|
// don't send mouse events if we are hiddden
|
|
|
|
if (!mWidgetVisible)
|
|
|
|
return NS_OK;
|
|
|
|
|
2001-01-28 03:37:48 +03:00
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
if (privateEvent) {
|
|
|
|
nsMouseEvent* mouseEvent = nsnull;
|
|
|
|
privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent);
|
|
|
|
if (mouseEvent) {
|
|
|
|
nsEventStatus rv = ProcessEvent(*mouseEvent);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == rv) {
|
|
|
|
aMouseEvent->PreventDefault();
|
2001-12-06 09:57:03 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
|
|
|
|
|
|
|
|
if (nsevent) {
|
|
|
|
nsevent->PreventBubble();
|
|
|
|
}
|
2001-01-28 03:37:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchMouseToPlugin failed, mouseEvent null");
|
|
|
|
}
|
|
|
|
else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchMouseToPlugin failed, privateEvent null");
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
|
|
|
|
{
|
2001-12-30 01:32:55 +03:00
|
|
|
// printf("nsGUIEvent.message: %d\n", anEvent.message);
|
2001-01-12 02:56:35 +03:00
|
|
|
nsEventStatus rv = nsEventStatus_eIgnore;
|
2001-01-11 02:51:07 +03:00
|
|
|
if (!mInstance) // if mInstance is null, we shouldn't be here
|
|
|
|
return rv;
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2005-01-05 03:21:06 +03:00
|
|
|
// check for null mWidget
|
|
|
|
if (mWidget) {
|
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
|
|
|
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
|
|
|
EventRecord macEvent;
|
|
|
|
EventRecord* event = (EventRecord*)anEvent.nativeMsg;
|
|
|
|
if ((event == NULL) || (event->what == nullEvent) ||
|
2005-10-14 02:39:36 +04:00
|
|
|
(anEvent.message == NS_FOCUS_CONTENT) ||
|
2005-01-05 03:21:06 +03:00
|
|
|
(anEvent.message == NS_BLUR_CONTENT) ||
|
|
|
|
(anEvent.message == NS_MOUSE_MOVE) ||
|
|
|
|
(anEvent.message == NS_MOUSE_ENTER)) {
|
|
|
|
GUItoMacEvent(anEvent, event, macEvent);
|
|
|
|
event = &macEvent;
|
|
|
|
}
|
2003-02-28 02:35:47 +03:00
|
|
|
|
2005-10-14 02:39:36 +04:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
|
|
|
if (anEvent.message == NS_FOCUS_CONTENT)
|
|
|
|
{
|
|
|
|
// Work around an issue in the Flash plugin, which can cache a pointer
|
|
|
|
// to a doomed TSM document (one that belongs to a NSTSMInputContext)
|
|
|
|
// and try to activate it after it has been deleted. See bug 183313.
|
|
|
|
::DeactivateTSMDocument(::TSMGetActiveDocument());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
nsPluginPort* pluginPort = FixUpPluginWindow(ePluginPaintIgnore);
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
if (pluginPort) {
|
|
|
|
nsPluginEvent pluginEvent =
|
|
|
|
{
|
|
|
|
event,
|
|
|
|
nsPluginPlatformWindowRef(GetWindowFromPort(pluginPort->port))
|
|
|
|
};
|
2003-02-28 02:35:47 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
2003-02-28 02:35:47 +03:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (eventHandled && !(anEvent.message == NS_MOUSE_LEFT_BUTTON_DOWN &&
|
|
|
|
!mContentFocused))
|
|
|
|
rv = nsEventStatus_eConsumeNoDefault;
|
|
|
|
|
|
|
|
pluginWidget->EndDrawPlugin();
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2005-01-05 03:21:06 +03:00
|
|
|
// this code supports windowless plugins
|
|
|
|
nsPluginEvent * pPluginEvent = (nsPluginEvent *)anEvent.nativeMsg;
|
|
|
|
// we can get synthetic events from the nsEventStateManager... these
|
|
|
|
// have no nativeMsg
|
2005-10-16 22:58:34 +04:00
|
|
|
nsPluginEvent pluginEvent;
|
2005-09-28 18:29:45 +04:00
|
|
|
if (!pPluginEvent) {
|
|
|
|
switch (anEvent.message) {
|
|
|
|
case NS_FOCUS_CONTENT:
|
|
|
|
pluginEvent.event = WM_SETFOCUS;
|
|
|
|
pluginEvent.wParam = 0;
|
|
|
|
pluginEvent.lParam = 0;
|
|
|
|
pPluginEvent = &pluginEvent;
|
|
|
|
break;
|
|
|
|
case NS_BLUR_CONTENT:
|
|
|
|
pluginEvent.event = WM_KILLFOCUS;
|
|
|
|
pluginEvent.wParam = 0;
|
|
|
|
pluginEvent.lParam = 0;
|
|
|
|
pPluginEvent = &pluginEvent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (pPluginEvent) {
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(pPluginEvent, &eventHandled);
|
|
|
|
if (eventHandled)
|
|
|
|
rv = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
nsresult
|
|
|
|
nsPluginInstanceOwner::Destroy()
|
|
|
|
{
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2001-03-20 02:26:41 +03:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
// stop the timer explicitly to reduce reference count.
|
|
|
|
CancelTimer();
|
|
|
|
|
2002-01-16 01:45:26 +03:00
|
|
|
// unregister context menu listener
|
|
|
|
if (mCXMenuListener) {
|
|
|
|
mCXMenuListener->Destroy(mOwner);
|
|
|
|
NS_RELEASE(mCXMenuListener);
|
|
|
|
}
|
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(content));
|
|
|
|
if (receiver) {
|
2001-03-20 01:10:23 +03:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
nsCOMPtr<nsIDOMEventListener> listener;
|
|
|
|
QueryInterface(NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener));
|
2001-09-28 07:34:53 +04:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
// Unregister focus event listener
|
|
|
|
receiver->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMFocusListener));
|
|
|
|
|
|
|
|
// Unregister mouse event listener
|
|
|
|
receiver->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
|
|
|
|
// now for the mouse motion listener
|
|
|
|
receiver->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseMotionListener));
|
|
|
|
|
|
|
|
// Unregister key event listener;
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("keypress"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("keydown"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("keyup"), listener, PR_TRUE);
|
|
|
|
|
|
|
|
// Unregister drag event listener;
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("dragdrop"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("dragover"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("dragexit"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("dragenter"), listener, PR_TRUE);
|
|
|
|
receiver->RemoveEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
|
2002-07-02 17:52:05 +04:00
|
|
|
}
|
|
|
|
|
2002-01-18 23:12:29 +03:00
|
|
|
// Unregister scroll position listener
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIFrame* parentWithView = mOwner->GetAncestorWithView();
|
|
|
|
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
|
2005-01-05 03:21:06 +03:00
|
|
|
while (curView) {
|
2004-11-24 03:19:21 +03:00
|
|
|
nsIScrollableView* scrollingView = curView->ToScrollableView();
|
|
|
|
if (scrollingView)
|
2003-02-28 02:35:47 +03:00
|
|
|
scrollingView->RemoveScrollPositionListener((nsIScrollPositionListener *)this);
|
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
curView = curView->GetParent();
|
2002-01-18 23:12:29 +03:00
|
|
|
}
|
|
|
|
|
2001-09-28 07:34:53 +04:00
|
|
|
mOwner = nsnull; // break relationship between frame and plugin instance owner
|
|
|
|
|
2000-10-18 03:13:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
// Paints are handled differently, so we just simulate an update event.
|
|
|
|
|
|
|
|
void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, PRUint32 ndc)
|
|
|
|
{
|
2005-10-12 06:15:26 +04:00
|
|
|
if (!mInstance || !mOwner)
|
2001-12-22 03:25:25 +03:00
|
|
|
return;
|
|
|
|
|
2005-09-29 02:40:49 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2000-10-18 01:45:39 +04:00
|
|
|
#ifdef DO_DIRTY_INTERSECT // aDirtyRect isn't always correct, see bug 56128
|
2001-12-22 03:25:25 +03:00
|
|
|
nsPoint rel(aDirtyRect.x, aDirtyRect.y);
|
|
|
|
nsPoint abs(0,0);
|
|
|
|
nsCOMPtr<nsIWidget> containerWidget;
|
|
|
|
|
|
|
|
// Convert dirty rect relative coordinates to absolute and also get the containerWidget
|
2004-12-26 22:48:54 +03:00
|
|
|
ConvertRelativeToWindowAbsolute(mOwner, rel, abs, *getter_AddRefs(containerWidget));
|
2000-10-18 01:45:39 +04:00
|
|
|
|
2001-12-22 03:25:25 +03:00
|
|
|
nsRect absDirtyRect = nsRect(abs.x, abs.y, aDirtyRect.width, aDirtyRect.height);
|
2000-10-18 01:45:39 +04:00
|
|
|
|
2001-12-22 03:25:25 +03:00
|
|
|
// Convert to absolute pixel values for the dirty rect
|
|
|
|
nsRect absDirtyRectInPixels;
|
2005-10-12 06:15:26 +04:00
|
|
|
ConvertTwipsToPixels(*mOwner->GetPresContext(), absDirtyRect,
|
|
|
|
absDirtyRectInPixels);
|
2000-10-18 01:45:39 +04:00
|
|
|
#endif
|
|
|
|
|
2003-02-28 02:35:47 +03:00
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
2003-02-28 02:35:47 +03:00
|
|
|
nsPluginPort* pluginPort = FixUpPluginWindow(ePluginPaintEnable);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (pluginPort) {
|
2003-02-28 02:35:47 +03:00
|
|
|
WindowRef nativeWindowRef = ::GetWindowFromPort(pluginPort->port);
|
|
|
|
|
|
|
|
EventRecord updateEvent;
|
|
|
|
InitializeEventRecord(&updateEvent);
|
|
|
|
updateEvent.what = updateEvt;
|
|
|
|
updateEvent.message = UInt32(nativeWindowRef);
|
|
|
|
|
|
|
|
nsPluginEvent pluginEvent = { &updateEvent, nsPluginPlatformWindowRef(nativeWindowRef) };
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
|
|
|
}
|
|
|
|
pluginWidget->EndDrawPlugin();
|
2002-11-06 04:24:57 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2001-12-22 03:25:25 +03:00
|
|
|
nsPluginWindow * window;
|
|
|
|
GetWindow(window);
|
|
|
|
nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
|
|
|
nsRect relDirtyRectInPixels;
|
2005-10-12 06:15:26 +04:00
|
|
|
ConvertTwipsToPixels(*mOwner->GetPresContext(), relDirtyRect,
|
|
|
|
relDirtyRectInPixels);
|
2001-12-22 03:25:25 +03:00
|
|
|
|
|
|
|
// we got dirty rectangle in relative window coordinates, but we
|
|
|
|
// need it in absolute units and in the (left, top, right, bottom) form
|
|
|
|
RECT drc;
|
|
|
|
drc.left = relDirtyRectInPixels.x + window->x;
|
|
|
|
drc.top = relDirtyRectInPixels.y + window->y;
|
|
|
|
drc.right = drc.left + relDirtyRectInPixels.width;
|
|
|
|
drc.bottom = drc.top + relDirtyRectInPixels.height;
|
|
|
|
|
|
|
|
nsPluginEvent pluginEvent;
|
2005-09-28 18:29:45 +04:00
|
|
|
pluginEvent.event = WM_PAINT;
|
1999-07-07 06:33:17 +04:00
|
|
|
pluginEvent.wParam = (uint32)ndc;
|
2001-12-22 03:25:25 +03:00
|
|
|
pluginEvent.lParam = (uint32)&drc;
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Here's how we give idle time to plugins.
|
|
|
|
|
2002-09-07 09:38:16 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* /* timer */)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2001-01-12 02:56:35 +03:00
|
|
|
// validate the plugin clipping information by syncing the plugin window info to
|
|
|
|
// reflect the current widget location. This makes sure that everything is updated
|
|
|
|
// correctly in the event of scrolling in the window.
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mInstance) {
|
2003-02-28 02:35:47 +03:00
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
2003-02-28 02:35:47 +03:00
|
|
|
nsPluginPort* pluginPort = FixUpPluginWindow(ePluginPaintIgnore);
|
|
|
|
if (pluginPort) {
|
|
|
|
EventRecord idleEvent;
|
|
|
|
InitializeEventRecord(&idleEvent);
|
|
|
|
idleEvent.what = nullEvent;
|
|
|
|
|
|
|
|
// give a bogus 'where' field of our null event when hidden, so Flash
|
|
|
|
// won't respond to mouse moves in other tabs, see bug 120875
|
|
|
|
if (!mWidgetVisible)
|
|
|
|
idleEvent.where.h = idleEvent.where.v = 20000;
|
|
|
|
|
|
|
|
nsPluginEvent pluginEvent = { &idleEvent, nsPluginPlatformWindowRef(GetWindowFromPort(pluginPort->port)) };
|
|
|
|
|
|
|
|
PRBool eventHandled = PR_FALSE;
|
|
|
|
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginWidget->EndDrawPlugin();
|
|
|
|
}
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
#endif
|
2002-11-06 04:24:57 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
void nsPluginInstanceOwner::StartTimer()
|
|
|
|
{
|
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// start a periodic timer to provide null events to the plugin instance.
|
|
|
|
if (!mPluginTimer) {
|
|
|
|
mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
2003-02-28 02:35:47 +03:00
|
|
|
if (NS_SUCCEEDED(rv))
|
2002-11-06 04:24:57 +03:00
|
|
|
rv = mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_REPEATING_SLACK);
|
|
|
|
}
|
2000-01-22 00:56:09 +03:00
|
|
|
#endif
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsPluginInstanceOwner::CancelTimer()
|
|
|
|
{
|
2001-01-12 02:56:35 +03:00
|
|
|
if (mPluginTimer) {
|
|
|
|
mPluginTimer->Cancel();
|
2001-07-11 06:29:45 +04:00
|
|
|
mPluginTimer = nsnull;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::Init(nsPresContext* aPresContext, nsObjectFrame *aFrame)
|
1999-07-07 06:33:17 +04:00
|
|
|
{
|
|
|
|
//do not addref to avoid circular refs. MMP
|
|
|
|
mOwner = aFrame;
|
2001-03-20 02:26:41 +03:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIContent* content = mOwner->GetContent();
|
2001-03-20 02:26:41 +03:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
// Some plugins require a specific sequence of shutdown and startup when
|
|
|
|
// a page is reloaded. Shutdown happens usually when the last instance
|
|
|
|
// is destroyed. Here we make sure the plugin instance in the old
|
|
|
|
// document is destroyed before we try to create the new one.
|
2005-01-20 06:39:09 +03:00
|
|
|
aPresContext->EnsureVisible(PR_TRUE);
|
2001-08-02 04:03:29 +04:00
|
|
|
|
2002-01-16 01:45:26 +03:00
|
|
|
// register context menu listener
|
|
|
|
mCXMenuListener = new nsPluginDOMContextMenuListener();
|
|
|
|
if (mCXMenuListener) {
|
|
|
|
NS_ADDREF(mCXMenuListener);
|
|
|
|
mCXMenuListener->Init(aFrame);
|
|
|
|
}
|
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(content));
|
|
|
|
if (receiver) {
|
2001-03-20 02:26:41 +03:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
nsCOMPtr<nsIDOMEventListener> listener;
|
|
|
|
QueryInterface(NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener));
|
2002-01-16 01:45:26 +03:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
// Register focus listener
|
|
|
|
receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMFocusListener));
|
2002-07-02 17:52:05 +04:00
|
|
|
|
2003-04-02 07:35:58 +04:00
|
|
|
// Register mouse listener
|
|
|
|
receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
|
|
|
|
// now do the mouse motion listener
|
|
|
|
receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseMotionListener));
|
|
|
|
|
|
|
|
// Register key listener
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("keypress"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("keydown"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("keyup"), listener, PR_TRUE);
|
|
|
|
|
|
|
|
// Register drag listener
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("dragdrop"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("dragover"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("dragexit"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("dragenter"), listener, PR_TRUE);
|
|
|
|
receiver->AddEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
|
2002-07-02 17:52:05 +04:00
|
|
|
}
|
2001-01-17 23:04:09 +03:00
|
|
|
|
2002-01-18 23:12:29 +03:00
|
|
|
// Register scroll position listener
|
2003-02-28 02:35:47 +03:00
|
|
|
// We need to register a scroll pos listener on every scrollable
|
|
|
|
// view up to the top
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIFrame* parentWithView = mOwner->GetAncestorWithView();
|
|
|
|
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
|
2005-01-05 03:21:06 +03:00
|
|
|
while (curView) {
|
2004-11-24 03:19:21 +03:00
|
|
|
nsIScrollableView* scrollingView = curView->ToScrollableView();
|
|
|
|
if (scrollingView)
|
2003-02-28 02:35:47 +03:00
|
|
|
scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)this);
|
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
curView = curView->GetParent();
|
2002-01-18 23:12:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginPort* nsPluginInstanceOwner::GetPluginPort()
|
|
|
|
{
|
|
|
|
//!!! Port must be released for windowless plugins on Windows, because it is HDC !!!
|
|
|
|
|
|
|
|
nsPluginPort* result = NULL;
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mWidget) {
|
1999-07-07 06:33:17 +04:00
|
|
|
#ifdef XP_WIN
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
|
1999-07-07 06:33:17 +04:00
|
|
|
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
|
|
|
return result;
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
|
|
|
|
{
|
|
|
|
#ifdef XP_WIN
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mWidget && mPluginWindow &&
|
|
|
|
mPluginWindow->type == nsPluginWindowType_Drawable) {
|
|
|
|
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
|
|
|
{
|
2002-09-26 06:53:27 +04:00
|
|
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
nsIView *view;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (mOwner) {
|
1999-07-07 06:33:17 +04:00
|
|
|
// Create view if necessary
|
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
view = mOwner->GetView();
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (!view || !mWidget) {
|
2002-03-22 07:19:10 +03:00
|
|
|
PRBool windowless = PR_FALSE;
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
mInstance->GetValue(nsPluginInstanceVariable_WindowlessBool,
|
|
|
|
(void *)&windowless);
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2001-01-12 02:56:35 +03:00
|
|
|
// always create widgets in Twips, not pixels
|
2005-10-12 06:15:26 +04:00
|
|
|
float p2t = mOwner->GetPresContext()->ScaledPixelsToTwips();
|
2004-12-26 22:48:54 +03:00
|
|
|
rv = mOwner->CreateWidget(NSIntPixelsToTwips(mPluginWindow->width, p2t),
|
2002-09-26 06:53:27 +04:00
|
|
|
NSIntPixelsToTwips(mPluginWindow->height, p2t),
|
1999-07-07 06:33:17 +04:00
|
|
|
windowless);
|
2005-01-05 03:21:06 +03:00
|
|
|
if (NS_OK == rv) {
|
2003-06-30 14:46:59 +04:00
|
|
|
view = mOwner->GetView();
|
2005-01-05 03:21:06 +03:00
|
|
|
|
|
|
|
if (view) {
|
2003-06-30 14:46:59 +04:00
|
|
|
mWidget = view->GetWidget();
|
2002-03-22 07:19:10 +03:00
|
|
|
PRBool fTransparent = PR_FALSE;
|
2005-01-05 03:21:06 +03:00
|
|
|
mInstance->GetValue(nsPluginInstanceVariable_TransparentBool,
|
|
|
|
(void *)&fTransparent);
|
2001-12-01 17:31:45 +03:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
view->GetViewManager()->SetViewContentTransparency(view,
|
|
|
|
fTransparent);
|
2001-06-19 01:41:57 +04:00
|
|
|
}
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
if (PR_TRUE == windowless) {
|
2002-09-26 06:53:27 +04:00
|
|
|
mPluginWindow->type = nsPluginWindowType_Drawable;
|
2001-06-19 01:41:57 +04:00
|
|
|
|
2005-01-05 03:21:06 +03:00
|
|
|
// this needs to be a HDC according to the spec, but I do
|
|
|
|
// not see the right way to release it so let's postpone
|
|
|
|
// passing HDC till paint event when it is really
|
|
|
|
// needed. Change spec?
|
|
|
|
mPluginWindow->window = nsnull;
|
|
|
|
} else if (mWidget) {
|
|
|
|
mWidget->Resize(mPluginWindow->width, mPluginWindow->height,
|
|
|
|
PR_FALSE);
|
|
|
|
|
|
|
|
// mPluginWindow->type is used in |GetPluginPort| so it must
|
|
|
|
// be initilized first
|
2002-09-26 06:53:27 +04:00
|
|
|
mPluginWindow->type = nsPluginWindowType_Window;
|
|
|
|
mPluginWindow->window = GetPluginPort();
|
1999-07-07 06:33:17 +04:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
// start the idle timer.
|
|
|
|
StartTimer();
|
2003-03-11 03:54:18 +03:00
|
|
|
|
|
|
|
// tell the plugin window about the widget
|
|
|
|
mPluginWindow->SetPluginWidget(mWidget);
|
1999-07-07 06:33:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-05 03:21:06 +03:00
|
|
|
|
1999-07-07 06:33:17 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsPluginInstanceOwner::SetPluginHost(nsIPluginHost* aHost)
|
|
|
|
{
|
|
|
|
mPluginHost = aHost;
|
|
|
|
}
|
2000-09-29 03:29:26 +04:00
|
|
|
|
2004-11-15 21:12:35 +03:00
|
|
|
#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && (defined(XP_MAC) || defined(XP_MACOSX)))
|
2001-12-22 03:25:25 +03:00
|
|
|
// convert frame coordinates from twips to pixels
|
2004-08-01 03:15:21 +04:00
|
|
|
static void ConvertTwipsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect)
|
2001-12-22 03:25:25 +03:00
|
|
|
{
|
|
|
|
float t2p;
|
2004-02-11 07:57:07 +03:00
|
|
|
t2p = aPresContext.TwipsToPixels();
|
2001-12-22 03:25:25 +03:00
|
|
|
aPixelRect.x = NSTwipsToIntPixels(aTwipsRect.x, t2p);
|
|
|
|
aPixelRect.y = NSTwipsToIntPixels(aTwipsRect.y, t2p);
|
|
|
|
aPixelRect.width = NSTwipsToIntPixels(aTwipsRect.width, t2p);
|
|
|
|
aPixelRect.height = NSTwipsToIntPixels(aTwipsRect.height, t2p);
|
|
|
|
}
|
2003-05-24 02:14:21 +04:00
|
|
|
#endif
|
2000-09-29 03:29:26 +04:00
|
|
|
|
|
|
|
// Mac specific code to fix up the port location and clipping region
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
2000-10-18 01:45:39 +04:00
|
|
|
|
|
|
|
#ifdef DO_DIRTY_INTERSECT
|
|
|
|
// Convert from a frame relative coordinate to a coordinate relative to its
|
|
|
|
// containing window
|
2004-12-26 22:48:54 +03:00
|
|
|
static void ConvertRelativeToWindowAbsolute(nsIFrame* aFrame,
|
|
|
|
nsPoint& aRel,
|
|
|
|
nsPoint& aAbs,
|
|
|
|
nsIWidget*& aContainerWidget)
|
2000-10-18 01:45:39 +04:00
|
|
|
{
|
|
|
|
// See if this frame has a view
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIView *view = aFrame->GetView();
|
|
|
|
if (!view) {
|
|
|
|
aAbs.x = 0;
|
|
|
|
aAbs.y = 0;
|
|
|
|
// Calculate frames offset from its nearest view
|
2004-12-26 22:48:54 +03:00
|
|
|
aFrame->GetOffsetFromView(aAbs, &view);
|
2000-10-18 01:45:39 +04:00
|
|
|
} else {
|
2003-06-30 14:46:59 +04:00
|
|
|
// Store frames offset from its view.
|
|
|
|
aAbs = aFrame->GetPosition();
|
2000-10-18 01:45:39 +04:00
|
|
|
}
|
|
|
|
|
2004-01-30 06:20:41 +03:00
|
|
|
NS_ASSERTION(view, "the object frame does not have a view");
|
2003-06-30 14:46:59 +04:00
|
|
|
if (view) {
|
2004-01-30 06:20:41 +03:00
|
|
|
// Calculate the view's offset from its nearest widget
|
|
|
|
nsPoint viewOffset;
|
|
|
|
aContainerWidget = view->GetNearestWidget(&viewOffset);
|
|
|
|
NS_IF_ADDREF(aContainerWidget);
|
|
|
|
aAbs += viewOffset;
|
2000-10-18 01:45:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add relative coordinate to the absolute coordinate that has been calculated
|
|
|
|
aAbs += aRel;
|
|
|
|
}
|
2001-01-12 02:56:35 +03:00
|
|
|
#endif // DO_DIRTY_INTERSECT
|
|
|
|
|
2003-02-28 02:35:47 +03:00
|
|
|
nsPluginPort* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
|
2001-01-12 02:56:35 +03:00
|
|
|
{
|
2002-09-26 06:53:27 +04:00
|
|
|
if (!mWidget || !mPluginWindow)
|
2002-11-06 04:24:57 +03:00
|
|
|
return nsnull;
|
2002-09-26 06:53:27 +04:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
nsPluginPort* pluginPort = GetPluginPort();
|
|
|
|
|
|
|
|
if (!pluginPort)
|
|
|
|
return nsnull;
|
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
// first, check our view for CSS visibility style
|
2003-06-30 14:46:59 +04:00
|
|
|
PRBool isVisible =
|
|
|
|
mOwner->GetView()->GetVisibility() == nsViewVisibility_kShow;
|
2003-02-28 02:35:47 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
2002-09-26 06:53:27 +04:00
|
|
|
|
2003-02-28 02:35:47 +03:00
|
|
|
nsPoint pluginOrigin;
|
|
|
|
nsRect widgetClip;
|
|
|
|
PRBool widgetVisible;
|
2005-09-29 02:40:49 +04:00
|
|
|
pluginWidget->GetPluginClipRect(widgetClip, pluginOrigin, /* out */ widgetVisible);
|
|
|
|
|
|
|
|
// printf("GetPluginClipRect returning visible %d\n", widgetVisible);
|
|
|
|
|
|
|
|
isVisible &= widgetVisible;
|
2003-02-28 02:35:47 +03:00
|
|
|
if (!isVisible)
|
|
|
|
widgetClip.Empty();
|
2005-09-29 02:40:49 +04:00
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
// set the port coordinates
|
|
|
|
mPluginWindow->x = -pluginPort->portx;
|
|
|
|
mPluginWindow->y = -pluginPort->porty;
|
2002-09-26 06:53:27 +04:00
|
|
|
|
2005-09-29 02:40:49 +04:00
|
|
|
nsPluginRect oldClipRect = mPluginWindow->clipRect;
|
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
// fix up the clipping region
|
2003-02-28 02:35:47 +03:00
|
|
|
mPluginWindow->clipRect.top = widgetClip.y;
|
|
|
|
mPluginWindow->clipRect.left = widgetClip.x;
|
|
|
|
|
2005-09-29 02:40:49 +04:00
|
|
|
mWidgetVisible = isVisible;
|
|
|
|
|
|
|
|
if (!mWidgetVisible || inPaintState == ePluginPaintDisable) {
|
2003-02-28 02:35:47 +03:00
|
|
|
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top;
|
|
|
|
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left;
|
2005-09-29 02:40:49 +04:00
|
|
|
// pluginPort = nsnull; // don't uncomment this
|
2003-02-28 02:35:47 +03:00
|
|
|
}
|
2005-09-29 02:40:49 +04:00
|
|
|
else if (inPaintState == ePluginPaintEnable)
|
|
|
|
{
|
|
|
|
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
|
|
|
|
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
|
2002-11-06 04:24:57 +03:00
|
|
|
}
|
2005-09-29 02:40:49 +04:00
|
|
|
|
|
|
|
// if the clip rect changed, call SetWindow()
|
|
|
|
// (RealPlayer needs this to draw correctly)
|
|
|
|
if (mPluginWindow->clipRect.left != oldClipRect.left ||
|
|
|
|
mPluginWindow->clipRect.top != oldClipRect.top ||
|
|
|
|
mPluginWindow->clipRect.right != oldClipRect.right ||
|
|
|
|
mPluginWindow->clipRect.bottom != oldClipRect.bottom)
|
|
|
|
{
|
|
|
|
mInstance->SetWindow(mPluginWindow);
|
2002-11-06 04:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return pluginPort;
|
2001-01-12 02:56:35 +03:00
|
|
|
}
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#endif // XP_MAC || XP_MACOSX
|
2003-02-28 02:35:47 +03:00
|
|
|
|