Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLAnonymousUtils.cpp File Reference
#include "nsHTMLEditor.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIEditor.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsISelection.h"
#include "nsTextEditUtils.h"
#include "nsEditorUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsTextEditRules.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsUnicharUtils.h"

Go to the source code of this file.


static PRInt32 GetCSSFloatValue (nsIDOMCSSStyleDeclaration *aDecl, const nsAString &aProperty)

Function Documentation

static PRInt32 GetCSSFloatValue ( nsIDOMCSSStyleDeclaration aDecl,
const nsAString &  aProperty 
) [static]

Definition at line 64 of file nsHTMLAnonymousUtils.cpp.


  nsCOMPtr<nsIDOMCSSValue> value;
  // get the computed CSSValue of the property
  nsresult res = aDecl->GetPropertyCSSValue(aProperty, getter_AddRefs(value));
  if (NS_FAILED(res) || !value) return 0;

  // check the type of the returned CSSValue; we handle here only
  // pixel and enum types
  nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(value);
  PRUint16 type;

  float f;
  switch (type) {
    case nsIDOMCSSPrimitiveValue::CSS_PX:
      // the value is in pixels, just get it
      res = val->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_PX, &f);
      if (NS_FAILED(res)) return 0;
    case nsIDOMCSSPrimitiveValue::CSS_IDENT: {
      // the value is keyword, we have to map these keywords into
      // numeric values
      nsAutoString str;
      res = val->GetStringValue(str);
      if (str.EqualsLiteral("thin"))
        f = 1;
      if (str.EqualsLiteral("medium"))
        f = 3;
      if (str.EqualsLiteral("thick"))
        f = 5;
      f = 0;

  return (PRInt32) f;

Here is the call graph for this function:

Here is the caller graph for this function: