Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLFrameElement.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #include "nsIDOMHTMLFrameElement.h"
00038 #include "nsGenericHTMLElement.h"
00039 #include "nsHTMLAtoms.h"
00040 #include "nsIPresShell.h"
00041 #include "nsIDocument.h"
00042 #include "nsIDOMDocument.h"
00043 #include "nsDOMError.h"
00044 
00045 
00046 class nsHTMLFrameElement : public nsGenericHTMLFrameElement,
00047                            public nsIDOMHTMLFrameElement
00048 {
00049 public:
00050   nsHTMLFrameElement(nsINodeInfo *aNodeInfo);
00051   virtual ~nsHTMLFrameElement();
00052 
00053   // nsISupports
00054   NS_DECL_ISUPPORTS_INHERITED
00055 
00056   // nsIDOMNode
00057   NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFrameElement::)
00058 
00059   // nsIDOMElement
00060   NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
00061 
00062   // nsIDOMHTMLElement
00063   NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
00064 
00065   // nsIDOMHTMLFrameElement
00066   NS_DECL_NSIDOMHTMLFRAMEELEMENT
00067 
00068   // nsIContent
00069   virtual PRBool ParseAttribute(nsIAtom* aAttribute,
00070                                 const nsAString& aValue,
00071                                 nsAttrValue& aResult);
00072   NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
00073   nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
00074 };
00075 
00076 
00077 NS_IMPL_NS_NEW_HTML_ELEMENT(Frame)
00078 
00079 
00080 nsHTMLFrameElement::nsHTMLFrameElement(nsINodeInfo *aNodeInfo)
00081   : nsGenericHTMLFrameElement(aNodeInfo)
00082 {
00083 }
00084 
00085 nsHTMLFrameElement::~nsHTMLFrameElement()
00086 {
00087 }
00088 
00089 
00090 NS_IMPL_ADDREF_INHERITED(nsHTMLFrameElement, nsGenericElement)
00091 NS_IMPL_RELEASE_INHERITED(nsHTMLFrameElement, nsGenericElement)
00092 
00093 
00094 // QueryInterface implementation for nsHTMLFrameElement
00095 NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFrameElement,
00096                                     nsGenericHTMLFrameElement)
00097   NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLFrameElement)
00098   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLFrameElement)
00099 NS_HTML_CONTENT_INTERFACE_MAP_END
00100 
00101 
00102 NS_IMPL_DOM_CLONENODE(nsHTMLFrameElement)
00103 
00104 
00105 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder)
00106 NS_IMPL_URI_ATTR(nsHTMLFrameElement, LongDesc, longdesc)
00107 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight)
00108 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth)
00109 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name)
00110 NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize)
00111 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling)
00112 NS_IMPL_URI_ATTR(nsHTMLFrameElement, Src, src)
00113 
00114 
00115 NS_IMETHODIMP
00116 nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
00117 {
00118   return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument);
00119 }
00120 
00121 PRBool
00122 nsHTMLFrameElement::ParseAttribute(nsIAtom* aAttribute,
00123                                    const nsAString& aValue,
00124                                    nsAttrValue& aResult)
00125 {
00126   if (aAttribute == nsHTMLAtoms::bordercolor) {
00127     return aResult.ParseColor(aValue, nsGenericHTMLFrameElement::GetOwnerDoc());
00128   }
00129   if (aAttribute == nsHTMLAtoms::frameborder) {
00130     return ParseFrameborderValue(aValue, aResult);
00131   }
00132   if (aAttribute == nsHTMLAtoms::marginwidth) {
00133     return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
00134   }
00135   if (aAttribute == nsHTMLAtoms::marginheight) {
00136     return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
00137   }
00138   if (aAttribute == nsHTMLAtoms::scrolling) {
00139     return ParseScrollingValue(aValue, aResult);
00140   }
00141 
00142   return nsGenericHTMLFrameElement::ParseAttribute(aAttribute, aValue, aResult);
00143 }
00144 
00145 static void
00146 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
00147                       nsRuleData* aData)
00148 {
00149   nsGenericHTMLElement::MapScrollingAttributeInto(aAttributes, aData);
00150   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
00151 }
00152 
00153 NS_IMETHODIMP_(PRBool)
00154 nsHTMLFrameElement::IsAttributeMapped(const nsIAtom* aAttribute) const
00155 {
00156   static const MappedAttributeEntry* const map[] = {
00157     sScrollingAttributeMap,
00158     sCommonAttributeMap,
00159   };
00160   
00161   return FindAttributeDependence(aAttribute, map, NS_ARRAY_LENGTH(map));
00162 }
00163 
00164 nsMapRuleToAttributesFunc
00165 nsHTMLFrameElement::GetAttributeMappingFunction() const
00166 {
00167   return &MapAttributesIntoRule;
00168 }