blob: b426ade433b9a719852e0a3c866f43762a3c11f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkDOM.h"
#include "SkViewPriv.h"
//////////////////////////////////////////////////////////////////////
void SkView::Artist::draw(SkView* view, SkCanvas* canvas)
{
SkASSERT(view && canvas);
this->onDraw(view, canvas);
}
void SkView::Artist::inflate(const SkDOM& dom, const SkDOM::Node* node)
{
SkASSERT(node);
this->onInflate(dom, node);
}
void SkView::Artist::onInflate(const SkDOM&, const SkDOM::Node*)
{
// subclass should override this as needed
}
SkView::Artist* SkView::getArtist() const
{
Artist_SkTagList* rec = (Artist_SkTagList*)this->findTagList(kViewArtist_SkTagList);
SkASSERT(rec == nullptr || rec->fArtist != nullptr);
return rec ? rec->fArtist : nullptr;
}
SkView::Artist* SkView::setArtist(Artist* obj)
{
if (obj == nullptr)
{
this->removeTagList(kViewArtist_SkTagList);
}
else // add/replace
{
Artist_SkTagList* rec = (Artist_SkTagList*)this->findTagList(kViewArtist_SkTagList);
if (rec)
SkRefCnt_SafeAssign(rec->fArtist, obj);
else
this->addTagList(new Artist_SkTagList(obj));
}
return obj;
}
////////////////////////////////////////////////////////////////////////////////
void SkView::Layout::layoutChildren(SkView* parent)
{
SkASSERT(parent);
if (parent->width() > 0 && parent->height() > 0)
this->onLayoutChildren(parent);
}
void SkView::Layout::inflate(const SkDOM& dom, const SkDOM::Node* node)
{
SkASSERT(node);
this->onInflate(dom, node);
}
void SkView::Layout::onInflate(const SkDOM&, const SkDOM::Node*)
{
// subclass should override this as needed
}
SkView::Layout* SkView::getLayout() const
{
Layout_SkTagList* rec = (Layout_SkTagList*)this->findTagList(kViewLayout_SkTagList);
SkASSERT(rec == nullptr || rec->fLayout != nullptr);
return rec ? rec->fLayout : nullptr;
}
SkView::Layout* SkView::setLayout(Layout* obj, bool invokeLayoutNow)
{
if (obj == nullptr)
{
this->removeTagList(kViewLayout_SkTagList);
}
else // add/replace
{
Layout_SkTagList* rec = (Layout_SkTagList*)this->findTagList(kViewLayout_SkTagList);
if (rec)
SkRefCnt_SafeAssign(rec->fLayout, obj);
else
this->addTagList(new Layout_SkTagList(obj));
}
if (invokeLayoutNow)
this->invokeLayout();
return obj;
}
|