コード例 #1
0
NS_IMETHODIMP
nsHTMLEditor::ShowInlineTableEditingUI(nsIDOMElement * aCell)
{
    NS_ENSURE_ARG_POINTER(aCell);

    // do nothing if aCell is not a table cell...
    if (!nsHTMLEditUtils::IsTableCell(aCell))
        return NS_OK;

    if (mInlineEditedCell) {
        NS_ERROR("call HideInlineTableEditingUI first");
        return NS_ERROR_UNEXPECTED;
    }

    // the resizers and the shadow will be anonymous children of the body
    nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
    NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);

    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableAddColumnBefore"),
                           false, getter_AddRefs(mAddColumnBeforeButton));
    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableRemoveColumn"),
                           false, getter_AddRefs(mRemoveColumnButton));
    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableAddColumnAfter"),
                           false, getter_AddRefs(mAddColumnAfterButton));

    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableAddRowBefore"),
                           false, getter_AddRefs(mAddRowBeforeButton));
    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableRemoveRow"),
                           false, getter_AddRefs(mRemoveRowButton));
    CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
                           NS_LITERAL_STRING("mozTableAddRowAfter"),
                           false, getter_AddRefs(mAddRowAfterButton));

    AddMouseClickListener(mAddColumnBeforeButton);
    AddMouseClickListener(mRemoveColumnButton);
    AddMouseClickListener(mAddColumnAfterButton);
    AddMouseClickListener(mAddRowBeforeButton);
    AddMouseClickListener(mRemoveRowButton);
    AddMouseClickListener(mAddRowAfterButton);

    mInlineEditedCell = aCell;
    return RefreshInlineTableEditingUI();
}
コード例 #2
0
nsresult
nsHTMLEditor::CreateShadow(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode,
                           nsIDOMElement * aOriginalObject)
{
  // let's create an image through the element factory
  nsAutoString name;
  if (nsHTMLEditUtils::IsImage(aOriginalObject))
    name.AssignLiteral("img");
  else
    name.AssignLiteral("span");
  nsresult res = CreateAnonymousElement(name,
                                        aParentNode,
                                        NS_LITERAL_STRING("mozResizingShadow"),
                                        PR_TRUE,
                                        aReturn);

  if (!*aReturn)
    return NS_ERROR_FAILURE;

  return res;
}