From 4cedce858af96641391e745b768bb547ba4e1efd Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Wed, 20 Mar 2002 22:14:27 +0000 Subject: [PATCH] bug 124637 - when figuring available width for HRs subtract out both margins. a=asa, sr=attinasi, r=alexsavulov. git-svn-id: svn://10.0.0.236/trunk@116999 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsImageFrame.cpp | 13 +++++++------ mozilla/layout/generic/nsLineLayout.cpp | 15 ++++++++++++++- mozilla/layout/html/base/src/nsImageFrame.cpp | 13 +++++++------ mozilla/layout/html/base/src/nsLineLayout.cpp | 15 ++++++++++++++- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 91b9bb0962e..3fd94db5021 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -1794,12 +1794,13 @@ mRect.height); fprintf(out, " [content=%p]", mContent); // output the img src url - nsCOMPtr uri; - mLoads[0].mRequest->GetURI(getter_AddRefs(uri)); - nsCAutoString uristr; - uri->GetAsciiSpec(uristr); - fprintf(out, " [src=%s]", uristr.get()); - + if (mLoads[0].mRequest) { + nsCOMPtr uri; + mLoads[0].mRequest->GetURI(getter_AddRefs(uri)); + nsCAutoString uristr; + uri->GetAsciiSpec(uristr); + fprintf(out, " [src=%s]", uristr.get()); + } fputs("\n", out); return NS_OK; } diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index b7d784e528e..ae015af6d57 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -1420,6 +1420,19 @@ nsLineLayout::ApplyStartMargin(PerFrameData* pfd, // XXXwaterson probably not the right way to get this; e.g., embeddings, etc. PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection); + PRBool reducedBothMargins = PR_FALSE; + // An HR needs to reduce the avail width by both margins, because it effectively fits + // on one line. If it gets continued then only the continuation has any width. XXX - Are + // there other elements with these characterstics and if so, is there a bit indicating that? + if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) { + nsCOMPtr frameType; + pfd->mFrame->GetFrameType(getter_AddRefs(frameType)); + if (nsLayoutAtoms::hrFrame == frameType.get()) { + aReflowState.availableWidth -= pfd->mMargin.left + pfd->mMargin.right; + reducedBothMargins = PR_TRUE; + } + } + // Only apply start-margin on the first-in flow for inline frames nsIFrame *prevInFlow; pfd->mFrame->GetPrevInFlow(&prevInFlow); @@ -1432,7 +1445,7 @@ nsLineLayout::ApplyStartMargin(PerFrameData* pfd, pfd->mMargin.right = 0; } - if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) { + if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) && !reducedBothMargins){ // Adjust available width to account for the left margin. The // right margin will be accounted for when we finish flowing the // frame. diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 91b9bb0962e..3fd94db5021 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -1794,12 +1794,13 @@ mRect.height); fprintf(out, " [content=%p]", mContent); // output the img src url - nsCOMPtr uri; - mLoads[0].mRequest->GetURI(getter_AddRefs(uri)); - nsCAutoString uristr; - uri->GetAsciiSpec(uristr); - fprintf(out, " [src=%s]", uristr.get()); - + if (mLoads[0].mRequest) { + nsCOMPtr uri; + mLoads[0].mRequest->GetURI(getter_AddRefs(uri)); + nsCAutoString uristr; + uri->GetAsciiSpec(uristr); + fprintf(out, " [src=%s]", uristr.get()); + } fputs("\n", out); return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index b7d784e528e..ae015af6d57 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -1420,6 +1420,19 @@ nsLineLayout::ApplyStartMargin(PerFrameData* pfd, // XXXwaterson probably not the right way to get this; e.g., embeddings, etc. PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection); + PRBool reducedBothMargins = PR_FALSE; + // An HR needs to reduce the avail width by both margins, because it effectively fits + // on one line. If it gets continued then only the continuation has any width. XXX - Are + // there other elements with these characterstics and if so, is there a bit indicating that? + if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) { + nsCOMPtr frameType; + pfd->mFrame->GetFrameType(getter_AddRefs(frameType)); + if (nsLayoutAtoms::hrFrame == frameType.get()) { + aReflowState.availableWidth -= pfd->mMargin.left + pfd->mMargin.right; + reducedBothMargins = PR_TRUE; + } + } + // Only apply start-margin on the first-in flow for inline frames nsIFrame *prevInFlow; pfd->mFrame->GetPrevInFlow(&prevInFlow); @@ -1432,7 +1445,7 @@ nsLineLayout::ApplyStartMargin(PerFrameData* pfd, pfd->mMargin.right = 0; } - if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) { + if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) && !reducedBothMargins){ // Adjust available width to account for the left margin. The // right margin will be accounted for when we finish flowing the // frame.