mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 14:30:43 +00:00
Added SizeOf printout support
This commit is contained in:
parent
591b2ccd11
commit
fe2fe771df
@ -48,7 +48,10 @@
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDocLoader.h"
|
||||
#include "nsIFileWidget.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
|
||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
@ -101,6 +104,80 @@ extern int NET_PollSockets();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void
|
||||
WindowData::ShowContentSize()
|
||||
{
|
||||
if (nsnull == ww) {
|
||||
return;
|
||||
}
|
||||
nsISizeOfHandler* szh;
|
||||
if (NS_OK != NS_NewSizeOfHandler(&szh)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDocument* doc;
|
||||
doc = ww->GetDocument();
|
||||
if (nsnull != doc) {
|
||||
nsIContent* content;
|
||||
content = doc->GetRootContent();
|
||||
if (nsnull != content) {
|
||||
content->SizeOf(szh);
|
||||
PRUint32 totalSize;
|
||||
szh->GetSize(totalSize);
|
||||
printf("Content model size is approximately %d bytes\n", totalSize);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
NS_RELEASE(szh);
|
||||
}
|
||||
|
||||
void
|
||||
WindowData::ShowFrameSize()
|
||||
{
|
||||
if (nsnull == ww) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDocument* doc;
|
||||
|
||||
doc = ww->GetDocument();
|
||||
if (nsnull != doc ){
|
||||
PRInt32 i, shells = doc->GetNumberOfShells();
|
||||
for (i = 0; i < shells; i++) {
|
||||
nsIPresShell* shell = doc->GetShellAt(i);
|
||||
if (nsnull != shell) {
|
||||
nsISizeOfHandler* szh;
|
||||
if (NS_OK != NS_NewSizeOfHandler(&szh)) {
|
||||
return;
|
||||
}
|
||||
nsIFrame* root;
|
||||
root = shell->GetRootFrame();
|
||||
if (nsnull != root) {
|
||||
root->SizeOf(szh);
|
||||
PRUint32 totalSize;
|
||||
szh->GetSize(totalSize);
|
||||
printf("Frame model for shell=%p size is approximately %d bytes\n",
|
||||
shell, totalSize);
|
||||
}
|
||||
NS_RELEASE(szh);
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WindowData::ShowStyleSize()
|
||||
{
|
||||
if (nsnull == ww) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
struct OnLinkClickEvent : public PLEvent {
|
||||
OnLinkClickEvent(DocObserver* aHandler, const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec, nsIPostData* aPostData = 0);
|
||||
@ -815,12 +892,10 @@ nsEventStatus nsViewer::DispatchMenuItem(nsGUIEvent *aEvent)
|
||||
nsEventStatus result = nsEventStatus_eIgnore;
|
||||
|
||||
switch(aEvent->message) {
|
||||
|
||||
case NS_MENU_SELECTED:
|
||||
nsMenuEvent* menuEvent = (nsMenuEvent*)aEvent;
|
||||
WindowData* wd = FindWindowData(aEvent->widget);
|
||||
switch(menuEvent->menuItem) {
|
||||
|
||||
case VIEWER_EXIT:
|
||||
ExitViewer();
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
@ -904,6 +979,24 @@ nsEventStatus nsViewer::DispatchMenuItem(nsGUIEvent *aEvent)
|
||||
DoDebugRobot(wd);
|
||||
break;
|
||||
|
||||
case VIEWER_SHOW_CONTENT_SIZE:
|
||||
if (nsnull != wd) {
|
||||
wd->ShowContentSize();
|
||||
}
|
||||
break;
|
||||
|
||||
case VIEWER_SHOW_FRAME_SIZE:
|
||||
if (nsnull != wd) {
|
||||
wd->ShowFrameSize();
|
||||
}
|
||||
break;
|
||||
|
||||
case VIEWER_SHOW_STYLE_SIZE:
|
||||
if (nsnull != wd) {
|
||||
wd->ShowStyleSize();
|
||||
}
|
||||
break;
|
||||
|
||||
case VIEWER_ONE_COLUMN:
|
||||
case VIEWER_TWO_COLUMN:
|
||||
case VIEWER_THREE_COLUMN:
|
||||
|
@ -123,6 +123,10 @@ struct WindowData {
|
||||
WindowData() {
|
||||
ww = nsnull;
|
||||
}
|
||||
|
||||
void ShowContentSize();
|
||||
void ShowFrameSize();
|
||||
void ShowStyleSize();
|
||||
};
|
||||
|
||||
class nsViewer : public nsDispatchListener {
|
||||
|
@ -44,6 +44,9 @@
|
||||
#define VIEWER_DUMP_STYLE_SHEETS 40025
|
||||
#define VIEWER_DUMP_STYLE_CONTEXTS 40026
|
||||
#define VIEWER_DEBUGROBOT 40027
|
||||
#define VIEWER_SHOW_CONTENT_SIZE 40028
|
||||
#define VIEWER_SHOW_FRAME_SIZE 40029
|
||||
#define VIEWER_SHOW_STYLE_SIZE 40030
|
||||
|
||||
// Note: must be in ascending sequential order
|
||||
#define VIEWER_ONE_COLUMN 40031
|
||||
|
@ -68,6 +68,10 @@ VIEWER MENU DISCARDABLE
|
||||
MENUITEM "Dump &Style Sheets", VIEWER_DUMP_STYLE_SHEETS
|
||||
MENUITEM "Dump &Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Show Content Size", VIEWER_SHOW_CONTENT_SIZE
|
||||
MENUITEM "Show Frame Size", VIEWER_SHOW_FRAME_SIZE
|
||||
MENUITEM "Show Style Size", VIEWER_SHOW_STYLE_SIZE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Debu&g Robot", VIEWER_DEBUGROBOT
|
||||
}
|
||||
POPUP "&Tools"
|
||||
|
Loading…
x
Reference in New Issue
Block a user