Index: content/public/common/common_param_traits.cc |
=================================================================== |
--- content/public/common/common_param_traits.cc (revision 175167) |
+++ content/public/common/common_param_traits.cc (working copy) |
@@ -169,6 +169,8 @@ |
} |
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { |
+ DCHECK_GE(p.width(), 0); |
+ DCHECK_GE(p.height(), 0); |
m->WriteInt(p.width()); |
m->WriteInt(p.height()); |
} |
@@ -177,8 +179,8 @@ |
PickleIterator* iter, |
gfx::Size* r) { |
int w, h; |
- if (!m->ReadInt(iter, &w) || |
- !m->ReadInt(iter, &h)) |
+ if (!m->ReadInt(iter, &w) || w < 0 || |
+ !m->ReadInt(iter, &h) || h < 0) |
return false; |
r->set_width(w); |
r->set_height(h); |
@@ -253,25 +255,20 @@ |
} |
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { |
- m->WriteInt(p.x()); |
- m->WriteInt(p.y()); |
- m->WriteInt(p.width()); |
- m->WriteInt(p.height()); |
+ WriteParam(m, p.origin()); |
+ WriteParam(m, p.size()); |
} |
bool ParamTraits<gfx::Rect>::Read(const Message* m, |
PickleIterator* iter, |
gfx::Rect* r) { |
- int x, y, w, h; |
- if (!m->ReadInt(iter, &x) || |
- !m->ReadInt(iter, &y) || |
- !m->ReadInt(iter, &w) || |
- !m->ReadInt(iter, &h)) |
+ gfx::Point origin; |
+ gfx::Size size; |
+ if (!ReadParam(m, iter, &origin) || |
+ !ReadParam(m, iter, &size)) |
return false; |
- r->set_x(x); |
- r->set_y(y); |
- r->set_width(w); |
- r->set_height(h); |
+ r->set_origin(origin); |
+ r->set_size(size); |
return true; |
} |