Ongoing deCOMtamination. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2003-07-02 10:30:00 +00:00
parent fcdbfdbca9
commit e324543a75
14 changed files with 286 additions and 474 deletions

View File

@ -114,8 +114,6 @@ CreateBidiContinuation(nsIPresContext* aPresContext,
NS_PRECONDITION(aFrame, "null ptr");
nsIFrame* parent;
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell) );
@ -129,8 +127,7 @@ CreateBidiContinuation(nsIPresContext* aPresContext,
NS_ASSERTION(styleContext, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation");
aFrame->GetParent(&parent);
nsIFrame* parent = aFrame->GetParent();
NS_ASSERTION(parent, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation");
(*aNewFrame)->Init(aPresContext, aContent, parent, styleContext, nsnull);
@ -230,7 +227,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
nsIFrame* frame = nsnull;
nsIFrame* nextBidi;
nsCOMPtr<nsIAtom> frameType;
nsCOMPtr<nsIContent> content;
nsIContent* content = nsnull;
nsCOMPtr<nsITextContent> textContent;
const nsTextFragment* fragment;
@ -245,8 +242,9 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
frame->GetFrameType(getter_AddRefs(frameType) );
if (nsLayoutAtoms::textFrame == frameType.get() ) {
mSuccess = frame->GetContent(getter_AddRefs(content) );
if (NS_FAILED(mSuccess) || (!content) ) {
content = frame->GetContent();
if (!content) {
mSuccess = NS_OK;
break;
}
textContent = do_QueryInterface(content, &mSuccess);
@ -299,7 +297,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
// IBMBIDI - Egypt - End
if ( (runLength > 0) && (runLength < fragmentLength) ) {
if (!EnsureBidiContinuation(aPresContext, content.get(), frame,
if (!EnsureBidiContinuation(aPresContext, content, frame,
&nextBidi, frameIndex) ) {
break;
}
@ -312,7 +310,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
frame->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi,
(void**) &nextBidi,sizeof(nextBidi));
if (RemoveBidiContinuation(aPresContext, frame, nextBidi,
content.get(), frameIndex, temp) ) {
content, frameIndex, temp) ) {
aForceReflow = PR_TRUE;
runLength -= temp;
lineOffset += temp;
@ -345,8 +343,7 @@ nsBidiPresUtils::InitLogicalArray(nsIPresContext* aPresContext,
for (frame = aCurrentFrame;
frame && frame != aNextInFlow;
frame->GetNextSibling(&frame) ) {
frame = frame->GetNextSibling()) {
rv = NS_ERROR_FAILURE;
const nsStyleDisplay* display = frame->GetStyleDisplay();
@ -410,7 +407,6 @@ nsBidiPresUtils::CreateBlockBuffer(nsIPresContext* aPresContext)
nsIFrame* frame;
nsIContent* prevContent = nsnull;
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsITextContent> textContent;
nsCOMPtr<nsIAtom> frameType;
const nsTextFragment* frag;
@ -422,14 +418,15 @@ nsBidiPresUtils::CreateBlockBuffer(nsIPresContext* aPresContext)
frame->GetFrameType(getter_AddRefs(frameType) );
if (nsLayoutAtoms::textFrame == frameType.get() ) {
mSuccess = frame->GetContent(getter_AddRefs(content) );
if ( (NS_FAILED(mSuccess) ) || (!content) ) {
nsIContent* content = frame->GetContent();
if (!content) {
mSuccess = NS_OK;
break;
}
if (content.get() == prevContent) {
if (content == prevContent) {
continue;
}
prevContent = content.get();
prevContent = content;
textContent = do_QueryInterface(content, &mSuccess);
if ( (NS_FAILED(mSuccess) ) || (!textContent) ) {
break;
@ -555,8 +552,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
return;
}
nsIFrame* frame = (nsIFrame*) (mVisualFrames[0]);
nsPoint origin;
nsRect rect;
PRInt32 i;
#ifdef FIX_FOR_BUG_40882
@ -573,12 +568,11 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING);
#endif // bug
frame->GetRect(rect);
nsRect rect = frame->GetRect();
if (frame != aFirstChild) {
aFirstChild->GetOrigin(origin);
rect.x = origin.x;
frame->MoveTo(aPresContext, rect.x, rect.y);
rect.x = aFirstChild->GetPosition().x;
frame->SetPosition(nsPoint(rect.x, rect.y));
}
for (i = 1; i < count; i++) {
@ -601,21 +595,20 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
dWidth = width - alefWidth;
}
if (dWidth <= 0) {
frame->MoveTo(aPresContext, rect.x + (nscoord)((float)width/8), rect.y);
frame->SetPosition(nsPoint(rect.x + (nscoord)((float)width/8), rect.y));
}
}
}
#endif // bug
frame = (nsIFrame*) (mVisualFrames[i]);
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, rect.x + rect.width, origin.y);
#ifdef FIX_FOR_BUG_40882
if (ch) {
dx += (rect.width - dWidth);
frame->MoveTo(aPresContext, rect.x + dWidth, origin.y);
}
frame->SetPosition(nsPoint(rect.x + dWidth, frame->GetPosition().y));
} else
#endif // bug 40882
frame->GetRect(rect);
frame->SetPosition(nsPoint(rect.XMost(), frame->GetPosition().y));
rect = frame->GetRect();
} // for
#ifdef FIX_FOR_BUG_40882
@ -634,8 +627,7 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
if (alignRight & 1) {
for (i = 0; i < count; i++) {
frame = (nsIFrame*) (mVisualFrames[i]);
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, origin.x + dx, origin.y);
frame->SetPosition(frame->GetPosition() + nsPoint(dx, 0));
}
}
}
@ -664,7 +656,7 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
PRInt32 maxX = 0;
RepositionContainerFrame(aPresContext, frame, minX, maxX);
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
} // for
}
@ -677,13 +669,12 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
nsIFrame* frame;
nsIFrame* firstChild;
nsCOMPtr<nsIAtom> frameType;
nsRect rect;
PRInt32 minX = 0x7FFFFFFF;
PRInt32 maxX = 0;
aContainer->FirstChild(aPresContext, nsnull, &firstChild);
for (frame = firstChild; frame; frame->GetNextSibling(&frame) ) {
for (frame = firstChild; frame; frame = frame->GetNextSibling()) {
frame->GetFrameType(getter_AddRefs(frameType) );
if ( (frameType.get() )
&& ( (nsLayoutAtoms::inlineFrame == frameType.get() )
@ -693,9 +684,9 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
RepositionContainerFrame(aPresContext, frame, minX, maxX);
}
else {
frame->GetRect(rect);
nsRect rect = frame->GetRect();
minX = PR_MIN(minX, rect.x);
maxX = PR_MAX(maxX, rect.x + rect.width);
maxX = PR_MAX(maxX, rect.XMost());
}
}
@ -703,18 +694,15 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
aMaxX = PR_MAX(maxX, aMaxX);
if (minX < maxX) {
aContainer->GetRect(rect);
nsRect rect = aContainer->GetRect();
rect.x = minX;
rect.width = maxX - minX;
aContainer->SetRect(aPresContext, rect);
aContainer->SetRect(rect);
}
// Now adjust all the kids (kid's coordinates are relative to the parent's)
nsPoint origin;
for (frame = firstChild; frame; frame->GetNextSibling(&frame) ) {
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, origin.x - minX, origin.y);
for (frame = firstChild; frame; frame = frame->GetNextSibling()) {
frame->SetPosition(frame->GetPosition() - nsPoint(minX, 0));
}
}
@ -736,11 +724,7 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIPresContext* aPresContext,
}
if (aFrameIndex + 1 < mLogicalFrames.Count() ) {
nsIFrame* frame = (nsIFrame*)mLogicalFrames[aFrameIndex + 1];
nsCOMPtr<nsIContent> content;
nsresult rv = frame->GetContent(getter_AddRefs(content) );
if (NS_SUCCEEDED(rv) && (content.get() == aContent) ) {
if (frame->GetContent() == aContent) {
*aNewFrame = frame;
++aFrameIndex;
aFrame->SetNextInFlow(nsnull);
@ -769,7 +753,6 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
if (!aFrame) {
return PR_FALSE;
}
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIAtom> frameType;
nsIFrame* frame;
PRInt32 index;
@ -779,8 +762,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
for (index = aFrameIndex + 1; index < frameCount; index++) {
// frames with the same content may not be adjacent. So check all frames.
frame = (nsIFrame*) mLogicalFrames[index];
frame->GetContent(getter_AddRefs(content) );
if (content.get() == aContent) {
if (frame->GetContent() == aContent) {
newIndex = index;
}
}
@ -788,8 +770,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
return PR_FALSE;
}
nsIFrame* nextBidi;
nsIFrame* parent;
aFrame->GetParent(&parent);
nsIFrame* parent = aFrame->GetParent();
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell) );
@ -804,11 +785,9 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
++aOffset;
}
else {
nsFrameState frameState;
frame->GetFrameState(&frameState);
if (frameState & NS_FRAME_IS_BIDI) {
if (frame->GetStateBits() & NS_FRAME_IS_BIDI) {
// only delete Bidi frames
if (parent != nsnull) {
if (parent) {
parent->RemoveFrame(aPresContext, *presShell,
nsLayoutAtoms::nextBidi, frame);
}

View File

@ -366,9 +366,6 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
nsPoint framePos(0, 0);
theFrame->GetPointFromOffset(presContext, rendContext, theFrameOffset, &framePos);
nsRect frameRect;
theFrame->GetRect(frameRect);
// we don't need drawingView anymore so reuse that; reset viewOffset values for our purposes
if (aRelativeToType == eClosestViewCoordinates)
{
@ -380,7 +377,7 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
viewOffset += framePos;
outCoordinates->x = viewOffset.x;
outCoordinates->y = viewOffset.y;
outCoordinates->height = frameRect.height;
outCoordinates->height = theFrame->GetSize().height;
outCoordinates->width = mCaretTwipsWidth;
return NS_OK;
@ -754,10 +751,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n
// mark the frame, so we get notified on deletion.
// frames are never unmarked, which means that we'll touch every frame we visit.
// this is not ideal.
nsFrameState frameState;
theFrame->GetFrameState(&frameState);
frameState |= NS_FRAME_EXTERNAL_REFERENCE;
theFrame->SetFrameState(frameState);
theFrame->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
mLastCaretFrame = theFrame;
mLastContentOffset = theFrameOffset;
@ -806,8 +800,6 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
nsIView* returnView = nsnull; // views are not refcounted
nscoord x, y;
// coorinates relative to the view we are going to use for drawing
if (coordType == eRenderingViewCoordinates)
{
@ -817,23 +809,17 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
// walk up to the first view with a widget
do {
theView->GetPosition(&x, &y);
//is this a scrollable view?
if (!scrollableView)
theView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&scrollableView);
PRBool hasWidget;
theView->HasWidget(&hasWidget);
if (hasWidget)
if (theView->HasWidget())
{
returnView = theView;
break;
}
drawViewOffset.x += x;
drawViewOffset.y += y;
theView->GetParent(theView);
drawViewOffset += theView->GetPosition();
theView = theView->GetParent();
} while (theView);
viewOffset = withinViewOffset;
@ -845,8 +831,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
scrollableView->GetClipView(&clipView);
if (!clipView) return; // should always have one
nsRect bounds;
clipView->GetBounds(bounds);
nsRect bounds = clipView->GetBounds();
scrollableView->GetScrollPosition(bounds.x, bounds.y);
bounds += drawViewOffset; // offset to coords of returned view
@ -854,7 +839,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
}
else
{
returnView->GetBounds(outClipRect);
outClipRect = returnView->GetBounds();
}
if (outRelativeView)
@ -867,29 +852,18 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
viewOffset = withinViewOffset;
do {
theView->GetPosition(&x, &y);
if (!returnView)
{
PRBool hasWidget;
theView->HasWidget(&hasWidget);
if (hasWidget)
returnView = theView;
}
if (!returnView && theView->HasWidget())
returnView = theView;
// is this right?
viewOffset.x += x;
viewOffset.y += y;
viewOffset += theView->GetPosition();
if (outRelativeView && coordType == eTopLevelWindowCoordinates)
*outRelativeView = theView;
theView->GetParent(theView);
theView = theView->GetParent();
} while (theView);
}
*outRenderingView = returnView;
}
@ -981,8 +955,7 @@ void nsCaret::GetCaretRectAndInvert()
{
NS_ASSERTION(mLastCaretFrame != nsnull, "Should have a frame here");
nsRect frameRect;
mLastCaretFrame->GetRect(frameRect);
nsRect frameRect = mLastCaretFrame->GetRect();
frameRect.x = 0; // the origin is accounted for in GetViewForRendering()
frameRect.y = 0;
@ -992,7 +965,7 @@ void nsCaret::GetCaretRectAndInvert()
nsIView *drawingView;
GetViewForRendering(mLastCaretFrame, eRenderingViewCoordinates, viewOffset, clipRect, &drawingView, nsnull);
if (drawingView == nsnull)
if (!drawingView)
return;
frameRect += viewOffset;

View File

@ -363,18 +363,19 @@ nsLeafIterator::Next()
}
else {
while(parent && !IsRootFrame(parent)) {
if (NS_SUCCEEDED(parent->GetNextSibling(&result)) && result) {
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
}
result = parent;
result = parent->GetNextSibling();
if (result) {
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
}
result = parent;
break;
}
else
{
parent->GetParent(&result);
result = parent->GetParent();
if (!result || IsRootFrame(result)) {
result = nsnull;
break;
@ -415,9 +416,9 @@ nsLeafIterator::Prev()
if (!parent)
parent = getLast();
while(parent){
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent )
while (parent){
nsIFrame *grandParent = parent->GetParent();
if (grandParent)
{
// check if FrameType of grandParent is TextInputFrame
if (mLockScroll) //lock the traversal when we hit a scroll frame
@ -450,7 +451,7 @@ nsLeafIterator::Prev()
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result)
while ((result = parent->GetNextSibling()) != nsnull)
{
parent = result;
}
@ -458,11 +459,10 @@ nsLeafIterator::Prev()
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result)
else if (!(result = parent->GetParent()))
{
result = nsnull;
break;
}
else
{
@ -550,12 +550,11 @@ nsFocusIterator::IsPopupFrame(nsIFrame* aFrame)
nsIFrame*
nsFocusIterator::GetParentFrame(nsIFrame* aFrame)
{
nsIFrame* result = 0;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder)
placeholder->GetParent(&result);
return placeholder->GetParent();
return result;
return nsnull;
}
nsIFrame*
@ -575,10 +574,10 @@ nsFocusIterator::GetFirstChild(nsIFrame* aFrame)
nsIFrame*
nsFocusIterator::GetNextSibling(nsIFrame* aFrame)
{
nsIFrame* result = 0;
nsIFrame* result = nsnull;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder) {
placeholder->GetNextSibling(&result);
result = placeholder->GetNextSibling();
if (result)
result = GetRealFrame(result);
}
@ -724,8 +723,8 @@ NS_IMETHODIMP
}
else {
while(parent && !IsRootFrame(parent)) {
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
nsIFrame *grandParent = parent->GetParent();
if (grandParent &&
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
nsFrameList list(result);
result = list.GetNextVisualFor(parent);
@ -737,7 +736,7 @@ NS_IMETHODIMP
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result || IsRootFrame(result)){
else if (!(result = parent->GetParent()) || IsRootFrame(result)) {
result = nsnull;
break;
}
@ -769,8 +768,8 @@ NS_IMETHODIMP
if (!parent)
parent = getLast();
while(parent){
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
nsIFrame *grandParent = parent->GetParent();
if (grandParent &&
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
nsFrameList list(result);
result = list.GetPrevVisualFor(parent);
@ -778,14 +777,14 @@ NS_IMETHODIMP
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result){
parent = result;
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result){
while ((result = parent->GetNextSibling()) != nsnull) {
parent = result;
}
}
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result){
else if ((result = parent->GetParent()) != nsnull) {
result = nsnull;
break;
}

View File

@ -234,7 +234,6 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
{
// Determine damaged area and tell view manager to redraw it
nsPoint offset;
nsRect bounds;
nsIView* view;
// NOTE: It is not sufficient to invalidate only the size of the image:
@ -246,7 +245,7 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// Invalidate the entire frame
// XXX We really only need to invalidate the client area of the frame...
mFrame->GetRect(bounds);
nsRect bounds = mFrame->GetRect();
bounds.x = bounds.y = 0;
// XXX this should be ok, but there is some crappy ass bug causing it not to work
@ -277,19 +276,16 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
// parts of the frame...
if (mFrame->HasView()) {
view = mFrame->GetView(mPresContext);
view = mFrame->GetView();
} else {
mFrame->GetOffsetFromView(mPresContext, offset, &view);
bounds.x += offset.x;
bounds.y += offset.y;
}
nsCOMPtr<nsIViewManager> vm = nsnull;
nsresult rv = NS_OK;
rv = view->GetViewManager(*getter_AddRefs(vm));
if (NS_SUCCEEDED(rv) && vm) {
nsIViewManager* vm = view->GetViewManager();
if (vm) {
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
}
}
}

View File

@ -137,9 +137,7 @@ nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
NS_ASSERTION(!prevInFlow, "aFrame must be first-in-flow");
#endif
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
nsIFrame* firstFrame = GetFirstChildFrame(aPresContext, aFrame, content);
nsIFrame* firstFrame = GetFirstChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (firstFrame && IsGeneratedContentFor(nsnull, firstFrame,
nsCSSPseudoElements::before)) {
@ -155,9 +153,7 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
nsIFrame* lastFrame = GetLastChildFrame(aPresContext, aFrame, content);
nsIFrame* lastFrame = GetLastChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (lastFrame && IsGeneratedContentFor(nsnull, lastFrame,
nsCSSPseudoElements::after)) {
@ -171,14 +167,12 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
nsIFrame*
nsLayoutUtils::GetPageFrame(nsIFrame* aFrame)
{
nsIFrame* frame = aFrame;
while (frame) {
for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}
@ -196,12 +190,8 @@ nsLayoutUtils::IsGeneratedContentFor(nsIContent* aContent,
return PR_FALSE;
}
if (aContent) {
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
if (content != aContent) {
return PR_FALSE;
}
if (aContent && aFrame->GetContent() != aContent) {
return PR_FALSE;
}
nsStyleContext* styleContext = aFrame->GetStyleContext();

View File

@ -1386,8 +1386,7 @@ nsPresContext::LoadImage(const nsString& aURL,
NS_NewURI(getter_AddRefs(uri), aURL, nsnull, baseURI, ioService);
if (!loader) {
nsCOMPtr<nsIContent> content;
aTargetFrame->GetContent(getter_AddRefs(content));
nsIContent* content = aTargetFrame->GetContent();
// Check with the content-policy things to make sure this load is permitted.
nsresult rv;
@ -1435,10 +1434,7 @@ nsPresContext::LoadImage(const nsString& aURL,
// Allow for a null target frame argument (for precached images)
if (aTargetFrame) {
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
aTargetFrame->SetFrameState(state);
aTargetFrame->AddStateBits(NS_FRAME_HAS_LOADED_IMAGES);
}
loader->Load(uri);

View File

@ -114,8 +114,6 @@ CreateBidiContinuation(nsIPresContext* aPresContext,
NS_PRECONDITION(aFrame, "null ptr");
nsIFrame* parent;
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell) );
@ -129,8 +127,7 @@ CreateBidiContinuation(nsIPresContext* aPresContext,
NS_ASSERTION(styleContext, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation");
aFrame->GetParent(&parent);
nsIFrame* parent = aFrame->GetParent();
NS_ASSERTION(parent, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation");
(*aNewFrame)->Init(aPresContext, aContent, parent, styleContext, nsnull);
@ -230,7 +227,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
nsIFrame* frame = nsnull;
nsIFrame* nextBidi;
nsCOMPtr<nsIAtom> frameType;
nsCOMPtr<nsIContent> content;
nsIContent* content = nsnull;
nsCOMPtr<nsITextContent> textContent;
const nsTextFragment* fragment;
@ -245,8 +242,9 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
frame->GetFrameType(getter_AddRefs(frameType) );
if (nsLayoutAtoms::textFrame == frameType.get() ) {
mSuccess = frame->GetContent(getter_AddRefs(content) );
if (NS_FAILED(mSuccess) || (!content) ) {
content = frame->GetContent();
if (!content) {
mSuccess = NS_OK;
break;
}
textContent = do_QueryInterface(content, &mSuccess);
@ -299,7 +297,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
// IBMBIDI - Egypt - End
if ( (runLength > 0) && (runLength < fragmentLength) ) {
if (!EnsureBidiContinuation(aPresContext, content.get(), frame,
if (!EnsureBidiContinuation(aPresContext, content, frame,
&nextBidi, frameIndex) ) {
break;
}
@ -312,7 +310,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext,
frame->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi,
(void**) &nextBidi,sizeof(nextBidi));
if (RemoveBidiContinuation(aPresContext, frame, nextBidi,
content.get(), frameIndex, temp) ) {
content, frameIndex, temp) ) {
aForceReflow = PR_TRUE;
runLength -= temp;
lineOffset += temp;
@ -345,8 +343,7 @@ nsBidiPresUtils::InitLogicalArray(nsIPresContext* aPresContext,
for (frame = aCurrentFrame;
frame && frame != aNextInFlow;
frame->GetNextSibling(&frame) ) {
frame = frame->GetNextSibling()) {
rv = NS_ERROR_FAILURE;
const nsStyleDisplay* display = frame->GetStyleDisplay();
@ -410,7 +407,6 @@ nsBidiPresUtils::CreateBlockBuffer(nsIPresContext* aPresContext)
nsIFrame* frame;
nsIContent* prevContent = nsnull;
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsITextContent> textContent;
nsCOMPtr<nsIAtom> frameType;
const nsTextFragment* frag;
@ -422,14 +418,15 @@ nsBidiPresUtils::CreateBlockBuffer(nsIPresContext* aPresContext)
frame->GetFrameType(getter_AddRefs(frameType) );
if (nsLayoutAtoms::textFrame == frameType.get() ) {
mSuccess = frame->GetContent(getter_AddRefs(content) );
if ( (NS_FAILED(mSuccess) ) || (!content) ) {
nsIContent* content = frame->GetContent();
if (!content) {
mSuccess = NS_OK;
break;
}
if (content.get() == prevContent) {
if (content == prevContent) {
continue;
}
prevContent = content.get();
prevContent = content;
textContent = do_QueryInterface(content, &mSuccess);
if ( (NS_FAILED(mSuccess) ) || (!textContent) ) {
break;
@ -555,8 +552,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
return;
}
nsIFrame* frame = (nsIFrame*) (mVisualFrames[0]);
nsPoint origin;
nsRect rect;
PRInt32 i;
#ifdef FIX_FOR_BUG_40882
@ -573,12 +568,11 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING);
#endif // bug
frame->GetRect(rect);
nsRect rect = frame->GetRect();
if (frame != aFirstChild) {
aFirstChild->GetOrigin(origin);
rect.x = origin.x;
frame->MoveTo(aPresContext, rect.x, rect.y);
rect.x = aFirstChild->GetPosition().x;
frame->SetPosition(nsPoint(rect.x, rect.y));
}
for (i = 1; i < count; i++) {
@ -601,21 +595,20 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
dWidth = width - alefWidth;
}
if (dWidth <= 0) {
frame->MoveTo(aPresContext, rect.x + (nscoord)((float)width/8), rect.y);
frame->SetPosition(nsPoint(rect.x + (nscoord)((float)width/8), rect.y));
}
}
}
#endif // bug
frame = (nsIFrame*) (mVisualFrames[i]);
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, rect.x + rect.width, origin.y);
#ifdef FIX_FOR_BUG_40882
if (ch) {
dx += (rect.width - dWidth);
frame->MoveTo(aPresContext, rect.x + dWidth, origin.y);
}
frame->SetPosition(nsPoint(rect.x + dWidth, frame->GetPosition().y));
} else
#endif // bug 40882
frame->GetRect(rect);
frame->SetPosition(nsPoint(rect.XMost(), frame->GetPosition().y));
rect = frame->GetRect();
} // for
#ifdef FIX_FOR_BUG_40882
@ -634,8 +627,7 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
if (alignRight & 1) {
for (i = 0; i < count; i++) {
frame = (nsIFrame*) (mVisualFrames[i]);
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, origin.x + dx, origin.y);
frame->SetPosition(frame->GetPosition() + nsPoint(dx, 0));
}
}
}
@ -664,7 +656,7 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext,
PRInt32 maxX = 0;
RepositionContainerFrame(aPresContext, frame, minX, maxX);
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
} // for
}
@ -677,13 +669,12 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
nsIFrame* frame;
nsIFrame* firstChild;
nsCOMPtr<nsIAtom> frameType;
nsRect rect;
PRInt32 minX = 0x7FFFFFFF;
PRInt32 maxX = 0;
aContainer->FirstChild(aPresContext, nsnull, &firstChild);
for (frame = firstChild; frame; frame->GetNextSibling(&frame) ) {
for (frame = firstChild; frame; frame = frame->GetNextSibling()) {
frame->GetFrameType(getter_AddRefs(frameType) );
if ( (frameType.get() )
&& ( (nsLayoutAtoms::inlineFrame == frameType.get() )
@ -693,9 +684,9 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
RepositionContainerFrame(aPresContext, frame, minX, maxX);
}
else {
frame->GetRect(rect);
nsRect rect = frame->GetRect();
minX = PR_MIN(minX, rect.x);
maxX = PR_MAX(maxX, rect.x + rect.width);
maxX = PR_MAX(maxX, rect.XMost());
}
}
@ -703,18 +694,15 @@ nsBidiPresUtils::RepositionContainerFrame(nsIPresContext* aPresContext,
aMaxX = PR_MAX(maxX, aMaxX);
if (minX < maxX) {
aContainer->GetRect(rect);
nsRect rect = aContainer->GetRect();
rect.x = minX;
rect.width = maxX - minX;
aContainer->SetRect(aPresContext, rect);
aContainer->SetRect(rect);
}
// Now adjust all the kids (kid's coordinates are relative to the parent's)
nsPoint origin;
for (frame = firstChild; frame; frame->GetNextSibling(&frame) ) {
frame->GetOrigin(origin);
frame->MoveTo(aPresContext, origin.x - minX, origin.y);
for (frame = firstChild; frame; frame = frame->GetNextSibling()) {
frame->SetPosition(frame->GetPosition() - nsPoint(minX, 0));
}
}
@ -736,11 +724,7 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIPresContext* aPresContext,
}
if (aFrameIndex + 1 < mLogicalFrames.Count() ) {
nsIFrame* frame = (nsIFrame*)mLogicalFrames[aFrameIndex + 1];
nsCOMPtr<nsIContent> content;
nsresult rv = frame->GetContent(getter_AddRefs(content) );
if (NS_SUCCEEDED(rv) && (content.get() == aContent) ) {
if (frame->GetContent() == aContent) {
*aNewFrame = frame;
++aFrameIndex;
aFrame->SetNextInFlow(nsnull);
@ -769,7 +753,6 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
if (!aFrame) {
return PR_FALSE;
}
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIAtom> frameType;
nsIFrame* frame;
PRInt32 index;
@ -779,8 +762,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
for (index = aFrameIndex + 1; index < frameCount; index++) {
// frames with the same content may not be adjacent. So check all frames.
frame = (nsIFrame*) mLogicalFrames[index];
frame->GetContent(getter_AddRefs(content) );
if (content.get() == aContent) {
if (frame->GetContent() == aContent) {
newIndex = index;
}
}
@ -788,8 +770,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
return PR_FALSE;
}
nsIFrame* nextBidi;
nsIFrame* parent;
aFrame->GetParent(&parent);
nsIFrame* parent = aFrame->GetParent();
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell) );
@ -804,11 +785,9 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext,
++aOffset;
}
else {
nsFrameState frameState;
frame->GetFrameState(&frameState);
if (frameState & NS_FRAME_IS_BIDI) {
if (frame->GetStateBits() & NS_FRAME_IS_BIDI) {
// only delete Bidi frames
if (parent != nsnull) {
if (parent) {
parent->RemoveFrame(aPresContext, *presShell,
nsLayoutAtoms::nextBidi, frame);
}

View File

@ -366,9 +366,6 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
nsPoint framePos(0, 0);
theFrame->GetPointFromOffset(presContext, rendContext, theFrameOffset, &framePos);
nsRect frameRect;
theFrame->GetRect(frameRect);
// we don't need drawingView anymore so reuse that; reset viewOffset values for our purposes
if (aRelativeToType == eClosestViewCoordinates)
{
@ -380,7 +377,7 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
viewOffset += framePos;
outCoordinates->x = viewOffset.x;
outCoordinates->y = viewOffset.y;
outCoordinates->height = frameRect.height;
outCoordinates->height = theFrame->GetSize().height;
outCoordinates->width = mCaretTwipsWidth;
return NS_OK;
@ -754,10 +751,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n
// mark the frame, so we get notified on deletion.
// frames are never unmarked, which means that we'll touch every frame we visit.
// this is not ideal.
nsFrameState frameState;
theFrame->GetFrameState(&frameState);
frameState |= NS_FRAME_EXTERNAL_REFERENCE;
theFrame->SetFrameState(frameState);
theFrame->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
mLastCaretFrame = theFrame;
mLastContentOffset = theFrameOffset;
@ -806,8 +800,6 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
nsIView* returnView = nsnull; // views are not refcounted
nscoord x, y;
// coorinates relative to the view we are going to use for drawing
if (coordType == eRenderingViewCoordinates)
{
@ -817,23 +809,17 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
// walk up to the first view with a widget
do {
theView->GetPosition(&x, &y);
//is this a scrollable view?
if (!scrollableView)
theView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&scrollableView);
PRBool hasWidget;
theView->HasWidget(&hasWidget);
if (hasWidget)
if (theView->HasWidget())
{
returnView = theView;
break;
}
drawViewOffset.x += x;
drawViewOffset.y += y;
theView->GetParent(theView);
drawViewOffset += theView->GetPosition();
theView = theView->GetParent();
} while (theView);
viewOffset = withinViewOffset;
@ -845,8 +831,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
scrollableView->GetClipView(&clipView);
if (!clipView) return; // should always have one
nsRect bounds;
clipView->GetBounds(bounds);
nsRect bounds = clipView->GetBounds();
scrollableView->GetScrollPosition(bounds.x, bounds.y);
bounds += drawViewOffset; // offset to coords of returned view
@ -854,7 +839,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
}
else
{
returnView->GetBounds(outClipRect);
outClipRect = returnView->GetBounds();
}
if (outRelativeView)
@ -867,29 +852,18 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
viewOffset = withinViewOffset;
do {
theView->GetPosition(&x, &y);
if (!returnView)
{
PRBool hasWidget;
theView->HasWidget(&hasWidget);
if (hasWidget)
returnView = theView;
}
if (!returnView && theView->HasWidget())
returnView = theView;
// is this right?
viewOffset.x += x;
viewOffset.y += y;
viewOffset += theView->GetPosition();
if (outRelativeView && coordType == eTopLevelWindowCoordinates)
*outRelativeView = theView;
theView->GetParent(theView);
theView = theView->GetParent();
} while (theView);
}
*outRenderingView = returnView;
}
@ -981,8 +955,7 @@ void nsCaret::GetCaretRectAndInvert()
{
NS_ASSERTION(mLastCaretFrame != nsnull, "Should have a frame here");
nsRect frameRect;
mLastCaretFrame->GetRect(frameRect);
nsRect frameRect = mLastCaretFrame->GetRect();
frameRect.x = 0; // the origin is accounted for in GetViewForRendering()
frameRect.y = 0;
@ -992,7 +965,7 @@ void nsCaret::GetCaretRectAndInvert()
nsIView *drawingView;
GetViewForRendering(mLastCaretFrame, eRenderingViewCoordinates, viewOffset, clipRect, &drawingView, nsnull);
if (drawingView == nsnull)
if (!drawingView)
return;
frameRect += viewOffset;

View File

@ -123,12 +123,11 @@ protected:
void
nsFrameList::DestroyFrames(nsIPresContext* aPresContext)
{
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
nsIFrame* next;
for (nsIFrame* frame = mFirstChild; frame; frame = next) {
next = frame->GetNextSibling();
frame->Destroy(aPresContext);
mFirstChild = frame = next;
mFirstChild = next;
}
}
@ -144,11 +143,10 @@ nsFrameList::AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList)
else {
lastChild->SetNextSibling(aFrameList);
}
if (nsnull != aParent) {
nsIFrame* frame = aFrameList;
while (nsnull != frame) {
if (aParent) {
for (nsIFrame* frame = aFrameList; frame;
frame = frame->GetNextSibling()) {
frame->SetParent(aParent);
frame->GetNextSibling(&frame);
}
}
}
@ -177,8 +175,7 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
{
NS_PRECONDITION(nsnull != aFrame, "null ptr");
if (nsnull != aFrame) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aFrame->GetNextSibling();
aFrame->SetNextSibling(nsnull);
if (aFrame == mFirstChild) {
mFirstChild = nextFrame;
@ -186,7 +183,7 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
}
else {
nsIFrame* prevSibling = GetPrevSiblingFor(aFrame);
if (nsnull != prevSibling) {
if (prevSibling) {
prevSibling->SetNextSibling(nextFrame);
return PR_TRUE;
}
@ -199,9 +196,8 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
PRBool
nsFrameList::RemoveFirstChild()
{
if (nsnull != mFirstChild) {
nsIFrame* nextFrame;
mFirstChild->GetNextSibling(&nextFrame);
if (mFirstChild) {
nsIFrame* nextFrame = mFirstChild->GetNextSibling();
mFirstChild->SetNextSibling(nsnull);
mFirstChild = nextFrame;
return PR_TRUE;
@ -232,12 +228,11 @@ nsFrameList::InsertFrame(nsIFrame* aParent,
mFirstChild = aNewFrame;
}
else {
nsIFrame* nextFrame;
aPrevSibling->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aPrevSibling->GetNextSibling();
aPrevSibling->SetNextSibling(aNewFrame);
aNewFrame->SetNextSibling(nextFrame);
}
if (nsnull != aParent) {
if (aParent) {
aNewFrame->SetParent(aParent);
}
}
@ -251,12 +246,11 @@ nsFrameList::InsertFrames(nsIFrame* aParent,
NS_PRECONDITION(nsnull != aFrameList, "null ptr");
if (nsnull != aFrameList) {
nsIFrame* lastNewFrame = nsnull;
if (nsnull != aParent) {
nsIFrame* frame = aFrameList;
while (nsnull != frame) {
if (aParent) {
for (nsIFrame* frame = aFrameList; frame;
frame = frame->GetNextSibling()) {
frame->SetParent(aParent);
lastNewFrame = frame;
frame->GetNextSibling(&frame);
}
}
@ -272,8 +266,7 @@ nsFrameList::InsertFrames(nsIFrame* aParent,
mFirstChild = aFrameList;
}
else {
nsIFrame* nextFrame;
aPrevSibling->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aPrevSibling->GetNextSibling();
aPrevSibling->SetNextSibling(aFrameList);
lastNewFrame->SetNextSibling(nextFrame);
}
@ -291,8 +284,7 @@ nsFrameList::DoReplaceFrame(nsIFrame* aParent,
return PR_FALSE;
}
nsIFrame* nextFrame;
aOldFrame->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aOldFrame->GetNextSibling();
if (aOldFrame == mFirstChild) {
mFirstChild = aNewFrame;
}
@ -338,9 +330,8 @@ nsFrameList::Split(nsIFrame* aAfterFrame, nsIFrame** aNextFrameResult)
NS_PRECONDITION(nsnull != aNextFrameResult, "null ptr");
NS_ASSERTION(ContainsFrame(aAfterFrame), "split after unknown frame");
if ((nsnull != aNextFrameResult) && (nsnull != aAfterFrame)) {
nsIFrame* nextFrame;
aAfterFrame->GetNextSibling(&nextFrame);
if (aNextFrameResult && aAfterFrame) {
nsIFrame* nextFrame = aAfterFrame->GetNextSibling();
aAfterFrame->SetNextSibling(nsnull);
*aNextFrameResult = nextFrame;
return PR_TRUE;
@ -380,13 +371,14 @@ nsIFrame*
nsFrameList::LastChild() const
{
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
if (nsnull == next) {
break;
}
if (!frame) {
return nsnull;
}
nsIFrame* next = frame->GetNextSibling();
while (next) {
frame = next;
next = frame->GetNextSibling();
}
return frame;
}
@ -397,8 +389,8 @@ nsFrameList::FrameAt(PRInt32 aIndex) const
NS_PRECONDITION(aIndex >= 0, "invalid arg");
if (aIndex < 0) return nsnull;
nsIFrame* frame = mFirstChild;
while ((aIndex-- > 0) && (nsnull != frame)) {
frame->GetNextSibling(&frame);
while ((aIndex-- > 0) && frame) {
frame = frame->GetNextSibling();
}
return frame;
}
@ -408,11 +400,11 @@ nsFrameList::ContainsFrame(const nsIFrame* aFrame) const
{
NS_PRECONDITION(nsnull != aFrame, "null ptr");
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
while (frame) {
if (frame == aFrame) {
return PR_TRUE;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return PR_FALSE;
}
@ -422,9 +414,9 @@ nsFrameList::GetLength() const
{
PRInt32 count = 0;
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
while (frame) {
count++;
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return count;
}
@ -437,9 +429,8 @@ nsFrameList::GetPrevSiblingFor(nsIFrame* aFrame) const
return nsnull;
}
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
while (frame) {
nsIFrame* next = frame->GetNextSibling();
if (next == aFrame) {
break;
}
@ -452,12 +443,9 @@ void
nsFrameList::VerifyParent(nsIFrame* aParent) const
{
#ifdef NS_DEBUG
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* parent;
frame->GetParent(&parent);
NS_ASSERTION(parent == aParent, "bad parent");
frame->GetNextSibling(&frame);
for (nsIFrame* frame = mFirstChild; frame;
frame = frame->GetNextSibling()) {
NS_ASSERTION(frame->GetParent() == aParent, "bad parent");
}
#endif
}
@ -467,14 +455,12 @@ void
nsFrameList::List(nsIPresContext* aPresContext, FILE* out) const
{
fputs("<\n", out);
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
for (nsIFrame* frame = mFirstChild; frame;
frame = frame->GetNextSibling()) {
nsIFrameDebug* frameDebug;
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
frameDebug->List(aPresContext, out, 1);
}
frame->GetNextSibling(&frame);
}
fputs(">\n", out);
}
@ -492,30 +478,27 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
if (atom.get() == nsLayoutAtoms::blockFrame)
return GetPrevSiblingFor(aFrame);
nsRect tempRect;
nsIFrame* blockFrame;
nsIFrame* frame;
nsIFrame* furthestFrame = nsnull;
frame = mFirstChild;
nsresult result = aFrame->GetParent(&blockFrame);
if (NS_FAILED(result) || !blockFrame)
nsIFrame* blockFrame = aFrame->GetParent();
if (!blockFrame)
return GetPrevSiblingFor(aFrame);
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
nsresult result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
if (NS_FAILED(result) || !iter) { // If the parent is not a block frame, just check all the siblings
PRInt32 maxX, limX;
maxX = -0x7fffffff;
aFrame->GetRect(tempRect);
limX = tempRect.x;
limX = aFrame->GetRect().x;
while (frame) {
frame->GetRect(tempRect);
nsRect tempRect = frame->GetRect();
if (tempRect.x > maxX && tempRect.x < limX) { // we are looking for the highest value less than the current one
maxX = tempRect.x;
furthestFrame = frame;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return furthestFrame;
@ -528,25 +511,23 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
nsFrameOrigin maxOrig(LINE_MIN, XCOORD_MIN);
PRInt32 testLine, thisLine;
aFrame->GetRect(tempRect);
result = iter->FindLineContaining(aFrame, &thisLine);
if (NS_FAILED(result) || thisLine < 0)
return nsnull;
nsFrameOrigin limOrig(thisLine, tempRect.x);
nsFrameOrigin limOrig(thisLine, aFrame->GetRect().x);
while (frame) {
if (NS_SUCCEEDED(iter->FindLineContaining(frame, &testLine))
&& testLine >= 0
&& (testLine == thisLine || testLine == thisLine - 1)) {
frame->GetRect(tempRect);
nsFrameOrigin testOrig(testLine, tempRect.x);
nsFrameOrigin testOrig(testLine, frame->GetRect().x);
if (testOrig > maxOrig && testOrig < limOrig) { // we are looking for the highest value less than the current one
maxOrig = testOrig;
furthestFrame = frame;
}
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return furthestFrame;
}
@ -560,38 +541,32 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
aFrame->GetFrameType(getter_AddRefs(atom));
if (atom.get() == nsLayoutAtoms::blockFrame) {
nsIFrame* frame;
aFrame->GetNextSibling(&frame);
return frame;
return aFrame->GetNextSibling();
}
nsRect tempRect;
nsIFrame* blockFrame;
nsIFrame* frame;
nsIFrame* nearestFrame = nsnull;
frame = mFirstChild;
nsresult result = aFrame->GetParent(&blockFrame);
if (NS_FAILED(result) || !blockFrame)
nsIFrame* blockFrame = aFrame->GetParent();
if (!blockFrame)
return GetPrevSiblingFor(aFrame);
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
nsresult result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
if (NS_FAILED(result) || !iter) { // If the parent is not a block frame, just check all the siblings
PRInt32 minX, limX;
minX = 0x7fffffff;
aFrame->GetRect(tempRect);
limX = tempRect.x;
limX = aFrame->GetRect().x;
while (frame) {
frame->GetRect(tempRect);
nsRect tempRect = frame->GetRect();
if (tempRect.x < minX && tempRect.x > limX) { // we are looking for the lowest value greater than the current one
minX = tempRect.x;
nearestFrame = frame;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return nearestFrame;
}
// Otherwise use the LineIterator to check the siblings on this line and the previous line
@ -601,25 +576,23 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
nsFrameOrigin minOrig(MY_LINE_MAX, XCOORD_MAX);
PRInt32 testLine, thisLine;
aFrame->GetRect(tempRect);
result = iter->FindLineContaining(aFrame, &thisLine);
if (NS_FAILED(result) || thisLine < 0)
return nsnull;
nsFrameOrigin limOrig(thisLine, tempRect.x);
nsFrameOrigin limOrig(thisLine, aFrame->GetRect().x);
while (frame) {
if (NS_SUCCEEDED(iter->FindLineContaining(frame, &testLine))
&& testLine >= 0
&& (testLine == thisLine || testLine == thisLine + 1)) {
frame->GetRect(tempRect);
nsFrameOrigin testOrig(testLine, tempRect.x);
nsFrameOrigin testOrig(testLine, frame->GetRect().x);
if (testOrig < minOrig && testOrig > limOrig) { // we are looking for the lowest value greater than the current one
minOrig = testOrig;
nearestFrame = frame;
}
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return nearestFrame;
}

View File

@ -363,18 +363,19 @@ nsLeafIterator::Next()
}
else {
while(parent && !IsRootFrame(parent)) {
if (NS_SUCCEEDED(parent->GetNextSibling(&result)) && result) {
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
}
result = parent;
result = parent->GetNextSibling();
if (result) {
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
}
result = parent;
break;
}
else
{
parent->GetParent(&result);
result = parent->GetParent();
if (!result || IsRootFrame(result)) {
result = nsnull;
break;
@ -415,9 +416,9 @@ nsLeafIterator::Prev()
if (!parent)
parent = getLast();
while(parent){
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent )
while (parent){
nsIFrame *grandParent = parent->GetParent();
if (grandParent)
{
// check if FrameType of grandParent is TextInputFrame
if (mLockScroll) //lock the traversal when we hit a scroll frame
@ -450,7 +451,7 @@ nsLeafIterator::Prev()
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
{
parent = result;
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result)
while ((result = parent->GetNextSibling()) != nsnull)
{
parent = result;
}
@ -458,11 +459,10 @@ nsLeafIterator::Prev()
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result)
else if (!(result = parent->GetParent()))
{
result = nsnull;
break;
}
else
{
@ -550,12 +550,11 @@ nsFocusIterator::IsPopupFrame(nsIFrame* aFrame)
nsIFrame*
nsFocusIterator::GetParentFrame(nsIFrame* aFrame)
{
nsIFrame* result = 0;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder)
placeholder->GetParent(&result);
return placeholder->GetParent();
return result;
return nsnull;
}
nsIFrame*
@ -575,10 +574,10 @@ nsFocusIterator::GetFirstChild(nsIFrame* aFrame)
nsIFrame*
nsFocusIterator::GetNextSibling(nsIFrame* aFrame)
{
nsIFrame* result = 0;
nsIFrame* result = nsnull;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder) {
placeholder->GetNextSibling(&result);
result = placeholder->GetNextSibling();
if (result)
result = GetRealFrame(result);
}
@ -724,8 +723,8 @@ NS_IMETHODIMP
}
else {
while(parent && !IsRootFrame(parent)) {
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
nsIFrame *grandParent = parent->GetParent();
if (grandParent &&
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
nsFrameList list(result);
result = list.GetNextVisualFor(parent);
@ -737,7 +736,7 @@ NS_IMETHODIMP
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result || IsRootFrame(result)){
else if (!(result = parent->GetParent()) || IsRootFrame(result)) {
result = nsnull;
break;
}
@ -769,8 +768,8 @@ NS_IMETHODIMP
if (!parent)
parent = getLast();
while(parent){
nsIFrame *grandParent;
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
nsIFrame *grandParent = parent->GetParent();
if (grandParent &&
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
nsFrameList list(result);
result = list.GetPrevVisualFor(parent);
@ -778,14 +777,14 @@ NS_IMETHODIMP
parent = result;
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result){
parent = result;
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result){
while ((result = parent->GetNextSibling()) != nsnull) {
parent = result;
}
}
result = parent;
break;
}
else if (NS_FAILED(parent->GetParent(&result)) || !result){
else if ((result = parent->GetParent()) != nsnull) {
result = nsnull;
break;
}

View File

@ -234,7 +234,6 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
{
// Determine damaged area and tell view manager to redraw it
nsPoint offset;
nsRect bounds;
nsIView* view;
// NOTE: It is not sufficient to invalidate only the size of the image:
@ -246,7 +245,7 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// Invalidate the entire frame
// XXX We really only need to invalidate the client area of the frame...
mFrame->GetRect(bounds);
nsRect bounds = mFrame->GetRect();
bounds.x = bounds.y = 0;
// XXX this should be ok, but there is some crappy ass bug causing it not to work
@ -277,19 +276,16 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
// parts of the frame...
if (mFrame->HasView()) {
view = mFrame->GetView(mPresContext);
view = mFrame->GetView();
} else {
mFrame->GetOffsetFromView(mPresContext, offset, &view);
bounds.x += offset.x;
bounds.y += offset.y;
}
nsCOMPtr<nsIViewManager> vm = nsnull;
nsresult rv = NS_OK;
rv = view->GetViewManager(*getter_AddRefs(vm));
if (NS_SUCCEEDED(rv) && vm) {
nsIViewManager* vm = view->GetViewManager();
if (vm) {
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
}
}
}

View File

@ -137,9 +137,7 @@ nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
NS_ASSERTION(!prevInFlow, "aFrame must be first-in-flow");
#endif
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
nsIFrame* firstFrame = GetFirstChildFrame(aPresContext, aFrame, content);
nsIFrame* firstFrame = GetFirstChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (firstFrame && IsGeneratedContentFor(nsnull, firstFrame,
nsCSSPseudoElements::before)) {
@ -155,9 +153,7 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
nsIFrame* lastFrame = GetLastChildFrame(aPresContext, aFrame, content);
nsIFrame* lastFrame = GetLastChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (lastFrame && IsGeneratedContentFor(nsnull, lastFrame,
nsCSSPseudoElements::after)) {
@ -171,14 +167,12 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
nsIFrame*
nsLayoutUtils::GetPageFrame(nsIFrame* aFrame)
{
nsIFrame* frame = aFrame;
while (frame) {
for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}
@ -196,12 +190,8 @@ nsLayoutUtils::IsGeneratedContentFor(nsIContent* aContent,
return PR_FALSE;
}
if (aContent) {
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
if (content != aContent) {
return PR_FALSE;
}
if (aContent && aFrame->GetContent() != aContent) {
return PR_FALSE;
}
nsStyleContext* styleContext = aFrame->GetStyleContext();

View File

@ -1386,8 +1386,7 @@ nsPresContext::LoadImage(const nsString& aURL,
NS_NewURI(getter_AddRefs(uri), aURL, nsnull, baseURI, ioService);
if (!loader) {
nsCOMPtr<nsIContent> content;
aTargetFrame->GetContent(getter_AddRefs(content));
nsIContent* content = aTargetFrame->GetContent();
// Check with the content-policy things to make sure this load is permitted.
nsresult rv;
@ -1435,10 +1434,7 @@ nsPresContext::LoadImage(const nsString& aURL,
// Allow for a null target frame argument (for precached images)
if (aTargetFrame) {
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
aTargetFrame->SetFrameState(state);
aTargetFrame->AddStateBits(NS_FRAME_HAS_LOADED_IMAGES);
}
loader->Load(uri);

View File

@ -123,12 +123,11 @@ protected:
void
nsFrameList::DestroyFrames(nsIPresContext* aPresContext)
{
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
nsIFrame* next;
for (nsIFrame* frame = mFirstChild; frame; frame = next) {
next = frame->GetNextSibling();
frame->Destroy(aPresContext);
mFirstChild = frame = next;
mFirstChild = next;
}
}
@ -144,11 +143,10 @@ nsFrameList::AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList)
else {
lastChild->SetNextSibling(aFrameList);
}
if (nsnull != aParent) {
nsIFrame* frame = aFrameList;
while (nsnull != frame) {
if (aParent) {
for (nsIFrame* frame = aFrameList; frame;
frame = frame->GetNextSibling()) {
frame->SetParent(aParent);
frame->GetNextSibling(&frame);
}
}
}
@ -177,8 +175,7 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
{
NS_PRECONDITION(nsnull != aFrame, "null ptr");
if (nsnull != aFrame) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aFrame->GetNextSibling();
aFrame->SetNextSibling(nsnull);
if (aFrame == mFirstChild) {
mFirstChild = nextFrame;
@ -186,7 +183,7 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
}
else {
nsIFrame* prevSibling = GetPrevSiblingFor(aFrame);
if (nsnull != prevSibling) {
if (prevSibling) {
prevSibling->SetNextSibling(nextFrame);
return PR_TRUE;
}
@ -199,9 +196,8 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame)
PRBool
nsFrameList::RemoveFirstChild()
{
if (nsnull != mFirstChild) {
nsIFrame* nextFrame;
mFirstChild->GetNextSibling(&nextFrame);
if (mFirstChild) {
nsIFrame* nextFrame = mFirstChild->GetNextSibling();
mFirstChild->SetNextSibling(nsnull);
mFirstChild = nextFrame;
return PR_TRUE;
@ -232,12 +228,11 @@ nsFrameList::InsertFrame(nsIFrame* aParent,
mFirstChild = aNewFrame;
}
else {
nsIFrame* nextFrame;
aPrevSibling->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aPrevSibling->GetNextSibling();
aPrevSibling->SetNextSibling(aNewFrame);
aNewFrame->SetNextSibling(nextFrame);
}
if (nsnull != aParent) {
if (aParent) {
aNewFrame->SetParent(aParent);
}
}
@ -251,12 +246,11 @@ nsFrameList::InsertFrames(nsIFrame* aParent,
NS_PRECONDITION(nsnull != aFrameList, "null ptr");
if (nsnull != aFrameList) {
nsIFrame* lastNewFrame = nsnull;
if (nsnull != aParent) {
nsIFrame* frame = aFrameList;
while (nsnull != frame) {
if (aParent) {
for (nsIFrame* frame = aFrameList; frame;
frame = frame->GetNextSibling()) {
frame->SetParent(aParent);
lastNewFrame = frame;
frame->GetNextSibling(&frame);
}
}
@ -272,8 +266,7 @@ nsFrameList::InsertFrames(nsIFrame* aParent,
mFirstChild = aFrameList;
}
else {
nsIFrame* nextFrame;
aPrevSibling->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aPrevSibling->GetNextSibling();
aPrevSibling->SetNextSibling(aFrameList);
lastNewFrame->SetNextSibling(nextFrame);
}
@ -291,8 +284,7 @@ nsFrameList::DoReplaceFrame(nsIFrame* aParent,
return PR_FALSE;
}
nsIFrame* nextFrame;
aOldFrame->GetNextSibling(&nextFrame);
nsIFrame* nextFrame = aOldFrame->GetNextSibling();
if (aOldFrame == mFirstChild) {
mFirstChild = aNewFrame;
}
@ -338,9 +330,8 @@ nsFrameList::Split(nsIFrame* aAfterFrame, nsIFrame** aNextFrameResult)
NS_PRECONDITION(nsnull != aNextFrameResult, "null ptr");
NS_ASSERTION(ContainsFrame(aAfterFrame), "split after unknown frame");
if ((nsnull != aNextFrameResult) && (nsnull != aAfterFrame)) {
nsIFrame* nextFrame;
aAfterFrame->GetNextSibling(&nextFrame);
if (aNextFrameResult && aAfterFrame) {
nsIFrame* nextFrame = aAfterFrame->GetNextSibling();
aAfterFrame->SetNextSibling(nsnull);
*aNextFrameResult = nextFrame;
return PR_TRUE;
@ -380,13 +371,14 @@ nsIFrame*
nsFrameList::LastChild() const
{
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
if (nsnull == next) {
break;
}
if (!frame) {
return nsnull;
}
nsIFrame* next = frame->GetNextSibling();
while (next) {
frame = next;
next = frame->GetNextSibling();
}
return frame;
}
@ -397,8 +389,8 @@ nsFrameList::FrameAt(PRInt32 aIndex) const
NS_PRECONDITION(aIndex >= 0, "invalid arg");
if (aIndex < 0) return nsnull;
nsIFrame* frame = mFirstChild;
while ((aIndex-- > 0) && (nsnull != frame)) {
frame->GetNextSibling(&frame);
while ((aIndex-- > 0) && frame) {
frame = frame->GetNextSibling();
}
return frame;
}
@ -408,11 +400,11 @@ nsFrameList::ContainsFrame(const nsIFrame* aFrame) const
{
NS_PRECONDITION(nsnull != aFrame, "null ptr");
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
while (frame) {
if (frame == aFrame) {
return PR_TRUE;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return PR_FALSE;
}
@ -422,9 +414,9 @@ nsFrameList::GetLength() const
{
PRInt32 count = 0;
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
while (frame) {
count++;
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return count;
}
@ -437,9 +429,8 @@ nsFrameList::GetPrevSiblingFor(nsIFrame* aFrame) const
return nsnull;
}
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* next;
frame->GetNextSibling(&next);
while (frame) {
nsIFrame* next = frame->GetNextSibling();
if (next == aFrame) {
break;
}
@ -452,12 +443,9 @@ void
nsFrameList::VerifyParent(nsIFrame* aParent) const
{
#ifdef NS_DEBUG
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
nsIFrame* parent;
frame->GetParent(&parent);
NS_ASSERTION(parent == aParent, "bad parent");
frame->GetNextSibling(&frame);
for (nsIFrame* frame = mFirstChild; frame;
frame = frame->GetNextSibling()) {
NS_ASSERTION(frame->GetParent() == aParent, "bad parent");
}
#endif
}
@ -467,14 +455,12 @@ void
nsFrameList::List(nsIPresContext* aPresContext, FILE* out) const
{
fputs("<\n", out);
nsIFrame* frame = mFirstChild;
while (nsnull != frame) {
for (nsIFrame* frame = mFirstChild; frame;
frame = frame->GetNextSibling()) {
nsIFrameDebug* frameDebug;
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
frameDebug->List(aPresContext, out, 1);
}
frame->GetNextSibling(&frame);
}
fputs(">\n", out);
}
@ -492,30 +478,27 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
if (atom.get() == nsLayoutAtoms::blockFrame)
return GetPrevSiblingFor(aFrame);
nsRect tempRect;
nsIFrame* blockFrame;
nsIFrame* frame;
nsIFrame* furthestFrame = nsnull;
frame = mFirstChild;
nsresult result = aFrame->GetParent(&blockFrame);
if (NS_FAILED(result) || !blockFrame)
nsIFrame* blockFrame = aFrame->GetParent();
if (!blockFrame)
return GetPrevSiblingFor(aFrame);
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
nsresult result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
if (NS_FAILED(result) || !iter) { // If the parent is not a block frame, just check all the siblings
PRInt32 maxX, limX;
maxX = -0x7fffffff;
aFrame->GetRect(tempRect);
limX = tempRect.x;
limX = aFrame->GetRect().x;
while (frame) {
frame->GetRect(tempRect);
nsRect tempRect = frame->GetRect();
if (tempRect.x > maxX && tempRect.x < limX) { // we are looking for the highest value less than the current one
maxX = tempRect.x;
furthestFrame = frame;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return furthestFrame;
@ -528,25 +511,23 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
nsFrameOrigin maxOrig(LINE_MIN, XCOORD_MIN);
PRInt32 testLine, thisLine;
aFrame->GetRect(tempRect);
result = iter->FindLineContaining(aFrame, &thisLine);
if (NS_FAILED(result) || thisLine < 0)
return nsnull;
nsFrameOrigin limOrig(thisLine, tempRect.x);
nsFrameOrigin limOrig(thisLine, aFrame->GetRect().x);
while (frame) {
if (NS_SUCCEEDED(iter->FindLineContaining(frame, &testLine))
&& testLine >= 0
&& (testLine == thisLine || testLine == thisLine - 1)) {
frame->GetRect(tempRect);
nsFrameOrigin testOrig(testLine, tempRect.x);
nsFrameOrigin testOrig(testLine, frame->GetRect().x);
if (testOrig > maxOrig && testOrig < limOrig) { // we are looking for the highest value less than the current one
maxOrig = testOrig;
furthestFrame = frame;
}
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return furthestFrame;
}
@ -560,38 +541,32 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
aFrame->GetFrameType(getter_AddRefs(atom));
if (atom.get() == nsLayoutAtoms::blockFrame) {
nsIFrame* frame;
aFrame->GetNextSibling(&frame);
return frame;
return aFrame->GetNextSibling();
}
nsRect tempRect;
nsIFrame* blockFrame;
nsIFrame* frame;
nsIFrame* nearestFrame = nsnull;
frame = mFirstChild;
nsresult result = aFrame->GetParent(&blockFrame);
if (NS_FAILED(result) || !blockFrame)
nsIFrame* blockFrame = aFrame->GetParent();
if (!blockFrame)
return GetPrevSiblingFor(aFrame);
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
nsresult result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator), (void**)&iter);
if (NS_FAILED(result) || !iter) { // If the parent is not a block frame, just check all the siblings
PRInt32 minX, limX;
minX = 0x7fffffff;
aFrame->GetRect(tempRect);
limX = tempRect.x;
limX = aFrame->GetRect().x;
while (frame) {
frame->GetRect(tempRect);
nsRect tempRect = frame->GetRect();
if (tempRect.x < minX && tempRect.x > limX) { // we are looking for the lowest value greater than the current one
minX = tempRect.x;
nearestFrame = frame;
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return nearestFrame;
}
// Otherwise use the LineIterator to check the siblings on this line and the previous line
@ -601,25 +576,23 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
nsFrameOrigin minOrig(MY_LINE_MAX, XCOORD_MAX);
PRInt32 testLine, thisLine;
aFrame->GetRect(tempRect);
result = iter->FindLineContaining(aFrame, &thisLine);
if (NS_FAILED(result) || thisLine < 0)
return nsnull;
nsFrameOrigin limOrig(thisLine, tempRect.x);
nsFrameOrigin limOrig(thisLine, aFrame->GetRect().x);
while (frame) {
if (NS_SUCCEEDED(iter->FindLineContaining(frame, &testLine))
&& testLine >= 0
&& (testLine == thisLine || testLine == thisLine + 1)) {
frame->GetRect(tempRect);
nsFrameOrigin testOrig(testLine, tempRect.x);
nsFrameOrigin testOrig(testLine, frame->GetRect().x);
if (testOrig < minOrig && testOrig > limOrig) { // we are looking for the lowest value greater than the current one
minOrig = testOrig;
nearestFrame = frame;
}
}
frame->GetNextSibling(&frame);
frame = frame->GetNextSibling();
}
return nearestFrame;
}