Index: ui/android/resources/nine_patch_resource.cc |
diff --git a/ui/android/resources/nine_patch_resource.cc b/ui/android/resources/nine_patch_resource.cc |
index cf8055dd40c02741cabd49f5f0faecbcc03a2ec9..5a8ff78e66073f9ed60fecaa74bc3c31a4315ef3 100644 |
--- a/ui/android/resources/nine_patch_resource.cc |
+++ b/ui/android/resources/nine_patch_resource.cc |
@@ -5,6 +5,8 @@ |
#include "ui/android/resources/nine_patch_resource.h" |
#include "base/memory/ptr_util.h" |
+#include "cc/layers/nine_patch_layer.h" |
+#include "ui/gfx/geometry/point_f.h" |
namespace ui { |
@@ -21,6 +23,22 @@ NinePatchResource::NinePatchResource(gfx::Rect padding, gfx::Rect aperture) |
NinePatchResource::~NinePatchResource() = default; |
+gfx::Size NinePatchResource::DrawSize(const gfx::Size& content_size) const { |
+ // The effective drawing size of the resource includes the size of the content |
+ // (fit inside the expanded padding area) and the size of the margins on each |
+ // side. |
+ return gfx::Size(content_size.width() + size().width() - padding_.width(), |
+ content_size.height() + size().height() - padding_.height()); |
+} |
+ |
+gfx::PointF NinePatchResource::DrawPosition( |
+ const gfx::Point& content_position) const { |
+ // Offset the location of the layer by the amount taken by the left and top |
+ // margin. |
+ return gfx::PointF(content_position.x() - padding_.x(), |
+ content_position.y() - padding_.y()); |
+} |
+ |
gfx::Rect NinePatchResource::Border(const gfx::Size& bounds) const { |
return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f)); |
} |