Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/html/HTMLFrameSetElement.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef HTMLFrameSetElement_h
8
#define HTMLFrameSetElement_h
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/UniquePtr.h"
12
#include "nsGenericHTMLElement.h"
13
14
/**
15
 * The nsFramesetUnit enum is used to denote the type of each entry
16
 * in the row or column spec.
17
 */
18
enum nsFramesetUnit {
19
  eFramesetUnit_Fixed = 0,
20
  eFramesetUnit_Percent,
21
  eFramesetUnit_Relative
22
};
23
24
/**
25
 * The nsFramesetSpec struct is used to hold a single entry in the
26
 * row or column spec.
27
 */
28
struct nsFramesetSpec {
29
  nsFramesetUnit mUnit;
30
  nscoord        mValue;
31
};
32
33
/**
34
 * The maximum number of entries allowed in the frame set element row
35
 * or column spec.
36
 */
37
0
#define NS_MAX_FRAMESET_SPEC_COUNT 16000
38
39
//----------------------------------------------------------------------
40
41
namespace mozilla {
42
namespace dom {
43
44
class OnBeforeUnloadEventHandlerNonNull;
45
46
class HTMLFrameSetElement final : public nsGenericHTMLElement
47
{
48
public:
49
  explicit HTMLFrameSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
50
    : nsGenericHTMLElement(std::move(aNodeInfo)),
51
      mNumRows(0),
52
      mNumCols(0),
53
      mCurrentRowColHint(NS_STYLE_HINT_REFLOW)
54
0
  {
55
0
    SetHasWeirdParserInsertionMode();
56
0
  }
57
58
  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFrameSetElement, frameset)
59
60
  // nsISupports
61
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLFrameSetElement,
62
                                       nsGenericHTMLElement)
63
64
  void GetCols(DOMString& aCols)
65
  {
66
    GetHTMLAttr(nsGkAtoms::cols, aCols);
67
  }
68
  void SetCols(const nsAString& aCols, ErrorResult& aError)
69
  {
70
    SetHTMLAttr(nsGkAtoms::cols, aCols, aError);
71
  }
72
  void GetRows(DOMString& aRows)
73
  {
74
    GetHTMLAttr(nsGkAtoms::rows, aRows);
75
  }
76
  void SetRows(const nsAString& aRows, ErrorResult& aError)
77
  {
78
    SetHTMLAttr(nsGkAtoms::rows, aRows, aError);
79
  }
80
81
  virtual bool IsEventAttributeNameInternal(nsAtom *aName) override;
82
83
  // Event listener stuff; we need to declare only the ones we need to
84
  // forward to window that don't come from nsIDOMHTMLFrameSetElement.
85
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
86
#define WINDOW_EVENT_HELPER(name_, type_)                               \
87
  type_* GetOn##name_();                                                \
88
  void SetOn##name_(type_* handler);
89
#define WINDOW_EVENT(name_, id_, type_, struct_)                        \
90
  WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
91
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                  \
92
  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
93
#include "mozilla/EventNameList.h" // IWYU pragma: keep
94
#undef BEFOREUNLOAD_EVENT
95
#undef WINDOW_EVENT
96
#undef WINDOW_EVENT_HELPER
97
#undef EVENT
98
99
   /**
100
    * GetRowSpec is used to get the "rows" spec.
101
    * @param out int32_t aNumValues The number of row sizes specified.
102
    * @param out nsFramesetSpec* aSpecs The array of size specifications.
103
             This is _not_ owned by the caller, but by the nsFrameSetElement
104
             implementation.  DO NOT DELETE IT.
105
    */
106
  nsresult GetRowSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs);
107
   /**
108
    * GetColSpec is used to get the "cols" spec
109
    * @param out int32_t aNumValues The number of row sizes specified.
110
    * @param out nsFramesetSpec* aSpecs The array of size specifications.
111
             This is _not_ owned by the caller, but by the nsFrameSetElement
112
             implementation.  DO NOT DELETE IT.
113
    */
114
  nsresult GetColSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs);
115
116
117
  virtual bool ParseAttribute(int32_t aNamespaceID,
118
                                nsAtom* aAttribute,
119
                                const nsAString& aValue,
120
                                nsIPrincipal* aMaybeScriptedPrincipal,
121
                                nsAttrValue& aResult) override;
122
  virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
123
                                              int32_t aModType) const override;
124
125
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
126
127
protected:
128
  virtual ~HTMLFrameSetElement();
129
130
  virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
131
132
  virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
133
                                 const nsAttrValueOrString* aValue,
134
                                 bool aNotify) override;
135
136
private:
137
  nsresult ParseRowCol(const nsAString& aValue,
138
                       int32_t& aNumSpecs,
139
                       UniquePtr<nsFramesetSpec[]>* aSpecs);
140
141
  /**
142
   * The number of size specs in our "rows" attr
143
   */
144
  int32_t          mNumRows;
145
  /**
146
   * The number of size specs in our "cols" attr
147
   */
148
  int32_t          mNumCols;
149
  /**
150
   * The style hint to return for the rows/cols attrs in
151
   * GetAttributeChangeHint
152
   */
153
  nsChangeHint      mCurrentRowColHint;
154
  /**
155
   * The parsed representation of the "rows" attribute
156
   */
157
  UniquePtr<nsFramesetSpec[]>  mRowSpecs; // parsed, non-computed dimensions
158
  /**
159
   * The parsed representation of the "cols" attribute
160
   */
161
  UniquePtr<nsFramesetSpec[]>  mColSpecs; // parsed, non-computed dimensions
162
};
163
164
} // namespace dom
165
} // namespace mozilla
166
167
#endif // HTMLFrameSetElement_h