gecko-dev/dom/events/NotifyPaintEvent.cpp
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00

177 lines
4.8 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "base/basictypes.h"
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/NotifyPaintEvent.h"
#include "mozilla/dom/PaintRequest.h"
#include "mozilla/GfxMessageUtils.h"
#include "nsContentUtils.h"
namespace mozilla {
namespace dom {
NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
: Event(aOwner, aPresContext, aEvent)
{
if (mEvent) {
mEvent->mMessage = aEventMessage;
}
if (aInvalidateRequests) {
mInvalidateRequests.AppendElements(Move(aInvalidateRequests->mRequests));
}
}
NS_INTERFACE_MAP_BEGIN(NotifyPaintEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyPaintEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
NS_IMPL_ADDREF_INHERITED(NotifyPaintEvent, Event)
NS_IMPL_RELEASE_INHERITED(NotifyPaintEvent, Event)
nsRegion
NotifyPaintEvent::GetRegion()
{
nsRegion r;
if (!nsContentUtils::IsCallerChrome()) {
return r;
}
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
r.Or(r, mInvalidateRequests[i].mRect);
r.SimplifyOutward(10);
}
return r;
}
NS_IMETHODIMP
NotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
{
*aResult = BoundingClientRect().take();
return NS_OK;
}
already_AddRefed<DOMRect>
NotifyPaintEvent::BoundingClientRect()
{
RefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
if (mPresContext) {
rect->SetLayoutRect(GetRegion().GetBounds());
}
return rect.forget();
}
NS_IMETHODIMP
NotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
{
*aResult = ClientRects().take();
return NS_OK;
}
already_AddRefed<DOMRectList>
NotifyPaintEvent::ClientRects()
{
nsISupports* parent = ToSupports(this);
RefPtr<DOMRectList> rectList = new DOMRectList(parent);
nsRegion r = GetRegion();
nsRegionRectIterator iter(r);
for (const nsRect* rgnRect = iter.Next(); rgnRect; rgnRect = iter.Next()) {
RefPtr<DOMRect> rect = new DOMRect(parent);
rect->SetLayoutRect(*rgnRect);
rectList->Append(rect);
}
return rectList.forget();
}
NS_IMETHODIMP
NotifyPaintEvent::GetPaintRequests(nsISupports** aResult)
{
RefPtr<PaintRequestList> requests = PaintRequests();
requests.forget(aResult);
return NS_OK;
}
already_AddRefed<PaintRequestList>
NotifyPaintEvent::PaintRequests()
{
Event* parent = this;
RefPtr<PaintRequestList> requests = new PaintRequestList(parent);
if (nsContentUtils::IsCallerChrome()) {
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
RefPtr<PaintRequest> r = new PaintRequest(parent);
r->SetRequest(mInvalidateRequests[i]);
requests->Append(r);
}
}
return requests.forget();
}
NS_IMETHODIMP_(void)
NotifyPaintEvent::Serialize(IPC::Message* aMsg,
bool aSerializeInterfaceType)
{
if (aSerializeInterfaceType) {
IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
}
Event::Serialize(aMsg, false);
uint32_t length = mInvalidateRequests.Length();
IPC::WriteParam(aMsg, length);
for (uint32_t i = 0; i < length; ++i) {
IPC::WriteParam(aMsg, mInvalidateRequests[i].mRect);
IPC::WriteParam(aMsg, mInvalidateRequests[i].mFlags);
}
}
NS_IMETHODIMP_(bool)
NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
{
NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
uint32_t length = 0;
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &length), false);
mInvalidateRequests.SetCapacity(length);
for (uint32_t i = 0; i < length; ++i) {
nsInvalidateRequestList::Request req;
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mRect), false);
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mFlags), false);
mInvalidateRequests.AppendElement(req);
}
return true;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
already_AddRefed<NotifyPaintEvent>
NS_NewDOMNotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
EventMessage aEventMessage,
nsInvalidateRequestList* aInvalidateRequests)
{
RefPtr<NotifyPaintEvent> it =
new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
aInvalidateRequests);
return it.forget();
}