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 #ifndef mozilla_dom_HTMLTableRowElement_h
7 #define mozilla_dom_HTMLTableRowElement_h
8 
9 #include "mozilla/Attributes.h"
10 #include "nsGenericHTMLElement.h"
11 
12 class nsContentList;
13 
14 namespace mozilla {
15 namespace dom {
16 
17 class HTMLTableSectionElement;
18 
19 class HTMLTableRowElement final : public nsGenericHTMLElement {
20  public:
HTMLTableRowElement(already_AddRefed<mozilla::dom::NodeInfo> && aNodeInfo)21   explicit HTMLTableRowElement(
22       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
23       : nsGenericHTMLElement(std::move(aNodeInfo)) {
24     SetHasWeirdParserInsertionMode();
25   }
26 
27   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTableRowElement, tr)
28 
29   // nsISupports
30   NS_DECL_ISUPPORTS_INHERITED
31 
32   int32_t RowIndex() const;
33   int32_t SectionRowIndex() const;
34   nsIHTMLCollection* Cells();
35   already_AddRefed<nsGenericHTMLElement> InsertCell(int32_t aIndex,
36                                                     ErrorResult& aError);
37   void DeleteCell(int32_t aValue, ErrorResult& aError);
38 
GetAlign(DOMString & aAlign)39   void GetAlign(DOMString& aAlign) { GetHTMLAttr(nsGkAtoms::align, aAlign); }
SetAlign(const nsAString & aAlign,ErrorResult & aError)40   void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
41     SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
42   }
GetCh(DOMString & aCh)43   void GetCh(DOMString& aCh) { GetHTMLAttr(nsGkAtoms::_char, aCh); }
SetCh(const nsAString & aCh,ErrorResult & aError)44   void SetCh(const nsAString& aCh, ErrorResult& aError) {
45     SetHTMLAttr(nsGkAtoms::_char, aCh, aError);
46   }
GetChOff(DOMString & aChOff)47   void GetChOff(DOMString& aChOff) { GetHTMLAttr(nsGkAtoms::charoff, aChOff); }
SetChOff(const nsAString & aChOff,ErrorResult & aError)48   void SetChOff(const nsAString& aChOff, ErrorResult& aError) {
49     SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError);
50   }
GetVAlign(DOMString & aVAlign)51   void GetVAlign(DOMString& aVAlign) {
52     GetHTMLAttr(nsGkAtoms::valign, aVAlign);
53   }
SetVAlign(const nsAString & aVAlign,ErrorResult & aError)54   void SetVAlign(const nsAString& aVAlign, ErrorResult& aError) {
55     SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError);
56   }
GetBgColor(DOMString & aBgColor)57   void GetBgColor(DOMString& aBgColor) {
58     GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
59   }
SetBgColor(const nsAString & aBgColor,ErrorResult & aError)60   void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) {
61     SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
62   }
63 
64   virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
65                               const nsAString& aValue,
66                               nsIPrincipal* aMaybeScriptedPrincipal,
67                               nsAttrValue& aResult) override;
68   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
69       const override;
70   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
71 
72   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
73 
74   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTableRowElement,
75                                            nsGenericHTMLElement)
76 
77  protected:
78   virtual ~HTMLTableRowElement();
79 
80   virtual JSObject* WrapNode(JSContext* aCx,
81                              JS::Handle<JSObject*> aGivenProto) override;
82 
83   HTMLTableSectionElement* GetSection() const;
84   HTMLTableElement* GetTable() const;
85   RefPtr<nsContentList> mCells;
86 
87  private:
88   static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
89                                     MappedDeclarations&);
90 };
91 
92 }  // namespace dom
93 }  // namespace mozilla
94 
95 #endif /* mozilla_dom_HTMLTableRowElement_h */
96