Landing AttributeChanged alteration. AttributeChanged now fires even when the

style hint is REFLOW or VISUAL (and not just CONTENT).
This commit is contained in:
hyatt%netscape.com 1999-09-08 03:51:41 +00:00
Родитель 73ea2cd8bf
Коммит 18be26df3e
11 изменённых файлов: 91 добавлений и 34 удалений

Просмотреть файл

@ -6859,7 +6859,6 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
break;
case NS_STYLE_HINT_REFLOW:
case NS_STYLE_HINT_VISUAL:
break;
case NS_STYLE_HINT_CONTENT:
// let the frame deal with it, since we don't know how to
result = primaryFrame->AttributeChanged(aPresContext, aContent, aAttribute, maxHint);

Просмотреть файл

@ -379,7 +379,8 @@ nsGfxTextControlFrame::AttributeChanged(nsIPresContext* aPresContext,
mEditor->EnableUndo(PR_FALSE); // wipe out undo info
SetTextControlFrameState(value); // set new text value
mEditor->EnableUndo(PR_TRUE); // fire up a new txn stack
nsFormFrame::StyleChangeReflow(aPresContext, this);
if (aHint != NS_STYLE_HINT_REFLOW)
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
else if (nsHTMLAtoms::maxlength == aAttribute)
{
@ -447,7 +448,7 @@ nsGfxTextControlFrame::AttributeChanged(nsIPresContext* aPresContext,
}
mEditor->SetFlags(flags);
}
else if (nsHTMLAtoms::size == aAttribute) {
else if (nsHTMLAtoms::size == aAttribute && aHint != NS_STYLE_HINT_REFLOW) {
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
// Allow the base class to handle common attributes supported

Просмотреть файл

@ -57,9 +57,11 @@ nsNativeButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
/*XXXnsresult result = */GetValue(&value);
button->SetLabel(value);
NS_RELEASE(button);
nsFormFrame::StyleChangeReflow(aPresContext, this);
if (aHint != NS_STYLE_HINT_REFLOW)
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
} else if (nsHTMLAtoms::size == aAttribute) {
} else if (nsHTMLAtoms::size == aAttribute &&
aHint != NS_STYLE_HINT_REFLOW) {
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
// Allow the base class to handle common attributes supported

Просмотреть файл

@ -158,7 +158,8 @@ nsNativeTextControlFrame::AttributeChanged(nsIPresContext* aPresContext,
/*XXXnsresult rv = */GetText(&value, PR_TRUE);
PRUint32 ignore;
text->SetText(value, ignore);
nsFormFrame::StyleChangeReflow(aPresContext, this);
if (aHint != NS_STYLE_HINT_REFLOW)
nsFormFrame::StyleChangeReflow(aPresContext, this);
} else if (nsHTMLAtoms::maxlength == aAttribute) {
PRInt32 maxLength;
nsresult rv = GetMaxLength(&maxLength);
@ -169,7 +170,8 @@ nsNativeTextControlFrame::AttributeChanged(nsIPresContext* aPresContext,
PRBool oldReadOnly;
text->SetReadOnly(nsFormFrame::GetReadonly(this),oldReadOnly);
}
else if (nsHTMLAtoms::size == aAttribute) {
else if (nsHTMLAtoms::size == aAttribute &&
aHint != NS_STYLE_HINT_REFLOW) {
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
// Allow the base class to handle common attributes supported

Просмотреть файл

@ -6859,7 +6859,6 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
break;
case NS_STYLE_HINT_REFLOW:
case NS_STYLE_HINT_VISUAL:
break;
case NS_STYLE_HINT_CONTENT:
// let the frame deal with it, since we don't know how to
result = primaryFrame->AttributeChanged(aPresContext, aContent, aAttribute, maxHint);

Просмотреть файл

@ -373,8 +373,40 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
}
}
NS_IMETHODIMP
nsMenuFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute,
PRInt32 aHint)
{
if (aAttribute == nsXULAtoms::open) {
nsAutoString openVal;
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(aChild);
domElement->GetAttribute("open", openVal);
if (openVal == "true")
OpenMenuInternal(PR_TRUE);
else OpenMenuInternal(PR_FALSE);
}
return NS_OK;
}
void
nsMenuFrame::OpenMenu(PRBool aActivateFlag)
{
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mContent);
if (aActivateFlag) {
// Now that the menu is opened, we should have a menupopup child built.
// Mark it as generated, which ensures a frame gets built.
MarkAsGenerated();
domElement->SetAttribute("open", "true");
}
else domElement->RemoveAttribute("open");
}
void
nsMenuFrame::OpenMenu(PRBool aActivateFlag)
nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
{
gEatMouseMove = PR_TRUE;
@ -386,12 +418,7 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
if (!OnCreate())
return;
// Open the menu.
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mContent);
domElement->SetAttribute("open", "true");
// Now that the menu is opened, we should have a menupopup child built.
// Mark it as generated, which ensures a frame gets built.
// XXX Only have this here because of RDF-generated content.
MarkAsGenerated();
nsIFrame* frame = mPopupFrames.FirstChild();
@ -428,9 +455,6 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
ActivateMenu(PR_FALSE);
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mContent);
domElement->RemoveAttribute("open");
mMenuOpen = PR_FALSE;
// Set the focus back to our view's widget.
@ -958,7 +982,15 @@ nsMenuFrame::OnCreate()
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_CREATE;
nsresult rv = mContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv;
if (child)
rv = child->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
else rv = mContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
return PR_TRUE;
@ -971,7 +1003,15 @@ nsMenuFrame::OnDestroy()
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_DESTROY;
nsresult rv = mContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv;
if (child)
rv = child->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
else rv = mContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
return PR_TRUE;

Просмотреть файл

@ -114,7 +114,9 @@ public:
void ToggleMenuState();
void SelectMenu(PRBool aActivateFlag);
void OpenMenu(PRBool aActivateFlag);
void ActivateMenu(PRBool aActivateFlag);
PRBool IsMenu();
@ -132,6 +134,7 @@ public:
PRBool IsGenerated();
protected:
void OpenMenuInternal(PRBool aActivateFlag);
void GetMenuChildrenElement(nsIContent** aResult);
// Called to split the accesskey attribute up based on the specified string.
@ -149,6 +152,11 @@ protected:
// Called as a hook just before the menu goes away.
PRBool OnDestroy();
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute,
PRInt32 aHint);
protected:
nsFrameList mPopupFrames;
PRBool mIsMenu; // Whether or not we can even have children or not.

