LCOV - code coverage report
Current view: directory - content/html/content/src - nsHTMLSharedObjectElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 173 3 1.7 %
Date: 2012-06-02 Functions: 160 3 1.9 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : // vim:set et sw=2 sts=2 cin:
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Communicator client code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "mozilla/Util.h"
      40                 : 
      41                 : #include "nsGenericHTMLElement.h"
      42                 : #include "nsObjectLoadingContent.h"
      43                 : #include "nsGkAtoms.h"
      44                 : #include "nsDOMError.h"
      45                 : #include "nsIDocument.h"
      46                 : #include "nsIDOMDocument.h"
      47                 : #include "nsIDOMHTMLAppletElement.h"
      48                 : #include "nsIDOMHTMLEmbedElement.h"
      49                 : #include "nsThreadUtils.h"
      50                 : #include "nsIDOMGetSVGDocument.h"
      51                 : #include "nsIDOMSVGDocument.h"
      52                 : #include "nsIScriptError.h"
      53                 : #include "nsIWidget.h"
      54                 : 
      55                 : using namespace mozilla;
      56                 : using namespace mozilla::dom;
      57                 : 
      58                 : class nsHTMLSharedObjectElement : public nsGenericHTMLElement
      59                 :                                 , public nsObjectLoadingContent
      60                 :                                 , public nsIDOMHTMLAppletElement
      61                 :                                 , public nsIDOMHTMLEmbedElement
      62                 :                                 , public nsIDOMGetSVGDocument
      63                 : {
      64                 : public:
      65                 :   nsHTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
      66                 :                             mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
      67                 :   virtual ~nsHTMLSharedObjectElement();
      68                 : 
      69                 :   // nsISupports
      70                 :   NS_DECL_ISUPPORTS_INHERITED
      71                 : 
      72                 :   // nsIDOMNode
      73               0 :   NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
      74                 : 
      75                 :   // nsIDOMElement
      76               0 :   NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
      77                 : 
      78                 :   // nsIDOMHTMLElement
      79               0 :   NS_FORWARD_NSIDOMHTMLELEMENT_BASIC(nsGenericHTMLElement::)
      80               0 :   NS_SCRIPTABLE NS_IMETHOD Click() {
      81               0 :     return nsGenericHTMLElement::Click();
      82                 :   }
      83                 :   NS_SCRIPTABLE NS_IMETHOD GetTabIndex(PRInt32* aTabIndex);
      84                 :   NS_SCRIPTABLE NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
      85               0 :   NS_SCRIPTABLE NS_IMETHOD Focus() {
      86               0 :     return nsGenericHTMLElement::Focus();
      87                 :   }
      88               0 :   NS_SCRIPTABLE NS_IMETHOD GetDraggable(bool* aDraggable) {
      89               0 :     return nsGenericHTMLElement::GetDraggable(aDraggable);
      90                 :   }
      91               0 :   NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) {
      92               0 :     return nsGenericHTMLElement::GetInnerHTML(aInnerHTML);
      93                 :   }
      94               0 :   NS_SCRIPTABLE NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) {
      95               0 :     return nsGenericHTMLElement::SetInnerHTML(aInnerHTML);
      96                 :   }
      97                 : 
      98                 :   // nsIDOMHTMLAppletElement
      99                 :   NS_DECL_NSIDOMHTMLAPPLETELEMENT
     100                 : 
     101                 :   // Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
     102                 :   // NS_DECL_NSIDOMHTMLAPPLETELEMENT.
     103                 : 
     104                 :   // nsIDOMHTMLEmbedElement
     105                 :   NS_IMETHOD GetSrc(nsAString &aSrc);
     106                 :   NS_IMETHOD SetSrc(const nsAString &aSrc);
     107                 :   NS_IMETHOD GetType(nsAString &aType);
     108                 :   NS_IMETHOD SetType(const nsAString &aType);
     109                 : 
     110                 :   // nsIDOMGetSVGDocument
     111                 :   NS_DECL_NSIDOMGETSVGDOCUMENT
     112                 : 
     113                 :   virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
     114                 :                               nsIContent *aBindingParent,
     115                 :                               bool aCompileEventHandlers);
     116                 :   virtual void UnbindFromTree(bool aDeep = true,
     117                 :                               bool aNullParent = true);
     118                 :   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom *aName,
     119                 :                            nsIAtom *aPrefix, const nsAString &aValue,
     120                 :                            bool aNotify);
     121                 : 
     122                 :   virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
     123                 :   virtual IMEState GetDesiredIMEState();
     124                 : 
     125                 :   virtual void DoneAddingChildren(bool aHaveNotified);
     126                 :   virtual bool IsDoneAddingChildren();
     127                 : 
     128                 :   virtual bool ParseAttribute(PRInt32 aNamespaceID,
     129                 :                                 nsIAtom *aAttribute,
     130                 :                                 const nsAString &aValue,
     131                 :                                 nsAttrValue &aResult);
     132                 :   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
     133                 :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const;
     134                 :   virtual nsEventStates IntrinsicState() const;
     135                 :   virtual void DestroyContent();
     136                 : 
     137                 :   // nsObjectLoadingContent
     138                 :   virtual PRUint32 GetCapabilities() const;
     139                 : 
     140                 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
     141                 : 
     142                 :   nsresult CopyInnerTo(nsGenericElement* aDest) const;
     143                 : 
     144               0 :   void StartObjectLoad() { StartObjectLoad(true); }
     145                 : 
     146            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLSharedObjectElement,
     147                 :                                                      nsGenericHTMLElement)
     148                 : 
     149               0 :   virtual nsXPCClassInfo* GetClassInfo()
     150                 :   {
     151               0 :     return static_cast<nsXPCClassInfo*>(GetClassInfoInternal());
     152                 :   }
     153                 :   nsIClassInfo* GetClassInfoInternal();
     154                 : private:
     155                 :   /**
     156                 :    * Calls LoadObject with the correct arguments to start the plugin load.
     157                 :    */
     158                 :   NS_HIDDEN_(void) StartObjectLoad(bool aNotify);
     159                 : 
     160               0 :   void GetTypeAttrValue(nsCString &aValue) const
     161                 :   {
     162               0 :     if (mNodeInfo->Equals(nsGkAtoms::applet)) {
     163               0 :       aValue.AppendLiteral("application/x-java-vm");
     164                 :     }
     165                 :     else {
     166               0 :       nsAutoString type;
     167               0 :       GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
     168                 : 
     169               0 :       CopyUTF16toUTF8(type, aValue);
     170                 :     }
     171               0 :   }
     172                 : 
     173               0 :   nsIAtom *URIAttrName() const
     174                 :   {
     175               0 :     return mNodeInfo->Equals(nsGkAtoms::applet) ?
     176                 :            nsGkAtoms::code :
     177               0 :            nsGkAtoms::src;
     178                 :   }
     179                 : 
     180                 :   // mIsDoneAddingChildren is only really used for <applet>.  This boolean is
     181                 :   // always true for <embed>, per the documentation in nsIContent.h.
     182                 :   bool mIsDoneAddingChildren;
     183                 : };
     184                 : 
     185                 : 
     186               0 : NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(SharedObject)
     187                 : 
     188                 : 
     189               0 : nsHTMLSharedObjectElement::nsHTMLSharedObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
     190                 :                                                      FromParser aFromParser)
     191                 :   : nsGenericHTMLElement(aNodeInfo),
     192               0 :     mIsDoneAddingChildren(mNodeInfo->Equals(nsGkAtoms::embed) || !aFromParser)
     193                 : {
     194               0 :   RegisterFreezableElement();
     195               0 :   SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
     196                 : 
     197                 :   // By default we're in the loading state
     198               0 :   AddStatesSilently(NS_EVENT_STATE_LOADING);
     199               0 : }
     200                 : 
     201               0 : nsHTMLSharedObjectElement::~nsHTMLSharedObjectElement()
     202                 : {
     203               0 :   UnregisterFreezableElement();
     204               0 :   DestroyImageLoadingContent();
     205               0 : }
     206                 : 
     207                 : bool
     208               0 : nsHTMLSharedObjectElement::IsDoneAddingChildren()
     209                 : {
     210               0 :   return mIsDoneAddingChildren;
     211                 : }
     212                 : 
     213                 : void
     214               0 : nsHTMLSharedObjectElement::DoneAddingChildren(bool aHaveNotified)
     215                 : {
     216               0 :   if (!mIsDoneAddingChildren) {
     217               0 :     mIsDoneAddingChildren = true;
     218                 : 
     219                 :     // If we're already in a document, we need to trigger the load
     220                 :     // Otherwise, BindToTree takes care of that.
     221               0 :     if (IsInDoc()) {
     222               0 :       StartObjectLoad(aHaveNotified);
     223                 :     }
     224                 :   }
     225               0 : }
     226                 : 
     227            1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLSharedObjectElement)
     228               0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLSharedObjectElement,
     229                 :                                                   nsGenericHTMLElement)
     230               0 :   nsObjectLoadingContent::Traverse(tmp, cb);
     231               0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
     232                 : 
     233               0 : NS_IMPL_ADDREF_INHERITED(nsHTMLSharedObjectElement, nsGenericElement) 
     234               0 : NS_IMPL_RELEASE_INHERITED(nsHTMLSharedObjectElement, nsGenericElement) 
     235                 : 
     236                 : DOMCI_DATA(HTMLAppletElement, nsHTMLSharedObjectElement)
     237                 : DOMCI_DATA(HTMLEmbedElement, nsHTMLSharedObjectElement)
     238                 : 
     239                 : nsIClassInfo*
     240               0 : nsHTMLSharedObjectElement::GetClassInfoInternal()
     241                 : {
     242               0 :   if (mNodeInfo->Equals(nsGkAtoms::applet)) {
     243               0 :     return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLAppletElement_id);
     244                 :   }
     245               0 :   if (mNodeInfo->Equals(nsGkAtoms::embed)) {
     246               0 :     return NS_GetDOMClassInfoInstance(eDOMClassInfo_HTMLEmbedElement_id);
     247                 :   }
     248               0 :   return nsnull;
     249                 : }
     250                 : 
     251               0 : NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSharedObjectElement)
     252                 :   NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(nsHTMLSharedObjectElement,
     253                 :                                                   nsIDOMHTMLAppletElement)
     254                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIRequestObserver)
     255                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIStreamListener)
     256                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIFrameLoaderOwner)
     257                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgIContainerObserver)
     258                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIObjectLoadingContent)
     259                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgIDecoderObserver)
     260                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIImageLoadingContent)
     261                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIInterfaceRequestor)
     262                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIChannelEventSink)
     263               0 :   NS_OFFSET_AND_INTERFACE_TABLE_END
     264               0 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(nsHTMLSharedObjectElement,
     265                 :                                                          nsGenericHTMLElement,
     266                 :                                                          nsIDOMHTMLAppletElement)
     267               0 :   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLAppletElement, applet)
     268               0 :   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLEmbedElement, embed)
     269               0 :   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMGetSVGDocument, embed)
     270               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_GETTER(GetClassInfoInternal)
     271               0 : NS_HTML_CONTENT_INTERFACE_MAP_END
     272                 : 
     273               0 : NS_IMPL_ELEMENT_CLONE(nsHTMLSharedObjectElement)
     274                 : 
     275                 : nsresult
     276               0 : nsHTMLSharedObjectElement::BindToTree(nsIDocument *aDocument,
     277                 :                                       nsIContent *aParent,
     278                 :                                       nsIContent *aBindingParent,
     279                 :                                       bool aCompileEventHandlers)
     280                 : {
     281                 :   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
     282                 :                                                  aBindingParent,
     283               0 :                                                  aCompileEventHandlers);
     284               0 :   NS_ENSURE_SUCCESS(rv, rv);
     285                 : 
     286                 :   // If we already have all the children, start the load.
     287               0 :   if (mIsDoneAddingChildren) {
     288                 :     void (nsHTMLSharedObjectElement::*start)() =
     289               0 :       &nsHTMLSharedObjectElement::StartObjectLoad;
     290               0 :     nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
     291                 :   }
     292                 : 
     293               0 :   return NS_OK;
     294                 : }
     295                 : 
     296                 : void
     297               0 : nsHTMLSharedObjectElement::UnbindFromTree(bool aDeep,
     298                 :                                           bool aNullParent)
     299                 : {
     300               0 :   RemovedFromDocument();
     301               0 :   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
     302               0 : }
     303                 : 
     304                 : 
     305                 : 
     306                 : nsresult
     307               0 : nsHTMLSharedObjectElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom *aName,
     308                 :                                    nsIAtom *aPrefix, const nsAString &aValue,
     309                 :                                    bool aNotify)
     310                 : {
     311                 :   // If we plan to call LoadObject, we want to do it first so that the
     312                 :   // object load kicks off _before_ the reflow triggered by the SetAttr.  But if
     313                 :   // aNotify is false, we are coming from the parser or some such place; we'll
     314                 :   // get bound after all the attributes have been set, so we'll do the
     315                 :   // object load from BindToTree/DoneAddingChildren.
     316                 :   // Skip the LoadObject call in that case.
     317                 :   // We also don't want to start loading the object when we're not yet in
     318                 :   // a document, just in case that the caller wants to set additional
     319                 :   // attributes before inserting the node into the document.
     320               0 :   if (aNotify && IsInDoc() && mIsDoneAddingChildren &&
     321               0 :       aNameSpaceID == kNameSpaceID_None && aName == URIAttrName()) {
     322               0 :     nsCAutoString type;
     323               0 :     GetTypeAttrValue(type);
     324               0 :     LoadObject(aValue, aNotify, type, true);
     325                 :   }
     326                 : 
     327                 :   return nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
     328               0 :                                        aNotify);
     329                 : }
     330                 : 
     331                 : bool
     332               0 : nsHTMLSharedObjectElement::IsHTMLFocusable(bool aWithMouse,
     333                 :                                            bool *aIsFocusable,
     334                 :                                            PRInt32 *aTabIndex)
     335                 : {
     336               0 :   if (mNodeInfo->Equals(nsGkAtoms::embed) || Type() == eType_Plugin) {
     337                 :     // Has plugin content: let the plugin decide what to do in terms of
     338                 :     // internal focus from mouse clicks
     339               0 :     if (aTabIndex) {
     340               0 :       GetTabIndex(aTabIndex);
     341                 :     }
     342                 : 
     343               0 :     *aIsFocusable = true;
     344                 : 
     345                 :     // Let the plugin decide, so override.
     346               0 :     return true;
     347                 :   }
     348                 : 
     349               0 :   return nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex);
     350                 : }
     351                 : 
     352                 : nsIContent::IMEState
     353               0 : nsHTMLSharedObjectElement::GetDesiredIMEState()
     354                 : {
     355               0 :   if (Type() == eType_Plugin) {
     356               0 :     return IMEState(IMEState::PLUGIN);
     357                 :   }
     358                 :    
     359               0 :   return nsGenericHTMLElement::GetDesiredIMEState();
     360                 : }
     361                 : 
     362               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Align, align)
     363               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Alt, alt)
     364               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Archive, archive)
     365               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Code, code)
     366               0 : NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, CodeBase, codebase)
     367               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Height, height)
     368               0 : NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Hspace, hspace)
     369               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Name, name)
     370               0 : NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLSharedObjectElement, Object, object, codebase)
     371               0 : NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, Src, src)
     372               0 : NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLSharedObjectElement, TabIndex, tabindex, -1)
     373               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Type, type)
     374               0 : NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Vspace, vspace)
     375               0 : NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Width, width)
     376                 : 
     377                 : NS_IMETHODIMP
     378               0 : nsHTMLSharedObjectElement::GetSVGDocument(nsIDOMDocument **aResult)
     379                 : {
     380               0 :   NS_ENSURE_ARG_POINTER(aResult);
     381                 : 
     382               0 :   *aResult = nsnull;
     383                 : 
     384               0 :   if (!IsInDoc()) {
     385               0 :     return NS_OK;
     386                 :   }
     387                 : 
     388                 :   // XXXbz should this use GetCurrentDoc()?  sXBL/XBL2 issue!
     389               0 :   nsIDocument *sub_doc = OwnerDoc()->GetSubDocumentFor(this);
     390               0 :   if (!sub_doc) {
     391               0 :     return NS_OK;
     392                 :   }
     393                 : 
     394               0 :   return CallQueryInterface(sub_doc, aResult);
     395                 : }
     396                 : 
     397                 : bool
     398               0 : nsHTMLSharedObjectElement::ParseAttribute(PRInt32 aNamespaceID,
     399                 :                                           nsIAtom *aAttribute,
     400                 :                                           const nsAString &aValue,
     401                 :                                           nsAttrValue &aResult)
     402                 : {
     403               0 :   if (aNamespaceID == kNameSpaceID_None) {
     404               0 :     if (aAttribute == nsGkAtoms::align) {
     405               0 :       return ParseAlignValue(aValue, aResult);
     406                 :     }
     407               0 :     if (ParseImageAttribute(aAttribute, aValue, aResult)) {
     408               0 :       return true;
     409                 :     }
     410                 :   }
     411                 : 
     412                 :   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
     413               0 :                                               aResult);
     414                 : }
     415                 : 
     416                 : static void
     417               0 : MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
     418                 :                       nsRuleData *aData)
     419                 : {
     420               0 :   nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aData);
     421               0 :   nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
     422               0 :   nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
     423               0 :   nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
     424               0 :   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
     425               0 : }
     426                 : 
     427                 : static void
     428               0 : EmbedMapAttributesIntoRule(const nsMappedAttributes *aAttributes,
     429                 :                            nsRuleData *aData)
     430                 : {
     431                 :   // NOTE: this should call the exact some methods than MapAttributesIntoRule
     432                 :   // except that MapCommonAttributesExceptHiddenInto is called instead of
     433                 :   // MapCommonAttributesInto.
     434                 :   // TODO: This method should be removed when bug 614825 will be fixed.
     435               0 :   nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aData);
     436               0 :   nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
     437               0 :   nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
     438               0 :   nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
     439               0 :   nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(aAttributes, aData);
     440               0 : }
     441                 : 
     442                 : NS_IMETHODIMP_(bool)
     443               0 : nsHTMLSharedObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
     444                 : {
     445                 :   static const MappedAttributeEntry* const map[] = {
     446                 :     sCommonAttributeMap,
     447                 :     sImageMarginSizeAttributeMap,
     448                 :     sImageBorderAttributeMap,
     449                 :     sImageAlignAttributeMap,
     450                 :   };
     451                 : 
     452               0 :   return FindAttributeDependence(aAttribute, map);
     453                 : }
     454                 : 
     455                 : 
     456                 : nsMapRuleToAttributesFunc
     457               0 : nsHTMLSharedObjectElement::GetAttributeMappingFunction() const
     458                 : {
     459               0 :   if (mNodeInfo->Equals(nsGkAtoms::embed)) {
     460               0 :     return &EmbedMapAttributesIntoRule;
     461                 :   }
     462                 : 
     463               0 :   return &MapAttributesIntoRule;
     464                 : }
     465                 : 
     466                 : void
     467               0 : nsHTMLSharedObjectElement::StartObjectLoad(bool aNotify)
     468                 : {
     469               0 :   nsCAutoString type;
     470               0 :   GetTypeAttrValue(type);
     471                 : 
     472               0 :   nsAutoString uri;
     473               0 :   if (!GetAttr(kNameSpaceID_None, URIAttrName(), uri)) {
     474                 :     // Be sure to call the nsIURI version if we have no attribute
     475                 :     // That handles the case where no URI is specified. An empty string would
     476                 :     // get interpreted as the page itself, instead of absence of URI.
     477               0 :     LoadObject(nsnull, aNotify, type);
     478                 :   }
     479                 :   else {
     480               0 :     LoadObject(uri, aNotify, type);
     481                 :   }
     482               0 :   SetIsNetworkCreated(false);
     483               0 : }
     484                 : 
     485                 : nsEventStates
     486               0 : nsHTMLSharedObjectElement::IntrinsicState() const
     487                 : {
     488               0 :   return nsGenericHTMLElement::IntrinsicState() | ObjectState();
     489                 : }
     490                 : 
     491                 : PRUint32
     492               0 : nsHTMLSharedObjectElement::GetCapabilities() const
     493                 : {
     494               0 :   PRUint32 capabilities = eSupportPlugins | eOverrideServerType;
     495               0 :   if (mNodeInfo->Equals(nsGkAtoms::embed)) {
     496               0 :     capabilities |= eSupportSVG | eSupportImages;
     497                 :   }
     498                 : 
     499               0 :   return capabilities;
     500                 : }
     501                 : 
     502                 : void
     503               0 : nsHTMLSharedObjectElement::DestroyContent()
     504                 : {
     505               0 :   RemovedFromDocument();
     506               0 :   nsGenericHTMLElement::DestroyContent();
     507               0 : }
     508                 : 
     509                 : nsresult
     510               0 : nsHTMLSharedObjectElement::CopyInnerTo(nsGenericElement* aDest) const
     511                 : {
     512               0 :   nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
     513               0 :   NS_ENSURE_SUCCESS(rv, rv);
     514                 : 
     515               0 :   if (aDest->OwnerDoc()->IsStaticDocument()) {
     516               0 :     CreateStaticClone(static_cast<nsHTMLSharedObjectElement*>(aDest));
     517                 :   }
     518                 : 
     519               0 :   return rv;
     520            4392 : }

Generated by: LCOV version 1.7