Skip to content

Commit d493cd2

Browse files
committed
Having an iframe as a descendent node shouldn't require ElementRareData
https://bugs.webkit.org/show_bug.cgi?id=216264 Reviewed by Darin Adler. Store the number of connected frames in the descendent nodes directly in Node using CompactUniquePtrTuple in the same space as where we store the NodeRareData pointer. This avoids creating ElementRareData on every ancestor element and shadow host / document of an iframe. Also moved TabIndexState there to simply NodeFlags, and created CustomElementState to replace the existing flags in NodeFlags to match the latest terminology used in the specification: https://dom.spec.whatwg.org/#concept-element-custom-element-state CustomElementState has four states: "uncustomized" (default; builtin elements), "undefined" (i.e. element has a valid custom element but it hasn't been defined or upgraded yet), "custom" (a valid custom element instance), and "failed" (upgrading has resulted in an error). Before this patch, "uncustomized" meant that neither IsCustomElement nor IsEditingTextOrUndefinedCustomElementFlag is set, "undefined" had IsCustomElement and IsEditingTextOrUndefinedCustomElementFlag set, and "custom" had IsCustomElement set but IsEditingTextOrUndefinedCustomElementFlag unset whereas "failed" had the opposite. No new tests since there should be no observable behavioral change. * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild): Mask out the bits stored in the pointer in the 64-bit architecture. In the 32-bit architecture, the pointer is the first component without any extra bits stored in it. * dom/Element.cpp: (WebCore::Node::setTabIndexState): Moved from Node.h. Updated to use the newly introduced bitfields. (WebCore::Node::setCustomElementState): Added. (WebCore::Element::setIsDefinedCustomElement): Now updates CustomElementState in the newly added bitfields. (WebCore::Element::setIsFailedCustomElementWithoutClearingReactionQueue): Ditto. (WebCore::Element::setIsCustomElementUpgradeCandidate): Ditto. * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData): Moved m_unusualTabIndex and m_childIndex to NodeRareData for better packing. * dom/Node.cpp: (WebCore::Node::materializeRareData): (WebCore::Node::clearRareData): (WebCore::Node::connectedSubframeCount const): Moved to the header file. (WebCore::Node::incrementConnectedSubframeCount): Now updates the newly added bitfields. (WebCore::Node::decrementConnectedSubframeCount): Ditto. * dom/Node.h: (WebCore::Node::isUndefinedCustomElement const): Now uses CustomElementState in the newly added bitfields. (WebCore::Node::isCustomElementUpgradeCandidate const): Ditto. (WebCore::Node::isDefinedCustomElement const): Ditto. (WebCore::Node::isFailedCustomElement const): Ditto. (WebCore::Node::isEditingText const): (WebCore::Node::connectedSubframeCount const): Moved here from cpp file. (WebCore::Node::rareDataMemoryOffset): (WebCore::Node::rareDataPointerMask): Added. (WebCore::Node::CustomElementState): Added. (WebCore::Node::RareDataBitFields): Added. (WebCore::Node::rareDataBitfields const): Added. (WebCore::Node::setRareDataBitfields): Added. (WebCore::Node::tabIndexState const): Updated to use rareDataBitfields. (WebCore::Node::setTabIndexState): Moved to Element.cpp. (WebCore::Node::customElementState const): Added. (WebCore::Node::hasRareData const): (WebCore::Node::rareData const): * dom/NodeRareData.cpp: * dom/NodeRareData.h: (WebCore::NodeRareData::UseType): Removed ConnectedFrameCount. (WebCore::NodeRareData::NodeRareData): (WebCore::NodeRareData::useTypes const): (WebCore::NodeRareData::connectedSubframeCount const): Deleted. (WebCore::NodeRareData::incrementConnectedSubframeCount): Deleted. (WebCore::NodeRareData::decrementConnectedSubframeCount): Deleted. (WebCore::NodeRareData): Moved m_unusualTabIndex and m_childIndex here for better packing in 64-bit architecture. Canonical link: https://commits.webkit.org/229133@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 661dbda commit d493cd2

9 files changed

Lines changed: 177 additions & 83 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,74 @@
1+
2020-09-08 Ryosuke Niwa <rniwa@webkit.org>
2+
3+
Having an iframe as a descendent node shouldn't require ElementRareData
4+
https://bugs.webkit.org/show_bug.cgi?id=216264
5+
6+
Reviewed by Darin Adler.
7+
8+
Store the number of connected frames in the descendent nodes directly in Node using CompactUniquePtrTuple
9+
in the same space as where we store the NodeRareData pointer. This avoids creating ElementRareData on every
10+
ancestor element and shadow host / document of an iframe.
11+
12+
Also moved TabIndexState there to simply NodeFlags, and created CustomElementState to replace the existing
13+
flags in NodeFlags to match the latest terminology used in the specification:
14+
https://dom.spec.whatwg.org/#concept-element-custom-element-state
15+
16+
CustomElementState has four states: "uncustomized" (default; builtin elements), "undefined" (i.e. element has
17+
a valid custom element but it hasn't been defined or upgraded yet), "custom" (a valid custom element instance),
18+
and "failed" (upgrading has resulted in an error). Before this patch, "uncustomized" meant that neither
19+
IsCustomElement nor IsEditingTextOrUndefinedCustomElementFlag is set, "undefined" had IsCustomElement
20+
and IsEditingTextOrUndefinedCustomElementFlag set, and "custom" had IsCustomElement set but
21+
IsEditingTextOrUndefinedCustomElementFlag unset whereas "failed" had the opposite.
22+
23+
No new tests since there should be no observable behavioral change.
24+
25+
* cssjit/SelectorCompiler.cpp:
26+
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild): Mask out the bits stored in
27+
the pointer in the 64-bit architecture. In the 32-bit architecture, the pointer is the first component
28+
without any extra bits stored in it.
29+
* dom/Element.cpp:
30+
(WebCore::Node::setTabIndexState): Moved from Node.h. Updated to use the newly introduced bitfields.
31+
(WebCore::Node::setCustomElementState): Added.
32+
(WebCore::Element::setIsDefinedCustomElement): Now updates CustomElementState in the newly added bitfields.
33+
(WebCore::Element::setIsFailedCustomElementWithoutClearingReactionQueue): Ditto.
34+
(WebCore::Element::setIsCustomElementUpgradeCandidate): Ditto.
35+
* dom/ElementRareData.cpp:
36+
* dom/ElementRareData.h:
37+
(WebCore::ElementRareData): Moved m_unusualTabIndex and m_childIndex to NodeRareData for better packing.
38+
* dom/Node.cpp:
39+
(WebCore::Node::materializeRareData):
40+
(WebCore::Node::clearRareData):
41+
(WebCore::Node::connectedSubframeCount const): Moved to the header file.
42+
(WebCore::Node::incrementConnectedSubframeCount): Now updates the newly added bitfields.
43+
(WebCore::Node::decrementConnectedSubframeCount): Ditto.
44+
* dom/Node.h:
45+
(WebCore::Node::isUndefinedCustomElement const): Now uses CustomElementState in the newly added bitfields.
46+
(WebCore::Node::isCustomElementUpgradeCandidate const): Ditto.
47+
(WebCore::Node::isDefinedCustomElement const): Ditto.
48+
(WebCore::Node::isFailedCustomElement const): Ditto.
49+
(WebCore::Node::isEditingText const):
50+
(WebCore::Node::connectedSubframeCount const): Moved here from cpp file.
51+
(WebCore::Node::rareDataMemoryOffset):
52+
(WebCore::Node::rareDataPointerMask): Added.
53+
(WebCore::Node::CustomElementState): Added.
54+
(WebCore::Node::RareDataBitFields): Added.
55+
(WebCore::Node::rareDataBitfields const): Added.
56+
(WebCore::Node::setRareDataBitfields): Added.
57+
(WebCore::Node::tabIndexState const): Updated to use rareDataBitfields.
58+
(WebCore::Node::setTabIndexState): Moved to Element.cpp.
59+
(WebCore::Node::customElementState const): Added.
60+
(WebCore::Node::hasRareData const):
61+
(WebCore::Node::rareData const):
62+
* dom/NodeRareData.cpp:
63+
* dom/NodeRareData.h:
64+
(WebCore::NodeRareData::UseType): Removed ConnectedFrameCount.
65+
(WebCore::NodeRareData::NodeRareData):
66+
(WebCore::NodeRareData::useTypes const):
67+
(WebCore::NodeRareData::connectedSubframeCount const): Deleted.
68+
(WebCore::NodeRareData::incrementConnectedSubframeCount): Deleted.
69+
(WebCore::NodeRareData::decrementConnectedSubframeCount): Deleted.
70+
(WebCore::NodeRareData): Moved m_unusualTabIndex and m_childIndex here for better packing in 64-bit architecture.
71+
172
2020-09-08 Tim Horton <timothy_horton@apple.com>
273

374
WebCore UnifiedSource81 builds for upwards of 10 minutes

Source/WebCore/cssjit/SelectorCompiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,6 +3582,10 @@ void SelectorCodeGenerator::generateElementIsNthChild(Assembler::JumpList& failu
35823582
LocalRegister elementRareData(m_registerAllocator);
35833583
m_assembler.loadPtr(Assembler::Address(previousSibling, Node::rareDataMemoryOffset()), elementRareData);
35843584

3585+
LocalRegister rareDataPointerMask(m_registerAllocator);
3586+
m_assembler.move(Assembler::TrustedImmPtr(Node::rareDataPointerMask()), rareDataPointerMask);
3587+
m_assembler.andPtr(rareDataPointerMask, elementRareData);
3588+
35853589
noCachedChildIndexCases.append(m_assembler.branchTestPtr(Assembler::Zero, elementRareData));
35863590
{
35873591
LocalRegister cachedChildIndex(m_registerAllocator);

Source/WebCore/dom/Element.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ inline ElementRareData& Element::ensureElementRareData()
241241
return static_cast<ElementRareData&>(ensureRareData());
242242
}
243243

244+
inline void Node::setTabIndexState(TabIndexState state)
245+
{
246+
auto bitfields = rareDataBitfields();
247+
bitfields.tabIndexState = static_cast<uint16_t>(state);
248+
setRareDataBitfields(bitfields);
249+
}
250+
244251
void Element::setTabIndexExplicitly(Optional<int> tabIndex)
245252
{
246253
if (!tabIndex) {
@@ -2422,10 +2429,16 @@ ShadowRoot& Element::ensureUserAgentShadowRoot()
24222429
return shadow;
24232430
}
24242431

2432+
inline void Node::setCustomElementState(CustomElementState state)
2433+
{
2434+
auto bitfields = rareDataBitfields();
2435+
bitfields.customElementState = static_cast<uint16_t>(state);
2436+
setRareDataBitfields(bitfields);
2437+
}
2438+
24252439
void Element::setIsDefinedCustomElement(JSCustomElementInterface& elementInterface)
24262440
{
2427-
clearFlag(IsEditingTextOrUndefinedCustomElementFlag);
2428-
setFlag(IsCustomElement);
2441+
setCustomElementState(CustomElementState::Custom);
24292442
auto& data = ensureElementRareData();
24302443
if (!data.customElementReactionQueue())
24312444
data.setCustomElementReactionQueue(makeUnique<CustomElementReactionQueue>(elementInterface));
@@ -2442,8 +2455,8 @@ void Element::setIsFailedCustomElement()
24422455
void Element::setIsFailedCustomElementWithoutClearingReactionQueue()
24432456
{
24442457
ASSERT(isUndefinedCustomElement());
2445-
ASSERT(getFlag(IsEditingTextOrUndefinedCustomElementFlag));
2446-
clearFlag(IsCustomElement);
2458+
ASSERT(customElementState() == CustomElementState::Undefined);
2459+
setCustomElementState(CustomElementState::Failed);
24472460
InspectorInstrumentation::didChangeCustomElementState(*this);
24482461
}
24492462

@@ -2459,9 +2472,8 @@ void Element::clearReactionQueueFromFailedCustomElement()
24592472

24602473
void Element::setIsCustomElementUpgradeCandidate()
24612474
{
2462-
ASSERT(!getFlag(IsCustomElement));
2463-
setFlag(IsCustomElement);
2464-
setFlag(IsEditingTextOrUndefinedCustomElementFlag);
2475+
ASSERT(customElementState() == CustomElementState::Uncustomized);
2476+
setCustomElementState(CustomElementState::Undefined);
24652477
InspectorInstrumentation::didChangeCustomElementState(*this);
24662478
}
24672479

Source/WebCore/dom/ElementRareData.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
namespace WebCore {
3535

3636
struct SameSizeAsElementRareData : NodeRareData {
37-
int tabIndex;
38-
unsigned short childIndex;
3937
LayoutSize sizeForResizing;
4038
IntPoint savedLayerScrollPosition;
4139
void* pointers[11];

Source/WebCore/dom/ElementRareData.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ class ElementRareData : public NodeRareData {
158158
#endif
159159

160160
private:
161-
int m_unusualTabIndex { 0 };
162-
unsigned short m_childIndex { 0 };
163-
164161
LayoutSize m_minimumSizeForResizing;
165162
IntPoint m_savedLayerScrollPosition;
166163
std::unique_ptr<RenderStyle> m_computedStyle;

Source/WebCore/dom/Node.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ void Node::willBeDeletedFrom(Document& document)
413413
void Node::materializeRareData()
414414
{
415415
if (is<Element>(*this))
416-
m_rareData = std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new ElementRareData);
416+
m_rareDataWithBitfields.setPointer(std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new ElementRareData));
417417
else
418-
m_rareData = std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new NodeRareData);
418+
m_rareDataWithBitfields.setPointer(std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new NodeRareData));
419419
}
420420

421421
inline void Node::NodeRareDataDeleter::operator()(NodeRareData* rareData) const
@@ -431,7 +431,7 @@ void Node::clearRareData()
431431
ASSERT(hasRareData());
432432
ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegistry()->isEmpty());
433433

434-
m_rareData = nullptr;
434+
m_rareDataWithBitfields.setPointer(nullptr);
435435
}
436436

437437
bool Node::isNode() const
@@ -2573,23 +2573,24 @@ void Node::removedLastRef()
25732573
delete this;
25742574
}
25752575

2576-
unsigned Node::connectedSubframeCount() const
2577-
{
2578-
return hasRareData() ? rareData()->connectedSubframeCount() : 0;
2579-
}
2580-
25812576
void Node::incrementConnectedSubframeCount(unsigned amount)
25822577
{
2578+
static_assert(RareDataBitFields { Page::maxNumberOfFrames, 0, 0 }.connectedSubframeCount == Page::maxNumberOfFrames, "connectedSubframeCount must fit Page::maxNumberOfFrames");
2579+
25832580
ASSERT(isContainerNode());
2584-
ensureRareData().incrementConnectedSubframeCount(amount);
2581+
auto bitfields = rareDataBitfields();
2582+
bitfields.connectedSubframeCount += amount;
2583+
RELEASE_ASSERT(bitfields.connectedSubframeCount == rareDataBitfields().connectedSubframeCount + amount);
2584+
setRareDataBitfields(bitfields);
25852585
}
25862586

25872587
void Node::decrementConnectedSubframeCount(unsigned amount)
25882588
{
2589-
ASSERT(rareData());
2590-
if (!hasRareData())
2591-
return; // Defend against type confusion when the above assertion fails. See webkit.org/b/200300.
2592-
rareData()->decrementConnectedSubframeCount(amount);
2589+
ASSERT(isContainerNode());
2590+
auto bitfields = rareDataBitfields();
2591+
RELEASE_ASSERT(amount <= bitfields.connectedSubframeCount);
2592+
bitfields.connectedSubframeCount -= amount;
2593+
setRareDataBitfields(bitfields);
25932594
}
25942595

25952596
void Node::updateAncestorConnectedSubframeCountForRemoval() const

Source/WebCore/dom/Node.h

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "StyleValidity.h"
3333
#include "TreeScope.h"
3434
#include <wtf/CompactPointerTuple.h>
35+
#include <wtf/CompactUniquePtrTuple.h>
3536
#include <wtf/Forward.h>
3637
#include <wtf/IsoMalloc.h>
3738
#include <wtf/ListHashSet.h>
@@ -229,10 +230,10 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
229230
HTMLSlotElement* assignedSlot() const;
230231
HTMLSlotElement* assignedSlotForBindings() const;
231232

232-
bool isUndefinedCustomElement() const { return isElementNode() && getFlag(IsEditingTextOrUndefinedCustomElementFlag); }
233-
bool isCustomElementUpgradeCandidate() const { return getFlag(IsCustomElement) && getFlag(IsEditingTextOrUndefinedCustomElementFlag); }
234-
bool isDefinedCustomElement() const { return getFlag(IsCustomElement) && !getFlag(IsEditingTextOrUndefinedCustomElementFlag); }
235-
bool isFailedCustomElement() const { return isElementNode() && !getFlag(IsCustomElement) && getFlag(IsEditingTextOrUndefinedCustomElementFlag); }
233+
bool isUndefinedCustomElement() const { return customElementState() == CustomElementState::Undefined || customElementState() == CustomElementState::Failed; }
234+
bool isCustomElementUpgradeCandidate() const { return customElementState() == CustomElementState::Undefined; }
235+
bool isDefinedCustomElement() const { return customElementState() == CustomElementState::Custom; }
236+
bool isFailedCustomElement() const { return customElementState() == CustomElementState::Failed; }
236237

237238
// Returns null, a child of ShadowRoot, or a legacy shadow root.
238239
Node* nonBoundaryShadowTreeRootNode();
@@ -296,7 +297,7 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
296297
Style::Validity styleValidity() const { return styleBitfields().styleValidity(); }
297298
bool styleResolutionShouldRecompositeLayer() const { return hasStyleFlag(NodeStyleFlag::StyleResolutionShouldRecompositeLayer); }
298299
bool childNeedsStyleRecalc() const { return hasStyleFlag(NodeStyleFlag::DescendantNeedsStyleResolution); }
299-
bool isEditingText() const { return getFlag(IsTextFlag) && getFlag(IsEditingTextOrUndefinedCustomElementFlag); }
300+
bool isEditingText() const { return getFlag(IsTextFlag) && getFlag(IsEditingText); }
300301

301302
void setChildNeedsStyleRecalc() { setStyleFlag(NodeStyleFlag::DescendantNeedsStyleResolution); }
302303
void clearChildNeedsStyleRecalc();
@@ -491,15 +492,20 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
491492
void unregisterTransientMutationObserver(MutationObserverRegistration&);
492493
void notifyMutationObserversNodeWillDetach();
493494

494-
unsigned connectedSubframeCount() const;
495+
unsigned connectedSubframeCount() const { return rareDataBitfields().connectedSubframeCount; }
495496
void incrementConnectedSubframeCount(unsigned amount = 1);
496497
void decrementConnectedSubframeCount(unsigned amount = 1);
497498
void updateAncestorConnectedSubframeCountForRemoval() const;
498499
void updateAncestorConnectedSubframeCountForInsertion() const;
499500

500501
#if ENABLE(JIT)
501502
static ptrdiff_t nodeFlagsMemoryOffset() { return OBJECT_OFFSETOF(Node, m_nodeFlags); }
502-
static ptrdiff_t rareDataMemoryOffset() { return OBJECT_OFFSETOF(Node, m_rareData); }
503+
static ptrdiff_t rareDataMemoryOffset() { return OBJECT_OFFSETOF(Node, m_rareDataWithBitfields); }
504+
#if CPU(ADDRESS64)
505+
static uint64_t rareDataPointerMask() { return CompactPointerTuple<NodeRareData*, uint16_t>::pointerMask; }
506+
#else
507+
static uint32_t rareDataPointerMask() { return -1; }
508+
#endif
503509
static int32_t flagIsText() { return IsTextFlag; }
504510
static int32_t flagIsContainer() { return IsContainerFlag; }
505511
static int32_t flagIsElement() { return IsElementFlag; }
@@ -526,12 +532,12 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
526532
HasEventTargetDataFlag = 1 << 11,
527533
// UnusedFlag = 1 << 12,
528534
// UnusedFlag = 1 << 13,
535+
// UnusedFlag = 1 << 14,
529536

530537
// These bits are used by derived classes, pulled up here so they can
531538
// be stored in the same memory word as the Node bits above.
532-
IsEditingTextOrUndefinedCustomElementFlag = 1 << 14, // Text and Element
533-
IsCustomElement = 1 << 15, // Element
534-
HasFocusWithin = 1 << 16,
539+
IsEditingText = 1 << 15, // Text
540+
HasFocusWithin = 1 << 16, // Element
535541
IsLinkFlag = 1 << 17,
536542
IsUserActionElement = 1 << 18,
537543
IsParsingChildrenFinishedFlag = 1 << 19,
@@ -547,28 +553,44 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
547553
ContainsFullScreenElementFlag = 1 << 26,
548554
#endif
549555

550-
// Bits 27-29 are free.
551-
// Bits 30-31: TabIndexState
556+
// Bits 27-31 are free.
552557

553558
DefaultNodeFlags = IsParsingChildrenFinishedFlag
554559
};
555560

