CssAltContent.h (1412B)
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 CssAltContent_h_ 7 #define CssAltContent_h_ 8 9 #include "nsStyleStruct.h" 10 11 namespace mozilla::a11y { 12 13 /** 14 * Queries alternative text specified in the CSS content property. 15 */ 16 class MOZ_STACK_CLASS CssAltContent { 17 public: 18 explicit CssAltContent(nsIContent* aContent); 19 20 /** 21 * Checks whether any CSS alt text has been specified. For example: 22 * if (CssAltContent(someContentNode)) ... 23 */ 24 explicit operator bool() const { return !mItems.IsEmpty(); } 25 26 /** 27 * Append all CSS alt text to a string. 28 */ 29 void AppendToString(nsAString& aOut); 30 31 /** 32 * Update accessibility if there is CSS alt content on the given element or a 33 * descendant pseudo-element which references the given attribute. 34 */ 35 static bool HandleAttributeChange(nsIContent* aContent, int32_t aNameSpaceID, 36 nsAtom* aAttribute); 37 38 private: 39 bool HandleAttributeChange(int32_t aNameSpaceID, nsAtom* aAttribute); 40 41 dom::Element* mRealElement = nullptr; 42 dom::Element* mPseudoElement = nullptr; 43 mozilla::Span<const mozilla::StyleContentItem> mItems; 44 }; 45 46 } // namespace mozilla::a11y 47 48 #endif