Commit 26d91ba5 authored by hyatt%netscape.com's avatar hyatt%netscape.com
Browse files

Fix for 93177, r/sr=pavlov,ben

parent 4d485ab1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -999,6 +999,17 @@ nsBox::GetOrientation(PRBool& aIsHorizontal)
   return NS_OK;
}

NS_IMETHODIMP 
nsBox::GetDirection(PRBool& aIsNormal)
{
   nsIFrame* frame = nsnull;
   GetFrame(&frame);
   nsFrameState state;
   frame->GetFrameState(&state);
   aIsNormal = (state & NS_STATE_IS_DIRECTION_NORMAL);
   return NS_OK;
}

nsresult
nsBox::SyncLayout(nsBoxLayoutState& aState)
{
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public:
  NS_IMETHOD GetHAlign(Halignment& aAlign);
  NS_IMETHOD GetInset(nsMargin& aInset);
  NS_IMETHOD GetOrientation(PRBool& aIsHorizontal);
  NS_IMETHOD GetDirection(PRBool& aIsNormal);

  NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
  NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
+56 −1
Original line number Diff line number Diff line
@@ -290,6 +290,11 @@ nsBoxFrame::IsHorizontal() const
   return mState & NS_STATE_IS_HORIZONTAL;
}

PRBool 
nsBoxFrame::IsNormalDirection() const
{
   return mState & NS_STATE_IS_DIRECTION_NORMAL;
}

/**
 * Initialize us. This is a good time to get the alignment of the box
@@ -370,6 +375,13 @@ nsBoxFrameInner::CacheAttributes()
  else
    mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;

  PRBool normal = PR_TRUE;
  mOuter->GetInitialDirection(normal); 
  if (normal)
    mOuter->mState |= NS_STATE_IS_DIRECTION_NORMAL;
  else
    mOuter->mState &= ~NS_STATE_IS_DIRECTION_NORMAL;

  mOuter->GetInitialVAlignment(mValign);
  mOuter->GetInitialHAlignment(mHalign);
  
@@ -634,6 +646,42 @@ nsBoxFrame::GetInitialOrientation(PRBool& aIsHorizontal)
  }
}

void
nsBoxFrame::GetInitialDirection(PRBool& aIsNormal)
{
  nsAutoString value;
  nsCOMPtr<nsIContent> content;
  GetContentOf(getter_AddRefs(content));

  if (!content)
    return;

  if (IsHorizontal()) {
    // For horizontal boxes only, we initialize our value based off the CSS 'direction' property.
    // This means that BiDI users will end up with horizontally inverted chrome.
    const nsStyleVisibility* vis;
    GetStyleData(eStyleStruct_Visibility,
                 (const nsStyleStruct*&)vis);
    aIsNormal = (vis->mDirection == NS_STYLE_DIRECTION_LTR); // If text runs RTL then so do we.
  }
  else
    aIsNormal = PR_TRUE; // Assume a normal direction in the vertical case.

  // Now check the style system to see if we should invert aIsNormal.
  const nsStyleXUL* boxInfo;
  GetStyleData(eStyleStruct_XUL,
               (const nsStyleStruct*&)boxInfo);
  if (boxInfo->mBoxDirection == NS_STYLE_BOX_DIRECTION_REVERSE)
    aIsNormal = !aIsNormal; // Invert our direction.
  
  // Now see if we have an attribute.  The attribute overrides
  // the style system value.
  if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::dir, value)) {
    if (value.EqualsIgnoreCase("reverse"))
      aIsNormal = !aIsNormal; // Invert our direction.
  }
}

/* Returns true if it was set.
 */
PRBool
@@ -1222,7 +1270,7 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext,
        aAttribute == nsXULAtoms::equalsize ||
        aAttribute == nsXULAtoms::autostretch) {

        if (aAttribute == nsXULAtoms::orient || aAttribute == nsXULAtoms::debug || aAttribute == nsHTMLAtoms::align || aAttribute == nsHTMLAtoms::valign) {
       if (aAttribute == nsXULAtoms::orient || aAttribute == nsXULAtoms::dir || aAttribute == nsXULAtoms::debug || aAttribute == nsHTMLAtoms::align || aAttribute == nsHTMLAtoms::valign) {
          mInner->mValign = nsBoxFrame::vAlign_Top;
          mInner->mHalign = nsBoxFrame::hAlign_Left;

@@ -1233,6 +1281,13 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext,
          else
            mState &= ~NS_STATE_IS_HORIZONTAL;

          PRBool normal = PR_TRUE;
          GetInitialDirection(normal);
          if (normal)
            mState |= NS_STATE_IS_DIRECTION_NORMAL;
          else
            mState &= ~NS_STATE_IS_DIRECTION_NORMAL;

          GetInitialVAlignment(mInner->mValign);
          GetInitialHAlignment(mInner->mHalign);
  
+4 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class nsHTMLInfo;
#define NS_STATE_IS_COLLAPSED            0x10000000
#define NS_STATE_STYLE_CHANGE            0x20000000
#define NS_STATE_EQUAL_SIZE              0x40000000
#define NS_STATE_IS_DIRECTION_NORMAL     0x80000000

class nsBoxFrame : public nsContainerFrame, public nsContainerBox
{
@@ -155,6 +156,7 @@ public:
                   nsDidReflowStatus aStatus);

  virtual PRBool IsHorizontal() const;
  virtual PRBool IsNormalDirection() const;

  virtual ~nsBoxFrame();

@@ -200,6 +202,7 @@ protected:

    virtual PRBool GetInitialEqualSize(PRBool& aEqualSize); 
    virtual void GetInitialOrientation(PRBool& aIsHorizontal);
    virtual void GetInitialDirection(PRBool& aIsNormal);
    virtual PRBool GetInitialHAlignment(Halignment& aHalign); 
    virtual PRBool GetInitialVAlignment(Valignment& aValign); 
    virtual PRBool GetInitialAutoStretch(PRBool& aStretch); 
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
 * Rights Reserved.
 *
 * Contributor(s): 
 *   David Hyatt (hyatt@netscape.com)
 */

/**
@@ -95,6 +96,7 @@ public:
  NS_IMETHOD GetVAlign(Valignment& aAlign) = 0;
  NS_IMETHOD GetHAlign(Halignment& aAlign) = 0;
  NS_IMETHOD GetOrientation(PRBool& aIsHorizontal)=0;
  NS_IMETHOD GetDirection(PRBool& aIsNormal)=0;
  NS_IMETHOD Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nsnull, PRBool aImmediate = PR_FALSE)=0;
  NS_IMETHOD NeedsRecalc()=0;
  NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox)=0;
Loading