1 : /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Mozilla Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2009
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Robert O'Callahan <robert@ocallahan.org>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "nsPaintRequest.h"
40 :
41 : #include "nsDOMClassInfoID.h"
42 : #include "nsClientRect.h"
43 : #include "nsIFrame.h"
44 : #include "nsContentUtils.h"
45 :
46 : DOMCI_DATA(PaintRequest, nsPaintRequest)
47 :
48 0 : NS_INTERFACE_TABLE_HEAD(nsPaintRequest)
49 0 : NS_INTERFACE_TABLE1(nsPaintRequest, nsIDOMPaintRequest)
50 0 : NS_INTERFACE_TABLE_TO_MAP_SEGUE
51 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PaintRequest)
52 0 : NS_INTERFACE_MAP_END
53 :
54 0 : NS_IMPL_ADDREF(nsPaintRequest)
55 0 : NS_IMPL_RELEASE(nsPaintRequest)
56 :
57 : NS_IMETHODIMP
58 0 : nsPaintRequest::GetClientRect(nsIDOMClientRect** aResult)
59 : {
60 0 : nsRefPtr<nsClientRect> clientRect = new nsClientRect();
61 0 : if (!clientRect)
62 0 : return NS_ERROR_OUT_OF_MEMORY;
63 0 : clientRect->SetLayoutRect(mRequest.mRect);
64 0 : clientRect.forget(aResult);
65 0 : return NS_OK;
66 : }
67 :
68 : NS_IMETHODIMP
69 0 : nsPaintRequest::GetReason(nsAString& aResult)
70 : {
71 0 : switch (mRequest.mFlags & nsIFrame::INVALIDATE_REASON_MASK) {
72 : case nsIFrame::INVALIDATE_REASON_SCROLL_BLIT:
73 0 : aResult.AssignLiteral("scroll copy");
74 0 : break;
75 : case nsIFrame::INVALIDATE_REASON_SCROLL_REPAINT:
76 0 : aResult.AssignLiteral("scroll repaint");
77 0 : break;
78 : default:
79 0 : aResult.Truncate();
80 0 : break;
81 : }
82 0 : return NS_OK;
83 : }
84 :
85 : DOMCI_DATA(PaintRequestList, nsPaintRequestList)
86 :
87 1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsPaintRequestList)
88 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPaintRequestList)
89 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
90 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent)
91 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
92 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPaintRequestList)
93 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
94 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParent)
95 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
96 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsPaintRequestList)
97 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
98 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
99 :
100 0 : NS_INTERFACE_TABLE_HEAD(nsPaintRequestList)
101 0 : NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
102 0 : NS_INTERFACE_TABLE1(nsPaintRequestList, nsIDOMPaintRequestList)
103 0 : NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsPaintRequestList)
104 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PaintRequestList)
105 0 : NS_INTERFACE_MAP_END
106 :
107 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPaintRequestList)
108 0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPaintRequestList)
109 :
110 : NS_IMETHODIMP
111 0 : nsPaintRequestList::GetLength(PRUint32* aLength)
112 : {
113 0 : *aLength = mArray.Count();
114 0 : return NS_OK;
115 : }
116 :
117 : NS_IMETHODIMP
118 0 : nsPaintRequestList::Item(PRUint32 aIndex, nsIDOMPaintRequest** aReturn)
119 : {
120 0 : NS_IF_ADDREF(*aReturn = nsPaintRequestList::GetItemAt(aIndex));
121 0 : return NS_OK;
122 : }
123 :
124 : nsIDOMPaintRequest*
125 0 : nsPaintRequestList::GetItemAt(PRUint32 aIndex)
126 : {
127 0 : return mArray.SafeObjectAt(aIndex);
128 4392 : }
|