Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; 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/. */
5 :
6 : #include "DisplayItemClipChain.h"
7 :
8 : namespace mozilla {
9 :
10 : /* static */ const DisplayItemClip*
11 4750 : DisplayItemClipChain::ClipForASR(const DisplayItemClipChain* aClipChain, const ActiveScrolledRoot* aASR)
12 : {
13 4756 : while (aClipChain && !ActiveScrolledRoot::IsAncestor(aClipChain->mASR, aASR)) {
14 6 : aClipChain = aClipChain->mParent;
15 : }
16 4744 : return (aClipChain && aClipChain->mASR == aASR) ? &aClipChain->mClip : nullptr;
17 : }
18 :
19 : bool
20 1518 : DisplayItemClipChain::Equal(const DisplayItemClipChain* aClip1, const DisplayItemClipChain* aClip2)
21 : {
22 1518 : if (aClip1 == aClip2) {
23 1518 : return true;
24 : }
25 :
26 0 : if (!aClip1 || !aClip2) {
27 0 : return false;
28 : }
29 :
30 0 : return aClip1->mASR == aClip2->mASR &&
31 0 : aClip1->mClip == aClip2->mClip &&
32 0 : Equal(aClip1->mParent, aClip2->mParent);
33 : }
34 :
35 : /* static */ nsCString
36 0 : DisplayItemClipChain::ToString(const DisplayItemClipChain* aClipChain)
37 : {
38 0 : nsAutoCString str;
39 0 : for (auto* sc = aClipChain; sc; sc = sc->mParent) {
40 0 : if (sc->mASR) {
41 0 : str.AppendPrintf("<%s> [0x%p]", sc->mClip.ToString().get(), sc->mASR->mScrollableFrame);
42 :
43 : } else {
44 0 : str.AppendPrintf("<%s> [root asr]", sc->mClip.ToString().get());
45 : }
46 0 : if (sc->mParent) {
47 0 : str.Append(", ");
48 : }
49 : }
50 0 : return str;
51 : }
52 :
53 : bool
54 0 : DisplayItemClipChain::HasRoundedCorners() const
55 : {
56 0 : return mClip.GetRoundedRectCount() > 0 || (mParent && mParent->HasRoundedCorners());
57 : }
58 :
59 : } // namespace mozilla
|