dom/events/ScrollAreaEvent.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "base/basictypes.h"
     7 #include "ipc/IPCMessageUtils.h"
     8 #include "mozilla/dom/DOMRect.h"
     9 #include "mozilla/dom/ScrollAreaEvent.h"
    10 #include "mozilla/ContentEvents.h"
    12 namespace mozilla {
    13 namespace dom {
    15 ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
    16                                  nsPresContext* aPresContext,
    17                                  InternalScrollAreaEvent* aEvent)
    18   : UIEvent(aOwner, aPresContext, aEvent)
    19   , mClientArea(nullptr)
    20 {
    21   mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
    22 }
    24 NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
    25 NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
    27 NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent)
    28   NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent)
    29 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
    32 #define FORWARD_GETTER(_name)                                                  \
    33   NS_IMETHODIMP                                                                \
    34   ScrollAreaEvent::Get ## _name(float* aResult)                                \
    35   {                                                                            \
    36     *aResult = _name();                                                        \
    37     return NS_OK;                                                              \
    38   }
    40 FORWARD_GETTER(X)
    41 FORWARD_GETTER(Y)
    42 FORWARD_GETTER(Width)
    43 FORWARD_GETTER(Height)
    45 NS_IMETHODIMP
    46 ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
    47                                      bool aCanBubble,
    48                                      bool aCancelable,
    49                                      nsIDOMWindow* aView,
    50                                      int32_t aDetail,
    51                                      float aX,
    52                                      float aY,
    53                                      float aWidth,
    54                                      float aHeight)
    55 {
    56   nsresult rv =
    57     UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
    58   NS_ENSURE_SUCCESS(rv, rv);
    60   mClientArea.SetRect(aX, aY, aWidth, aHeight);
    62   return NS_OK;
    63 }
    65 NS_IMETHODIMP_(void)
    66 ScrollAreaEvent::Serialize(IPC::Message* aMsg,
    67                            bool aSerializeInterfaceType)
    68 {
    69   if (aSerializeInterfaceType) {
    70     IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
    71   }
    73   Event::Serialize(aMsg, false);
    75   IPC::WriteParam(aMsg, X());
    76   IPC::WriteParam(aMsg, Y());
    77   IPC::WriteParam(aMsg, Width());
    78   IPC::WriteParam(aMsg, Height());
    79 }
    81 NS_IMETHODIMP_(bool)
    82 ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
    83 {
    84   NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
    86   float x, y, width, height;
    87   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false);
    88   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false);
    89   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false);
    90   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false);
    91   mClientArea.SetRect(x, y, width, height);
    93   return true;
    94 }
    96 } // namespace dom
    97 } // namespace mozilla
    99 using namespace mozilla;
   100 using namespace mozilla::dom;
   102 nsresult
   103 NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult,
   104                          EventTarget* aOwner,
   105                          nsPresContext* aPresContext,
   106                          InternalScrollAreaEvent* aEvent)
   107 {
   108   ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent);
   109   return CallQueryInterface(ev, aInstancePtrResult);
   110 }

mercurial