From a7b02ee40da8ed6e603b5c32d07e2f4869bce76b Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 15 Aug 2001 05:37:53 +0000 Subject: [PATCH] Fix for 95337. r=brendan, sr=ben --- layout/xul/base/src/nsTextBoxFrame.cpp | 17 +++++++- .../src/outliner/src/nsOutlinerBodyFrame.cpp | 42 +++++++++++++++---- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 42 +++++++++++++++---- 3 files changed, 85 insertions(+), 16 deletions(-) diff --git a/layout/xul/base/src/nsTextBoxFrame.cpp b/layout/xul/base/src/nsTextBoxFrame.cpp index 72c08071f44..02b325c1a44 100644 --- a/layout/xul/base/src/nsTextBoxFrame.cpp +++ b/layout/xul/base/src/nsTextBoxFrame.cpp @@ -56,6 +56,8 @@ #define CROP_LEFT "left" #define CROP_RIGHT "right" #define CROP_CENTER "center" +#define CROP_START "start" +#define CROP_END "end" #define NS_STATE_NEED_LAYOUT 0x01000000 @@ -175,11 +177,11 @@ nsTextBoxFrame::UpdateAttributes(nsIPresContext* aPresContext, mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, value); CroppingStyle cropType; - if (value.EqualsIgnoreCase(CROP_LEFT)) + if (value.EqualsIgnoreCase(CROP_LEFT) || value.EqualsIgnoreCase(CROP_START)) cropType = CropLeft; else if (value.EqualsIgnoreCase(CROP_CENTER)) cropType = CropCenter; - else if (value.EqualsIgnoreCase(CROP_RIGHT)) + else if (value.EqualsIgnoreCase(CROP_RIGHT) || value.EqualsIgnoreCase(CROP_END)) cropType = CropRight; else cropType = CropNone; @@ -188,6 +190,17 @@ nsTextBoxFrame::UpdateAttributes(nsIPresContext* aPresContext, aResize = PR_TRUE; mCropType = cropType; } + + if (mCropType == CropLeft || mCropType == CropRight) { + const nsStyleVisibility* vis = + (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); + if (vis->mDirection == NS_STYLE_DIRECTION_RTL) { + if (mCropType == CropLeft) + mCropType = CropRight; + else + mCropType = CropLeft; + } + } } if (aAttribute == nsnull || aAttribute == nsHTMLAtoms::value) { diff --git a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp index e70c7345b01..c96f89195ee 100644 --- a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp +++ b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp @@ -160,21 +160,26 @@ nsOutlinerColumn::nsOutlinerColumn(nsIContent* aColElement, nsIFrame* aFrame) // Cache the ID as an atom. mIDAtom = getter_AddRefs(NS_NewAtom(mID)); + nsCOMPtr styleContext; + aFrame->GetStyleContext(getter_AddRefs(styleContext)); + // Fetch the crop style. mCropStyle = 0; nsAutoString crop; mColElement->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop); if (crop.EqualsIgnoreCase("center")) mCropStyle = 1; - else if (crop.EqualsIgnoreCase("left")) + else if (crop.EqualsIgnoreCase("left") || crop.EqualsIgnoreCase("start")) mCropStyle = 2; - // Cache our text alignment policy. - nsCOMPtr styleContext; - if (!aFrame) - return; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + if (mCropStyle == 0 || mCropStyle == 2) { // Left or Right + const nsStyleVisibility* vis = + (const nsStyleVisibility*)styleContext->GetStyleData(eStyleStruct_Visibility); + if (vis->mDirection == NS_STYLE_DIRECTION_RTL) + mCropStyle = mCropStyle - 2; // Right becomes left, left becomes right. + } + // Cache our text alignment policy. const nsStyleText* textStyle = (const nsStyleText*)styleContext->GetStyleData(eStyleStruct_Text); @@ -2332,8 +2337,31 @@ nsOutlinerBodyFrame::EnsureColumns() PRUint32 count; cols->GetLength(&count); + if (count == 0) + return; // Nothing to do. + + // Get a column, and get the parent frame. We need to use its box direction + // to find out the order in which we should iterate the columns. + nsCOMPtr node; + cols->Item(0, getter_AddRefs(node)); + nsCOMPtr child(do_QueryInterface(node)); + + // Get the frame for this column. + nsIFrame* frame; + shell->GetPrimaryFrameFor(child, &frame); + if (!frame) + return; // This is disastrous. + + nsIFrame* colContainer; + frame->GetParent(&colContainer); + + nsCOMPtr colContainerBox(do_QueryInterface(colContainer)); + PRBool isNormal = PR_TRUE; + colContainerBox->GetDirection(isNormal); + + PRInt32 i = isNormal ? 0 : count-1; nsOutlinerColumn* currCol = nsnull; - for (PRUint32 i = 0; i < count; i++) { + for ( ; (isNormal ? (i < ((PRInt32)count)) : (i >= 0)); (isNormal ? i++ : i--)) { nsCOMPtr node; cols->Item(i, getter_AddRefs(node)); nsCOMPtr child(do_QueryInterface(node)); diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index e70c7345b01..c96f89195ee 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -160,21 +160,26 @@ nsOutlinerColumn::nsOutlinerColumn(nsIContent* aColElement, nsIFrame* aFrame) // Cache the ID as an atom. mIDAtom = getter_AddRefs(NS_NewAtom(mID)); + nsCOMPtr styleContext; + aFrame->GetStyleContext(getter_AddRefs(styleContext)); + // Fetch the crop style. mCropStyle = 0; nsAutoString crop; mColElement->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop); if (crop.EqualsIgnoreCase("center")) mCropStyle = 1; - else if (crop.EqualsIgnoreCase("left")) + else if (crop.EqualsIgnoreCase("left") || crop.EqualsIgnoreCase("start")) mCropStyle = 2; - // Cache our text alignment policy. - nsCOMPtr styleContext; - if (!aFrame) - return; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + if (mCropStyle == 0 || mCropStyle == 2) { // Left or Right + const nsStyleVisibility* vis = + (const nsStyleVisibility*)styleContext->GetStyleData(eStyleStruct_Visibility); + if (vis->mDirection == NS_STYLE_DIRECTION_RTL) + mCropStyle = mCropStyle - 2; // Right becomes left, left becomes right. + } + // Cache our text alignment policy. const nsStyleText* textStyle = (const nsStyleText*)styleContext->GetStyleData(eStyleStruct_Text); @@ -2332,8 +2337,31 @@ nsOutlinerBodyFrame::EnsureColumns() PRUint32 count; cols->GetLength(&count); + if (count == 0) + return; // Nothing to do. + + // Get a column, and get the parent frame. We need to use its box direction + // to find out the order in which we should iterate the columns. + nsCOMPtr node; + cols->Item(0, getter_AddRefs(node)); + nsCOMPtr child(do_QueryInterface(node)); + + // Get the frame for this column. + nsIFrame* frame; + shell->GetPrimaryFrameFor(child, &frame); + if (!frame) + return; // This is disastrous. + + nsIFrame* colContainer; + frame->GetParent(&colContainer); + + nsCOMPtr colContainerBox(do_QueryInterface(colContainer)); + PRBool isNormal = PR_TRUE; + colContainerBox->GetDirection(isNormal); + + PRInt32 i = isNormal ? 0 : count-1; nsOutlinerColumn* currCol = nsnull; - for (PRUint32 i = 0; i < count; i++) { + for ( ; (isNormal ? (i < ((PRInt32)count)) : (i >= 0)); (isNormal ? i++ : i--)) { nsCOMPtr node; cols->Item(i, getter_AddRefs(node)); nsCOMPtr child(do_QueryInterface(node));