Bug 190735. nsIFrame deCOMtamination, r+rs=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2003-08-06 03:07:12 +00:00
Родитель 85e98ae5a9
Коммит 50878e792b
23 изменённых файлов: 361 добавлений и 757 удалений

Просмотреть файл

@ -1816,14 +1816,11 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (containerView) {
// see if the containerView has already been hooked into a foreign view manager hierarchy
// if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
nsCOMPtr<nsIViewManager> containerVM;
containerView->GetViewManager(*getter_AddRefs(containerVM));
nsCOMPtr<nsIViewManager> checkVM;
nsIViewManager* containerVM = containerView->GetViewManager();
nsIView* pView = containerView;
do {
pView->GetParent(pView);
} while (pView != nsnull
&& NS_SUCCEEDED(pView->GetViewManager(*getter_AddRefs(checkVM))) && checkVM == containerVM);
pView = pView->GetParent();
} while (pView && pView->GetViewManager() == containerVM);
if (!pView) {
// OK, so the container is not already hooked up into a foreign view manager hierarchy.
@ -1882,7 +1879,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Setup hierarchical relationship in view manager
mViewManager->SetRootView(view);
view->GetWidget(*getter_AddRefs(mWindow));
mWindow = view->GetWidget();
// This SetFocus is necessary so the Arrow Key and Page Key events
// go to the scrolled view as soon as the Window is created instead of going to
@ -3202,12 +3199,10 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
nsIFrame * pageFrame;
seqFrame->FirstChild(mPresContext, nsnull, &pageFrame);
while (pageFrame != nsnull) {
nsRect pageRect;
pageFrame->GetRect(pageRect);
nsRect pageRect = pageFrame->GetRect();
if (pageNum == 1) {
gap = pageRect.y;
}
pageRect.y -= gap;
if (pageRect.Contains(pageRect.x, y)) {
currentPage = pageFrame;
}
@ -3216,7 +3211,7 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
break;
}
pageNum++;
pageFrame->GetNextSibling(&pageFrame);
pageFrame = pageFrame->GetNextSibling();
}
if (aType == nsIWebBrowserPrint::PRINTPREVIEW_PREV_PAGE) {
@ -3244,9 +3239,6 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
}
if (fndPageFrame && scrollableView) {
// get the child rect
nsRect fRect;
fndPageFrame->GetRect(fRect);
// find offset from view
nsPoint pnt;
nsIView * view;
@ -3259,7 +3251,7 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
}
// scroll so that top of page (plus the gray area) is at the top of the scroll area
scrollableView->ScrollTo(0, fRect.y-deadSpaceGap, PR_TRUE);
scrollableView->ScrollTo(0, fndPageFrame->GetPosition().y-deadSpaceGap, PR_TRUE);
}
return NS_OK;
#else

Просмотреть файл

