Commit d0c35dd3 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Inline some NGPhysicalOffsetRect methods

We want to use NGPhysicalOffsetRect in more places in legacy code, but
don't want performance regressions caused by the additional function
calls. Some performance measurement (e.g. crrev.com/c/1567095) showed
that such small function calls can accumualte to quite big cost if they
are called very frequently.

Change-Id: I2bbe10669e1c7bbcfae2cf155536fab44136402e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1577586
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652904}
parent 4a634b73
......@@ -11,10 +11,6 @@
namespace blink {
bool NGPhysicalOffsetRect::operator==(const NGPhysicalOffsetRect& other) const {
return other.offset == offset && other.size == size;
}
bool NGPhysicalOffsetRect::Contains(const NGPhysicalOffsetRect& other) const {
return offset.left <= other.offset.left && offset.top <= other.offset.top &&
Right() >= other.Right() && Bottom() >= other.Bottom();
......@@ -84,14 +80,6 @@ void NGPhysicalOffsetRect::ExpandEdgesToPixelBoundaries() {
size.height = LayoutUnit(max_bottom - top);
}
NGPhysicalOffsetRect::NGPhysicalOffsetRect(const LayoutRect& source)
: NGPhysicalOffsetRect({source.X(), source.Y()},
{source.Width(), source.Height()}) {}
LayoutRect NGPhysicalOffsetRect::ToLayoutRect() const {
return {offset.left, offset.top, size.width, size.height};
}
LayoutRect NGPhysicalOffsetRect::ToLayoutFlippedRect(
const ComputedStyle& style,
const NGPhysicalSize& container_size) const {
......@@ -101,10 +89,6 @@ LayoutRect NGPhysicalOffsetRect::ToLayoutFlippedRect(
size.width, size.height};
}
FloatRect NGPhysicalOffsetRect::ToFloatRect() const {
return {offset.left, offset.top, size.width, size.height};
}
String NGPhysicalOffsetRect::ToString() const {
return String::Format("%s,%s %sx%s", offset.left.ToString().Ascii().data(),
offset.top.ToString().Ascii().data(),
......
......@@ -8,13 +8,13 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_offset.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_size.h"
#include "third_party/blink/renderer/platform/geometry/float_rect.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
namespace blink {
class ComputedStyle;
class FloatRect;
class LayoutRect;
struct NGPhysicalBoxStrut;
// NGPhysicalOffsetRect is the position and size of a rect (typically a
......@@ -32,7 +32,9 @@ struct CORE_EXPORT NGPhysicalOffsetRect {
LayoutUnit Right() const { return offset.left + size.width; }
LayoutUnit Bottom() const { return offset.top + size.height; }
bool operator==(const NGPhysicalOffsetRect& other) const;
bool operator==(const NGPhysicalOffsetRect& other) const {
return offset == other.offset && size == other.size;
}
bool Contains(const NGPhysicalOffsetRect& other) const;
......@@ -47,12 +49,15 @@ struct CORE_EXPORT NGPhysicalOffsetRect {
// Conversions from/to existing code. New code prefers type safety for
// logical/physical distinctions.
explicit NGPhysicalOffsetRect(const LayoutRect&);
LayoutRect ToLayoutRect() const;
explicit NGPhysicalOffsetRect(const LayoutRect& r)
: offset(r.X(), r.Y()), size(r.Width(), r.Height()) {}
LayoutRect ToLayoutRect() const {
return LayoutRect(offset.left, offset.top, size.width, size.height);
}
LayoutRect ToLayoutFlippedRect(const ComputedStyle&,
const NGPhysicalSize&) const;
FloatRect ToFloatRect() const;
FloatRect ToFloatRect() const { return FloatRect(ToLayoutRect()); }
String ToString() const;
};
......
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