From b8be429add42d8315b5d9c4aac79231565fa05fb Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Tue, 6 Aug 2002 12:59:48 +0000 Subject: [PATCH] Hacky fix to make HR's ALIGN attribute work again. b=158197 r=mjudge sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@126503 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsLineLayout.cpp | 23 +++++++++++++++++-- mozilla/layout/html/base/src/nsLineLayout.cpp | 23 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 28e43d4b574..c89c89596d9 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -3052,9 +3052,28 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, content->GetTag(*getter_AddRefs(tag)); if (tag == nsHTMLAtoms::hr) { // get the alignment from the HR frame + + // hack to get the HRFrame due to the wrapper frame for the + // quirks mode anonymous content + nsIFrame *hrFrame = psd->mFirstFrame->mFrame; + nsCOMPtr frameType; + hrFrame->GetFrameType(getter_AddRefs(frameType)); + if (frameType != nsLayoutAtoms::hrFrame) { + // |hrFrame| is a wrapper frame, so the real frame is one + // of its children. + nsIFrame *child; + for (hrFrame->FirstChild(mPresContext, nsnull, &child); + child; child->GetNextSibling(&child)) { + child->GetFrameType(getter_AddRefs(frameType)); + if (frameType == nsLayoutAtoms::hrFrame) { + hrFrame = child; + break; + } + } + } + const nsStyleMargin* margin; - psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Margin, - (const nsStyleStruct*&)margin); + ::GetStyleData(hrFrame, &margin); textAlign = NS_STYLE_TEXT_ALIGN_CENTER; nsStyleCoord zero(nscoord(0)); nsStyleCoord temp; diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 28e43d4b574..c89c89596d9 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -3052,9 +3052,28 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, content->GetTag(*getter_AddRefs(tag)); if (tag == nsHTMLAtoms::hr) { // get the alignment from the HR frame + + // hack to get the HRFrame due to the wrapper frame for the + // quirks mode anonymous content + nsIFrame *hrFrame = psd->mFirstFrame->mFrame; + nsCOMPtr frameType; + hrFrame->GetFrameType(getter_AddRefs(frameType)); + if (frameType != nsLayoutAtoms::hrFrame) { + // |hrFrame| is a wrapper frame, so the real frame is one + // of its children. + nsIFrame *child; + for (hrFrame->FirstChild(mPresContext, nsnull, &child); + child; child->GetNextSibling(&child)) { + child->GetFrameType(getter_AddRefs(frameType)); + if (frameType == nsLayoutAtoms::hrFrame) { + hrFrame = child; + break; + } + } + } + const nsStyleMargin* margin; - psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Margin, - (const nsStyleStruct*&)margin); + ::GetStyleData(hrFrame, &margin); textAlign = NS_STYLE_TEXT_ALIGN_CENTER; nsStyleCoord zero(nscoord(0)); nsStyleCoord temp;