//////////////////////////////////////////////////////////////////////
-void SkView::getLocalBounds(SkRect* bounds) const
-{
- if (bounds)
+void SkView::getLocalBounds(SkRect* bounds) const {
+ if (bounds) {
bounds->set(0, 0, fWidth, fHeight);
+ }
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-void SkView::detachFromParent_NoLayout()
-{
- if (fParent == NULL)
+void SkView::detachFromParent_NoLayout() {
+ this->validate();
+ if (fParent == NULL) {
return;
+ }
- if (fContainsFocus)
+ if (fContainsFocus) {
(void)this->setFocusView(NULL);
+ }
this->inval(NULL);
- SkView* next = NULL;
+ SkView* next = NULL;
- if (fNextSibling != this) // do we have any siblings
- {
+ if (fNextSibling != this) { // do we have any siblings
fNextSibling->fPrevSibling = fPrevSibling;
fPrevSibling->fNextSibling = fNextSibling;
next = fNextSibling;
}
- if (fParent->fFirstChild == this)
+ if (fParent->fFirstChild == this) {
fParent->fFirstChild = next;
+ }
fParent = fNextSibling = fPrevSibling = NULL;
+ this->validate();
this->unref();
}
-void SkView::detachFromParent()
-{
+void SkView::detachFromParent() {
+ this->validate();
SkView* parent = fParent;
- if (parent)
- {
+ if (parent) {
this->detachFromParent_NoLayout();
parent->invokeLayout();
}
+ this->validate();
}
-SkView* SkView::attachChildToBack(SkView* child)
-{
+SkView* SkView::attachChildToBack(SkView* child) {
+ this->validate();
SkASSERT(child != this);
if (child == NULL || fFirstChild == child)
child->ref();
child->detachFromParent_NoLayout();
- if (fFirstChild == NULL)
- {
+ if (fFirstChild == NULL) {
child->fNextSibling = child;
child->fPrevSibling = child;
- }
- else
- {
+ } else {
child->fNextSibling = fFirstChild;
child->fPrevSibling = fFirstChild->fPrevSibling;
fFirstChild->fPrevSibling->fNextSibling = child;
child->fParent = this;
child->inval(NULL);
+ this->validate();
this->invokeLayout();
DONE:
return child;
}
-SkView* SkView::attachChildToFront(SkView* child)
-{
+SkView* SkView::attachChildToFront(SkView* child) {
+ this->validate();
SkASSERT(child != this);
if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child))
child->ref();
child->detachFromParent_NoLayout();
- if (fFirstChild == NULL)
- {
+ if (fFirstChild == NULL) {
fFirstChild = child;
child->fNextSibling = child;
child->fPrevSibling = child;
- }
- else
- {
+ } else {
child->fNextSibling = fFirstChild;
child->fPrevSibling = fFirstChild->fPrevSibling;
fFirstChild->fPrevSibling->fNextSibling = child;
child->fParent = this;
child->inval(NULL);
+ this->validate();
this->invokeLayout();
DONE:
return child;
}
-void SkView::detachAllChildren()
-{
+void SkView::detachAllChildren() {
+ this->validate();
while (fFirstChild)
fFirstChild->detachFromParent_NoLayout();
}
-void SkView::localToGlobal(SkMatrix* matrix) const
-{
+void SkView::localToGlobal(SkMatrix* matrix) const {
if (matrix) {
matrix->reset();
const SkView* view = this;
/* Even if the subclass overrides onInflate, they should always be
sure to call the inherited method, so that we get called.
*/
-void SkView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
-{
+void SkView::onInflate(const SkDOM& dom, const SkDOM::Node* node) {
SkScalar x, y;
x = this->locX();
this->setFlags(flags);
}
-void SkView::inflate(const SkDOM& dom, const SkDOM::Node* node)
-{
+void SkView::inflate(const SkDOM& dom, const SkDOM::Node* node) {
this->onInflate(dom, node);
}
-void SkView::onPostInflate(const SkTDict<SkView*>&)
-{
+void SkView::onPostInflate(const SkTDict<SkView*>&) {
// override in subclass as needed
}
-void SkView::postInflate(const SkTDict<SkView*>& dict)
-{
+void SkView::postInflate(const SkTDict<SkView*>& dict) {
this->onPostInflate(dict);
B2FIter iter(this);
//////////////////////////////////////////////////////////////////
-SkView* SkView::sendEventToParents(const SkEvent& evt)
-{
+SkView* SkView::sendEventToParents(const SkEvent& evt) {
SkView* parent = fParent;
- while (parent)
- {
- if (parent->doEvent(evt))
+ while (parent) {
+ if (parent->doEvent(evt)) {
return parent;
+ }
parent = parent->fParent;
}
return NULL;
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
-SkView::F2BIter::F2BIter(const SkView* parent)
-{
+SkView::F2BIter::F2BIter(const SkView* parent) {
fFirstChild = parent ? parent->fFirstChild : NULL;
fChild = fFirstChild ? fFirstChild->fPrevSibling : NULL;
}
-SkView* SkView::F2BIter::next()
-{
+SkView* SkView::F2BIter::next() {
SkView* curr = fChild;
- if (fChild)
- {
- if (fChild == fFirstChild)
+ if (fChild) {
+ if (fChild == fFirstChild) {
fChild = NULL;
- else
+ } else {
fChild = fChild->fPrevSibling;
+ }
}
return curr;
}
-SkView::B2FIter::B2FIter(const SkView* parent)
-{
+SkView::B2FIter::B2FIter(const SkView* parent) {
fFirstChild = parent ? parent->fFirstChild : NULL;
fChild = fFirstChild;
}
-SkView* SkView::B2FIter::next()
-{
+SkView* SkView::B2FIter::next() {
SkView* curr = fChild;
- if (fChild)
- {
+ if (fChild) {
SkView* next = fChild->fNextSibling;
if (next == fFirstChild)
next = NULL;
#ifdef SK_DEBUG
+void SkView::validate() const {
+ if (fParent) {
+ SkASSERT(fNextSibling);
+ SkASSERT(fPrevSibling);
+ } else {
+ bool nextNull = NULL == fNextSibling;
+ bool prevNull = NULL == fNextSibling;
+ SkASSERT(nextNull && prevNull || !nextNull && !prevNull);
+ }
+}
+
static inline void show_if_nonzero(const char name[], SkScalar value)
{
if (value)