1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef HTMLFrameSetElement_h
7 #define HTMLFrameSetElement_h
9 #include "mozilla/Attributes.h"
10 #include "nsIDOMHTMLFrameSetElement.h"
11 #include "nsGenericHTMLElement.h"
14 * The nsFramesetUnit enum is used to denote the type of each entry
15 * in the row or column spec.
18 eFramesetUnit_Fixed
= 0,
19 eFramesetUnit_Percent
,
20 eFramesetUnit_Relative
24 * The nsFramesetSpec struct is used to hold a single entry in the
27 struct nsFramesetSpec
{
33 * The maximum number of entries allowed in the frame set element row
36 #define NS_MAX_FRAMESET_SPEC_COUNT 16000
38 //----------------------------------------------------------------------
43 class OnBeforeUnloadEventHandlerNonNull
;
45 class HTMLFrameSetElement MOZ_FINAL
: public nsGenericHTMLElement
,
46 public nsIDOMHTMLFrameSetElement
49 explicit HTMLFrameSetElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
)
50 : nsGenericHTMLElement(aNodeInfo
),
53 mCurrentRowColHint(NS_STYLE_HINT_REFLOW
)
55 SetHasWeirdParserInsertionMode();
58 NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLFrameSetElement
, frameset
)
61 NS_DECL_ISUPPORTS_INHERITED
63 // nsIDOMHTMLFrameSetElement
64 NS_DECL_NSIDOMHTMLFRAMESETELEMENT
66 void GetCols(nsString
& aCols
)
68 GetHTMLAttr(nsGkAtoms::cols
, aCols
);
70 void SetCols(const nsAString
& aCols
, ErrorResult
& aError
)
72 SetHTMLAttr(nsGkAtoms::cols
, aCols
, aError
);
74 void GetRows(nsString
& aRows
)
76 GetHTMLAttr(nsGkAtoms::rows
, aRows
);
78 void SetRows(const nsAString
& aRows
, ErrorResult
& aError
)
80 SetHTMLAttr(nsGkAtoms::rows
, aRows
, aError
);
83 virtual bool IsEventAttributeName(nsIAtom
*aName
) MOZ_OVERRIDE
;
85 // Event listener stuff; we need to declare only the ones we need to
86 // forward to window that don't come from nsIDOMHTMLFrameSetElement.
87 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
88 #define WINDOW_EVENT_HELPER(name_, type_) \
89 type_* GetOn##name_(); \
90 void SetOn##name_(type_* handler);
91 #define WINDOW_EVENT(name_, id_, type_, struct_) \
92 WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
93 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
94 WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
95 #include "mozilla/EventNameList.h" // IWYU pragma: keep
96 #undef BEFOREUNLOAD_EVENT
98 #undef WINDOW_EVENT_HELPER
101 // These override the SetAttr methods in nsGenericHTMLElement (need
102 // both here to silence compiler warnings).
103 nsresult
SetAttr(int32_t aNameSpaceID
, nsIAtom
* aName
,
104 const nsAString
& aValue
, bool aNotify
)
106 return SetAttr(aNameSpaceID
, aName
, nullptr, aValue
, aNotify
);
108 virtual nsresult
SetAttr(int32_t aNameSpaceID
, nsIAtom
* aName
,
109 nsIAtom
* aPrefix
, const nsAString
& aValue
,
110 bool aNotify
) MOZ_OVERRIDE
;
113 * GetRowSpec is used to get the "rows" spec.
114 * @param out int32_t aNumValues The number of row sizes specified.
115 * @param out nsFramesetSpec* aSpecs The array of size specifications.
116 This is _not_ owned by the caller, but by the nsFrameSetElement
117 implementation. DO NOT DELETE IT.
119 nsresult
GetRowSpec(int32_t *aNumValues
, const nsFramesetSpec
** aSpecs
);
121 * GetColSpec is used to get the "cols" spec
122 * @param out int32_t aNumValues The number of row sizes specified.
123 * @param out nsFramesetSpec* aSpecs The array of size specifications.
124 This is _not_ owned by the caller, but by the nsFrameSetElement
125 implementation. DO NOT DELETE IT.
127 nsresult
GetColSpec(int32_t *aNumValues
, const nsFramesetSpec
** aSpecs
);
130 virtual bool ParseAttribute(int32_t aNamespaceID
,
132 const nsAString
& aValue
,
133 nsAttrValue
& aResult
) MOZ_OVERRIDE
;
134 virtual nsChangeHint
GetAttributeChangeHint(const nsIAtom
* aAttribute
,
135 int32_t aModType
) const MOZ_OVERRIDE
;
137 virtual nsresult
Clone(mozilla::dom::NodeInfo
*aNodeInfo
, nsINode
**aResult
) const MOZ_OVERRIDE
;
140 virtual ~HTMLFrameSetElement();
142 virtual JSObject
* WrapNode(JSContext
*aCx
) MOZ_OVERRIDE
;
145 nsresult
ParseRowCol(const nsAString
& aValue
,
147 nsFramesetSpec
** aSpecs
);
150 * The number of size specs in our "rows" attr
154 * The number of size specs in our "cols" attr
158 * The style hint to return for the rows/cols attrs in
159 * GetAttributeChangeHint
161 nsChangeHint mCurrentRowColHint
;
163 * The parsed representation of the "rows" attribute
165 nsAutoArrayPtr
<nsFramesetSpec
> mRowSpecs
; // parsed, non-computed dimensions
167 * The parsed representation of the "cols" attribute
169 nsAutoArrayPtr
<nsFramesetSpec
> mColSpecs
; // parsed, non-computed dimensions
173 } // namespace mozilla
175 #endif // HTMLFrameSetElement_h