1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
|
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003-2024 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#pragma once
#include "AXTextStateChangeIntent.h"
#include "ContainerNode.h"
#include "ElementIdentifier.h"
#include "EventOptions.h"
#include "FocusOptions.h"
#include "HitTestRequest.h"
#include "QualifiedName.h"
#include "RenderPtr.h"
#include "ScrollTypes.h"
#include "ShadowRootMode.h"
#include "SimulatedClickOptions.h"
#include "WebAnimationTypes.h"
#include <JavaScriptCore/Forward.h>
#define DUMP_NODE_STATISTICS 0
namespace JSC {
class JSGlobalObject;
class JSValue;
}
namespace WebCore {
class Attr;
class Attribute;
class AttributeIteratorAccessor;
class CustomElementDefaultARIA;
class CustomElementReactionQueue;
class CustomStateSet;
class DatasetDOMStringMap;
class DOMRect;
class DOMRectList;
class DOMTokenList;
class DeferredPromise;
class Document;
class ElementAnimationRareData;
class ElementData;
class ElementRareData;
class FormAssociatedCustomElement;
class FormListedElement;
class HTMLButtonElement;
class HTMLDocument;
class HTMLElement;
class IntSize;
class JSCustomElementInterface;
class KeyframeEffectStack;
class KeyboardEvent;
class LocalFrame;
class Locale;
class PlatformKeyboardEvent;
class PlatformMouseEvent;
class PlatformWheelEvent;
class PopoverData;
class PseudoElement;
class RenderStyle;
class RenderTreePosition;
class SpaceSplitString;
class StylePropertyMap;
class StylePropertyMapReadOnly;
class Text;
class TrustedHTML;
class TrustedScript;
class TrustedScriptURL;
class UniqueElementData;
class ValidatedFormListedElement;
class WebAnimation;
#if ENABLE(ATTACHMENT_ELEMENT)
class AttachmentAssociatedElement;
#endif
enum class AnimationImpact : uint8_t;
enum class EventHandling : uint8_t;
enum class EventProcessing : uint8_t;
enum class FullscreenNavigationUI : uint8_t;
enum class FullscreenKeyboardLock : uint8_t;
enum class IsSyntheticClick : bool { No, Yes };
enum class ParserContentPolicy : uint8_t;
enum class ResolveURLs : uint8_t { No, NoExcludingURLsForPrivacy, Yes, YesExcludingURLsForPrivacy };
enum class SelectionRestorationMode : uint8_t;
enum class ShadowRootDelegatesFocus : bool { No, Yes };
enum class ShadowRootClonable : bool { No, Yes };
enum class ShadowRootSerializable : bool { No, Yes };
enum class VisibilityAdjustment : uint8_t;
// https://github.com/whatwg/html/pull/9841
enum class CommandType: uint8_t {
Invalid,
Custom,
TogglePopover,
HidePopover,
ShowPopover,
ShowModal,
Close,
};
struct CheckVisibilityOptions;
struct FullscreenOptions;
struct GetAnimationsOptions;
struct GetHTMLOptions;
struct IntersectionObserverData;
struct KeyframeAnimationOptions;
struct PointerLockOptions;
struct ResizeObserverData;
struct ScrollIntoViewOptions;
struct ScrollToOptions;
struct SecurityPolicyViolationEventInit;
struct ShadowRootInit;
using ElementName = NodeName;
using ExplicitlySetAttrElementsMap = UncheckedKeyHashMap<QualifiedName, Vector<WeakPtr<Element, WeakPtrImplWithEventTargetData>>>;
using TrustedTypeOrString = std::variant<RefPtr<TrustedHTML>, RefPtr<TrustedScript>, RefPtr<TrustedScriptURL>, AtomString>;
// https://drafts.csswg.org/css-contain/#relevant-to-the-user
enum class ContentRelevancy : uint8_t {
OnScreen = 1 << 0,
Focused = 1 << 1,
IsInTopLayer = 1 << 2,
Selected = 1 << 3,
};
namespace Calculation {
class RandomKeyMap;
}
namespace CSS {
struct SerializationContext;
}
namespace Style {
class Resolver;
enum class Change : uint8_t;
struct PseudoElementIdentifier;
struct ResolutionContext;
struct ResolvedStyle;
}
class Element : public ContainerNode {
WTF_MAKE_TZONE_OR_ISO_ALLOCATED(Element);
WTF_OVERRIDE_DELETE_FOR_CHECKED_PTR(Element);
public:
static Ref<Element> create(const QualifiedName&, Document&);
virtual ~Element();
WEBCORE_EXPORT bool hasAttribute(const QualifiedName&) const;
WEBCORE_EXPORT const AtomString& getAttribute(const QualifiedName&) const;
AtomString getAttributeForBindings(const QualifiedName&, ResolveURLs = ResolveURLs::NoExcludingURLsForPrivacy) const;
template<typename... QualifiedNames>
inline const AtomString& getAttribute(const QualifiedName&, const QualifiedNames&...) const;
WEBCORE_EXPORT ExceptionOr<void> setAttribute(const QualifiedName&, const AtomString& value, bool enforceTrustedTypes = false);
void setAttributeWithoutOverwriting(const QualifiedName&, const AtomString& value);
WEBCORE_EXPORT void setAttributeWithoutSynchronization(const QualifiedName&, const AtomString& value);
void setSynchronizedLazyAttribute(const QualifiedName&, const AtomString& value);
bool removeAttribute(const QualifiedName&);
Vector<String> getAttributeNames() const;
// Typed getters and setters for language bindings.
WEBCORE_EXPORT int getIntegralAttribute(const QualifiedName& attributeName) const;
WEBCORE_EXPORT void setIntegralAttribute(const QualifiedName& attributeName, int value);
WEBCORE_EXPORT unsigned getUnsignedIntegralAttribute(const QualifiedName& attributeName) const;
WEBCORE_EXPORT void setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsigned value);
WEBCORE_EXPORT RefPtr<Element> getElementAttributeForBindings(const QualifiedName& attributeName) const;
WEBCORE_EXPORT void setElementAttribute(const QualifiedName& attributeName, Element* value);
WEBCORE_EXPORT std::optional<Vector<Ref<Element>>> getElementsArrayAttributeForBindings(const QualifiedName& attributeName) const;
WEBCORE_EXPORT void setElementsArrayAttribute(const QualifiedName& attributeName, std::optional<Vector<Ref<Element>>>&& value);
static bool isElementReflectionAttribute(const Settings&, const QualifiedName&);
static bool isElementsArrayReflectionAttribute(const QualifiedName&);
WEBCORE_EXPORT void setUserInfo(JSC::JSGlobalObject&, JSC::JSValue);
WEBCORE_EXPORT String userInfo() const;
// Call this to get the value of an attribute that is known not to be the style
// attribute or one of the SVG animatable attributes.
inline bool hasAttributeWithoutSynchronization(const QualifiedName&) const;
inline const AtomString& attributeWithoutSynchronization(const QualifiedName&) const;
inline const AtomString& attributeWithDefaultARIA(const QualifiedName&) const;
inline String attributeTrimmedWithDefaultARIA(const QualifiedName&) const;
enum class TopLayerElementType : bool { Other, Popover };
HTMLElement* topmostPopoverAncestor(TopLayerElementType topLayerType);
#if DUMP_NODE_STATISTICS
bool hasNamedNodeMap() const;
#endif
WEBCORE_EXPORT bool hasAttributes() const;
// This variant will not update the potentially invalid attributes. To be used when not interested
// in style attribute or one of the SVG animation attributes.
bool hasAttributesWithoutUpdate() const;
WEBCORE_EXPORT bool hasAttribute(const AtomString& qualifiedName) const;
WEBCORE_EXPORT bool hasAttributeNS(const AtomString& namespaceURI, const AtomString& localName) const;
WEBCORE_EXPORT const AtomString& getAttribute(const AtomString& qualifiedName) const;
WEBCORE_EXPORT const AtomString& getAttributeNS(const AtomString& namespaceURI, const AtomString& localName) const;
AtomString getAttributeForBindings(const AtomString& qualifiedName, ResolveURLs = ResolveURLs::NoExcludingURLsForPrivacy) const;
inline AtomString getAttributeNSForBindings(const AtomString& namespaceURI, const AtomString& localName, ResolveURLs = ResolveURLs::NoExcludingURLsForPrivacy) const;
RefPtr<Element> elementForAttributeInternal(const QualifiedName& attributeName) const;
std::optional<Vector<Ref<Element>>> elementsArrayForAttributeInternal(const QualifiedName& attributeName) const;
WEBCORE_EXPORT ExceptionOr<void> setAttribute(const AtomString& qualifiedName, const AtomString& value);
ExceptionOr<void> setAttribute(const AtomString& qualifiedName, const TrustedTypeOrString& value);
unsigned validateAttributeIndex(unsigned index, const QualifiedName& qname) const;
static ExceptionOr<QualifiedName> parseAttributeName(const AtomString& namespaceURI, const AtomString& qualifiedName);
WEBCORE_EXPORT ExceptionOr<void> setAttributeNS(const AtomString& namespaceURI, const AtomString& qualifiedName, const AtomString& value);
ExceptionOr<void> setAttributeNS(const AtomString& namespaceURI, const AtomString& qualifiedName, const TrustedTypeOrString& value);
ExceptionOr<bool> toggleAttribute(const AtomString& qualifiedName, std::optional<bool> force);
inline const AtomString& getIdAttribute() const;
inline void setIdAttribute(const AtomString&);
inline const AtomString& getNameAttribute() const;
// Call this to get the value of the id attribute for style resolution purposes.
// The value will already be lowercased if the document is in compatibility mode,
// so this function is not suitable for non-style uses.
inline const AtomString& idForStyleResolution() const;
// Internal methods that assume the existence of attribute storage, one should use hasAttributes()
// before calling them.
inline std::span<const Attribute> attributes() const;
inline unsigned attributeCount() const;
inline const Attribute& attributeAt(unsigned index) const;
inline const Attribute* findAttributeByName(const QualifiedName&) const;
inline unsigned findAttributeIndexByName(const QualifiedName&) const;
inline unsigned findAttributeIndexByName(const AtomString&, bool shouldIgnoreAttributeCase) const;
bool checkVisibility(const CheckVisibilityOptions&);
WEBCORE_EXPORT void scrollIntoView(std::optional<std::variant<bool, ScrollIntoViewOptions>>&& arg);
WEBCORE_EXPORT void scrollIntoView(bool alignToTop = true);
WEBCORE_EXPORT void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true);
void scrollBy(const ScrollToOptions&);
void scrollBy(double x, double y);
virtual void scrollTo(const ScrollToOptions&, ScrollClamping = ScrollClamping::Clamped, ScrollSnapPointSelectionMethod = ScrollSnapPointSelectionMethod::Closest, std::optional<FloatSize> originalScrollDelta = std::nullopt);
void scrollTo(double x, double y);
WEBCORE_EXPORT int offsetLeftForBindings();
WEBCORE_EXPORT int offsetLeft();
WEBCORE_EXPORT int offsetTopForBindings();
WEBCORE_EXPORT int offsetTop();
WEBCORE_EXPORT int offsetWidth();
WEBCORE_EXPORT int offsetHeight();
bool mayCauseRepaintInsideViewport(const IntRect* visibleRect = nullptr) const;
// FIXME: Replace uses of offsetParent in the platform with calls
// to the render layer and merge bindingsOffsetParent and offsetParent.
WEBCORE_EXPORT RefPtr<Element> offsetParentForBindings();
inline const Element* rootElement() const;
Element* offsetParent();
WEBCORE_EXPORT int clientLeft();
WEBCORE_EXPORT int clientTop();
WEBCORE_EXPORT int clientWidth();
WEBCORE_EXPORT int clientHeight();
virtual int scrollLeft();
virtual int scrollTop();
virtual void setScrollLeft(int);
virtual void setScrollTop(int);
virtual int scrollWidth();
virtual int scrollHeight();
// This updates layout, and has custom handling for SVG.
WEBCORE_EXPORT IntRect boundsInRootViewSpace();
// This does not update layout, and uses absoluteBoundingBoxRect().
WEBCORE_EXPORT IntRect boundingBoxInRootViewCoordinates() const;
WEBCORE_EXPORT std::optional<std::pair<CheckedPtr<RenderObject>, FloatRect>> boundingAbsoluteRectWithoutLayout() const;
WEBCORE_EXPORT FloatRect boundingClientRect();
WEBCORE_EXPORT Ref<DOMRectList> getClientRects();
Ref<DOMRect> getBoundingClientRect();
// Returns the absolute bounding box translated into screen coordinates.
WEBCORE_EXPORT IntRect screenRect() const;
WEBCORE_EXPORT bool removeAttribute(const AtomString& qualifiedName);
WEBCORE_EXPORT bool removeAttributeNS(const AtomString& namespaceURI, const AtomString& localName);
void removeAttributeForBindings(const AtomString& qualifiedName) { removeAttribute(qualifiedName); }
void removeAttributeNSForBindings(const AtomString& namespaceURI, const AtomString& localName) { removeAttributeNS(namespaceURI, localName); }
Ref<Attr> detachAttribute(unsigned index);
WEBCORE_EXPORT RefPtr<Attr> getAttributeNode(const AtomString& qualifiedName);
WEBCORE_EXPORT RefPtr<Attr> getAttributeNodeNS(const AtomString& namespaceURI, const AtomString& localName);
WEBCORE_EXPORT ExceptionOr<RefPtr<Attr>> setAttributeNode(Attr&);
WEBCORE_EXPORT ExceptionOr<RefPtr<Attr>> setAttributeNodeNS(Attr&);
WEBCORE_EXPORT ExceptionOr<Ref<Attr>> removeAttributeNode(Attr&);
RefPtr<Attr> attrIfExists(const QualifiedName&);
Ref<Attr> ensureAttr(const QualifiedName&);
const Vector<RefPtr<Attr>>& attrNodeList();
const QualifiedName& tagQName() const { return m_tagName; }
#if ENABLE(JIT)
static constexpr ptrdiff_t tagQNameMemoryOffset() { return OBJECT_OFFSETOF(Element, m_tagName); }
#endif
String tagName() const { return nodeName(); }
bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
bool hasTagName(const MathMLQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
inline bool hasTagName(const SVGQualifiedName& tagName) const;
bool hasLocalName(const AtomString& other) const { return m_tagName.localName() == other; }
const AtomString& localName() const final { return m_tagName.localName(); }
const AtomString& prefix() const final { return m_tagName.prefix(); }
const AtomString& namespaceURI() const final { return m_tagName.namespaceURI(); }
const AtomString& localNameLowercase() const { return m_tagName.localNameLowercase(); }
ElementName elementName() const { return m_tagName.nodeName(); }
Namespace nodeNamespace() const { return m_tagName.nodeNamespace(); }
ExceptionOr<void> setPrefix(const AtomString&) final;
String nodeName() const override;
Ref<Element> cloneElementWithChildren(Document&, CustomElementRegistry*);
Ref<Element> cloneElementWithoutChildren(Document&, CustomElementRegistry*);
void normalizeAttributes();
WEBCORE_EXPORT void setBooleanAttribute(const QualifiedName& name, bool);
// For exposing to DOM only.
WEBCORE_EXPORT NamedNodeMap& attributesMap() const;
enum class AttributeModificationReason : uint8_t { Directly, ByCloning, Parser };
// This function is called whenever an attribute is added, changed or removed.
// Do not call this function directly. notifyAttributeChanged() should be used instead
// in order to update state dependent on attribute changes.
virtual void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason = AttributeModificationReason::Directly);
// Only called by the parser immediately after element construction.
void parserSetAttributes(std::span<const Attribute>);
bool isEventHandlerAttribute(const Attribute&) const;
virtual FormListedElement* asFormListedElement();
virtual ValidatedFormListedElement* asValidatedFormListedElement();
virtual bool attributeContainsJavaScriptURL(const Attribute&) const;
#if ENABLE(ATTACHMENT_ELEMENT)
virtual AttachmentAssociatedElement* asAttachmentAssociatedElement();
#endif
// Remove attributes that might introduce scripting from the vector leaving the element unchanged.
void stripScriptingAttributes(Vector<Attribute>&) const;
const ElementData* elementData() const { return m_elementData.get(); }
static constexpr ptrdiff_t elementDataMemoryOffset() { return OBJECT_OFFSETOF(Element, m_elementData); }
inline UniqueElementData& ensureUniqueElementData();
void synchronizeAllAttributes() const;
// Clones attributes only.
void cloneAttributesFromElement(const Element&);
// Clones all attribute-derived data, including subclass specifics (through copyNonAttributeProperties.)
void cloneDataFromElement(const Element&);
virtual void didMoveToNewDocument(Document& oldDocument, Document& newDocument);
bool hasEquivalentAttributes(const Element& other) const;
virtual void copyNonAttributePropertiesFromElement(const Element&) { }
virtual RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&);
virtual bool rendererIsNeeded(const RenderStyle&);
virtual bool isReplaced(const RenderStyle&) const { return false; }
inline ShadowRoot* shadowRoot() const; // Defined in ElementRareData.h
RefPtr<ShadowRoot> shadowRootForBindings(JSC::JSGlobalObject&) const;
RefPtr<Element> resolveReferenceTarget() const;
RefPtr<Element> retargetReferenceTargetForBindings(RefPtr<Element>) const;
enum class CustomElementRegistryKind : bool { Window, Null };
WEBCORE_EXPORT ExceptionOr<ShadowRoot&> attachShadow(const ShadowRootInit&, CustomElementRegistryKind = CustomElementRegistryKind::Window);
ExceptionOr<ShadowRoot&> attachDeclarativeShadow(ShadowRootMode, ShadowRootDelegatesFocus, ShadowRootClonable, ShadowRootSerializable, String referenceTarget, CustomElementRegistryKind);
WEBCORE_EXPORT ShadowRoot* userAgentShadowRoot() const;
RefPtr<ShadowRoot> protectedUserAgentShadowRoot() const;
WEBCORE_EXPORT ShadowRoot& ensureUserAgentShadowRoot();
WEBCORE_EXPORT ShadowRoot& createUserAgentShadowRoot();
void setIsDefinedCustomElement(JSCustomElementInterface&);
void setIsFailedCustomElement();
void setIsFailedOrPrecustomizedCustomElementWithoutClearingReactionQueue();
void clearReactionQueueFromFailedCustomElement();
void setIsCustomElementUpgradeCandidate();
void enqueueToUpgrade(JSCustomElementInterface&);
CustomElementReactionQueue* reactionQueue() const;
CustomElementRegistry* customElementRegistry() const;
CustomElementDefaultARIA& customElementDefaultARIA();
CheckedRef<CustomElementDefaultARIA> checkedCustomElementDefaultARIA();
CustomElementDefaultARIA* customElementDefaultARIAIfExists() const;
bool isInActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); }
bool active() const { return isUserActionElement() && isUserActionElementActive(); }
bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); }
bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }
bool isBeingDragged() const { return isUserActionElement() && isUserActionElementDragged(); }
bool hasFocusVisible() const { return isUserActionElement() && isUserActionElementHasFocusVisible(); }
bool hasFocusWithin() const { return isUserActionElement() && isUserActionElementHasFocusWithin(); };
virtual void setActive(bool = true, Style::InvalidationScope = Style::InvalidationScope::All);
virtual void setHovered(bool = true, Style::InvalidationScope = Style::InvalidationScope::All, HitTestRequest = {});
virtual void setFocus(bool, FocusVisibility = FocusVisibility::Invisible);
void setBeingDragged(bool);
void setHasFocusVisible(bool);
void setHasFocusWithin(bool);
void setHasTentativeFocus(bool);
std::optional<int> tabIndexSetExplicitly() const;
bool shouldBeIgnoredInSequentialFocusNavigation() const { return defaultTabIndex() < 0 && !supportsFocus(); }
bool hasFocusableStyle() const;
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual bool shouldUseInputMethod();
virtual int tabIndexForBindings() const;
WEBCORE_EXPORT void setTabIndexForBindings(int);
// Used by the HTMLElement and SVGElement IDLs.
WEBCORE_EXPORT const AtomString& nonce() const;
WEBCORE_EXPORT void setNonce(const AtomString&);
inline void hideNonce(); // Defined in ElementInlines.h.
ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, NodeVector* addedNodes);
WEBCORE_EXPORT ExceptionOr<Element*> insertAdjacentElement(const String& where, Element& newChild);
WEBCORE_EXPORT ExceptionOr<void> insertAdjacentHTML(const String& where, std::variant<RefPtr<TrustedHTML>, String>&&);
WEBCORE_EXPORT ExceptionOr<void> insertAdjacentText(const String& where, String&& text);
using Node::computedStyle;
const RenderStyle* computedStyle(const std::optional<Style::PseudoElementIdentifier>&) override;
const RenderStyle* computedStyleForEditability();
bool needsStyleInvalidation() const;
// Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
bool styleAffectedByEmpty() const { return hasStyleFlag(NodeStyleFlag::StyleAffectedByEmpty); }
bool descendantsAffectedByPreviousSibling() const { return hasStyleFlag(NodeStyleFlag::DescendantsAffectedByPreviousSibling); }
bool childrenAffectedByFirstChildRules() const { return hasStyleFlag(NodeStyleFlag::ChildrenAffectedByFirstChildRules); }
bool childrenAffectedByLastChildRules() const { return hasStyleFlag(NodeStyleFlag::ChildrenAffectedByLastChildRules); }
bool childrenAffectedByForwardPositionalRules() const { return hasStyleFlag(NodeStyleFlag::ChildrenAffectedByForwardPositionalRules); }
bool descendantsAffectedByForwardPositionalRules() const { return hasStyleFlag(NodeStyleFlag::DescendantsAffectedByForwardPositionalRules); }
bool childrenAffectedByBackwardPositionalRules() const { return hasStyleFlag(NodeStyleFlag::ChildrenAffectedByBackwardPositionalRules); }
bool descendantsAffectedByBackwardPositionalRules() const { return hasStyleFlag(NodeStyleFlag::DescendantsAffectedByBackwardPositionalRules); }
bool affectsNextSiblingElementStyle() const { return hasStyleFlag(NodeStyleFlag::AffectsNextSiblingElementStyle); }
bool styleIsAffectedByPreviousSibling() const { return hasStyleFlag(NodeStyleFlag::StyleIsAffectedByPreviousSibling); }
bool affectedByHasWithPositionalPseudoClass() const { return hasStyleFlag(NodeStyleFlag::AffectedByHasWithPositionalPseudoClass); }
unsigned childIndex() const { return hasRareData() ? rareDataChildIndex() : 0; }
bool hasFlagsSetDuringStylingOfChildren() const;
void setStyleAffectedByEmpty() { setStyleFlag(NodeStyleFlag::StyleAffectedByEmpty); }
void setDescendantsAffectedByPreviousSibling() { setStyleFlag(NodeStyleFlag::DescendantsAffectedByPreviousSibling); }
void setChildrenAffectedByFirstChildRules() { setStyleFlag(NodeStyleFlag::ChildrenAffectedByFirstChildRules); }
void setChildrenAffectedByLastChildRules() { setStyleFlag(NodeStyleFlag::ChildrenAffectedByLastChildRules); }
void setChildrenAffectedByForwardPositionalRules() { setStyleFlag(NodeStyleFlag::ChildrenAffectedByForwardPositionalRules); }
void setDescendantsAffectedByForwardPositionalRules() { setStyleFlag(NodeStyleFlag::DescendantsAffectedByForwardPositionalRules); }
void setChildrenAffectedByBackwardPositionalRules() { setStyleFlag(NodeStyleFlag::ChildrenAffectedByBackwardPositionalRules); }
void setDescendantsAffectedByBackwardPositionalRules() { setStyleFlag(NodeStyleFlag::DescendantsAffectedByBackwardPositionalRules); }
void setAffectsNextSiblingElementStyle() { setStyleFlag(NodeStyleFlag::AffectsNextSiblingElementStyle); }
void setStyleIsAffectedByPreviousSibling() { setStyleFlag(NodeStyleFlag::StyleIsAffectedByPreviousSibling); }
void setAffectedByHasWithPositionalPseudoClass() { setStyleFlag(NodeStyleFlag::AffectedByHasWithPositionalPseudoClass); }
void setChildIndex(unsigned);
const AtomString& effectiveLang() const;
const AtomString& langFromAttribute() const;
Locale& locale() const;
void updateEffectiveLangStateAndPropagateToDescendants();
virtual bool accessKeyAction(bool /*sendToAnyEvent*/) { return false; }
virtual bool isURLAttribute(const Attribute&) const { return false; }
virtual bool attributeContainsURL(const Attribute& attribute) const { return isURLAttribute(attribute); }
String resolveURLStringIfNeeded(const String& urlString, ResolveURLs = ResolveURLs::Yes, const URL& base = URL()) const;
virtual String completeURLsInAttributeValue(const URL& base, const Attribute&, ResolveURLs = ResolveURLs::Yes) const;
virtual Attribute replaceURLsInAttributeValue(const Attribute&, const CSS::SerializationContext&) const;
virtual bool isHTMLContentAttribute(const Attribute&) const { return false; }
WEBCORE_EXPORT URL getURLAttribute(const QualifiedName&) const;
inline URL getURLAttributeForBindings(const QualifiedName&) const;
URL getNonEmptyURLAttribute(const QualifiedName&) const;
virtual const AtomString& imageSourceURL() const;
virtual AtomString target() const { return nullAtom(); }
static RefPtr<Element> findFocusDelegateForTarget(ContainerNode&, FocusTrigger);
RefPtr<Element> findFocusDelegate(FocusTrigger = FocusTrigger::Other);
RefPtr<Element> findAutofocusDelegate(FocusTrigger = FocusTrigger::Other);
static AXTextStateChangeIntent defaultFocusTextStateChangeIntent() { return AXTextStateChangeIntent(AXTextStateChangeTypeSelectionMove, AXTextSelection { AXTextSelectionDirectionDiscontiguous, AXTextSelectionGranularityUnknown, true }); }
virtual void focus(const FocusOptions& = { });
virtual void focusForBindings(FocusOptions&&);
void findTargetAndUpdateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal);
virtual RefPtr<Element> focusAppearanceUpdateTarget();
virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal);
virtual void blur();
virtual void runFocusingStepsForAutofocus();
ExceptionOr<void> setHTMLUnsafe(std::variant<RefPtr<TrustedHTML>, String>&&);
String getHTML(GetHTMLOptions&&) const;
WEBCORE_EXPORT String innerHTML() const;
WEBCORE_EXPORT String outerHTML() const;
WEBCORE_EXPORT ExceptionOr<void> setInnerHTML(std::variant<RefPtr<TrustedHTML>, String>&&);
WEBCORE_EXPORT ExceptionOr<void> setOuterHTML(std::variant<RefPtr<TrustedHTML>, String>&&);
WEBCORE_EXPORT String innerText();
WEBCORE_EXPORT String outerText();
virtual String title() const;
WEBCORE_EXPORT const AtomString& userAgentPart() const;
WEBCORE_EXPORT void setUserAgentPart(const AtomString&);
// Use Document::registerForDocumentActivationCallbacks() to subscribe to these
virtual void prepareForDocumentSuspension() { }
virtual void resumeFromDocumentSuspension() { }
void willBecomeFullscreenElement();
virtual void ancestorWillEnterFullscreen() { }
virtual void didBecomeFullscreenElement() { }
virtual void willStopBeingFullscreenElement() { }
virtual void didStopBeingFullscreenElement() { }
bool isFinishedParsingChildren() const { return isParsingChildrenFinished(); }
// Overriding these functions to make parsing a special case should be avoided if possible
// as that could lead to elements responding differently to the parser vs. other kinds of DOM mutations.
void beginParsingChildren() { clearIsParsingChildrenFinished(); }
virtual void finishParsingChildren();
PseudoElement& ensurePseudoElement(PseudoId);
WEBCORE_EXPORT PseudoElement* beforePseudoElement() const;
WEBCORE_EXPORT PseudoElement* afterPseudoElement() const;
bool childNeedsShadowWalker() const;
void didShadowTreeAwareChildrenChange();
virtual bool matchesValidPseudoClass() const;
virtual bool matchesInvalidPseudoClass() const;
virtual bool matchesUserValidPseudoClass() const;
virtual bool matchesUserInvalidPseudoClass() const;
virtual bool matchesReadWritePseudoClass() const;
virtual bool matchesIndeterminatePseudoClass() const;
virtual bool matchesDefaultPseudoClass() const;
WEBCORE_EXPORT ExceptionOr<bool> matches(const String& selectors);
WEBCORE_EXPORT ExceptionOr<Element*> closest(const String& selectors);
WEBCORE_EXPORT DOMTokenList& classList();
SpaceSplitString partNames() const;
DOMTokenList& part();
DatasetDOMStringMap& dataset();
#if ENABLE(VIDEO)
virtual bool isMediaElement() const { return false; }
#endif
virtual bool isFormListedElement() const { return false; }
virtual bool isValidatedFormListedElement() const { return false; }
virtual bool isMaybeFormAssociatedCustomElement() const { return false; }
virtual bool isSpinButtonElement() const { return false; }
virtual bool isTextFormControlElement() const { return false; }
virtual bool isTextField() const { return false; }
virtual bool isTextPlaceholderElement() const { return false; }
virtual bool isOptionalFormControl() const { return false; }
virtual bool isRequiredFormControl() const { return false; }
virtual bool isInRange() const { return false; }
virtual bool isOutOfRange() const { return false; }
virtual bool isUploadButton() const { return false; }
virtual bool isSliderContainerElement() const { return false; }
virtual bool isSliderThumbElement() const { return false; }
virtual bool isHTMLTablePartElement() const { return false; }
virtual bool isDevolvableWidget() const { return false; }
bool canContainRangeEndPoint() const override;
// Used for disabled form elements; if true, prevents mouse events from being dispatched
// to event listeners, and prevents DOMActivate events from being sent at all.
virtual bool isDisabledFormControl() const { return false; }
virtual bool childShouldCreateRenderer(const Node&) const;
KeyframeEffectStack* keyframeEffectStack(const std::optional<Style::PseudoElementIdentifier>&) const;
KeyframeEffectStack& ensureKeyframeEffectStack(const std::optional<Style::PseudoElementIdentifier>&);
bool hasKeyframeEffects(const std::optional<Style::PseudoElementIdentifier>&) const;
const AnimationCollection* animations(const std::optional<Style::PseudoElementIdentifier>&) const;
bool hasCompletedTransitionForProperty(const std::optional<Style::PseudoElementIdentifier>&, const AnimatableCSSProperty&) const;
bool hasRunningTransitionForProperty(const std::optional<Style::PseudoElementIdentifier>&, const AnimatableCSSProperty&) const;
bool hasRunningTransitions(const std::optional<Style::PseudoElementIdentifier>&) const;
AnimationCollection& ensureAnimations(const std::optional<Style::PseudoElementIdentifier>&);
const AnimatableCSSPropertyToTransitionMap* completedTransitionsByProperty(const std::optional<Style::PseudoElementIdentifier>&) const;
const AnimatableCSSPropertyToTransitionMap* runningTransitionsByProperty(const std::optional<Style::PseudoElementIdentifier>&) const;
AnimatableCSSPropertyToTransitionMap& ensureCompletedTransitionsByProperty(const std::optional<Style::PseudoElementIdentifier>&);
AnimatableCSSPropertyToTransitionMap& ensureRunningTransitionsByProperty(const std::optional<Style::PseudoElementIdentifier>&);
CSSAnimationCollection& animationsCreatedByMarkup(const std::optional<Style::PseudoElementIdentifier>&);
void setAnimationsCreatedByMarkup(const std::optional<Style::PseudoElementIdentifier>&, CSSAnimationCollection&&);
const RenderStyle* lastStyleChangeEventStyle(const std::optional<Style::PseudoElementIdentifier>&) const;
void setLastStyleChangeEventStyle(const std::optional<Style::PseudoElementIdentifier>&, std::unique_ptr<const RenderStyle>&&);
bool hasPropertiesOverridenAfterAnimation(const std::optional<Style::PseudoElementIdentifier>&) const;
void setHasPropertiesOverridenAfterAnimation(const std::optional<Style::PseudoElementIdentifier>&, bool);
void cssAnimationsDidUpdate(const std::optional<Style::PseudoElementIdentifier>&);
void keyframesRuleDidChange(const std::optional<Style::PseudoElementIdentifier>&);
bool hasPendingKeyframesUpdate(const std::optional<Style::PseudoElementIdentifier>&) const;
// FIXME: do we need a counter style didChange here? (rdar://103018993).
bool isLink() const { return hasStateFlag(StateFlag::IsLink); }
void setIsLink(bool flag);
bool isInTopLayer() const { return hasEventTargetFlag(EventTargetFlag::IsInTopLayer); }
void addToTopLayer();
void removeFromTopLayer();
#if ENABLE(FULLSCREEN_API)
bool hasFullscreenFlag() const { return hasElementStateFlag(ElementStateFlag::IsFullscreen); }
void setFullscreenFlag(bool);
WEBCORE_EXPORT void webkitRequestFullscreen();
virtual void requestFullscreen(FullscreenOptions&&, RefPtr<DeferredPromise>&&);
#endif
PopoverData* popoverData() const;
PopoverData& ensurePopoverData();
void clearPopoverData();
bool isPopoverShowing() const;
virtual bool isValidCommandType(const CommandType) { return false; }
virtual bool handleCommandInternal(const HTMLButtonElement&, const CommandType&) { return false; }
ExceptionOr<void> setPointerCapture(int32_t);
ExceptionOr<void> releasePointerCapture(int32_t);
bool hasPointerCapture(int32_t);
#if ENABLE(POINTER_LOCK)
JSC::JSValue requestPointerLock(JSC::JSGlobalObject& lexicalGlobalObject, PointerLockOptions&&);
WEBCORE_EXPORT void requestPointerLock();
#endif
OptionSet<VisibilityAdjustment> visibilityAdjustment() const;
void setVisibilityAdjustment(OptionSet<VisibilityAdjustment>);
bool isInVisibilityAdjustmentSubtree() const;
bool isSpellCheckingEnabled() const;
WEBCORE_EXPORT bool isWritingSuggestionsEnabled() const;
inline bool hasID() const;
inline bool hasClass() const;
inline bool hasName() const;
inline const SpaceSplitString& classNames() const;
inline bool hasClassName(const AtomString& className) const;
ScrollPosition savedLayerScrollPosition() const;
void setSavedLayerScrollPosition(const ScrollPosition&);
enum class EventIsDefaultPrevented : bool { No, Yes };
enum class EventIsDispatched : bool { No, Yes };
using DispatchMouseEventResult = std::pair<EventIsDispatched, EventIsDefaultPrevented>;
DispatchMouseEventResult dispatchMouseEvent(const PlatformMouseEvent& platformEvent, const AtomString& eventType, int clickCount = 0, Element* relatedTarget = nullptr, IsSyntheticClick = IsSyntheticClick::No);
bool dispatchWheelEvent(const PlatformWheelEvent&, OptionSet<EventHandling>&, EventIsCancelable = EventIsCancelable::Yes);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
bool dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
// FIXME: Consider changing signature to accept Element* because all callers perform copyRef().
void dispatchFocusInEventIfNeeded(RefPtr<Element>&& oldFocusedElement);
void dispatchFocusOutEventIfNeeded(RefPtr<Element>&& newFocusedElement);
virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, const FocusOptions&);
virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement);
void dispatchWebKitImageReadyEventForTesting();
WEBCORE_EXPORT bool dispatchMouseForceWillBegin();
void enqueueSecurityPolicyViolationEvent(SecurityPolicyViolationEventInit&&);
virtual void willRecalcStyle(Style::Change);
virtual void didRecalcStyle(Style::Change);
virtual void willResetComputedStyle();
virtual void willAttachRenderers();
virtual void didAttachRenderers();
virtual void willDetachRenderers();
virtual void didDetachRenderers();
virtual std::optional<Style::ResolvedStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle);
LayoutRect absoluteEventHandlerBounds(bool& includesFixedPositionElements) override;
const RenderStyle* existingComputedStyle() const;
WEBCORE_EXPORT const RenderStyle* renderOrDisplayContentsStyle() const;
WEBCORE_EXPORT const RenderStyle* renderOrDisplayContentsStyle(const std::optional<Style::PseudoElementIdentifier>&) const;
void clearBeforePseudoElement();
void clearAfterPseudoElement();
void resetComputedStyle();
void resetStyleRelations();
void resetChildStyleRelations();
void resetAllDescendantStyleRelations();
void clearHoverAndActiveStatusBeforeDetachingRenderer();
WEBCORE_EXPORT URL absoluteLinkURL() const;
#if ENABLE(TOUCH_EVENTS)
bool allowsDoubleTapGesture() const override;
#endif
Style::Resolver& styleResolver();
Style::ResolvedStyle resolveStyle(const Style::ResolutionContext&);
// Invalidates the style of a single element. Style is resolved lazily.
// Descendant elements are resolved as needed, for example if an inherited property changes.
// This should be called whenever an element changes in a manner that can affect its style.
void invalidateStyle();
// As above but also call RenderElement::setStyle with StyleDifference::RecompositeLayer flag for
// the element even when the style doesn't change. This is mostly needed by the animation code.
WEBCORE_EXPORT void invalidateStyleAndLayerComposition();
// Invalidate the element and all its descendants. This is used when there is some sort of change
// in the tree that may affect the style of any of the descendants and we don't know how to optimize
// the case to limit the scope. This is expensive and should be avoided.
void invalidateStyleForSubtree();
// Invalidates renderers for the element and all its descendants causing them to be torn down
// and rebuild during style resolution. Style is also recomputed. This is used in code dealing with
// custom (not style based) renderers. This is expensive and should be avoided.
// Elements newly added to the tree are also in this state.
void invalidateStyleAndRenderersForSubtree();
void invalidateRenderer();
void invalidateStyleInternal();
void invalidateStyleForAnimation();
void invalidateStyleForSubtreeInternal();
void invalidateForQueryContainerSizeChange();
void invalidateForAnchorRectChange();
void invalidateForResumingQueryContainerResolution();
void invalidateForResumingAnchorPositionedElementResolution();
bool needsUpdateQueryContainerDependentStyle() const;
void clearNeedsUpdateQueryContainerDependentStyle();
void invalidateEventListenerRegions();
bool hasDisplayContents() const;
bool hasDisplayNone() const;
void storeDisplayContentsOrNoneStyle(std::unique_ptr<RenderStyle>);
void clearDisplayContentsOrNoneStyle();
using ContainerNode::setAttributeEventListener;
void setAttributeEventListener(const AtomString& eventType, const QualifiedName& attributeName, const AtomString& value);
virtual IntersectionObserverData& ensureIntersectionObserverData();
virtual IntersectionObserverData* intersectionObserverDataIfExists();
ResizeObserverData& ensureResizeObserverData();
ResizeObserverData* resizeObserverDataIfExists();
std::optional<LayoutUnit> lastRememberedLogicalWidth() const;
std::optional<LayoutUnit> lastRememberedLogicalHeight() const;
void setLastRememberedLogicalWidth(LayoutUnit);
void clearLastRememberedLogicalWidth();
void setLastRememberedLogicalHeight(LayoutUnit);
void clearLastRememberedLogicalHeight();
RefPtr<Element> findAnchorElementForLink(String& outAnchorName);
ExceptionOr<Ref<WebAnimation>> animate(JSC::JSGlobalObject&, JSC::Strong<JSC::JSObject>&&, std::optional<std::variant<double, KeyframeAnimationOptions>>&&);
Vector<RefPtr<WebAnimation>> getAnimations(std::optional<GetAnimationsOptions>);
WEBCORE_EXPORT ElementIdentifier identifier() const;
WEBCORE_EXPORT static Element* fromIdentifier(ElementIdentifier);
String description() const override;
String debugDescription() const override;
bool hasDuplicateAttribute() const;
void setHasDuplicateAttribute(bool);
virtual void updateUserAgentShadowTree() { }
StylePropertyMapReadOnly* computedStyleMap();
ExplicitlySetAttrElementsMap& explicitlySetAttrElementsMap();
ExplicitlySetAttrElementsMap* explicitlySetAttrElementsMapIfExists() const;
bool isRelevantToUser() const;
std::optional<OptionSet<ContentRelevancy>> contentRelevancy() const;
void setContentRelevancy(OptionSet<ContentRelevancy>);
bool hasCustomState(const AtomString& state) const;
CustomStateSet& ensureCustomStateSet();
bool hasValidTextDirectionState() const;
bool hasAutoTextDirectionState() const;
void updateEffectiveTextDirection();
void updateEffectiveTextDirectionIfNeeded();
AtomString viewTransitionCapturedName(const std::optional<Style::PseudoElementIdentifier>&) const;
void setViewTransitionCapturedName(const std::optional<Style::PseudoElementIdentifier>&, AtomString);
Ref<Calculation::RandomKeyMap> randomKeyMap(const std::optional<Style::PseudoElementIdentifier>&) const;
bool hasRandomKeyMap() const;
protected:
Element(const QualifiedName&, Document&, OptionSet<TypeFlag>);
InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override;
void removedFromAncestor(RemovalType, ContainerNode&) override;
void childrenChanged(const ChildChange&) override;
void removeAllEventListeners() override;
void setTabIndexExplicitly(std::optional<int>);
void classAttributeChanged(const AtomString& newClassString, AttributeModificationReason);
void partAttributeChanged(const AtomString& newValue);
void addShadowRoot(Ref<ShadowRoot>&&);
ExceptionOr<void> replaceChildrenWithMarkup(const String&, OptionSet<ParserContentPolicy>);
static ExceptionOr<void> mergeWithNextTextNode(Text&);
StylePropertyMap* attributeStyleMap();
void setAttributeStyleMap(Ref<StylePropertyMap>&&);
FormAssociatedCustomElement& formAssociatedCustomElementUnsafe() const;
void ensureFormAssociatedCustomElement();
void disconnectFromIntersectionObservers();
static AtomString makeTargetBlankIfHasDanglingMarkup(const AtomString& target);
private:
LocalFrame* documentFrameWithNonNullView() const;
void hideNonceSlow();
bool isTextNode() const;
bool isUserActionElementInActiveChain() const;
bool isUserActionElementActive() const;
bool isUserActionElementFocused() const;
bool isUserActionElementHovered() const;
bool isUserActionElementDragged() const;
bool isUserActionElementHasFocusVisible() const;
bool isUserActionElementHasFocusWithin() const;
bool isNonceable() const;
virtual void didAddUserAgentShadowRoot(ShadowRoot&) { }
void didAddAttribute(const QualifiedName&, const AtomString&);
void willModifyAttribute(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue);
void didModifyAttribute(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue);
void didRemoveAttribute(const QualifiedName&, const AtomString& oldValue);
void synchronizeAttribute(const QualifiedName&) const;
void synchronizeAttribute(const AtomString& localName) const;
inline const Attribute* getAttributeInternal(const QualifiedName&) const;
inline const Attribute* getAttributeInternal(const AtomString& qualifiedName) const;
void updateName(const AtomString& oldName, const AtomString& newName);
void updateNameForTreeScope(TreeScope&, const AtomString& oldName, const AtomString& newName);
void updateNameForDocument(HTMLDocument&, const AtomString& oldName, const AtomString& newName);
enum class NotifyObservers : bool { No, Yes };
void updateId(const AtomString& oldId, const AtomString& newId, NotifyObservers = NotifyObservers::Yes);
void updateIdForTreeScope(TreeScope&, const AtomString& oldId, const AtomString& newId, NotifyObservers = NotifyObservers::Yes);
enum class HTMLDocumentNamedItemMapsUpdatingCondition : bool { Always, UpdateOnlyIfDiffersFromNameAttribute };
void updateIdForDocument(HTMLDocument&, const AtomString& oldId, const AtomString& newId, HTMLDocumentNamedItemMapsUpdatingCondition);
ExceptionOr<Node*> insertAdjacent(const String& where, Ref<Node>&& newChild);
bool childTypeAllowed(NodeType) const final;
void notifyAttributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason = AttributeModificationReason::Directly);
enum class InSynchronizationOfLazyAttribute : bool { No, Yes };
void setAttributeInternal(unsigned index, const QualifiedName&, const AtomString& value, InSynchronizationOfLazyAttribute);
void addAttributeInternal(const QualifiedName&, const AtomString& value, InSynchronizationOfLazyAttribute);
void removeAttributeInternal(unsigned index, InSynchronizationOfLazyAttribute);
void setSavedLayerScrollPositionSlow(const ScrollPosition&);
void clearBeforePseudoElementSlow();
void clearAfterPseudoElementSlow();
LayoutRect absoluteEventBounds(bool& boundsIncludeAllDescendantElements, bool& includesFixedPositionElements);
LayoutRect absoluteEventBoundsOfElementAndDescendants(bool& includesFixedPositionElements);
void disconnectFromIntersectionObserversSlow(IntersectionObserverData&);
void disconnectFromResizeObservers();
void disconnectFromResizeObserversSlow(ResizeObserverData&);
// The cloneNode function is private so that non-virtual cloneElementWith/WithoutChildren are used instead.
Ref<Node> cloneNodeInternal(Document&, CloningOperation, CustomElementRegistry*) override;
void cloneShadowTreeIfPossible(Element& newHost, CustomElementRegistry*);
virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&, CustomElementRegistry*);
inline void removeShadowRoot(); // Defined in ElementRareData.h.
void removeShadowRootSlow(ShadowRoot&);
enum class ResolveComputedStyleMode : uint8_t { Normal, RenderedOnly, Editability };
const RenderStyle* resolveComputedStyle(ResolveComputedStyleMode = ResolveComputedStyleMode::Normal);
const RenderStyle& resolvePseudoElementStyle(const Style::PseudoElementIdentifier&);
unsigned rareDataChildIndex() const;
void createUniqueElementData();
inline ElementRareData* elementRareData() const;
ElementRareData& ensureElementRareData();
ElementAnimationRareData* animationRareData(const std::optional<Style::PseudoElementIdentifier>&) const;
ElementAnimationRareData& ensureAnimationRareData(const std::optional<Style::PseudoElementIdentifier>&);
virtual int defaultTabIndex() const;
void detachAllAttrNodesFromElement();
void detachAttrNodeFromElementWithValue(Attr*, const AtomString& value);
// Anyone thinking of using this should call document instead of ownerDocument.
void ownerDocument() const = delete;
void attachAttributeNodeIfNeeded(Attr&);
#if ASSERT_ENABLED
WEBCORE_EXPORT bool fastAttributeLookupAllowed(const QualifiedName&) const;
#endif
void dirAttributeChanged(const AtomString& newValue);
bool hasEffectiveLangState() const;
void updateEffectiveLangState();
void updateEffectiveLangStateFromParent();
void setEffectiveLangStateOnOldDocumentElement();
void clearEffectiveLangStateOnNewDocumentElement();
bool hasLangAttr() const { return hasEventTargetFlag(EventTargetFlag::HasLangAttr); }
void setHasLangAttr(bool has) { setEventTargetFlag(EventTargetFlag::HasLangAttr, has); }
bool hasXMLLangAttr() const { return hasEventTargetFlag(EventTargetFlag::HasXMLLangAttr); }
void setHasXMLLangAttr(bool has) { setEventTargetFlag(EventTargetFlag::HasXMLLangAttr, has); }
bool effectiveLangKnownToMatchDocumentElement() const { return hasStateFlag(StateFlag::EffectiveLangKnownToMatchDocumentElement); }
void setEffectiveLangKnownToMatchDocumentElement(bool matches) { setStateFlag(StateFlag::EffectiveLangKnownToMatchDocumentElement, matches); }
bool hasLanguageAttribute() const { return hasLangAttr() || hasXMLLangAttr(); }
bool hasLangAttrKnownToMatchDocumentElement() const { return hasLanguageAttribute() && effectiveLangKnownToMatchDocumentElement(); }
bool hasEverHadSmoothScroll() const { return hasElementStateFlag(ElementStateFlag::EverHadSmoothScroll); }
void setHasEverHadSmoothScroll(bool value) { return setElementStateFlag(ElementStateFlag::EverHadSmoothScroll, value); }
void parentOrShadowHostNode() const = delete; // Call parentNode() instead.
QualifiedName m_tagName;
RefPtr<ElementData> m_elementData;
};
inline void Element::setSavedLayerScrollPosition(const ScrollPosition& position)
{
if (position.isZero() && !hasRareData())
return;
setSavedLayerScrollPositionSlow(position);
}
inline void Element::clearBeforePseudoElement()
{
if (hasRareData())
clearBeforePseudoElementSlow();
}
inline void Element::clearAfterPseudoElement()
{
if (hasRareData())
clearAfterPseudoElementSlow();
}
inline void Element::disconnectFromIntersectionObservers()
{
auto* observerData = intersectionObserverDataIfExists();
if (LIKELY(!observerData))
return;
disconnectFromIntersectionObserversSlow(*observerData);
}
inline void Element::disconnectFromResizeObservers()
{
auto* observerData = resizeObserverDataIfExists();
if (LIKELY(!observerData))
return;
disconnectFromResizeObserversSlow(*observerData);
}
void invalidateForSiblingCombinators(Element* sibling);
inline bool isInTopLayerOrBackdrop(const RenderStyle&, const Element*);
WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ContentRelevancy);
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Element)
static bool isType(const WebCore::Node& node) { return node.isElementNode(); }
static bool isType(const WebCore::EventTarget& target)
{
auto* node = dynamicDowncast<WebCore::Node>(target);
return node && isType(*node);
}
SPECIALIZE_TYPE_TRAITS_END()
|