зеркало из https://github.com/mozilla/gecko-dev.git
Bug 163137. Make DOM inspector scroll to put an element in view upon selecting it in the DOM tree view. This was previously only working for HTML elements.
r=rbs, sr=bzbarsky
This commit is contained in:
Родитель
c532fa8ac0
Коммит
235a80e8a2
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
* Christopher A. Aillon <christopher@aillon.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -47,5 +48,6 @@ interface inIFlasher : nsISupports
|
|||
{
|
||||
void drawElementOutline(in nsIDOMElement aElement, in wstring aColor, in long aThickness, in boolean aInvert);
|
||||
void repaintElement(in nsIDOMElement aElement);
|
||||
void scrollElementIntoView(in nsIDOMElement aElement);
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
* Christopher A. Aillon <christopher@aillon.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -43,6 +44,8 @@
|
|||
#include "nsIViewManager.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID);
|
||||
|
||||
|
@ -134,12 +137,37 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement, const PRUnichar* aColor,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inFlasher::ScrollElementIntoView(nsIDOMElement *aElement)
|
||||
{
|
||||
NS_PRECONDITION(aElement, "Dude, where's my arg?!");
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
|
||||
if (!window) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
|
||||
NS_ASSERTION(presShell, "Dude, where's my pres shell?!");
|
||||
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
|
||||
if (!frame) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
presShell->ScrollFrameIntoView(frame,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE /* VPercent */,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE /* HPercent */);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inFlasher
|
||||
|
||||
NS_IMETHODIMP
|
||||
inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, nscolor aColor,
|
||||
PRUint32 aThickness, float aP2T, nsIRenderingContext* aRenderContext)
|
||||
nsresult
|
||||
inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
nscolor aColor, PRUint32 aThickness, float aP2T,
|
||||
nsIRenderingContext* aRenderContext)
|
||||
{
|
||||
aRenderContext->SetColor(aColor);
|
||||
DrawLine(aX, aY, aWidth, aThickness, DIR_HORIZONTAL, BOUND_OUTER, aP2T, aRenderContext);
|
||||
|
@ -150,9 +178,10 @@ inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inFlasher::DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRUint32 aThickness,
|
||||
PRBool aDir, PRBool aBounds, float aP2T, nsIRenderingContext* aRenderContext)
|
||||
nsresult
|
||||
inFlasher::DrawLine(nscoord aX, nscoord aY, nscoord aLength,
|
||||
PRUint32 aThickness, PRBool aDir, PRBool aBounds,
|
||||
float aP2T, nsIRenderingContext* aRenderContext)
|
||||
{
|
||||
nscoord thickTwips = NSIntPixelsToTwips(aThickness, aP2T);
|
||||
if (aDir) { // horizontal
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
|
||||
#include "nsIInspectorCSSUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define BOUND_INNER 0
|
||||
#define BOUND_OUTER 1
|
||||
|
||||
|
@ -63,13 +63,12 @@ public:
|
|||
virtual ~inFlasher();
|
||||
|
||||
protected:
|
||||
nsIFrame* GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell);
|
||||
nsIPresShell* GetPresShellFor(nsISupports* aThing);
|
||||
|
||||
NS_IMETHOD DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, nscolor aColor,
|
||||
PRUint32 aThickness, float aP2T, nsIRenderingContext* aRenderContext);
|
||||
NS_IMETHOD DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRUint32 aThickness,
|
||||
PRBool aDir, PRBool aBounds, float aP2T, nsIRenderingContext* aRenderContext);
|
||||
nsresult DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
nscolor aColor, PRUint32 aThickness, float aP2T,
|
||||
nsIRenderingContext* aRenderContext);
|
||||
nsresult DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRUint32 aThickness,
|
||||
PRBool aDir, PRBool aBounds, float aP2T,
|
||||
nsIRenderingContext* aRenderContext);
|
||||
|
||||
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче