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..a63d3752ddd25ed19fd66ec0fb72aafabaa5fa05 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,28 @@ NinePatchResource::NinePatchResource(gfx::Rect padding, gfx::Rect aperture) |
NinePatchResource::~NinePatchResource() = default; |
+void NinePatchResource::UpdateNinePatchLayer( |
mdjones
2017/03/16 21:01:48
This feels like something that should either be st
Khushal
2017/03/17 23:02:58
The getter is already public. This was supposed to
|
+ cc::NinePatchLayer* layer, |
+ const gfx::Rect& content_location) const { |
+ // The effective drawing size of the layer includes the size of the content |
+ // (fit inside the expanded padding area) and the size of the margins on each |
+ // side. |
+ gfx::Size draw_size( |
+ content_location.width() + size().width() - padding_.width(), |
+ content_location.height() + size().height() - padding_.height()); |
+ gfx::Rect border(Border(draw_size)); |
+ // Offset the location of the layer by the amount taken by the left and top |
+ // margin. |
+ gfx::PointF position(content_location.x() - padding_.x(), |
+ content_location.y() - padding_.y()); |
+ |
+ layer->SetBounds(draw_size); |
+ layer->SetPosition(position); |
+ layer->SetBorder(border); |
+ layer->SetAperture(aperture_); |
+ layer->SetUIResourceId(ui_resource()->id()); |
+} |
+ |
gfx::Rect NinePatchResource::Border(const gfx::Size& bounds) const { |
return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f)); |
} |