Просмотреть файл

@ -690,7 +690,9 @@ nsProgressMeterFrame::AttributeChanged(nsIPresContext* aPresContext,
setMode(newValue);
// needs to reflow so we start the timer.
Reflow(aPresContext);
if (aHint != NS_STYLE_HINT_REFLOW)
Reflow(aPresContext);
} else if (nsHTMLAtoms::align == aAttribute) {
nsAutoString newValue;
@ -698,8 +700,8 @@ nsProgressMeterFrame::AttributeChanged(nsIPresContext* aPresContext,
aChild->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, newValue);
setAlignment(newValue);
Reflow(aPresContext);
if (aHint != NS_STYLE_HINT_REFLOW)
Reflow(aPresContext);
}
return NS_OK;

Просмотреть файл

@ -190,9 +190,10 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext,
// if the current position changes
if (aAttribute == nsXULAtoms::curpos) {
CurrentPositionChanged(aPresContext);
} else if (aAttribute == nsXULAtoms::maxpos ||
} else if ((aHint != NS_STYLE_HINT_REFLOW) &&
(aAttribute == nsXULAtoms::maxpos ||
aAttribute == nsXULAtoms::pageincrement ||
aAttribute == nsXULAtoms::increment) {
aAttribute == nsXULAtoms::increment)) {
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));

Просмотреть файл

@ -155,17 +155,20 @@ nsTitledButtonFrame::AttributeChanged(nsIPresContext* aPresContext,
mNeedsLayout = PR_TRUE;
UpdateAttributes(*aPresContext);
#if 1 // added back in because boxes now handle only redraw what is reflowed.
// added back in because boxes now handle only redraw what is reflowed.
// reflow
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIReflowCommand> reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
#endif
if (aHint != NS_STYLE_HINT_REFLOW &&
(aAttribute == nsHTMLAtoms::align || aAttribute == nsHTMLAtoms::value ||
aAttribute == nsHTMLAtoms::src || aAttribute == nsXULAtoms::crop)) {
nsCOMPtr<nsIReflowCommand> reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
}
// redraw
mRenderer.Redraw();

Просмотреть файл

@ -252,10 +252,10 @@ nsTreeRowFrame::GetCursor(nsIPresContext& aPresContext,
nsRect rect;
GetRect(rect);
if (rect.x > aPoint.x || (rect.x+rect.width < aPoint.x)) {
aCursor = NS_STYLE_CURSOR_W_RESIZE;
aCursor = NS_STYLE_CURSOR_DEFAULT;
}
else {
aCursor = NS_STYLE_CURSOR_DEFAULT;
aCursor = NS_STYLE_CURSOR_W_RESIZE;
}
}
else aCursor = NS_STYLE_CURSOR_DEFAULT;