NS_IMETHODIMP HTMLEditor::RefreshInlineTableEditingUI() { nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mInlineEditedCell); if (!htmlElement) { return NS_ERROR_NULL_POINTER; } int32_t xCell, yCell, wCell, hCell; GetElementOrigin(mInlineEditedCell, xCell, yCell); nsresult rv = htmlElement->GetOffsetWidth(&wCell); NS_ENSURE_SUCCESS(rv, rv); rv = htmlElement->GetOffsetHeight(&hCell); NS_ENSURE_SUCCESS(rv, rv); int32_t xHoriz = xCell + wCell/2; int32_t yVert = yCell + hCell/2; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); int32_t rowCount, colCount; rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton); #ifdef DISABLE_TABLE_DELETION if (colCount== 1) { mRemoveColumnButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, NS_LITERAL_STRING("hidden"), true); } else { if (mRemoveColumnButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) { mRemoveColumnButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class); } #endif SetAnonymousElementPosition(xHoriz-4, yCell-7, mRemoveColumnButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xHoriz+6, yCell-7, mAddColumnAfterButton); SetAnonymousElementPosition(xCell-7, yVert-10, mAddRowBeforeButton); #ifdef DISABLE_TABLE_DELETION if (rowCount== 1) { mRemoveRowButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, NS_LITERAL_STRING("hidden"), true); } else { if (mRemoveRowButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) { mRemoveRowButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true); } #endif SetAnonymousElementPosition(xCell-7, yVert-4, mRemoveRowButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xCell-7, yVert+6, mAddRowAfterButton); return NS_OK; }
nsresult HTMLEditor::SetShadowPosition(Element* aShadow, Element* aOriginalObject, int32_t aOriginalObjectX, int32_t aOriginalObjectY) { SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, aShadow); if (HTMLEditUtils::IsImage(aOriginalObject)) { nsAutoString imageSource; aOriginalObject->GetAttr(kNameSpaceID_None, nsGkAtoms::src, imageSource); nsresult rv = aShadow->SetAttr(kNameSpaceID_None, nsGkAtoms::src, imageSource, true); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; }
nsresult nsHTMLEditor::SetShadowPosition(nsIDOMElement * aShadow, nsIDOMElement * aOriginalObject, PRInt32 aOriginalObjectX, PRInt32 aOriginalObjectY) { SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, aShadow); if (nsHTMLEditUtils::IsImage(aOriginalObject)) { nsAutoString imageSource; nsresult res = aOriginalObject->GetAttribute(NS_LITERAL_STRING("src"), imageSource); if (NS_FAILED(res)) return res; res = aShadow->SetAttribute(NS_LITERAL_STRING("src"), imageSource); if (NS_FAILED(res)) return res; } return NS_OK; }
nsresult HTMLEditor::SetAllResizersPosition() { NS_ENSURE_TRUE(mTopLeftHandle, NS_ERROR_FAILURE); int32_t x = mResizedObjectX; int32_t y = mResizedObjectY; int32_t w = mResizedObjectWidth; int32_t h = mResizedObjectHeight; // now let's place all the resizers around the image // get the size of resizers nsAutoString value; float resizerWidth, resizerHeight; nsCOMPtr<nsIAtom> dummyUnit; mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::width, value); mCSSEditUtils->ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit)); mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::height, value); mCSSEditUtils->ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit)); int32_t rw = (int32_t)((resizerWidth + 1) / 2); int32_t rh = (int32_t)((resizerHeight+ 1) / 2); SetAnonymousElementPosition(x-rw, y-rh, mTopLeftHandle); SetAnonymousElementPosition(x+w/2-rw, y-rh, mTopHandle); SetAnonymousElementPosition(x+w-rw-1, y-rh, mTopRightHandle); SetAnonymousElementPosition(x-rw, y+h/2-rh, mLeftHandle); SetAnonymousElementPosition(x+w-rw-1, y+h/2-rh, mRightHandle); SetAnonymousElementPosition(x-rw, y+h-rh-1, mBottomLeftHandle); SetAnonymousElementPosition(x+w/2-rw, y+h-rh-1, mBottomHandle); SetAnonymousElementPosition(x+w-rw-1, y+h-rh-1, mBottomRightHandle); return NS_OK; }
nsresult nsHTMLEditor::SetAllResizersPosition() { if (!mTopLeftHandle) return NS_ERROR_FAILURE; PRInt32 x = mResizedObjectX; PRInt32 y = mResizedObjectY; PRInt32 w = mResizedObjectWidth; PRInt32 h = mResizedObjectHeight; // now let's place all the resizers around the image // get the size of resizers nsAutoString value; float resizerWidth, resizerHeight; nsCOMPtr<nsIAtom> dummyUnit; mHTMLCSSUtils->GetComputedProperty(mTopLeftHandle, nsEditProperty::cssWidth, value); mHTMLCSSUtils->ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit)); mHTMLCSSUtils->GetComputedProperty(mTopLeftHandle, nsEditProperty::cssHeight, value); mHTMLCSSUtils->ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit)); PRInt32 rw = (PRInt32)((resizerWidth + 1) / 2); PRInt32 rh = (PRInt32)((resizerHeight+ 1) / 2); SetAnonymousElementPosition(x-rw, y-rh, mTopLeftHandle); SetAnonymousElementPosition(x+w/2-rw, y-rh, mTopHandle); SetAnonymousElementPosition(x+w-rw-1, y-rh, mTopRightHandle); SetAnonymousElementPosition(x-rw, y+h/2-rh, mLeftHandle); SetAnonymousElementPosition(x+w-rw-1, y+h/2-rh, mRightHandle); SetAnonymousElementPosition(x-rw, y+h-rh-1, mBottomLeftHandle); SetAnonymousElementPosition(x+w/2-rw, y+h-rh-1, mBottomHandle); SetAnonymousElementPosition(x+w-rw-1, y+h-rh-1, mBottomRightHandle); return NS_OK; }
NS_IMETHODIMP nsHTMLEditor::RefreshInlineTableEditingUI() { nsCOMPtr<nsIDOMNSHTMLElement> nsElement = do_QueryInterface(mInlineEditedCell); if (!nsElement) {return NS_ERROR_NULL_POINTER; } PRInt32 xCell, yCell, wCell, hCell; GetElementOrigin(mInlineEditedCell, xCell, yCell); nsresult res = nsElement->GetOffsetWidth(&wCell); NS_ENSURE_SUCCESS(res, res); res = nsElement->GetOffsetHeight(&hCell); NS_ENSURE_SUCCESS(res, res); PRInt32 xHoriz = xCell + wCell/2; PRInt32 yVert = yCell + hCell/2; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); PRInt32 rowCount, colCount; res = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(res, res); SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton); #ifdef DISABLE_TABLE_DELETION NS_NAMED_LITERAL_STRING(classStr, "class"); if (colCount== 1) { mRemoveColumnButton->SetAttribute(classStr, NS_LITERAL_STRING("hidden")); } else { PRBool hasClass = PR_FALSE; res = mRemoveColumnButton->HasAttribute(classStr, &hasClass); if (NS_SUCCEEDED(res) && hasClass) mRemoveColumnButton->RemoveAttribute(classStr); #endif SetAnonymousElementPosition(xHoriz-4, yCell-7, mRemoveColumnButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xHoriz+6, yCell-7, mAddColumnAfterButton); SetAnonymousElementPosition(xCell-7, yVert-10, mAddRowBeforeButton); #ifdef DISABLE_TABLE_DELETION if (rowCount== 1) { mRemoveRowButton->SetAttribute(classStr, NS_LITERAL_STRING("hidden")); } else { PRBool hasClass = PR_FALSE; res = mRemoveRowButton->HasAttribute(classStr, &hasClass); if (NS_SUCCEEDED(res) && hasClass) mRemoveRowButton->RemoveAttribute(classStr); #endif SetAnonymousElementPosition(xCell-7, yVert-4, mRemoveRowButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xCell-7, yVert+6, mAddRowAfterButton); return NS_OK; }