Fix event targetting bugs by using paint layers in GetFrameForPoint, testing for visibility, and trying GetFrameForPoint on additional views if one fails. r=joki@netscape.com(, hyatt@netscape.com) b=12232,20051,21304,24474,26785, and remaining issues from 23161.

This commit is contained in:
dbaron%fas.harvard.edu 2000-03-22 02:43:08 +00:00
Родитель e38031a522
Коммит 87e19c9cef
108 изменённых файлов: 1225 добавлений и 440 удалений

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

@ -389,7 +389,8 @@ public:
const nsRect& aDirtyRect);
NS_IMETHOD HandleEvent(nsIView* aView,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
nsEventStatus* aEventStatus,
PRBool& aHandled);
NS_IMETHOD Scrolled(nsIView *aView);
NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
@ -2958,7 +2959,8 @@ PresShell::PopCurrentEventFrame()
NS_IMETHODIMP
PresShell::HandleEvent(nsIView *aView,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
nsEventStatus* aEventStatus,
PRBool& aHandled)
{
void* clientData;
nsIFrame* frame;
@ -2966,6 +2968,8 @@ PresShell::HandleEvent(nsIView *aView,
NS_ASSERTION(!(nsnull == aView), "null view");
aHandled = PR_TRUE; // XXX Is this right?
if (mIsDestroying || mReflowLockCount > 0) {
return NS_OK;
}
@ -2992,10 +2996,58 @@ PresShell::HandleEvent(nsIView *aView,
manager->GetFocusedContent(&focusContent);
if (focusContent)
GetPrimaryFrameFor(focusContent, &mCurrentEventFrame);
else frame->GetFrameForPoint(mPresContext, aEvent->point, &mCurrentEventFrame);
else {
// XXX This is the way key events seem to work? Why?????
// They spend time doing calls to GetFrameForPoint with the
// point as (0,0) (or sometimes something else).
// XXX If this code is really going to stay, it should
// probably go into a separate function, because its just
// a duplicate of the code a few lines below:
// This is because we want to give the point in the same
// coordinates as the frame's own Rect, so mRect.Contains(aPoint)
// works. However, this point is relative to the frame's rect, so
// we need to add on the origin of the rect.
nsPoint eventPoint;
frame->GetOrigin(eventPoint);
eventPoint += aEvent->point;
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
// XXX Is this the right thing to do?
mCurrentEventFrame = nsnull;
aHandled = PR_FALSE;
rv = NS_OK;
}
}
}
}
}
else {
frame->GetFrameForPoint(mPresContext, aEvent->point, &mCurrentEventFrame);
// This is because we want to give the point in the same
// coordinates as the frame's own Rect, so mRect.Contains(aPoint)
// works. However, this point is relative to the frame's rect, so
// we need to add on the origin of the rect.
nsPoint eventPoint;
frame->GetOrigin(eventPoint);
eventPoint += aEvent->point;
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
// XXX Is this the right thing to do?
mCurrentEventFrame = nsnull;
aHandled = PR_FALSE;
rv = NS_OK;
}
}
}
}
NS_IF_RELEASE(mCurrentEventContent);
if (GetCurrentEventFrame() || focusContent) {
@ -3064,6 +3116,7 @@ PresShell::HandleEvent(nsIView *aView,
}
else {
rv = NS_OK;
aHandled = PR_FALSE;
}
return rv;

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

@ -697,8 +697,16 @@ public:
nsPoint& aPoint,
PRInt32& aCursor) = 0;
/**
* 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
* the given paint layer. A frame should return itself if it should
* recieve the events. A successful return value indicates that a
* point was found.
*/
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame) = 0;

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

@ -1643,15 +1643,32 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
NS_IMETHODIMP
nsComboboxControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (nsFormFrame::GetDisabled(this)) {
*aFrame = this;
return NS_OK;
} else {
return nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
PRBool inThisFrame = mRect.Contains(aPoint);
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame) ) {
return NS_ERROR_FAILURE;
}
return NS_OK;
if ( nsFormFrame::GetDisabled(this) && inThisFrame ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) {
nsresult rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_SUCCEEDED(rv)) return rv;
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
}
return NS_ERROR_FAILURE;
}

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

@ -113,7 +113,7 @@ public:
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
// nsIFormControlFrame
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);

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

@ -440,13 +440,18 @@ nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (nsFormFrame::GetDisabled(this)) {
*aFrame = this;
return NS_OK;
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
} else {
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
return NS_OK;
}

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

@ -79,7 +79,7 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
#endif
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) { return NS_OK; };
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,

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

@ -400,10 +400,18 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
if (mRect.Contains(aPoint)) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

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

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

