Index: third_party/WebKit/Source/core/layout/ng/ng_units.h |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_units.h b/third_party/WebKit/Source/core/layout/ng/ng_units.h |
index d52f17d858c99989caea7fcec888dcfde5443383..8a49bd8d375d9ddf5953ec01a95aad02e7a615fc 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_units.h |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_units.h |
@@ -92,8 +92,10 @@ struct NGPhysicalRect { |
NGPhysicalSize size; |
}; |
+// TODO(glebl): move to a separate file in layout/ng/units. |
struct CORE_EXPORT NGLogicalRect { |
NGLogicalRect() {} |
+ // TODO(glebl): Make this private and use the builder everywhere. |
NGLogicalRect(LayoutUnit inline_offset, |
LayoutUnit block_offset, |
LayoutUnit inline_size, |
@@ -101,9 +103,72 @@ struct CORE_EXPORT NGLogicalRect { |
: offset(inline_offset, block_offset), size(inline_size, block_size) {} |
bool IsEmpty() const; |
+ |
+ // Whether this rectangle within the provided rectangle. |
+ bool IsWithin(const NGLogicalRect& other) const; |
+ |
String ToString() const; |
bool operator==(const NGLogicalRect& other) const; |
+ // Getters |
+ LayoutUnit InlineStartOffset() const { return offset.inline_offset; } |
+ |
+ LayoutUnit InlineEndOffset() const { |
+ return offset.inline_offset + size.inline_size; |
+ } |
+ |
+ LayoutUnit BlockStartOffset() const { return offset.block_offset; } |
+ |
+ LayoutUnit BlockEndOffset() const { |
+ return offset.block_offset + size.block_size; |
+ } |
+ |
+ LayoutUnit BlockSize() const { return size.block_size; } |
+ |
+ LayoutUnit InlineSize() const { return size.inline_size; } |
+ |
+ class Builder { |
ikilpatrick
2016/10/28 23:18:24
yeah, i'm not sold on using the builder for these
Gleb Lanbin
2016/10/28 23:54:09
yes, I'm not a 100% fan of it either because it's
|
+ public: |
+ Builder() = default; |
+ |
+ Builder& SetInlineOffset(const LayoutUnit& inline_offset) { |
+ inline_offset_ = inline_offset; |
+ return *this; |
+ } |
+ |
+ Builder& SetBlockOffset(const LayoutUnit& block_offset) { |
+ block_offset_ = block_offset; |
+ return *this; |
+ } |
+ |
+ Builder& SetInlineSize(const LayoutUnit& inline_size) { |
+ inline_size_ = inline_size; |
+ return *this; |
+ } |
+ |
+ Builder& SetBlockSize(const LayoutUnit& block_size) { |
+ block_size_ = block_size; |
+ return *this; |
+ } |
+ |
+ NGLogicalRect* BuildNew() { |
+ return new NGLogicalRect(inline_offset_, block_offset_, inline_size_, |
+ block_size_); |
+ } |
+ |
+ NGLogicalRect Build() { |
+ return NGLogicalRect(inline_offset_, block_offset_, inline_size_, |
+ block_size_); |
+ } |
+ |
+ private: |
+ LayoutUnit inline_offset_; |
+ LayoutUnit block_offset_; |
+ LayoutUnit inline_size_; |
+ LayoutUnit block_size_; |
+ DISALLOW_COPY_AND_ASSIGN(Builder); |
+ }; |
+ |
NGLogicalOffset offset; |
NGLogicalSize size; |
}; |