Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLFrameSetElement.h
blobd0c735621ab6ada39aeda677010ed200462c73ee
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef HTMLFrameSetElement_h
8 #define HTMLFrameSetElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/UniquePtr.h"
12 #include "nsGenericHTMLElement.h"
14 /**
15 * The nsFramesetUnit enum is used to denote the type of each entry
16 * in the row or column spec.
18 enum nsFramesetUnit {
19 eFramesetUnit_Fixed = 0,
20 eFramesetUnit_Percent,
21 eFramesetUnit_Relative
24 /**
25 * The nsFramesetSpec struct is used to hold a single entry in the
26 * row or column spec.
28 struct nsFramesetSpec {
29 nsFramesetUnit mUnit;
30 nscoord mValue;
33 /**
34 * The maximum number of entries allowed in the frame set element row
35 * or column spec.
37 #define NS_MAX_FRAMESET_SPEC_COUNT 16000
39 //----------------------------------------------------------------------
41 namespace mozilla::dom {
43 class OnBeforeUnloadEventHandlerNonNull;
45 class HTMLFrameSetElement final : public nsGenericHTMLElement {
46 public:
47 explicit HTMLFrameSetElement(
48 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
49 : nsGenericHTMLElement(std::move(aNodeInfo)),
50 mNumRows(0),
51 mNumCols(0),
52 mCurrentRowColHint(NS_STYLE_HINT_REFLOW) {
53 SetHasWeirdParserInsertionMode();
56 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFrameSetElement, frameset)
58 // nsISupports
59 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLFrameSetElement,
60 nsGenericHTMLElement)
62 void GetCols(DOMString& aCols) { GetHTMLAttr(nsGkAtoms::cols, aCols); }
63 void SetCols(const nsAString& aCols, ErrorResult& aError) {
64 SetHTMLAttr(nsGkAtoms::cols, aCols, aError);
66 void GetRows(DOMString& aRows) { GetHTMLAttr(nsGkAtoms::rows, aRows); }
67 void SetRows(const nsAString& aRows, ErrorResult& aError) {
68 SetHTMLAttr(nsGkAtoms::rows, aRows, aError);
71 bool IsEventAttributeNameInternal(nsAtom* aName) override;
73 // Event listener stuff; we need to declare only the ones we need to
74 // forward to window that don't come from nsIDOMHTMLFrameSetElement.
75 #define EVENT(name_, id_, type_, \
76 struct_) /* nothing; handled by the superclass */
77 #define WINDOW_EVENT_HELPER(name_, type_) \
78 type_* GetOn##name_(); \
79 void SetOn##name_(type_* handler);
80 #define WINDOW_EVENT(name_, id_, type_, struct_) \
81 WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
82 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
83 WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
84 #include "mozilla/EventNameList.h" // IWYU pragma: keep
85 #undef BEFOREUNLOAD_EVENT
86 #undef WINDOW_EVENT
87 #undef WINDOW_EVENT_HELPER
88 #undef EVENT
90 /**
91 * GetRowSpec is used to get the "rows" spec.
92 * @param out int32_t aNumValues The number of row sizes specified.
93 * @param out nsFramesetSpec* aSpecs The array of size specifications.
94 This is _not_ owned by the caller, but by the nsFrameSetElement
95 implementation. DO NOT DELETE IT.
97 nsresult GetRowSpec(int32_t* aNumValues, const nsFramesetSpec** aSpecs);
98 /**
99 * GetColSpec is used to get the "cols" spec
100 * @param out int32_t aNumValues The number of row sizes specified.
101 * @param out nsFramesetSpec* aSpecs The array of size specifications.
102 This is _not_ owned by the caller, but by the nsFrameSetElement
103 implementation. DO NOT DELETE IT.
105 nsresult GetColSpec(int32_t* aNumValues, const nsFramesetSpec** aSpecs);
107 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
108 const nsAString& aValue,
109 nsIPrincipal* aMaybeScriptedPrincipal,
110 nsAttrValue& aResult) override;
111 nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
112 int32_t aModType) const override;
114 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
116 protected:
117 virtual ~HTMLFrameSetElement();
119 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
121 void BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
122 const nsAttrValue* aValue, bool aNotify) override;
124 private:
125 nsresult ParseRowCol(const nsAttrValue& aValue, int32_t& aNumSpecs,
126 UniquePtr<nsFramesetSpec[]>* aSpecs);
129 * The number of size specs in our "rows" attr
131 int32_t mNumRows;
133 * The number of size specs in our "cols" attr
135 int32_t mNumCols;
137 * The style hint to return for the rows/cols attrs in
138 * GetAttributeChangeHint
140 nsChangeHint mCurrentRowColHint;
142 * The parsed representation of the "rows" attribute
144 UniquePtr<nsFramesetSpec[]> mRowSpecs; // parsed, non-computed dimensions
146 * The parsed representation of the "cols" attribute
148 UniquePtr<nsFramesetSpec[]> mColSpecs; // parsed, non-computed dimensions
151 } // namespace mozilla::dom
153 #endif // HTMLFrameSetElement_h