Bug 108310. Make GetFrameForPoint take frame-relative coordinates, not bogus relative-to-some-view-or-other, and simplify the signature. r+sr=roc, patch by Eli Friedman.

This commit is contained in:
roc+%cs.cmu.edu 2005-09-19 02:15:54 +00:00
parent 4f4b8670f4
commit fed343c43a
70 changed files with 476 additions and 660 deletions

View File

@ -5960,31 +5960,19 @@ PresShell::HandleEvent(nsIView *aView,
aHandled = PR_FALSE; aHandled = PR_FALSE;
rv = NS_OK; rv = NS_OK;
} else { } else {
rv = NS_OK;
nsPoint eventPoint; nsPoint eventPoint;
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame); eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
// XXX Until GetFrameForPoint is cleaned up, we need to account for the
// weird input the function takes. These adjustments counteract the
// adjustments GetFrameForPoint makes.
eventPoint += frame->GetPosition();
nsPoint originOffset;
nsIView *view = nsnull;
frame->GetOriginToViewOffset(originOffset, &view);
NS_ASSERTION(view == aView, "view != aView");
if (view == aView)
eventPoint -= originOffset;
rv = frame->GetFrameForPoint(eventPoint, mCurrentEventFrame = frame->GetFrameForPoint(eventPoint,
NS_FRAME_PAINT_LAYER_FOREGROUND, NS_FRAME_PAINT_LAYER_FOREGROUND);
&mCurrentEventFrame); if (!mCurrentEventFrame) {
if (NS_FAILED(rv)) { mCurrentEventFrame = frame->GetFrameForPoint(eventPoint,
rv = frame->GetFrameForPoint(eventPoint, NS_FRAME_PAINT_LAYER_FLOATS);
NS_FRAME_PAINT_LAYER_FLOATS, if (!mCurrentEventFrame) {
&mCurrentEventFrame); mCurrentEventFrame = frame->GetFrameForPoint(eventPoint,
if (NS_FAILED(rv)) { NS_FRAME_PAINT_LAYER_BACKGROUND);
rv = frame->GetFrameForPoint(eventPoint, if (!mCurrentEventFrame) {
NS_FRAME_PAINT_LAYER_BACKGROUND,
&mCurrentEventFrame);
if (NS_FAILED (rv)) {
if (aForceHandle) { if (aForceHandle) {
mCurrentEventFrame = frame; mCurrentEventFrame = frame;
} }
@ -5992,7 +5980,6 @@ PresShell::HandleEvent(nsIView *aView,
mCurrentEventFrame = nsnull; mCurrentEventFrame = nsnull;
} }
aHandled = PR_FALSE; aHandled = PR_FALSE;
rv = NS_OK;
} }
} }
} }

View File

@ -1633,10 +1633,9 @@ nsComboboxControlFrame::GetName(nsAString* aResult)
return nsFormControlHelper::GetName(mContent, aResult); return nsFormControlHelper::GetName(mContent, aResult);
} }
NS_IMETHODIMP nsIFrame*
nsComboboxControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsComboboxControlFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// The button is getting the hover events so... // The button is getting the hover events so...
// None of the children frames of the combobox get // None of the children frames of the combobox get
@ -1654,14 +1653,7 @@ nsComboboxControlFrame::GetFrameForPoint(const nsPoint& aPoint,
// Now the functionality of the OPTIONs depends on the SELECT // Now the functionality of the OPTIONs depends on the SELECT
// being visible. Oh well... // being visible. Oh well...
if ( mRect.Contains(aPoint) && return nsFrame::GetFrameForPoint(aPoint, aWhichLayer);
(aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) ) {
if (GetStyleVisibility()->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
} }

View File

@ -138,7 +138,8 @@ public:
nsIFrame* aChildList); nsIFrame* aChildList);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const; virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer);
virtual nsIFrame* GetContentInsertionFrame(); virtual nsIFrame* GetContentInsertionFrame();

View File

@ -98,9 +98,8 @@ public:
nsIFrame* aOldFrame, nsIFrame* aOldFrame,
nsIFrame* aNewFrame); nsIFrame* aNewFrame);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
virtual nsIAtom* GetType() const; virtual nsIAtom* GetType() const;
virtual PRBool IsContainingBlock() const; virtual PRBool IsContainingBlock() const;
@ -666,13 +665,13 @@ nsFieldSetFrame::ReplaceFrame(nsIAtom* aListName,
return mContentFrame->ReplaceFrame(aListName, aOldFrame, aNewFrame); return mContentFrame->ReplaceFrame(aListName, aOldFrame, aNewFrame);
} }
NS_IMETHODIMP nsIFrame*
nsFieldSetFrame::GetFrameForPoint(const nsPoint& aPoint, nsFieldSetFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY

View File

@ -578,22 +578,21 @@ nsFileControlFrame::IsLeaf() const
return PR_TRUE; return PR_TRUE;
} }
NS_IMETHODIMP nsIFrame*
nsFileControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsFileControlFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
#ifndef DEBUG_NEWFRAME #ifndef DEBUG_NEWFRAME
if ( nsFormControlHelper::GetDisabled(mContent) && mRect.Contains(aPoint) ) { nsRect thisRect(nsPoint(0,0), GetSize());
if (nsFormControlHelper::GetDisabled(mContent) && thisRect.Contains(aPoint)) {
if (GetStyleVisibility()->IsVisible()) { if (GetStyleVisibility()->IsVisible()) {
*aFrame = this; return this;
return NS_OK;
} }
} else { } else {
return nsAreaFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsAreaFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
#endif #endif
return NS_ERROR_FAILURE; return nsnull;
} }
#ifdef NS_DEBUG #ifdef NS_DEBUG

View File

@ -93,7 +93,8 @@ public:
NS_IMETHOD GetFrameName(nsAString& aResult) const; NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif #endif
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) { return NS_OK; }; NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) { return NS_OK; };
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute, nsIAtom* aAttribute,
PRInt32 aModType); PRInt32 aModType);

View File

@ -431,25 +431,24 @@ nsFormControlFrame::Paint(nsPresContext* aPresContext,
return rv; return rv;
} }
NS_IMETHODIMP nsIFrame*
nsFormControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsFormControlFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsresult rv = NS_ERROR_FAILURE; nsIFrame* frame = nsnull;
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) {
rv = nsLeafFrame::GetFrameForPoint(aPoint, frame = nsLeafFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_FOREGROUND, aFrame); NS_FRAME_PAINT_LAYER_FOREGROUND);
if (NS_SUCCEEDED(rv)) if (frame)
return NS_OK; return frame;
rv = nsLeafFrame::GetFrameForPoint(aPoint, frame = nsLeafFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_FLOATS, aFrame); NS_FRAME_PAINT_LAYER_FLOATS);
if (NS_SUCCEEDED(rv)) if (frame)
return NS_OK; return frame;
rv = nsLeafFrame::GetFrameForPoint(aPoint, frame = nsLeafFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_BACKGROUND, aFrame); NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
return rv; return frame;
} }
void void

View File

@ -114,9 +114,8 @@ public:
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext, NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
nsIAtom* aListName, nsIAtom* aListName,

View File

@ -278,19 +278,16 @@ nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
} }
NS_IMETHODIMP nsIFrame*
nsHTMLButtonControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsHTMLButtonControlFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsRect thisRect(nsPoint(0,0), GetSize());
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND && if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
mRect.Contains(aPoint)) { thisRect.Contains(aPoint) && GetStyleVisibility()->IsVisible()) {
if (GetStyleVisibility()->IsVisible()) { return this;
*aFrame = this;
return NS_OK;
}
} }
return NS_ERROR_FAILURE; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -85,7 +85,8 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext, NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
nsIAtom* aListName, nsIAtom* aListName,

View File

@ -102,32 +102,31 @@ nsSelectsAreaFrame::IsOptionElementFrame(nsIFrame *aFrame)
} }
//--------------------------------------------------------- //---------------------------------------------------------
NS_IMETHODIMP nsIFrame*
nsSelectsAreaFrame::GetFrameForPoint(const nsPoint& aPoint, nsSelectsAreaFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsRect thisRect(nsPoint(0,0), GetSize());
PRBool inThisFrame = thisRect.Contains(aPoint);
PRBool inThisFrame = mRect.Contains(aPoint); if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame)) {
return nsnull;
if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame )) {
return NS_ERROR_FAILURE;
} }
nsresult result = nsAreaFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); nsIFrame* frame = nsAreaFrame::GetFrameForPoint(aPoint, aWhichLayer);
if (result == NS_OK) { if (frame) {
nsIFrame* selectedFrame = *aFrame; nsIFrame* selectedFrame = frame;
while (selectedFrame && !IsOptionElementFrame(selectedFrame)) { while (selectedFrame && !IsOptionElementFrame(selectedFrame)) {
selectedFrame = selectedFrame->GetParent(); selectedFrame = selectedFrame->GetParent();
} }
if (selectedFrame) { if (selectedFrame) {
*aFrame = selectedFrame; return selectedFrame;
} }
// else, keep the original result as *aFrame, which could be this frame // else, keep the original result as *aFrame, which could be this frame
} }
return result; return frame;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -54,7 +54,8 @@ public:
// nsISupports // nsISupports
//NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); //NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD Paint(nsPresContext* aPresContext, NS_IMETHOD Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,

View File

@ -2096,25 +2096,24 @@ nsTextControlFrame::Paint(nsPresContext* aPresContext,
return rv; return rv;
} }
NS_IMETHODIMP nsIFrame*
nsTextControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsTextControlFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsresult rv = NS_ERROR_FAILURE; nsIFrame* frame = nsnull;
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) {
rv = nsStackFrame::GetFrameForPoint(aPoint, frame = nsStackFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_FOREGROUND, aFrame); NS_FRAME_PAINT_LAYER_FOREGROUND);
if (NS_SUCCEEDED(rv)) if (frame)
return NS_OK; return frame;
rv = nsStackFrame::GetFrameForPoint(aPoint, frame = nsStackFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_FLOATS, aFrame); NS_FRAME_PAINT_LAYER_FLOATS);
if (NS_SUCCEEDED(rv)) if (frame)
return NS_OK; return frame;
rv = nsStackFrame::GetFrameForPoint(aPoint, frame = nsStackFrame::GetFrameForPoint(aPoint,
NS_FRAME_PAINT_LAYER_BACKGROUND, aFrame); NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
return rv; return frame;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -89,9 +89,8 @@ public:
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,

View File

@ -6736,56 +6736,46 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) {
return cursor.get(); return cursor.get();
} }
static inline void static inline nsIFrame*
GetFrameFromLine(const nsRect& aLineArea, const nsPoint& aTmp, GetFrameFromLine(nsIFrame* aBlock, const nsRect& aLineArea, const nsPoint& aTmp,
nsBlockFrame::line_iterator& aLine, nsBlockFrame::line_iterator& aLine,
nsFramePaintLayer aWhichLayer, nsIFrame** aFrame) { nsFramePaintLayer aWhichLayer) {
nsIFrame* frame = nsnull;
if (aLineArea.Contains(aTmp)) { if (aLineArea.Contains(aTmp)) {
nsIFrame* kid = aLine->mFirstChild; nsIFrame* kid = aLine->mFirstChild;
PRInt32 n = aLine->GetChildCount(); PRInt32 n = aLine->GetChildCount();
while (--n >= 0) { while (--n >= 0) {
nsIFrame *hit; nsIFrame *hit = kid->GetFrameForPoint(aTmp - kid->GetOffsetTo(aBlock),
nsresult rv = kid->GetFrameForPoint(aTmp, aWhichLayer, &hit); aWhichLayer);
if (hit)
if (NS_SUCCEEDED(rv) && hit) { frame = hit;
*aFrame = hit;
}
kid = kid->GetNextSibling(); kid = kid->GetNextSibling();
} }
} }
return frame;
} }
// Optimized function that uses line combined areas to skip lines // Optimized function that uses line combined areas to skip lines
// we know can't contain the point // we know can't contain the point
nsresult nsIFrame*
nsBlockFrame::GetFrameForPointUsing(const nsPoint& aPoint, nsBlockFrame::GetFrameForPointUsing(const nsPoint& aPoint,
nsIAtom* aList, nsIAtom* aList,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf, PRBool aConsiderSelf)
nsIFrame** aFrame)
{ {
if (aList) { if (aList)
return nsContainerFrame::GetFrameForPointUsing(aPoint, return nsContainerFrame::GetFrameForPointUsing(aPoint, aList, aWhichLayer,
aList, aWhichLayer, aConsiderSelf, aFrame); aConsiderSelf);
nsRect thisRect(nsPoint(0,0), GetSize());
nsIFrame* frame = nsnull;
PRBool inThisFrame = thisRect.Contains(aPoint);
if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame)) {
return nsnull;
} }
PRBool inThisFrame = mRect.Contains(aPoint); nsLineBox* cursor = GetFirstLineContaining(aPoint.y);
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
return NS_ERROR_FAILURE;
}
*aFrame = nsnull;
nsPoint tmp(aPoint.x - mRect.x, aPoint.y - mRect.y);
nsPoint originOffset;
nsIView *view = nsnull;
nsresult rv = GetOriginToViewOffset(originOffset, &view);
if (NS_SUCCEEDED(rv) && view)
tmp += originOffset;
nsLineBox* cursor = GetFirstLineContaining(tmp.y);
line_iterator line_end = end_lines(); line_iterator line_end = end_lines();
if (cursor) { if (cursor) {
@ -6797,10 +6787,13 @@ nsBlockFrame::GetFrameForPointUsing(const nsPoint& aPoint,
// Because we have a cursor, the combinedArea.ys are non-decreasing. // Because we have a cursor, the combinedArea.ys are non-decreasing.
// Once we've passed tmp.y, we can never see it again. // Once we've passed tmp.y, we can never see it again.
if (!lineArea.IsEmpty()) { if (!lineArea.IsEmpty()) {
if (lineArea.y > tmp.y) { if (lineArea.y > aPoint.y) {
break; break;
} }
GetFrameFromLine(lineArea, tmp, line, aWhichLayer, aFrame); nsIFrame* hit = GetFrameFromLine(this, lineArea, aPoint, line,
aWhichLayer);
if (hit)
frame = hit;
} }
} }
} else { } else {
@ -6820,7 +6813,10 @@ nsBlockFrame::GetFrameForPointUsing(const nsPoint& aPoint,
lastY = lineArea.y; lastY = lineArea.y;
lastYMost = lineArea.YMost(); lastYMost = lineArea.YMost();
GetFrameFromLine(lineArea, tmp, line, aWhichLayer, aFrame); nsIFrame* hit = GetFrameFromLine(this, lineArea, aPoint, line,
aWhichLayer);
if (hit)
frame = hit;
} }
lineCount++; lineCount++;
} }
@ -6830,71 +6826,53 @@ nsBlockFrame::GetFrameForPointUsing(const nsPoint& aPoint,
} }
} }
if (*aFrame) { if (frame)
return NS_OK; return frame;
}
if ( inThisFrame && aConsiderSelf ) { if (inThisFrame && aConsiderSelf && GetStyleVisibility()->IsVisible())
if (GetStyleVisibility()->IsVisible()) { return this;
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE; return nsnull;
} }
NS_IMETHODIMP nsIFrame*
nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsresult rv; nsIFrame* frame;
switch (aWhichLayer) { switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND: case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPoint, nsnull, frame = GetFrameForPointUsing(aPoint, nsnull,
NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE);
aFrame); if (frame)
if (NS_OK == rv) { return frame;
return NS_OK; if (mBullet)
} return GetFrameForPointUsing(aPoint, nsLayoutAtoms::bulletList,
if (nsnull != mBullet) { NS_FRAME_PAINT_LAYER_FOREGROUND,
rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::bulletList, PR_FALSE);
NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, return nsnull;
aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATS: case NS_FRAME_PAINT_LAYER_FLOATS:
// we painted our floats before our children, and thus // we painted our floats before our children, and thus
// we should check floats within children first // we should check floats within children first
rv = GetFrameForPointUsing(aPoint, nsnull, frame = GetFrameForPointUsing(aPoint, nsnull,
NS_FRAME_PAINT_LAYER_FLOATS, PR_FALSE, NS_FRAME_PAINT_LAYER_FLOATS, PR_FALSE);
aFrame); if (frame)
if (NS_OK == rv) { return frame;
return NS_OK; if (mFloats.NotEmpty())
}
if (mFloats.NotEmpty()) {
return GetFrameForPointUsing(aPoint, nsLayoutAtoms::floatList, return GetFrameForPointUsing(aPoint, nsLayoutAtoms::floatList,
NS_FRAME_PAINT_LAYER_ALL, PR_FALSE, NS_FRAME_PAINT_LAYER_ALL, PR_FALSE);
aFrame); return nsnull;
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND: case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self // Because this frame is a block, pass PR_TRUE to consider this frame
return GetFrameForPointUsing(aPoint, nsnull, return GetFrameForPointUsing(aPoint, nsnull,
NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE);
aFrame);
break;
} }
// we shouldn't get here // we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood"); NS_NOTREACHED("aWhichLayer was not understood");
return NS_ERROR_FAILURE; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -200,12 +200,12 @@ public:
// are non-decreasing. // are non-decreasing.
void SetupLineCursor(); void SetupLineCursor();
nsresult GetFrameForPointUsing(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPointUsing(const nsPoint& aPoint,
nsIAtom* aList, nsIAtom* aList,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf, PRBool aConsiderSelf);
nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); nsFramePaintLayer aWhichLayer);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);

