Bug 1277298 - Store the 'scrollgrab' property in a NODE_FLAG_BIT rather than a new field of nsGenericHTMLElement. r=smaug
MozReview-Commit-ID: 7DV33kG2KNt
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -107,18 +107,21 @@ enum {
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT |
ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT,
// All of the restyle bits together, for convenience.
ELEMENT_ALL_RESTYLE_FLAGS = ELEMENT_PENDING_RESTYLE_FLAGS |
ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS |
ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR,
+ // Set if this element is marked as 'scrollgrab' (see bug 912666)
+ ELEMENT_HAS_SCROLLGRAB = ELEMENT_FLAG_BIT(5),
+
// Remaining bits are for subclasses
- ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 5
+ ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 6
};
#undef ELEMENT_FLAG_BIT
// Make sure we have space for our bits
ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET);
namespace mozilla {
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -47,18 +47,17 @@ typedef nsMappedAttributeElement nsGener
/**
* A common superclass for HTML elements
*/
class nsGenericHTMLElement : public nsGenericHTMLElementBase,
public nsIDOMHTMLElement
{
public:
explicit nsGenericHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
- : nsGenericHTMLElementBase(aNodeInfo),
- mScrollgrab(false)
+ : nsGenericHTMLElementBase(aNodeInfo)
{
NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML,
"Unexpected namespace");
AddStatesSilently(NS_EVENT_STATE_LTR);
SetFlags(NODE_HAS_DIRECTION_LTR);
}
NS_DECL_ISUPPORTS_INHERITED
@@ -189,21 +188,25 @@ public:
{
SetHTMLAttr(nsGkAtoms::spellcheck,
aSpellcheck ? NS_LITERAL_STRING("true")
: NS_LITERAL_STRING("false"),
aError);
}
bool Scrollgrab() const
{
- return mScrollgrab;
+ return HasFlag(ELEMENT_HAS_SCROLLGRAB);
}
void SetScrollgrab(bool aValue)
{
- mScrollgrab = aValue;
+ if (aValue) {
+ SetFlags(ELEMENT_HAS_SCROLLGRAB);
+ } else {
+ UnsetFlags(ELEMENT_HAS_SCROLLGRAB);
+ }
}
void GetInnerText(mozilla::dom::DOMString& aValue, mozilla::ErrorResult& aError);
void SetInnerText(const nsAString& aValue);
/**
* Determine whether an attribute is an event (onclick, etc.)
* @param aName the attribute
@@ -1162,18 +1165,16 @@ protected:
* made editable through contentEditable or designMode.
*/
bool IsEditableRoot() const;
nsresult SetUndoScopeInternal(bool aUndoScope);
private:
void ChangeEditableState(int32_t aChange);
-
- bool mScrollgrab;
};
namespace mozilla {
namespace dom {
class HTMLFieldSetElement;
} // namespace dom
} // namespace mozilla