2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#ifndef mozilla_EventStates_h_
|
|
|
|
#define mozilla_EventStates_h_
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2013-07-31 21:08:35 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-11-20 19:20:14 +03:00
|
|
|
#include "nsDebug.h"
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* EventStates is the class used to represent the event states of nsIContent
|
2010-10-20 15:26:32 +04:00
|
|
|
* instances. These states are calculated by IntrinsicState() and
|
|
|
|
* ContentStatesChanged() has to be called when one of them changes thus
|
|
|
|
* informing the layout/style engine of the change.
|
|
|
|
* Event states are associated with pseudo-classes.
|
|
|
|
*/
|
2014-04-03 08:18:36 +04:00
|
|
|
class EventStates
|
2010-10-20 15:26:32 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
typedef uint64_t InternalType;
|
2017-03-20 18:54:54 +03:00
|
|
|
typedef uint64_t ServoType;
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2016-07-09 00:39:53 +03:00
|
|
|
constexpr EventStates()
|
2010-10-20 15:26:32 +04:00
|
|
|
: mStates(0)
|
2014-04-03 08:18:36 +04:00
|
|
|
{
|
|
|
|
}
|
2010-10-20 15:26:32 +04:00
|
|
|
|
|
|
|
// NOTE: the ideal scenario would be to have the default constructor public
|
|
|
|
// setting mStates to 0 and this constructor (without = 0) private.
|
|
|
|
// In that case, we could be sure that only macros at the end were creating
|
2014-04-03 08:18:36 +04:00
|
|
|
// EventStates instances with mStates set to something else than 0.
|
2010-10-20 15:26:32 +04:00
|
|
|
// Unfortunately, this constructor is needed at at least two places now.
|
2016-07-09 00:39:53 +03:00
|
|
|
explicit constexpr EventStates(InternalType aStates)
|
2010-10-20 15:26:32 +04:00
|
|
|
: mStates(aStates)
|
2014-04-03 08:18:36 +04:00
|
|
|
{
|
|
|
|
}
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2016-07-09 00:39:53 +03:00
|
|
|
EventStates constexpr operator|(const EventStates& aEventStates) const
|
2014-04-03 08:18:36 +04:00
|
|
|
{
|
|
|
|
return EventStates(mStates | aEventStates.mStates);
|
2010-10-20 15:26:32 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates& operator|=(const EventStates& aEventStates)
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
mStates |= aEventStates.mStates;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: calling if (eventStates1 & eventStates2) will not build.
|
|
|
|
// This might work correctly if operator bool() is defined
|
|
|
|
// but using HasState, HasAllStates or HasAtLeastOneOfStates is recommended.
|
2016-07-09 00:39:53 +03:00
|
|
|
EventStates constexpr operator&(const EventStates& aEventStates) const
|
2014-04-03 08:18:36 +04:00
|
|
|
{
|
|
|
|
return EventStates(mStates & aEventStates.mStates);
|
2010-10-20 15:26:32 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates& operator&=(const EventStates& aEventStates)
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
mStates &= aEventStates.mStates;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
bool operator==(const EventStates& aEventStates) const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
return mStates == aEventStates.mStates;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
bool operator!=(const EventStates& aEventStates) const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
return mStates != aEventStates.mStates;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates operator~() const
|
|
|
|
{
|
|
|
|
return EventStates(~mStates);
|
2010-10-20 15:26:32 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates operator^(const EventStates& aEventStates) const
|
|
|
|
{
|
|
|
|
return EventStates(mStates ^ aEventStates.mStates);
|
2010-10-20 15:26:32 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates& operator^=(const EventStates& aEventStates)
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
mStates ^= aEventStates.mStates;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* Returns true if the EventStates instance is empty.
|
|
|
|
* A EventStates instance is empty if it contains no state.
|
2010-10-20 15:26:32 +04:00
|
|
|
*
|
|
|
|
* @return Whether if the object is empty.
|
|
|
|
*/
|
2014-04-03 08:18:36 +04:00
|
|
|
bool IsEmpty() const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
return mStates == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* Returns true if the EventStates instance contains the state
|
2010-10-20 15:26:32 +04:00
|
|
|
* contained in aEventStates.
|
|
|
|
* @note aEventStates should contain only one state.
|
|
|
|
*
|
|
|
|
* @param aEventStates The state to check.
|
|
|
|
*
|
|
|
|
* @return Whether the object has the state from aEventStates
|
|
|
|
*/
|
2014-04-03 08:18:36 +04:00
|
|
|
bool HasState(EventStates aEventStates) const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
// If aEventStates.mStates is a power of two, it contains only one state
|
|
|
|
// (or none, but we don't really care).
|
|
|
|
if ((aEventStates.mStates & (aEventStates.mStates - 1))) {
|
|
|
|
NS_ERROR("When calling HasState, "
|
2014-04-03 08:18:36 +04:00
|
|
|
"EventStates object has to contain only one state!");
|
2010-10-20 15:26:32 +04:00
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
return mStates & aEventStates.mStates;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* Returns true if the EventStates instance contains one of the states
|
2010-10-20 15:26:32 +04:00
|
|
|
* contained in aEventStates.
|
|
|
|
*
|
|
|
|
* @param aEventStates The states to check.
|
|
|
|
*
|
|
|
|
* @return Whether the object has at least one state from aEventStates
|
|
|
|
*/
|
2014-04-03 08:18:36 +04:00
|
|
|
bool HasAtLeastOneOfStates(EventStates aEventStates) const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
return mStates & aEventStates.mStates;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* Returns true if the EventStates instance contains all states
|
2010-10-20 15:26:32 +04:00
|
|
|
* contained in aEventStates.
|
|
|
|
*
|
|
|
|
* @param aEventStates The states to check.
|
|
|
|
*
|
|
|
|
* @return Whether the object has all states from aEventStates
|
|
|
|
*/
|
2014-04-03 08:18:36 +04:00
|
|
|
bool HasAllStates(EventStates aEventStates) const
|
|
|
|
{
|
2010-10-20 15:26:32 +04:00
|
|
|
return (mStates & aEventStates.mStates) == aEventStates.mStates;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We only need that method for inDOMUtils::GetContentState.
|
|
|
|
// If inDOMUtils::GetContentState is removed, this method should be removed.
|
|
|
|
InternalType GetInternalValue() const {
|
|
|
|
return mStates;
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
/**
|
|
|
|
* Method used to get the appropriate state representation for Servo.
|
|
|
|
*/
|
|
|
|
ServoType ServoValue() const
|
|
|
|
{
|
2017-03-24 02:45:07 +03:00
|
|
|
return mStates;
|
2016-07-19 04:02:55 +03:00
|
|
|
}
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
private:
|
|
|
|
InternalType mStates;
|
|
|
|
};
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* The following macros are creating EventStates instance with different
|
2010-10-20 15:26:32 +04:00
|
|
|
* values depending of their meaning.
|
2014-04-03 08:18:36 +04:00
|
|
|
* Ideally, EventStates instance with values different than 0 should only be
|
2010-10-20 15:26:32 +04:00
|
|
|
* created that way.
|
|
|
|
*/
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
// Helper to define a new EventStates macro.
|
2010-10-20 15:26:32 +04:00
|
|
|
#define NS_DEFINE_EVENT_STATE_MACRO(_val) \
|
2014-04-03 08:18:36 +04:00
|
|
|
(mozilla::EventStates(mozilla::EventStates::InternalType(1) << _val))
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2016-02-24 04:51:47 +03:00
|
|
|
/*
|
|
|
|
* In order to efficiently convert Gecko EventState values into Servo
|
|
|
|
* ElementState values [1], we maintain the invariant that the low bits of
|
|
|
|
* EventState can be masked off to form an ElementState (this works so
|
|
|
|
* long as Servo never supports a state that Gecko doesn't).
|
|
|
|
*
|
|
|
|
* This is unfortunately rather fragile for now, but we should soon have
|
|
|
|
* the infrastructure to statically-assert that these match up. If you
|
|
|
|
* need to change these, please notify somebody involved with Stylo.
|
|
|
|
*
|
|
|
|
* [1] https://github.com/servo/servo/blob/master/components/style/element_state.rs
|
|
|
|
*/
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
// Mouse is down on content.
|
|
|
|
#define NS_EVENT_STATE_ACTIVE NS_DEFINE_EVENT_STATE_MACRO(0)
|
|
|
|
// Content has focus.
|
|
|
|
#define NS_EVENT_STATE_FOCUS NS_DEFINE_EVENT_STATE_MACRO(1)
|
|
|
|
// Mouse is hovering over content.
|
|
|
|
#define NS_EVENT_STATE_HOVER NS_DEFINE_EVENT_STATE_MACRO(2)
|
2016-02-25 00:50:40 +03:00
|
|
|
// Content is enabled (and can be disabled).
|
2016-02-24 04:51:47 +03:00
|
|
|
#define NS_EVENT_STATE_ENABLED NS_DEFINE_EVENT_STATE_MACRO(3)
|
2016-02-25 00:50:40 +03:00
|
|
|
// Content is disabled.
|
2016-02-24 04:51:47 +03:00
|
|
|
#define NS_EVENT_STATE_DISABLED NS_DEFINE_EVENT_STATE_MACRO(4)
|
|
|
|
// Content is checked.
|
|
|
|
#define NS_EVENT_STATE_CHECKED NS_DEFINE_EVENT_STATE_MACRO(5)
|
|
|
|
// Content is in the indeterminate state.
|
|
|
|
#define NS_EVENT_STATE_INDETERMINATE NS_DEFINE_EVENT_STATE_MACRO(6)
|
2017-01-06 02:01:59 +03:00
|
|
|
// Content shows its placeholder
|
|
|
|
#define NS_EVENT_STATE_PLACEHOLDERSHOWN NS_DEFINE_EVENT_STATE_MACRO(7)
|
|
|
|
// Content is URL's target (ref).
|
|
|
|
#define NS_EVENT_STATE_URLTARGET NS_DEFINE_EVENT_STATE_MACRO(8)
|
|
|
|
// Content is the full screen element, or a frame containing the
|
|
|
|
// current full-screen element.
|
|
|
|
#define NS_EVENT_STATE_FULL_SCREEN NS_DEFINE_EVENT_STATE_MACRO(9)
|
2017-03-15 17:34:29 +03:00
|
|
|
// Content is valid (and can be invalid).
|
|
|
|
#define NS_EVENT_STATE_VALID NS_DEFINE_EVENT_STATE_MACRO(10)
|
|
|
|
// Content is invalid.
|
|
|
|
#define NS_EVENT_STATE_INVALID NS_DEFINE_EVENT_STATE_MACRO(11)
|
|
|
|
// UI friendly version of :valid pseudo-class.
|
|
|
|
#define NS_EVENT_STATE_MOZ_UI_VALID NS_DEFINE_EVENT_STATE_MACRO(12)
|
2017-03-24 02:45:07 +03:00
|
|
|
// UI friendly version of :invalid pseudo-class.
|
|
|
|
#define NS_EVENT_STATE_MOZ_UI_INVALID NS_DEFINE_EVENT_STATE_MACRO(13)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Content could not be rendered (image/object/etc).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_BROKEN NS_DEFINE_EVENT_STATE_MACRO(14)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Content disabled by the user (images turned off, say).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_USERDISABLED NS_DEFINE_EVENT_STATE_MACRO(15)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Content suppressed by the user (ad blocking, etc).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_SUPPRESSED NS_DEFINE_EVENT_STATE_MACRO(16)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Content is still loading such that there is nothing to show the
|
|
|
|
// user (eg an image which hasn't started coming in yet).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_LOADING NS_DEFINE_EVENT_STATE_MACRO(17)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Handler for the content has been blocked.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_HANDLER_BLOCKED NS_DEFINE_EVENT_STATE_MACRO(18)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Handler for the content has been disabled.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_HANDLER_DISABLED NS_DEFINE_EVENT_STATE_MACRO(19)
|
2017-03-18 19:41:39 +03:00
|
|
|
// Handler for the content has crashed
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_HANDLER_CRASHED NS_DEFINE_EVENT_STATE_MACRO(20)
|
2017-03-23 05:01:12 +03:00
|
|
|
// Content is required.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_REQUIRED NS_DEFINE_EVENT_STATE_MACRO(21)
|
2017-03-23 05:01:12 +03:00
|
|
|
// Content is optional (and can be required).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_OPTIONAL NS_DEFINE_EVENT_STATE_MACRO(22)
|
|
|
|
// Element is an unresolved custom element candidate
|
|
|
|
#define NS_EVENT_STATE_UNRESOLVED NS_DEFINE_EVENT_STATE_MACRO(23)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Link has been visited.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_VISITED NS_DEFINE_EVENT_STATE_MACRO(24)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Link hasn't been visited.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_UNVISITED NS_DEFINE_EVENT_STATE_MACRO(25)
|
|
|
|
// Drag is hovering over content.
|
|
|
|
#define NS_EVENT_STATE_DRAGOVER NS_DEFINE_EVENT_STATE_MACRO(26)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Content value is in-range (and can be out-of-range).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_INRANGE NS_DEFINE_EVENT_STATE_MACRO(27)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Content value is out-of-range.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_OUTOFRANGE NS_DEFINE_EVENT_STATE_MACRO(28)
|
2010-10-20 15:26:32 +04:00
|
|
|
// These two are temporary (see bug 302188)
|
|
|
|
// Content is read-only.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_MOZ_READONLY NS_DEFINE_EVENT_STATE_MACRO(29)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Content is editable.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_MOZ_READWRITE NS_DEFINE_EVENT_STATE_MACRO(30)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Content is the default one (meaning depends of the context).
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_DEFAULT NS_DEFINE_EVENT_STATE_MACRO(31)
|
2010-10-20 15:26:32 +04:00
|
|
|
// Content is a submit control and the form isn't valid.
|
2017-03-15 17:34:29 +03:00
|
|
|
#define NS_EVENT_STATE_MOZ_SUBMITINVALID NS_DEFINE_EVENT_STATE_MACRO(32)
|
2012-05-16 15:23:31 +04:00
|
|
|
// Content is in the optimum region.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(33)
|
2012-05-16 15:23:31 +04:00
|
|
|
// Content is in the suboptimal region.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(34)
|
2012-05-16 15:23:31 +04:00
|
|
|
// Content is in the sub-suboptimal region.
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_SUB_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(35)
|
|
|
|
// Element is highlighted (devtools inspector)
|
|
|
|
#define NS_EVENT_STATE_DEVTOOLS_HIGHLIGHTED NS_DEFINE_EVENT_STATE_MACRO(36)
|
|
|
|
// Element is transitioning for rules changed by style editor
|
|
|
|
#define NS_EVENT_STATE_STYLEEDITOR_TRANSITIONING NS_DEFINE_EVENT_STATE_MACRO(37)
|
|
|
|
#define NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL NS_DEFINE_EVENT_STATE_MACRO(38)
|
|
|
|
// Content has focus and should show a ring.
|
|
|
|
#define NS_EVENT_STATE_FOCUSRING NS_DEFINE_EVENT_STATE_MACRO(39)
|
|
|
|
// Handler for click to play plugin
|
|
|
|
#define NS_EVENT_STATE_TYPE_CLICK_TO_PLAY NS_DEFINE_EVENT_STATE_MACRO(40)
|
2012-07-11 19:56:34 +04:00
|
|
|
// Handler for click to play plugin (vulnerable w/update)
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_VULNERABLE_UPDATABLE NS_DEFINE_EVENT_STATE_MACRO(41)
|
2012-07-11 19:56:34 +04:00
|
|
|
// Handler for click to play plugin (vulnerable w/no update)
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(42)
|
|
|
|
// Element has focus-within.
|
|
|
|
#define NS_EVENT_STATE_FOCUS_WITHIN NS_DEFINE_EVENT_STATE_MACRO(43)
|
2012-08-10 07:37:58 +04:00
|
|
|
// Element is ltr (for :dir pseudo-class)
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(44)
|
2012-08-10 07:37:58 +04:00
|
|
|
// Element is rtl (for :dir pseudo-class)
|
2017-03-24 02:45:07 +03:00
|
|
|
#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(45)
|
2017-06-20 06:24:59 +03:00
|
|
|
// States for tracking the state of the "dir" attribute for HTML elements. We
|
|
|
|
// use these to avoid having to get "dir" attributes all the time during
|
|
|
|
// selector matching for some parts of the UA stylesheet.
|
|
|
|
//
|
|
|
|
// These states are externally managed, because we also don't want to keep
|
|
|
|
// getting "dir" attributes in IntrinsicState.
|
|
|
|
//
|
|
|
|
// Element is HTML and has a "dir" attibute. This state might go away depending
|
|
|
|
// on how https://github.com/whatwg/html/issues/2769 gets resolved. The value
|
|
|
|
// could be anything.
|
|
|
|
#define NS_EVENT_STATE_HAS_DIR_ATTR NS_DEFINE_EVENT_STATE_MACRO(46)
|
|
|
|
// Element is HTML, has a "dir" attribute, and the attribute's value is
|
|
|
|
// case-insensitively equal to "ltr".
|
|
|
|
#define NS_EVENT_STATE_DIR_ATTR_LTR NS_DEFINE_EVENT_STATE_MACRO(47)
|
|
|
|
// Element is HTML, has a "dir" attribute, and the attribute's value is
|
|
|
|
// case-insensitively equal to "rtl".
|
|
|
|
#define NS_EVENT_STATE_DIR_ATTR_RTL NS_DEFINE_EVENT_STATE_MACRO(48)
|
|
|
|
// Element is HTML, and is either a <bdi> element with no valid-valued "dir"
|
|
|
|
// attribute or any HTML element which has a "dir" attribute whose value is
|
|
|
|
// "auto".
|
|
|
|
#define NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO NS_DEFINE_EVENT_STATE_MACRO(49)
|
2017-04-20 12:44:14 +03:00
|
|
|
// Element is filled by Autofill feature.
|
|
|
|
#define NS_EVENT_STATE_AUTOFILL NS_DEFINE_EVENT_STATE_MACRO(50)
|
2017-05-04 08:54:34 +03:00
|
|
|
// Element is filled with preview data by Autofill feature.
|
|
|
|
#define NS_EVENT_STATE_AUTOFILL_PREVIEW NS_DEFINE_EVENT_STATE_MACRO(51)
|
2010-10-20 15:26:32 +04:00
|
|
|
|
2013-01-24 13:30:28 +04:00
|
|
|
// Event state that is used for values that need to be parsed but do nothing.
|
|
|
|
#define NS_EVENT_STATE_IGNORE NS_DEFINE_EVENT_STATE_MACRO(63)
|
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
/**
|
2014-04-03 08:18:36 +04:00
|
|
|
* NOTE: do not go over 63 without updating EventStates::InternalType!
|
2010-10-20 15:26:32 +04:00
|
|
|
*/
|
|
|
|
|
2012-08-10 07:37:58 +04:00
|
|
|
#define DIRECTION_STATES (NS_EVENT_STATE_LTR | NS_EVENT_STATE_RTL)
|
|
|
|
|
2017-06-20 06:24:59 +03:00
|
|
|
#define DIR_ATTR_STATES (NS_EVENT_STATE_HAS_DIR_ATTR | \
|
|
|
|
NS_EVENT_STATE_DIR_ATTR_LTR | \
|
|
|
|
NS_EVENT_STATE_DIR_ATTR_RTL | \
|
|
|
|
NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO)
|
|
|
|
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
#define DISABLED_STATES (NS_EVENT_STATE_DISABLED | NS_EVENT_STATE_ENABLED)
|
|
|
|
|
2017-08-03 08:27:00 +03:00
|
|
|
#define REQUIRED_STATES (NS_EVENT_STATE_REQUIRED | NS_EVENT_STATE_OPTIONAL)
|
|
|
|
|
2017-03-06 05:44:13 +03:00
|
|
|
// Event states that can be added and removed through
|
|
|
|
// Element::{Add,Remove}ManuallyManagedStates.
|
|
|
|
//
|
|
|
|
// Take care when manually managing state bits. You are responsible for
|
|
|
|
// setting or clearing the bit when an Element is added or removed from a
|
|
|
|
// document (e.g. in BindToTree and UnbindFromTree), if that is an
|
|
|
|
// appropriate thing to do for your state bit.
|
|
|
|
#define MANUALLY_MANAGED_STATES ( \
|
2017-05-04 08:54:34 +03:00
|
|
|
NS_EVENT_STATE_AUTOFILL | \
|
|
|
|
NS_EVENT_STATE_AUTOFILL_PREVIEW \
|
2017-03-06 05:44:13 +03:00
|
|
|
)
|
|
|
|
|
2017-03-06 05:44:13 +03:00
|
|
|
// Event states that are managed externally to an element (by the
|
|
|
|
// EventStateManager, or by other code). As opposed to those in
|
|
|
|
// INTRINSIC_STATES, which are are computed by the element itself
|
|
|
|
// and returned from Element::IntrinsicState.
|
|
|
|
#define EXTERNALLY_MANAGED_STATES ( \
|
2017-03-06 05:44:13 +03:00
|
|
|
MANUALLY_MANAGED_STATES | \
|
2017-06-20 06:24:59 +03:00
|
|
|
DIR_ATTR_STATES | \
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
DISABLED_STATES | \
|
2017-08-03 08:27:00 +03:00
|
|
|
REQUIRED_STATES | \
|
2017-03-06 05:44:13 +03:00
|
|
|
NS_EVENT_STATE_ACTIVE | \
|
|
|
|
NS_EVENT_STATE_DRAGOVER | \
|
|
|
|
NS_EVENT_STATE_FOCUS | \
|
|
|
|
NS_EVENT_STATE_FOCUSRING | \
|
|
|
|
NS_EVENT_STATE_FOCUS_WITHIN | \
|
|
|
|
NS_EVENT_STATE_FULL_SCREEN | \
|
|
|
|
NS_EVENT_STATE_HOVER | \
|
|
|
|
NS_EVENT_STATE_UNRESOLVED | \
|
|
|
|
NS_EVENT_STATE_URLTARGET \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define INTRINSIC_STATES (~EXTERNALLY_MANAGED_STATES)
|
2011-06-01 05:46:56 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#endif // mozilla_EventStates_h_
|