@ -524,7 +524,7 @@ nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
aSeqFrame->FirstChild(aPO->mPresContext, nsnull, &pageFrame);
while (pageFrame != nsnull) {
aCount++;
pageFrame->GetNextSibling(&pageFrame);
pageFrame = pageFrame->GetNextSibling();
}
return NS_OK;
@ -2091,13 +2091,9 @@ void nsPrintEngine::CheckForHiddenFrameSetFrames()
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsIFrame* frame;
po->mDisplayPresShell->GetRootFrame(&frame);
if (frame) {
nsRect rect;
frame->GetRect(rect);
if (rect.height == 0) {
// set this PO and its children to not print and be hidden
SetPrintPO(po, PR_FALSE, PR_TRUE, eSetPrintFlag | eSetHiddenFlag);
}
if (frame && frame->GetSize().height == 0) {
// set this PO and its children to not print and be hidden
SetPrintPO(po, PR_FALSE, PR_TRUE, eSetPrintFlag | eSetHiddenFlag);
}
}
}
@ -2714,10 +2710,9 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
}
if (frame) {
nsIView* view = frame->GetView(aPO->mParent->mPresContext);
nsIView* view = frame->GetView();
if (view) {
nsCOMPtr<nsIWidget> w2;
view->GetWidget(*getter_AddRefs(w2));
nsIWidget* w2 = view->GetWidget();
if (w2) {
widget = w2;
}
@ -2731,7 +2726,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
widget->GetNativeData(NS_NATIVE_WIDGET),
PR_TRUE, PR_TRUE,
eContentTypeContent);
aPO->mRootView->GetWidget(*getter_AddRefs(aPO->mWindow));
aPO->mWindow = aPO->mRootView->GetWidget();
aPO->mPresContext->SetPaginatedScrolling(canCreateScrollbars);
}
#endif // NS_PRINT_PREVIEW
@ -2866,7 +2861,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView* v = theRootFrame->GetView(aPO->mPresContext);
nsIView* v = theRootFrame->GetView();
if (v) {
v->List(fd);
} else {
@ -2949,8 +2944,7 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
// Calc absolute position of the frame all the way up
// to the SimpleSeq frame
nsRect rect;
frame->GetRect(rect);
nsRect rect = frame->GetRect();
rect.Deflate(borderPadding);
rect.x = 0;
@ -2958,16 +2952,15 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
nsIFrame * parent = frame;
nsIFrame * pageFrame = nsnull;
nsIFrame * seqFrame = nsnull;
while (parent != nsnull) {
nsRect rr;
parent->GetRect(rr);
while (parent) {
nsRect rr = parent->GetRect();
rect.x += rr.x;
rect.y += rr.y;
nsIFrame * temp = parent;
temp->GetParent(&parent);
parent = temp->GetParent();
// Keep a pointer to the Seq and Page frames
nsIPageSequenceFrame * sqf = nsnull;
if (parent != nsnull &&
if (parent &&
NS_SUCCEEDED(CallQueryInterface(parent, &sqf)) && sqf) {
pageFrame = temp;
seqFrame = parent;
@ -2992,7 +2985,7 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
break;
}
pageNum++;
child->GetNextSibling(&child);
child = child->GetNextSibling();
} // while
}
return NS_OK;
@ -3023,7 +3016,7 @@ nsPrintEngine::CalcNumPrintableDocsAndPages(PRInt32& aNumDocs, PRInt32& aNumPage
seqFrame->FirstChild(po->mPresContext, nsnull, &frame);
while (frame) {
aNumPages++;
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
}
}
@ -3089,16 +3082,15 @@ static void GetIFramePosition(nsPrintObject * aPO, nscoord& aX, nscoord& aY)
// and then traverse out ot the pageContentFrame
frame->FirstChild(aPO->mParent->mPresContext, nsnull, &frame);
while (frame) {
nsRect r;
frame->GetRect(r);
aX += r.x;
aY += r.y;
nsPoint pt = frame->GetPosition();
aX += pt.x;
aY += pt.y;
nsCOMPtr<nsIAtom> frameType;
frame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::pageContentFrame == frameType.get()) {
break;
}
frame->GetParent(&frame);
frame = frame->GetParent();
}
}
}
@ -3333,12 +3325,8 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
nsRect areaRect;
nsIFrame * areaFrame = FindFrameByType(poPresContext, startFrame, nsHTMLAtoms::body, rect, areaRect);
if (areaFrame) {
nsRect areaRect;
areaFrame->GetRect(areaRect);
startRect.y -= margin.top+areaRect.y;
startRect.y -= margin.top + areaFrame->GetPosition().y;
endRect.y -= margin.top;
areaRect.y -= startRect.y;
areaRect.x -= margin.left;
// XXX This is temporary fix for printing more than one page of a selection
pageSequence->SetSelectionHeight(startRect.y, endRect.y+endRect.height-startRect.y);
@ -3366,19 +3354,17 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(poPresContext);
if (!ppContext) {
nsRect srect;
seqFrame->GetRect(srect);
nscoord sheight = seqFrame->GetSize().height;
nsRect r;
poRootView->GetBounds(r);
nsRect r = poRootView->GetBounds();
r.x = r.y = 0;
r.height = srect.height;
r.height = sheight;
aPO->mViewManager->ResizeView(poRootView, r, PR_FALSE);
rootFrame->GetRect(r);
r = rootFrame->GetRect();
r.height = srect.height;
rootFrame->SetRect(poPresContext, r);
r.height = sheight;
rootFrame->SetRect(r);
mPageSeqFrame = pageSequence;
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
@ -3692,23 +3678,17 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext,
NS_ASSERTION(aType, "Pointer is null!");
nsIFrame * child;
nsRect rect;
aParentFrame->GetRect(rect);
aRect.x += rect.x;
aRect.y += rect.y;
aRect += aParentFrame->GetPosition();
aParentFrame->FirstChild(aPresContext, nsnull, &child);
while (child != nsnull) {
nsCOMPtr<nsIContent> content;
child->GetContent(getter_AddRefs(content));
while (child) {
nsIContent* content = child->GetContent();
if (content) {
nsCOMPtr<nsIAtom> type;
content->GetTag(getter_AddRefs(type));
if (type.get() == aType) {
nsRect r;
child->GetRect(r);
nsRect r = child->GetRect();
aChildRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return child;
}
}
@ -3716,10 +3696,9 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext,
if (fndFrame != nsnull) {
return fndFrame;
}
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return nsnull;
}
@ -3742,16 +3721,12 @@ nsPrintEngine::FindSelectionBoundsWithList(nsIPresContext* aPresContext,
nsIFrame * child;
aParentFrame->FirstChild(aPresContext, aList, &child);
nsRect rect;
aParentFrame->GetRect(rect);
aRect.x += rect.x;
aRect.y += rect.y;
while (child != nsnull) {
nsFrameState state;
child->GetFrameState(&state);
aRect += aParentFrame->GetPosition();
while (child) {
// only leaf frames have this bit flipped
// then check the hard way
PRBool isSelected = (state & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
PRBool isSelected = (child->GetStateBits() & NS_FRAME_SELECTED_CONTENT)
== NS_FRAME_SELECTED_CONTENT;
if (isSelected) {
if (NS_FAILED(child->IsVisibleForPainting(aPresContext, aRC, PR_TRUE, &isSelected))) {
return NS_ERROR_FAILURE;
@ -3759,22 +3734,19 @@ nsPrintEngine::FindSelectionBoundsWithList(nsIPresContext* aPresContext,
}
if (isSelected) {
nsRect r;
child->GetRect(r);
nsRect r = child->GetRect();
if (aStartFrame == nsnull) {
aStartFrame = child;
aStartRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
} else {
child->GetRect(r);
aEndFrame = child;
aEndRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
}
}
FindSelectionBounds(aPresContext, aRC, child, aRect, aStartFrame, aStartRect, aEndFrame, aEndRect);
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return NS_OK;
}
@ -3838,13 +3810,13 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
nsIFrame * startFrame = nsnull;
nsIFrame * endFrame = nsnull;
nsRect rect;
seqFrame->GetRect(rect);
// start out with the sequence frame and search the entire frame tree
// capturing the the starting and ending child frames of the selection
// and their rects
FindSelectionBounds(aPresContext, aRC, seqFrame, rect, startFrame, aStartRect, endFrame, aEndRect);
nsRect r = seqFrame->GetRect();
FindSelectionBounds(aPresContext, aRC, seqFrame, r,
startFrame, aStartRect, endFrame, aEndRect);
#ifdef DEBUG_rodsX
printf("Start Frame: %p\n", startFrame);
@ -3894,7 +3866,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
while (child != nsnull) {
printf("Page: %d - %p\n", pageNum, child);
pageNum++;
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
}
#endif
@ -3912,7 +3884,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
aEndPageNum = pageNum;
}
pageNum++;
page->GetNextSibling(&page);
page = page->GetNextSibling();
}
#ifdef DEBUG_rodsX
@ -4785,19 +4757,15 @@ static void DumpFrames(FILE* out,
frameDebug->GetFrameName(tmp);
}
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
nsFrameState state;
child->GetFrameState(&state);
PRBool isSelected;
if (NS_SUCCEEDED(child->IsVisibleForPainting(aPresContext, *aRendContext, PR_TRUE, &isSelected))) {
fprintf(out, " %p %s", child, isSelected?"VIS":"UVS");
nsRect rect;
child->GetRect(rect);
nsRect rect = child->GetRect();
fprintf(out, "[%d,%d,%d,%d] ", rect.x, rect.y, rect.width, rect.height);
nsIView* view = child->GetView(aPresContext);
fprintf(out, "v: %p ", view);
fprintf(out, "v: %p ", (void*)child->GetView());
fprintf(out, "\n");
DumpFrames(out, aPresContext, aRendContext, child, aLevel+1);
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
}
}
@ -4816,8 +4784,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
fprintf(out, "docshell=%p \n", aDocShell);
nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell);
if (nsnull != shell) {
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsIView* root;
vm->GetRootView(root);
@ -4888,7 +4855,7 @@ void DumpLayoutData(char* aTitleStr,
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView* v = aRootFrame->GetView(aPresContext);
nsIView* v = aRootFrame->GetView();
if (v) {
v->List(fd);
} else {

Просмотреть файл

@ -613,9 +613,7 @@ public:
{
if (mSelection && mPresContext && mView)
{
void *clientData = 0;
mView->GetClientData(clientData);
nsIFrame *frame = (nsIFrame *)clientData;
nsIFrame *frame = NS_STATIC_CAST(nsIFrame*, mView->GetClientData());
if (!frame)
return NS_OK;
@ -1168,33 +1166,21 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
*offsetX = *offsetY = 0;
nsresult result;
nsIFrame *frame = aFrame;
while (frame)
{
result = frame->GetParentWithView(aPresContext, &frame);
if (NS_FAILED(result))
return result;
frame = frame->GetAncestorWithView();
if (frame) {
nsIView *view = frame->GetView(aPresContext);
nsIView *view = frame->GetView();
if (view)
{
nscoord vX = 0, vY = 0;
result = view->GetPosition(&vX, &vY);
if (NS_FAILED(result))
return result;
*offsetX += vX;
*offsetY += vY;
nsPoint pt = view->GetPosition();
*offsetX += pt.x;
*offsetY += pt.y;
}
}
}
return NS_OK;
@ -1270,12 +1256,7 @@ nsSelection::ConstrainFrameAndPointToAnchorSubtree(nsIPresContext *aPresContext,
// Now find the root of the subtree containing aFrame's content.
//
nsCOMPtr<nsIContent> content;
result = aFrame->GetContent(getter_AddRefs(content));
if (NS_FAILED(result))
return result;
nsIContent* content = aFrame->GetContent();
if (content)
{
@ -1548,9 +1529,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
if (NS_FAILED(result) || !frame)
return result?result:NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content;
result = frame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(frame->GetContent());
nsCOMPtr<nsIDOMNode> parentNode;
nsPeekOffsetStruct pos;
@ -1812,13 +1791,10 @@ nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
while (NS_FAILED(result) && blockFrame)
{
thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame) {
blockFrame = blockFrame->GetParent();
if (blockFrame) {
it = do_QueryInterface(blockFrame, &result);
}
else {
blockFrame = nsnull;
}
}
if (!blockFrame || !it)
return NS_ERROR_FAILURE;
@ -2266,13 +2242,10 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
while (NS_FAILED(result) && blockFrame)
{
thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame) {
blockFrame = blockFrame->GetParent();
if (blockFrame) {
it = do_QueryInterface(blockFrame, &result);
}
else {
blockFrame = nsnull;
}
}
if (!blockFrame || !it)
return NS_ERROR_FAILURE;
@ -2297,12 +2270,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
lastFrame = firstFrame;
for (;lineFrameCount > 1;lineFrameCount --) {
result = lastFrame->GetNextSibling(&lastFrame);
if (NS_FAILED(result)){
NS_ASSERTION(0,"should not be reached nsFrame\n");
return NS_ERROR_FAILURE;
}
lastFrame = lastFrame->GetNextSibling();
}
// GetFirstLeaf
@ -2321,7 +2289,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
if (NS_FAILED(result) || !lookahead)
break; //nothing to do
lastFrame = lookahead;
while (NS_SUCCEEDED(lastFrame->GetNextSibling(&lookahead)) && lookahead)
while ((lookahead = lastFrame->GetNextSibling()) != nsnull)
lastFrame = lookahead;
}
//END LINE DATA CODE
@ -3117,7 +3085,6 @@ nsSelection::CommonPageMove(PRBool aForward,
nsresult result;
const nsIView* clipView;
nsRect viewRect;
//get the frame from the scrollable view
void* clientData;
@ -3130,8 +3097,8 @@ nsSelection::CommonPageMove(PRBool aForward,
if (NS_FAILED(result))
return result;
if (scrolledView && NS_SUCCEEDED(scrolledView->GetClientData(clientData)))
mainframe = (nsIFrame*)clientData;
if (scrolledView)
mainframe = NS_STATIC_CAST(nsIFrame*, scrolledView->GetClientData());
if (!mainframe)
return NS_ERROR_FAILURE;
@ -3139,8 +3106,7 @@ nsSelection::CommonPageMove(PRBool aForward,
// find out where we are; determine amount to page up/down
if (NS_FAILED(result = aScrollableView->GetClipView(&clipView)))
return result;
if (NS_FAILED(result = clipView->GetBounds(viewRect)))
return result;
nsRect viewRect = clipView->GetBounds();
nsCOMPtr<nsIPresContext> context;
result = mTracker->GetPresContext(getter_AddRefs(context));
@ -3196,10 +3162,8 @@ nsSelection::CommonPageMove(PRBool aForward,
nscoord x,y;
while (caretView != scrolledView)
{
caretView->GetPosition(&x, &y);
caretPos.x += x;
caretPos.y += y;
caretView->GetParent(caretView);
caretPos += caretView->GetPosition();
caretView = caretView->GetParent();
if (!caretView) //how did we miss the scrolled view. something is very wrong
return NS_ERROR_FAILURE;
}
@ -3346,7 +3310,7 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe
return NS_OK;
}
thisFrame->GetParent(&thisFrame);
thisFrame = thisFrame->GetParent();
}
*foundFrame = nsnull;
@ -4389,8 +4353,7 @@ nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
if (!selectAllFrame)
return NS_OK;
nsCOMPtr<nsIContent> selectAllContent;
selectAllFrame->GetContent(getter_AddRefs(selectAllContent));
nsIContent* selectAllContent = selectAllFrame->GetContent();
if (selectAllContent)
{
nsCOMPtr<nsIContent> parentContent = selectAllContent->GetParent();
@ -5077,7 +5040,6 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
}
// Now iterated through the child frames and set them
nsCOMPtr<nsIContent> innercontent;
nsRect frameRect;
while (NS_ENUMERATOR_FALSE == aInnerIter->IsDone())
{
result = aInnerIter->CurrentNode(getter_AddRefs(innercontent));
@ -5088,7 +5050,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
{
//NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame
frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);//spread from here to hit all frames in flow
frame->GetRect(frameRect);
nsRect frameRect = frame->GetRect();
//if a rect is 0 height/width then try to notify next available in flow of selection status.
while (!frameRect.width || !frameRect.height)
@ -5096,7 +5058,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
//try to notify next in flow that its content is selected.
if (NS_SUCCEEDED(frame->GetNextInFlow(&frame)) && frame)
{
frame->GetRect(frameRect);
frameRect = frame->GetRect();
frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
}
else
@ -5480,14 +5442,9 @@ nsTypedSelection::GetViewAncestorOffset(nsIView *aView, nsIView *aAncestorView,
for (nsIView* view = aView; view && view != aAncestorView;
view = view->GetParent())
{
nscoord x = 0, y = 0;
nsresult result = view->GetPosition(&x, &y);
if (NS_FAILED(result))
return result;
*aXOffset += x;
*aYOffset += y;
nsPoint pt = view->GetPosition();
*aXOffset += pt.x;
*aYOffset += pt.y;
}
return NS_OK;
@ -5506,10 +5463,7 @@ nsTypedSelection::GetClosestScrollableView(nsIView *aView, nsIScrollableView **a
CallQueryInterface(aView, aScrollableView);
if (!*aScrollableView)
{
nsresult result = aView->GetParent(aView);
if (NS_FAILED(result))
return result;
aView = aView->GetParent();
}
}
@ -5578,12 +5532,7 @@ nsTypedSelection::ScrollPointIntoClipView(nsIPresContext *aPresContext, nsIView
// If it is, scroll the view till it is inside the visible area!
//
nsRect bounds;
result = cView->GetBounds(bounds);
if (NS_FAILED(result))
return result;
nsRect bounds = cView->GetBounds();
result = scrollableView->GetScrollPosition(bounds.x,bounds.y);
@ -5659,19 +5608,8 @@ nsTypedSelection::ScrollPointIntoClipView(nsIPresContext *aPresContext, nsIView
if (dx != 0 || dy != 0)
{
// Get the PresShell
nsCOMPtr<nsIPresShell> presShell;
result = aPresContext->GetShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell,result);
// Get the ViewManager
nsCOMPtr<nsIViewManager> viewManager;
result = presShell->GetViewManager(getter_AddRefs(viewManager));
NS_ENSURE_TRUE(viewManager,result);
// Make sure latest bits are available before we scroll them.
viewManager->Composite();
aPresContext->GetViewManager()->Composite();
// Now scroll the view!
@ -5766,10 +5704,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
// closest scrollable view.
//
result = view->GetParent(view);
if (NS_FAILED(result))
return result;
view = view->GetParent();
while (view)
{
@ -5821,7 +5756,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
if (!view)
return result;
view->GetParent(view);
view = view->GetParent();
}
}
}
@ -5902,7 +5837,7 @@ nsTypedSelection::DoAutoScroll(nsIPresContext *aPresContext, nsIFrame *aFrame, n
// Find the closest view to the frame!
nsIView *closestView = aFrame->GetClosestView(aPresContext);
nsIView *closestView = aFrame->GetClosestView();
if (!closestView)
return NS_ERROR_FAILURE;
@ -7042,12 +6977,7 @@ nsTypedSelection::GetRootScrollableView(nsIScrollableView **aScrollableView)
if (!presShell)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIViewManager> viewManager;
rv = presShell->GetViewManager(getter_AddRefs(viewManager));
if (NS_FAILED(rv))
return rv;
nsIViewManager* viewManager = presShell->GetViewManager();
if (!viewManager)
return NS_ERROR_NULL_POINTER;
@ -7099,14 +7029,11 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi
// XXX Deal with the case where there is a scrolled element, e.g., a
// DIV in the middle...
while (closestView && closestView != scrolledView) {
nscoord dx, dy;
// Update the offset
closestView->GetPosition(&dx, &dy);
offset.MoveBy(dx, dy);
offset += closestView->GetPosition();
// Get its parent view
closestView->GetParent(closestView);
closestView = closestView->GetParent();
}
*aX = offset.x;
@ -7162,25 +7089,19 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
// a rendering context.
//
nsCOMPtr<nsIWidget> widget;
nsIView *closestView = 0;
nsIWidget* widget = nsnull;
nsIView *closestView = nsnull;
nsPoint offset(0, 0);
rv = aFrame->GetOffsetFromView(presContext, offset, &closestView);
while (!widget && closestView)
{
rv = closestView->GetWidget(*getter_AddRefs(widget));
if (NS_FAILED(rv))
return rv;
widget = closestView->GetWidget();
if (!widget)
{
rv = closestView->GetParent(closestView);
if (NS_FAILED(rv))
return rv;
closestView = closestView->GetParent();
}
}
@ -7288,18 +7209,12 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
return NS_ERROR_FAILURE;
nsIView *view = 0;
nsIFrame *parentWithView = 0;
result = frame->GetParentWithView(presContext, &parentWithView);
if (NS_FAILED(result))
return result;
nsIFrame *parentWithView = frame->GetAncestorWithView();
if (!parentWithView)
return NS_ERROR_FAILURE;
view = parentWithView->GetView(presContext);
nsIView* view = parentWithView->GetView();
result = GetClosestScrollableView(view, aScrollableView);
@ -7351,10 +7266,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
//
// Get the frame's rect.
//
result = frame->GetRect(*aRect);
if (NS_FAILED(result))
return result;
*aRect = frame->GetRect();
//
// Translate the frame's rect into root view coordinates.
@ -7381,12 +7293,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
nsRect clipRect;
result = clipView->GetBounds(clipRect);
if (NS_FAILED(result))
return result;
nsRect clipRect = clipView->GetBounds();
result = (*aScrollableView)->GetScrollPosition(clipRect.x, clipRect.y);
@ -7435,12 +7342,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
nsRect svRect;
result = scrolledView->GetBounds(svRect);
if (NS_FAILED(result))
return result;
nsRect svRect = scrolledView->GetBounds();
if (aRect->x < 0)
aRect->x = 0;
@ -7456,10 +7358,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
// Must be a non-text frame, just scroll the frame
// into view.
//
result = frame->GetRect(*aRect);
if (NS_FAILED(result))
return result;
*aRect = frame->GetRect();
result = GetFrameToScrolledViewOffsets(*aScrollableView, frame, &aRect->x, &aRect->y);
}
@ -7484,10 +7383,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
nsRect visibleRect;
aScrollableView->GetClipView(&clipView);
clipView->GetBounds(visibleRect);
nsRect visibleRect = clipView->GetBounds();
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
@ -7564,10 +7462,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
if (!view)
return rv;
rv = view->GetParent(view);
if (NS_FAILED(rv))
return rv;
view = view->GetParent();
if (view)
{

Просмотреть файл

@ -732,8 +732,8 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
nsCOMPtr<nsIPresShell> presShell;
nsIWidget* rootWidget = nsnull;
if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) {
nsCOMPtr<nsIViewManager> vm;
if (NS_SUCCEEDED(presShell->GetViewManager(getter_AddRefs(vm))) && vm) {
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
vm->GetWidget(&rootWidget);
}
}
@ -786,8 +786,8 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
nsCOMPtr<nsIPresShell> presShell;
nsIWidget* rootWidget = nsnull;
if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) {
nsCOMPtr<nsIViewManager> vm;
if (NS_SUCCEEDED(presShell->GetViewManager(getter_AddRefs(vm))) && vm) {
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
vm->GetWidget(&rootWidget);
}
}
@ -1003,11 +1003,10 @@ nsresult nsDOMEvent::GetScrollInfo(nsIScrollableView** aScrollableView,
nsCOMPtr<nsIPresShell> presShell;
if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) {
nsCOMPtr<nsIViewManager> vm;
presShell->GetViewManager(getter_AddRefs(vm));
if(vm) {
return vm->GetRootScrollableView(aScrollableView);
}
nsIViewManager* vm = presShell->GetViewManager();
if(vm) {
return vm->GetRootScrollableView(aScrollableView);
}
}
return NS_OK;
}

Просмотреть файл

@ -2792,8 +2792,7 @@ void nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
// menu away from the top left corner of the frame. If we always
// used the frame height, the context menu could end up far away,
// for example when we're focused on linked images.
nsCOMPtr<nsIViewManager> vm;
aPresShell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = aPresShell->GetViewManager();
if (vm) {
nsIScrollableView* scrollableView = nsnull;
vm->GetRootScrollableView(&scrollableView);
@ -2803,9 +2802,7 @@ void nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
}
else {
// No scrollable view, use height of frame as fallback
nsRect frameRect;
frame->GetRect(frameRect);
extraDistance = frameRect.height;
extraDistance = frame->GetSize().height;
}
aTargetPt.x += extraDistance;
aTargetPt.y += extraDistance;

Просмотреть файл

@ -320,10 +320,7 @@ NS_IMPL_ISUPPORTS3(nsEventStateManager, nsIEventStateManager, nsIObserver, nsISu
inline void
SetFrameExternalReference(nsIFrame* aFrame)
{
nsFrameState state;
aFrame->GetFrameState(&state);
state |= NS_FRAME_EXTERNAL_REFERENCE;
aFrame->SetFrameState(state);
aFrame->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
}
NS_IMETHODIMP
@ -944,7 +941,7 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
if (frame) {
const nsStyleVisibility* vis = frame->GetStyleVisibility();
PRBool viewShown = frame->AreAncestorViewsVisible(mPresContext);
PRBool viewShown = frame->AreAncestorViewsVisible();
// get the XUL element
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(content);
@ -1115,9 +1112,8 @@ nsEventStateManager :: CreateClickHoldTimer ( nsIPresContext* inPresContext, nsG
// if content clicked on has a popup, don't even start the timer
// since we'll end up conflicting and both will show.
nsCOMPtr<nsIContent> clickedContent;
if ( mGestureDownFrame ) {
mGestureDownFrame->GetContent(getter_AddRefs(clickedContent));
nsIContent* clickedContent = mGestureDownFrame->GetContent();
if ( clickedContent ) {
// check for the |popup| attribute
nsAutoString popup;
@ -1231,9 +1227,8 @@ nsEventStateManager :: FireContextClick ( )
// when we're through because no one else is doing anything more with this
// event and it will get reset on the very next event to the correct frame).
mCurrentTarget = mGestureDownFrame;
nsCOMPtr<nsIContent> lastContent;
if ( mGestureDownFrame ) {
mGestureDownFrame->GetContent(getter_AddRefs(lastContent));
nsIContent* lastContent = mGestureDownFrame->GetContent();
if ( lastContent ) {
// before dispatching, check that we're not on something that doesn't get a context menu
@ -1576,8 +1571,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
PRInt32 aNumLines, PRBool aScrollHorizontal, PRBool aScrollPage,
PRBool aUseTargetFrame)
{
nsCOMPtr<nsIContent> targetContent;
aTargetFrame->GetContent(getter_AddRefs(targetContent));
nsCOMPtr<nsIContent> targetContent = aTargetFrame->GetContent();
if (!targetContent)
GetFocusedContent(getter_AddRefs(targetContent));
if (!targetContent) return NS_OK;
@ -1672,7 +1666,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
if (sv)
CallQueryInterface(sv, &focusView);
} else {
focusView = focusFrame->GetClosestView(aPresContext);
focusView = focusFrame->GetClosestView();
if (!focusView)
return NS_ERROR_FAILURE;
@ -1698,8 +1692,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
CallQueryInterface(sv, &portView);
if (!portView)
return NS_ERROR_FAILURE;
nsRect portRect;
portView->GetBounds(portRect);
nsRect portRect = portView->GetBounds();
passToParent = aScrollHorizontal ? (xPos + portRect.width >= scrolledSize.width)
: (yPos + portRect.height >= scrolledSize.height);
@ -1830,9 +1823,8 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN && !mNormalLMouseEventInProcess) {
//Our state is out of whack. We got a mouseup while still processing
//the mousedown. Kill View-level mouse capture or it'll stay stuck
nsCOMPtr<nsIViewManager> viewMan;
if (aView) {
aView->GetViewManager(*getter_AddRefs(viewMan));
nsIViewManager* viewMan = aView->GetViewManager();
if (viewMan) {
nsIView* grabbingView;
viewMan->GetMouseEventGrabber(grabbingView);
@ -1860,9 +1852,9 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
}
nsIFrame* currFrame = mCurrentTarget;
nsCOMPtr<nsIContent> activeContent;
nsIContent* activeContent = nsnull;
if (mCurrentTarget)
mCurrentTarget->GetContent(getter_AddRefs(activeContent));
activeContent = mCurrentTarget->GetContent();
// Look for the nearest enclosing focusable frame.
while (currFrame) {
@ -1877,12 +1869,12 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
const nsStyleUserInterface* ui = currFrame->GetStyleUserInterface();
if ((ui->mUserFocus != NS_STYLE_USER_FOCUS_IGNORE) &&
(ui->mUserFocus != NS_STYLE_USER_FOCUS_NONE)) {
currFrame->GetContent(getter_AddRefs(newFocus));
newFocus = currFrame->GetContent();
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(newFocus));
if (domElement)
break;
}
currFrame->GetParent(&currFrame);
currFrame = currFrame->GetParent();
}
if (newFocus && currFrame)
@ -2030,8 +2022,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
case MOUSE_SCROLL_TEXTSIZE:
{
// Exclude form controls and XUL content.
nsCOMPtr<nsIContent> content;
aTargetFrame->GetContent(getter_AddRefs(content));
nsIContent* content = aTargetFrame->GetContent();
if (content &&
!content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL) &&
!content->IsContentOfType(nsIContent::eXUL))
@ -2119,12 +2110,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
// force the update to happen now, otherwise multiple scrolls can
// occur before the update is processed. (bug #7354)
nsIViewManager* vm = nsnull;
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
nsIViewManager* vm = aView->GetViewManager();
if (vm) {
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
vm->ForceUpdate();
NS_RELEASE(vm);
}
}
}
@ -2139,12 +2129,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
// force the update to happen now, otherwise multiple scrolls can
// occur before the update is processed. (bug #7354)
nsIViewManager* vm = nsnull;
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
nsIViewManager* vm = aView->GetViewManager();
if (vm) {
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
vm->ForceUpdate();
NS_RELEASE(vm);
}
}
}
@ -2275,7 +2264,7 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
}
if (aFrame == mCurrentTarget) {
if (aFrame) {
aFrame->GetContent(getter_AddRefs(mCurrentTargetContent));
mCurrentTargetContent = aFrame->GetContent();
}
mCurrentTarget = nsnull;
}
@ -2336,9 +2325,9 @@ nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext,
}
//If not locked, look for correct cursor
else {
nsCOMPtr<nsIContent> targetContent;
nsIContent* targetContent = nsnull;
if (mCurrentTarget) {
mCurrentTarget->GetContent(getter_AddRefs(targetContent));
targetContent = mCurrentTarget->GetContent();
}
//Check if the current target is disabled. If so use the default pointer.
@ -3032,8 +3021,7 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
nsCOMPtr<nsIDOMWindowInternal> domwin(do_QueryInterface(sgo));
nsCOMPtr<nsIWidget> widget;
nsCOMPtr<nsIViewManager> vm;
presShell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
vm->GetWidget(getter_AddRefs(widget));
}
@ -3445,14 +3433,12 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
nsIFrame* currentFrame = (nsIFrame*)currentItem;
while (currentFrame) {
nsCOMPtr<nsIContent> child;
currentFrame->GetContent(getter_AddRefs(child));
const nsStyleVisibility* vis = currentFrame->GetStyleVisibility();
const nsStyleUserInterface* ui = currentFrame->GetStyleUserInterface();
PRBool viewShown = currentFrame->AreAncestorViewsVisible(mPresContext);
PRBool viewShown = currentFrame->AreAncestorViewsVisible();
nsIContent* child = currentFrame->GetContent();
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(child));
// if collapsed or hidden, we don't get tabbed into.
@ -4144,7 +4130,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));
if (shell) {
shell->GetViewManager(getter_AddRefs(kungFuDeathGrip));
kungFuDeathGrip = shell->GetViewManager();
nsCOMPtr<nsIPresContext> oldPresContext;
shell->GetPresContext(getter_AddRefs(oldPresContext));
@ -4279,8 +4265,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
// This raises the window that has both content and scroll bars in it
// instead of the child window just below it that contains only the content
// That way we focus the same window that gets focused by a mouse click
nsCOMPtr<nsIViewManager> vm;
presShell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
nsCOMPtr<nsIWidget> widget;
vm->GetWidget(getter_AddRefs(widget));
@ -4473,12 +4458,11 @@ void nsEventStateManager::ForceViewUpdate(nsIView* aView)
// force the update to happen now, otherwise multiple scrolls can
// occur before the update is processed. (bug #7354)
nsIViewManager* vm = nsnull;
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
nsIViewManager* vm = aView->GetViewManager();
if (vm) {
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
vm->ForceUpdate();
NS_RELEASE(vm);
}
}
@ -4566,8 +4550,7 @@ void nsEventStateManager::FlushPendingEvents(nsIPresContext* aPresContext) {
aPresContext->GetShell(getter_AddRefs(shell));
if (nsnull != shell) {
shell->FlushPendingNotifications(PR_FALSE);
nsCOMPtr<nsIViewManager> viewManager;
shell->GetViewManager(getter_AddRefs(viewManager));
nsIViewManager* viewManager = shell->GetViewManager();
if (viewManager) {
viewManager->FlushPendingInvalidates();
}
@ -4701,7 +4684,7 @@ nsresult nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent
startFrame = NS_STATIC_CAST(nsIFrame*, currentItem);
if (startFrame) {
PRBool endEqualsStart(startContent == endContent);
startFrame->GetContent(getter_AddRefs(startContent));
startContent = startFrame->GetContent();
if (endEqualsStart)
endContent = startContent;
}

Просмотреть файл

@ -584,11 +584,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
nsIFrame* next = frame;
do {
nsRect rect;
next->GetRect(rect);
rcFrame.UnionRect(rcFrame, rect);
rcFrame.UnionRect(rcFrame, next->GetRect());
next->GetNextInFlow(&next);
} while (next);
@ -598,12 +594,11 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
// Find the frame parent whose content's tagName either matches
// the tagName passed in or is the document element.
nsCOMPtr<nsIContent> content;
nsIFrame* parent = nsnull;
PRBool done = PR_FALSE;
nsCOMPtr<nsIAtom> tag;
frame->GetContent(getter_AddRefs(content));
nsIContent* content = frame->GetContent();
if (content) {
content->GetTag(getter_AddRefs(tag));
@ -621,7 +616,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
PRBool is_absolutely_positioned = PR_FALSE;
PRBool is_positioned = PR_FALSE;
frame->GetOrigin(origin);
origin = frame->GetPosition();
const nsStyleDisplay* display = frame->GetStyleDisplay();
@ -638,7 +633,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
is_positioned = PR_TRUE;
}
frame->GetParent(&parent);
parent = frame->GetParent();
while (parent) {
display = parent->GetStyleDisplay();
@ -647,7 +642,8 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
// Stop at the first *parent* that is positioned (fixed,
// absolute, or relatiive)
parent->GetContent(aOffsetParent);
*aOffsetParent = parent->GetContent();
NS_IF_ADDREF(*aOffsetParent);
break;
}
@ -656,12 +652,10 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
// right coordinate system
if (!is_absolutely_positioned) {
nsPoint parentOrigin;
parent->GetOrigin(parentOrigin);
origin += parentOrigin;
origin += parent->GetPosition();
}
parent->GetContent(getter_AddRefs(content));
content = parent->GetContent();
if (content) {
// If we've hit the document element, break here
@ -682,7 +676,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
}
}
parent->GetParent(&parent);
parent = parent->GetParent();
}
if (is_absolutely_positioned && !*aOffsetParent) {
@ -1013,7 +1007,7 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
// the root scrollable frame.
do {
frame->GetParent(&frame);
frame = frame->GetParent();
if (!frame) {
break;
@ -1177,8 +1171,7 @@ nsGenericHTMLElement::GetScrollWidth(PRInt32* aScrollWidth)
const nsSize
nsGenericHTMLElement::GetClientAreaSize(nsIFrame *aFrame)
{
nsRect rect;
aFrame->GetRect(rect);
nsRect rect = aFrame->GetRect();
const nsStyleBorder* border = aFrame->GetStyleBorder();
@ -1204,10 +1197,9 @@ nsGenericHTMLElement::GetClientHeight(PRInt32* aClientHeight)
if (scrollView) {
const nsIView *view = nsnull;
nsRect r;
scrollView->GetClipView(&view);
view->GetBounds(r);
nsRect r = view->GetBounds();
*aClientHeight = NSTwipsToIntPixels(r.height, t2p);
} else if (mNodeInfo->Equals(nsHTMLAtoms::body) && frame) {
@ -1236,10 +1228,9 @@ nsGenericHTMLElement::GetClientWidth(PRInt32* aClientWidth)
if (scrollView) {
const nsIView *view = nsnull;
nsRect r;
scrollView->GetClipView(&view);
view->GetBounds(r);
nsRect r = view->GetBounds();
*aClientWidth = NSTwipsToIntPixels(r.width, t2p);
} else if (mNodeInfo->Equals(nsHTMLAtoms::body) && frame) {

Просмотреть файл

@ -408,8 +408,7 @@ nsHTMLImageElement::GetWidthHeight(PRInt32* aWidth, PRInt32* aHeight)
if (frame) {
// XXX we could put an accessor on nsIImageFrame to return its
// mComputedSize.....
nsSize size;
frame->GetSize(size);
nsSize size = frame->GetSize();
nsMargin margin;
frame->CalcBorderPadding(margin);

Просмотреть файл

@ -4002,8 +4002,7 @@ HTMLContentSink::DidProcessAToken(void)
return NS_OK;
}
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
PRUint32 eventTime;
nsCOMPtr<nsIWidget> widget;
@ -4193,8 +4192,7 @@ HTMLContentSink::StartLayout()
shell->InitialReflow(r.width, r.height);
// Now trigger a refresh
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
RefreshIfEnabled(vm);
}
@ -4236,8 +4234,7 @@ HTMLContentSink::StartLayout()
nsCOMPtr<nsIPresShell> shell;
mDocument->GetShellAt(i, getter_AddRefs(shell));
if (shell) {
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsIView* rootView = nsnull;
vm->GetRootView(rootView);

Просмотреть файл

@ -2910,11 +2910,10 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
rv = aShell->GetPrimaryFrameFor(body, &frame);
if (NS_SUCCEEDED(rv) && frame) {
nsSize size;
nsIView* view;
nsCOMPtr<nsIPresContext> presContext;
aShell->GetPresContext(getter_AddRefs(presContext));
view = frame->GetView(presContext);
nsIView* view = frame->GetView();
// If we have a view check if it's scrollable. If not,
// just use the view size itself
@ -2926,31 +2925,25 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
scrollableView->GetScrolledView(view);
}
nsRect r;
rv = view->GetBounds(r);
if (NS_SUCCEEDED(rv)) {
size.height = r.height;
size.width = r.width;
}
nsRect r = view->GetBounds();
size.height = r.height;
size.width = r.width;
}
// If we don't have a view, use the frame size
else {
rv = frame->GetSize(size);
size = frame->GetSize();
}
// Convert from twips to pixels
nsCOMPtr<nsIPresContext> context;
rv = aShell->GetPresContext(getter_AddRefs(context));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPresContext> context;
float scale;
context->GetTwipsToPixels(&scale);
rv = aShell->GetPresContext(getter_AddRefs(context));
if (NS_SUCCEEDED(rv)) {
float scale;
context->GetTwipsToPixels(&scale);
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
}
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
}
}

Просмотреть файл

@ -291,8 +291,7 @@ nsMediaDocument::StartLayout()
shell->InitialReflow(visibleArea.width, visibleArea.height);
// Now trigger a refresh.
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
}

Просмотреть файл

@ -1556,12 +1556,10 @@ nsComputedDOMStyle::GetTextIndent(nsIFrame *aFrame,
break;
case eStyleUnit_Percent:
{
nsIFrame *container = nsnull;
container = GetContainingBlock(aFrame);
nsIFrame *container = GetContainingBlock(aFrame);
if (container) {
nsSize size;
container->GetSize(size);
val->SetTwips(size.width * text->mTextIndent.GetPercentValue());
val->SetTwips(container->GetSize().width *
text->mTextIndent.GetPercentValue());
} else {
// no containing block
val->SetPercent(text->mTextIndent.GetPercentValue());
@ -2263,20 +2261,16 @@ nsComputedDOMStyle::GetHeight(nsIFrame *aFrame,
const nsStyleDisplay* displayData = nsnull;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)displayData,
aFrame);
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE) {
nsFrameState frameState;
aFrame->GetFrameState(&frameState);
if (!(frameState & NS_FRAME_REPLACED_ELEMENT)) {
calcHeight = PR_FALSE;
}
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE
&& !(aFrame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT)) {
calcHeight = PR_FALSE;
}
}
if (calcHeight) {
nsSize size;
nsMargin padding;
nsMargin border;
aFrame->GetSize(size);
nsSize size = aFrame->GetSize();
const nsStylePadding* paddingData = nsnull;
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData,
aFrame);
@ -2341,20 +2335,16 @@ nsComputedDOMStyle::GetWidth(nsIFrame *aFrame,
const nsStyleDisplay *displayData = nsnull;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)displayData,
aFrame);
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE) {
nsFrameState frameState;
aFrame->GetFrameState(&frameState);
if (!(frameState & NS_FRAME_REPLACED_ELEMENT)) {
calcWidth = PR_FALSE;
}
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE
&& !(aFrame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT)) {
calcWidth = PR_FALSE;
}
}
if (calcWidth) {
nsSize size;
nsSize size = aFrame->GetSize();
nsMargin padding;
nsMargin border;
aFrame->GetSize(size);
const nsStylePadding *paddingData = nsnull;
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData,
aFrame);
@ -2422,7 +2412,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame,
if (positionData->mMinHeight.GetUnit() == eStyleUnit_Percent) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
minHeight = nscoord(size.height *
positionData->mMinHeight.GetPercentValue());
}
@ -2439,7 +2429,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame,
if (!container) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
} else {
// no containing block
val->SetPercent(positionData->mMaxHeight.GetPercentValue());
@ -2488,7 +2478,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame,
if (positionData->mMinWidth.GetUnit() == eStyleUnit_Percent) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
minWidth = nscoord(size.width *
positionData->mMinWidth.GetPercentValue());
}
@ -2505,7 +2495,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame,
if (!container) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
} else {
// no containing block
val->SetPercent(positionData->mMaxWidth.GetPercentValue());
@ -2548,7 +2538,6 @@ nsComputedDOMStyle::GetMinHeight(nsIFrame *aFrame,
if (positionData) {
nsIFrame *container = nsnull;
nsSize size;
switch (positionData->mMinHeight.GetUnit()) {
case eStyleUnit_Coord:
val->SetTwips(positionData->mMinHeight.GetCoordValue());
@ -2556,8 +2545,7 @@ nsComputedDOMStyle::GetMinHeight(nsIFrame *aFrame,
case eStyleUnit_Percent:
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
val->SetTwips(size.height *
val->SetTwips(container->GetSize().height *
positionData->mMinHeight.GetPercentValue());
} else {
// no containing block
@ -2596,7 +2584,6 @@ nsComputedDOMStyle::GetMinWidth(nsIFrame *aFrame,
if (positionData) {
nsIFrame *container = nsnull;
nsSize size;
switch (positionData->mMinWidth.GetUnit()) {
case eStyleUnit_Coord:
val->SetTwips(positionData->mMinWidth.GetCoordValue());
@ -2604,8 +2591,7 @@ nsComputedDOMStyle::GetMinWidth(nsIFrame *aFrame,
case eStyleUnit_Percent:
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
val->SetTwips(size.width *
val->SetTwips(container->GetSize().width *
positionData->mMinWidth.GetPercentValue());
} else {
// no containing block
@ -2704,14 +2690,12 @@ nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIFrame* aFrame,
nsIFrame* container = GetContainingBlock(aFrame);
if (container) {
nsRect rect;
nsRect containerRect;
nscoord margin = GetMarginWidthCoordFor(aSide, aFrame);
nscoord border = GetBorderWidthCoordFor(aSide, container);
nscoord horScrollBarHeight = 0;
nscoord verScrollBarWidth = 0;
aFrame->GetRect(rect);
container->GetRect(containerRect);
nsRect rect = aFrame->GetRect();
nsRect containerRect = container->GetRect();
nsCOMPtr<nsIAtom> typeAtom;
container->GetFrameType(getter_AddRefs(typeAtom));
@ -2841,10 +2825,9 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIFrame* aFrame,
if (container) {
nsMargin border;
nsMargin padding;
nsSize size;
container->GetStyleBorder()->CalcBorderFor(container, border);
container->GetStylePadding()->CalcPaddingFor(container, padding);
container->GetSize(size);
nsSize size = container->GetSize();
if (aSide == NS_SIDE_LEFT || aSide == NS_SIDE_RIGHT) {
val->SetTwips(sign * coord.GetPercentValue() *
(size.width - border.left - border.right -
@ -2952,7 +2935,7 @@ nsComputedDOMStyle::GetContainingBlock(nsIFrame *aFrame)
nsIFrame* container = aFrame;
PRBool done = PR_FALSE;
do {
container->GetParent(&container);
container = container->GetParent();
if (container) {
(container)->IsPercentageBase(done);
}
@ -3218,9 +3201,7 @@ nsComputedDOMStyle::GetBorderRadiusFor(PRUint8 aSide, nsIFrame *aFrame,
break;
case eStyleUnit_Percent:
if (aFrame) {
nsSize size;
aFrame->GetSize(size);
val->SetTwips(coord.GetPercentValue() * size.width);
val->SetTwips(coord.GetPercentValue() * aFrame->GetSize().width);
} else {
val->SetPercent(coord.GetPercentValue());
}

Просмотреть файл

@ -69,6 +69,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
const nscoord* aEnumTable, PRInt32 aNumEnums)
{
nscoord result = 0;
nsIFrame* parentFrame = aFrame->GetParent();
switch (aCoord.GetUnit()) {
case eStyleUnit_Auto:
@ -76,9 +77,8 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
break;
case eStyleUnit_Inherit:
nsIFrame* parentFrame;
aFrame->GetParent(&parentFrame); // XXX may not be direct parent...
if (nsnull != parentFrame) {
// XXX may not be direct parent...
if (parentFrame) {
nsStyleContext* parentContext = parentFrame->GetStyleContext();
if (nsnull != parentContext) {
nsMargin parentSpacing;
@ -119,14 +119,11 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
{
nscoord baseWidth = 0;
PRBool isBase = PR_FALSE;
nsIFrame* frame;
aFrame->GetParent(&frame);
while (nsnull != frame) {
nsIFrame* frame = aFrame->GetParent();
while (frame) {
frame->IsPercentageBase(isBase);
if (isBase) {
nsSize size;
frame->GetSize(size);
baseWidth = size.width;
baseWidth = frame->GetSize().width;
// subtract border of containing block
nsMargin border;
frame->GetStyleBorder()->CalcBorderFor(frame, border);
@ -142,7 +139,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
}
break;
}
frame->GetParent(&frame);
frame = frame->GetParent();
}
result = (nscoord)((float)baseWidth * aCoord.GetPercentValue());
}

Просмотреть файл

@ -568,8 +568,7 @@ nsSVGSVGElement::ForceRedraw()
NS_ASSERTION(presShell, "need presShell to unsuspend redraw");
if (!presShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIViewManager> vm;
presShell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = presShell->GetViewManager();
NS_ASSERTION(vm, "need viewmanager to unsuspend redraw");
if (!vm) return NS_ERROR_FAILURE;
@ -986,11 +985,11 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
context->GetTwipsToPixels(&t2p);
nsCOMPtr<nsIWidget> widget;
nsIWidget* widget = nsnull;
while (frame) {
// Look for a widget so we can get screen coordinates
nsIView* view = frame->GetView(context);
nsIView* view = frame->GetView();
if (view) {
// handle scrolled views along the way:
nsIScrollableView* scrollableView = nsnull;
@ -1003,18 +1002,17 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
}
// if this is a widget we break and get screen coords from it:
view->GetWidget(*getter_AddRefs(widget));
widget = view->GetWidget();
if (widget)
break;
}
// No widget yet, so count up the coordinates of the frame
nsPoint origin;
frame->GetOrigin(origin);
nsPoint origin = frame->GetPosition();
x += origin.x;
y += origin.y;
frame->GetParent(&frame);
frame = frame->GetParent();
}

Просмотреть файл

@ -1334,12 +1334,10 @@ nsXMLContentSink::StartLayout()
shell->InitialReflow(r.width, r.height);
// Now trigger a refresh
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
RefreshIfEnabled(vm);
}
}
}
@ -1387,8 +1385,7 @@ nsXMLContentSink::StartLayout()
nsCOMPtr<nsIPresShell> shell;
mDocument->GetShellAt(i, getter_AddRefs(shell));
if (shell) {
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsIView* rootView = nsnull;
vm->GetRootView(rootView);

Просмотреть файл

@ -4556,14 +4556,11 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide)
shell->GetPresContext(getter_AddRefs(presContext));
if (frame && presContext) {
nsIView* view = frame->GetClosestView(presContext);
nsIView* view = frame->GetClosestView();
if (view) {
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
// XXXldb Um, not all views have widgets...
widget->HideWindowChrome(aShouldHide);
view->GetWidget()->HideWindowChrome(aShouldHide);
}
}
}

Просмотреть файл

@ -330,14 +330,14 @@ XULPopupListenerImpl::FireFocusOnTargetContent(nsIDOMNode* aTargetNode)
if ((ui->mUserFocus != NS_STYLE_USER_FOCUS_IGNORE) &&
(ui->mUserFocus != NS_STYLE_USER_FOCUS_NONE))
{
currFrame->GetContent(getter_AddRefs(newFocus));
newFocus = currFrame->GetContent();
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(newFocus));
if (domElement) {
element = domElement;
break;
}
}
currFrame->GetParent(&currFrame);
currFrame = currFrame->GetParent();
}
nsCOMPtr<nsIContent> focusableContent = do_QueryInterface(element);
nsCOMPtr<nsIEventStateManager> esm;

Просмотреть файл

@ -1683,10 +1683,7 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
result = aShell->GetPrimaryFrameFor(mRootContent, &frame);
if (NS_SUCCEEDED(result) && frame) {
nsCOMPtr<nsIPresContext> presContext;
aShell->GetPresContext(getter_AddRefs(presContext));
nsIView* view = frame->GetView(presContext);
nsIView* view = frame->GetView();
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
@ -1696,31 +1693,25 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
scrollableView->GetScrolledView(view);
}
nsRect r;
result = view->GetBounds(r);
if (NS_SUCCEEDED(result)) {
size.height = r.height;
size.width = r.width;
}
nsRect r = view->GetBounds();
size.height = r.height;
size.width = r.width;
}
// If we don't have a view, use the frame size
else {
result = frame->GetSize(size);
size = frame->GetSize();
}
// Convert from twips to pixels
nsCOMPtr<nsIPresContext> context;
result = aShell->GetPresContext(getter_AddRefs(context));
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIPresContext> context;
result = aShell->GetPresContext(getter_AddRefs(context));
if (NS_SUCCEEDED(result)) {
float scale;
context->GetTwipsToPixels(&scale);
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
}
float scale;
context->GetTwipsToPixels(&scale);
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
}
}
else {
@ -2268,8 +2259,7 @@ nsXULDocument::StartLayout(void)
// dropping dirty rects if refresh is disabled rather than
// accumulating them until refresh is enabled and then
// triggering a repaint...
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsCOMPtr<nsIContentViewer> contentViewer;
nsresult rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));

Просмотреть файл

@ -1816,14 +1816,11 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (containerView) {
// see if the containerView has already been hooked into a foreign view manager hierarchy
// if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
nsCOMPtr<nsIViewManager> containerVM;
containerView->GetViewManager(*getter_AddRefs(containerVM));
nsCOMPtr<nsIViewManager> checkVM;
nsIViewManager* containerVM = containerView->GetViewManager();
nsIView* pView = containerView;
do {
pView->GetParent(pView);
} while (pView != nsnull
&& NS_SUCCEEDED(pView->GetViewManager(*getter_AddRefs(checkVM))) && checkVM == containerVM);
pView = pView->GetParent();
} while (pView && pView->GetViewManager() == containerVM);
if (!pView) {
// OK, so the container is not already hooked up into a foreign view manager hierarchy.
@ -1882,7 +1879,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Setup hierarchical relationship in view manager
mViewManager->SetRootView(view);
view->GetWidget(*getter_AddRefs(mWindow));
mWindow = view->GetWidget();
// This SetFocus is necessary so the Arrow Key and Page Key events
// go to the scrolled view as soon as the Window is created instead of going to
@ -3202,12 +3199,10 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
nsIFrame * pageFrame;
seqFrame->FirstChild(mPresContext, nsnull, &pageFrame);
while (pageFrame != nsnull) {
nsRect pageRect;
pageFrame->GetRect(pageRect);
nsRect pageRect = pageFrame->GetRect();
if (pageNum == 1) {
gap = pageRect.y;
}
pageRect.y -= gap;
if (pageRect.Contains(pageRect.x, y)) {
currentPage = pageFrame;
}
@ -3216,7 +3211,7 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
break;
}
pageNum++;
pageFrame->GetNextSibling(&pageFrame);
pageFrame = pageFrame->GetNextSibling();
}
if (aType == nsIWebBrowserPrint::PRINTPREVIEW_PREV_PAGE) {
@ -3244,9 +3239,6 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
}
if (fndPageFrame && scrollableView) {
// get the child rect
nsRect fRect;
fndPageFrame->GetRect(fRect);
// find offset from view
nsPoint pnt;
nsIView * view;
@ -3259,7 +3251,7 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum)
}
// scroll so that top of page (plus the gray area) is at the top of the scroll area
scrollableView->ScrollTo(0, fRect.y-deadSpaceGap, PR_TRUE);
scrollableView->ScrollTo(0, fndPageFrame->GetPosition().y-deadSpaceGap, PR_TRUE);
}
return NS_OK;
#else

Просмотреть файл

@ -613,9 +613,7 @@ public:
{
if (mSelection && mPresContext && mView)
{
void *clientData = 0;
mView->GetClientData(clientData);
nsIFrame *frame = (nsIFrame *)clientData;
nsIFrame *frame = NS_STATIC_CAST(nsIFrame*, mView->GetClientData());
if (!frame)
return NS_OK;
@ -1168,33 +1166,21 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
*offsetX = *offsetY = 0;
nsresult result;
nsIFrame *frame = aFrame;
while (frame)
{
result = frame->GetParentWithView(aPresContext, &frame);
if (NS_FAILED(result))
return result;
frame = frame->GetAncestorWithView();
if (frame) {
nsIView *view = frame->GetView(aPresContext);
nsIView *view = frame->GetView();
if (view)
{
nscoord vX = 0, vY = 0;
result = view->GetPosition(&vX, &vY);
if (NS_FAILED(result))
return result;
*offsetX += vX;
*offsetY += vY;
nsPoint pt = view->GetPosition();
*offsetX += pt.x;
*offsetY += pt.y;
}
}
}
return NS_OK;
@ -1270,12 +1256,7 @@ nsSelection::ConstrainFrameAndPointToAnchorSubtree(nsIPresContext *aPresContext,
// Now find the root of the subtree containing aFrame's content.
//
nsCOMPtr<nsIContent> content;
result = aFrame->GetContent(getter_AddRefs(content));
if (NS_FAILED(result))
return result;
nsIContent* content = aFrame->GetContent();
if (content)
{
@ -1548,9 +1529,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
if (NS_FAILED(result) || !frame)
return result?result:NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content;
result = frame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(frame->GetContent());
nsCOMPtr<nsIDOMNode> parentNode;
nsPeekOffsetStruct pos;
@ -1812,13 +1791,10 @@ nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
while (NS_FAILED(result) && blockFrame)
{
thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame) {
blockFrame = blockFrame->GetParent();
if (blockFrame) {
it = do_QueryInterface(blockFrame, &result);
}
else {
blockFrame = nsnull;
}
}
if (!blockFrame || !it)
return NS_ERROR_FAILURE;
@ -2266,13 +2242,10 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
while (NS_FAILED(result) && blockFrame)
{
thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame) {
blockFrame = blockFrame->GetParent();
if (blockFrame) {
it = do_QueryInterface(blockFrame, &result);
}
else {
blockFrame = nsnull;
}
}
if (!blockFrame || !it)
return NS_ERROR_FAILURE;
@ -2297,12 +2270,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
lastFrame = firstFrame;
for (;lineFrameCount > 1;lineFrameCount --) {
result = lastFrame->GetNextSibling(&lastFrame);
if (NS_FAILED(result)){
NS_ASSERTION(0,"should not be reached nsFrame\n");
return NS_ERROR_FAILURE;
}
lastFrame = lastFrame->GetNextSibling();
}
// GetFirstLeaf
@ -2321,7 +2289,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
if (NS_FAILED(result) || !lookahead)
break; //nothing to do
lastFrame = lookahead;
while (NS_SUCCEEDED(lastFrame->GetNextSibling(&lookahead)) && lookahead)
while ((lookahead = lastFrame->GetNextSibling()) != nsnull)
lastFrame = lookahead;
}
//END LINE DATA CODE
@ -3117,7 +3085,6 @@ nsSelection::CommonPageMove(PRBool aForward,
nsresult result;
const nsIView* clipView;
nsRect viewRect;
//get the frame from the scrollable view
void* clientData;
@ -3130,8 +3097,8 @@ nsSelection::CommonPageMove(PRBool aForward,
if (NS_FAILED(result))
return result;
if (scrolledView && NS_SUCCEEDED(scrolledView->GetClientData(clientData)))
mainframe = (nsIFrame*)clientData;
if (scrolledView)
mainframe = NS_STATIC_CAST(nsIFrame*, scrolledView->GetClientData());
if (!mainframe)
return NS_ERROR_FAILURE;
@ -3139,8 +3106,7 @@ nsSelection::CommonPageMove(PRBool aForward,
// find out where we are; determine amount to page up/down
if (NS_FAILED(result = aScrollableView->GetClipView(&clipView)))
return result;
if (NS_FAILED(result = clipView->GetBounds(viewRect)))
return result;
nsRect viewRect = clipView->GetBounds();
nsCOMPtr<nsIPresContext> context;
result = mTracker->GetPresContext(getter_AddRefs(context));
@ -3196,10 +3162,8 @@ nsSelection::CommonPageMove(PRBool aForward,
nscoord x,y;
while (caretView != scrolledView)
{
caretView->GetPosition(&x, &y);
caretPos.x += x;
caretPos.y += y;
caretView->GetParent(caretView);
caretPos += caretView->GetPosition();
caretView = caretView->GetParent();
if (!caretView) //how did we miss the scrolled view. something is very wrong
return NS_ERROR_FAILURE;
}
@ -3346,7 +3310,7 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe
return NS_OK;
}
thisFrame->GetParent(&thisFrame);
thisFrame = thisFrame->GetParent();
}
*foundFrame = nsnull;
@ -4389,8 +4353,7 @@ nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
if (!selectAllFrame)
return NS_OK;
nsCOMPtr<nsIContent> selectAllContent;
selectAllFrame->GetContent(getter_AddRefs(selectAllContent));
nsIContent* selectAllContent = selectAllFrame->GetContent();
if (selectAllContent)
{
nsCOMPtr<nsIContent> parentContent = selectAllContent->GetParent();
@ -5077,7 +5040,6 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
}
// Now iterated through the child frames and set them
nsCOMPtr<nsIContent> innercontent;
nsRect frameRect;
while (NS_ENUMERATOR_FALSE == aInnerIter->IsDone())
{
result = aInnerIter->CurrentNode(getter_AddRefs(innercontent));
@ -5088,7 +5050,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
{
//NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame
frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);//spread from here to hit all frames in flow
frame->GetRect(frameRect);
nsRect frameRect = frame->GetRect();
//if a rect is 0 height/width then try to notify next available in flow of selection status.
while (!frameRect.width || !frameRect.height)
@ -5096,7 +5058,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
//try to notify next in flow that its content is selected.
if (NS_SUCCEEDED(frame->GetNextInFlow(&frame)) && frame)
{
frame->GetRect(frameRect);
frameRect = frame->GetRect();
frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
}
else
@ -5480,14 +5442,9 @@ nsTypedSelection::GetViewAncestorOffset(nsIView *aView, nsIView *aAncestorView,
for (nsIView* view = aView; view && view != aAncestorView;
view = view->GetParent())
{
nscoord x = 0, y = 0;
nsresult result = view->GetPosition(&x, &y);
if (NS_FAILED(result))
return result;
*aXOffset += x;
*aYOffset += y;
nsPoint pt = view->GetPosition();
*aXOffset += pt.x;
*aYOffset += pt.y;
}
return NS_OK;
@ -5506,10 +5463,7 @@ nsTypedSelection::GetClosestScrollableView(nsIView *aView, nsIScrollableView **a
CallQueryInterface(aView, aScrollableView);
if (!*aScrollableView)
{
nsresult result = aView->GetParent(aView);
if (NS_FAILED(result))
return result;
aView = aView->GetParent();
}
}
@ -5578,12 +5532,7 @@ nsTypedSelection::ScrollPointIntoClipView(nsIPresContext *aPresContext, nsIView
// If it is, scroll the view till it is inside the visible area!
//
nsRect bounds;
result = cView->GetBounds(bounds);
if (NS_FAILED(result))
return result;
nsRect bounds = cView->GetBounds();
result = scrollableView->GetScrollPosition(bounds.x,bounds.y);
@ -5659,19 +5608,8 @@ nsTypedSelection::ScrollPointIntoClipView(nsIPresContext *aPresContext, nsIView
if (dx != 0 || dy != 0)
{
// Get the PresShell
nsCOMPtr<nsIPresShell> presShell;
result = aPresContext->GetShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell,result);
// Get the ViewManager
nsCOMPtr<nsIViewManager> viewManager;
result = presShell->GetViewManager(getter_AddRefs(viewManager));
NS_ENSURE_TRUE(viewManager,result);
// Make sure latest bits are available before we scroll them.
viewManager->Composite();
aPresContext->GetViewManager()->Composite();
// Now scroll the view!
@ -5766,10 +5704,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
// closest scrollable view.
//
result = view->GetParent(view);
if (NS_FAILED(result))
return result;
view = view->GetParent();
while (view)
{
@ -5821,7 +5756,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
if (!view)
return result;
view->GetParent(view);
view = view->GetParent();
}
}
}
@ -5902,7 +5837,7 @@ nsTypedSelection::DoAutoScroll(nsIPresContext *aPresContext, nsIFrame *aFrame, n
// Find the closest view to the frame!
nsIView *closestView = aFrame->GetClosestView(aPresContext);
nsIView *closestView = aFrame->GetClosestView();
if (!closestView)
return NS_ERROR_FAILURE;
@ -7042,12 +6977,7 @@ nsTypedSelection::GetRootScrollableView(nsIScrollableView **aScrollableView)
if (!presShell)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIViewManager> viewManager;
rv = presShell->GetViewManager(getter_AddRefs(viewManager));
if (NS_FAILED(rv))
return rv;
nsIViewManager* viewManager = presShell->GetViewManager();
if (!viewManager)
return NS_ERROR_NULL_POINTER;
@ -7099,14 +7029,11 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi
// XXX Deal with the case where there is a scrolled element, e.g., a
// DIV in the middle...
while (closestView && closestView != scrolledView) {
nscoord dx, dy;
// Update the offset
closestView->GetPosition(&dx, &dy);
offset.MoveBy(dx, dy);
offset += closestView->GetPosition();
// Get its parent view
closestView->GetParent(closestView);
closestView = closestView->GetParent();
}
*aX = offset.x;
@ -7162,25 +7089,19 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
// a rendering context.
//
nsCOMPtr<nsIWidget> widget;
nsIView *closestView = 0;
nsIWidget* widget = nsnull;
nsIView *closestView = nsnull;
nsPoint offset(0, 0);
rv = aFrame->GetOffsetFromView(presContext, offset, &closestView);
while (!widget && closestView)
{
rv = closestView->GetWidget(*getter_AddRefs(widget));
if (NS_FAILED(rv))
return rv;
widget = closestView->GetWidget();
if (!widget)
{
rv = closestView->GetParent(closestView);
if (NS_FAILED(rv))
return rv;
closestView = closestView->GetParent();
}
}
@ -7288,18 +7209,12 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
return NS_ERROR_FAILURE;
nsIView *view = 0;
nsIFrame *parentWithView = 0;
result = frame->GetParentWithView(presContext, &parentWithView);
if (NS_FAILED(result))
return result;
nsIFrame *parentWithView = frame->GetAncestorWithView();
if (!parentWithView)
return NS_ERROR_FAILURE;
view = parentWithView->GetView(presContext);
nsIView* view = parentWithView->GetView();
result = GetClosestScrollableView(view, aScrollableView);
@ -7351,10 +7266,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
//
// Get the frame's rect.
//
result = frame->GetRect(*aRect);
if (NS_FAILED(result))
return result;
*aRect = frame->GetRect();
//
// Translate the frame's rect into root view coordinates.
@ -7381,12 +7293,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
nsRect clipRect;
result = clipView->GetBounds(clipRect);
if (NS_FAILED(result))
return result;
nsRect clipRect = clipView->GetBounds();
result = (*aScrollableView)->GetScrollPosition(clipRect.x, clipRect.y);
@ -7435,12 +7342,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
nsRect svRect;
result = scrolledView->GetBounds(svRect);
if (NS_FAILED(result))
return result;
nsRect svRect = scrolledView->GetBounds();
if (aRect->x < 0)
aRect->x = 0;
@ -7456,10 +7358,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
// Must be a non-text frame, just scroll the frame
// into view.
//
result = frame->GetRect(*aRect);
if (NS_FAILED(result))
return result;
*aRect = frame->GetRect();
result = GetFrameToScrolledViewOffsets(*aScrollableView, frame, &aRect->x, &aRect->y);
}
@ -7484,10 +7383,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
nsRect visibleRect;
aScrollableView->GetClipView(&clipView);
clipView->GetBounds(visibleRect);
nsRect visibleRect = clipView->GetBounds();
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
@ -7564,10 +7462,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
if (!view)
return rv;
rv = view->GetParent(view);
if (NS_FAILED(rv))
return rv;
view = view->GetParent();
if (view)
{

Просмотреть файл

@ -524,7 +524,7 @@ nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
aSeqFrame->FirstChild(aPO->mPresContext, nsnull, &pageFrame);
while (pageFrame != nsnull) {
aCount++;
pageFrame->GetNextSibling(&pageFrame);
pageFrame = pageFrame->GetNextSibling();
}
return NS_OK;
@ -2091,13 +2091,9 @@ void nsPrintEngine::CheckForHiddenFrameSetFrames()
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsIFrame* frame;
po->mDisplayPresShell->GetRootFrame(&frame);
if (frame) {
nsRect rect;
frame->GetRect(rect);
if (rect.height == 0) {
// set this PO and its children to not print and be hidden
SetPrintPO(po, PR_FALSE, PR_TRUE, eSetPrintFlag | eSetHiddenFlag);
}
if (frame && frame->GetSize().height == 0) {
// set this PO and its children to not print and be hidden
SetPrintPO(po, PR_FALSE, PR_TRUE, eSetPrintFlag | eSetHiddenFlag);
}
}
}
@ -2714,10 +2710,9 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
}
if (frame) {
nsIView* view = frame->GetView(aPO->mParent->mPresContext);
nsIView* view = frame->GetView();
if (view) {
nsCOMPtr<nsIWidget> w2;
view->GetWidget(*getter_AddRefs(w2));
nsIWidget* w2 = view->GetWidget();
if (w2) {
widget = w2;
}
@ -2731,7 +2726,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
widget->GetNativeData(NS_NATIVE_WIDGET),
PR_TRUE, PR_TRUE,
eContentTypeContent);
aPO->mRootView->GetWidget(*getter_AddRefs(aPO->mWindow));
aPO->mWindow = aPO->mRootView->GetWidget();
aPO->mPresContext->SetPaginatedScrolling(canCreateScrollbars);
}
#endif // NS_PRINT_PREVIEW
@ -2866,7 +2861,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView* v = theRootFrame->GetView(aPO->mPresContext);
nsIView* v = theRootFrame->GetView();
if (v) {
v->List(fd);
} else {
@ -2949,8 +2944,7 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
// Calc absolute position of the frame all the way up
// to the SimpleSeq frame
nsRect rect;
frame->GetRect(rect);
nsRect rect = frame->GetRect();
rect.Deflate(borderPadding);
rect.x = 0;
@ -2958,16 +2952,15 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
nsIFrame * parent = frame;
nsIFrame * pageFrame = nsnull;
nsIFrame * seqFrame = nsnull;
while (parent != nsnull) {
nsRect rr;
parent->GetRect(rr);
while (parent) {
nsRect rr = parent->GetRect();
rect.x += rr.x;
rect.y += rr.y;
nsIFrame * temp = parent;
temp->GetParent(&parent);
parent = temp->GetParent();
// Keep a pointer to the Seq and Page frames
nsIPageSequenceFrame * sqf = nsnull;
if (parent != nsnull &&
if (parent &&
NS_SUCCEEDED(CallQueryInterface(parent, &sqf)) && sqf) {
pageFrame = temp;
seqFrame = parent;
@ -2992,7 +2985,7 @@ nsPrintEngine::CalcPageFrameLocation(nsIPresShell * aPresShell,
break;
}
pageNum++;
child->GetNextSibling(&child);
child = child->GetNextSibling();
} // while
}
return NS_OK;
@ -3023,7 +3016,7 @@ nsPrintEngine::CalcNumPrintableDocsAndPages(PRInt32& aNumDocs, PRInt32& aNumPage
seqFrame->FirstChild(po->mPresContext, nsnull, &frame);
while (frame) {
aNumPages++;
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
}
}
@ -3089,16 +3082,15 @@ static void GetIFramePosition(nsPrintObject * aPO, nscoord& aX, nscoord& aY)
// and then traverse out ot the pageContentFrame
frame->FirstChild(aPO->mParent->mPresContext, nsnull, &frame);
while (frame) {
nsRect r;
frame->GetRect(r);
aX += r.x;
aY += r.y;
nsPoint pt = frame->GetPosition();
aX += pt.x;
aY += pt.y;
nsCOMPtr<nsIAtom> frameType;
frame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::pageContentFrame == frameType.get()) {
break;
}
frame->GetParent(&frame);
frame = frame->GetParent();
}
}
}
@ -3333,12 +3325,8 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
nsRect areaRect;
nsIFrame * areaFrame = FindFrameByType(poPresContext, startFrame, nsHTMLAtoms::body, rect, areaRect);
if (areaFrame) {
nsRect areaRect;
areaFrame->GetRect(areaRect);
startRect.y -= margin.top+areaRect.y;
startRect.y -= margin.top + areaFrame->GetPosition().y;
endRect.y -= margin.top;
areaRect.y -= startRect.y;
areaRect.x -= margin.left;
// XXX This is temporary fix for printing more than one page of a selection
pageSequence->SetSelectionHeight(startRect.y, endRect.y+endRect.height-startRect.y);
@ -3366,19 +3354,17 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(poPresContext);
if (!ppContext) {
nsRect srect;
seqFrame->GetRect(srect);
nscoord sheight = seqFrame->GetSize().height;
nsRect r;
poRootView->GetBounds(r);
nsRect r = poRootView->GetBounds();
r.x = r.y = 0;
r.height = srect.height;
r.height = sheight;
aPO->mViewManager->ResizeView(poRootView, r, PR_FALSE);
rootFrame->GetRect(r);
r = rootFrame->GetRect();
r.height = srect.height;
rootFrame->SetRect(poPresContext, r);
r.height = sheight;
rootFrame->SetRect(r);
mPageSeqFrame = pageSequence;
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
@ -3692,23 +3678,17 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext,
NS_ASSERTION(aType, "Pointer is null!");
nsIFrame * child;
nsRect rect;
aParentFrame->GetRect(rect);
aRect.x += rect.x;
aRect.y += rect.y;
aRect += aParentFrame->GetPosition();
aParentFrame->FirstChild(aPresContext, nsnull, &child);
while (child != nsnull) {
nsCOMPtr<nsIContent> content;
child->GetContent(getter_AddRefs(content));
while (child) {
nsIContent* content = child->GetContent();
if (content) {
nsCOMPtr<nsIAtom> type;
content->GetTag(getter_AddRefs(type));
if (type.get() == aType) {
nsRect r;
child->GetRect(r);
nsRect r = child->GetRect();
aChildRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return child;
}
}
@ -3716,10 +3696,9 @@ nsPrintEngine::FindFrameByType(nsIPresContext* aPresContext,
if (fndFrame != nsnull) {
return fndFrame;
}
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return nsnull;
}
@ -3742,16 +3721,12 @@ nsPrintEngine::FindSelectionBoundsWithList(nsIPresContext* aPresContext,
nsIFrame * child;
aParentFrame->FirstChild(aPresContext, aList, &child);
nsRect rect;
aParentFrame->GetRect(rect);
aRect.x += rect.x;
aRect.y += rect.y;
while (child != nsnull) {
nsFrameState state;
child->GetFrameState(&state);
aRect += aParentFrame->GetPosition();
while (child) {
// only leaf frames have this bit flipped
// then check the hard way
PRBool isSelected = (state & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
PRBool isSelected = (child->GetStateBits() & NS_FRAME_SELECTED_CONTENT)
== NS_FRAME_SELECTED_CONTENT;
if (isSelected) {
if (NS_FAILED(child->IsVisibleForPainting(aPresContext, aRC, PR_TRUE, &isSelected))) {
return NS_ERROR_FAILURE;
@ -3759,22 +3734,19 @@ nsPrintEngine::FindSelectionBoundsWithList(nsIPresContext* aPresContext,
}
if (isSelected) {
nsRect r;
child->GetRect(r);
nsRect r = child->GetRect();
if (aStartFrame == nsnull) {
aStartFrame = child;
aStartRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
} else {
child->GetRect(r);
aEndFrame = child;
aEndRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
}
}
FindSelectionBounds(aPresContext, aRC, child, aRect, aStartFrame, aStartRect, aEndFrame, aEndRect);
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
aRect.x -= rect.x;
aRect.y -= rect.y;
aRect -= aParentFrame->GetPosition();
return NS_OK;
}
@ -3838,13 +3810,13 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
nsIFrame * startFrame = nsnull;
nsIFrame * endFrame = nsnull;
nsRect rect;
seqFrame->GetRect(rect);
// start out with the sequence frame and search the entire frame tree
// capturing the the starting and ending child frames of the selection
// and their rects
FindSelectionBounds(aPresContext, aRC, seqFrame, rect, startFrame, aStartRect, endFrame, aEndRect);
nsRect r = seqFrame->GetRect();
FindSelectionBounds(aPresContext, aRC, seqFrame, r,
startFrame, aStartRect, endFrame, aEndRect);
#ifdef DEBUG_rodsX
printf("Start Frame: %p\n", startFrame);
@ -3894,7 +3866,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
while (child != nsnull) {
printf("Page: %d - %p\n", pageNum, child);
pageNum++;
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
}
#endif
@ -3912,7 +3884,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
aEndPageNum = pageNum;
}
pageNum++;
page->GetNextSibling(&page);
page = page->GetNextSibling();
}
#ifdef DEBUG_rodsX
@ -4785,19 +4757,15 @@ static void DumpFrames(FILE* out,
frameDebug->GetFrameName(tmp);
}
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
nsFrameState state;
child->GetFrameState(&state);
PRBool isSelected;
if (NS_SUCCEEDED(child->IsVisibleForPainting(aPresContext, *aRendContext, PR_TRUE, &isSelected))) {
fprintf(out, " %p %s", child, isSelected?"VIS":"UVS");
nsRect rect;
child->GetRect(rect);
nsRect rect = child->GetRect();
fprintf(out, "[%d,%d,%d,%d] ", rect.x, rect.y, rect.width, rect.height);
nsIView* view = child->GetView(aPresContext);
fprintf(out, "v: %p ", view);
fprintf(out, "v: %p ", (void*)child->GetView());
fprintf(out, "\n");
DumpFrames(out, aPresContext, aRendContext, child, aLevel+1);
child->GetNextSibling(&child);
child = child->GetNextSibling();
}
}
}
@ -4816,8 +4784,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
fprintf(out, "docshell=%p \n", aDocShell);
nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell);
if (nsnull != shell) {
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsIView* root;
vm->GetRootView(root);
@ -4888,7 +4855,7 @@ void DumpLayoutData(char* aTitleStr,
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView* v = aRootFrame->GetView(aPresContext);
nsIView* v = aRootFrame->GetView();
if (v) {
v->List(fd);
} else {

Просмотреть файл

@ -1556,12 +1556,10 @@ nsComputedDOMStyle::GetTextIndent(nsIFrame *aFrame,
break;
case eStyleUnit_Percent:
{
nsIFrame *container = nsnull;
container = GetContainingBlock(aFrame);
nsIFrame *container = GetContainingBlock(aFrame);
if (container) {
nsSize size;
container->GetSize(size);
val->SetTwips(size.width * text->mTextIndent.GetPercentValue());
val->SetTwips(container->GetSize().width *
text->mTextIndent.GetPercentValue());
} else {
// no containing block
val->SetPercent(text->mTextIndent.GetPercentValue());
@ -2263,20 +2261,16 @@ nsComputedDOMStyle::GetHeight(nsIFrame *aFrame,
const nsStyleDisplay* displayData = nsnull;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)displayData,
aFrame);
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE) {
nsFrameState frameState;
aFrame->GetFrameState(&frameState);
if (!(frameState & NS_FRAME_REPLACED_ELEMENT)) {
calcHeight = PR_FALSE;
}
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE
&& !(aFrame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT)) {
calcHeight = PR_FALSE;
}
}
if (calcHeight) {
nsSize size;
nsMargin padding;
nsMargin border;
aFrame->GetSize(size);
nsSize size = aFrame->GetSize();
const nsStylePadding* paddingData = nsnull;
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData,
aFrame);
@ -2341,20 +2335,16 @@ nsComputedDOMStyle::GetWidth(nsIFrame *aFrame,
const nsStyleDisplay *displayData = nsnull;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)displayData,
aFrame);
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE) {
nsFrameState frameState;
aFrame->GetFrameState(&frameState);
if (!(frameState & NS_FRAME_REPLACED_ELEMENT)) {
calcWidth = PR_FALSE;
}
if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE
&& !(aFrame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT)) {
calcWidth = PR_FALSE;
}
}
if (calcWidth) {
nsSize size;
nsSize size = aFrame->GetSize();
nsMargin padding;
nsMargin border;
aFrame->GetSize(size);
const nsStylePadding *paddingData = nsnull;
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData,
aFrame);
@ -2422,7 +2412,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame,
if (positionData->mMinHeight.GetUnit() == eStyleUnit_Percent) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
minHeight = nscoord(size.height *
positionData->mMinHeight.GetPercentValue());
}
@ -2439,7 +2429,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame,
if (!container) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
} else {
// no containing block
val->SetPercent(positionData->mMaxHeight.GetPercentValue());
@ -2488,7 +2478,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame,
if (positionData->mMinWidth.GetUnit() == eStyleUnit_Percent) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
minWidth = nscoord(size.width *
positionData->mMinWidth.GetPercentValue());
}
@ -2505,7 +2495,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame,
if (!container) {
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
size = container->GetSize();
} else {
// no containing block
val->SetPercent(positionData->mMaxWidth.GetPercentValue());
@ -2548,7 +2538,6 @@ nsComputedDOMStyle::GetMinHeight(nsIFrame *aFrame,
if (positionData) {
nsIFrame *container = nsnull;
nsSize size;
switch (positionData->mMinHeight.GetUnit()) {
case eStyleUnit_Coord:
val->SetTwips(positionData->mMinHeight.GetCoordValue());
@ -2556,8 +2545,7 @@ nsComputedDOMStyle::GetMinHeight(nsIFrame *aFrame,
case eStyleUnit_Percent:
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
val->SetTwips(size.height *
val->SetTwips(container->GetSize().height *
positionData->mMinHeight.GetPercentValue());
} else {
// no containing block
@ -2596,7 +2584,6 @@ nsComputedDOMStyle::GetMinWidth(nsIFrame *aFrame,
if (positionData) {
nsIFrame *container = nsnull;
nsSize size;
switch (positionData->mMinWidth.GetUnit()) {
case eStyleUnit_Coord:
val->SetTwips(positionData->mMinWidth.GetCoordValue());
@ -2604,8 +2591,7 @@ nsComputedDOMStyle::GetMinWidth(nsIFrame *aFrame,
case eStyleUnit_Percent:
container = GetContainingBlock(aFrame);
if (container) {
container->GetSize(size);
val->SetTwips(size.width *
val->SetTwips(container->GetSize().width *
positionData->mMinWidth.GetPercentValue());
} else {
// no containing block
@ -2704,14 +2690,12 @@ nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIFrame* aFrame,
nsIFrame* container = GetContainingBlock(aFrame);
if (container) {
nsRect rect;
nsRect containerRect;
nscoord margin = GetMarginWidthCoordFor(aSide, aFrame);
nscoord border = GetBorderWidthCoordFor(aSide, container);
nscoord horScrollBarHeight = 0;
nscoord verScrollBarWidth = 0;
aFrame->GetRect(rect);
container->GetRect(containerRect);
nsRect rect = aFrame->GetRect();
nsRect containerRect = container->GetRect();
nsCOMPtr<nsIAtom> typeAtom;
container->GetFrameType(getter_AddRefs(typeAtom));
@ -2841,10 +2825,9 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIFrame* aFrame,
if (container) {
nsMargin border;
nsMargin padding;
nsSize size;
container->GetStyleBorder()->CalcBorderFor(container, border);
container->GetStylePadding()->CalcPaddingFor(container, padding);
container->GetSize(size);
nsSize size = container->GetSize();
if (aSide == NS_SIDE_LEFT || aSide == NS_SIDE_RIGHT) {
val->SetTwips(sign * coord.GetPercentValue() *
(size.width - border.left - border.right -
@ -2952,7 +2935,7 @@ nsComputedDOMStyle::GetContainingBlock(nsIFrame *aFrame)
nsIFrame* container = aFrame;
PRBool done = PR_FALSE;
do {
container->GetParent(&container);
container = container->GetParent();
if (container) {
(container)->IsPercentageBase(done);
}
@ -3218,9 +3201,7 @@ nsComputedDOMStyle::GetBorderRadiusFor(PRUint8 aSide, nsIFrame *aFrame,
break;
case eStyleUnit_Percent:
if (aFrame) {
nsSize size;
aFrame->GetSize(size);
val->SetTwips(coord.GetPercentValue() * size.width);
val->SetTwips(coord.GetPercentValue() * aFrame->GetSize().width);
} else {
val->SetPercent(coord.GetPercentValue());
}

Просмотреть файл

@ -69,6 +69,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
const nscoord* aEnumTable, PRInt32 aNumEnums)
{
nscoord result = 0;
nsIFrame* parentFrame = aFrame->GetParent();
switch (aCoord.GetUnit()) {
case eStyleUnit_Auto:
@ -76,9 +77,8 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
break;
case eStyleUnit_Inherit:
nsIFrame* parentFrame;
aFrame->GetParent(&parentFrame); // XXX may not be direct parent...
if (nsnull != parentFrame) {
// XXX may not be direct parent...
if (parentFrame) {
nsStyleContext* parentContext = parentFrame->GetStyleContext();
if (nsnull != parentContext) {
nsMargin parentSpacing;
@ -119,14 +119,11 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
{
nscoord baseWidth = 0;
PRBool isBase = PR_FALSE;
nsIFrame* frame;
aFrame->GetParent(&frame);
while (nsnull != frame) {
nsIFrame* frame = aFrame->GetParent();
while (frame) {
frame->IsPercentageBase(isBase);
if (isBase) {
nsSize size;
frame->GetSize(size);
baseWidth = size.width;
baseWidth = frame->GetSize().width;
// subtract border of containing block
nsMargin border;
frame->GetStyleBorder()->CalcBorderFor(frame, border);
@ -142,7 +139,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
}
break;
}
frame->GetParent(&frame);
frame = frame->GetParent();
}
result = (nscoord)((float)baseWidth * aCoord.GetPercentValue());
}