Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ax_relative_bounds.cc
Go to the documentation of this file.
1// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <cmath>
8
9#include "ax_enum_util.h"
10#include "base/string_utils.h"
11
13
14namespace ui {
15
16AXRelativeBounds::AXRelativeBounds() : offset_container_id(-1) {}
17
19
22 bounds = other.bounds;
23 if (other.transform)
24 transform = std::make_unique<gfx::Transform>(*other.transform);
25}
26
29 bounds = other.bounds;
30 if (other.transform)
31 transform = std::make_unique<gfx::Transform>(*other.transform);
32 else
33 transform.reset(nullptr);
34 return *this;
35}
36
39 return false;
40 if (bounds != other.bounds)
41 return false;
42 if (!transform && !other.transform)
43 return true;
44 if ((transform && !other.transform) || (!transform && other.transform))
45 return false;
46 return *transform == *other.transform;
47}
48
50 return !operator==(other);
51}
52
53std::string AXRelativeBounds::ToString() const {
54 std::string result;
55
56 if (offset_container_id != -1)
57 result += "offset_container_id=" +
58 NumberToString(static_cast<int>(round(offset_container_id))) +
59 " ";
60
61 result += "(" + NumberToString(static_cast<int>(round(bounds.x()))) + ", " +
62 NumberToString(static_cast<int>(round(bounds.y()))) + ")-(" +
63 NumberToString(static_cast<int>(round(bounds.width()))) + ", " +
64 NumberToString(static_cast<int>(round(bounds.height()))) + ")";
65
66 if (transform && !transform->IsIdentity())
67 result += " transform=" + transform->ToString();
68
69 return result;
70}
71
72std::ostream& operator<<(std::ostream& stream, const AXRelativeBounds& bounds) {
73 return stream << bounds.ToString();
74}
75
76} // namespace ui
static void round(SkPoint *p)
constexpr float y() const
Definition rect_f.h:50
constexpr float width() const
Definition rect_f.h:53
constexpr float height() const
Definition rect_f.h:56
constexpr float x() const
Definition rect_f.h:47
GAsyncResult * result
std::string NumberToString(int32_t number)
std::ostream & operator<<(std::ostream &os, AXEventGenerator::Event event)
AXRelativeBounds & operator=(AXRelativeBounds other)
bool operator!=(const AXRelativeBounds &other) const
std::string ToString() const
std::unique_ptr< gfx::Transform > transform
bool operator==(const AXRelativeBounds &other) const