View File

@ -69,9 +69,8 @@ public:
NS_IMETHOD RemoveFrame(nsIAtom* aListName, NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame); nsIFrame* aOldFrame);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
virtual nsIFrame* GetContentInsertionFrame() { virtual nsIFrame* GetContentInsertionFrame() {
return GetFirstChild(nsnull)->GetContentInsertionFrame(); return GetFirstChild(nsnull)->GetContentInsertionFrame();
@ -168,14 +167,13 @@ nsColumnSetFrame::GetType() const
return nsLayoutAtoms::columnSetFrame; return nsLayoutAtoms::columnSetFrame;
} }
NS_IMETHODIMP nsIFrame*
nsColumnSetFrame::GetFrameForPoint(const nsPoint& aPoint, nsColumnSetFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// This frame counts as part of the background. // This frame counts as part of the background.
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
(aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -293,73 +293,60 @@ nsContainerFrame::PaintChild(nsPresContext* aPresContext,
} }
} }
NS_IMETHODIMP nsIFrame*
nsContainerFrame::GetFrameForPoint(const nsPoint& aPoint, nsContainerFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND), aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND);
} }
nsresult nsIFrame*
nsContainerFrame::GetFrameForPointUsing(const nsPoint& aPoint, nsContainerFrame::GetFrameForPointUsing(const nsPoint& aPoint,
nsIAtom* aList, nsIAtom* aList,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf, PRBool aConsiderSelf)
nsIFrame** aFrame)
{ {
nsIFrame *hit; nsRect thisRect(nsPoint(0,0), GetSize());
nsPoint tmp; PRBool inThisFrame = thisRect.Contains(aPoint);
PRBool inThisFrame = mRect.Contains(aPoint); if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame))
return nsnull;
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
return NS_ERROR_FAILURE;
}
nsIFrame* frame = nsnull;
nsIFrame* kid = GetFirstChild(aList); nsIFrame* kid = GetFirstChild(aList);
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
nsPoint originOffset;
nsIView *view = nsnull;
nsresult rv = GetOriginToViewOffset(originOffset, &view);
if (NS_SUCCEEDED(rv) && view)
tmp += originOffset;
while (kid) { while (kid) {
nsIFrame* hit;
nsPoint kidPoint = aPoint - kid->GetOffsetTo(this);
if (aWhichLayer == NS_FRAME_PAINT_LAYER_ALL) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_ALL) {
// Check all layers on this kid before moving on to the next one // Check all layers on this kid before moving on to the next one
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_FOREGROUND, &hit); hit = kid->GetFrameForPoint(kidPoint,
if (NS_FAILED(rv) || !hit) { NS_FRAME_PAINT_LAYER_FOREGROUND);
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_FLOATS, &hit); if (!hit) {
if (NS_FAILED(rv) || !hit) { hit = kid->GetFrameForPoint(kidPoint,
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_BACKGROUND, &hit); NS_FRAME_PAINT_LAYER_FLOATS);
if (!hit) {
hit = kid->GetFrameForPoint(kidPoint,
NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
} }
} else { } else {
rv = kid->GetFrameForPoint(tmp, aWhichLayer, &hit); hit = kid->GetFrameForPoint(kidPoint, aWhichLayer);
} }
if (NS_SUCCEEDED(rv) && hit) { if (hit)
*aFrame = hit; frame = hit;
}
kid = kid->GetNextSibling(); kid = kid->GetNextSibling();
} }
if (*aFrame) { if (frame)
return NS_OK; return frame;
}
if ( inThisFrame && aConsiderSelf ) { if (inThisFrame && aConsiderSelf && GetStyleVisibility()->IsVisible())
if (GetStyleVisibility()->IsVisible()) { return this;
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -70,9 +70,8 @@ public:
const nsRect& aDirtyRect, const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD ReplaceFrame(nsIAtom* aListName, NS_IMETHOD ReplaceFrame(nsIAtom* aListName,
nsIFrame* aOldFrame, nsIFrame* aOldFrame,
nsIFrame* aNewFrame); nsIFrame* aNewFrame);
@ -187,11 +186,10 @@ protected:
nsContainerFrame(); nsContainerFrame();
~nsContainerFrame(); ~nsContainerFrame();
nsresult GetFrameForPointUsing(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPointUsing(const nsPoint& aPoint,
nsIAtom* aList, nsIAtom* aList,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf, PRBool aConsiderSelf);
nsIFrame** aFrame);
virtual void PaintChildren(nsPresContext* aPresContext, virtual void PaintChildren(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,

View File

@ -2057,19 +2057,16 @@ nsFrame::GetCursor(const nsPoint& aPoint,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsFrame::GetFrameForPoint(const nsPoint& aPoint, nsFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) && nsRect thisRect(nsPoint(0,0), GetSize());
(mRect.Contains(aPoint))) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
if (GetStyleVisibility()->IsVisible()) { thisRect.Contains(aPoint) && GetStyleVisibility()->IsVisible()) {
*aFrame = this; return this;
return NS_OK;
}
} }
return NS_ERROR_FAILURE; return nsnull;
} }
// Resize and incremental reflow // Resize and incremental reflow

View File

@ -200,9 +200,8 @@ public:
nsIContent** aContent); nsIContent** aContent);
NS_IMETHOD GetCursor(const nsPoint& aPoint, NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor); nsIFrame::Cursor& aCursor);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD GetPointFromOffset(nsPresContext* inPresContext, NS_IMETHOD GetPointFromOffset(nsPresContext* inPresContext,
nsIRenderingContext* inRendContext, nsIRenderingContext* inRendContext,

View File

@ -135,9 +135,8 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD GetCursor(const nsPoint& aPoint, NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor); nsIFrame::Cursor& aCursor);
@ -840,18 +839,14 @@ nsHTMLFramesetFrame::GetCursor(const nsPoint& aPoint,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsHTMLFramesetFrame::GetFrameForPoint(const nsPoint& aPoint, nsHTMLFramesetFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
//XXX Temporary to deal with event handling in both this and FramsetBorderFrame //XXX Temporary to deal with event handling in both this and FramsetBorderFrame
if (mDragger) { if (mDragger)
*aFrame = this; return this;
return NS_OK; return nsContainerFrame::GetFrameForPoint(aPoint, aWhichLayer);
} else {
return nsContainerFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame);
}
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1761,19 +1756,15 @@ nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsHTMLFramesetBorderFrame::GetFrameForPoint(const nsPoint& aPoint, nsHTMLFramesetBorderFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
if ( (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND) || nsRect thisRect(nsPoint(0,0), GetSize());
(!((mState & NS_FRAME_OUTSIDE_CHILDREN) || mRect.Contains(aPoint) ))) if (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND ||
{ !((mState & NS_FRAME_OUTSIDE_CHILDREN) || thisRect.Contains(aPoint)))
return NS_ERROR_FAILURE; return nsnull;
} return this;
*aFrame = this;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -134,9 +134,8 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD GetCursor(const nsPoint& aPoint, NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor); nsIFrame::Cursor& aCursor);

View File

@ -112,9 +112,8 @@ public:
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
virtual PRBool IsContainingBlock() const { return PR_TRUE; } virtual PRBool IsContainingBlock() const { return PR_TRUE; }
NS_IMETHOD Paint(nsPresContext* aPresContext, NS_IMETHOD Paint(nsPresContext* aPresContext,
@ -606,13 +605,13 @@ CanvasFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
CanvasFrame::GetFrameForPoint(const nsPoint& aPoint, CanvasFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
nsIAtom* nsIAtom*

View File

@ -780,15 +780,13 @@ public:
/** /**
* Get the frame that should receive events for a given point in the * Get the frame that should receive events for a given point in the
* coordinate space of this frame's parent, if the frame is painted in * coordinate space of this frame, if the frame is painted in
* the given paint layer. A frame should return itself if it should * the given paint layer. A frame should return itself if it should
* recieve the events. A successful return value indicates that a * recieve the events. A successful return value indicates that a
* point was found. * point was found.
*/ */
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer) = 0;
nsIFrame** aFrame) = 0;
/** /**
* Get a point (in the frame's coordinate space) given an offset into * Get a point (in the frame's coordinate space) given an offset into

View File

@ -88,14 +88,13 @@ ViewportFrame::SetInitialChildList(nsPresContext* aPresContext,
return rv; return rv;
} }
NS_IMETHODIMP nsIFrame*
ViewportFrame::GetFrameForPoint(const nsPoint& aPoint, ViewportFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
(aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -71,9 +71,8 @@ public:
nsIAtom* aListName, nsIAtom* aListName,
nsIFrame* aChildList); nsIFrame* aChildList);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD AppendFrames(nsIAtom* aListName, NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList); nsIFrame* aFrameList);

View File

@ -250,17 +250,15 @@ nsMathMLmactionFrame::SetInitialChildList(nsPresContext* aPresContext,
} }
// Return the selected frame ... // Return the selected frame ...
NS_IMETHODIMP nsIFrame*
nsMathMLmactionFrame::GetFrameForPoint(const nsPoint& aPoint, nsMathMLmactionFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsIFrame* childFrame = GetSelectedFrame(); nsIFrame* childFrame = GetSelectedFrame();
if (childFrame) { if (childFrame)
nsPoint pt(aPoint.x - mRect.x, aPoint.y - mRect.y); return childFrame->GetFrameForPoint(aPoint - childFrame->GetOffsetTo(this),
return childFrame->GetFrameForPoint(pt, aWhichLayer, aFrame); aWhichLayer);
} return nsFrame::GetFrameForPoint(aPoint, aWhichLayer);
return nsFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame);
} }
// Only paint the selected child... // Only paint the selected child...

View File

@ -72,10 +72,8 @@ public:
nsIAtom* aListName, nsIAtom* aListName,
nsIFrame* aChildList); nsIFrame* aChildList);
NS_IMETHOD virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer);
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD NS_IMETHOD
Paint(nsPresContext* aPresContext, Paint(nsPresContext* aPresContext,

View File

@ -449,13 +449,13 @@ nsTableCellFrame::Paint(nsPresContext* aPresContext,
aWhichLayer);*/ aWhichLayer);*/
} }
NS_IMETHODIMP nsIFrame*
nsTableCellFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableCellFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }
//null range means the whole thing //null range means the whole thing

View File

@ -129,9 +129,8 @@ public:
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD SetSelected(nsPresContext* aPresContext, NS_IMETHOD SetSelected(nsPresContext* aPresContext,
nsIDOMRange *aRange, nsIDOMRange *aRange,

View File

@ -144,12 +144,11 @@ nsTableColFrame::Paint(nsPresContext* aPresContext,
} }
// override, since we want to act like a block // override, since we want to act like a block
NS_IMETHODIMP nsIFrame*
nsTableColFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableColFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
return NS_ERROR_FAILURE; return nsnull;
} }
NS_METHOD nsTableColFrame::Reflow(nsPresContext* aPresContext, NS_METHOD nsTableColFrame::Reflow(nsPresContext* aPresContext,

View File

@ -120,9 +120,8 @@ public:
// column groups don't paint their own background -- the cells do // column groups don't paint their own background -- the cells do
virtual PRBool CanPaintBackground() { return PR_FALSE; } virtual PRBool CanPaintBackground() { return PR_FALSE; }
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD Reflow(nsPresContext* aPresContext, NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,

View File

@ -351,13 +351,12 @@ nsTableColGroupFrame::GetSkipSides() const
return skip; return skip;
} }
NS_IMETHODIMP nsIFrame*
nsTableColGroupFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableColGroupFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE, aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE);
} }
NS_METHOD nsTableColGroupFrame::Reflow(nsPresContext* aPresContext, NS_METHOD nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,

View File

@ -147,9 +147,8 @@ public:
/** @see nsIFrame::GetFrameForPoint /** @see nsIFrame::GetFrameForPoint
*/ */
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
/** reflow of a column group is a trivial matter of reflowing /** reflow of a column group is a trivial matter of reflowing
* the col group's children (columns), and setting this frame * the col group's children (columns), and setting this frame

View File

@ -1438,13 +1438,13 @@ nsTableFrame::Paint(nsPresContext* aPresContext,
aWhichLayer);*/ aWhichLayer);*/
} }
NS_IMETHODIMP nsIFrame*
nsTableFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer,
aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND);
} }

