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

Unified Diff: third_party/WebKit/Source/core/layout/ng/geometry/ng_margin_strut.cc

Issue 2721613003: [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Don't export NGBoxStrut for now Created 3 years, 10 months 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: third_party/WebKit/Source/core/layout/ng/geometry/ng_margin_strut.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/geometry/ng_margin_strut.cc b/third_party/WebKit/Source/core/layout/ng/geometry/ng_margin_strut.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eabab22f543b5541cc8125bc0bc438567d0e6030
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/geometry/ng_margin_strut.cc
@@ -0,0 +1,35 @@
+// 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 "core/layout/ng/geometry/ng_margin_strut.h"
+
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+LayoutUnit NGMarginStrut::Sum() const {
+ return margin + negative_margin;
+}
+
+bool NGMarginStrut::operator==(const NGMarginStrut& other) const {
+ return margin == other.margin && negative_margin == other.negative_margin;
+}
+
+void NGMarginStrut::Append(const LayoutUnit& value) {
+ if (value < 0) {
+ negative_margin = std::min(value, negative_margin);
+ } else {
+ margin = std::max(value, margin);
+ }
+}
+
+String NGMarginStrut::ToString() const {
+ return String::format("%d %d", margin.toInt(), negative_margin.toInt());
+}
+
+std::ostream& operator<<(std::ostream& stream, const NGMarginStrut& value) {
+ return stream << value.ToString();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698