76465 - outliner rowHeight, r=waterson, sr=hyatt
76297 - screen coordinates, r=hyatt, sr=brendan 76428 - can't set view on an outliner until its frame is created, r=brendan, sr=hyatt 76894 - obelisk crash, r=evaughan, sr=hyatt git-svn-id: svn://10.0.0.236/trunk@93471 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
765331050a
commit
d3360b597a
@ -34,6 +34,8 @@ interface nsIBoxObject : nsISupports
|
||||
|
||||
readonly attribute long x;
|
||||
readonly attribute long y;
|
||||
readonly attribute long screenX;
|
||||
readonly attribute long screenY;
|
||||
readonly attribute long width;
|
||||
readonly attribute long height;
|
||||
|
||||
|
||||
@ -36,7 +36,8 @@
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIView.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
|
||||
// Static IIDs/CIDs. Try to minimize these.
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
@ -231,7 +232,76 @@ nsBoxObject::GetOffsetRect(nsRect& aRect)
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBoxObject::GetScreenRect(nsRect& aRect)
|
||||
{
|
||||
aRect.x = aRect.y = 0;
|
||||
aRect.Empty();
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mContent->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
// Get Presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell = getter_AddRefs(doc->GetShellAt(0));
|
||||
|
||||
if (presShell) {
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
presShell->FlushPendingNotifications();
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
if (presContext) {
|
||||
nsIFrame* frame;
|
||||
nsresult rv = presShell->GetPrimaryFrameFor(mContent, &frame);
|
||||
|
||||
PRInt32 offsetX = 0;
|
||||
PRInt32 offsetY = 0;
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
|
||||
while (frame) {
|
||||
// Look for a widget so we can get screen coordinates
|
||||
nsIView* view;
|
||||
rv = frame->GetView(presContext, &view);
|
||||
if (view) {
|
||||
rv = view->GetWidget(*getter_AddRefs(widget));
|
||||
if (widget)
|
||||
break;
|
||||
}
|
||||
|
||||
// No widget yet, so count up the coordinates of the frame
|
||||
nsPoint origin;
|
||||
frame->GetOrigin(origin);
|
||||
offsetX += origin.x;
|
||||
offsetY += origin.y;
|
||||
|
||||
frame->GetParent(&frame);
|
||||
}
|
||||
|
||||
if (widget) {
|
||||
// Get the scale from that Presentation Context
|
||||
float scale;
|
||||
presContext->GetTwipsToPixels(&scale);
|
||||
|
||||
// Convert to pixels using that scale
|
||||
offsetX = NSTwipsToIntPixels(offsetX, scale);
|
||||
offsetY = NSTwipsToIntPixels(offsetY, scale);
|
||||
|
||||
// Add the widget's screen coordinates to the offset we've counted
|
||||
nsRect oldBox(0,0,0,0);
|
||||
widget->WidgetToScreen(oldBox, aRect);
|
||||
aRect.x += offsetX;
|
||||
aRect.y += offsetY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetX(PRInt32* aResult)
|
||||
@ -269,6 +339,30 @@ nsBoxObject::GetHeight(PRInt32* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetScreenX(PRInt32 *_retval)
|
||||
{
|
||||
nsRect rect;
|
||||
nsresult rv = GetScreenRect(rect);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*_retval = rect.x;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetScreenY(PRInt32 *_retval)
|
||||
{
|
||||
nsRect rect;
|
||||
nsresult rv = GetScreenRect(rect);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*_retval = rect.y;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetLookAndFeelMetric(const PRUnichar* aPropertyName,
|
||||
PRUnichar** aResult)
|
||||
|
||||
@ -47,6 +47,7 @@ public:
|
||||
|
||||
virtual nsIFrame* GetFrame();
|
||||
nsresult GetOffsetRect(nsRect& aRect);
|
||||
nsresult GetScreenRect(nsRect& aRect);
|
||||
|
||||
// MEMBER VARIABLES
|
||||
protected:
|
||||
|
||||
@ -253,7 +253,9 @@ nsObeliskLayout::ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox
|
||||
nsCOMPtr<nsIMonument> parent;
|
||||
nsCOMPtr<nsIBox> parentBox;
|
||||
GetParentMonument(aBox, parentBox, getter_AddRefs(parent));
|
||||
|
||||
if (!parent)
|
||||
return NS_OK;
|
||||
|
||||
nsIBox* child = nsnull;
|
||||
aBox->GetChildBox(&child);
|
||||
PRInt32 count = 0;
|
||||
|
||||
@ -53,6 +53,11 @@ interface nsIOutlinerBoxObject : nsISupports
|
||||
*/
|
||||
readonly attribute nsIOutlinerSelection selection;
|
||||
|
||||
/**
|
||||
* Obtain the height of a row.
|
||||
*/
|
||||
readonly attribute long rowHeight;
|
||||
|
||||
/**
|
||||
* Get the index of the first visible row.
|
||||
*/
|
||||
|
||||
@ -494,6 +494,17 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetSelection(nsIOutlinerSelection** aSelectio
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBodyFrame::GetRowHeight(PRInt32* _retval)
|
||||
{
|
||||
PRInt32 height = mRowHeight == 0 ? GetRowHeight() : mRowHeight;
|
||||
|
||||
float t2p;
|
||||
mPresContext->GetTwipsToPixels(&t2p);
|
||||
*_retval = NSToCoordRound((float) height * t2p);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBodyFrame::GetFirstVisibleRow(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = mTopRowIndex;
|
||||
|
||||
@ -149,7 +149,11 @@ NS_IMETHODIMP nsOutlinerBoxObject::SetView(nsIOutlinerView * aView)
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
if (body)
|
||||
return body->SetView(aView);
|
||||
return NS_OK;
|
||||
else {
|
||||
nsCOMPtr<nsISupports> suppView(do_QueryInterface(aView));
|
||||
SetPropertyAsSupports(NS_LITERAL_STRING("view").get(), suppView);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetFocused(PRBool* aFocused)
|
||||
@ -184,6 +188,14 @@ NS_IMETHODIMP nsOutlinerBoxObject::GetSelection(nsIOutlinerSelection * *aSelecti
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetRowHeight(PRInt32* _retval)
|
||||
{
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
if (body)
|
||||
return body->GetRowHeight(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetFirstVisibleRow(PRInt32 *_retval)
|
||||
{
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
|
||||
@ -53,6 +53,11 @@ interface nsIOutlinerBoxObject : nsISupports
|
||||
*/
|
||||
readonly attribute nsIOutlinerSelection selection;
|
||||
|
||||
/**
|
||||
* Obtain the height of a row.
|
||||
*/
|
||||
readonly attribute long rowHeight;
|
||||
|
||||
/**
|
||||
* Get the index of the first visible row.
|
||||
*/
|
||||
|
||||
@ -494,6 +494,17 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetSelection(nsIOutlinerSelection** aSelectio
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBodyFrame::GetRowHeight(PRInt32* _retval)
|
||||
{
|
||||
PRInt32 height = mRowHeight == 0 ? GetRowHeight() : mRowHeight;
|
||||
|
||||
float t2p;
|
||||
mPresContext->GetTwipsToPixels(&t2p);
|
||||
*_retval = NSToCoordRound((float) height * t2p);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBodyFrame::GetFirstVisibleRow(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = mTopRowIndex;
|
||||
|
||||
@ -149,7 +149,11 @@ NS_IMETHODIMP nsOutlinerBoxObject::SetView(nsIOutlinerView * aView)
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
if (body)
|
||||
return body->SetView(aView);
|
||||
return NS_OK;
|
||||
else {
|
||||
nsCOMPtr<nsISupports> suppView(do_QueryInterface(aView));
|
||||
SetPropertyAsSupports(NS_LITERAL_STRING("view").get(), suppView);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetFocused(PRBool* aFocused)
|
||||
@ -184,6 +188,14 @@ NS_IMETHODIMP nsOutlinerBoxObject::GetSelection(nsIOutlinerSelection * *aSelecti
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetRowHeight(PRInt32* _retval)
|
||||
{
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
if (body)
|
||||
return body->GetRowHeight(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOutlinerBoxObject::GetFirstVisibleRow(PRInt32 *_retval)
|
||||
{
|
||||
nsIOutlinerBoxObject* body = GetOutlinerBody();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user