556-
static constexpr unsigned s_tabIndexStateBitOffset = 30;
557-
static constexpr uint32_t s_tabIndexStateBitMask = 3U << s_tabIndexStateBitOffset;
558561
enum class TabIndexState : uint8_t {
559562
NotSet = 0,
560563
Zero = 1,
561564
NegativeOne = 2,
562565
InRareData = 3,
563566
};
564567

568+
enum class CustomElementState : uint8_t {
569+
Uncustomized = 0,
570+
Undefined = 1,
571+
Custom = 2,
572+
Failed = 3,
573+
};
574+
575+
struct RareDataBitFields {
576+
uint16_t connectedSubframeCount : 10;
577+
uint16_t tabIndexState : 2;
578+
uint16_t customElementState : 2;
579+
};
580+
565581
bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
566582
void setFlag(bool f, NodeFlags mask) const { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
567583
void setFlag(NodeFlags mask) const { m_nodeFlags |= mask; }
568584
void clearFlag(NodeFlags mask) const { m_nodeFlags &= ~mask; }
569585

570-
TabIndexState tabIndexState() const { return static_cast<TabIndexState>((m_nodeFlags & s_tabIndexStateBitMask) >> s_tabIndexStateBitOffset); }
571-
void setTabIndexState(TabIndexState state) { m_nodeFlags = (m_nodeFlags & ~s_tabIndexStateBitMask) | (static_cast<uint32_t>(state) << s_tabIndexStateBitOffset); }
586+
RareDataBitFields rareDataBitfields() const { return bitwise_cast<RareDataBitFields>(m_rareDataWithBitfields.type()); }
587+
void setRareDataBitfields(RareDataBitFields bitfields) { m_rareDataWithBitfields.setType(bitwise_cast<uint16_t>(bitfields)); }
588+
589+
TabIndexState tabIndexState() const { return static_cast<TabIndexState>(rareDataBitfields().tabIndexState); }
590+
void setTabIndexState(TabIndexState);
591+
592+
CustomElementState customElementState() const { return static_cast<CustomElementState>(rareDataBitfields().customElementState); }
593+
void setCustomElementState(CustomElementState);
572594

573595
bool isParsingChildrenFinished() const { return getFlag(IsParsingChildrenFinishedFlag); }
574596
void setIsParsingChildrenFinished() { setFlag(IsParsingChildrenFinishedFlag); }
@@ -586,7 +608,7 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
586608
CreateSVGElement = CreateElement | IsSVGFlag | HasCustomStyleResolveCallbacksFlag,
587609
CreateMathMLElement = CreateElement | IsMathMLFlag,
588610
CreateDocument = CreateContainer | IsDocumentNodeFlag | IsConnectedFlag,
589-
CreateEditingText = CreateText | IsEditingTextOrUndefinedCustomElementFlag,
611+
CreateEditingText = CreateText | IsEditingText,
590612
};
591613
Node(Document&, ConstructionType);
592614

@@ -648,8 +670,8 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
648670

649671
virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { }
650672

651-
bool hasRareData() const { return !!m_rareData; }
652-
NodeRareData* rareData() const { return m_rareData.get(); }
673+
bool hasRareData() const { return !!m_rareDataWithBitfields.pointer(); }
674+
NodeRareData* rareData() const { return m_rareDataWithBitfields.pointer(); }
653675
NodeRareData& ensureRareData();
654676
void clearRareData();
655677

@@ -705,7 +727,7 @@ class Node : public CanMakeWeakPtr<Node>, public EventTarget {
705727
Node* m_previous { nullptr };
706728
Node* m_next { nullptr };
707729
CompactPointerTuple<RenderObject*, uint16_t> m_rendererWithStyleFlags;
708-
std::unique_ptr<NodeRareData, NodeRareDataDeleter> m_rareData;
730+
CompactUniquePtrTuple<NodeRareData, uint16_t, NodeRareDataDeleter> m_rareDataWithBitfields;
709731
};
710732

711733
bool connectedInSameTreeScope(const Node*, const Node*);

Source/WebCore/dom/NodeRareData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
namespace WebCore {
3737

3838
struct SameSizeAsNodeRareData {
39-
unsigned m_frameCountAndIsElementRareDataFlag;
39+
uint32_t m_tabIndex;
40+
uint32_t m_childIndexAndIsElementRareDataFlag;
4041
void* m_pointer[2];
4142
};
4243

0 commit comments

Comments
 (0)