예제 #1
0
nsresult
nsStyledElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
{
  nsGenericElement::nsDOMSlots *slots = GetDOMSlots();
  NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);

  if (!slots->mStyle) {
    // Just in case...
    ReparseStyleAttribute(PR_TRUE);

    slots->mStyle = new nsDOMCSSAttributeDeclaration(this);
    NS_ENSURE_TRUE(slots->mStyle, NS_ERROR_OUT_OF_MEMORY);
    SetFlags(NODE_MAY_HAVE_STYLE);
  }

  // Why bother with QI?
  NS_ADDREF(*aStyle = slots->mStyle);
  return NS_OK;
}
예제 #2
0
/* readonly attribute nsIDOMCSSStyleDeclaration style; */
NS_IMETHODIMP
nsSVGStylableElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
{
  nsDOMSlots *slots = GetDOMSlots();

  if (!slots->mStyle) {
    nsICSSOMFactory* cssOMFactory = nsnull;
    // We could cache the factory here, but lets wait with that until
    // we share code with html here.
    nsresult rv = CallGetService(kCSSOMFactoryCID, &cssOMFactory);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = cssOMFactory->
      CreateDOMCSSAttributeDeclaration(this, getter_AddRefs(slots->mStyle));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  NS_ADDREF(*aStyle = slots->mStyle);

  return NS_OK;
}