LCOV - code coverage report
Current view: directory - content/html/content/src - nsHTMLIFrameElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 92 0 0.0 %
Date: 2012-06-02 Functions: 135 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #include "mozilla/Util.h"
      39                 : 
      40                 : #include "nsIDOMHTMLIFrameElement.h"
      41                 : #include "nsGenericHTMLFrameElement.h"
      42                 : #include "nsIDOMDocument.h"
      43                 : #include "nsIDOMGetSVGDocument.h"
      44                 : #include "nsIDOMSVGDocument.h"
      45                 : #include "nsGkAtoms.h"
      46                 : #include "nsIDocument.h"
      47                 : #include "nsMappedAttributes.h"
      48                 : #include "nsDOMError.h"
      49                 : #include "nsRuleData.h"
      50                 : #include "nsStyleConsts.h"
      51                 : 
      52                 : using namespace mozilla;
      53                 : using namespace mozilla::dom;
      54                 : 
      55                 : class nsHTMLIFrameElement : public nsGenericHTMLFrameElement
      56                 :                           , public nsIDOMHTMLIFrameElement
      57                 :                           , public nsIDOMGetSVGDocument
      58                 : {
      59                 : public:
      60                 :   nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
      61                 :                       mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
      62                 :   virtual ~nsHTMLIFrameElement();
      63                 : 
      64                 :   // nsISupports
      65                 :   NS_DECL_ISUPPORTS_INHERITED
      66                 : 
      67                 :   // nsIDOMNode
      68               0 :   NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
      69                 : 
      70                 :   // nsIDOMElement
      71               0 :   NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
      72                 : 
      73                 :   // nsIDOMHTMLElement
      74               0 :   NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
      75                 : 
      76                 :   // nsIDOMHTMLIFrameElement
      77                 :   NS_DECL_NSIDOMHTMLIFRAMEELEMENT
      78                 : 
      79                 :   // nsIDOMGetSVGDocument
      80                 :   NS_DECL_NSIDOMGETSVGDOCUMENT
      81                 : 
      82                 :   // nsIContent
      83                 :   virtual bool ParseAttribute(PRInt32 aNamespaceID,
      84                 :                                 nsIAtom* aAttribute,
      85                 :                                 const nsAString& aValue,
      86                 :                                 nsAttrValue& aResult);
      87                 :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
      88                 :   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
      89                 : 
      90                 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
      91                 :   virtual nsXPCClassInfo* GetClassInfo();
      92                 : };
      93                 : 
      94                 : 
      95               0 : NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(IFrame)
      96                 : 
      97                 : 
      98               0 : nsHTMLIFrameElement::nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
      99                 :                                          FromParser aFromParser)
     100               0 :   : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
     101                 : {
     102               0 : }
     103                 : 
     104               0 : nsHTMLIFrameElement::~nsHTMLIFrameElement()
     105                 : {
     106               0 : }
     107                 : 
     108                 : 
     109               0 : NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameElement,nsGenericElement)
     110               0 : NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameElement,nsGenericElement)
     111                 : 
     112               0 : DOMCI_NODE_DATA(HTMLIFrameElement, nsHTMLIFrameElement)
     113                 : 
     114                 : // QueryInterface implementation for nsHTMLIFrameElement
     115               0 : NS_INTERFACE_TABLE_HEAD(nsHTMLIFrameElement)
     116                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(nsHTMLIFrameElement)
     117                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMHTMLIFrameElement)
     118                 :     NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMGetSVGDocument)
     119               0 :   NS_OFFSET_AND_INTERFACE_TABLE_END
     120               0 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLIFrameElement,
     121                 :                                                nsGenericHTMLFrameElement)
     122               0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLIFrameElement)
     123                 : 
     124                 : 
     125               0 : NS_IMPL_ELEMENT_CLONE(nsHTMLIFrameElement)
     126                 : 
     127                 : 
     128               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align)
     129               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, FrameBorder, frameborder)
     130               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height)
     131               0 : NS_IMPL_URI_ATTR(nsHTMLIFrameElement, LongDesc, longdesc)
     132               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight)
     133               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth)
     134               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name)
     135               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling)
     136               0 : NS_IMPL_URI_ATTR(nsHTMLIFrameElement, Src, src)
     137               0 : NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width)
     138               0 : NS_IMPL_BOOL_ATTR(nsHTMLIFrameElement, MozAllowFullScreen, mozallowfullscreen)
     139                 : 
     140                 : NS_IMETHODIMP
     141               0 : nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
     142                 : {
     143               0 :   return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument);
     144                 : }
     145                 : 
     146                 : NS_IMETHODIMP
     147               0 : nsHTMLIFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
     148                 : {
     149               0 :   return nsGenericHTMLFrameElement::GetContentWindow(aContentWindow);
     150                 : }
     151                 : 
     152                 : NS_IMETHODIMP
     153               0 : nsHTMLIFrameElement::GetSVGDocument(nsIDOMDocument **aResult)
     154                 : {
     155               0 :   return GetContentDocument(aResult);
     156                 : }
     157                 : 
     158                 : bool
     159               0 : nsHTMLIFrameElement::ParseAttribute(PRInt32 aNamespaceID,
     160                 :                                     nsIAtom* aAttribute,
     161                 :                                     const nsAString& aValue,
     162                 :                                     nsAttrValue& aResult)
     163                 : {
     164               0 :   if (aNamespaceID == kNameSpaceID_None) {
     165               0 :     if (aAttribute == nsGkAtoms::marginwidth) {
     166               0 :       return aResult.ParseSpecialIntValue(aValue);
     167                 :     }
     168               0 :     if (aAttribute == nsGkAtoms::marginheight) {
     169               0 :       return aResult.ParseSpecialIntValue(aValue);
     170                 :     }
     171               0 :     if (aAttribute == nsGkAtoms::width) {
     172               0 :       return aResult.ParseSpecialIntValue(aValue);
     173                 :     }
     174               0 :     if (aAttribute == nsGkAtoms::height) {
     175               0 :       return aResult.ParseSpecialIntValue(aValue);
     176                 :     }
     177               0 :     if (aAttribute == nsGkAtoms::frameborder) {
     178               0 :       return ParseFrameborderValue(aValue, aResult);
     179                 :     }
     180               0 :     if (aAttribute == nsGkAtoms::scrolling) {
     181               0 :       return ParseScrollingValue(aValue, aResult);
     182                 :     }
     183               0 :     if (aAttribute == nsGkAtoms::align) {
     184               0 :       return ParseAlignValue(aValue, aResult);
     185                 :     }
     186                 :   }
     187                 : 
     188                 :   return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
     189               0 :                                                    aValue, aResult);
     190                 : }
     191                 : 
     192                 : static void
     193               0 : MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
     194                 :                       nsRuleData* aData)
     195                 : {
     196               0 :   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     197                 :     // frameborder: 0 | 1 (| NO | YES in quirks mode)
     198                 :     // If frameborder is 0 or No, set border to 0
     199                 :     // else leave it as the value set in html.css
     200               0 :     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
     201               0 :     if (value && value->Type() == nsAttrValue::eEnum) {
     202               0 :       PRInt32 frameborder = value->GetEnumValue();
     203               0 :       if (NS_STYLE_FRAME_0 == frameborder ||
     204                 :           NS_STYLE_FRAME_NO == frameborder ||
     205                 :           NS_STYLE_FRAME_OFF == frameborder) {
     206               0 :         nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
     207               0 :         if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
     208               0 :           borderLeftWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
     209               0 :         nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
     210               0 :         if (borderRightWidth->GetUnit() == eCSSUnit_Null)
     211               0 :           borderRightWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
     212               0 :         nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
     213               0 :         if (borderTopWidth->GetUnit() == eCSSUnit_Null)
     214               0 :           borderTopWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
     215               0 :         nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
     216               0 :         if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
     217               0 :           borderBottomWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
     218                 :       }
     219                 :     }
     220                 :   }
     221               0 :   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     222                 :     // width: value
     223               0 :     nsCSSValue* width = aData->ValueForWidth();
     224               0 :     if (width->GetUnit() == eCSSUnit_Null) {
     225               0 :       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
     226               0 :       if (value && value->Type() == nsAttrValue::eInteger)
     227               0 :         width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
     228               0 :       else if (value && value->Type() == nsAttrValue::ePercent)
     229               0 :         width->SetPercentValue(value->GetPercentValue());
     230                 :     }
     231                 : 
     232                 :     // height: value
     233               0 :     nsCSSValue* height = aData->ValueForHeight();
     234               0 :     if (height->GetUnit() == eCSSUnit_Null) {
     235               0 :       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
     236               0 :       if (value && value->Type() == nsAttrValue::eInteger)
     237               0 :         height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
     238               0 :       else if (value && value->Type() == nsAttrValue::ePercent)
     239               0 :         height->SetPercentValue(value->GetPercentValue());
     240                 :     }
     241                 :   }
     242                 : 
     243               0 :   nsGenericHTMLElement::MapScrollingAttributeInto(aAttributes, aData);
     244               0 :   nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
     245               0 :   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
     246               0 : }
     247                 : 
     248                 : NS_IMETHODIMP_(bool)
     249               0 : nsHTMLIFrameElement::IsAttributeMapped(const nsIAtom* aAttribute) const
     250                 : {
     251                 :   static const MappedAttributeEntry attributes[] = {
     252                 :     { &nsGkAtoms::width },
     253                 :     { &nsGkAtoms::height },
     254                 :     { &nsGkAtoms::frameborder },
     255                 :     { nsnull },
     256                 :   };
     257                 : 
     258                 :   static const MappedAttributeEntry* const map[] = {
     259                 :     attributes,
     260                 :     sScrollingAttributeMap,
     261                 :     sImageAlignAttributeMap,
     262                 :     sCommonAttributeMap,
     263                 :   };
     264                 :   
     265               0 :   return FindAttributeDependence(aAttribute, map);
     266                 : }
     267                 : 
     268                 : 
     269                 : 
     270                 : nsMapRuleToAttributesFunc
     271               0 : nsHTMLIFrameElement::GetAttributeMappingFunction() const
     272                 : {
     273               0 :   return &MapAttributesIntoRule;
     274                 : }
     275                 : 

Generated by: LCOV version 1.7