@ -24,6 +24,7 @@
#include "nsCOMPtr.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIContent.h"
#include "nsIStyleContext.h"
nsresult
NS_NewSelectsAreaFrame(nsIPresShell* aShell, nsIFrame** aNewFrame, PRUint32 aFlags)
@ -90,18 +91,28 @@ nsSelectsAreaFrame::IsOptionElementFrame(nsIFrame *aFrame)
NS_IMETHODIMP
nsSelectsAreaFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsIFrame* selectedFrame = *aFrame;
while ((nsnull != selectedFrame) && (PR_FALSE == IsOptionElementFrame(selectedFrame))) {
selectedFrame->GetParent(&selectedFrame);
}
if (nsnull != selectedFrame) {
*aFrame = selectedFrame;
PRBool inThisFrame = mRect.Contains(aPoint);
if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame )) {
return NS_ERROR_FAILURE;
}
return NS_OK;
nsresult result = nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (result == NS_OK) {
nsIFrame* selectedFrame = *aFrame;
while ((nsnull != selectedFrame) && (PR_FALSE == IsOptionElementFrame(selectedFrame))) {
selectedFrame->GetParent(&selectedFrame);
}
if (nsnull != selectedFrame) {
*aFrame = selectedFrame;
}
// else, keep the original result as *aFrame, which could be this frame
}
return result;
}

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

