Bug 431086 - nsHTMLObjectResizer refactor.

This commit is contained in:
Chris Pearce 2009-04-14 15:05:34 +12:00
Родитель d7f6d3ca7b
Коммит 862acdd94c
2 изменённых файлов: 23 добавлений и 10 удалений

Просмотреть файл

@ -785,6 +785,8 @@ protected:
nsIContent * aParentContent,
nsIPresShell* aShell);
nsresult ShowResizersInner(nsIDOMElement *aResizedElement);
// Returns the offset of an element's frame to its absolute containing block.
nsresult GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 & aY);
nsresult GetPositionAndDimensions(nsIDOMElement * aElement,

Просмотреть файл

@ -334,22 +334,30 @@ nsHTMLEditor::RefreshResizers()
NS_IMETHODIMP
nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
{
nsresult res = ShowResizersInner(aResizedElement);
if (NS_FAILED(res))
HideResizers();
return res;
}
nsresult
nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
{
NS_ENSURE_ARG_POINTER(aResizedElement);
nsresult res;
nsCOMPtr<nsIDOMNode> parentNode;
res = aResizedElement->GetParentNode(getter_AddRefs(parentNode));
NS_ENSURE_SUCCESS(res, res);
if (mResizedObject) {
NS_ERROR("call HideResizers first");
return NS_ERROR_UNEXPECTED;
}
mResizedObject = aResizedElement;
// The resizers and the shadow will be anonymous siblings of the element.
nsresult res;
nsCOMPtr<nsIDOMNode> parentNode;
res = aResizedElement->GetParentNode(getter_AddRefs(parentNode));
NS_ENSURE_SUCCESS(res, res);
res = CreateResizer(getter_AddRefs(mTopLeftHandle),
nsIHTMLObjectResizer::eTopLeft, parentNode);
if (NS_FAILED(res)) return res;
@ -405,7 +413,6 @@ nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
res = CreateResizingInfo(getter_AddRefs(mResizingInfo), parentNode);
if (NS_FAILED(res)) return res;
// and listen to the "resize" event on the window first, get the
// window from the document...
nsCOMPtr<nsIDOMDocument> domDoc;
@ -436,9 +443,13 @@ nsHTMLEditor::HideResizers(void)
nsresult res;
nsCOMPtr<nsIDOMNode> parentNode;
res = mTopLeftHandle->GetParentNode(getter_AddRefs(parentNode));
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parentNode);
nsCOMPtr<nsIContent> parentContent;
if (mTopLeftHandle) {
res = mTopLeftHandle->GetParentNode(getter_AddRefs(parentNode));
NS_ENSURE_SUCCESS(res, res);
parentContent = do_QueryInterface(parentNode);
}
NS_NAMED_LITERAL_STRING(mousedown, "mousedown");