зеркало из https://github.com/mozilla/gecko-dev.git
fixed the bug where events were not getting passed down to content inside
of cells with rowspans. Basically, I just override HandleEvent() in nsTableRowGroupFrame to ask nsTableRowFrame::Contains(), rather than the default action which is to just use the child's rect.
This commit is contained in:
Родитель
5befa347fb
Коммит
a8be97a521
|
@ -1374,6 +1374,46 @@ nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
PRBool nsTableRowFrame::Contains(nsPoint& aPoint)
|
||||
{
|
||||
if (gsDebug) printf("Row %p index %d ::Contains aPoint(%d,%d) and row rect (%d,%d,%d,%d)\n",
|
||||
this, mRowIndex,
|
||||
aPoint.x, aPoint.y,
|
||||
mRect.x, mRect.y, mRect.width, mRect.height);
|
||||
PRBool result = PR_FALSE;
|
||||
// first, check the row rect and see if the point is in their
|
||||
if (mRect.Contains(aPoint)) {
|
||||
if (gsDebug) printf("%p Row::Contains point.\n");
|
||||
result = PR_TRUE;
|
||||
}
|
||||
// if that fails, check the cells, they might span outside the row rect
|
||||
else {
|
||||
nsIFrame* kid;
|
||||
FirstChild(kid);
|
||||
while (nsnull != kid) {
|
||||
nsRect kidRect;
|
||||
kid->GetRect(kidRect);
|
||||
nsPoint point(aPoint);
|
||||
point.MoveBy(-mRect.x, -mRect.y); // offset the point to check by the row container
|
||||
if (gsDebug) printf("Row %p checking point (%d,%d) vs. cell rect (%d,%d,%d,%d)\n",
|
||||
point.x, point.y,
|
||||
kidRect.x, kidRect.y, kidRect.width, kidRect.height);
|
||||
if (kidRect.Contains(point)) {
|
||||
if (gsDebug) printf("cell contains point.\n");
|
||||
result = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
kid->GetNextSibling(kid);
|
||||
}
|
||||
}
|
||||
if (gsDebug) printf("%p Row::Contains returning %d\n", this, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -119,6 +119,8 @@ public:
|
|||
/** set this row's starting row index */
|
||||
virtual void SetRowIndex (int aRowIndex);
|
||||
|
||||
virtual PRBool Contains(nsPoint& aPoint);
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -226,6 +226,48 @@ 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_METHOD nsTableRowGroupFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (gsDebug) printf("TRGF %p::HandleEvent aPoint(%d,%d) and row rect (%d,%d,%d,%d)\n",
|
||||
this, aEvent->point.x, aEvent->point.y,
|
||||
mRect.x, mRect.y, mRect.width, mRect.height);
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
nsIFrame* kid;
|
||||
FirstChild(kid);
|
||||
while (nsnull != kid) {
|
||||
nsRect kidRect;
|
||||
kid->GetRect(kidRect);
|
||||
const nsStyleDisplay *childDisplay;
|
||||
kid->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
|
||||
if (((nsTableRowFrame*)(kid))->Contains(aEvent->point)) {
|
||||
if (gsDebug) printf("%p TRGF::HE calling HE on child %d\n", this, kid);
|
||||
aEvent->point.MoveBy(-kidRect.x, -kidRect.y);
|
||||
kid->HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
aEvent->point.MoveBy(kidRect.x, kidRect.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aEvent->point.MoveBy(-kidRect.x, -kidRect.y);
|
||||
kid->HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
aEvent->point.MoveBy(kidRect.x, kidRect.y);
|
||||
break;
|
||||
}
|
||||
kid->GetNextSibling(kid);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aReflowState,
|
||||
|
|
|
@ -66,6 +66,15 @@ public:
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
/**
|
||||
* Pass through the event to the correct child frame.
|
||||
* Return PR_TRUE if the event is consumed.
|
||||
* @see nsContainerFrame::HandleEvent
|
||||
*/
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
/** calls Reflow for all of its child rows.
|
||||
* Rows are all set to the same width and stacked vertically.
|
||||
* <P> rows are not split unless absolutely necessary.
|
||||
|
|
|
@ -1374,6 +1374,46 @@ nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
PRBool nsTableRowFrame::Contains(nsPoint& aPoint)
|
||||
{
|
||||
if (gsDebug) printf("Row %p index %d ::Contains aPoint(%d,%d) and row rect (%d,%d,%d,%d)\n",
|
||||
this, mRowIndex,
|
||||
aPoint.x, aPoint.y,
|
||||
mRect.x, mRect.y, mRect.width, mRect.height);
|
||||
PRBool result = PR_FALSE;
|
||||
// first, check the row rect and see if the point is in their
|
||||
if (mRect.Contains(aPoint)) {
|
||||
if (gsDebug) printf("%p Row::Contains point.\n");
|
||||
result = PR_TRUE;
|
||||
}
|
||||
// if that fails, check the cells, they might span outside the row rect
|
||||
else {
|
||||
nsIFrame* kid;
|
||||
FirstChild(kid);
|
||||
while (nsnull != kid) {
|
||||
nsRect kidRect;
|
||||
kid->GetRect(kidRect);
|
||||
nsPoint point(aPoint);
|
||||
point.MoveBy(-mRect.x, -mRect.y); // offset the point to check by the row container
|
||||
if (gsDebug) printf("Row %p checking point (%d,%d) vs. cell rect (%d,%d,%d,%d)\n",
|
||||
point.x, point.y,
|
||||
kidRect.x, kidRect.y, kidRect.width, kidRect.height);
|
||||
if (kidRect.Contains(point)) {
|
||||
if (gsDebug) printf("cell contains point.\n");
|
||||
result = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
kid->GetNextSibling(kid);
|
||||
}
|
||||
}
|
||||
if (gsDebug) printf("%p Row::Contains returning %d\n", this, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -119,6 +119,8 @@ public:
|
|||
/** set this row's starting row index */
|
||||
virtual void SetRowIndex (int aRowIndex);
|
||||
|
||||
virtual PRBool Contains(nsPoint& aPoint);
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -226,6 +226,48 @@ 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_METHOD nsTableRowGroupFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (gsDebug) printf("TRGF %p::HandleEvent aPoint(%d,%d) and row rect (%d,%d,%d,%d)\n",
|
||||
this, aEvent->point.x, aEvent->point.y,
|
||||
mRect.x, mRect.y, mRect.width, mRect.height);
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
nsIFrame* kid;
|
||||
FirstChild(kid);
|
||||
while (nsnull != kid) {
|
||||
nsRect kidRect;
|
||||
kid->GetRect(kidRect);
|
||||
const nsStyleDisplay *childDisplay;
|
||||
kid->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
|
||||
if (((nsTableRowFrame*)(kid))->Contains(aEvent->point)) {
|
||||
if (gsDebug) printf("%p TRGF::HE calling HE on child %d\n", this, kid);
|
||||
aEvent->point.MoveBy(-kidRect.x, -kidRect.y);
|
||||
kid->HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
aEvent->point.MoveBy(kidRect.x, kidRect.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aEvent->point.MoveBy(-kidRect.x, -kidRect.y);
|
||||
kid->HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
aEvent->point.MoveBy(kidRect.x, kidRect.y);
|
||||
break;
|
||||
}
|
||||
kid->GetNextSibling(kid);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aReflowState,
|
||||
|
|
|
@ -66,6 +66,15 @@ public:
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
/**
|
||||
* Pass through the event to the correct child frame.
|
||||
* Return PR_TRUE if the event is consumed.
|
||||
* @see nsContainerFrame::HandleEvent
|
||||
*/
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
/** calls Reflow for all of its child rows.
|
||||
* Rows are all set to the same width and stacked vertically.
|
||||
* <P> rows are not split unless absolutely necessary.
|
||||
|
|
Загрузка…
Ссылка в новой задаче