@ -39,7 +39,7 @@ public:
// nsISupports
//NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
protected:
PRBool IsOptionElement(nsIContent* aContent);

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -104,7 +104,7 @@ public:
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
NS_IMETHOD VerifyTree() const;
#endif
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -240,85 +240,52 @@ nsContainerFrame::PaintChild(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsContainerFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND), aFrame);
}
nsresult
nsContainerFrame::GetFrameForPointUsing(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIAtom* aList,
nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf,
nsIFrame** aFrame)
{
nsIFrame* kid;
nsRect kidRect;
nsIFrame *kid, *hit;
nsPoint tmp;
*aFrame = this;
nsIFrame *childFrame = 0;
nsresult rv = NS_ERROR_FAILURE;
PRBool inThisFrame = mRect.Contains(aPoint);
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
return NS_ERROR_FAILURE;
}
// Attempt to find the first child that contains the desired
// point. We try to use a quick check on the child frames bbox to
// avoid a potentially expensive recursion into the child frames
// GetFrameForPoint method.
FirstChild(aPresContext, aList, &kid);
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
while (nsnull != kid) {
kid->GetRect(kidRect);
// Do a quick check and see if the child frame contains the point
if (kidRect.Contains(aPoint)) {
// The child frame contains the point. Now see if it really
// contains the point.
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
rv = kid->GetFrameForPoint(aPresContext, tmp, aFrame);
if (NS_SUCCEEDED(rv) && *aFrame) {
// We found the target frame somewhere in the child frame.
childFrame = *aFrame;
break;
}
else {
// We didn't find the target frame in any of the children,
// but save the fact that this kid contains the point.
childFrame = kid;
}
if (NS_SUCCEEDED(rv) && hit) {
*aFrame = hit;
}
kid->GetNextSibling(&kid);
}
//Only keep looking outside if we didn't absolutely find a child leaf node.
//This is indicated by the successful return from GetFrameForPoint. If we
//only found a container frame we'll have set childFrame to our best guess
//at a container frame but rv will still have failed so we should go on
//looking for the correct leaf frame in the outside children.
if (NS_FAILED(rv)) {
// Try again, this time looking only inside child frames that have
// outside children.
FirstChild(aPresContext, aList, &kid);
while (nsnull != kid) {
nsFrameState state;
kid->GetFrameState(&state);
if (NS_FRAME_OUTSIDE_CHILDREN & state) {
kid->GetRect(kidRect);
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
if (NS_OK == kid->GetFrameForPoint(aPresContext, tmp, aFrame)) {
return NS_OK;
}
else {
*aFrame = this;
}
}
kid->GetNextSibling(&kid);
}
if (*aFrame) {
return NS_OK;
}
if (childFrame) {
// We didn't find any overlapping frames that contain
// the point, so just return the original childFrame.
*aFrame = childFrame;
return NS_OK;
if ( inThisFrame && aConsiderSelf ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;

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

@ -52,6 +52,7 @@ public:
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD ReplaceFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -156,6 +157,8 @@ protected:
nsresult GetFrameForPointUsing(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIAtom* aList,
nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf,
nsIFrame** aFrame);
virtual void PaintChildren(nsIPresContext* aPresContext,

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

@ -1312,10 +1312,19 @@ nsFrame::GetCursor(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) &&
(mRect.Contains(aPoint))) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
// Resize and incremental reflow

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

@ -203,6 +203,7 @@ public:
PRInt32& aCursor);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetPointFromOffset(nsIPresContext* inPresContext,

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

@ -117,6 +117,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
@ -630,6 +631,7 @@ nsHTMLFramesetFrame::GetCursor(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLFramesetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
//XXX Temporary to deal with event handling in both this and FramsetBorderFrame
@ -637,7 +639,7 @@ nsHTMLFramesetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
*aFrame = this;
return NS_OK;
} else {
return nsContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
}
@ -1711,8 +1713,15 @@ nsHTMLFramesetBorderFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLFramesetBorderFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if ( (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND) ||
(!((mState & NS_FRAME_OUTSIDE_CHILDREN) || mRect.Contains(aPoint) )))
{
return NS_ERROR_FAILURE;
}
*aFrame = this;
return NS_OK;
}

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

@ -129,6 +129,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,

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

@ -78,6 +78,10 @@ public:
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD IsPercentageBase(PRBool& aBase) const {
aBase = PR_TRUE;
return NS_OK;
@ -420,6 +424,16 @@ RootFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
RootFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP
RootFrame::GetFrameType(nsIAtom** aType) const
{

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

@ -697,8 +697,16 @@ public:
nsPoint& aPoint,
PRInt32& aCursor) = 0;
/**
* 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
* the given paint layer. A frame should return itself if it should
* recieve the events. A successful return value indicates that a
* point was found.
*/
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame) = 0;

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

@ -55,6 +55,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
@ -161,6 +165,16 @@ ViewportFrame::SetInitialChildList(nsIPresContext* aPresContext,
return rv;
}
NS_IMETHODIMP
ViewportFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP
ViewportFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -104,7 +104,7 @@ public:
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
NS_IMETHOD VerifyTree() const;
#endif
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -6129,27 +6129,57 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv;
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
switch (aWhichLayer) {
case NS_FRAME_PAINT_LAYER_FOREGROUND:
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
}
return rv;
break;
case NS_FRAME_PAINT_LAYER_FLOATERS:
// we painted our floaters before our children, and thus
// we should check floaters within children first
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (mFloaters.NotEmpty()) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_FLOATERS, PR_FALSE, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
return GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::floaterList, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_FALSE, aFrame);
} else {
return NS_ERROR_FAILURE;
}
break;
case NS_FRAME_PAINT_LAYER_BACKGROUND:
// we're a block, so PR_TRUE for consider self
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
break;
}
rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
if (nsnull != mBullet) {
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::bulletList, aFrame);
if (NS_OK == rv) {
return NS_OK;
}
}
return rv;
// we shouldn't get here
NS_ASSERTION(PR_FALSE, "aWhichLayer was not understood");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -240,85 +240,52 @@ nsContainerFrame::PaintChild(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsContainerFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aFrame);
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND), aFrame);
}
nsresult
nsContainerFrame::GetFrameForPointUsing(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIAtom* aList,
nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf,
nsIFrame** aFrame)
{
nsIFrame* kid;
nsRect kidRect;
nsIFrame *kid, *hit;
nsPoint tmp;
*aFrame = this;
nsIFrame *childFrame = 0;
nsresult rv = NS_ERROR_FAILURE;
PRBool inThisFrame = mRect.Contains(aPoint);
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
return NS_ERROR_FAILURE;
}
// Attempt to find the first child that contains the desired
// point. We try to use a quick check on the child frames bbox to
// avoid a potentially expensive recursion into the child frames
// GetFrameForPoint method.
FirstChild(aPresContext, aList, &kid);
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
while (nsnull != kid) {
kid->GetRect(kidRect);
// Do a quick check and see if the child frame contains the point
if (kidRect.Contains(aPoint)) {
// The child frame contains the point. Now see if it really
// contains the point.
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
rv = kid->GetFrameForPoint(aPresContext, tmp, aFrame);
if (NS_SUCCEEDED(rv) && *aFrame) {
// We found the target frame somewhere in the child frame.
childFrame = *aFrame;
break;
}
else {
// We didn't find the target frame in any of the children,
// but save the fact that this kid contains the point.
childFrame = kid;
}
if (NS_SUCCEEDED(rv) && hit) {
*aFrame = hit;
}
kid->GetNextSibling(&kid);
}
//Only keep looking outside if we didn't absolutely find a child leaf node.
//This is indicated by the successful return from GetFrameForPoint. If we
//only found a container frame we'll have set childFrame to our best guess
//at a container frame but rv will still have failed so we should go on
//looking for the correct leaf frame in the outside children.
if (NS_FAILED(rv)) {
// Try again, this time looking only inside child frames that have
// outside children.
FirstChild(aPresContext, aList, &kid);
while (nsnull != kid) {
nsFrameState state;
kid->GetFrameState(&state);
if (NS_FRAME_OUTSIDE_CHILDREN & state) {
kid->GetRect(kidRect);
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
if (NS_OK == kid->GetFrameForPoint(aPresContext, tmp, aFrame)) {
return NS_OK;
}
else {
*aFrame = this;
}
}
kid->GetNextSibling(&kid);
}
if (*aFrame) {
return NS_OK;
}
if (childFrame) {
// We didn't find any overlapping frames that contain
// the point, so just return the original childFrame.
*aFrame = childFrame;
return NS_OK;
if ( inThisFrame && aConsiderSelf ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;

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

@ -52,6 +52,7 @@ public:
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD ReplaceFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -156,6 +157,8 @@ protected:
nsresult GetFrameForPointUsing(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIAtom* aList,
nsFramePaintLayer aWhichLayer,
PRBool aConsiderSelf,
nsIFrame** aFrame);
virtual void PaintChildren(nsIPresContext* aPresContext,

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

@ -1312,10 +1312,19 @@ nsFrame::GetCursor(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) &&
(mRect.Contains(aPoint))) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
// Resize and incremental reflow

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

@ -203,6 +203,7 @@ public:
PRInt32& aCursor);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetPointFromOffset(nsIPresContext* inPresContext,

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

@ -78,6 +78,10 @@ public:
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD IsPercentageBase(PRBool& aBase) const {
aBase = PR_TRUE;
return NS_OK;
@ -420,6 +424,16 @@ RootFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
RootFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP
RootFrame::GetFrameType(nsIAtom** aType) const
{

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

@ -389,7 +389,8 @@ public:
const nsRect& aDirtyRect);
NS_IMETHOD HandleEvent(nsIView* aView,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
nsEventStatus* aEventStatus,
PRBool& aHandled);
NS_IMETHOD Scrolled(nsIView *aView);
NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
@ -2958,7 +2959,8 @@ PresShell::PopCurrentEventFrame()
NS_IMETHODIMP
PresShell::HandleEvent(nsIView *aView,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
nsEventStatus* aEventStatus,
PRBool& aHandled)
{
void* clientData;
nsIFrame* frame;
@ -2966,6 +2968,8 @@ PresShell::HandleEvent(nsIView *aView,
NS_ASSERTION(!(nsnull == aView), "null view");
aHandled = PR_TRUE; // XXX Is this right?
if (mIsDestroying || mReflowLockCount > 0) {
return NS_OK;
}
@ -2992,10 +2996,58 @@ PresShell::HandleEvent(nsIView *aView,
manager->GetFocusedContent(&focusContent);
if (focusContent)
GetPrimaryFrameFor(focusContent, &mCurrentEventFrame);
else frame->GetFrameForPoint(mPresContext, aEvent->point, &mCurrentEventFrame);
else {
// XXX This is the way key events seem to work? Why?????
// They spend time doing calls to GetFrameForPoint with the
// point as (0,0) (or sometimes something else).
// XXX If this code is really going to stay, it should
// probably go into a separate function, because its just
// a duplicate of the code a few lines below:
// This is because we want to give the point in the same
// coordinates as the frame's own Rect, so mRect.Contains(aPoint)
// works. However, this point is relative to the frame's rect, so
// we need to add on the origin of the rect.
nsPoint eventPoint;
frame->GetOrigin(eventPoint);
eventPoint += aEvent->point;
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
// XXX Is this the right thing to do?
mCurrentEventFrame = nsnull;
aHandled = PR_FALSE;
rv = NS_OK;
}
}
}
}
}
else {
frame->GetFrameForPoint(mPresContext, aEvent->point, &mCurrentEventFrame);
// This is because we want to give the point in the same
// coordinates as the frame's own Rect, so mRect.Contains(aPoint)
// works. However, this point is relative to the frame's rect, so
// we need to add on the origin of the rect.
nsPoint eventPoint;
frame->GetOrigin(eventPoint);
eventPoint += aEvent->point;
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
if (rv != NS_OK) {
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
if (rv != NS_OK) {
// XXX Is this the right thing to do?
mCurrentEventFrame = nsnull;
aHandled = PR_FALSE;
rv = NS_OK;
}
}
}
}
NS_IF_RELEASE(mCurrentEventContent);
if (GetCurrentEventFrame() || focusContent) {
@ -3064,6 +3116,7 @@ PresShell::HandleEvent(nsIView *aView,
}
else {
rv = NS_OK;
aHandled = PR_FALSE;
}
return rv;

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

@ -844,6 +844,16 @@ nsScrollFrame::Paint(nsIPresContext* aPresContext,
aWhichLayer);
}
NS_IMETHODIMP
nsScrollFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
PRIntn
nsScrollFrame::GetSkipSides() const
{

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

@ -83,6 +83,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/**
* Get the "type" of the frame
*

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

@ -24,6 +24,7 @@
#include "nsCOMPtr.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIContent.h"
#include "nsIStyleContext.h"
nsresult
NS_NewSelectsAreaFrame(nsIPresShell* aShell, nsIFrame** aNewFrame, PRUint32 aFlags)
@ -90,18 +91,28 @@ nsSelectsAreaFrame::IsOptionElementFrame(nsIFrame *aFrame)
NS_IMETHODIMP
nsSelectsAreaFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsIFrame* selectedFrame = *aFrame;
while ((nsnull != selectedFrame) && (PR_FALSE == IsOptionElementFrame(selectedFrame))) {
selectedFrame->GetParent(&selectedFrame);
}
if (nsnull != selectedFrame) {
*aFrame = selectedFrame;
PRBool inThisFrame = mRect.Contains(aPoint);
if (!((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame )) {
return NS_ERROR_FAILURE;
}
return NS_OK;
nsresult result = nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (result == NS_OK) {
nsIFrame* selectedFrame = *aFrame;
while ((nsnull != selectedFrame) && (PR_FALSE == IsOptionElementFrame(selectedFrame))) {
selectedFrame->GetParent(&selectedFrame);
}
if (nsnull != selectedFrame) {
*aFrame = selectedFrame;
}
// else, keep the original result as *aFrame, which could be this frame
}
return result;
}

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

@ -39,7 +39,7 @@ public:
// nsISupports
//NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
protected:
PRBool IsOptionElement(nsIContent* aContent);

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

@ -55,6 +55,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
@ -161,6 +165,16 @@ ViewportFrame::SetInitialChildList(nsIPresContext* aPresContext,
return rv;
}
NS_IMETHODIMP
ViewportFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP
ViewportFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,

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

@ -117,6 +117,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
@ -630,6 +631,7 @@ nsHTMLFramesetFrame::GetCursor(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLFramesetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
//XXX Temporary to deal with event handling in both this and FramsetBorderFrame
@ -637,7 +639,7 @@ nsHTMLFramesetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
*aFrame = this;
return NS_OK;
} else {
return nsContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
}
@ -1711,8 +1713,15 @@ nsHTMLFramesetBorderFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLFramesetBorderFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if ( (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND) ||
(!((mState & NS_FRAME_OUTSIDE_CHILDREN) || mRect.Contains(aPoint) )))
{
return NS_ERROR_FAILURE;
}
*aFrame = this;
return NS_OK;
}

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

@ -129,6 +129,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,

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

@ -1643,15 +1643,32 @@ nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValue
NS_IMETHODIMP
nsComboboxControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (nsFormFrame::GetDisabled(this)) {
*aFrame = this;
return NS_OK;
} else {
return nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
PRBool inThisFrame = mRect.Contains(aPoint);
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame) ) {
return NS_ERROR_FAILURE;
}
return NS_OK;
if ( nsFormFrame::GetDisabled(this) && inThisFrame ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) {
nsresult rv = GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
if (NS_SUCCEEDED(rv)) return rv;
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, NS_FRAME_PAINT_LAYER_BACKGROUND, PR_TRUE, aFrame);
}
return NS_ERROR_FAILURE;
}

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

@ -113,7 +113,7 @@ public:
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
// nsIFormControlFrame
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);

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

@ -440,13 +440,18 @@ nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (nsFormFrame::GetDisabled(this)) {
*aFrame = this;
return NS_OK;
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
} else {
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
return NS_OK;
}

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

@ -79,7 +79,7 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
#endif
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) { return NS_OK; };
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,

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

@ -400,10 +400,18 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
if (mRect.Contains(aPoint)) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

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

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

@ -96,7 +96,7 @@ public:
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD GetFor(nsString& aFor);
@ -237,14 +237,19 @@ nsLabelFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsLabelFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
if (nsnull != *aFrame) {
nsresult rv = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (rv == NS_OK) {
nsCOMPtr<nsIFormControlFrame> controlFrame = do_QueryInterface(*aFrame);
if (!controlFrame) {
// if the hit frame isn't a form control then
// check to see if it is an anchor
// XXX It could be something else that should get the event. Perhaps
// this is better handled by event bubbling?
nsIFrame * parent;
(*aFrame)->GetParent(&parent);
while (parent != this && parent != nsnull) {
@ -252,16 +257,29 @@ nsLabelFrame::GetFrameForPoint(nsIPresContext* aPresContext,
parent->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMHTMLAnchorElement> anchorElement(do_QueryInterface(content));
if (anchorElement) {
*aFrame = parent;
return NS_OK;
nsIStyleContext *psc;
parent->GetStyleContext(&psc);
if (psc) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
psc->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = parent;
return NS_OK;
}
}
}
parent->GetParent(&parent);
}
*aFrame = this;
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
}
return NS_OK;
return rv;
}
NS_IMETHODIMP

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

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

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

@ -115,6 +115,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,
nsIDOMRange *aRange,
PRBool aSelected,

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

@ -130,6 +130,24 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext* aPresContext,
return NS_OK;
}
// override, since we want to act like a block
NS_IMETHODIMP
nsTableColFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) &&
(mRect.Contains(aPoint))) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

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

@ -93,6 +93,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

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

@ -467,6 +467,16 @@ nsTableColGroupFrame::GetSkipSides() const
return skip;
}
NS_IMETHODIMP
nsTableColGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

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

@ -95,6 +95,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** reflow of a column group is a trivial matter of reflowing
* the col group's children (columns), and setting this frame
* to 0-size. Since tables are row-centric, column group frames

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

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

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

@ -187,6 +187,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** nsIFrame method overridden to handle table specifics
*/
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,

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

@ -383,6 +383,16 @@ NS_METHOD nsTableOuterFrame::Paint(nsIPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
nsTableOuterFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext,
nsIDOMRange *aRange,
PRBool aSelected,

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

@ -108,6 +108,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** process a reflow command for the table.
* This involves reflowing the caption and the inner table.
* @see nsIFrame::Reflow */

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

@ -454,6 +454,60 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
}
}
/* we overload this here because rows have children that can span outside of themselves.
* 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.
*/
NS_IMETHODIMP
nsTableRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// 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
// the NS_FRAME_OUTSIDE_CHILDREN bit of mState set correctly (see
// nsIFrame.h).
// I imagine fixing this would help performance of GetFrameForPoint in
// tables. It may also fix problems with relative positioning.
// This is basically copied from nsContainerFrame::GetFrameForPointUsing,
// except for one bit removed
nsIFrame *kid, *hit;
nsPoint tmp;
PRBool inThisFrame = mRect.Contains(aPoint);
FirstChild(aPresContext, nsnull, &kid);
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
while (nsnull != kid) {
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
if (NS_SUCCEEDED(rv) && hit) {
*aFrame = hit;
}
kid->GetNextSibling(&kid);
}
if (*aFrame) {
return NS_OK;
}
if ( inThisFrame && (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND)) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
nscoord nsTableRowFrame::GetTallestChild() const
{

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

@ -122,6 +122,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** calls Reflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.

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

@ -270,41 +270,14 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
}
}
/* we overload this here because rows have children that can span outside of themselves.
* 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.
*/
NS_IMETHODIMP
nsTableRowGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsIFrame* kid;
nsRect kidRect;
nsPoint tmp;
*aFrame = this;
FirstChild(aPresContext, nsnull, &kid);
while (nsnull != kid) {
kid->GetRect(kidRect);
const nsStyleDisplay *childDisplay;
kid->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
if (((nsTableRowFrame*)(kid))->Contains(aPresContext, aPoint)) {
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
return kid->GetFrameForPoint(aPresContext, tmp, aFrame);
}
}
else {
if (kidRect.Contains(aPoint)) {
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
return kid->GetFrameForPoint(aPresContext, tmp, aFrame);
}
}
GetNextFrame(kid, &kid);
}
return NS_ERROR_FAILURE;
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
// Position and size aKidFrame and update our reflow state. The origin of

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

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

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

@ -272,15 +272,14 @@ nsMathMLmactionFrame::SetInitialChildList(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsMathMLmactionFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsIFrame* childFrame = GetSelectedFrame();
if (childFrame)
return childFrame->GetFrameForPoint(aPresContext, aPoint, aFrame);
return childFrame->GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
else
*aFrame = this;
return NS_OK;
return nsFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
// Only paint the selected child...

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

@ -59,6 +59,7 @@ public:
NS_IMETHOD
GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD

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

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

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

@ -115,6 +115,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,
nsIDOMRange *aRange,
PRBool aSelected,

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

@ -130,6 +130,24 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext* aPresContext,
return NS_OK;
}
// override, since we want to act like a block
NS_IMETHODIMP
nsTableColFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) &&
(mRect.Contains(aPoint))) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

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

