Allow floating point rectangles to be sent via IPC.

These are required by the Android find-in-page implementation. Further patches
will introduce automatic conversion from WebKit::WebFloatRect to gfx::RectF.


BUG=136762
TEST=new case added to base_unittests


Review URL: https://chromiumcodereview.appspot.com/10818011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147974 0039d316-1c4b-4281-b951-d872f2087c98
parent 22aca01d
......@@ -12,6 +12,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/range/range.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
namespace {
......@@ -422,6 +423,34 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
p.width(), p.height()));
}
void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) {
ParamTraits<float>::Write(m, p.x());
ParamTraits<float>::Write(m, p.y());
ParamTraits<float>::Write(m, p.width());
ParamTraits<float>::Write(m, p.height());
}
bool ParamTraits<gfx::RectF>::Read(const Message* m,
PickleIterator* iter,
gfx::RectF* r) {
float x, y, w, h;
if (!ParamTraits<float>::Read(m, iter, &x) ||
!ParamTraits<float>::Read(m, iter, &y) ||
!ParamTraits<float>::Read(m, iter, &w) ||
!ParamTraits<float>::Read(m, iter, &h))
return false;
r->set_x(x);
r->set_y(y);
r->set_width(w);
r->set_height(h);
return true;
}
void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) {
l->append(base::StringPrintf("(%f, %f, %f, %f)", p.x(), p.y(),
p.width(), p.height()));
}
void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) {
m->WriteUInt64(r.start());
m->WriteUInt64(r.end());
......
......@@ -33,6 +33,7 @@ struct Referrer;
namespace gfx {
class Point;
class Rect;
class RectF;
class Size;
} // namespace gfx
......@@ -128,6 +129,14 @@ struct CONTENT_EXPORT ParamTraits<gfx::Rect> {
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<gfx::RectF> {
typedef gfx::RectF param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, PickleIterator* iter, param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<gfx::NativeWindow> {
typedef gfx::NativeWindow param_type;
......
......@@ -401,10 +401,14 @@
'gfx/point.cc',
'gfx/point.h',
'gfx/point_base.h',
'gfx/point_f.cc',
'gfx/point_f.h',
'gfx/rect.cc',
'gfx/rect.h',
'gfx/rect_base.h',
'gfx/rect_base_impl.h',
'gfx/rect_f.cc',
'gfx/rect_f.h',
'gfx/render_text.cc',
'gfx/render_text.h',
'gfx/render_text_mac.cc',
......@@ -433,6 +437,8 @@
'gfx/size.h',
'gfx/size_base.h',
'gfx/size_base_impl.h',
'gfx/size_f.cc',
'gfx/size_f.h',
'gfx/skbitmap_operations.cc',
'gfx/skbitmap_operations.h',
'gfx/skia_util.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment