Bug 745535 - Implement AttributeChanged on nsMathMLmactionFrame. r=karlt

This commit is contained in:
Andrii Zui 2012-05-18 13:35:43 -04:00
Родитель 81f2bec769
Коммит c2a63c0b43
2 изменённых файлов: 64 добавлений и 23 удалений

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

@ -71,6 +71,25 @@
#define NS_MATHML_ACTION_TYPE_TOOLTIP 3 // unsupported
// helper function to parse actiontype attribute
static PRInt32
GetActionType(nsIContent* aContent)
{
nsAutoString value;
if (aContent)
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::actiontype_, value);
if (value.EqualsLiteral("toggle"))
return NS_MATHML_ACTION_TYPE_TOGGLE;
if (value.EqualsLiteral("statusline"))
return NS_MATHML_ACTION_TYPE_STATUSLINE;
if (value.EqualsLiteral("tooltip"))
return NS_MATHML_ACTION_TYPE_TOOLTIP;
return NS_MATHML_ACTION_TYPE_NONE;
}
nsIFrame*
NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
@ -98,34 +117,12 @@ nsMathMLmactionFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsAutoString value, prefix;
// Init our local attributes
mChildCount = -1; // these will be updated in GetSelectedFrame()
mSelection = 0;
mSelectedFrame = nsnull;
nsRefPtr<nsStyleContext> newStyleContext;
mActionType = NS_MATHML_ACTION_TYPE_NONE;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::actiontype_, value);
if (!value.IsEmpty()) {
if (value.EqualsLiteral("toggle"))
mActionType = NS_MATHML_ACTION_TYPE_TOGGLE;
// XXX use goto to jump out of these if?
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
// expected tooltip prefix (8ch)...
if (8 < value.Length() && 0 == value.Find("tooltip#"))
mActionType = NS_MATHML_ACTION_TYPE_TOOLTIP;
}
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
if (value.EqualsLiteral("statusline"))
mActionType = NS_MATHML_ACTION_TYPE_STATUSLINE;
}
}
mActionType = GetActionType(aContent);
// Let the base class do the rest
return nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
@ -247,6 +244,45 @@ nsMathMLmactionFrame::SetInitialChildList(ChildListID aListID,
return rv;
}
NS_IMETHODIMP
nsMathMLmactionFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
bool needsReflow = false;
if (aAttribute == nsGkAtoms::actiontype_) {
// updating mActionType ...
PRInt32 oldActionType = mActionType;
mActionType = GetActionType(mContent);
// We have to initiate a reflow only when changing actiontype
// from toggle or to toggle.
if (oldActionType == NS_MATHML_ACTION_TYPE_TOGGLE ||
mActionType == NS_MATHML_ACTION_TYPE_TOGGLE) {
needsReflow = true;
}
} else if (aAttribute == nsGkAtoms::selection_) {
// When the selection attribute is changed we have to initiate a reflow
// only when actiontype is toggle.
if (NS_MATHML_ACTION_TYPE_TOGGLE == mActionType) {
needsReflow = true;
}
} else {
// let the base class handle other attribute changes
return
nsMathMLContainerFrame::AttributeChanged(aNameSpaceID,
aAttribute, aModType);
}
if (needsReflow) {
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
}
return NS_OK;
}
// Only paint the selected child...
NS_IMETHODIMP
nsMathMLmactionFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,

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

@ -83,6 +83,11 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
private:
void MouseClick();
void MouseOver();