@ -93,6 +93,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

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

@ -467,6 +467,16 @@ nsTableColGroupFrame::GetSkipSides() const
return skip;
}
NS_IMETHODIMP
nsTableColGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

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

@ -95,6 +95,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** reflow of a column group is a trivial matter of reflowing
* the col group's children (columns), and setting this frame
* to 0-size. Since tables are row-centric, column group frames

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

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

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

@ -187,6 +187,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** nsIFrame method overridden to handle table specifics
*/
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,

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

@ -383,6 +383,16 @@ NS_METHOD nsTableOuterFrame::Paint(nsIPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
nsTableOuterFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext,
nsIDOMRange *aRange,
PRBool aSelected,

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

@ -108,6 +108,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** process a reflow command for the table.
* This involves reflowing the caption and the inner table.
* @see nsIFrame::Reflow */

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

@ -454,6 +454,60 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
}
}
/* we overload this here because rows have children that can span outside of themselves.
* 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.
*/
NS_IMETHODIMP
nsTableRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// 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
// the NS_FRAME_OUTSIDE_CHILDREN bit of mState set correctly (see
// nsIFrame.h).
// I imagine fixing this would help performance of GetFrameForPoint in
// tables. It may also fix problems with relative positioning.
// This is basically copied from nsContainerFrame::GetFrameForPointUsing,
// except for one bit removed
nsIFrame *kid, *hit;
nsPoint tmp;
PRBool inThisFrame = mRect.Contains(aPoint);
FirstChild(aPresContext, nsnull, &kid);
*aFrame = nsnull;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
while (nsnull != kid) {
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
if (NS_SUCCEEDED(rv) && hit) {
*aFrame = hit;
}
kid->GetNextSibling(&kid);
}
if (*aFrame) {
return NS_OK;
}
if ( inThisFrame && (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND)) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
nscoord nsTableRowFrame::GetTallestChild() const
{

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

@ -122,6 +122,11 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
/** calls Reflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.

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

@ -270,41 +270,14 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
}
}
/* we overload this here because rows have children that can span outside of themselves.
* 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.
*/
NS_IMETHODIMP
nsTableRowGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsIFrame* kid;
nsRect kidRect;
nsPoint tmp;
*aFrame = this;
FirstChild(aPresContext, nsnull, &kid);
while (nsnull != kid) {
kid->GetRect(kidRect);
const nsStyleDisplay *childDisplay;
kid->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
if (((nsTableRowFrame*)(kid))->Contains(aPresContext, aPoint)) {
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
return kid->GetFrameForPoint(aPresContext, tmp, aFrame);
}
}
else {
if (kidRect.Contains(aPoint)) {
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
return kid->GetFrameForPoint(aPresContext, tmp, aFrame);
}
}
GetNextFrame(kid, &kid);
}
return NS_ERROR_FAILURE;
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
}
// Position and size aKidFrame and update our reflow state. The origin of

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

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

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

