Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Unified Diff: Source/core/dom/Element.h

Issue 202633006: Use an unsigned of flags in ElementRareData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: try again Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.h
diff --git a/Source/core/dom/Element.h b/Source/core/dom/Element.h
index d5699359c87b8a69d254b94c70308101eeb3fc4d..0e9091741b78ab33b5a3fa31818181d9e747403c 100644
--- a/Source/core/dom/Element.h
+++ b/Source/core/dom/Element.h
@@ -75,6 +75,37 @@ enum SpellcheckAttributeState {
SpellcheckAttributeDefault
};
+enum ElementFlags {
+ TabIndexWasSetExplicitly = 1 << 0,
+ NeedsFocusAppearanceUpdateSoonAfterAttach = 1 << 1,
+ StyleAffectedByEmpty = 1 << 2,
+ IsInCanvasSubtree = 1 << 3,
+ ContainsFullScreenElement = 1 << 4,
+ IsInTopLayer = 1 << 5,
+ HasPendingResources = 1 << 6,
+ ChildrenAffectedByFocus = 1 << 7,
+ ChildrenAffectedByHover = 1 << 8,
+ ChildrenAffectedByActive = 1 << 9,
+ ChildrenAffectedByDrag = 1 << 10,
+ ChildrenAffectedByFirstChildRules = 1 << 11,
+ ChildrenAffectedByLastChildRules = 1 << 12,
+ ChildrenAffectedByDirectAdjacentRules = 1 << 13,
+ ChildrenAffectedByForwardPositionalRules = 1 << 14,
+ ChildrenAffectedByBackwardPositionalRules = 1 << 15,
+
+ // If any of these flags are set we cannot share style.
+ ElementFlagsPreventingStyleSharing =
+ ChildrenAffectedByFocus
+ | ChildrenAffectedByHover
+ | ChildrenAffectedByActive
+ | ChildrenAffectedByDrag
+ | ChildrenAffectedByFirstChildRules
+ | ChildrenAffectedByLastChildRules
+ | ChildrenAffectedByDirectAdjacentRules
+ | ChildrenAffectedByForwardPositionalRules
+ | ChildrenAffectedByBackwardPositionalRules,
+};
+
class Element : public ContainerNode {
public:
static PassRefPtr<Element> create(const QualifiedName&, Document*);
@@ -327,35 +358,45 @@ public:
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
// 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 hasRareData() && rareDataStyleAffectedByEmpty(); }
- bool childrenAffectedByFocus() const { return hasRareData() && rareDataChildrenAffectedByFocus(); }
- bool childrenAffectedByHover() const { return hasRareData() && rareDataChildrenAffectedByHover(); }
- bool childrenAffectedByActive() const { return hasRareData() && rareDataChildrenAffectedByActive(); }
- bool childrenAffectedByDrag() const { return hasRareData() && rareDataChildrenAffectedByDrag(); }
- bool childrenAffectedByPositionalRules() const { return hasRareData() && (rareDataChildrenAffectedByForwardPositionalRules() || rareDataChildrenAffectedByBackwardPositionalRules()); }
- bool childrenAffectedByFirstChildRules() const { return hasRareData() && rareDataChildrenAffectedByFirstChildRules(); }
- bool childrenAffectedByLastChildRules() const { return hasRareData() && rareDataChildrenAffectedByLastChildRules(); }
- bool childrenAffectedByDirectAdjacentRules() const { return hasRareData() && rareDataChildrenAffectedByDirectAdjacentRules(); }
- bool childrenAffectedByForwardPositionalRules() const { return hasRareData() && rareDataChildrenAffectedByForwardPositionalRules(); }
- bool childrenAffectedByBackwardPositionalRules() const { return hasRareData() && rareDataChildrenAffectedByBackwardPositionalRules(); }
- unsigned childIndex() const { return hasRareData() ? rareDataChildIndex() : 0; }
+ bool styleAffectedByEmpty() const { return hasElementFlag(StyleAffectedByEmpty); }
+ void setStyleAffectedByEmpty() { setElementFlag(StyleAffectedByEmpty); }
+
+ bool childrenAffectedByFocus() const { return hasElementFlag(ChildrenAffectedByFocus); }
+ void setChildrenAffectedByFocus() { setElementFlag(ChildrenAffectedByFocus); }
+
+ bool childrenAffectedByHover() const { return hasElementFlag(ChildrenAffectedByHover); }
+ void setChildrenAffectedByHover() { setElementFlag(ChildrenAffectedByHover); }
+
+ bool childrenAffectedByActive() const { return hasElementFlag(ChildrenAffectedByActive); }
+ void setChildrenAffectedByActive() { setElementFlag(ChildrenAffectedByActive); }
+
+ bool childrenAffectedByDrag() const { return hasElementFlag(ChildrenAffectedByDrag); }
+ void setChildrenAffectedByDrag() { setElementFlag(ChildrenAffectedByDrag); }
+
+ bool childrenAffectedByPositionalRules() const { return hasElementFlag(ChildrenAffectedByForwardPositionalRules) || hasElementFlag(ChildrenAffectedByBackwardPositionalRules); }
+
+ bool childrenAffectedByFirstChildRules() const { return hasElementFlag(ChildrenAffectedByFirstChildRules); }
+ void setChildrenAffectedByFirstChildRules() { setElementFlag(ChildrenAffectedByFirstChildRules); }
- bool childrenSupportStyleSharing() const;
-
- void setStyleAffectedByEmpty();
- void setChildrenAffectedByFocus();
- void setChildrenAffectedByHover();
- void setChildrenAffectedByActive();
- void setChildrenAffectedByDrag();
- void setChildrenAffectedByFirstChildRules();
- void setChildrenAffectedByLastChildRules();
- void setChildrenAffectedByDirectAdjacentRules();
- void setChildrenAffectedByForwardPositionalRules();
- void setChildrenAffectedByBackwardPositionalRules();
+ bool childrenAffectedByLastChildRules() const { return hasElementFlag(ChildrenAffectedByLastChildRules); }
+ void setChildrenAffectedByLastChildRules() { setElementFlag(ChildrenAffectedByLastChildRules); }
+
+ bool childrenAffectedByDirectAdjacentRules() const { return hasElementFlag(ChildrenAffectedByDirectAdjacentRules); }
+ void setChildrenAffectedByDirectAdjacentRules() { setElementFlag(ChildrenAffectedByDirectAdjacentRules); }
+
+ bool childrenAffectedByForwardPositionalRules() const { return hasElementFlag(ChildrenAffectedByForwardPositionalRules); }
+ void setChildrenAffectedByForwardPositionalRules() { setElementFlag(ChildrenAffectedByForwardPositionalRules); }
+
+ bool childrenAffectedByBackwardPositionalRules() const { return hasElementFlag(ChildrenAffectedByBackwardPositionalRules); }
+ void setChildrenAffectedByBackwardPositionalRules() { setElementFlag(ChildrenAffectedByBackwardPositionalRules); }
+
+ void setIsInCanvasSubtree(bool value) { setElementFlag(IsInCanvasSubtree, value); }
+ bool isInCanvasSubtree() const { return hasElementFlag(IsInCanvasSubtree); }
+
+ unsigned childIndex() const { return hasRareData() ? rareDataChildIndex() : 0; }
void setChildIndex(unsigned);
- void setIsInCanvasSubtree(bool);
- bool isInCanvasSubtree() const;
+ bool childrenSupportStyleSharing() const { return !hasElementFlag(ElementFlagsPreventingStyleSharing); }
bool isUpgradedCustomElement() { return customElementState() == Upgraded; }
bool isUnresolvedCustomElement() { return customElementState() == WaitingForUpgrade; }
@@ -381,7 +422,7 @@ public:
// focusable but some elements, such as form controls and links, are. Unlike
// rendererIsFocusable(), this method may be called when layout is not up to
// date, so it must not use the renderer to determine focusability.
- virtual bool supportsFocus() const;
+ virtual bool supportsFocus() const { return hasElementFlag(TabIndexWasSetExplicitly); }
// Whether the node can actually be focused.
bool isFocusable() const;
virtual bool isKeyboardFocusable() const;
@@ -470,9 +511,9 @@ public:
// to event listeners, and prevents DOMActivate events from being sent at all.
virtual bool isDisabledFormControl() const { return false; }
- bool hasPendingResources() const;
- void setHasPendingResources();
- void clearHasPendingResources();
+ bool hasPendingResources() const { return hasElementFlag(HasPendingResources); }
+ void setHasPendingResources() { setElementFlag(HasPendingResources); }
+ void clearHasPendingResources() { clearElementFlag(HasPendingResources); }
virtual void buildPendingResource() { };
enum {
@@ -481,14 +522,14 @@ public:
};
void webkitRequestFullScreen(unsigned short flags);
- bool containsFullScreenElement() const;
+ bool containsFullScreenElement() const { return hasElementFlag(ContainsFullScreenElement); }
void setContainsFullScreenElement(bool);
void setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(bool);
// W3C API
void webkitRequestFullscreen();
- bool isInTopLayer() const;
+ bool isInTopLayer() const { return hasElementFlag(IsInTopLayer); }
void setIsInTopLayer(bool);
void webkitRequestPointerLock();
@@ -565,6 +606,11 @@ protected:
Node* insertAdjacent(const String& where, Node* newChild, ExceptionState&);
private:
+ bool hasElementFlag(ElementFlags mask) const { return hasRareData() && hasElementFlagInternal(mask); }
+ void setElementFlag(ElementFlags, bool value = true);
+ void clearElementFlag(ElementFlags);
+ bool hasElementFlagInternal(ElementFlags) const;
+
void styleAttributeChanged(const AtomicString& newStyleString, AttributeModificationReason);
void updatePresentationAttributeStyle();
@@ -637,16 +683,7 @@ private:
virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren();
QualifiedName m_tagName;
- bool rareDataStyleAffectedByEmpty() const;
- bool rareDataChildrenAffectedByFocus() const;
- bool rareDataChildrenAffectedByHover() const;
- bool rareDataChildrenAffectedByActive() const;
- bool rareDataChildrenAffectedByDrag() const;
- bool rareDataChildrenAffectedByFirstChildRules() const;
- bool rareDataChildrenAffectedByLastChildRules() const;
- bool rareDataChildrenAffectedByDirectAdjacentRules() const;
- bool rareDataChildrenAffectedByForwardPositionalRules() const;
- bool rareDataChildrenAffectedByBackwardPositionalRules() const;
+
unsigned rareDataChildIndex() const;
SpellcheckAttributeState spellcheckAttributeState() const;
« no previous file with comments | « no previous file | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698