Line data Source code
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 BorrowedAttrInfo_h__
8 : #define BorrowedAttrInfo_h__
9 :
10 : #include "mozilla/Assertions.h"
11 :
12 : class nsAttrName;
13 : class nsAttrValue;
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : /**
19 : * Struct that stores info on an attribute. The name and value must either both
20 : * be null or both be non-null.
21 : *
22 : * Note that, just as the pointers returned by GetAttrNameAt, the pointers that
23 : * this struct hold are only valid until the element or its attributes are
24 : * mutated (directly or via script).
25 : */
26 : struct BorrowedAttrInfo
27 : {
28 150 : BorrowedAttrInfo()
29 150 : : mName(nullptr)
30 150 : , mValue(nullptr)
31 : {
32 150 : }
33 :
34 : BorrowedAttrInfo(const nsAttrName* aName, const nsAttrValue* aValue);
35 :
36 : BorrowedAttrInfo(const BorrowedAttrInfo& aOther);
37 :
38 : const nsAttrName* mName;
39 : const nsAttrValue* mValue;
40 :
41 242 : explicit operator bool() const { return mName != nullptr; }
42 : };
43 :
44 : } // namespace dom
45 : } // namespace mozilla
46 : #endif
|