@ -3505,9 +3505,11 @@ nsCalculatedBoxInfoImpl::Clear()
NS_IMETHODIMP
nsBoxFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
return nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
// this should act like a block, so we need to override
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
/*
nsRect r(0,0,mRect.width, mRect.height);

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

@ -85,6 +85,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,

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

@ -186,29 +186,39 @@ nsDeckFrame::Paint(nsIPresContext* aPresContext,
NS_IMETHODIMP nsDeckFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// if its not in our child just return us.
*aFrame = this;
// If it's not in this frame, then it's not going to be in any
// children (since there cannot be overflowing children).
if (!mRect.Contains(aPoint)) {
return NS_ERROR_FAILURE;
}
// get the selected frame and see if the point is in it.
nsIFrame* selectedFrame = GetSelectedFrame();
if (nsnull != selectedFrame)
{
nsRect childRect;
selectedFrame->GetRect(childRect);
// adjust the point
nsPoint p = aPoint;
p.x -= mRect.x;
p.y -= mRect.y;
return selectedFrame->GetFrameForPoint(aPresContext, p, aWhichLayer, aFrame);
}
if (childRect.Contains(aPoint)) {
// adjust the point
nsPoint p = aPoint;
p.x -= childRect.x;
p.y -= childRect.y;
return selectedFrame->GetFrameForPoint(aPresContext, p, aFrame);
if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) {
// if its not in our child just return us.
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
}
return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -58,6 +58,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetFrameName(nsString& aResult) const

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

@ -217,22 +217,32 @@ nsMenuFrame::Destroy(nsIPresContext* aPresContext)
NS_IMETHODIMP
nsMenuFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult result = nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsCOMPtr<nsIContent> content;
if (*aFrame) {
(*aFrame)->GetContent(getter_AddRefs(content));
if (content) {
// This allows selective overriding for subcontent.
nsAutoString value;
content->GetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value == "true")
return result;
}
if (!mRect.Contains(aPoint)) {
return NS_ERROR_FAILURE;
}
*aFrame = this; // Capture all events so that we can perform selection
return NS_OK;
nsresult result = nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if ((result != NS_OK) || (*aFrame == this)) {
return result;
}
nsCOMPtr<nsIContent> content;
(*aFrame)->GetContent(getter_AddRefs(content));
if (content) {
// This allows selective overriding for subcontent.
nsAutoString value;
content->GetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value == "true")
return result;
}
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this; // Capture all events so that we can perform selection
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

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

@ -88,6 +88,7 @@ public:
// Overridden to prevent events from ever going to children of the menu.
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,

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

@ -1229,16 +1229,10 @@ nsMenuPopupFrame::Destroy(nsIPresContext* aPresContext)
NS_IMETHODIMP
nsMenuPopupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsRect rect;
GetRect(rect);
if (rect.Contains(aPoint)) {
return nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
}
*aFrame = this;
return NS_OK;
return nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
NS_IMETHODIMP_(void)
@ -1295,4 +1289,3 @@ nsMenuPopupFrame::KillCloseTimer()
}
return NS_OK;
}

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

@ -102,7 +102,7 @@ public:
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
static void GetNearestEnclosingView(nsIPresContext* aPresContext, nsIFrame* aStartFrame, nsIView** aResult);

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

@ -668,26 +668,55 @@ nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame,
NS_IMETHODIMP nsSliderFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (isDraggingThumb(aPresContext))
{
// XXX I assume it's better not to test for visibility here.
*aFrame = this;
return NS_OK;
}
if ((! mRect.Contains(aPoint)) ||
(aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND)) {
return NS_ERROR_FAILURE;
}
nsIFrame* thumbFrame = mFrames.FirstChild();
// XXX If thumbFrame always considers itself FOREGROUND, then it
// would be better to just call thumbFrame->GetFrameForPoint and
// return if it returns NS_OK.
nsRect thumbRect;
thumbFrame->GetRect(thumbRect);
if (thumbRect.Contains(aPoint)) {
*aFrame = thumbFrame;
} else {
// always return us
*aFrame = this;
nsPoint tmp;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
if (thumbRect.Contains(tmp)) {
nsIStyleContext *tsc;
thumbFrame->GetStyleContext(&tsc);
if (tsc) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
tsc->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = thumbFrame;
NS_RELEASE(tsc);
return NS_OK;
}
NS_RELEASE(tsc);
}
}
return NS_OK;
// always return us (if visible)
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
return NS_ERROR_FAILURE;
//return nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
}

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

@ -110,7 +110,7 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, nsIFrame** aFrame);
const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,

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

@ -419,15 +419,17 @@ nsSplitterFrame::HandleRelease(nsIPresContext* aPresContext,
NS_IMETHODIMP nsSplitterFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
// if the mouse is captured always return us as the frame.
if (mInner->IsMouseCaptured(aPresContext))
{
// XXX It's probably better not to check visibility here, right?
*aFrame = this;
return NS_OK;
} else
return nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
NS_IMETHODIMP

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

@ -93,7 +93,7 @@ public:
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
virtual PRBool GetInitialOrientation(PRBool& aIsHorizontal);

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

@ -28,6 +28,7 @@
//
#include "nsSpringFrame.h"
#include "nsIStyleContext.h"
nsresult
NS_NewSpringFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
@ -47,10 +48,23 @@ NS_NewSpringFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
NS_IMETHODIMP nsSpringFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (!mRect.Contains(aPoint)) {
return NS_ERROR_FAILURE;
}
// always return us (if visible)
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this;
return NS_OK;
}
return NS_ERROR_FAILURE;
/*
// clicks just go right through springs.
return NS_ERROR_FAILURE;

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

@ -42,6 +42,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetFrameName(nsString& aResult) const

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

@ -151,12 +151,14 @@ nsStackFrame::LayoutChildrenInRect(nsRect& aGivenSize, nscoord& aMaxAscent)
NS_IMETHODIMP
nsStackFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsRect r(0,0,mRect.width, mRect.height);
nsRect r(mRect);
// if it is not inside us fail
if (!r.Contains(aPoint)) {
// if it is not inside us or not in the layer in which we paint, fail
if ((aWhichLayer != NS_FRAME_PAINT_LAYER_BACKGROUND) ||
(!r.Contains(aPoint))) {
return NS_ERROR_FAILURE;
}
@ -176,8 +178,6 @@ nsStackFrame::GetFrameForPoint(nsIPresContext* aPresContext,
return NS_OK;
}
// nsPoint tmp;
//tmp.MoveTo(aPoint.x - r.x, aPoint.y - r.y);
nsIFrame* first = mFrames.FirstChild();
@ -186,9 +186,11 @@ nsStackFrame::GetFrameForPoint(nsIPresContext* aPresContext,
// look at the children in reverse order
nsresult rv;
if (first)
rv = GetStackedFrameForPoint(aPresContext, first, nsRect(0,0,mRect.width, mRect.height), aPoint, aFrame);
else
if (first) {
nsPoint tmp;
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
rv = GetStackedFrameForPoint(aPresContext, first, nsRect(0,0,mRect.width, mRect.height), tmp, aFrame);
} else
rv = NS_ERROR_FAILURE;
if (!NS_SUCCEEDED(rv)) {
@ -230,24 +232,18 @@ nsStackFrame::GetStackedFrameForPoint(nsIPresContext* aPresContext,
// look at all the children is reverse order. Use the stack to do
// this.
nsIFrame* next;
nsresult rv;
aChild->GetNextSibling(&next);
if (next != nsnull) {
nsresult rv = GetStackedFrameForPoint(aPresContext, next, aRect, aPoint, aFrame);
rv = GetStackedFrameForPoint(aPresContext, next, aRect, aPoint, aFrame);
if (NS_SUCCEEDED(rv) && *aFrame)
return rv;
}
nsRect childRect;
aChild->GetRect(childRect);
if (childRect.Contains(aPoint)) {
nsPoint tmp;
tmp.MoveTo(aPoint.x - childRect.x, aPoint.y - childRect.y);
return aChild->GetFrameForPoint(aPresContext, tmp, aFrame);
}
return NS_ERROR_FAILURE;
rv = aChild->GetFrameForPoint(aPresContext, aPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, aFrame);
if (NS_SUCCEEDED(rv) && *aFrame)
return rv;
return aChild->GetFrameForPoint(aPresContext, aPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, aFrame);
}
void

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

@ -49,6 +49,7 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD GetFrameName(nsString& aResult) const

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

@ -284,6 +284,7 @@ nsToolbarFrame :: Paint ( nsIPresContext* aPresContext,
} // Paint
#if 0
//
// GetFrameForPoint
//
@ -292,9 +293,14 @@ nsToolbarFrame :: Paint ( nsIPresContext* aPresContext,
NS_IMETHODIMP
nsToolbarFrame :: GetFrameForPoint ( nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (! mRect.Contains(aPoint)) {
return retVal;
}
// returning NS_OK means that we tell the frame finding code that we have something
// and to stop looking elsewhere for a frame.
@ -308,6 +314,7 @@ nsToolbarFrame :: GetFrameForPoint ( nsIPresContext* aPresContext,
return retVal;
} // GetFrameForPoint
#endif
//

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

@ -74,9 +74,12 @@ public:
nsFramePaintLayer aWhichLayer);
// nsFrame overrides
#if 0
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
#endif
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,

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

@ -576,6 +576,7 @@ nsToolboxFrame::GetInset(nsMargin& margin)
}
#if 0
//
// GetFrameForPoint
//
@ -584,9 +585,14 @@ nsToolboxFrame::GetInset(nsMargin& margin)
NS_IMETHODIMP
nsToolboxFrame :: GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (! mRect.Contains(aPoint)) {
return retVal;
}
// returning NS_OK means that we tell the frame finding code that we have something
// and to stop looking elsewhere for a frame.
@ -596,10 +602,10 @@ nsToolboxFrame :: GetFrameForPoint(nsIPresContext* aPresContext,
*aFrame = this;
retVal = NS_OK;
}
return retVal;
} // GetFrameForPoint
#endif
//

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

@ -85,10 +85,13 @@ public:
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
#if 0
// Overridden to capture events
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
#endif
/*BEGIN implementations of dragevent handler interface*/
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);

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

