Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Unified Diff: content/public/android/java/src/org/chromium/content_public/resources/LayoutResource.java

Issue 731133002: Upstream ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add generated enum class to BUILD.gn Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content_public/resources/LayoutResource.java
diff --git a/content/public/android/java/src/org/chromium/content_public/resources/LayoutResource.java b/content/public/android/java/src/org/chromium/content_public/resources/LayoutResource.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8ec39d8c238a711cfb9d7551320cdc3ab685f91
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content_public/resources/LayoutResource.java
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content_public.resources;
+
+import android.graphics.Rect;
+import android.graphics.RectF;
+
+/**
+ * A resource that provides sizing information for layouts.
+ */
+public class LayoutResource {
+ private final RectF mPadding;
+ private final RectF mBitmapSize;
+ private final RectF mAperture;
+
+ public LayoutResource(float pxToDp, Resource resource) {
+ Rect padding = resource.getPadding();
+ Rect bitmapSize = resource.getBitmapSize();
+ Rect aperture = resource.getAperture();
+
+ mPadding = new RectF(padding.left * pxToDp, padding.top * pxToDp, padding.right * pxToDp,
+ padding.bottom * pxToDp);
+
+ mBitmapSize = new RectF(bitmapSize.left * pxToDp, bitmapSize.top * pxToDp,
+ bitmapSize.right * pxToDp, bitmapSize.bottom * pxToDp);
+
+ mAperture = new RectF(aperture.left * pxToDp, aperture.top * pxToDp,
+ aperture.right * pxToDp, aperture.bottom * pxToDp);
+ }
+
+ /**
+ * @return The padded content area of this resource in dp. For 9-patches this will represent
+ * the valid content of the 9-patch. It can mean other things for other Resources
+ * though.
+ */
+ public RectF getPadding() {
+ return mPadding;
+ }
+
+ /**
+ * @return The size of the bitmap in dp;
+ */
+ public RectF getBitmapSize() {
+ return mBitmapSize;
+ }
+
+ /**
+ * @return The aperture of this resource in dp. For 9-patches this will represent the area of
+ * the {@link Bitmap} that should not be stretched. It can mean other things for other
+ * Resources though.
+ */
+ public RectF getAperture() {
+ return mAperture;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698