Event Target Debugging (b=18175), a debugging feature to help with fixing bugs where events are going to the wrong elements. It shows (like Visual Debugging) which frame is receiving events, and one can therefore move the mouse over the page to see what frame gets events. All the code is #ifdef NS_DEBUG. However, it is not yet hooked up to the viewer menu (to be checked in later).
r=joki
This commit is contained in:
Родитель
01765890e9
Коммит
2d313e91ec
|
@ -41,6 +41,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetShowFrameBorders(PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable) = 0;
|
||||
|
||||
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult) = 0;
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetShowFrameBorders(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable);
|
||||
|
||||
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult);
|
||||
|
||||
|
@ -87,6 +91,20 @@ nsLayoutDebugger::GetShowFrameBorders(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::SetShowEventTargetFrameBorder(PRBool aEnable)
|
||||
{
|
||||
nsIFrameDebug::ShowEventTargetFrameBorder(aEnable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::GetShowEventTargetFrameBorder(PRBool* aResult)
|
||||
{
|
||||
*aResult = nsIFrameDebug::GetShowEventTargetFrameBorder();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult)
|
||||
|
|
|
@ -477,6 +477,10 @@ protected:
|
|||
nsIFrame* mCurrentEventFrame;
|
||||
nsIContent* mCurrentEventContent;
|
||||
nsVoidArray mCurrentEventFrameStack;
|
||||
#ifdef NS_DEBUG
|
||||
nsRect mCurrentTargetRect;
|
||||
nsIView* mCurrentTargetView;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIFrameSelection> mSelection;
|
||||
nsCOMPtr<nsICaret> mCaret;
|
||||
|
@ -618,6 +622,9 @@ PresShell::PresShell()
|
|||
mCurrentEventContent = nsnull;
|
||||
mCurrentEventFrame = nsnull;
|
||||
EnableScrolling();
|
||||
#ifdef NS_DEBUG
|
||||
mCurrentTargetView = nsnull;
|
||||
#endif
|
||||
mPendingReflowEvent = PR_FALSE;
|
||||
mDocumentIsLoading = PR_TRUE;
|
||||
mBatchReflows = PR_FALSE;
|
||||
|
@ -2734,6 +2741,11 @@ PresShell::Paint(nsIView *aView,
|
|||
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
||||
aRenderingContext.DrawRect(0, 0, r.width, r.height);
|
||||
}
|
||||
// Draw a border around the current event target
|
||||
if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (aView == mCurrentTargetView)) {
|
||||
aRenderingContext.SetColor(NS_RGB(128,0,128));
|
||||
aRenderingContext.DrawRect(mCurrentTargetRect.x, mCurrentTargetRect.y, mCurrentTargetRect.width, mCurrentTargetRect.height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2856,6 +2868,32 @@ PresShell::HandleEvent(nsIView *aView,
|
|||
NS_RELEASE(manager);
|
||||
NS_IF_RELEASE(focusContent);
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (GetCurrentEventFrame())) {
|
||||
nsIView *oldView = mCurrentTargetView;
|
||||
nsPoint offset(0,0);
|
||||
nsRect oldTargetRect(mCurrentTargetRect);
|
||||
mCurrentEventFrame->GetRect(mCurrentTargetRect);
|
||||
mCurrentEventFrame->GetView(mPresContext, &mCurrentTargetView);
|
||||
if ( ! mCurrentTargetView ) {
|
||||
mCurrentEventFrame->GetOffsetFromView(mPresContext, offset, &mCurrentTargetView);
|
||||
}
|
||||
if (mCurrentTargetView) {
|
||||
mCurrentTargetRect.x = offset.x;
|
||||
mCurrentTargetRect.y = offset.y;
|
||||
// use aView or mCurrentTargetView??
|
||||
if ( (mCurrentTargetRect != oldTargetRect) || (mCurrentTargetView != oldView)) {
|
||||
nsIViewManager *vm;
|
||||
if ((NS_OK == GetViewManager(&vm)) && vm) {
|
||||
vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0);
|
||||
if (oldView)
|
||||
vm->UpdateView(oldView,oldTargetRect,0);
|
||||
NS_IF_RELEASE(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
PopCurrentEventFrame();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -115,6 +115,10 @@ public:
|
|||
static NS_LAYOUT void ShowFrameBorders(PRBool aEnable);
|
||||
static NS_LAYOUT PRBool GetShowFrameBorders();
|
||||
|
||||
// Show frame border of event target
|
||||
static NS_LAYOUT void ShowEventTargetFrameBorder(PRBool aEnable);
|
||||
static NS_LAYOUT PRBool GetShowEventTargetFrameBorder();
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetShowFrameBorders(PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable) = 0;
|
||||
|
||||
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult) = 0;
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetShowFrameBorders(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable);
|
||||
|
||||
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult);
|
||||
|
||||
|
@ -87,6 +91,20 @@ nsLayoutDebugger::GetShowFrameBorders(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::SetShowEventTargetFrameBorder(PRBool aEnable)
|
||||
{
|
||||
nsIFrameDebug::ShowEventTargetFrameBorder(aEnable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::GetShowEventTargetFrameBorder(PRBool* aResult)
|
||||
{
|
||||
*aResult = nsIFrameDebug::GetShowEventTargetFrameBorder();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
|
||||
PRInt32* aSizeInBytesResult)
|
||||
|
|
|
@ -107,6 +107,18 @@ NS_LAYOUT PRBool nsIFrameDebug::GetShowFrameBorders()
|
|||
return gShowFrameBorders;
|
||||
}
|
||||
|
||||
static PRBool gShowEventTargetFrameBorder = PR_FALSE;
|
||||
|
||||
NS_LAYOUT void nsIFrameDebug::ShowEventTargetFrameBorder(PRBool aEnable)
|
||||
{
|
||||
gShowEventTargetFrameBorder = aEnable;
|
||||
}
|
||||
|
||||
NS_LAYOUT PRBool nsIFrameDebug::GetShowEventTargetFrameBorder()
|
||||
{
|
||||
return gShowEventTargetFrameBorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: the log module is created during library initialization which
|
||||
* means that you cannot perform logging before then.
|
||||
|
|
|
@ -115,6 +115,10 @@ public:
|
|||
static NS_LAYOUT void ShowFrameBorders(PRBool aEnable);
|
||||
static NS_LAYOUT PRBool GetShowFrameBorders();
|
||||
|
||||
// Show frame border of event target
|
||||
static NS_LAYOUT void ShowEventTargetFrameBorder(PRBool aEnable);
|
||||
static NS_LAYOUT PRBool GetShowEventTargetFrameBorder();
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
|
|
|
@ -107,6 +107,18 @@ NS_LAYOUT PRBool nsIFrameDebug::GetShowFrameBorders()
|
|||
return gShowFrameBorders;
|
||||
}
|
||||
|
||||
static PRBool gShowEventTargetFrameBorder = PR_FALSE;
|
||||
|
||||
NS_LAYOUT void nsIFrameDebug::ShowEventTargetFrameBorder(PRBool aEnable)
|
||||
{
|
||||
gShowEventTargetFrameBorder = aEnable;
|
||||
}
|
||||
|
||||
NS_LAYOUT PRBool nsIFrameDebug::GetShowEventTargetFrameBorder()
|
||||
{
|
||||
return gShowEventTargetFrameBorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: the log module is created during library initialization which
|
||||
* means that you cannot perform logging before then.
|
||||
|
|
|
@ -477,6 +477,10 @@ protected:
|
|||
nsIFrame* mCurrentEventFrame;
|
||||
nsIContent* mCurrentEventContent;
|
||||
nsVoidArray mCurrentEventFrameStack;
|
||||
#ifdef NS_DEBUG
|
||||
nsRect mCurrentTargetRect;
|
||||
nsIView* mCurrentTargetView;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIFrameSelection> mSelection;
|
||||
nsCOMPtr<nsICaret> mCaret;
|
||||
|
@ -618,6 +622,9 @@ PresShell::PresShell()
|
|||
mCurrentEventContent = nsnull;
|
||||
mCurrentEventFrame = nsnull;
|
||||
EnableScrolling();
|
||||
#ifdef NS_DEBUG
|
||||
mCurrentTargetView = nsnull;
|
||||
#endif
|
||||
mPendingReflowEvent = PR_FALSE;
|
||||
mDocumentIsLoading = PR_TRUE;
|
||||
mBatchReflows = PR_FALSE;
|
||||
|
@ -2734,6 +2741,11 @@ PresShell::Paint(nsIView *aView,
|
|||
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
||||
aRenderingContext.DrawRect(0, 0, r.width, r.height);
|
||||
}
|
||||
// Draw a border around the current event target
|
||||
if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (aView == mCurrentTargetView)) {
|
||||
aRenderingContext.SetColor(NS_RGB(128,0,128));
|
||||
aRenderingContext.DrawRect(mCurrentTargetRect.x, mCurrentTargetRect.y, mCurrentTargetRect.width, mCurrentTargetRect.height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2856,6 +2868,32 @@ PresShell::HandleEvent(nsIView *aView,
|
|||
NS_RELEASE(manager);
|
||||
NS_IF_RELEASE(focusContent);
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (GetCurrentEventFrame())) {
|
||||
nsIView *oldView = mCurrentTargetView;
|
||||
nsPoint offset(0,0);
|
||||
nsRect oldTargetRect(mCurrentTargetRect);
|
||||
mCurrentEventFrame->GetRect(mCurrentTargetRect);
|
||||
mCurrentEventFrame->GetView(mPresContext, &mCurrentTargetView);
|
||||
if ( ! mCurrentTargetView ) {
|
||||
mCurrentEventFrame->GetOffsetFromView(mPresContext, offset, &mCurrentTargetView);
|
||||
}
|
||||
if (mCurrentTargetView) {
|
||||
mCurrentTargetRect.x = offset.x;
|
||||
mCurrentTargetRect.y = offset.y;
|
||||
// use aView or mCurrentTargetView??
|
||||
if ( (mCurrentTargetRect != oldTargetRect) || (mCurrentTargetView != oldView)) {
|
||||
nsIViewManager *vm;
|
||||
if ((NS_OK == GetViewManager(&vm)) && vm) {
|
||||
vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0);
|
||||
if (oldView)
|
||||
vm->UpdateView(oldView,oldTargetRect,0);
|
||||
NS_IF_RELEASE(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
PopCurrentEventFrame();
|
||||
}
|
||||
else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче