summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/layout_unit.cc
blob: e27c262080c6984d58d83c262467dca7e53f2467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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/platform/layout_unit.h"

#include <ostream>
#include "third_party/blink/renderer/platform/wtf/text/text_stream.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

namespace blink {

String LayoutUnit::ToString() const {
  if (value_ == LayoutUnit::Max().RawValue())
    return "LayoutUnit::max(" + String::Number(ToDouble()) + ")";
  if (value_ == LayoutUnit::Min().RawValue())
    return "LayoutUnit::min(" + String::Number(ToDouble()) + ")";
  if (value_ == LayoutUnit::NearlyMax().RawValue())
    return "LayoutUnit::nearlyMax(" + String::Number(ToDouble()) + ")";
  if (value_ == LayoutUnit::NearlyMin().RawValue())
    return "LayoutUnit::nearlyMin(" + String::Number(ToDouble()) + ")";
  return String::Number(ToDouble());
}

std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) {
  return stream << value.ToString();
}

WTF::TextStream& operator<<(WTF::TextStream& ts, const LayoutUnit& unit) {
  return ts << WTF::TextStream::FormatNumberRespectingIntegers(unit.ToDouble());
}

}  // namespace blink