content/base/public/nsIContent.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 #ifndef nsIContent_h___
michael@0 6 #define nsIContent_h___
michael@0 7
michael@0 8 #include "mozilla/Attributes.h"
michael@0 9 #include "nsCaseTreatment.h" // for enum, cannot be forward-declared
michael@0 10 #include "nsINode.h"
michael@0 11
michael@0 12 // Forward declarations
michael@0 13 class nsAString;
michael@0 14 class nsIAtom;
michael@0 15 class nsIURI;
michael@0 16 class nsRuleWalker;
michael@0 17 class nsAttrValue;
michael@0 18 class nsAttrName;
michael@0 19 class nsTextFragment;
michael@0 20 class nsIFrame;
michael@0 21 class nsXBLBinding;
michael@0 22
michael@0 23 namespace mozilla {
michael@0 24 class EventChainPreVisitor;
michael@0 25 namespace dom {
michael@0 26 class ShadowRoot;
michael@0 27 struct CustomElementData;
michael@0 28 } // namespace dom
michael@0 29 namespace widget {
michael@0 30 struct IMEState;
michael@0 31 } // namespace widget
michael@0 32 } // namespace mozilla
michael@0 33
michael@0 34 enum nsLinkState {
michael@0 35 eLinkState_Unvisited = 1,
michael@0 36 eLinkState_Visited = 2,
michael@0 37 eLinkState_NotLink = 3
michael@0 38 };
michael@0 39
michael@0 40 // IID for the nsIContent interface
michael@0 41 #define NS_ICONTENT_IID \
michael@0 42 { 0x1329e5b7, 0x4bcd, 0x450c, \
michael@0 43 { 0xa2, 0x3a, 0x98, 0xc5, 0x85, 0xcd, 0x73, 0xf9 } }
michael@0 44
michael@0 45 /**
michael@0 46 * A node of content in a document's content model. This interface
michael@0 47 * is supported by all content objects.
michael@0 48 */
michael@0 49 class nsIContent : public nsINode {
michael@0 50 public:
michael@0 51 typedef mozilla::widget::IMEState IMEState;
michael@0 52
michael@0 53 #ifdef MOZILLA_INTERNAL_API
michael@0 54 // If you're using the external API, the only thing you can know about
michael@0 55 // nsIContent is that it exists with an IID
michael@0 56
michael@0 57 nsIContent(already_AddRefed<nsINodeInfo>& aNodeInfo)
michael@0 58 : nsINode(aNodeInfo)
michael@0 59 {
michael@0 60 MOZ_ASSERT(mNodeInfo);
michael@0 61 SetNodeIsContent();
michael@0 62 }
michael@0 63 #endif // MOZILLA_INTERNAL_API
michael@0 64
michael@0 65 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
michael@0 66
michael@0 67 /**
michael@0 68 * Bind this content node to a tree. If this method throws, the caller must
michael@0 69 * call UnbindFromTree() on the node. In the typical case of a node being
michael@0 70 * appended to a parent, this will be called after the node has been added to
michael@0 71 * the parent's child list and before nsIDocumentObserver notifications for
michael@0 72 * the addition are dispatched.
michael@0 73 * @param aDocument The new document for the content node. Must match the
michael@0 74 * current document of aParent, if aParent is not null.
michael@0 75 * May not be null if aParent is null.
michael@0 76 * @param aParent The new parent for the content node. May be null if the
michael@0 77 * node is being bound as a direct child of the document.
michael@0 78 * @param aBindingParent The new binding parent for the content node.
michael@0 79 * This is must either be non-null if a particular
michael@0 80 * binding parent is desired or match aParent's binding
michael@0 81 * parent.
michael@0 82 * @param aCompileEventHandlers whether to initialize the event handlers in
michael@0 83 * the document (used by nsXULElement)
michael@0 84 * @note either aDocument or aParent must be non-null. If both are null,
michael@0 85 * this method _will_ crash.
michael@0 86 * @note This method must not be called by consumers of nsIContent on a node
michael@0 87 * that is already bound to a tree. Call UnbindFromTree first.
michael@0 88 * @note This method will handle rebinding descendants appropriately (eg
michael@0 89 * changing their binding parent as needed).
michael@0 90 * @note This method does not add the content node to aParent's child list
michael@0 91 * @throws NS_ERROR_OUT_OF_MEMORY if that happens
michael@0 92 */
michael@0 93 virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
michael@0 94 nsIContent* aBindingParent,
michael@0 95 bool aCompileEventHandlers) = 0;
michael@0 96
michael@0 97 /**
michael@0 98 * Unbind this content node from a tree. This will set its current document
michael@0 99 * and binding parent to null. In the typical case of a node being removed
michael@0 100 * from a parent, this will be called after it has been removed from the
michael@0 101 * parent's child list and after the nsIDocumentObserver notifications for
michael@0 102 * the removal have been dispatched.
michael@0 103 * @param aDeep Whether to recursively unbind the entire subtree rooted at
michael@0 104 * this node. The only time false should be passed is when the
michael@0 105 * parent node of the content is being destroyed.
michael@0 106 * @param aNullParent Whether to null out the parent pointer as well. This
michael@0 107 * is usually desirable. This argument should only be false while
michael@0 108 * recursively calling UnbindFromTree when a subtree is detached.
michael@0 109 * @note This method is safe to call on nodes that are not bound to a tree.
michael@0 110 */
michael@0 111 virtual void UnbindFromTree(bool aDeep = true,
michael@0 112 bool aNullParent = true) = 0;
michael@0 113
michael@0 114 /**
michael@0 115 * DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.
michael@0 116 * Get the document for this content.
michael@0 117 * @return the document
michael@0 118 */
michael@0 119 nsIDocument *GetDocument() const
michael@0 120 {
michael@0 121 return GetCurrentDoc();
michael@0 122 }
michael@0 123
michael@0 124 enum {
michael@0 125 /**
michael@0 126 * All XBL flattened tree children of the node, as well as :before and
michael@0 127 * :after anonymous content and native anonymous children.
michael@0 128 *
michael@0 129 * @note the result children order is
michael@0 130 * 1. :before generated node
michael@0 131 * 2. XBL flattened tree children of this node
michael@0 132 * 3. native anonymous nodes
michael@0 133 * 4. :after generated node
michael@0 134 */
michael@0 135 eAllChildren = 0,
michael@0 136
michael@0 137 /**
michael@0 138 * All XBL explicit children of the node (see
michael@0 139 * http://www.w3.org/TR/xbl/#explicit3 ), as well as :before and :after
michael@0 140 * anonymous content and native anonymous children.
michael@0 141 *
michael@0 142 * @note the result children order is
michael@0 143 * 1. :before generated node
michael@0 144 * 2. XBL explicit children of the node
michael@0 145 * 3. native anonymous nodes
michael@0 146 * 4. :after generated node
michael@0 147 */
michael@0 148 eAllButXBL = 1,
michael@0 149
michael@0 150 /**
michael@0 151 * Skip native anonymous content created for placeholder of HTML input,
michael@0 152 * used in conjunction with eAllChildren or eAllButXBL.
michael@0 153 */
michael@0 154 eSkipPlaceholderContent = 2
michael@0 155 };
michael@0 156
michael@0 157 /**
michael@0 158 * Return either the XBL explicit children of the node or the XBL flattened
michael@0 159 * tree children of the node, depending on the filter, as well as
michael@0 160 * native anonymous children.
michael@0 161 *
michael@0 162 * @note calling this method with eAllButXBL will return children that are
michael@0 163 * also in the eAllButXBL and eAllChildren child lists of other descendants
michael@0 164 * of this node in the tree, but those other nodes cannot be reached from the
michael@0 165 * eAllButXBL child list.
michael@0 166 */
michael@0 167 virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) = 0;
michael@0 168
michael@0 169 /**
michael@0 170 * Get whether this content is C++-generated anonymous content
michael@0 171 * @see nsIAnonymousContentCreator
michael@0 172 * @return whether this content is anonymous
michael@0 173 */
michael@0 174 bool IsRootOfNativeAnonymousSubtree() const
michael@0 175 {
michael@0 176 NS_ASSERTION(!HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT) ||
michael@0 177 (HasFlag(NODE_IS_ANONYMOUS_ROOT) &&
michael@0 178 HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)),
michael@0 179 "Some flags seem to be missing!");
michael@0 180 return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT);
michael@0 181 }
michael@0 182
michael@0 183 bool IsRootOfChromeAccessOnlySubtree() const
michael@0 184 {
michael@0 185 return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT |
michael@0 186 NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS);
michael@0 187 }
michael@0 188
michael@0 189 /**
michael@0 190 * Makes this content anonymous
michael@0 191 * @see nsIAnonymousContentCreator
michael@0 192 */
michael@0 193 void SetIsNativeAnonymousRoot()
michael@0 194 {
michael@0 195 SetFlags(NODE_IS_ANONYMOUS_ROOT | NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
michael@0 196 NODE_IS_NATIVE_ANONYMOUS_ROOT);
michael@0 197 }
michael@0 198
michael@0 199 /**
michael@0 200 * Returns |this| if it is not chrome-only/native anonymous, otherwise
michael@0 201 * first non chrome-only/native anonymous ancestor.
michael@0 202 */
michael@0 203 virtual nsIContent* FindFirstNonChromeOnlyAccessContent() const;
michael@0 204
michael@0 205 /**
michael@0 206 * Returns true if and only if this node has a parent, but is not in
michael@0 207 * its parent's child list.
michael@0 208 */
michael@0 209 bool IsRootOfAnonymousSubtree() const
michael@0 210 {
michael@0 211 NS_ASSERTION(!IsRootOfNativeAnonymousSubtree() ||
michael@0 212 (GetParent() && GetBindingParent() == GetParent()),
michael@0 213 "root of native anonymous subtree must have parent equal "
michael@0 214 "to binding parent");
michael@0 215 NS_ASSERTION(!GetParent() ||
michael@0 216 ((GetBindingParent() == GetParent()) ==
michael@0 217 HasFlag(NODE_IS_ANONYMOUS_ROOT)) ||
michael@0 218 // Unfortunately default content for XBL insertion points is
michael@0 219 // anonymous content that is bound with the parent of the
michael@0 220 // insertion point as the parent but the bound element for the
michael@0 221 // binding as the binding parent. So we have to complicate
michael@0 222 // the assert a bit here.
michael@0 223 (GetBindingParent() &&
michael@0 224 (GetBindingParent() == GetParent()->GetBindingParent()) ==
michael@0 225 HasFlag(NODE_IS_ANONYMOUS_ROOT)),
michael@0 226 "For nodes with parent, flag and GetBindingParent() check "
michael@0 227 "should match");
michael@0 228 return HasFlag(NODE_IS_ANONYMOUS_ROOT);
michael@0 229 }
michael@0 230
michael@0 231 /**
michael@0 232 * Returns true if there is NOT a path through child lists
michael@0 233 * from the top of this node's parent chain back to this node or
michael@0 234 * if the node is in native anonymous subtree without a parent.
michael@0 235 */
michael@0 236 bool IsInAnonymousSubtree() const
michael@0 237 {
michael@0 238 NS_ASSERTION(!IsInNativeAnonymousSubtree() || GetBindingParent() ||
michael@0 239 (!IsInDoc() &&
michael@0 240 static_cast<nsIContent*>(SubtreeRoot())->IsInNativeAnonymousSubtree()),
michael@0 241 "Must have binding parent when in native anonymous subtree which is in document.\n"
michael@0 242 "Native anonymous subtree which is not in document must have native anonymous root.");
michael@0 243 return IsInNativeAnonymousSubtree() || (!HasFlag(NODE_IS_IN_SHADOW_TREE) && GetBindingParent() != nullptr);
michael@0 244 }
michael@0 245
michael@0 246 /**
michael@0 247 * Return true iff this node is in an HTML document (in the HTML5 sense of
michael@0 248 * the term, i.e. not in an XHTML/XML document).
michael@0 249 */
michael@0 250 inline bool IsInHTMLDocument() const;
michael@0 251
michael@0 252 /**
michael@0 253 * Get the namespace that this element's tag is defined in
michael@0 254 * @return the namespace
michael@0 255 */
michael@0 256 inline int32_t GetNameSpaceID() const
michael@0 257 {
michael@0 258 return mNodeInfo->NamespaceID();
michael@0 259 }
michael@0 260
michael@0 261 /**
michael@0 262 * Get the NodeInfo for this element
michael@0 263 * @return the nodes node info
michael@0 264 */
michael@0 265 inline nsINodeInfo* NodeInfo() const
michael@0 266 {
michael@0 267 return mNodeInfo;
michael@0 268 }
michael@0 269
michael@0 270 inline bool IsInNamespace(int32_t aNamespace) const
michael@0 271 {
michael@0 272 return mNodeInfo->NamespaceID() == aNamespace;
michael@0 273 }
michael@0 274
michael@0 275 inline bool IsHTML() const
michael@0 276 {
michael@0 277 return IsInNamespace(kNameSpaceID_XHTML);
michael@0 278 }
michael@0 279
michael@0 280 inline bool IsHTML(nsIAtom* aTag) const
michael@0 281 {
michael@0 282 return mNodeInfo->Equals(aTag, kNameSpaceID_XHTML);
michael@0 283 }
michael@0 284
michael@0 285 inline bool IsSVG() const
michael@0 286 {
michael@0 287 return IsInNamespace(kNameSpaceID_SVG);
michael@0 288 }
michael@0 289
michael@0 290 inline bool IsSVG(nsIAtom* aTag) const
michael@0 291 {
michael@0 292 return mNodeInfo->Equals(aTag, kNameSpaceID_SVG);
michael@0 293 }
michael@0 294
michael@0 295 inline bool IsXUL() const
michael@0 296 {
michael@0 297 return IsInNamespace(kNameSpaceID_XUL);
michael@0 298 }
michael@0 299
michael@0 300 inline bool IsXUL(nsIAtom* aTag) const
michael@0 301 {
michael@0 302 return mNodeInfo->Equals(aTag, kNameSpaceID_XUL);
michael@0 303 }
michael@0 304
michael@0 305 inline bool IsMathML() const
michael@0 306 {
michael@0 307 return IsInNamespace(kNameSpaceID_MathML);
michael@0 308 }
michael@0 309
michael@0 310 inline bool IsMathML(nsIAtom* aTag) const
michael@0 311 {
michael@0 312 return mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
michael@0 313 }
michael@0 314
michael@0 315 inline bool IsActiveChildrenElement() const
michael@0 316 {
michael@0 317 return mNodeInfo->Equals(nsGkAtoms::children, kNameSpaceID_XBL) &&
michael@0 318 GetBindingParent();
michael@0 319 }
michael@0 320
michael@0 321 /**
michael@0 322 * Returns an atom holding the name of the attribute of type ID on
michael@0 323 * this content node (if applicable). Returns null for non-element
michael@0 324 * content nodes.
michael@0 325 */
michael@0 326 virtual nsIAtom *GetIDAttributeName() const = 0;
michael@0 327
michael@0 328 /**
michael@0 329 * Set attribute values. All attribute values are assumed to have a
michael@0 330 * canonical string representation that can be used for these
michael@0 331 * methods. The SetAttr method is assumed to perform a translation
michael@0 332 * of the canonical form into the underlying content specific
michael@0 333 * form.
michael@0 334 *
michael@0 335 * @param aNameSpaceID the namespace of the attribute
michael@0 336 * @param aName the name of the attribute
michael@0 337 * @param aValue the value to set
michael@0 338 * @param aNotify specifies how whether or not the document should be
michael@0 339 * notified of the attribute change.
michael@0 340 */
michael@0 341 nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
michael@0 342 const nsAString& aValue, bool aNotify)
michael@0 343 {
michael@0 344 return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
michael@0 345 }
michael@0 346
michael@0 347 /**
michael@0 348 * Set attribute values. All attribute values are assumed to have a
michael@0 349 * canonical String representation that can be used for these
michael@0 350 * methods. The SetAttr method is assumed to perform a translation
michael@0 351 * of the canonical form into the underlying content specific
michael@0 352 * form.
michael@0 353 *
michael@0 354 * @param aNameSpaceID the namespace of the attribute
michael@0 355 * @param aName the name of the attribute
michael@0 356 * @param aPrefix the prefix of the attribute
michael@0 357 * @param aValue the value to set
michael@0 358 * @param aNotify specifies how whether or not the document should be
michael@0 359 * notified of the attribute change.
michael@0 360 */
michael@0 361 virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
michael@0 362 nsIAtom* aPrefix, const nsAString& aValue,
michael@0 363 bool aNotify) = 0;
michael@0 364
michael@0 365 /**
michael@0 366 * Get the current value of the attribute. This returns a form that is
michael@0 367 * suitable for passing back into SetAttr.
michael@0 368 *
michael@0 369 * @param aNameSpaceID the namespace of the attr
michael@0 370 * @param aName the name of the attr
michael@0 371 * @param aResult the value (may legitimately be the empty string) [OUT]
michael@0 372 * @returns true if the attribute was set (even when set to empty string)
michael@0 373 * false when not set.
michael@0 374 */
michael@0 375 bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
michael@0 376 nsAString& aResult) const;
michael@0 377
michael@0 378 /**
michael@0 379 * Determine if an attribute has been set (empty string or otherwise).
michael@0 380 *
michael@0 381 * @param aNameSpaceId the namespace id of the attribute
michael@0 382 * @param aAttr the attribute name
michael@0 383 * @return whether an attribute exists
michael@0 384 */
michael@0 385 bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const;
michael@0 386
michael@0 387 /**
michael@0 388 * Test whether this content node's given attribute has the given value. If
michael@0 389 * the attribute is not set at all, this will return false.
michael@0 390 *
michael@0 391 * @param aNameSpaceID The namespace ID of the attribute. Must not
michael@0 392 * be kNameSpaceID_Unknown.
michael@0 393 * @param aName The name atom of the attribute. Must not be null.
michael@0 394 * @param aValue The value to compare to.
michael@0 395 * @param aCaseSensitive Whether to do a case-sensitive compare on the value.
michael@0 396 */
michael@0 397 bool AttrValueIs(int32_t aNameSpaceID,
michael@0 398 nsIAtom* aName,
michael@0 399 const nsAString& aValue,
michael@0 400 nsCaseTreatment aCaseSensitive) const;
michael@0 401
michael@0 402 /**
michael@0 403 * Test whether this content node's given attribute has the given value. If
michael@0 404 * the attribute is not set at all, this will return false.
michael@0 405 *
michael@0 406 * @param aNameSpaceID The namespace ID of the attribute. Must not
michael@0 407 * be kNameSpaceID_Unknown.
michael@0 408 * @param aName The name atom of the attribute. Must not be null.
michael@0 409 * @param aValue The value to compare to. Must not be null.
michael@0 410 * @param aCaseSensitive Whether to do a case-sensitive compare on the value.
michael@0 411 */
michael@0 412 bool AttrValueIs(int32_t aNameSpaceID,
michael@0 413 nsIAtom* aName,
michael@0 414 nsIAtom* aValue,
michael@0 415 nsCaseTreatment aCaseSensitive) const;
michael@0 416
michael@0 417 enum {
michael@0 418 ATTR_MISSING = -1,
michael@0 419 ATTR_VALUE_NO_MATCH = -2
michael@0 420 };
michael@0 421 /**
michael@0 422 * Check whether this content node's given attribute has one of a given
michael@0 423 * list of values. If there is a match, we return the index in the list
michael@0 424 * of the first matching value. If there was no attribute at all, then
michael@0 425 * we return ATTR_MISSING. If there was an attribute but it didn't
michael@0 426 * match, we return ATTR_VALUE_NO_MATCH. A non-negative result always
michael@0 427 * indicates a match.
michael@0 428 *
michael@0 429 * @param aNameSpaceID The namespace ID of the attribute. Must not
michael@0 430 * be kNameSpaceID_Unknown.
michael@0 431 * @param aName The name atom of the attribute. Must not be null.
michael@0 432 * @param aValues a nullptr-terminated array of pointers to atom values to test
michael@0 433 * against.
michael@0 434 * @param aCaseSensitive Whether to do a case-sensitive compare on the values.
michael@0 435 * @return ATTR_MISSING, ATTR_VALUE_NO_MATCH or the non-negative index
michael@0 436 * indicating the first value of aValues that matched
michael@0 437 */
michael@0 438 typedef nsIAtom* const* const AttrValuesArray;
michael@0 439 virtual int32_t FindAttrValueIn(int32_t aNameSpaceID,
michael@0 440 nsIAtom* aName,
michael@0 441 AttrValuesArray* aValues,
michael@0 442 nsCaseTreatment aCaseSensitive) const
michael@0 443 {
michael@0 444 return ATTR_MISSING;
michael@0 445 }
michael@0 446
michael@0 447 /**
michael@0 448 * Remove an attribute so that it is no longer explicitly specified.
michael@0 449 *
michael@0 450 * @param aNameSpaceID the namespace id of the attribute
michael@0 451 * @param aAttr the name of the attribute to unset
michael@0 452 * @param aNotify specifies whether or not the document should be
michael@0 453 * notified of the attribute change
michael@0 454 */
michael@0 455 virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
michael@0 456 bool aNotify) = 0;
michael@0 457
michael@0 458
michael@0 459 /**
michael@0 460 * Get the namespace / name / prefix of a given attribute.
michael@0 461 *
michael@0 462 * @param aIndex the index of the attribute name
michael@0 463 * @returns The name at the given index, or null if the index is
michael@0 464 * out-of-bounds.
michael@0 465 * @note The document returned by NodeInfo()->GetDocument() (if one is
michael@0 466 * present) is *not* necessarily the owner document of the element.
michael@0 467 * @note The pointer returned by this function is only valid until the
michael@0 468 * next call of either GetAttrNameAt or SetAttr on the element.
michael@0 469 */
michael@0 470 virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const = 0;
michael@0 471
michael@0 472 /**
michael@0 473 * Get the number of all specified attributes.
michael@0 474 *
michael@0 475 * @return the number of attributes
michael@0 476 */
michael@0 477 virtual uint32_t GetAttrCount() const = 0;
michael@0 478
michael@0 479 /**
michael@0 480 * Get direct access (but read only) to the text in the text content.
michael@0 481 * NOTE: For elements this is *not* the concatenation of all text children,
michael@0 482 * it is simply null;
michael@0 483 */
michael@0 484 virtual const nsTextFragment *GetText() = 0;
michael@0 485
michael@0 486 /**
michael@0 487 * Get the length of the text content.
michael@0 488 * NOTE: This should not be called on elements.
michael@0 489 */
michael@0 490 virtual uint32_t TextLength() const = 0;
michael@0 491
michael@0 492 /**
michael@0 493 * Determines if an event attribute name (such as onclick) is valid for
michael@0 494 * a given element type.
michael@0 495 * @note calls nsContentUtils::IsEventAttributeName with right flag
michael@0 496 * @note overridden by subclasses as needed
michael@0 497 * @param aName the event name to look up
michael@0 498 */
michael@0 499 virtual bool IsEventAttributeName(nsIAtom* aName)
michael@0 500 {
michael@0 501 return false;
michael@0 502 }
michael@0 503
michael@0 504 /**
michael@0 505 * Set the text to the given value. If aNotify is true then
michael@0 506 * the document is notified of the content change.
michael@0 507 * NOTE: For elements this always ASSERTS and returns NS_ERROR_FAILURE
michael@0 508 */
michael@0 509 virtual nsresult SetText(const char16_t* aBuffer, uint32_t aLength,
michael@0 510 bool aNotify) = 0;
michael@0 511
michael@0 512 /**
michael@0 513 * Append the given value to the current text. If aNotify is true then
michael@0 514 * the document is notified of the content change.
michael@0 515 * NOTE: For elements this always ASSERTS and returns NS_ERROR_FAILURE
michael@0 516 */
michael@0 517 virtual nsresult AppendText(const char16_t* aBuffer, uint32_t aLength,
michael@0 518 bool aNotify) = 0;
michael@0 519
michael@0 520 /**
michael@0 521 * Set the text to the given value. If aNotify is true then
michael@0 522 * the document is notified of the content change.
michael@0 523 * NOTE: For elements this always asserts and returns NS_ERROR_FAILURE
michael@0 524 */
michael@0 525 nsresult SetText(const nsAString& aStr, bool aNotify)
michael@0 526 {
michael@0 527 return SetText(aStr.BeginReading(), aStr.Length(), aNotify);
michael@0 528 }
michael@0 529
michael@0 530 /**
michael@0 531 * Query method to see if the frame is nothing but whitespace
michael@0 532 * NOTE: Always returns false for elements
michael@0 533 */
michael@0 534 virtual bool TextIsOnlyWhitespace() = 0;
michael@0 535
michael@0 536 /**
michael@0 537 * Method to see if the text node contains data that is useful
michael@0 538 * for a translation: i.e., it consists of more than just whitespace,
michael@0 539 * digits and punctuation.
michael@0 540 * NOTE: Always returns false for elements.
michael@0 541 */
michael@0 542 virtual bool HasTextForTranslation() = 0;
michael@0 543
michael@0 544 /**
michael@0 545 * Append the text content to aResult.
michael@0 546 * NOTE: This asserts and returns for elements
michael@0 547 */
michael@0 548 virtual void AppendTextTo(nsAString& aResult) = 0;
michael@0 549
michael@0 550 /**
michael@0 551 * Append the text content to aResult.
michael@0 552 * NOTE: This asserts and returns for elements
michael@0 553 */
michael@0 554 virtual bool AppendTextTo(nsAString& aResult,
michael@0 555 const mozilla::fallible_t&) NS_WARN_UNUSED_RESULT = 0;
michael@0 556
michael@0 557 /**
michael@0 558 * Check if this content is focusable and in the current tab order.
michael@0 559 * Note: most callers should use nsIFrame::IsFocusable() instead as it
michael@0 560 * checks visibility and other layout factors as well.
michael@0 561 * Tabbable is indicated by a nonnegative tabindex & is a subset of focusable.
michael@0 562 * For example, only the selected radio button in a group is in the
michael@0 563 * tab order, unless the radio group has no selection in which case
michael@0 564 * all of the visible, non-disabled radio buttons in the group are
michael@0 565 * in the tab order. On the other hand, all of the visible, non-disabled
michael@0 566 * radio buttons are always focusable via clicking or script.
michael@0 567 * Also, depending on either the accessibility.tabfocus pref or
michael@0 568 * a system setting (nowadays: Full keyboard access, mac only)
michael@0 569 * some widgets may be focusable but removed from the tab order.
michael@0 570 * @param [inout, optional] aTabIndex the computed tab index
michael@0 571 * In: default tabindex for element (-1 nonfocusable, == 0 focusable)
michael@0 572 * Out: computed tabindex
michael@0 573 * @param [optional] aTabIndex the computed tab index
michael@0 574 * < 0 if not tabbable
michael@0 575 * == 0 if in normal tab order
michael@0 576 * > 0 can be tabbed to in the order specified by this value
michael@0 577 * @return whether the content is focusable via mouse, kbd or script.
michael@0 578 */
michael@0 579 bool IsFocusable(int32_t* aTabIndex = nullptr, bool aWithMouse = false);
michael@0 580 virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse);
michael@0 581
michael@0 582 /**
michael@0 583 * The method focuses (or activates) element that accesskey is bound to. It is
michael@0 584 * called when accesskey is activated.
michael@0 585 *
michael@0 586 * @param aKeyCausesActivation - if true then element should be activated
michael@0 587 * @param aIsTrustedEvent - if true then event that is cause of accesskey
michael@0 588 * execution is trusted.
michael@0 589 */
michael@0 590 virtual void PerformAccesskey(bool aKeyCausesActivation,
michael@0 591 bool aIsTrustedEvent)
michael@0 592 {
michael@0 593 }
michael@0 594
michael@0 595 /*
michael@0 596 * Get desired IME state for the content.
michael@0 597 *
michael@0 598 * @return The desired IME status for the content.
michael@0 599 * This is a combination of an IME enabled value and
michael@0 600 * an IME open value of widget::IMEState.
michael@0 601 * If you return DISABLED, you should not set the OPEN and CLOSE
michael@0 602 * value.
michael@0 603 * PASSWORD should be returned only from password editor, this value
michael@0 604 * has a special meaning. It is used as alternative of DISABLED.
michael@0 605 * PLUGIN should be returned only when plug-in has focus. When a
michael@0 606 * plug-in is focused content, we should send native events directly.
michael@0 607 * Because we don't process some native events, but they may be needed
michael@0 608 * by the plug-in.
michael@0 609 */
michael@0 610 virtual IMEState GetDesiredIMEState();
michael@0 611
michael@0 612 /**
michael@0 613 * Gets content node with the binding (or native code, possibly on the
michael@0 614 * frame) responsible for our construction (and existence). Used by
michael@0 615 * anonymous content (both XBL-generated and native-anonymous).
michael@0 616 *
michael@0 617 * null for all explicit content (i.e., content reachable from the top
michael@0 618 * of its GetParent() chain via child lists).
michael@0 619 *
michael@0 620 * @return the binding parent
michael@0 621 */
michael@0 622 virtual nsIContent *GetBindingParent() const = 0;
michael@0 623
michael@0 624 /**
michael@0 625 * Gets the current XBL binding that is bound to this element.
michael@0 626 *
michael@0 627 * @return the current binding.
michael@0 628 */
michael@0 629 virtual nsXBLBinding *GetXBLBinding() const = 0;
michael@0 630
michael@0 631 /**
michael@0 632 * Sets or unsets an XBL binding for this element. Setting a
michael@0 633 * binding on an element that already has a binding will remove the
michael@0 634 * old binding.
michael@0 635 *
michael@0 636 * @param aBinding The binding to bind to this content. If nullptr is
michael@0 637 * provided as the argument, then existing binding will be
michael@0 638 * removed.
michael@0 639 *
michael@0 640 * @param aOldBindingManager The old binding manager that contains
michael@0 641 * this content if this content was adopted
michael@0 642 * to another document.
michael@0 643 */
michael@0 644 virtual void SetXBLBinding(nsXBLBinding* aBinding,
michael@0 645 nsBindingManager* aOldBindingManager = nullptr) = 0;
michael@0 646
michael@0 647 /**
michael@0 648 * Sets the ShadowRoot binding for this element. The contents of the
michael@0 649 * binding is rendered in place of this node's children.
michael@0 650 *
michael@0 651 * @param aShadowRoot The ShadowRoot to be bound to this element.
michael@0 652 */
michael@0 653 virtual void SetShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot) = 0;
michael@0 654
michael@0 655 /**
michael@0 656 * Gets the ShadowRoot binding for this element.
michael@0 657 *
michael@0 658 * @return The ShadowRoot currently bound to this element.
michael@0 659 */
michael@0 660 virtual mozilla::dom::ShadowRoot *GetShadowRoot() const = 0;
michael@0 661
michael@0 662 /**
michael@0 663 * Gets the root of the node tree for this content if it is in a shadow tree.
michael@0 664 * This method is called |GetContainingShadow| instead of |GetRootShadowRoot|
michael@0 665 * to avoid confusion with |GetShadowRoot|.
michael@0 666 *
michael@0 667 * @return The ShadowRoot that is the root of the node tree.
michael@0 668 */
michael@0 669 virtual mozilla::dom::ShadowRoot *GetContainingShadow() const = 0;
michael@0 670
michael@0 671 /**
michael@0 672 * Gets the insertion parent element of the XBL binding.
michael@0 673 * The insertion parent is our one true parent in the transformed DOM.
michael@0 674 *
michael@0 675 * @return the insertion parent element.
michael@0 676 */
michael@0 677 virtual nsIContent *GetXBLInsertionParent() const = 0;
michael@0 678
michael@0 679 /**
michael@0 680 * Sets the insertion parent element of the XBL binding.
michael@0 681 *
michael@0 682 * @param aContent The insertion parent element.
michael@0 683 */
michael@0 684 virtual void SetXBLInsertionParent(nsIContent* aContent) = 0;
michael@0 685
michael@0 686 /**
michael@0 687 * Returns the content node that is the parent of this node in the flattened
michael@0 688 * tree. For nodes that are not filtered into an insertion point, this
michael@0 689 * simply returns their DOM parent in the original DOM tree.
michael@0 690 *
michael@0 691 * @return the flattened tree parent
michael@0 692 */
michael@0 693 nsIContent *GetFlattenedTreeParent() const;
michael@0 694
michael@0 695 /**
michael@0 696 * Gets the custom element data used by web components custom element.
michael@0 697 * Custom element data is created at the first attempt to enqueue a callback.
michael@0 698 *
michael@0 699 * @return The custom element data or null if none.
michael@0 700 */
michael@0 701 virtual mozilla::dom::CustomElementData *GetCustomElementData() const = 0;
michael@0 702
michael@0 703 /**
michael@0 704 * Sets the custom element data, ownership of the
michael@0 705 * callback data is taken by this content.
michael@0 706 *
michael@0 707 * @param aCallbackData The custom element data.
michael@0 708 */
michael@0 709 virtual void SetCustomElementData(mozilla::dom::CustomElementData* aData) = 0;
michael@0 710
michael@0 711 /**
michael@0 712 * API to check if this is a link that's traversed in response to user input
michael@0 713 * (e.g. a click event). Specializations for HTML/SVG/generic XML allow for
michael@0 714 * different types of link in different types of content.
michael@0 715 *
michael@0 716 * @param aURI Required out param. If this content is a link, a new nsIURI
michael@0 717 * set to this link's URI will be passed out.
michael@0 718 *
michael@0 719 * @note The out param, aURI, is guaranteed to be set to a non-null pointer
michael@0 720 * when the return value is true.
michael@0 721 *
michael@0 722 * XXXjwatt: IMO IsInteractiveLink would be a better name.
michael@0 723 */
michael@0 724 virtual bool IsLink(nsIURI** aURI) const = 0;
michael@0 725
michael@0 726 /**
michael@0 727 * Get a pointer to the full href URI (fully resolved and canonicalized,
michael@0 728 * since it's an nsIURI object) for link elements.
michael@0 729 *
michael@0 730 * @return A pointer to the URI or null if the element is not a link or it
michael@0 731 * has no HREF attribute.
michael@0 732 */
michael@0 733 virtual already_AddRefed<nsIURI> GetHrefURI() const
michael@0 734 {
michael@0 735 return nullptr;
michael@0 736 }
michael@0 737
michael@0 738 /**
michael@0 739 * This method is called when the parser finishes creating the element. This
michael@0 740 * particularly means that it has done everything you would expect it to have
michael@0 741 * done after it encounters the > at the end of the tag (for HTML or XML).
michael@0 742 * This includes setting the attributes, setting the document / form, and
michael@0 743 * placing the element into the tree at its proper place.
michael@0 744 *
michael@0 745 * For container elements, this is called *before* any of the children are
michael@0 746 * created or added into the tree.
michael@0 747 *
michael@0 748 * NOTE: this is currently only called for input and button, in the HTML
michael@0 749 * content sink. If you want to call it on your element, modify the content
michael@0 750 * sink of your choice to do so. This is an efficiency measure.
michael@0 751 *
michael@0 752 * If you also need to determine whether the parser is the one creating your
michael@0 753 * element (through createElement() or cloneNode() generally) then add a
michael@0 754 * uint32_t aFromParser to the NS_NewXXX() constructor for your element and
michael@0 755 * have the parser pass the appropriate flags. See HTMLInputElement.cpp and
michael@0 756 * nsHTMLContentSink::MakeContentObject().
michael@0 757 *
michael@0 758 * DO NOT USE THIS METHOD to get around the fact that it's hard to deal with
michael@0 759 * attributes dynamically. If you make attributes affect your element from
michael@0 760 * this method, it will only happen on initialization and JavaScript will not
michael@0 761 * be able to create elements (which requires them to first create the
michael@0 762 * element and then call setAttribute() directly, at which point
michael@0 763 * DoneCreatingElement() has already been called and is out of the picture).
michael@0 764 */
michael@0 765 virtual void DoneCreatingElement()
michael@0 766 {
michael@0 767 }
michael@0 768
michael@0 769 /**
michael@0 770 * This method is called when the parser begins creating the element's
michael@0 771 * children, if any are present.
michael@0 772 *
michael@0 773 * This is only called for XTF elements currently.
michael@0 774 */
michael@0 775 virtual void BeginAddingChildren()
michael@0 776 {
michael@0 777 }
michael@0 778
michael@0 779 /**
michael@0 780 * This method is called when the parser finishes creating the element's children,
michael@0 781 * if any are present.
michael@0 782 *
michael@0 783 * NOTE: this is currently only called for textarea, select, applet, and
michael@0 784 * object elements in the HTML content sink. If you want
michael@0 785 * to call it on your element, modify the content sink of your
michael@0 786 * choice to do so. This is an efficiency measure.
michael@0 787 *
michael@0 788 * If you also need to determine whether the parser is the one creating your
michael@0 789 * element (through createElement() or cloneNode() generally) then add a
michael@0 790 * boolean aFromParser to the NS_NewXXX() constructor for your element and
michael@0 791 * have the parser pass true. See HTMLInputElement.cpp and
michael@0 792 * nsHTMLContentSink::MakeContentObject().
michael@0 793 *
michael@0 794 * @param aHaveNotified Whether there has been a
michael@0 795 * ContentInserted/ContentAppended notification for this content node
michael@0 796 * yet.
michael@0 797 */
michael@0 798 virtual void DoneAddingChildren(bool aHaveNotified)
michael@0 799 {
michael@0 800 }
michael@0 801
michael@0 802 /**
michael@0 803 * For HTML textarea, select, applet, and object elements, returns
michael@0 804 * true if all children have been added OR if the element was not
michael@0 805 * created by the parser. Returns true for all other elements.
michael@0 806 * @returns false if the element was created by the parser and
michael@0 807 * it is an HTML textarea, select, applet, or object
michael@0 808 * element and not all children have been added.
michael@0 809 * @returns true otherwise.
michael@0 810 */
michael@0 811 virtual bool IsDoneAddingChildren()
michael@0 812 {
michael@0 813 return true;
michael@0 814 }
michael@0 815
michael@0 816 /**
michael@0 817 * Get the ID of this content node (the atom corresponding to the
michael@0 818 * value of the null-namespace attribute whose name is given by
michael@0 819 * GetIDAttributeName(). This may be null if there is no ID.
michael@0 820 */
michael@0 821 nsIAtom* GetID() const {
michael@0 822 if (HasID()) {
michael@0 823 return DoGetID();
michael@0 824 }
michael@0 825 return nullptr;
michael@0 826 }
michael@0 827
michael@0 828 /**
michael@0 829 * Get the class list of this content node (this corresponds to the
michael@0 830 * value of the null-namespace attribute whose name is given by
michael@0 831 * GetClassAttributeName()). This may be null if there are no
michael@0 832 * classes, but that's not guaranteed.
michael@0 833 */
michael@0 834 const nsAttrValue* GetClasses() const {
michael@0 835 if (HasFlag(NODE_MAY_HAVE_CLASS)) {
michael@0 836 return DoGetClasses();
michael@0 837 }
michael@0 838 return nullptr;
michael@0 839 }
michael@0 840
michael@0 841 /**
michael@0 842 * Walk aRuleWalker over the content style rules (presentational
michael@0 843 * hint rules) for this content node.
michael@0 844 */
michael@0 845 NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
michael@0 846
michael@0 847 /**
michael@0 848 * Should be called when the node can become editable or when it can stop
michael@0 849 * being editable (for example when its contentEditable attribute changes,
michael@0 850 * when it is moved into an editable parent, ...). If aNotify is true and
michael@0 851 * the node is an element, this will notify the state change.
michael@0 852 */
michael@0 853 virtual void UpdateEditableState(bool aNotify);
michael@0 854
michael@0 855 /**
michael@0 856 * Destroy this node and its children. Ideally this shouldn't be needed
michael@0 857 * but for now we need to do it to break cycles.
michael@0 858 */
michael@0 859 virtual void DestroyContent() = 0;
michael@0 860
michael@0 861 /**
michael@0 862 * Saves the form state of this node and its children.
michael@0 863 */
michael@0 864 virtual void SaveSubtreeState() = 0;
michael@0 865
michael@0 866 /**
michael@0 867 * Getter and setter for our primary frame pointer. This is the frame that
michael@0 868 * is most closely associated with the content. A frame is more closely
michael@0 869 * associated with the content than another frame if the one frame contains
michael@0 870 * directly or indirectly the other frame (e.g., when a frame is scrolled
michael@0 871 * there is a scroll frame that contains the frame being scrolled). This
michael@0 872 * frame is always the first continuation.
michael@0 873 *
michael@0 874 * In the case of absolutely positioned elements and floated elements, this
michael@0 875 * frame is the out of flow frame, not the placeholder.
michael@0 876 */
michael@0 877 nsIFrame* GetPrimaryFrame() const
michael@0 878 {
michael@0 879 return IsInDoc() ? mPrimaryFrame : nullptr;
michael@0 880 }
michael@0 881 void SetPrimaryFrame(nsIFrame* aFrame) {
michael@0 882 NS_ASSERTION(IsInDoc(), "This will end badly!");
michael@0 883 NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
michael@0 884 "Losing track of existing primary frame");
michael@0 885 mPrimaryFrame = aFrame;
michael@0 886 }
michael@0 887
michael@0 888 nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
michael@0 889 nsAString& aNamespaceURI) const;
michael@0 890
michael@0 891 /**
michael@0 892 * If this content has independent selection, e.g., if this is input field
michael@0 893 * or textarea, this return TRUE. Otherwise, false.
michael@0 894 */
michael@0 895 bool HasIndependentSelection();
michael@0 896
michael@0 897 /**
michael@0 898 * If the content is a part of HTML editor, this returns editing
michael@0 899 * host content. When the content is in designMode, this returns its body
michael@0 900 * element. Also, when the content isn't editable, this returns null.
michael@0 901 */
michael@0 902 mozilla::dom::Element* GetEditingHost();
michael@0 903
michael@0 904 /**
michael@0 905 * Determing language. Look at the nearest ancestor element that has a lang
michael@0 906 * attribute in the XML namespace or is an HTML/SVG element and has a lang in
michael@0 907 * no namespace attribute.
michael@0 908 */
michael@0 909 void GetLang(nsAString& aResult) const {
michael@0 910 for (const nsIContent* content = this; content; content = content->GetParent()) {
michael@0 911 if (content->GetAttrCount() > 0) {
michael@0 912 // xml:lang has precedence over lang on HTML elements (see
michael@0 913 // XHTML1 section C.7).
michael@0 914 bool hasAttr = content->GetAttr(kNameSpaceID_XML, nsGkAtoms::lang,
michael@0 915 aResult);
michael@0 916 if (!hasAttr && (content->IsHTML() || content->IsSVG())) {
michael@0 917 hasAttr = content->GetAttr(kNameSpaceID_None, nsGkAtoms::lang,
michael@0 918 aResult);
michael@0 919 }
michael@0 920 NS_ASSERTION(hasAttr || aResult.IsEmpty(),
michael@0 921 "GetAttr that returns false should not make string non-empty");
michael@0 922 if (hasAttr) {
michael@0 923 return;
michael@0 924 }
michael@0 925 }
michael@0 926 }
michael@0 927 }
michael@0 928
michael@0 929 // Overloaded from nsINode
michael@0 930 virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE;
michael@0 931
michael@0 932 virtual nsresult PreHandleEvent(
michael@0 933 mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
michael@0 934
michael@0 935 virtual bool IsPurple() = 0;
michael@0 936 virtual void RemovePurple() = 0;
michael@0 937
michael@0 938 virtual bool OwnedOnlyByTheDOMTree() { return false; }
michael@0 939 protected:
michael@0 940 /**
michael@0 941 * Hook for implementing GetID. This is guaranteed to only be
michael@0 942 * called if HasID() is true.
michael@0 943 */
michael@0 944 virtual nsIAtom* DoGetID() const = 0;
michael@0 945
michael@0 946 private:
michael@0 947 /**
michael@0 948 * Hook for implementing GetClasses. This is guaranteed to only be
michael@0 949 * called if the NODE_MAY_HAVE_CLASS flag is set.
michael@0 950 */
michael@0 951 virtual const nsAttrValue* DoGetClasses() const = 0;
michael@0 952
michael@0 953 public:
michael@0 954 #ifdef DEBUG
michael@0 955 /**
michael@0 956 * List the content (and anything it contains) out to the given
michael@0 957 * file stream. Use aIndent as the base indent during formatting.
michael@0 958 */
michael@0 959 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
michael@0 960
michael@0 961 /**
michael@0 962 * Dump the content (and anything it contains) out to the given
michael@0 963 * file stream. Use aIndent as the base indent during formatting.
michael@0 964 */
michael@0 965 virtual void DumpContent(FILE* out = stdout, int32_t aIndent = 0,
michael@0 966 bool aDumpAll = true) const = 0;
michael@0 967 #endif
michael@0 968
michael@0 969 /**
michael@0 970 * Append to aOutDescription a short (preferably one line) string
michael@0 971 * describing the content.
michael@0 972 * Currently implemented for elements only.
michael@0 973 */
michael@0 974 virtual void Describe(nsAString& aOutDescription) const {
michael@0 975 aOutDescription = NS_LITERAL_STRING("(not an element)");
michael@0 976 }
michael@0 977
michael@0 978 enum ETabFocusType {
michael@0 979 //eTabFocus_textControlsMask = (1<<0), // unused - textboxes always tabbable
michael@0 980 eTabFocus_formElementsMask = (1<<1), // non-text form elements
michael@0 981 eTabFocus_linksMask = (1<<2), // links
michael@0 982 eTabFocus_any = 1 + (1<<1) + (1<<2) // everything that can be focused
michael@0 983 };
michael@0 984
michael@0 985 // Tab focus model bit field:
michael@0 986 static int32_t sTabFocusModel;
michael@0 987
michael@0 988 // accessibility.tabfocus_applies_to_xul pref - if it is set to true,
michael@0 989 // the tabfocus bit field applies to xul elements.
michael@0 990 static bool sTabFocusModelAppliesToXUL;
michael@0 991 };
michael@0 992
michael@0 993 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
michael@0 994
michael@0 995 inline nsIContent* nsINode::AsContent()
michael@0 996 {
michael@0 997 MOZ_ASSERT(IsContent());
michael@0 998 return static_cast<nsIContent*>(this);
michael@0 999 }
michael@0 1000
michael@0 1001 #define NS_IMPL_FROMCONTENT_HELPER(_class, _check) \
michael@0 1002 static _class* FromContent(nsIContent* aContent) \
michael@0 1003 { \
michael@0 1004 return aContent->_check ? static_cast<_class*>(aContent) : nullptr; \
michael@0 1005 } \
michael@0 1006 static _class* FromContentOrNull(nsIContent* aContent) \
michael@0 1007 { \
michael@0 1008 return aContent ? FromContent(aContent) : nullptr; \
michael@0 1009 }
michael@0 1010
michael@0 1011 #define NS_IMPL_FROMCONTENT(_class, _nsid) \
michael@0 1012 NS_IMPL_FROMCONTENT_HELPER(_class, IsInNamespace(_nsid))
michael@0 1013
michael@0 1014 #define NS_IMPL_FROMCONTENT_WITH_TAG(_class, _nsid, _tag) \
michael@0 1015 NS_IMPL_FROMCONTENT_HELPER(_class, NodeInfo()->Equals(nsGkAtoms::_tag, _nsid))
michael@0 1016
michael@0 1017 #define NS_IMPL_FROMCONTENT_HTML_WITH_TAG(_class, _tag) \
michael@0 1018 NS_IMPL_FROMCONTENT_WITH_TAG(_class, kNameSpaceID_XHTML, _tag)
michael@0 1019
michael@0 1020 #endif /* nsIContent_h___ */

mercurial