2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2009-11-17 17:22:23 +03:00
|
|
|
#include "base/basictypes.h"
|
2012-08-28 16:41:04 +04:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2014-02-28 18:58:43 +04:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
|
|
|
#include "mozilla/dom/NotifyPaintEvent.h"
|
2014-04-03 08:18:37 +04:00
|
|
|
#include "mozilla/dom/PaintRequest.h"
|
2013-07-26 23:28:31 +04:00
|
|
|
#include "mozilla/GfxMessageUtils.h"
|
2008-09-18 13:47:21 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-09-20 14:21:03 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
NotifyPaintEvent::NotifyPaintEvent(
|
|
|
|
EventTarget* aOwner, nsPresContext* aPresContext, WidgetEvent* aEvent,
|
2017-02-17 01:50:58 +03:00
|
|
|
EventMessage aEventMessage, nsTArray<nsRect>* aInvalidateRequests,
|
2017-01-26 08:01:33 +03:00
|
|
|
uint64_t aTransactionId, DOMHighResTimeStamp aTimeStamp)
|
2014-03-05 04:37:43 +04:00
|
|
|
: Event(aOwner, aPresContext, aEvent) {
|
2009-06-23 13:09:05 +04:00
|
|
|
if (mEvent) {
|
2015-08-26 15:56:59 +03:00
|
|
|
mEvent->mMessage = aEventMessage;
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
2009-09-04 08:49:18 +04:00
|
|
|
if (aInvalidateRequests) {
|
2017-02-17 01:50:58 +03:00
|
|
|
mInvalidateRequests.SwapElements(*aInvalidateRequests);
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
2016-04-13 23:59:15 +03:00
|
|
|
|
|
|
|
mTransactionId = aTransactionId;
|
2017-01-26 08:01:33 +03:00
|
|
|
mTimeStamp = aTimeStamp;
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
nsRegion NotifyPaintEvent::GetRegion(SystemCallerGuarantee) {
|
2008-09-18 13:47:21 +04:00
|
|
|
nsRegion r;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
|
2017-02-17 01:50:58 +03:00
|
|
|
r.Or(r, mInvalidateRequests[i]);
|
2009-09-04 08:49:18 +04:00
|
|
|
r.SimplifyOutward(10);
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
already_AddRefed<DOMRect> NotifyPaintEvent::BoundingClientRect(
|
|
|
|
SystemCallerGuarantee aGuarantee) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2013-03-17 11:55:17 +04:00
|
|
|
if (mPresContext) {
|
2017-02-02 02:26:31 +03:00
|
|
|
rect->SetLayoutRect(GetRegion(aGuarantee).GetBounds());
|
2013-03-17 11:55:17 +04:00
|
|
|
}
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2013-04-16 00:27:37 +04:00
|
|
|
return rect.forget();
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
|
|
|
|
2013-09-20 14:21:03 +04:00
|
|
|
already_AddRefed<DOMRectList> NotifyPaintEvent::ClientRects(
|
2017-02-02 02:26:31 +03:00
|
|
|
SystemCallerGuarantee aGuarantee) {
|
2013-03-17 11:55:17 +04:00
|
|
|
nsISupports* parent = ToSupports(this);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMRectList> rectList = new DOMRectList(parent);
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
nsRegion r = GetRegion(aGuarantee);
|
2016-01-19 04:20:44 +03:00
|
|
|
for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMRect> rect = new DOMRect(parent);
|
2016-01-19 04:20:44 +03:00
|
|
|
rect->SetLayoutRect(iter.Get());
|
2008-09-18 13:47:21 +04:00
|
|
|
rectList->Append(rect);
|
|
|
|
}
|
|
|
|
|
2013-04-16 00:27:37 +04:00
|
|
|
return rectList.forget();
|
2009-09-04 08:49:18 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:37 +04:00
|
|
|
already_AddRefed<PaintRequestList> NotifyPaintEvent::PaintRequests(
|
2017-02-02 02:26:31 +03:00
|
|
|
SystemCallerGuarantee) {
|
2014-03-05 04:37:43 +04:00
|
|
|
Event* parent = this;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PaintRequestList> requests = new PaintRequestList(parent);
|
2009-09-04 08:49:18 +04:00
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
|
|
|
|
RefPtr<PaintRequest> r = new PaintRequest(parent);
|
|
|
|
r->SetRequest(mInvalidateRequests[i]);
|
|
|
|
requests->Append(r);
|
2009-09-04 08:49:18 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 12:16:55 +04:00
|
|
|
return requests.forget();
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
void NotifyPaintEvent::Serialize(IPC::Message* aMsg,
|
|
|
|
bool aSerializeInterfaceType) {
|
2009-11-17 17:22:23 +03:00
|
|
|
if (aSerializeInterfaceType) {
|
|
|
|
IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
|
|
|
|
}
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
Event::Serialize(aMsg, false);
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t length = mInvalidateRequests.Length();
|
2009-11-17 17:22:23 +03:00
|
|
|
IPC::WriteParam(aMsg, length);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2017-02-17 01:50:58 +03:00
|
|
|
IPC::WriteParam(aMsg, mInvalidateRequests[i]);
|
2009-11-17 17:22:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
bool NotifyPaintEvent::Deserialize(const IPC::Message* aMsg,
|
|
|
|
PickleIterator* aIter) {
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t length = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &length), false);
|
2009-11-17 17:22:23 +03:00
|
|
|
mInvalidateRequests.SetCapacity(length);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2017-02-17 01:50:58 +03:00
|
|
|
nsRect req;
|
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req), false);
|
2009-11-17 17:22:23 +03:00
|
|
|
mInvalidateRequests.AppendElement(req);
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-11-17 17:22:23 +03:00
|
|
|
}
|
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
uint64_t NotifyPaintEvent::TransactionId(SystemCallerGuarantee) {
|
2016-04-13 23:59:15 +03:00
|
|
|
return mTransactionId;
|
|
|
|
}
|
|
|
|
|
2017-02-02 02:26:31 +03:00
|
|
|
DOMHighResTimeStamp NotifyPaintEvent::PaintTimeStamp(SystemCallerGuarantee) {
|
2017-01-26 08:01:33 +03:00
|
|
|
return mTimeStamp;
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2008-09-18 13:47:21 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<NotifyPaintEvent> NS_NewDOMNotifyPaintEvent(
|
2014-02-28 18:58:43 +04:00
|
|
|
EventTarget* aOwner, nsPresContext* aPresContext, WidgetEvent* aEvent,
|
2017-02-17 01:50:58 +03:00
|
|
|
EventMessage aEventMessage, nsTArray<nsRect>* aInvalidateRequests,
|
2017-01-26 08:01:33 +03:00
|
|
|
uint64_t aTransactionId, DOMHighResTimeStamp aTimeStamp) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<NotifyPaintEvent> it =
|
2015-08-26 15:56:59 +03:00
|
|
|
new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
|
2017-01-26 08:01:33 +03:00
|
|
|
aInvalidateRequests, aTransactionId, aTimeStamp);
|
2015-08-12 14:39:31 +03:00
|
|
|
return it.forget();
|
2008-09-18 13:47:21 +04:00
|
|
|
}
|