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

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

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 | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index e3833d12c9a809d70f202098ae5dad23d485916f..40eca817404dba8bd515b7ae65a166e804168f83 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -227,6 +227,26 @@ inline ElementRareData& Element::ensureElementRareData()
return static_cast<ElementRareData&>(ensureRareData());
}
+bool Element::hasElementFlagInternal(ElementFlags mask) const
+{
+ ASSERT(hasRareData());
+ return elementRareData()->hasFlag(mask);
+}
+
+void Element::setElementFlag(ElementFlags mask, bool value)
+{
+ if (!hasRareData() && !value)
+ return;
+ ensureElementRareData().setFlag(mask, value);
+}
+
+void Element::clearElementFlag(ElementFlags mask)
+{
+ if (!hasRareData())
+ return;
+ elementRareData()->clearFlag(mask);
+}
+
void Element::clearTabIndexExplicitlyIfNeeded()
{
if (hasRareData())
@@ -238,11 +258,6 @@ void Element::setTabIndexExplicitly(short tabIndex)
ensureElementRareData().setTabIndexExplicitly(tabIndex);
}
-bool Element::supportsFocus() const
-{
- return hasRareData() && elementRareData()->tabIndexSetExplicitly();
-}
-
short Element::tabIndex() const
{
return hasRareData() ? elementRareData()->tabIndex() : 0;
@@ -1388,8 +1403,7 @@ void Element::removedFrom(ContainerNode* insertionPoint)
document().removeFromTopLayer(this);
- if (hasRareData())
- elementRareData()->setIsInCanvasSubtree(false);
+ clearElementFlag(IsInCanvasSubtree);
}
void Element::attach(const AttachContext& context)
@@ -1430,10 +1444,10 @@ void Element::attach(const AttachContext& context)
if (hasRareData()) {
ElementRareData* data = elementRareData();
- if (data->needsFocusAppearanceUpdateSoonAfterAttach()) {
+ if (data->hasFlag(NeedsFocusAppearanceUpdateSoonAfterAttach)) {
if (isFocusable() && document().focusedElement() == this)
document().updateFocusAppearanceSoon(false /* don't restore selection */);
- data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
+ data->clearFlag(NeedsFocusAppearanceUpdateSoonAfterAttach);
}
if (!renderer()) {
if (ActiveAnimations* activeAnimations = data->activeAnimations()) {
@@ -2172,7 +2186,7 @@ void Element::focus(bool restorePreviousSelection, FocusType type)
doc.updateLayoutIgnorePendingStylesheets();
if (!isFocusable()) {
- ensureElementRareData().setNeedsFocusAppearanceUpdateSoonAfterAttach(true);
+ setElementFlag(NeedsFocusAppearanceUpdateSoonAfterAttach);
return;
}
@@ -2507,56 +2521,6 @@ RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
return pseudoElementSpecifier ? rareData.computedStyle()->getCachedPseudoStyle(pseudoElementSpecifier) : rareData.computedStyle();
}
-void Element::setStyleAffectedByEmpty()
-{
- ensureElementRareData().setStyleAffectedByEmpty(true);
-}
-
-void Element::setChildrenAffectedByFocus()
-{
- ensureElementRareData().setChildrenAffectedByFocus(true);
-}
-
-void Element::setChildrenAffectedByHover()
-{
- ensureElementRareData().setChildrenAffectedByHover(true);
-}
-
-void Element::setChildrenAffectedByActive()
-{
- ensureElementRareData().setChildrenAffectedByActive(true);
-}
-
-void Element::setChildrenAffectedByDrag()
-{
- ensureElementRareData().setChildrenAffectedByDrag(true);
-}
-
-void Element::setChildrenAffectedByFirstChildRules()
-{
- ensureElementRareData().setChildrenAffectedByFirstChildRules(true);
-}
-
-void Element::setChildrenAffectedByLastChildRules()
-{
- ensureElementRareData().setChildrenAffectedByLastChildRules(true);
-}
-
-void Element::setChildrenAffectedByDirectAdjacentRules()
-{
- ensureElementRareData().setChildrenAffectedByDirectAdjacentRules(true);
-}
-
-void Element::setChildrenAffectedByForwardPositionalRules()
-{
- ensureElementRareData().setChildrenAffectedByForwardPositionalRules(true);
-}
-
-void Element::setChildrenAffectedByBackwardPositionalRules()
-{
- ensureElementRareData().setChildrenAffectedByBackwardPositionalRules(true);
-}
-
void Element::setChildIndex(unsigned index)
{
ElementRareData& rareData = ensureElementRareData();
@@ -2565,97 +2529,12 @@ void Element::setChildIndex(unsigned index)
rareData.setChildIndex(index);
}
-bool Element::childrenSupportStyleSharing() const
-{
- if (!hasRareData())
- return true;
- return !rareDataChildrenAffectedByFocus()
- && !rareDataChildrenAffectedByHover()
- && !rareDataChildrenAffectedByActive()
- && !rareDataChildrenAffectedByDrag()
- && !rareDataChildrenAffectedByFirstChildRules()
- && !rareDataChildrenAffectedByLastChildRules()
- && !rareDataChildrenAffectedByDirectAdjacentRules()
- && !rareDataChildrenAffectedByForwardPositionalRules()
- && !rareDataChildrenAffectedByBackwardPositionalRules();
-}
-
-bool Element::rareDataStyleAffectedByEmpty() const
-{
- ASSERT(hasRareData());
- return elementRareData()->styleAffectedByEmpty();
-}
-
-bool Element::rareDataChildrenAffectedByFocus() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByFocus();
-}
-
-bool Element::rareDataChildrenAffectedByHover() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByHover();
-}
-
-bool Element::rareDataChildrenAffectedByActive() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByActive();
-}
-
-bool Element::rareDataChildrenAffectedByDrag() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByDrag();
-}
-
-bool Element::rareDataChildrenAffectedByFirstChildRules() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByFirstChildRules();
-}
-
-bool Element::rareDataChildrenAffectedByLastChildRules() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByLastChildRules();
-}
-
-bool Element::rareDataChildrenAffectedByDirectAdjacentRules() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByDirectAdjacentRules();
-}
-
-bool Element::rareDataChildrenAffectedByForwardPositionalRules() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByForwardPositionalRules();
-}
-
-bool Element::rareDataChildrenAffectedByBackwardPositionalRules() const
-{
- ASSERT(hasRareData());
- return elementRareData()->childrenAffectedByBackwardPositionalRules();
-}
-
unsigned Element::rareDataChildIndex() const
{
ASSERT(hasRareData());
return elementRareData()->childIndex();
}
-void Element::setIsInCanvasSubtree(bool isInCanvasSubtree)
-{
- ensureElementRareData().setIsInCanvasSubtree(isInCanvasSubtree);
-}
-
-bool Element::isInCanvasSubtree() const
-{
- return hasRareData() && elementRareData()->isInCanvasSubtree();
-}
-
AtomicString Element::computeInheritedLanguage() const
{
const Node* n = this;
@@ -2689,7 +2568,7 @@ Locale& Element::locale() const
void Element::cancelFocusAppearanceUpdate()
{
if (hasRareData())
- elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
+ clearElementFlag(NeedsFocusAppearanceUpdateSoonAfterAttach);
if (document().focusedElement() == this)
document().cancelFocusAppearanceUpdate();
}
@@ -2858,14 +2737,9 @@ void Element::webkitRequestFullScreen(unsigned short flags)
FullscreenElementStack::from(document()).requestFullScreenForElement(this, (flags | LEGACY_MOZILLA_REQUEST), FullscreenElementStack::EnforceIFrameAllowFullScreenRequirement);
}
-bool Element::containsFullScreenElement() const
-{
- return hasRareData() && elementRareData()->containsFullScreenElement();
-}
-
void Element::setContainsFullScreenElement(bool flag)
{
- ensureElementRareData().setContainsFullScreenElement(flag);
+ setElementFlag(ContainsFullScreenElement, flag);
setNeedsStyleRecalc(SubtreeStyleChange);
}
@@ -2882,16 +2756,11 @@ void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo
element->setContainsFullScreenElement(flag);
}
-bool Element::isInTopLayer() const
-{
- return hasRareData() && elementRareData()->isInTopLayer();
-}
-
void Element::setIsInTopLayer(bool inTopLayer)
{
if (isInTopLayer() == inTopLayer)
return;
- ensureElementRareData().setIsInTopLayer(inTopLayer);
+ setElementFlag(IsInTopLayer, inTopLayer);
// We must ensure a reattach occurs so the renderer is inserted in the correct sibling order under RenderView according to its
// top layer position, or in its usual place if not in the top layer.
@@ -3319,21 +3188,6 @@ bool Element::hasInputMethodContext() const
return hasRareData() && elementRareData()->hasInputMethodContext();
}
-bool Element::hasPendingResources() const
-{
- return hasRareData() && elementRareData()->hasPendingResources();
-}
-
-void Element::setHasPendingResources()
-{
- ensureElementRareData().setHasPendingResources(true);
-}
-
-void Element::clearHasPendingResources()
-{
- ensureElementRareData().setHasPendingResources(false);
-}
-
void Element::synchronizeStyleAttributeInternal() const
{
ASSERT(isStyledElement());
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698