View File

@ -327,9 +327,8 @@ public:
void PaintBCBorders(nsIRenderingContext& aRenderingContext, void PaintBCBorders(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect); const nsRect& aDirtyRect);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
/** nsIFrame method overridden to handle table specifics /** nsIFrame method overridden to handle table specifics
*/ */

View File

@ -340,23 +340,20 @@ nsTableOuterFrame::Paint(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsTableOuterFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableOuterFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsresult rv;
// caption frames live in a different list which we need to check separately // caption frames live in a different list which we need to check separately
if (mCaptionFrame) { if (mCaptionFrame) {
rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::captionList, aWhichLayer, PR_FALSE, aFrame); nsIFrame* frame = GetFrameForPointUsing(aPoint, nsLayoutAtoms::captionList,
if (NS_OK == rv) { aWhichLayer, PR_FALSE);
return NS_OK; if (frame)
} return frame;
} }
// This frame should never get events (it contains the margins of the // This frame should never get events (it contains the margins of the
// table), so always pass |PR_FALSE| for |aConsiderSelf|. // table), so always pass |PR_FALSE| for |aConsiderSelf|.
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE, aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE);
} }
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsPresContext* aPresContext, NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsPresContext* aPresContext,

View File

@ -134,9 +134,8 @@ public:
// the outer table does not paint its entire background if it has margins and/or captions // the outer table does not paint its entire background if it has margins and/or captions
virtual PRBool CanPaintBackground() { return PR_FALSE; } virtual PRBool CanPaintBackground() { return PR_FALSE; }
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
/** process a reflow command for the table. /** process a reflow command for the table.
* This involves reflowing the caption and the inner table. * This involves reflowing the caption and the inner table.

View File

@ -588,10 +588,9 @@ nsTableRowFrame::GetSkipSides() const
* so the default "get the child rect, see if it contains the event point" action isn't * so the default "get the child rect, see if it contains the event point" action isn't
* sufficient. We have to ask the row if it has a child that contains the point. * sufficient. We have to ask the row if it has a child that contains the point.
*/ */
NS_IMETHODIMP nsIFrame*
nsTableRowFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableRowFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// XXX This would not need to exist (except as a one-liner, to make this // XXX This would not need to exist (except as a one-liner, to make this
// frame work like a block frame) if rows with rowspan cells made the // frame work like a block frame) if rows with rowspan cells made the
@ -606,26 +605,16 @@ nsTableRowFrame::GetFrameForPoint(const nsPoint& aPoint,
// This is basically copied from nsContainerFrame::GetFrameForPointUsing, // This is basically copied from nsContainerFrame::GetFrameForPointUsing,
// except for one bit removed // except for one bit removed
nsIFrame *hit;
nsPoint tmp;
nsIFrame* kid = GetFirstChild(nsnull); nsIFrame* kid = GetFirstChild(nsnull);
*aFrame = nsnull; nsIFrame* frame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y); while (kid) {
while (nsnull != kid) { nsIFrame* hit = kid->GetFrameForPoint(aPoint - kid->GetOffsetTo(this),
nsresult rv = kid->GetFrameForPoint(tmp, aWhichLayer, &hit); aWhichLayer);
if (hit)
if (NS_SUCCEEDED(rv) && hit) { frame = hit;
*aFrame = hit;
}
kid = kid->GetNextSibling(); kid = kid->GetNextSibling();
} }
return frame;
if (*aFrame) {
return NS_OK;
}
return NS_ERROR_FAILURE;
} }
// Calculate the cell's actual size given its pass2 desired width and height. // Calculate the cell's actual size given its pass2 desired width and height.

View File

@ -103,9 +103,8 @@ public:
// rows don't paint their own background -- the cells do // rows don't paint their own background -- the cells do
virtual PRBool CanPaintBackground() { return PR_FALSE; } virtual PRBool CanPaintBackground() { return PR_FALSE; }
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
nsTableCellFrame* GetFirstCell() ; nsTableCellFrame* GetFirstCell() ;

View File

@ -248,14 +248,12 @@ nsTableRowGroupFrame::GetSkipSides() const
return skip; return skip;
} }
nsIFrame*
NS_IMETHODIMP
nsTableRowGroupFrame::GetFrameForPoint(const nsPoint& aPoint, nsTableRowGroupFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE, aFrame); return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE);
} }
// Position and size aKidFrame and update our reflow state. The origin of // Position and size aKidFrame and update our reflow state. The origin of

View File

@ -148,7 +148,8 @@ public:
* Return PR_TRUE if a frame containing the point is found. * Return PR_TRUE if a frame containing the point is found.
* @see nsContainerFrame::GetFrameForPoint * @see nsContainerFrame::GetFrameForPoint
*/ */
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer);
/** calls Reflow for all of its child rows. /** calls Reflow for all of its child rows.
* Rows are all set to the same width and stacked vertically. * Rows are all set to the same width and stacked vertically.

View File

@ -1297,7 +1297,8 @@ NS_IMETHODIMP
nsBox::GetDebugBoxAt( const nsPoint& aPoint, nsBox::GetDebugBoxAt( const nsPoint& aPoint,
nsIBox** aBox) nsIBox** aBox)
{ {
if (!mRect.Contains(aPoint)) nsRect thisRect(nsPoint(0,0), GetSize());
if (!thisRect.Contains(aPoint))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsIBox* child = nsnull; nsIBox* child = nsnull;
@ -1305,10 +1306,8 @@ nsBox::GetDebugBoxAt( const nsPoint& aPoint,
GetChildBox(&child); GetChildBox(&child);
*aBox = nsnull; *aBox = nsnull;
nsPoint tmp;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
while (nsnull != child) { while (nsnull != child) {
nsresult rv = child->GetDebugBoxAt(tmp, &hit); nsresult rv = child->GetDebugBoxAt(aPoint - child->GetOffsetTo(this), &hit);
if (NS_SUCCEEDED(rv) && hit) { if (NS_SUCCEEDED(rv) && hit) {
*aBox = hit; *aBox = hit;
@ -1325,7 +1324,7 @@ nsBox::GetDebugBoxAt( const nsPoint& aPoint,
nsMargin m; nsMargin m;
GetBorderAndPadding(m); GetBorderAndPadding(m);
nsRect rect(mRect); nsRect rect(thisRect);
rect.Deflate(m); rect.Deflate(m);
if (rect.Contains(aPoint)) { if (rect.Contains(aPoint)) {
GetInset(m); GetInset(m);

View File

@ -1737,25 +1737,21 @@ nsBoxFrame::GetDebug(PRBool& aDebug)
} }
#endif #endif
NS_IMETHODIMP nsIFrame*
nsBoxFrame::GetFrameForPoint(const nsPoint& aPoint, nsBoxFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame) {
{ nsRect thisRect(nsPoint(0,0), GetSize());
if (!mRect.Contains(aPoint)) if (!thisRect.Contains(aPoint))
return NS_ERROR_FAILURE; return nsnull;
const nsStyleVisibility* vis = GetStyleVisibility(); const nsStyleVisibility* vis = GetStyleVisibility();
if (vis->mVisible == NS_STYLE_VISIBILITY_COLLAPSE) if (vis->mVisible == NS_STYLE_VISIBILITY_COLLAPSE)
return NS_ERROR_FAILURE; return nsnull;
nsIView* view = nsnull;
nsPoint originOffset;
GetOriginToViewOffset(originOffset, &view);
#ifdef DEBUG_LAYOUT #ifdef DEBUG_LAYOUT
// get the debug frame. // get the debug frame.
if (view || (mState & NS_STATE_IS_ROOT)) if (HasView() || (mState & NS_STATE_IS_ROOT))
{ {
nsIBox* box = nsnull; nsIBox* box = nsnull;
if (NS_SUCCEEDED(GetDebugBoxAt(aPoint, &box)) && box) if (NS_SUCCEEDED(GetDebugBoxAt(aPoint, &box)) && box)
@ -1763,79 +1759,56 @@ nsBoxFrame::GetFrameForPoint(const nsPoint& aPoint,
PRBool isDebug = PR_FALSE; PRBool isDebug = PR_FALSE;
box->GetDebug(isDebug); box->GetDebug(isDebug);
if (isDebug) { if (isDebug) {
*aFrame = box; return box;
return NS_OK;
} }
} }
} }
#endif #endif
nsIFrame *hit = nsnull; nsIFrame *hit = nsnull;
nsPoint tmp;
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
if (view)
tmp += originOffset;
nsIBox* kid = nsnull; nsIBox* kid = nsnull;
GetChildBox(&kid); GetChildBox(&kid);
while (nsnull != kid) { while (kid) {
GetFrameForPointChild(tmp, aWhichLayer, kid, hit != nsnull, &hit); nsIFrame* frame = GetFrameForPointChild(aPoint, aWhichLayer, kid,
hit != nsnull);
if (frame)
hit = frame;
kid->GetNextBox(&kid); kid->GetNextBox(&kid);
} }
if (hit) if (hit)
*aFrame = hit; return hit;
if (*aFrame) {
return NS_OK;
}
// if no kids were hit then select us // if no kids were hit then select us
if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND && vis->IsVisible()) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND && vis->IsVisible())
*aFrame = this; return this;
return NS_OK;
}
return NS_ERROR_FAILURE; return nsnull;
} }
/* virtual */ nsresult /* virtual */ nsIFrame*
nsBoxFrame::GetFrameForPointChild(const nsPoint& aPoint, nsBoxFrame::GetFrameForPointChild(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
nsIFrame* aChild, nsIFrame* aChild,
PRBool aCheckMouseThrough, PRBool aCheckMouseThrough)
nsIFrame** aFrame)
{ {
nsIFrame *hit = nsnull; nsIFrame *hit = aChild->GetFrameForPoint(aPoint - aChild->GetOffsetTo(this),
nsresult rv = aWhichLayer);
aChild->GetFrameForPoint(aPoint, aWhichLayer, &hit); if (hit) {
if (!aCheckMouseThrough)
if (NS_SUCCEEDED(rv) && hit) { return hit;
rv = NS_ERROR_FAILURE; // If we had a lower frame for this point, check whether hit's box has
if (!aCheckMouseThrough) { // mouse through. If so, stick with the lower frame that we found.
*aFrame = hit; PRBool isAdaptor = PR_FALSE;
rv = NS_OK; nsIBox *box = GetBoxForFrame(hit, isAdaptor);
} if (box) {
else PRBool mouseThrough = PR_FALSE;
{ box->GetMouseThrough(mouseThrough);
// If we had a lower frame for this point, check whether hit's box has // if the child says it can never mouse though ignore it.
// mouse through. If so, stick with the lower frame that we found. if (!mouseThrough)
PRBool isAdaptor = PR_FALSE; return hit;
nsIBox *box = GetBoxForFrame(hit, isAdaptor);
if (box) {
PRBool mouseThrough = PR_FALSE;
box->GetMouseThrough(mouseThrough);
// if the child says it can never mouse though ignore it.
if (!mouseThrough) {
*aFrame = hit;
rv = NS_OK;
}
}
} }
} }
return rv; return nsnull;
} }
nsIBox* nsIBox*

View File

@ -123,9 +123,8 @@ public:
// ----- public methods ------- // ----- public methods -------
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD GetCursor(const nsPoint& aPoint, NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor); nsIFrame::Cursor& aCursor);
@ -252,11 +251,10 @@ protected:
protected: protected:
nsresult RegUnregAccessKey(nsPresContext* aPresContext, nsresult RegUnregAccessKey(nsPresContext* aPresContext,
PRBool aDoReg); PRBool aDoReg);
virtual nsresult GetFrameForPointChild(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPointChild(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
nsIFrame* aChild, nsIFrame* aChild,
PRBool aCheckMouseThrough, PRBool aCheckMouseThrough);
nsIFrame** aFrame);
NS_HIDDEN_(void) CheckBoxOrder(nsBoxLayoutState& aState); NS_HIDDEN_(void) CheckBoxOrder(nsBoxLayoutState& aState);

View File

@ -86,12 +86,12 @@ nsButtonBoxFrame::GetMouseThrough(PRBool& aMouseThrough)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsButtonBoxFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame*
nsFramePaintLayer aWhichLayer, nsButtonBoxFrame::GetFrameForPoint(const nsPoint& aPoint,
nsIFrame** aFrame) nsFramePaintLayer aWhichLayer)
{ {
// override, since we don't want children to get events // override, since we don't want children to get events
return nsFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -47,9 +47,8 @@ public:
nsButtonBoxFrame(nsIPresShell* aPresShell); nsButtonBoxFrame(nsIPresShell* aPresShell);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,

View File

@ -239,32 +239,30 @@ nsDeckFrame::Paint(nsPresContext* aPresContext,
} }
NS_IMETHODIMP nsIFrame*
nsDeckFrame::GetFrameForPoint(const nsPoint& aPoint, nsDeckFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// if it is not inside us fail // if it is not inside us fail
if (!mRect.Contains(aPoint)) { nsRect thisRect(nsPoint(0,0), GetSize());
return NS_ERROR_FAILURE; if (!thisRect.Contains(aPoint))
} return nsnull;
// get the selected frame and see if the point is in it. // get the selected frame and see if the point is in it.
nsIBox* selectedBox = GetSelectedBox(); nsIBox* selectedBox = GetSelectedBox();
if (selectedBox) { if (selectedBox) {
nsPoint tmp(aPoint.x - mRect.x, aPoint.y - mRect.y); nsIFrame* frame;
if (frame = selectedBox->GetFrameForPoint(aPoint -
if (NS_SUCCEEDED(selectedBox->GetFrameForPoint(tmp, aWhichLayer, aFrame))) selectedBox->GetOffsetTo(this),
return NS_OK; aWhichLayer))
return frame;
} }
// if its not in our child just return us. // if its not in our child just return us.
if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) { if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND)
*aFrame = this; return this;
return NS_OK;
}
return NS_ERROR_FAILURE; return nsnull;
} }

