mMolecule.proportionalWidth = 100;
mMolecule.proportionalWidth = -1;
void StyleContextImpl::HackStyleFor(nsIPresContext* aPresContext,                                    nsIContent* aContent,                                    nsIFrame* aParentFrame){/*  mColor.mColor = NS_RGB(0, 0, 0);*/  mMolecule.display = NS_STYLE_DISPLAY_BLOCK;  mMolecule.whiteSpace = NS_STYLE_WHITESPACE_NORMAL;  mMolecule.verticalAlign = NS_STYLE_VERTICAL_ALIGN_BASELINE;  mMolecule.textAlign = NS_STYLE_TEXT_ALIGN_LEFT;  mMolecule.positionFlags = NS_STYLE_POSITION_STATIC;  mMolecule.floats = 0;  // XXX If it's a B guy then make it inline  nsIAtom* tag = aContent->GetTag();  nsAutoString buf;  if (tag != nsnull) {    tag->ToString(buf);    NS_RELEASE(tag);    if (buf.EqualsIgnoreCase("B")) {//      float p2t = aPresContext->GetPixelsToTwips();      mMolecule.display = NS_STYLE_DISPLAY_INLINE;//      mColor.mBackgroundColor = NS_RGB(128, 128, 255);//      mColor.mBackgroundFlags = 0;//      mMolecule.border.top = nscoord(5 * p2t);//      mMolecule.border.right = nscoord(5 * p2t);//      mMolecule.border.bottom = nscoord(5 * p2t);//      mMolecule.border.left = nscoord(5 * p2t);//      for (int i = 0; i < 4; i++) {//        mMolecule.borderStyle[i] = NS_STYLE_BORDER_STYLE_INSET;//        mMolecule.borderColor[i] = NS_RGB(128, 128, 128);//      }    } else if (buf.EqualsIgnoreCase("A")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;      mMolecule.cursor = NS_STYLE_CURSOR_HAND;    } else if (buf.EqualsIgnoreCase("BR")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;      nsString  align("CLEAR");      nsString  value;      if (eContentAttr_HasValue == aContent->GetAttribute(align, value)) {        if (0 == value.Compare("left", PR_TRUE)) {          mMolecule.clear = NS_STYLE_CLEAR_LEFT;        } else if (0 == value.Compare("right", PR_TRUE)) {          mMolecule.clear = NS_STYLE_CLEAR_RIGHT;        } else if (0 == value.Compare("all", PR_TRUE)) {          mMolecule.clear = NS_STYLE_CLEAR_BOTH;        }      }    } else if (buf.EqualsIgnoreCase("SPACER")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("WBR")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("INPUT")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("I")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("S")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("PRE")) {      mMolecule.whiteSpace = NS_STYLE_WHITESPACE_PRE;      mMolecule.margin.top = NS_POINTS_TO_TWIPS_INT(3);      mMolecule.margin.bottom = NS_POINTS_TO_TWIPS_INT(3);//      mColor.mBackgroundImage = "resource:/res/gear1.gif";//      mColor.mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;    } else if (buf.EqualsIgnoreCase("U")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("FONT")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;    } else if (buf.EqualsIgnoreCase("THREED")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;      mFont.mThreeD = 1;    } else if (buf.EqualsIgnoreCase("TT")) {      mMolecule.display = NS_STYLE_DISPLAY_INLINE;//      mFont.mFont.name.SetLength(0);//      mFont.mFont.name.Append("Courier");//      mMolecule.positionFlags = NS_STYLE_POSITION_RELATIVE;//      mMolecule.left = -50;//      mMolecule.top = -50;    } else if (buf.EqualsIgnoreCase("IMG")) {      float p2t = aPresContext->GetPixelsToTwips();      mMolecule.display = NS_STYLE_DISPLAY_INLINE;      mMolecule.padding.top = nscoord(2 * p2t);      mMolecule.padding.right = nscoord(2 * p2t);      mMolecule.padding.bottom = nscoord(2 * p2t);      mMolecule.padding.left = nscoord(2 * p2t);      nsString  align("ALIGN");      nsString  value;      if (eContentAttr_HasValue == aContent->GetAttribute(align, value)) {        if (0 == value.Compare("left", PR_TRUE)) {          mMolecule.floats = NS_STYLE_FLOAT_LEFT;        } else if (0 == value.Compare("right", PR_TRUE)) {          mMolecule.floats = NS_STYLE_FLOAT_RIGHT;        }      }    } else if (buf.EqualsIgnoreCase("P")) {      nsString align("align");      nsString value;      if (eContentAttr_NotThere != aContent->GetAttribute(align, value)) {        if (0 == value.Compare("center", PR_TRUE)) {          mMolecule.textAlign = NS_STYLE_TEXT_ALIGN_CENTER;        }        if (0 == value.Compare("right", PR_TRUE)) {          mMolecule.textAlign = NS_STYLE_TEXT_ALIGN_RIGHT;        }      }//      mMolecule.margin.top = NS_POINTS_TO_TWIPS_INT(2);//      mMolecule.margin.bottom = NS_POINTS_TO_TWIPS_INT(2);    } else if (buf.EqualsIgnoreCase("BODY")) {      float p2t = aPresContext->GetPixelsToTwips();//      mColor.mBackgroundColor = NS_RGB(255, 255, 255);//      mColor.mBackgroundFlags = 0;      //mColor.mBackgroundFlags = 0;      //mColor.mBackgroundImage = "resource:/res/rock_gra.gif";      //mColor.mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;      mMolecule.padding.top = nscoord(5 * p2t);      mMolecule.padding.right = nscoord(5 * p2t);      mMolecule.padding.bottom = nscoord(5 * p2t);      mMolecule.padding.left = nscoord(5 * p2t);      mMolecule.border.top = nscoord(1 * p2t);      mMolecule.border.right = nscoord(1 * p2t);      mMolecule.border.bottom = nscoord(1 * p2t);      mMolecule.border.left = nscoord(1 * p2t);      for (int i = 0; i < 4; i++) {        mMolecule.borderStyle[i] = NS_STYLE_BORDER_STYLE_SOLID;        mMolecule.borderColor[i] = NS_RGB(0, 255, 0);      }    } else if (buf.EqualsIgnoreCase("LI")) {      mMolecule.display = NS_STYLE_DISPLAY_LIST_ITEM;    } else if (buf.EqualsIgnoreCase("UL") || buf.EqualsIgnoreCase("OL")) {      float p2t = aPresContext->GetPixelsToTwips();      mMolecule.padding.left = nscoord(40 * p2t);      mMolecule.margin.top = NS_POINTS_TO_TWIPS_INT(5);      mMolecule.margin.bottom = NS_POINTS_TO_TWIPS_INT(5);    } else if (buf.EqualsIgnoreCase("TABLE")) {                     // TABLE      mMolecule.border.top = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.border.bottom = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.border.right = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.border.left = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.borderStyle[0] = mMolecule.borderStyle[1] =      mMolecule.borderStyle[2] = mMolecule.borderStyle[3] = NS_STYLE_BORDER_STYLE_SOLID;      mMolecule.fixedWidth = -1;      mMolecule.proportionalWidth = 100;      nsString  align("ALIGN");      nsString  value;      if (eContentAttr_HasValue == aContent->GetAttribute(align, value)) {        if (0 == value.Compare("left", PR_TRUE)) {          mMolecule.floats = NS_STYLE_FLOAT_LEFT;        } else if (0 == value.Compare("right", PR_TRUE)) {          mMolecule.floats = NS_STYLE_FLOAT_RIGHT;        }      }    } else if (buf.EqualsIgnoreCase("CAPTION")) {                   // CAPTION      mMolecule.verticalAlign = NS_STYLE_VERTICAL_ALIGN_TOP;    } else if (buf.EqualsIgnoreCase("TBODY")) {                     // TBODY      mMolecule.padding.top = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.bottom = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.right = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.left = NS_POINTS_TO_TWIPS_INT(1);    } else if (buf.EqualsIgnoreCase("TR")) {                        // TROW      mMolecule.padding.top = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.bottom = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.right = NS_POINTS_TO_TWIPS_INT(1);      mMolecule.padding.left = NS_POINTS_TO_TWIPS_INT(1);    } else if (buf.EqualsIgnoreCase("TD")) {                        // TD      float p2t = aPresContext->GetPixelsToTwips();                  // Set padding to twenty for testing purposes      int cellPadding = 1;      if (gsDebug==PR_TRUE)        cellPadding = 20;      mMolecule.verticalAlign = NS_STYLE_VERTICAL_ALIGN_MIDDLE;              mMolecule.padding.top = NS_POINTS_TO_TWIPS_INT(cellPadding);      mMolecule.padding.bottom = NS_POINTS_TO_TWIPS_INT(cellPadding);      mMolecule.padding.right = NS_POINTS_TO_TWIPS_INT(cellPadding);      mMolecule.padding.left = NS_POINTS_TO_TWIPS_INT(cellPadding);//      mColor.mBackgroundColor = NS_RGB(255, 255, 0);//      mColor.mBackgroundFlags = 0;      mMolecule.border.top = nscoord(1 * p2t);      mMolecule.border.right = nscoord(1 * p2t);      mMolecule.border.bottom = nscoord(1 * p2t);      mMolecule.border.left = nscoord(1 * p2t);      for (int i = 0; i < 4; i++) {        mMolecule.borderStyle[i] = NS_STYLE_BORDER_STYLE_SOLID;        mMolecule.borderColor[i] = NS_RGB(128, 128, 128);      }      mMolecule.fixedWidth = -1;      mMolecule.proportionalWidth = -1;      mMolecule.fixedHeight = -1;      mMolecule.proportionalHeight = -1;    } else if (buf.EqualsIgnoreCase("COL")) {      mMolecule.fixedWidth = -1;      mMolecule.proportionalWidth = -1;      mMolecule.fixedHeight = -1;      mMolecule.proportionalHeight = -1;    }  } else {    // It's text (!)    mMolecule.display = NS_STYLE_DISPLAY_INLINE;    mMolecule.cursor = NS_STYLE_CURSOR_IBEAM;    nsIContent* content;         aParentFrame->GetContent(content);    nsIAtom* parentTag = content->GetTag();    parentTag->ToString(buf);    NS_RELEASE(content);    NS_RELEASE(parentTag);    if (buf.EqualsIgnoreCase("B")) {//      mFont.mFont.size = NS_POINTS_TO_TWIPS_INT(18);//      mFont.mFont.weight = NS_FONT_WEIGHT_BOLD;    } else if (buf.EqualsIgnoreCase("A")) {//      mColor.mColor = NS_RGB(0,0,255);//      mFont.mFont.decorations = NS_FONT_DECORATION_UNDERLINE;      // This simulates a <PRE><A>text inheritance rule      // Check the parent of the A      nsIFrame* parentParentFrame;             aParentFrame->GetGeometricParent(parentParentFrame);      if (nsnull != parentParentFrame) {        nsIContent* parentParentContent;                 parentParentFrame->GetContent(parentParentContent);        nsIAtom* parentParentTag = parentParentContent->GetTag();        parentParentTag->ToString(buf);        NS_RELEASE(parentParentTag);        NS_RELEASE(parentParentContent);        if (buf.EqualsIgnoreCase("PRE")) {          mMolecule.whiteSpace = NS_STYLE_WHITESPACE_PRE;//          mFont.mFont.name.SetLength(0);//          mFont.mFont.name.Append("Courier");        }      }    } else if (buf.EqualsIgnoreCase("THREED")) {//      mFont.mFont.size = NS_POINTS_TO_TWIPS_INT(18);//      mFont.mFont.weight = NS_FONT_WEIGHT_BOLD;      mFont.mThreeD = 1;    } else if (buf.EqualsIgnoreCase("I")) {//      mFont.mFont.style = NS_FONT_STYLE_ITALIC;    } else if (buf.EqualsIgnoreCase("BLINK")) {//      mFont.mFont.decorations |= NS_STYLE_TEXT_DECORATION_BLINK;    } else if (buf.EqualsIgnoreCase("TT")) {//      mFont.mFont.name.SetLength(0);//      mFont.mFont.name.Append("Courier");    } else if (buf.EqualsIgnoreCase("S")) {//      mFont.mFont.decorations = NS_FONT_DECORATION_LINE_THROUGH;    } else if (buf.EqualsIgnoreCase("U")) {//      mFont.mFont.decorations = NS_FONT_DECORATION_UNDERLINE;    } else if (buf.EqualsIgnoreCase("PRE")) {      mMolecule.whiteSpace = NS_STYLE_WHITESPACE_PRE;//      mFont.mFont.name.SetLength(0);//      mFont.mFont.name.Append("Courier");    }  }#if 0  if ((NS_STYLE_DISPLAY_BLOCK == mMolecule.display) ||      (NS_STYLE_DISPLAY_LIST_ITEM == mMolecule.display)) {    // Always justify text (take that ie)    mMolecule.textAlign = NS_STYLE_TEXT_ALIGN_JUSTIFY;  }#endif  mMolecule.borderPadding.top =    mMolecule.border.top + mMolecule.padding.top;  mMolecule.borderPadding.right =    mMolecule.border.right + mMolecule.padding.right;  mMolecule.borderPadding.bottom =    mMolecule.border.bottom + mMolecule.padding.bottom;  mMolecule.borderPadding.left =    mMolecule.border.left + mMolecule.padding.left;}