add validate to SkView for debugging
git-svn-id: http://skia.googlecode.com/svn/trunk@9596 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
f09b87dda3
commit
a25c94e50a
@ -373,6 +373,11 @@ protected:
|
|||||||
virtual bool onGetFocusView(SkView**) const { return false; }
|
virtual bool onGetFocusView(SkView**) const { return false; }
|
||||||
virtual bool onSetFocusView(SkView*) { return false; }
|
virtual bool onSetFocusView(SkView*) { return false; }
|
||||||
|
|
||||||
|
#ifdef SK_DEBUG
|
||||||
|
void validate() const;
|
||||||
|
#else
|
||||||
|
void validate() const {}
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
SkScalar fWidth, fHeight;
|
SkScalar fWidth, fHeight;
|
||||||
SkMatrix fMatrix;
|
SkMatrix fMatrix;
|
||||||
|
@ -509,55 +509,58 @@ bool SkView::handleInval(const SkRect*) {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void SkView::getLocalBounds(SkRect* bounds) const
|
void SkView::getLocalBounds(SkRect* bounds) const {
|
||||||
{
|
if (bounds) {
|
||||||
if (bounds)
|
|
||||||
bounds->set(0, 0, fWidth, fHeight);
|
bounds->set(0, 0, fWidth, fHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void SkView::detachFromParent_NoLayout()
|
void SkView::detachFromParent_NoLayout() {
|
||||||
{
|
this->validate();
|
||||||
if (fParent == NULL)
|
if (fParent == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fContainsFocus)
|
if (fContainsFocus) {
|
||||||
(void)this->setFocusView(NULL);
|
(void)this->setFocusView(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
this->inval(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;
|
fNextSibling->fPrevSibling = fPrevSibling;
|
||||||
fPrevSibling->fNextSibling = fNextSibling;
|
fPrevSibling->fNextSibling = fNextSibling;
|
||||||
next = fNextSibling;
|
next = fNextSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fParent->fFirstChild == this)
|
if (fParent->fFirstChild == this) {
|
||||||
fParent->fFirstChild = next;
|
fParent->fFirstChild = next;
|
||||||
|
}
|
||||||
|
|
||||||
fParent = fNextSibling = fPrevSibling = NULL;
|
fParent = fNextSibling = fPrevSibling = NULL;
|
||||||
|
|
||||||
|
this->validate();
|
||||||
this->unref();
|
this->unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::detachFromParent()
|
void SkView::detachFromParent() {
|
||||||
{
|
this->validate();
|
||||||
SkView* parent = fParent;
|
SkView* parent = fParent;
|
||||||
|
|
||||||
if (parent)
|
if (parent) {
|
||||||
{
|
|
||||||
this->detachFromParent_NoLayout();
|
this->detachFromParent_NoLayout();
|
||||||
parent->invokeLayout();
|
parent->invokeLayout();
|
||||||
}
|
}
|
||||||
|
this->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkView* SkView::attachChildToBack(SkView* child)
|
SkView* SkView::attachChildToBack(SkView* child) {
|
||||||
{
|
this->validate();
|
||||||
SkASSERT(child != this);
|
SkASSERT(child != this);
|
||||||
|
|
||||||
if (child == NULL || fFirstChild == child)
|
if (child == NULL || fFirstChild == child)
|
||||||
@ -566,13 +569,10 @@ SkView* SkView::attachChildToBack(SkView* child)
|
|||||||
child->ref();
|
child->ref();
|
||||||
child->detachFromParent_NoLayout();
|
child->detachFromParent_NoLayout();
|
||||||
|
|
||||||
if (fFirstChild == NULL)
|
if (fFirstChild == NULL) {
|
||||||
{
|
|
||||||
child->fNextSibling = child;
|
child->fNextSibling = child;
|
||||||
child->fPrevSibling = child;
|
child->fPrevSibling = child;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
child->fNextSibling = fFirstChild;
|
child->fNextSibling = fFirstChild;
|
||||||
child->fPrevSibling = fFirstChild->fPrevSibling;
|
child->fPrevSibling = fFirstChild->fPrevSibling;
|
||||||
fFirstChild->fPrevSibling->fNextSibling = child;
|
fFirstChild->fPrevSibling->fNextSibling = child;
|
||||||
@ -583,13 +583,14 @@ SkView* SkView::attachChildToBack(SkView* child)
|
|||||||
child->fParent = this;
|
child->fParent = this;
|
||||||
child->inval(NULL);
|
child->inval(NULL);
|
||||||
|
|
||||||
|
this->validate();
|
||||||
this->invokeLayout();
|
this->invokeLayout();
|
||||||
DONE:
|
DONE:
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkView* SkView::attachChildToFront(SkView* child)
|
SkView* SkView::attachChildToFront(SkView* child) {
|
||||||
{
|
this->validate();
|
||||||
SkASSERT(child != this);
|
SkASSERT(child != this);
|
||||||
|
|
||||||
if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child))
|
if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child))
|
||||||
@ -598,14 +599,11 @@ SkView* SkView::attachChildToFront(SkView* child)
|
|||||||
child->ref();
|
child->ref();
|
||||||
child->detachFromParent_NoLayout();
|
child->detachFromParent_NoLayout();
|
||||||
|
|
||||||
if (fFirstChild == NULL)
|
if (fFirstChild == NULL) {
|
||||||
{
|
|
||||||
fFirstChild = child;
|
fFirstChild = child;
|
||||||
child->fNextSibling = child;
|
child->fNextSibling = child;
|
||||||
child->fPrevSibling = child;
|
child->fPrevSibling = child;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
child->fNextSibling = fFirstChild;
|
child->fNextSibling = fFirstChild;
|
||||||
child->fPrevSibling = fFirstChild->fPrevSibling;
|
child->fPrevSibling = fFirstChild->fPrevSibling;
|
||||||
fFirstChild->fPrevSibling->fNextSibling = child;
|
fFirstChild->fPrevSibling->fNextSibling = child;
|
||||||
@ -615,19 +613,19 @@ SkView* SkView::attachChildToFront(SkView* child)
|
|||||||
child->fParent = this;
|
child->fParent = this;
|
||||||
child->inval(NULL);
|
child->inval(NULL);
|
||||||
|
|
||||||
|
this->validate();
|
||||||
this->invokeLayout();
|
this->invokeLayout();
|
||||||
DONE:
|
DONE:
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::detachAllChildren()
|
void SkView::detachAllChildren() {
|
||||||
{
|
this->validate();
|
||||||
while (fFirstChild)
|
while (fFirstChild)
|
||||||
fFirstChild->detachFromParent_NoLayout();
|
fFirstChild->detachFromParent_NoLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::localToGlobal(SkMatrix* matrix) const
|
void SkView::localToGlobal(SkMatrix* matrix) const {
|
||||||
{
|
|
||||||
if (matrix) {
|
if (matrix) {
|
||||||
matrix->reset();
|
matrix->reset();
|
||||||
const SkView* view = this;
|
const SkView* view = this;
|
||||||
@ -662,8 +660,7 @@ bool SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const
|
|||||||
/* Even if the subclass overrides onInflate, they should always be
|
/* Even if the subclass overrides onInflate, they should always be
|
||||||
sure to call the inherited method, so that we get called.
|
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;
|
SkScalar x, y;
|
||||||
|
|
||||||
x = this->locX();
|
x = this->locX();
|
||||||
@ -693,18 +690,15 @@ void SkView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
|
|||||||
this->setFlags(flags);
|
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);
|
this->onInflate(dom, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::onPostInflate(const SkTDict<SkView*>&)
|
void SkView::onPostInflate(const SkTDict<SkView*>&) {
|
||||||
{
|
|
||||||
// override in subclass as needed
|
// override in subclass as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::postInflate(const SkTDict<SkView*>& dict)
|
void SkView::postInflate(const SkTDict<SkView*>& dict) {
|
||||||
{
|
|
||||||
this->onPostInflate(dict);
|
this->onPostInflate(dict);
|
||||||
|
|
||||||
B2FIter iter(this);
|
B2FIter iter(this);
|
||||||
@ -715,14 +709,13 @@ void SkView::postInflate(const SkTDict<SkView*>& dict)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SkView* SkView::sendEventToParents(const SkEvent& evt)
|
SkView* SkView::sendEventToParents(const SkEvent& evt) {
|
||||||
{
|
|
||||||
SkView* parent = fParent;
|
SkView* parent = fParent;
|
||||||
|
|
||||||
while (parent)
|
while (parent) {
|
||||||
{
|
if (parent->doEvent(evt)) {
|
||||||
if (parent->doEvent(evt))
|
|
||||||
return parent;
|
return parent;
|
||||||
|
}
|
||||||
parent = parent->fParent;
|
parent = parent->fParent;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -743,38 +736,33 @@ SkView* SkView::sendQueryToParents(SkEvent* evt) {
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SkView::F2BIter::F2BIter(const SkView* parent)
|
SkView::F2BIter::F2BIter(const SkView* parent) {
|
||||||
{
|
|
||||||
fFirstChild = parent ? parent->fFirstChild : NULL;
|
fFirstChild = parent ? parent->fFirstChild : NULL;
|
||||||
fChild = fFirstChild ? fFirstChild->fPrevSibling : NULL;
|
fChild = fFirstChild ? fFirstChild->fPrevSibling : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkView* SkView::F2BIter::next()
|
SkView* SkView::F2BIter::next() {
|
||||||
{
|
|
||||||
SkView* curr = fChild;
|
SkView* curr = fChild;
|
||||||
|
|
||||||
if (fChild)
|
if (fChild) {
|
||||||
{
|
if (fChild == fFirstChild) {
|
||||||
if (fChild == fFirstChild)
|
|
||||||
fChild = NULL;
|
fChild = NULL;
|
||||||
else
|
} else {
|
||||||
fChild = fChild->fPrevSibling;
|
fChild = fChild->fPrevSibling;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkView::B2FIter::B2FIter(const SkView* parent)
|
SkView::B2FIter::B2FIter(const SkView* parent) {
|
||||||
{
|
|
||||||
fFirstChild = parent ? parent->fFirstChild : NULL;
|
fFirstChild = parent ? parent->fFirstChild : NULL;
|
||||||
fChild = fFirstChild;
|
fChild = fFirstChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkView* SkView::B2FIter::next()
|
SkView* SkView::B2FIter::next() {
|
||||||
{
|
|
||||||
SkView* curr = fChild;
|
SkView* curr = fChild;
|
||||||
|
|
||||||
if (fChild)
|
if (fChild) {
|
||||||
{
|
|
||||||
SkView* next = fChild->fNextSibling;
|
SkView* next = fChild->fNextSibling;
|
||||||
if (next == fFirstChild)
|
if (next == fFirstChild)
|
||||||
next = NULL;
|
next = NULL;
|
||||||
@ -788,6 +776,17 @@ SkView* SkView::B2FIter::next()
|
|||||||
|
|
||||||
#ifdef SK_DEBUG
|
#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)
|
static inline void show_if_nonzero(const char name[], SkScalar value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
Loading…
Reference in New Issue
Block a user