@ -150,17 +150,22 @@ NS_IMETHODIMP nsTreeCellFrame::Reflow(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
if (mAllowEvents)
{
return nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
return nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
}
else
{
nsresult result = nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
if (! ( mRect.Contains(aPoint) || ( mState & NS_FRAME_OUTSIDE_CHILDREN)) )
{
return NS_ERROR_FAILURE;
}
nsresult result = nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
nsCOMPtr<nsIContent> content;
if (*aFrame) {
if (result == NS_OK) {
(*aFrame)->GetContent(getter_AddRefs(content));
if (content) {
// This allows selective overriding for subcontent.
@ -170,8 +175,15 @@ nsTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
return result;
}
}
*aFrame = this; // Capture all events so that we can perform selection and expand/collapse.
return NS_OK;
if (mRect.Contains(aPoint)) {
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisible()) {
*aFrame = this; // Capture all events so that we can perform selection and expand/collapse.
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
}

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

@ -39,6 +39,7 @@ public:
PRInt32 aHint);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,

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

@ -246,9 +246,10 @@ nsTreeRowFrame::HandleEvent(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsTreeRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame)
{
nsresult rv = nsTableRowFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsresult rv = nsTableRowFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
if (mDraggingHeader) {
mHitFrame = *aFrame;
*aFrame = this;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше