зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598833 part 1. Move IntrinsicState from nsIContent to Element. r=smaug
This commit is contained in:
Родитель
c91fa35aba
Коммит
f137314503
|
@ -694,20 +694,23 @@ PRUint64
|
|||
nsAccessible::NativeState()
|
||||
{
|
||||
PRUint64 state = 0;
|
||||
nsEventStates intrinsicState = mContent->IntrinsicState();
|
||||
PRBool disabled = PR_FALSE;
|
||||
if (mContent->IsElement()) {
|
||||
nsEventStates intrinsicState = mContent->AsElement()->IntrinsicState();
|
||||
|
||||
if (intrinsicState.HasState(NS_EVENT_STATE_INVALID))
|
||||
state |= states::INVALID;
|
||||
if (intrinsicState.HasState(NS_EVENT_STATE_INVALID))
|
||||
state |= states::INVALID;
|
||||
|
||||
if (intrinsicState.HasState(NS_EVENT_STATE_REQUIRED))
|
||||
state |= states::REQUIRED;
|
||||
if (intrinsicState.HasState(NS_EVENT_STATE_REQUIRED))
|
||||
state |= states::REQUIRED;
|
||||
|
||||
PRBool disabled = mContent->IsHTML() ?
|
||||
(intrinsicState.HasState(NS_EVENT_STATE_DISABLED)) :
|
||||
(mContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsAccessibilityAtoms::disabled,
|
||||
nsAccessibilityAtoms::_true,
|
||||
eCaseMatters));
|
||||
disabled = mContent->IsHTML() ?
|
||||
(intrinsicState.HasState(NS_EVENT_STATE_DISABLED)) :
|
||||
(mContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsAccessibilityAtoms::disabled,
|
||||
nsAccessibilityAtoms::_true,
|
||||
eCaseMatters));
|
||||
}
|
||||
|
||||
// Set unavailable state based on disabled state, otherwise set focus states
|
||||
if (disabled) {
|
||||
|
|
|
@ -81,7 +81,7 @@ nsHTMLLinkAccessible::NativeState()
|
|||
states |= states::SELECTABLE;
|
||||
}
|
||||
|
||||
nsEventStates state = mContent->IntrinsicState();
|
||||
nsEventStates state = mContent->AsElement()->IntrinsicState();
|
||||
if (state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED)) {
|
||||
states |= states::LINKED;
|
||||
|
@ -187,7 +187,7 @@ nsHTMLLinkAccessible::IsLinked()
|
|||
if (IsDefunct())
|
||||
return PR_FALSE;
|
||||
|
||||
nsEventStates state = mContent->IntrinsicState();
|
||||
nsEventStates state = mContent->AsElement()->IntrinsicState();
|
||||
return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED);
|
||||
}
|
||||
|
|
|
@ -86,6 +86,14 @@ public:
|
|||
#ifdef MOZILLA_INTERNAL_API
|
||||
Element(already_AddRefed<nsINodeInfo> aNodeInfo) : nsIContent(aNodeInfo) {}
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this element. This is the
|
||||
* state that is independent of the element's presentation. To get the full
|
||||
* content state, use nsEventStateManager. See nsEventStates.h for
|
||||
* the possible bits that could be set here.
|
||||
*/
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -76,8 +76,8 @@ enum nsLinkState {
|
|||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x32b94ba0, 0x1ebc, 0x4dfc, \
|
||||
{ 0xba, 0x8c, 0x5f, 0x24, 0x2b, 0xcb, 0xaf, 0xce } }
|
||||
{ 0xba1c9e22, 0x4b73, 0x42ae, \
|
||||
{ 0xb6, 0x45, 0xa7, 0x83, 0xd0, 0x7e, 0xee, 0x2c } }
|
||||
|
||||
/**
|
||||
* A node of content in a document's content model. This interface
|
||||
|
@ -786,14 +786,6 @@ public:
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this content node. This is
|
||||
* the state that is independent of the node's presentation. To get the full
|
||||
* content state, use nsEventStateManager. Also see nsEventStateManager
|
||||
* for the possible bits that could be set here.
|
||||
*/
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
|
||||
/**
|
||||
* Get the ID of this content node (the atom corresponding to the
|
||||
* value of the null-namespace attribute whose name is given by
|
||||
|
|
|
@ -786,7 +786,7 @@ nsINode::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
nsEventStates
|
||||
nsIContent::IntrinsicState() const
|
||||
Element::IntrinsicState() const
|
||||
{
|
||||
return IsEditable() ? NS_EVENT_STATE_MOZ_READWRITE :
|
||||
NS_EVENT_STATE_MOZ_READONLY;
|
||||
|
|
|
@ -238,7 +238,6 @@ nsTextNode::List(FILE* out, PRInt32 aIndent) const
|
|||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Text@%p", static_cast<const void*>(this));
|
||||
fprintf(out, " intrinsicstate=[%llx]", IntrinsicState().GetInternalValue());
|
||||
fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
|
||||
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
|
||||
fprintf(out, " refcount=%d<", mRefCnt.get());
|
||||
|
|
|
@ -4240,7 +4240,10 @@ ShouldShowFocusRing(nsIContent* aContent)
|
|||
nsEventStates
|
||||
nsEventStateManager::GetContentState(nsIContent *aContent)
|
||||
{
|
||||
nsEventStates state = aContent->IntrinsicState();
|
||||
nsEventStates state;
|
||||
if (aContent->IsElement()) {
|
||||
state = aContent->AsElement()->IntrinsicState();
|
||||
}
|
||||
|
||||
if (IsAncestorOf(aContent, mActiveContent)) {
|
||||
state |= NS_EVENT_STATE_ACTIVE;
|
||||
|
|
|
@ -3543,19 +3543,29 @@ nsGenericHTMLElement::IsEditableRoot() const
|
|||
static void
|
||||
MakeContentDescendantsEditable(nsIContent *aContent, nsIDocument *aDocument)
|
||||
{
|
||||
nsEventStates stateBefore = aContent->IntrinsicState();
|
||||
// If aContent is not an element, we just need to update its
|
||||
// internal editable state and don't need to notify anyone about
|
||||
// that. For elements, we need to send a ContentStateChanged
|
||||
// notification.
|
||||
if (!aContent->IsElement()) {
|
||||
aContent->UpdateEditableState();
|
||||
return;
|
||||
}
|
||||
|
||||
aContent->UpdateEditableState();
|
||||
Element *element = aContent->AsElement();
|
||||
nsEventStates stateBefore = element->IntrinsicState();
|
||||
|
||||
if (aDocument && stateBefore != aContent->IntrinsicState()) {
|
||||
aDocument->ContentStateChanged(aContent,
|
||||
element->UpdateEditableState();
|
||||
|
||||
if (aDocument && stateBefore != element->IntrinsicState()) {
|
||||
aDocument->ContentStateChanged(element,
|
||||
NS_EVENT_STATE_MOZ_READONLY |
|
||||
NS_EVENT_STATE_MOZ_READWRITE);
|
||||
}
|
||||
|
||||
PRUint32 i, n = aContent->GetChildCount();
|
||||
for (i = 0; i < n; ++i) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
for (nsIContent *child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (!child->HasAttr(kNameSpaceID_None, nsGkAtoms::contenteditable)) {
|
||||
MakeContentDescendantsEditable(child, aDocument);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ nsButtonFrameRenderer::isDisabled()
|
|||
{
|
||||
// NOTE: we might want to remove this method to prevent calling too often
|
||||
// IntrinsicState().
|
||||
return mFrame->GetContent()->IntrinsicState().HasState(NS_EVENT_STATE_DISABLED);
|
||||
return mFrame->GetContent()->AsElement()->
|
||||
IntrinsicState().HasState(NS_EVENT_STATE_DISABLED);
|
||||
}
|
||||
|
||||
class nsDisplayButtonBoxShadowOuter : public nsDisplayItem {
|
||||
|
|
|
@ -749,7 +749,7 @@ nsComboboxControlFrame::GetFrameName(nsAString& aResult) const
|
|||
void
|
||||
nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
||||
{
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
return;
|
||||
}
|
||||
|
@ -949,7 +949,7 @@ nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1405,7 +1405,7 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
|
|||
nsPoint aPt)
|
||||
{
|
||||
/* Do we need to do anything? */
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || mFocused != this)
|
||||
return;
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ nsFileControlFrame::SyncAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
|||
void
|
||||
nsFileControlFrame::SyncDisabledState()
|
||||
{
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
||||
PR_TRUE);
|
||||
|
@ -704,7 +704,7 @@ nsFileControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
// Disabled file controls don't pass mouse events to their children, so we
|
||||
// put an invisible item in the display list above the children
|
||||
// just to catch events
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) && IsVisibleForPainting(aBuilder)) {
|
||||
rv = aLists.Content()->AppendNewToTop(
|
||||
new (aBuilder) nsDisplayEventReceiver(aBuilder, this));
|
||||
|
|
|
@ -1074,7 +1074,7 @@ nsListControlFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED))
|
||||
return NS_OK;
|
||||
|
||||
|
@ -1915,7 +1915,7 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
|
|||
|
||||
mButtonDown = PR_FALSE;
|
||||
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2124,7 +2124,7 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
|||
|
||||
UpdateInListState(aMouseEvent);
|
||||
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2431,7 +2431,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
{
|
||||
NS_ASSERTION(aKeyEvent, "keyEvent is null.");
|
||||
|
||||
nsEventStates eventStates = mContent->IntrinsicState();
|
||||
nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED))
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ using namespace mozilla;
|
|||
#define ALIGN_UNSET PRUint8(-1)
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
// static icon information
|
||||
nsImageFrame::IconLoad* nsImageFrame::gIconLoad = nsnull;
|
||||
|
@ -472,10 +473,10 @@ nsImageFrame::SourceRectToDest(const nsIntRect& aRect)
|
|||
|
||||
/* static */
|
||||
PRBool
|
||||
nsImageFrame::ShouldCreateImageFrameFor(nsIContent* aContent,
|
||||
nsImageFrame::ShouldCreateImageFrameFor(Element* aElement,
|
||||
nsStyleContext* aStyleContext)
|
||||
{
|
||||
nsEventStates state = aContent->IntrinsicState();
|
||||
nsEventStates state = aElement->IntrinsicState();
|
||||
if (IMAGE_OK(state,
|
||||
HaveFixedSize(aStyleContext->GetStylePosition()))) {
|
||||
// Image is fine; do the image frame thing
|
||||
|
@ -509,12 +510,12 @@ nsImageFrame::ShouldCreateImageFrameFor(nsIContent* aContent,
|
|||
else {
|
||||
// We are in quirks mode, so we can just check the tag name; no need to
|
||||
// check the namespace.
|
||||
nsIAtom *localName = aContent->NodeInfo()->NameAtom();
|
||||
nsIAtom *localName = aElement->Tag();
|
||||
|
||||
// Use a sized box if we have no alt text. This means no alt attribute
|
||||
// and the node is not an object or an input (since those always have alt
|
||||
// text).
|
||||
if (!aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::alt) &&
|
||||
if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::alt) &&
|
||||
localName != nsGkAtoms::object &&
|
||||
localName != nsGkAtoms::input) {
|
||||
useSizedBox = PR_TRUE;
|
||||
|
@ -1163,9 +1164,10 @@ static void PaintAltFeedback(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
|||
const nsRect& aDirtyRect, nsPoint aPt)
|
||||
{
|
||||
nsImageFrame* f = static_cast<nsImageFrame*>(aFrame);
|
||||
nsEventStates state = f->GetContent()->AsElement()->IntrinsicState();
|
||||
f->DisplayAltFeedback(*aCtx,
|
||||
aDirtyRect,
|
||||
IMAGE_OK(f->GetContent()->IntrinsicState(), PR_TRUE)
|
||||
IMAGE_OK(state, PR_TRUE)
|
||||
? nsImageFrame::gIconLoad->mLoadingImage
|
||||
: nsImageFrame::gIconLoad->mBrokenImage,
|
||||
aPt);
|
||||
|
@ -1326,7 +1328,7 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
getter_AddRefs(currentRequest));
|
||||
}
|
||||
|
||||
nsEventStates contentState = mContent->IntrinsicState();
|
||||
nsEventStates contentState = mContent->AsElement()->IntrinsicState();
|
||||
PRBool imageOK = IMAGE_OK(contentState, PR_TRUE);
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
* should get an image frame. Note that this method is only used by the
|
||||
* frame constructor; it's only here because it uses gIconLoad for now.
|
||||
*/
|
||||
static PRBool ShouldCreateImageFrameFor(nsIContent* aContent,
|
||||
static PRBool ShouldCreateImageFrameFor(mozilla::dom::Element* aElement,
|
||||
nsStyleContext* aStyleContext);
|
||||
|
||||
void DisplayAltFeedback(nsRenderingContext& aRenderingContext,
|
||||
|
|
Загрузка…
Ссылка в новой задаче