View File

@ -68,10 +68,8 @@ public:
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer);
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD Init(nsPresContext* aPresContext, NS_IMETHOD Init(nsPresContext* aPresContext,
nsIContent* aContent, nsIContent* aContent,

View File

@ -183,19 +183,18 @@ nsLeafBoxFrame::GetMouseThrough(PRBool& aMouseThrough)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsIFrame*
nsLeafBoxFrame::GetFrameForPoint(const nsPoint& aPoint, nsLeafBoxFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
if ((aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND)) if ((aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND))
return NS_ERROR_FAILURE; return nsnull;
if (!mRect.Contains(aPoint)) nsRect thisRect(nsPoint(0,0), GetSize());
return NS_ERROR_FAILURE; if (!thisRect.Contains(aPoint))
return nsnull;
*aFrame = this; return this;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -82,9 +82,8 @@ public:
nsStyleContext* aContext, nsStyleContext* aContext,
nsIFrame* asPrevInFlow); nsIFrame* asPrevInFlow);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute, nsIAtom* aAttribute,

View File

@ -79,23 +79,20 @@ nsListItemFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsListItemFrame::GetFrameForPoint(const nsPoint& aPoint, nsListItemFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsAutoString value; nsAutoString value;
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value); mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value.EqualsLiteral("true")) { if (value.EqualsLiteral("true")) {
return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
else if (mRect.Contains(aPoint)) { nsRect thisRect(nsPoint(0,0), GetSize());
if (GetStyleVisibility()->IsVisible()) { if (thisRect.Contains(aPoint) && GetStyleVisibility()->IsVisible())
*aFrame = this; // Capture all events so that we can perform selection and expand/collapse. // Capture all events so that we can perform selection and expand/collapse.
return NS_OK; return this;
} return nsnull;
}
return NS_ERROR_FAILURE;
} }
// Creation Routine /////////////////////////////////////////////////////////////////////// // Creation Routine ///////////////////////////////////////////////////////////////////////

View File

@ -57,9 +57,8 @@ public:
// overridden so that children of listitems don't handle mouse events, // overridden so that children of listitems don't handle mouse events,
// unless allowevents="true" is specified on the listitem // unless allowevents="true" is specified on the listitem
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
// nsIBox // nsIBox
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize); NS_IMETHOD GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize);

View File

@ -348,28 +348,25 @@ nsMenuFrame::Destroy(nsPresContext* aPresContext)
} }
// Called to prevent events from going to anything inside the menu. // Called to prevent events from going to anything inside the menu.
NS_IMETHODIMP nsIFrame*
nsMenuFrame::GetFrameForPoint(const nsPoint& aPoint, nsMenuFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
nsresult result = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); nsIFrame* frame = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
if (NS_FAILED(result) || *aFrame == this) { if (!frame || frame == this) {
return result; return frame;
} }
nsIContent* content = (*aFrame)->GetContent(); nsIContent* content = frame->GetContent();
if (content) { if (content) {
// This allows selective overriding for subcontent. // This allows selective overriding for subcontent.
nsAutoString value; nsAutoString value;
content->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value); content->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value.EqualsLiteral("true")) if (value.EqualsLiteral("true"))
return result; return frame;
} }
if (GetStyleVisibility()->IsVisible()) { if (GetStyleVisibility()->IsVisible())
*aFrame = this; // Capture all events so that we can perform selection return this; // Capture all events so that we can perform selection
return NS_OK; return nsnull;
}
return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -107,9 +107,8 @@ public:
NS_IMETHOD Destroy(nsPresContext* aPresContext); NS_IMETHOD Destroy(nsPresContext* aPresContext);
// Overridden to prevent events from ever going to children of the menu. // Overridden to prevent events from ever going to children of the menu.
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,

View File

@ -1975,12 +1975,11 @@ nsMenuPopupFrame::Destroy(nsPresContext* aPresContext)
return nsBoxFrame::Destroy(aPresContext); return nsBoxFrame::Destroy(aPresContext);
} }
NS_IMETHODIMP nsIFrame*
nsMenuPopupFrame::GetFrameForPoint(const nsPoint& aPoint, nsMenuPopupFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }

View File

@ -133,9 +133,8 @@ public:
NS_IMETHOD Destroy(nsPresContext* aPresContext); NS_IMETHOD Destroy(nsPresContext* aPresContext);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState); NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState);
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState); NS_IMETHOD MarkDirty(nsBoxLayoutState& aState);

View File

@ -583,11 +583,11 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull, nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull,
nsMouseEvent::eReal); nsMouseEvent::eReal);
// XXX The client point storage was moved to the DOM event, so now this can't // XXX This is messed up: it needs to account for widgets.
// work. A real fix would require fixing the mess that is popup coordinates nsPoint dummy;
// in layout. For now, don't bother setting the point. event.widget = GetClosestView()->GetNearestWidget(&dummy);
//event.point.x = aX; event.refPoint.x = aX;
//event.point.y = aY; event.refPoint.y = aY;
if (aPopupContent) { if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell(); nsIPresShell *shell = mPresContext->GetPresShell();

View File

@ -96,9 +96,8 @@ public:
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
/** /**
* Get the "type" of the frame * Get the "type" of the frame
@ -245,13 +244,12 @@ nsRootBoxFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIFrame*
nsRootBoxFrame::GetFrameForPoint(const nsPoint& aPoint, nsRootBoxFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// this should act like a block, so we need to override // this should act like a block, so we need to override
return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
nsIAtom* nsIAtom*

View File

@ -725,29 +725,25 @@ nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame,
} }
NS_IMETHODIMP nsSliderFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame* nsSliderFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
// This is EVIL, we shouldn't be messing with GetFrameForPoint just to get // This is EVIL, we shouldn't be messing with GetFrameForPoint just to get
// thumb mouse drag events to arrive at the slider! // thumb mouse drag events to arrive at the slider!
if (isDraggingThumb()) if (isDraggingThumb())
{
// XXX I assume it's better not to test for visibility here. // XXX I assume it's better not to test for visibility here.
*aFrame = this; return this;
return NS_OK;
}
if (NS_SUCCEEDED(nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame))) nsIFrame* frame;
return NS_OK; if ((frame = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer)))
return frame;
// always return us (if visible) // always return us (if visible)
if (mRect.Contains(aPoint) && GetStyleVisibility()->IsVisible()) { nsRect thisRect(nsPoint(0,0), GetSize());
*aFrame = this; if (thisRect.Contains(aPoint) && GetStyleVisibility()->IsVisible())
return NS_OK; return this;
}
return NS_ERROR_FAILURE; return nsnull;
} }

View File

@ -176,9 +176,8 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext, NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
nsIAtom* aListName, nsIAtom* aListName,

View File

@ -442,28 +442,25 @@ nsSplitterFrame::HandleRelease(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsSplitterFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame* nsSplitterFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame) {
{
// if the mouse is captured always return us as the frame. // if the mouse is captured always return us as the frame.
if (mInner->mDragging) if (mInner->mDragging)
{ {
// XXX It's probably better not to check visibility here, right? // XXX It's probably better not to check visibility here, right?
*aFrame = this; return this;
return NS_OK;
} }
nsresult rv = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); nsIFrame* frame = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
if (NS_FAILED(rv) && nsRect thisRect(nsPoint(0,0), GetSize());
aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND && if (!frame && aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
mRect.Contains(aPoint)) { thisRect.Contains(aPoint)) {
*aFrame = this; return this;
rv = NS_OK; }
}
return rv; return frame;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -102,9 +102,8 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
virtual void GetInitialOrientation(PRBool& aIsHorizontal); virtual void GetInitialOrientation(PRBool& aIsHorizontal);

View File

@ -88,35 +88,33 @@ nsStackFrame::nsStackFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayoutManage
} }
NS_IMETHODIMP nsIFrame*
nsStackFrame::GetFrameForPoint(const nsPoint& aPoint, nsStackFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
if (aWhichLayer != NS_FRAME_PAINT_LAYER_BACKGROUND) if (aWhichLayer != NS_FRAME_PAINT_LAYER_BACKGROUND)
return NS_ERROR_FAILURE; return nsnull;
return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
/* virtual */ nsresult /* virtual */ nsIFrame*
nsStackFrame::GetFrameForPointChild(const nsPoint& aPoint, nsStackFrame::GetFrameForPointChild(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
nsIFrame* aChild, nsIFrame* aChild,
PRBool aCheckMouseThrough, PRBool aCheckMouseThrough)
nsIFrame** aFrame)
{ {
if (aWhichLayer != NS_FRAME_PAINT_LAYER_BACKGROUND) if (aWhichLayer != NS_FRAME_PAINT_LAYER_BACKGROUND)
return NS_ERROR_FAILURE; return nsnull;
nsresult rv = nsBoxFrame::GetFrameForPointChild(aPoint, nsIFrame* frame = nsBoxFrame::GetFrameForPointChild(aPoint,
NS_FRAME_PAINT_LAYER_FOREGROUND, NS_FRAME_PAINT_LAYER_FOREGROUND,
aChild, aCheckMouseThrough, aFrame); aChild, aCheckMouseThrough);
if (NS_SUCCEEDED(rv)) if (frame)
return rv; return frame;
return nsBoxFrame::GetFrameForPointChild(aPoint, return nsBoxFrame::GetFrameForPointChild(aPoint,
NS_FRAME_PAINT_LAYER_BACKGROUND, NS_FRAME_PAINT_LAYER_BACKGROUND,
aChild, aCheckMouseThrough, aFrame); aChild, aCheckMouseThrough);
} }
void void

View File

@ -75,17 +75,15 @@ public:
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0); PRUint32 aFlags = 0);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
protected: protected:
virtual nsresult GetFrameForPointChild(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPointChild(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer,
nsIFrame* aChild, nsIFrame* aChild,
PRBool aCheckMouseThrough, PRBool aCheckMouseThrough);
nsIFrame** aFrame);
nsStackFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayout = nsnull); nsStackFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayout = nsnull);

View File

@ -103,19 +103,14 @@ nsTitleBarFrame::GetMouseThrough(PRBool& aMouseThrough)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsTitleBarFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame*
nsFramePaintLayer aWhichLayer, nsTitleBarFrame::GetFrameForPoint(const nsPoint& aPoint,
nsIFrame** aFrame) nsFramePaintLayer aWhichLayer)
{ {
// override, since we don't want children to get events // override, since we don't want children to get events
return nsFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); return nsFrame::GetFrameForPoint(aPoint, aWhichLayer);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext, nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,

View File

@ -54,9 +54,8 @@ public:
nsStyleContext* aContext, nsStyleContext* aContext,
nsIFrame* asPrevInFlow); nsIFrame* asPrevInFlow);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent, nsGUIEvent* aEvent,

View File

@ -124,21 +124,21 @@ nsTreeColFrame::Destroy(nsPresContext* aPresContext)
return nsBoxFrame::Destroy(aPresContext); return nsBoxFrame::Destroy(aPresContext);
} }
NS_IMETHODIMP nsIFrame*
nsTreeColFrame::GetFrameForPoint(const nsPoint& aPoint, nsTreeColFrame::GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer)
nsIFrame** aFrame)
{ {
if (!(mRect.Contains(aPoint) || (mState & NS_FRAME_OUTSIDE_CHILDREN))) nsRect thisRect(nsPoint(0,0), GetSize());
return NS_ERROR_FAILURE; if (!(thisRect.Contains(aPoint) || (mState & NS_FRAME_OUTSIDE_CHILDREN)))
return nsnull;
// If we are in either the first 2 pixels or the last 2 pixels, we're going to // If we are in either the first 2 pixels or the last 2 pixels, we're going to
// do something really strange. Check for an adjacent splitter. // do something really strange. Check for an adjacent splitter.
PRBool left = PR_FALSE; PRBool left = PR_FALSE;
PRBool right = PR_FALSE; PRBool right = PR_FALSE;
if (mRect.x + mRect.width - 60 < aPoint.x) if (mRect.width - 60 < aPoint.x)
right = PR_TRUE; right = PR_TRUE;
else if (mRect.x + 60 > aPoint.x) else if (60 > aPoint.x)
left = PR_TRUE; left = PR_TRUE;
if (left || right) { if (left || right) {
@ -153,30 +153,27 @@ nsTreeColFrame::GetFrameForPoint(const nsPoint& aPoint,
if (child) { if (child) {
nsINodeInfo *ni = child->GetContent()->GetNodeInfo(); nsINodeInfo *ni = child->GetContent()->GetNodeInfo();
if (ni && ni->Equals(nsXULAtoms::splitter, kNameSpaceID_XUL)) { if (ni && ni->Equals(nsXULAtoms::splitter, kNameSpaceID_XUL)) {
*aFrame = child; return child;
return NS_OK;
} }
} }
} }
nsresult result = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer, aFrame); nsIFrame* frame = nsBoxFrame::GetFrameForPoint(aPoint, aWhichLayer);
if (result == NS_OK) { if (frame) {
nsIContent* content = (*aFrame)->GetContent(); nsIContent* content = frame->GetContent();
if (content) { if (content) {
// This allows selective overriding for subcontent. // This allows selective overriding for subcontent.
nsAutoString value; nsAutoString value;
content->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value); content->GetAttr(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value.EqualsLiteral("true")) if (value.EqualsLiteral("true"))
return result; return frame;
} }
} }
if (mRect.Contains(aPoint)) {
if (GetStyleVisibility()->IsVisible()) { if (thisRect.Contains(aPoint) && GetStyleVisibility()->IsVisible()) {
*aFrame = this; // Capture all events. return this; // Capture all events.
return NS_OK;
}
} }
return NS_ERROR_FAILURE; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -58,9 +58,8 @@ public:
NS_IMETHOD Destroy(nsPresContext* aPresContext); NS_IMETHOD Destroy(nsPresContext* aPresContext);
// Overridden to capture events. // Overridden to capture events.
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer, nsFramePaintLayer aWhichLayer);
nsIFrame** aFrame);
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute, nsIAtom* aAttribute,