2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-02-15 19:55:36 -08:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/mozalloc.h"
|
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsAlgorithm.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsEditProperty.h"
|
|
|
|
#include "nsEditorUtils.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsHTMLCSSUtils.h"
|
|
|
|
#include "nsHTMLEditUtils.h"
|
|
|
|
#include "nsHTMLEditor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLObjectResizer.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMEvent.h"
|
2011-06-23 19:18:00 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMText.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIEditor.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsIHTMLObjectResizeListener.h"
|
|
|
|
#include "nsIHTMLObjectResizer.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPresShell.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsISupportsUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsStringFwd.h"
|
|
|
|
#include "nsSubstringTuple.h"
|
|
|
|
#include "nscore.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2012-07-12 23:33:42 -07:00
|
|
|
|
|
|
|
class nsISelection;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-16 17:59:29 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsHTMLEditUtils;
|
|
|
|
|
|
|
|
// ==================================================================
|
|
|
|
// DocumentResizeEventListener
|
|
|
|
// ==================================================================
|
|
|
|
NS_IMPL_ISUPPORTS1(DocumentResizeEventListener, nsIDOMEventListener)
|
|
|
|
|
|
|
|
DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor * aEditor)
|
|
|
|
{
|
|
|
|
mEditor = do_GetWeakReference(aEditor);
|
|
|
|
}
|
|
|
|
|
|
|
|
DocumentResizeEventListener::~DocumentResizeEventListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DocumentResizeEventListener::HandleEvent(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryReferent(mEditor);
|
|
|
|
if (objectResizer)
|
|
|
|
return objectResizer->RefreshResizers();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================================================================
|
|
|
|
// ResizerSelectionListener
|
|
|
|
// ==================================================================
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(ResizerSelectionListener, nsISelectionListener)
|
|
|
|
|
|
|
|
ResizerSelectionListener::ResizerSelectionListener(nsIHTMLEditor * aEditor)
|
|
|
|
{
|
|
|
|
mEditor = do_GetWeakReference(aEditor);
|
|
|
|
}
|
|
|
|
|
|
|
|
ResizerSelectionListener::~ResizerSelectionListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
ResizerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *aSelection, int16_t aReason)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if ((aReason & (nsISelectionListener::MOUSEDOWN_REASON |
|
|
|
|
nsISelectionListener::KEYPRESS_REASON |
|
|
|
|
nsISelectionListener::SELECTALL_REASON)) && aSelection)
|
|
|
|
{
|
|
|
|
// the selection changed and we need to check if we have to
|
|
|
|
// hide and/or redisplay resizing handles
|
|
|
|
nsCOMPtr<nsIHTMLEditor> editor = do_QueryReferent(mEditor);
|
|
|
|
if (editor)
|
|
|
|
editor->CheckSelectionStateForAnonymousButtons(aSelection);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================================================================
|
|
|
|
// ResizerMouseMotionListener
|
|
|
|
// ==================================================================
|
|
|
|
|
2011-06-27 16:34:54 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(ResizerMouseMotionListener, nsIDOMEventListener)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor * aEditor)
|
|
|
|
{
|
|
|
|
mEditor = do_GetWeakReference(aEditor);
|
|
|
|
}
|
|
|
|
|
|
|
|
ResizerMouseMotionListener::~ResizerMouseMotionListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-06-27 16:34:54 -07:00
|
|
|
ResizerMouseMotionListener::HandleEvent(nsIDOMEvent* aMouseEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
|
|
|
|
if (!mouseEvent) {
|
|
|
|
//non-ui event passed in. bad things.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't do anything special if not an HTML object resizer editor
|
|
|
|
nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryReferent(mEditor);
|
|
|
|
if (objectResizer)
|
|
|
|
{
|
|
|
|
// check if we have to redisplay a resizing shadow
|
|
|
|
objectResizer->MouseMove(aMouseEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================================================================
|
|
|
|
// nsHTMLEditor
|
|
|
|
// ==================================================================
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::CreateResizer(nsIDOMElement ** aReturn, int16_t aLocation, nsIDOMNode * aParentNode)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
|
|
|
|
aParentNode,
|
|
|
|
NS_LITERAL_STRING("mozResizer"),
|
2011-10-17 07:59:28 -07:00
|
|
|
false,
|
2007-03-22 10:30:00 -07:00
|
|
|
aReturn);
|
|
|
|
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(*aReturn, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// add the mouse listener so we can detect a click on a resizer
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(*aReturn));
|
2010-03-05 20:01:28 -08:00
|
|
|
evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mEventListener,
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsAutoString locationStr;
|
|
|
|
switch (aLocation) {
|
|
|
|
case nsIHTMLObjectResizer::eTopLeft:
|
|
|
|
locationStr = kTopLeft;
|
|
|
|
break;
|
|
|
|
case nsIHTMLObjectResizer::eTop:
|
|
|
|
locationStr = kTop;
|
|
|
|
break;
|
|
|
|
case nsIHTMLObjectResizer::eTopRight:
|
|
|
|
locationStr = kTopRight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIHTMLObjectResizer::eLeft:
|
|
|
|
locationStr = kLeft;
|
|
|
|
break;
|
|
|
|
case nsIHTMLObjectResizer::eRight:
|
|
|
|
locationStr = kRight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIHTMLObjectResizer::eBottomLeft:
|
|
|
|
locationStr = kBottomLeft;
|
|
|
|
break;
|
|
|
|
case nsIHTMLObjectResizer::eBottom:
|
|
|
|
locationStr = kBottom;
|
|
|
|
break;
|
|
|
|
case nsIHTMLObjectResizer::eBottomRight:
|
|
|
|
locationStr = kBottomRight;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = (*aReturn)->SetAttribute(NS_LITERAL_STRING("anonlocation"),
|
|
|
|
locationStr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
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"),
|
2011-10-17 07:59:28 -07:00
|
|
|
true,
|
2007-03-22 10:30:00 -07:00
|
|
|
aReturn);
|
|
|
|
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(*aReturn, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLEditor::CreateResizingInfo(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode)
|
|
|
|
{
|
|
|
|
// let's create an info box through the element factory
|
|
|
|
nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
|
|
|
|
aParentNode,
|
|
|
|
NS_LITERAL_STRING("mozResizingInfo"),
|
2011-10-17 07:59:28 -07:00
|
|
|
true,
|
2007-03-22 10:30:00 -07:00
|
|
|
aReturn);
|
|
|
|
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(*aReturn, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLEditor::SetAllResizersPosition()
|
|
|
|
{
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(mTopLeftHandle, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t x = mResizedObjectX;
|
|
|
|
int32_t y = mResizedObjectY;
|
|
|
|
int32_t w = mResizedObjectWidth;
|
|
|
|
int32_t h = mResizedObjectHeight;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 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));
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rw = (int32_t)((resizerWidth + 1) / 2);
|
|
|
|
int32_t rh = (int32_t)((resizerHeight+ 1) / 2);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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::RefreshResizers()
|
|
|
|
{
|
|
|
|
// nothing to do if resizers are not displayed...
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(mResizedObject, NS_OK);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult res = GetPositionAndDimensions(mResizedObject,
|
|
|
|
mResizedObjectX,
|
|
|
|
mResizedObjectY,
|
|
|
|
mResizedObjectWidth,
|
|
|
|
mResizedObjectHeight,
|
|
|
|
mResizedObjectBorderLeft,
|
|
|
|
mResizedObjectBorderTop,
|
|
|
|
mResizedObjectMarginLeft,
|
|
|
|
mResizedObjectMarginTop);
|
|
|
|
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = SetAllResizersPosition();
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
return SetShadowPosition(mResizingShadow, mResizedObject,
|
|
|
|
mResizedObjectX, mResizedObjectY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
|
2009-04-13 20:05:34 -07:00
|
|
|
{
|
|
|
|
nsresult res = ShowResizersInner(aResizedElement);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
HideResizers();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResizedElement);
|
2009-04-13 20:05:34 -07:00
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> parentNode;
|
|
|
|
res = aResizedElement->GetParentNode(getter_AddRefs(parentNode));
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2008-04-13 13:22:31 -07:00
|
|
|
|
|
|
|
if (mResizedObject) {
|
|
|
|
NS_ERROR("call HideResizers first");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
mResizedObject = aResizedElement;
|
|
|
|
|
2008-01-21 23:39:06 -08:00
|
|
|
// The resizers and the shadow will be anonymous siblings of the element.
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mTopLeftHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eTopLeft, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mTopHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eTop, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mTopRightHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eTopRight, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
res = CreateResizer(getter_AddRefs(mLeftHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eLeft, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mRightHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eRight, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
res = CreateResizer(getter_AddRefs(mBottomLeftHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eBottomLeft, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mBottomHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eBottom, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = CreateResizer(getter_AddRefs(mBottomRightHandle),
|
2008-01-21 23:39:06 -08:00
|
|
|
nsIHTMLObjectResizer::eBottomRight, parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
res = GetPositionAndDimensions(aResizedElement,
|
|
|
|
mResizedObjectX,
|
|
|
|
mResizedObjectY,
|
|
|
|
mResizedObjectWidth,
|
|
|
|
mResizedObjectHeight,
|
|
|
|
mResizedObjectBorderLeft,
|
|
|
|
mResizedObjectBorderTop,
|
|
|
|
mResizedObjectMarginLeft,
|
|
|
|
mResizedObjectMarginTop);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// and let's set their absolute positions in the document
|
|
|
|
res = SetAllResizersPosition();
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// now, let's create the resizing shadow
|
2008-01-21 23:39:06 -08:00
|
|
|
res = CreateShadow(getter_AddRefs(mResizingShadow), parentNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
aResizedElement);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
// and set its position
|
|
|
|
res = SetShadowPosition(mResizingShadow, mResizedObject,
|
|
|
|
mResizedObjectX, mResizedObjectY);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// and then the resizing info tooltip
|
2008-01-21 23:39:06 -08:00
|
|
|
res = CreateResizingInfo(getter_AddRefs(mResizingInfo), parentNode);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// and listen to the "resize" event on the window first, get the
|
|
|
|
// window from the document...
|
2012-03-24 01:19:14 -07:00
|
|
|
nsCOMPtr<nsIDocument> doc = GetDocument();
|
2010-06-17 12:41:16 -07:00
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(doc->GetWindow());
|
|
|
|
if (!target) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
|
|
|
mResizeEventListenerP = new DocumentResizeEventListener(this);
|
|
|
|
if (!mResizeEventListenerP) { return NS_ERROR_OUT_OF_MEMORY; }
|
2011-10-17 07:59:28 -07:00
|
|
|
res = target->AddEventListener(NS_LITERAL_STRING("resize"), mResizeEventListenerP, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
aResizedElement->SetAttribute(NS_LITERAL_STRING("_moz_resizing"), NS_LITERAL_STRING("true"));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::HideResizers(void)
|
|
|
|
{
|
2010-06-17 13:40:48 -07:00
|
|
|
NS_ENSURE_TRUE(mResizedObject, NS_OK);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// get the presshell's document observer interface.
|
2011-05-22 05:43:13 -07:00
|
|
|
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
2010-05-05 18:20:43 -07:00
|
|
|
// We allow the pres shell to be null; when it is, we presume there
|
|
|
|
// are no document observers to notify, but we still want to
|
|
|
|
// UnbindFromTree.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-21 23:39:06 -08:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIDOMNode> parentNode;
|
2009-04-13 20:05:34 -07:00
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
|
|
|
|
|
|
|
if (mTopLeftHandle) {
|
|
|
|
res = mTopLeftHandle->GetParentNode(getter_AddRefs(parentNode));
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
parentContent = do_QueryInterface(parentNode);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(mousedown, "mousedown");
|
2008-01-21 23:39:06 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mTopLeftHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mTopLeftHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mTopHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mTopHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mTopRightHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mTopRightHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mLeftHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mLeftHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mRightHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mRightHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mBottomLeftHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mBottomLeftHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mBottomHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mBottomHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mBottomRightHandle, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mBottomRightHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mResizingShadow, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mResizingShadow = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
RemoveListenerAndDeleteRef(mousedown, mEventListener, true,
|
2008-01-21 23:39:06 -08:00
|
|
|
mResizingInfo, parentContent, ps);
|
2012-07-30 07:20:58 -07:00
|
|
|
mResizingInfo = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-13 13:22:31 -07:00
|
|
|
if (mActivatedHandle) {
|
|
|
|
mActivatedHandle->RemoveAttribute(NS_LITERAL_STRING("_moz_activated"));
|
2012-07-30 07:20:58 -07:00
|
|
|
mActivatedHandle = nullptr;
|
2008-04-13 13:22:31 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// don't forget to remove the listeners !
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> target = GetDOMEventTarget();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-14 02:11:38 -07:00
|
|
|
if (target && mMouseMotionListenerP)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-05-14 02:11:38 -07:00
|
|
|
res = target->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
|
2011-10-17 07:59:28 -07:00
|
|
|
mMouseMotionListenerP, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(res), "failed to remove mouse motion listener");
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mMouseMotionListenerP = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-24 01:19:14 -07:00
|
|
|
nsCOMPtr<nsIDocument> doc = GetDocument();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!doc) { return NS_ERROR_NULL_POINTER; }
|
2007-05-14 02:11:38 -07:00
|
|
|
target = do_QueryInterface(doc->GetWindow());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!target) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
|
|
|
if (mResizeEventListenerP) {
|
2011-10-17 07:59:28 -07:00
|
|
|
res = target->RemoveEventListener(NS_LITERAL_STRING("resize"), mResizeEventListenerP, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(res), "failed to remove resize event listener");
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mResizeEventListenerP = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mResizedObject->RemoveAttribute(NS_LITERAL_STRING("_moz_resizing"));
|
2012-07-30 07:20:58 -07:00
|
|
|
mResizedObject = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLEditor::HideShadowAndInfo()
|
|
|
|
{
|
|
|
|
if (mResizingShadow)
|
|
|
|
mResizingShadow->SetAttribute(NS_LITERAL_STRING("class"), NS_LITERAL_STRING("hidden"));
|
|
|
|
if (mResizingInfo)
|
|
|
|
mResizingInfo->SetAttribute(NS_LITERAL_STRING("class"), NS_LITERAL_STRING("hidden"));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
|
|
|
{
|
|
|
|
// First notify the listeners if any
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t listenersCount = objectResizeEventListeners.Count();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (listenersCount) {
|
|
|
|
nsCOMPtr<nsIHTMLObjectResizeListener> listener;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t index;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (index = 0; index < listenersCount; index++) {
|
|
|
|
listener = objectResizeEventListeners[index];
|
|
|
|
listener->OnStartResizing(mResizedObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsResizing = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
mActivatedHandle = aHandle;
|
|
|
|
mActivatedHandle->SetAttribute(NS_LITERAL_STRING("_moz_activated"), NS_LITERAL_STRING("true"));
|
|
|
|
|
|
|
|
// do we want to preserve ratio or not?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool preserveRatio = nsHTMLEditUtils::IsImage(mResizedObject) &&
|
|
|
|
Preferences::GetBool("editor.resizing.preserve_ratio", true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// the way we change the position/size of the shadow depends on
|
|
|
|
// the handle
|
|
|
|
nsAutoString locationStr;
|
|
|
|
aHandle->GetAttribute(NS_LITERAL_STRING("anonlocation"), locationStr);
|
|
|
|
if (locationStr.Equals(kTopLeft)) {
|
|
|
|
SetResizeIncrements(1, 1, -1, -1, preserveRatio);
|
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kTop)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetResizeIncrements(0, 1, 0, -1, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kTopRight)) {
|
|
|
|
SetResizeIncrements(0, 1, 1, -1, preserveRatio);
|
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kLeft)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetResizeIncrements(1, 0, -1, 0, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kRight)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetResizeIncrements(0, 0, 1, 0, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kBottomLeft)) {
|
|
|
|
SetResizeIncrements(1, 0, -1, 1, preserveRatio);
|
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kBottom)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetResizeIncrements(0, 0, 0, 1, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (locationStr.Equals(kBottomRight)) {
|
|
|
|
SetResizeIncrements(0, 0, 1, 1, preserveRatio);
|
|
|
|
}
|
|
|
|
|
|
|
|
// make the shadow appear
|
|
|
|
mResizingShadow->RemoveAttribute(NS_LITERAL_STRING("class"));
|
|
|
|
|
|
|
|
// position it
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
NS_LITERAL_STRING("width"),
|
|
|
|
mResizedObjectWidth);
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
NS_LITERAL_STRING("height"),
|
|
|
|
mResizedObjectHeight);
|
|
|
|
|
|
|
|
// add a mouse move listener to the editor
|
2011-06-16 17:59:29 -07:00
|
|
|
nsresult result = NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!mMouseMotionListenerP) {
|
|
|
|
mMouseMotionListenerP = new ResizerMouseMotionListener(this);
|
|
|
|
if (!mMouseMotionListenerP) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> target = GetDOMEventTarget();
|
2007-05-14 02:11:38 -07:00
|
|
|
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-14 02:11:38 -07:00
|
|
|
result = target->AddEventListener(NS_LITERAL_STRING("mousemove"),
|
2011-10-17 07:59:28 -07:00
|
|
|
mMouseMotionListenerP, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),
|
|
|
|
"failed to register mouse motion listener");
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::MouseDown(int32_t aClientX, int32_t aClientY,
|
2008-04-23 04:53:29 -07:00
|
|
|
nsIDOMElement *aTarget, nsIDOMEvent* aEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool anonElement = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aTarget && NS_SUCCEEDED(aTarget->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)))
|
|
|
|
// we caught a click on an anonymous element
|
|
|
|
if (anonElement) {
|
|
|
|
nsAutoString anonclass;
|
|
|
|
nsresult res = aTarget->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (anonclass.EqualsLiteral("mozResizer")) {
|
|
|
|
// and that element is a resizer, let's start resizing!
|
2008-04-23 04:53:29 -07:00
|
|
|
aEvent->PreventDefault();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mOriginalX = aClientX;
|
|
|
|
mOriginalY = aClientY;
|
|
|
|
return StartResizing(aTarget);
|
|
|
|
}
|
|
|
|
if (anonclass.EqualsLiteral("mozGrabber")) {
|
|
|
|
// and that element is a grabber, let's start moving the element!
|
|
|
|
mOriginalX = aClientX;
|
|
|
|
mOriginalY = aClientY;
|
|
|
|
return GrabberClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::MouseUp(int32_t aClientX, int32_t aClientY,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMElement *aTarget)
|
|
|
|
{
|
|
|
|
if (mIsResizing) {
|
|
|
|
// we are resizing and release the mouse button, so let's
|
|
|
|
// end the resizing process
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsResizing = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
HideShadowAndInfo();
|
|
|
|
SetFinalSize(aClientX, aClientY);
|
|
|
|
}
|
|
|
|
else if (mIsMoving || mGrabberClicked) {
|
|
|
|
if (mIsMoving) {
|
|
|
|
mPositioningShadow->SetAttribute(NS_LITERAL_STRING("class"), NS_LITERAL_STRING("hidden"));
|
|
|
|
SetFinalPosition(aClientX, aClientY);
|
|
|
|
}
|
|
|
|
if (mGrabberClicked) {
|
|
|
|
EndMoving();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::SetResizeIncrements(int32_t aX, int32_t aY,
|
|
|
|
int32_t aW, int32_t aH,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPreserveRatio)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mXIncrementFactor = aX;
|
|
|
|
mYIncrementFactor = aY;
|
|
|
|
mWidthIncrementFactor = aW;
|
|
|
|
mHeightIncrementFactor = aH;
|
|
|
|
mPreserveRatio = aPreserveRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::SetResizingInfoPosition(int32_t aX, int32_t aY, int32_t aW, int32_t aH)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-24 01:19:14 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(leftStr, "left");
|
|
|
|
NS_NAMED_LITERAL_STRING(topStr, "top");
|
2008-01-21 23:39:06 -08:00
|
|
|
|
|
|
|
// Determine the position of the resizing info box based upon the new
|
|
|
|
// position and size of the element (aX, aY, aW, aH), and which
|
|
|
|
// resizer is the "activated handle". For example, place the resizing
|
|
|
|
// info box at the bottom-right corner of the new element, if the element
|
|
|
|
// is being resized by the bottom-right resizer.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t infoXPosition;
|
|
|
|
int32_t infoYPosition;
|
2008-01-21 23:39:06 -08:00
|
|
|
|
|
|
|
if (mActivatedHandle == mTopLeftHandle ||
|
|
|
|
mActivatedHandle == mLeftHandle ||
|
|
|
|
mActivatedHandle == mBottomLeftHandle)
|
|
|
|
infoXPosition = aX;
|
|
|
|
else if (mActivatedHandle == mTopHandle ||
|
|
|
|
mActivatedHandle == mBottomHandle)
|
|
|
|
infoXPosition = aX + (aW / 2);
|
|
|
|
else
|
|
|
|
// should only occur when mActivatedHandle is one of the 3 right-side
|
|
|
|
// handles, but this is a reasonable default if it isn't any of them (?)
|
|
|
|
infoXPosition = aX + aW;
|
|
|
|
|
|
|
|
if (mActivatedHandle == mTopLeftHandle ||
|
|
|
|
mActivatedHandle == mTopHandle ||
|
|
|
|
mActivatedHandle == mTopRightHandle)
|
|
|
|
infoYPosition = aY;
|
|
|
|
else if (mActivatedHandle == mLeftHandle ||
|
|
|
|
mActivatedHandle == mRightHandle)
|
|
|
|
infoYPosition = aY + (aH / 2);
|
|
|
|
else
|
|
|
|
// should only occur when mActivatedHandle is one of the 3 bottom-side
|
|
|
|
// handles, but this is a reasonable default if it isn't any of them (?)
|
|
|
|
infoYPosition = aY + aH;
|
|
|
|
|
|
|
|
// Offset info box by 20 so it's not directly under the mouse cursor.
|
|
|
|
const int mouseCursorOffset = 20;
|
2007-08-25 22:53:38 -07:00
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, leftStr,
|
2008-01-21 23:39:06 -08:00
|
|
|
infoXPosition + mouseCursorOffset);
|
2007-08-25 22:53:38 -07:00
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, topStr,
|
2008-01-21 23:39:06 -08:00
|
|
|
infoYPosition + mouseCursorOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> textInfo;
|
|
|
|
nsresult res = mResizingInfo->GetFirstChild(getter_AddRefs(textInfo));
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> junk;
|
|
|
|
if (textInfo) {
|
|
|
|
res = mResizingInfo->RemoveChild(textInfo, getter_AddRefs(junk));
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2012-07-30 07:20:58 -07:00
|
|
|
textInfo = nullptr;
|
|
|
|
junk = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString widthStr, heightStr, diffWidthStr, diffHeightStr;
|
|
|
|
widthStr.AppendInt(aW);
|
|
|
|
heightStr.AppendInt(aH);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t diffWidth = aW - mResizedObjectWidth;
|
|
|
|
int32_t diffHeight = aH - mResizedObjectHeight;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (diffWidth > 0)
|
|
|
|
diffWidthStr.AssignLiteral("+");
|
|
|
|
if (diffHeight > 0)
|
|
|
|
diffHeightStr.AssignLiteral("+");
|
|
|
|
diffWidthStr.AppendInt(diffWidth);
|
|
|
|
diffHeightStr.AppendInt(diffHeight);
|
|
|
|
|
|
|
|
nsAutoString info(widthStr + NS_LITERAL_STRING(" x ") + heightStr +
|
|
|
|
NS_LITERAL_STRING(" (") + diffWidthStr +
|
|
|
|
NS_LITERAL_STRING(", ") + diffHeightStr +
|
|
|
|
NS_LITERAL_STRING(")"));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMText> nodeAsText;
|
|
|
|
res = domdoc->CreateTextNode(info, getter_AddRefs(nodeAsText));
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
textInfo = do_QueryInterface(nodeAsText);
|
|
|
|
res = mResizingInfo->AppendChild(textInfo, getter_AddRefs(junk));
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool hasClass = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(mResizingInfo->HasAttribute(NS_LITERAL_STRING("class"), &hasClass )) && hasClass)
|
|
|
|
res = mResizingInfo->RemoveAttribute(NS_LITERAL_STRING("class"));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLEditor::SetShadowPosition(nsIDOMElement * aShadow,
|
|
|
|
nsIDOMElement * aOriginalObject,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aOriginalObjectX,
|
|
|
|
int32_t aOriginalObjectY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, aShadow);
|
|
|
|
|
|
|
|
if (nsHTMLEditUtils::IsImage(aOriginalObject)) {
|
|
|
|
nsAutoString imageSource;
|
|
|
|
nsresult res = aOriginalObject->GetAttribute(NS_LITERAL_STRING("src"),
|
|
|
|
imageSource);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
res = aShadow->SetAttribute(NS_LITERAL_STRING("src"), imageSource);
|
2010-06-17 12:27:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
nsHTMLEditor::GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t result = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!mPreserveRatio) {
|
|
|
|
switch (aID) {
|
|
|
|
case kX:
|
|
|
|
case kWidth:
|
|
|
|
result = aX - mOriginalX;
|
|
|
|
break;
|
|
|
|
case kY:
|
|
|
|
case kHeight:
|
|
|
|
result = aY - mOriginalY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t xi = (aX - mOriginalX) * mWidthIncrementFactor;
|
|
|
|
int32_t yi = (aY - mOriginalY) * mHeightIncrementFactor;
|
2007-03-22 10:30:00 -07:00
|
|
|
float objectSizeRatio =
|
|
|
|
((float)mResizedObjectWidth) / ((float)mResizedObjectHeight);
|
|
|
|
result = (xi > yi) ? xi : yi;
|
|
|
|
switch (aID) {
|
|
|
|
case kX:
|
|
|
|
case kWidth:
|
|
|
|
if (result == yi)
|
2012-08-22 08:56:38 -07:00
|
|
|
result = (int32_t) (((float) result) * objectSizeRatio);
|
|
|
|
result = (int32_t) (((float) result) * mWidthIncrementFactor);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case kY:
|
|
|
|
case kHeight:
|
|
|
|
if (result == xi)
|
2012-08-22 08:56:38 -07:00
|
|
|
result = (int32_t) (((float) result) / objectSizeRatio);
|
|
|
|
result = (int32_t) (((float) result) * mHeightIncrementFactor);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
nsHTMLEditor::GetNewResizingX(int32_t aX, int32_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t resized = mResizedObjectX +
|
2007-03-22 10:30:00 -07:00
|
|
|
GetNewResizingIncrement(aX, aY, kX) * mXIncrementFactor;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t max = mResizedObjectX + mResizedObjectWidth;
|
2013-01-15 04:22:03 -08:00
|
|
|
return std::min(resized, max);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
nsHTMLEditor::GetNewResizingY(int32_t aX, int32_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t resized = mResizedObjectY +
|
2007-03-22 10:30:00 -07:00
|
|
|
GetNewResizingIncrement(aX, aY, kY) * mYIncrementFactor;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t max = mResizedObjectY + mResizedObjectHeight;
|
2013-01-15 04:22:03 -08:00
|
|
|
return std::min(resized, max);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
nsHTMLEditor::GetNewResizingWidth(int32_t aX, int32_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t resized = mResizedObjectWidth +
|
2007-03-22 10:30:00 -07:00
|
|
|
GetNewResizingIncrement(aX, aY, kWidth) *
|
|
|
|
mWidthIncrementFactor;
|
2013-01-15 04:22:03 -08:00
|
|
|
return std::max(resized, 1);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
nsHTMLEditor::GetNewResizingHeight(int32_t aX, int32_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t resized = mResizedObjectHeight +
|
2007-03-22 10:30:00 -07:00
|
|
|
GetNewResizingIncrement(aX, aY, kHeight) *
|
|
|
|
mHeightIncrementFactor;
|
2013-01-15 04:22:03 -08:00
|
|
|
return std::max(resized, 1);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
|
|
|
|
{
|
|
|
|
NS_NAMED_LITERAL_STRING(leftStr, "left");
|
|
|
|
NS_NAMED_LITERAL_STRING(topStr, "top");
|
|
|
|
|
|
|
|
if (mIsResizing) {
|
|
|
|
// we are resizing and the mouse pointer's position has changed
|
|
|
|
// we have to resdisplay the shadow
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t clientX, clientY;
|
2007-03-22 10:30:00 -07:00
|
|
|
mouseEvent->GetClientX(&clientX);
|
|
|
|
mouseEvent->GetClientY(&clientY);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t newX = GetNewResizingX(clientX, clientY);
|
|
|
|
int32_t newY = GetNewResizingY(clientX, clientY);
|
|
|
|
int32_t newWidth = GetNewResizingWidth(clientX, clientY);
|
|
|
|
int32_t newHeight = GetNewResizingHeight(clientX, clientY);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
leftStr,
|
2008-01-21 23:39:06 -08:00
|
|
|
newX);
|
2007-03-22 10:30:00 -07:00
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
topStr,
|
2008-01-21 23:39:06 -08:00
|
|
|
newY);
|
2007-03-22 10:30:00 -07:00
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
NS_LITERAL_STRING("width"),
|
|
|
|
newWidth);
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingShadow,
|
|
|
|
NS_LITERAL_STRING("height"),
|
|
|
|
newHeight);
|
|
|
|
|
2008-01-21 23:39:06 -08:00
|
|
|
return SetResizingInfoPosition(newX, newY, newWidth, newHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mGrabberClicked) {
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t clientX, clientY;
|
2007-03-22 10:30:00 -07:00
|
|
|
mouseEvent->GetClientX(&clientX);
|
|
|
|
mouseEvent->GetClientY(&clientY);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t xThreshold =
|
2011-09-08 19:27:12 -07:00
|
|
|
LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdX, 1);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t yThreshold =
|
2011-09-08 19:27:12 -07:00
|
|
|
LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdY, 1);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-05 15:43:30 -08:00
|
|
|
if (DeprecatedAbs(clientX - mOriginalX) * 2 >= xThreshold ||
|
|
|
|
DeprecatedAbs(clientY - mOriginalY) * 2 >= yThreshold) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mGrabberClicked = false;
|
2012-07-30 07:20:58 -07:00
|
|
|
StartMoving(nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mIsMoving) {
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t clientX, clientY;
|
2007-03-22 10:30:00 -07:00
|
|
|
mouseEvent->GetClientX(&clientX);
|
|
|
|
mouseEvent->GetClientY(&clientY);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t newX = mPositionedObjectX + clientX - mOriginalX;
|
|
|
|
int32_t newY = mPositionedObjectY + clientY - mOriginalY;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
SnapToGrid(newX, newY);
|
|
|
|
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mPositioningShadow, leftStr, newX);
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mPositioningShadow, topStr, newY);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!mResizedObject) {
|
|
|
|
// paranoia
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mActivatedHandle) {
|
|
|
|
mActivatedHandle->RemoveAttribute(NS_LITERAL_STRING("_moz_activated"));
|
2012-07-30 07:20:58 -07:00
|
|
|
mActivatedHandle = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// we have now to set the new width and height of the resized object
|
|
|
|
// we don't set the x and y position because we don't control that in
|
|
|
|
// a normal HTML layout
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t left = GetNewResizingX(aX, aY);
|
|
|
|
int32_t top = GetNewResizingY(aX, aY);
|
|
|
|
int32_t width = GetNewResizingWidth(aX, aY);
|
|
|
|
int32_t height = GetNewResizingHeight(aX, aY);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool setWidth = !mResizedObjectIsAbsolutelyPositioned || (width != mResizedObjectWidth);
|
|
|
|
bool setHeight = !mResizedObjectIsAbsolutelyPositioned || (height != mResizedObjectHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t x, y;
|
2007-03-22 10:30:00 -07:00
|
|
|
x = left - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderLeft+mResizedObjectMarginLeft : 0);
|
|
|
|
y = top - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderTop+mResizedObjectMarginTop : 0);
|
|
|
|
|
|
|
|
// we want one transaction only from a user's point of view
|
|
|
|
nsAutoEditBatch batchIt(this);
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(widthStr, "width");
|
|
|
|
NS_NAMED_LITERAL_STRING(heightStr, "height");
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool hasAttr = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mResizedObjectIsAbsolutelyPositioned) {
|
|
|
|
if (setHeight)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssTop,
|
|
|
|
y,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setWidth)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssLeft,
|
|
|
|
x,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-02-01 02:54:22 -08:00
|
|
|
if (IsCSSEnabled() || mResizedObjectIsAbsolutelyPositioned) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setWidth && NS_SUCCEEDED(mResizedObject->HasAttribute(widthStr, &hasAttr)) && hasAttr)
|
|
|
|
RemoveAttribute(mResizedObject, widthStr);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
hasAttr = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setHeight && NS_SUCCEEDED(mResizedObject->HasAttribute(heightStr, &hasAttr)) && hasAttr)
|
|
|
|
RemoveAttribute(mResizedObject, heightStr);
|
|
|
|
|
|
|
|
if (setWidth)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssWidth,
|
|
|
|
width,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setHeight)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssHeight,
|
|
|
|
height,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// we use HTML size and remove all equivalent CSS properties
|
|
|
|
|
|
|
|
// we set the CSS width and height to remove it later,
|
|
|
|
// triggering an immediate reflow; otherwise, we have problems
|
|
|
|
// with asynchronous reflow
|
|
|
|
if (setWidth)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssWidth,
|
|
|
|
width,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setHeight)
|
|
|
|
mHTMLCSSUtils->SetCSSPropertyPixels(mResizedObject,
|
|
|
|
nsEditProperty::cssHeight,
|
|
|
|
height,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (setWidth) {
|
|
|
|
nsAutoString w;
|
|
|
|
w.AppendInt(width);
|
|
|
|
SetAttribute(mResizedObject, widthStr, w);
|
|
|
|
}
|
|
|
|
if (setHeight) {
|
|
|
|
nsAutoString h;
|
|
|
|
h.AppendInt(height);
|
|
|
|
SetAttribute(mResizedObject, heightStr, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setWidth)
|
|
|
|
mHTMLCSSUtils->RemoveCSSProperty(mResizedObject,
|
|
|
|
nsEditProperty::cssWidth,
|
|
|
|
EmptyString(),
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (setHeight)
|
|
|
|
mHTMLCSSUtils->RemoveCSSProperty(mResizedObject,
|
|
|
|
nsEditProperty::cssHeight,
|
|
|
|
EmptyString(),
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// finally notify the listeners if any
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t listenersCount = objectResizeEventListeners.Count();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (listenersCount) {
|
|
|
|
nsCOMPtr<nsIHTMLObjectResizeListener> listener;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t index;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (index = 0; index < listenersCount; index++) {
|
|
|
|
listener = objectResizeEventListeners[index];
|
|
|
|
listener->OnEndResizing(mResizedObject,
|
|
|
|
mResizedObjectWidth, mResizedObjectHeight,
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep track of that size
|
|
|
|
mResizedObjectWidth = width;
|
|
|
|
mResizedObjectHeight = height;
|
|
|
|
|
|
|
|
RefreshResizers();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::GetResizedObject(nsIDOMElement * *aResizedObject)
|
|
|
|
{
|
|
|
|
*aResizedObject = mResizedObject;
|
|
|
|
NS_IF_ADDREF(*aResizedObject);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsHTMLEditor::GetObjectResizingEnabled(bool *aIsObjectResizingEnabled)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aIsObjectResizingEnabled = mIsObjectResizingEnabled;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsHTMLEditor::SetObjectResizingEnabled(bool aObjectResizingEnabled)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mIsObjectResizingEnabled = aObjectResizingEnabled;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::AddObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aListener);
|
|
|
|
if (objectResizeEventListeners.Count() &&
|
|
|
|
objectResizeEventListeners.IndexOf(aListener) != -1) {
|
|
|
|
/* listener already registered */
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ASSERTION(false,
|
2007-03-22 10:30:00 -07:00
|
|
|
"trying to register an already registered object resize event listener");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
objectResizeEventListeners.AppendObject(aListener);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLEditor::RemoveObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aListener);
|
|
|
|
if (!objectResizeEventListeners.Count() ||
|
|
|
|
objectResizeEventListeners.IndexOf(aListener) == -1) {
|
|
|
|
/* listener was not registered */
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ASSERTION(false,
|
2007-03-22 10:30:00 -07:00
|
|
|
"trying to remove an object resize event listener that was not already registered");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
objectResizeEventListeners.RemoveObject(aListener);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|