Commit 59ab4380 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[LayoutNG] Remove unused geometry structs.

As above. This should have no behaviour change.

Change-Id: I78cad0b91877f736bcb7432a8e0a38e2f017f724
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1525318
Auto-Submit: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641673}
parent ddf5eb65
...@@ -2028,7 +2028,6 @@ jumbo_source_set("unit_tests") { ...@@ -2028,7 +2028,6 @@ jumbo_source_set("unit_tests") {
"layout/ng/geometry/ng_logical_rect_test.cc", "layout/ng/geometry/ng_logical_rect_test.cc",
"layout/ng/geometry/ng_physical_offset_rect_test.cc", "layout/ng/geometry/ng_physical_offset_rect_test.cc",
"layout/ng/geometry/ng_physical_offset_test.cc", "layout/ng/geometry/ng_physical_offset_test.cc",
"layout/ng/geometry/ng_physical_rect_test.cc",
"layout/ng/inline/ng_baseline_test.cc", "layout/ng/inline/ng_baseline_test.cc",
"layout/ng/inline/ng_caret_navigator_test.cc", "layout/ng/inline/ng_caret_navigator_test.cc",
"layout/ng/inline/ng_caret_position_test.cc", "layout/ng/inline/ng_caret_position_test.cc",
......
...@@ -312,14 +312,10 @@ blink_core_sources("layout") { ...@@ -312,14 +312,10 @@ blink_core_sources("layout") {
"ng/geometry/ng_logical_size.h", "ng/geometry/ng_logical_size.h",
"ng/geometry/ng_margin_strut.cc", "ng/geometry/ng_margin_strut.cc",
"ng/geometry/ng_margin_strut.h", "ng/geometry/ng_margin_strut.h",
"ng/geometry/ng_physical_location.cc",
"ng/geometry/ng_physical_location.h",
"ng/geometry/ng_physical_offset.cc", "ng/geometry/ng_physical_offset.cc",
"ng/geometry/ng_physical_offset.h", "ng/geometry/ng_physical_offset.h",
"ng/geometry/ng_physical_offset_rect.cc", "ng/geometry/ng_physical_offset_rect.cc",
"ng/geometry/ng_physical_offset_rect.h", "ng/geometry/ng_physical_offset_rect.h",
"ng/geometry/ng_physical_rect.cc",
"ng/geometry/ng_physical_rect.h",
"ng/geometry/ng_physical_size.cc", "ng/geometry/ng_physical_size.cc",
"ng/geometry/ng_physical_size.h", "ng/geometry/ng_physical_size.h",
"ng/geometry/ng_static_position.cc", "ng/geometry/ng_static_position.cc",
......
// Copyright 2016 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.
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_location.h"
#include <ostream>
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
bool NGPhysicalLocation::operator==(const NGPhysicalLocation& other) const {
return other.left == left && other.top == top;
}
String NGPhysicalLocation::ToString() const {
return String::Format("%dx%d", left.ToInt(), top.ToInt());
}
std::ostream& operator<<(std::ostream& os, const NGPhysicalLocation& value) {
return os << value.ToString();
}
} // namespace blink
// Copyright 2016 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.
#ifndef NGPhysicalLocation_h
#define NGPhysicalLocation_h
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
namespace blink {
// NGPhysicalLocation is the position of a rect (typically a fragment) relative
// to the root document.
struct CORE_EXPORT NGPhysicalLocation {
NGPhysicalLocation() = default;
NGPhysicalLocation(LayoutUnit left, LayoutUnit top) : left(left), top(top) {}
LayoutUnit left;
LayoutUnit top;
bool operator==(const NGPhysicalLocation& other) const;
String ToString() const;
};
CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGPhysicalLocation&);
} // namespace blink
#endif // NGPhysicalLocation_h
// Copyright 2016 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.
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_rect.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
NGPixelSnappedPhysicalRect NGPhysicalRect::SnapToDevicePixels() const {
NGPixelSnappedPhysicalRect snapped_rect;
snapped_rect.left = RoundToInt(location.left);
snapped_rect.top = RoundToInt(location.top);
snapped_rect.width = SnapSizeToPixel(size.width, location.left);
snapped_rect.height = SnapSizeToPixel(size.height, location.top);
return snapped_rect;
}
bool NGPhysicalRect::operator==(const NGPhysicalRect& other) const {
return other.location == location && other.size == size;
}
String NGPhysicalRect::ToString() const {
return String::Format("%s,%s %sx%s", location.left.ToString().Ascii().data(),
location.top.ToString().Ascii().data(),
size.width.ToString().Ascii().data(),
size.height.ToString().Ascii().data());
}
std::ostream& operator<<(std::ostream& os, const NGPhysicalRect& value) {
return os << value.ToString();
}
} // namespace blink
// Copyright 2016 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.
#ifndef NGPhysicalRect_h
#define NGPhysicalRect_h
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_location.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_size.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
namespace blink {
// NGPixelSnappedPhysicalRect is the position and size of a rect relative to the
// root document snapped to device pixels.
struct CORE_EXPORT NGPixelSnappedPhysicalRect {
int top;
int left;
int width;
int height;
};
// NGPhysicalRect is the position and size of a rect (typically a fragment)
// relative to the root document.
struct CORE_EXPORT NGPhysicalRect {
NGPhysicalRect();
NGPhysicalRect(const NGPhysicalLocation& location, const NGPhysicalSize& size)
: location(location), size(size) {}
NGPhysicalLocation Location() const { return location; }
NGPhysicalSize Size() const { return size; }
NGPixelSnappedPhysicalRect SnapToDevicePixels() const;
NGPhysicalLocation location;
NGPhysicalSize size;
bool operator==(const NGPhysicalRect& other) const;
String ToString() const;
};
CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGPhysicalRect&);
} // namespace blink
#endif // NGPhysicalRect_h
// Copyright 2017 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.
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_rect.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
namespace {
TEST(NGGeometryUnitsTest, SnapToDevicePixels) {
NGPhysicalRect rect(NGPhysicalLocation(LayoutUnit(4.5), LayoutUnit(9.5)),
NGPhysicalSize(LayoutUnit(10.5), LayoutUnit(11.5)));
NGPixelSnappedPhysicalRect snapped_rect = rect.SnapToDevicePixels();
EXPECT_EQ(5, snapped_rect.left);
EXPECT_EQ(10, snapped_rect.top);
EXPECT_EQ(10, snapped_rect.width);
EXPECT_EQ(11, snapped_rect.height);
rect = NGPhysicalRect(NGPhysicalLocation(LayoutUnit(4), LayoutUnit(9)),
NGPhysicalSize(LayoutUnit(10.5), LayoutUnit(11.5)));
snapped_rect = rect.SnapToDevicePixels();
EXPECT_EQ(4, snapped_rect.left);
EXPECT_EQ(9, snapped_rect.top);
EXPECT_EQ(11, snapped_rect.width);
EXPECT_EQ(12, snapped_rect.height);
rect = NGPhysicalRect(NGPhysicalLocation(LayoutUnit(1.3), LayoutUnit(1.6)),
NGPhysicalSize(LayoutUnit(5.8), LayoutUnit(4.3)));
snapped_rect = rect.SnapToDevicePixels();
EXPECT_EQ(1, snapped_rect.left);
EXPECT_EQ(2, snapped_rect.top);
EXPECT_EQ(6, snapped_rect.width);
EXPECT_EQ(4, snapped_rect.height);
rect = NGPhysicalRect(NGPhysicalLocation(LayoutUnit(1.6), LayoutUnit(1.3)),
NGPhysicalSize(LayoutUnit(5.8), LayoutUnit(4.3)));
snapped_rect = rect.SnapToDevicePixels();
EXPECT_EQ(2, snapped_rect.left);
EXPECT_EQ(1, snapped_rect.top);
EXPECT_EQ(5, snapped_rect.width);
EXPECT_EQ(5, snapped_rect.height);
}
} // namespace
} // namespace blink
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