mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1154701 part 5 - Switch nsHTMLEditor::objectResizeEventListeners to nsTArray; r=ehsan
This commit is contained in:
parent
bf443a34ea
commit
edc5f268b3
@ -195,7 +195,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLEditor, nsPlaintextEdito
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMouseMotionListenerP)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectionListenerP)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResizeEventListenerP)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(objectResizeEventListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mObjectResizeEventListeners)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAbsolutelyPositionedObject)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGrabber)
|
||||
|
@ -7,7 +7,6 @@
|
||||
#define nsHTMLEditor_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsPlaintextEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
@ -850,7 +849,7 @@ protected:
|
||||
nsCOMPtr<nsISelectionListener> mSelectionListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mResizeEventListenerP;
|
||||
|
||||
nsCOMArray<nsIHTMLObjectResizeListener> objectResizeEventListeners;
|
||||
nsTArray<mozilla::dom::OwningNonNull<nsIHTMLObjectResizeListener>> mObjectResizeEventListeners;
|
||||
|
||||
int32_t mOriginalX;
|
||||
int32_t mOriginalY;
|
||||
|
@ -499,14 +499,8 @@ nsresult
|
||||
nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
||||
{
|
||||
// First notify the listeners if any
|
||||
int32_t listenersCount = objectResizeEventListeners.Count();
|
||||
if (listenersCount) {
|
||||
nsCOMPtr<nsIHTMLObjectResizeListener> listener;
|
||||
int32_t index;
|
||||
for (index = 0; index < listenersCount; index++) {
|
||||
listener = objectResizeEventListeners[index];
|
||||
listener->OnStartResizing(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)));
|
||||
}
|
||||
for (auto& listener : mObjectResizeEventListeners) {
|
||||
listener->OnStartResizing(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)));
|
||||
}
|
||||
|
||||
mIsResizing = true;
|
||||
@ -976,16 +970,10 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
||||
EmptyString());
|
||||
}
|
||||
// finally notify the listeners if any
|
||||
int32_t listenersCount = objectResizeEventListeners.Count();
|
||||
if (listenersCount) {
|
||||
nsCOMPtr<nsIHTMLObjectResizeListener> listener;
|
||||
int32_t index;
|
||||
for (index = 0; index < listenersCount; index++) {
|
||||
listener = objectResizeEventListeners[index];
|
||||
listener->OnEndResizing(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)),
|
||||
mResizedObjectWidth, mResizedObjectHeight,
|
||||
width, height);
|
||||
}
|
||||
for (auto& listener : mObjectResizeEventListeners) {
|
||||
listener->OnEndResizing(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)),
|
||||
mResizedObjectWidth, mResizedObjectHeight, width,
|
||||
height);
|
||||
}
|
||||
|
||||
// keep track of that size
|
||||
@ -1021,14 +1009,13 @@ NS_IMETHODIMP
|
||||
nsHTMLEditor::AddObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
if (objectResizeEventListeners.Count() &&
|
||||
objectResizeEventListeners.IndexOf(aListener) != -1) {
|
||||
if (mObjectResizeEventListeners.Contains(aListener)) {
|
||||
/* listener already registered */
|
||||
NS_ASSERTION(false,
|
||||
"trying to register an already registered object resize event listener");
|
||||
return NS_OK;
|
||||
}
|
||||
objectResizeEventListeners.AppendObject(aListener);
|
||||
mObjectResizeEventListeners.AppendElement(*aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1036,14 +1023,13 @@ NS_IMETHODIMP
|
||||
nsHTMLEditor::RemoveObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
if (!objectResizeEventListeners.Count() ||
|
||||
objectResizeEventListeners.IndexOf(aListener) == -1) {
|
||||
if (!mObjectResizeEventListeners.Contains(aListener)) {
|
||||
/* listener was not registered */
|
||||
NS_ASSERTION(false,
|
||||
"trying to remove an object resize event listener that was not already registered");
|
||||
return NS_OK;
|
||||
}
|
||||
objectResizeEventListeners.RemoveObject(aListener);
|
||||
mObjectResizeEventListeners.RemoveElement(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user