Bug 380094 - make mousethrough more generally usefulp=toshok@hungry.comr+sr=roc

This commit is contained in:
asqueella@gmail.com 2007-05-13 09:00:00 -07:00
parent 2c6c566eb7
commit 1f0637ebc5
6 changed files with 33 additions and 108 deletions

View File

@ -3348,6 +3348,35 @@ nsFrame::AttributeChanged(PRInt32 aNameSpaceID,
return NS_OK;
}
PRBool nsFrame::GetMouseThrough() const
{
eMouseThrough mousethrough = unset;
if (mContent) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::never, &nsGkAtoms::always, nsnull};
static const eMouseThrough values[] = {never, always};
PRInt32 index = mContent->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::mousethrough, strings, eCaseMatters);
if (index >= 0) {
mousethrough = values[index];
}
}
switch(mousethrough)
{
case always:
return PR_TRUE;
case never:
return PR_FALSE;
case unset:
if (mParent)
return mParent->GetMouseThrough();
}
return PR_FALSE;
}
// Flow member functions
nsSplittableType

View File

@ -206,6 +206,8 @@ public:
PRInt8 aOutSideLimit
);
PRBool GetMouseThrough() const;
/**
* Find the nearest frame with a mouse capturer. If no
* parent has mouse capture this will return null.

View File

@ -136,8 +136,7 @@ nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
PRBool aIsRoot,
nsIBoxLayout* aLayoutManager) :
nsContainerFrame(aContext),
mMouseThrough(unset)
nsContainerFrame(aContext)
{
mState |= NS_FRAME_IS_BOX;
mState |= NS_STATE_IS_HORIZONTAL;
@ -222,47 +221,12 @@ nsBoxFrame::Init(nsIContent* aContent,
GetDebugPref(GetPresContext());
#endif
mMouseThrough = unset;
UpdateMouseThrough();
// register access key
rv = RegUnregAccessKey(PR_TRUE);
return rv;
}
void nsBoxFrame::UpdateMouseThrough()
{
if (mContent) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::never, &nsGkAtoms::always, nsnull};
static const eMouseThrough values[] = {never, always};
PRInt32 index = mContent->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::mousethrough, strings, eCaseMatters);
if (index >= 0) {
mMouseThrough = values[index];
}
}
}
PRBool
nsBoxFrame::GetMouseThrough() const
{
switch(mMouseThrough)
{
case always:
return PR_TRUE;
case never:
return PR_FALSE;
case unset:
if (mParent && mParent->IsBoxFrame())
return mParent->GetMouseThrough();
}
return PR_FALSE;
}
void
nsBoxFrame::CacheAttributes()
{
@ -1141,7 +1105,6 @@ nsBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
aAttribute == nsGkAtoms::orient ||
aAttribute == nsGkAtoms::pack ||
aAttribute == nsGkAtoms::dir ||
aAttribute == nsGkAtoms::mousethrough ||
aAttribute == nsGkAtoms::equalsize) {
if (aAttribute == nsGkAtoms::align ||
@ -1206,9 +1169,6 @@ nsBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
aAttribute == nsGkAtoms::top) {
mState &= ~NS_STATE_STACK_NOT_POSITIONED;
}
else if (aAttribute == nsGkAtoms::mousethrough) {
UpdateMouseThrough();
}
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);

View File

@ -112,7 +112,6 @@ public:
virtual Halignment GetHAlign() const { return mHalign; }
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
virtual PRBool GetMouseThrough() const;
virtual PRBool ComputesOwnOverflowArea() { return PR_FALSE; }
// ----- child and sibling operations ---
@ -282,7 +281,6 @@ private:
void DrawLine(nsIRenderingContext& aRenderingContext, PRBool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
void FillRect(nsIRenderingContext& aRenderingContext, PRBool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
#endif
void UpdateMouseThrough();
void CacheAttributes();
@ -292,8 +290,6 @@ private:
Halignment mHalign;
Valignment mValign;
eMouseThrough mMouseThrough;
#ifdef DEBUG_LAYOUT
static PRBool gDebug;
static nsIBox* mDebugChild;

View File

@ -73,7 +73,7 @@ NS_NewLeafBoxFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
} // NS_NewLeafBoxFrame
nsLeafBoxFrame::nsLeafBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext)
: nsLeafFrame(aContext), mMouseThrough(unset)
: nsLeafFrame(aContext)
{
mState |= NS_FRAME_IS_BOX;
}
@ -108,59 +108,10 @@ nsLeafBoxFrame::Init(
view->CreateWidget(kWidgetCID);
}
}
mMouseThrough = unset;
UpdateMouseThrough();
return rv;
}
NS_IMETHODIMP
nsLeafBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsresult rv = nsLeafFrame::AttributeChanged(aNameSpaceID, aAttribute,
aModType);
if (aAttribute == nsGkAtoms::mousethrough)
UpdateMouseThrough();
return rv;
}
void nsLeafBoxFrame::UpdateMouseThrough()
{
if (mContent) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::never, &nsGkAtoms::always, nsnull};
switch (mContent->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::mousethrough,
strings, eCaseMatters)) {
case 0: mMouseThrough = never; break;
case 1: mMouseThrough = always; break;
}
}
}
PRBool
nsLeafBoxFrame::GetMouseThrough() const
{
switch (mMouseThrough)
{
case always:
return PR_TRUE;
case never:
return PR_FALSE;
case unset:
if (mParent && mParent->IsBoxFrame())
return mParent->GetMouseThrough();
}
return PR_FALSE;
}
NS_IMETHODIMP
nsLeafBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,

View File

@ -94,11 +94,6 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists);
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
virtual PRBool GetMouseThrough() const;
virtual PRBool ComputesOwnOverflowArea() { return PR_FALSE; }
protected:
@ -116,14 +111,6 @@ protected:
nsLeafBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext);
protected:
eMouseThrough mMouseThrough;
private:
void UpdateMouseThrough();
}; // class nsLeafBoxFrame
#endif /* nsLeafBoxFrame_h___ */