Line data Source code
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/. */
5 :
6 : #ifndef mozilla_BindingStyleRule_h__
7 : #define mozilla_BindingStyleRule_h__
8 :
9 : #include "nscore.h"
10 : #include "nsStringGlue.h"
11 : #include "mozilla/css/Rule.h"
12 :
13 : /**
14 : * Shared superclass for mozilla::css::StyleRule and mozilla::ServoStyleRule,
15 : * for use from bindings code.
16 : */
17 :
18 : class nsICSSDeclaration;
19 :
20 : namespace mozilla {
21 : namespace dom {
22 : class Element;
23 : }
24 :
25 : class BindingStyleRule : public css::Rule
26 : {
27 : protected:
28 2933 : BindingStyleRule(uint32_t aLineNumber, uint32_t aColumnNumber)
29 2933 : : css::Rule(aLineNumber, aColumnNumber)
30 : {
31 2933 : }
32 0 : BindingStyleRule(const BindingStyleRule& aCopy)
33 0 : : css::Rule(aCopy)
34 : {
35 0 : }
36 16 : virtual ~BindingStyleRule() {}
37 :
38 : public:
39 : // This is pure virtual because we have no members, and are an abstract class
40 : // to start with. The fact that we have to have this declaration at all is
41 : // kinda dumb. :(
42 : virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
43 : const override MOZ_MUST_OVERRIDE = 0;
44 :
45 : // Likewise for this one. We have to override our superclass, but don't
46 : // really need to do anything in this method.
47 : virtual bool IsCCLeaf() const override MOZ_MUST_OVERRIDE = 0;
48 :
49 : virtual uint32_t GetSelectorCount() = 0;
50 : virtual nsresult GetSelectorText(uint32_t aSelectorIndex, nsAString& aText) = 0;
51 : virtual nsresult GetSpecificity(uint32_t aSelectorIndex,
52 : uint64_t* aSpecificity) = 0;
53 : virtual nsresult SelectorMatchesElement(dom::Element* aElement,
54 : uint32_t aSelectorIndex,
55 : const nsAString& aPseudo,
56 : bool* aMatches) = 0;
57 :
58 : // WebIDL API
59 : // For GetSelectorText/SetSelectorText, we purposefully use a signature that
60 : // matches the nsIDOMCSSStyleRule one for now, so subclasses can just
61 : // implement both at once. The actual implementations must never return
62 : // anything other than NS_OK;
63 : NS_IMETHOD GetSelectorText(nsAString& aSelectorText) = 0;
64 : NS_IMETHOD SetSelectorText(const nsAString& aSelectorText) = 0;
65 : virtual nsICSSDeclaration* Style() = 0;
66 :
67 : virtual JSObject* WrapObject(JSContext* aCx,
68 : JS::Handle<JSObject*> aGivenProto) override;
69 : };
70 :
71 : } // namespace mozilla
72 :
73 : #endif // mozilla_BindingStyleRule_h__
|