Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsHTMLFontElement.cpp File Reference
#include "nsCOMPtr.h"
#include "nsIDOMHTMLFontElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsIDeviceContext.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsMappedAttributes.h"
#include "nsCSSStruct.h"
#include "nsRuleData.h"
#include "nsIDocument.h"

Go to the source code of this file.

Classes

class  nsHTMLFontElement

Functions

static void MapAttributesIntoRule (const nsMappedAttributes *aAttributes, nsRuleData *aData)

Variables

static
NS_HTML_CONTENT_INTERFACE_MAP_END
const nsAttrValue::EnumTable 
kRelFontSizeTable []

Function Documentation

static void MapAttributesIntoRule ( const nsMappedAttributes aAttributes,
nsRuleData aData 
) [static]

Definition at line 165 of file nsHTMLFontElement.cpp.

{
  if (aData->mSID == eStyleStruct_Font) {
    nsRuleDataFont& font = *(aData->mFontData);
    
    // face: string list
    if (font.mFamily.GetUnit() == eCSSUnit_Null) {
      const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::face);
      if (value && value->Type() == nsAttrValue::eString &&
          !value->IsEmptyString()) {
        font.mFamily.SetStringValue(value->GetStringValue(), eCSSUnit_String);
        font.mFamilyFromHTML = PR_TRUE;
      }
    }

    // pointSize: int
    if (font.mSize.GetUnit() == eCSSUnit_Null) {
      const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::pointSize);
      if (value && value->Type() == nsAttrValue::eInteger)
        font.mSize.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
      else {
        // size: int, enum , 
        value = aAttributes->GetAttr(nsHTMLAtoms::size);
        if (value) {
          nsAttrValue::ValueType unit = value->Type();
          if (unit == nsAttrValue::eInteger || unit == nsAttrValue::eEnum) { 
            PRInt32 size;
            if (unit == nsAttrValue::eEnum) // int (+/-)
              size = value->GetEnumValue() + 3;  // XXX should be BASEFONT, not three see bug 3875
            else
              size = value->GetIntegerValue();

            size = ((0 < size) ? ((size < 8) ? size : 7) : 1); 
            font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
          }
        }
      }
    }

    // fontWeight: int
    if (font.mWeight.GetUnit() == eCSSUnit_Null) {
      const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::fontWeight);
      if (value && value->Type() == nsAttrValue::eInteger) // +/-
        font.mWeight.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
    }
  }
  else if (aData->mSID == eStyleStruct_Color) {
    if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
      // color: color
      const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::color);
      nscolor color;
      if (value && value->GetColorValue(color)) {
        aData->mColorData->mColor.SetColorValue(color);
      }
    }
  }
  else if (aData->mSID == eStyleStruct_TextReset) {
    // Make <a><font color="red">text</font></a> give the text a red underline
    // in quirks mode.  The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
    // affects quirks mode rendering.
    const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::color);
    nscolor color;
    if (value && value->GetColorValue(color)) {
      nsCSSValue& decoration = aData->mTextData->mDecoration;
      PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
      if (decoration.GetUnit() == eCSSUnit_Enumerated) {
        newValue |= decoration.GetIntValue();
      }
      decoration.SetIntValue(newValue, eCSSUnit_Enumerated);
    }
  }

  nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
  { "-10", -10 },
  { "-9", -9 },
  { "-8", -8 },
  { "-7", -7 },
  { "-6", -6 },
  { "-5", -5 },
  { "-4", -4 },
  { "-3", -3 },
  { "-2", -2 },
  { "-1", -1 },
  { "-0", 0 },
  { "+0", 0 },
  { "+1", 1 },
  { "+2", 2 },
  { "+3", 3 },
  { "+4", 4 },
  { "+5", 5 },
  { "+6", 6 },
  { "+7", 7 },
  { "+8", 8 },
  { "+9", 9 },
  { "+10", 10 },
  { 0 }
}

Definition at line 110 of file nsHTMLFontElement.cpp.