ax_relative_bounds_mojom_traits.cc 995 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 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. #include "ui/accessibility/mojom/ax_relative_bounds_mojom_traits.h"
  5. namespace mojo {
  6. // static
  7. gfx::Transform
  8. StructTraits<ax::mojom::AXRelativeBoundsDataView,
  9. ui::AXRelativeBounds>::transform(const ui::AXRelativeBounds& p) {
  10. if (p.transform)
  11. return *p.transform;
  12. else
  13. return gfx::Transform();
  14. }
  15. // static
  16. bool StructTraits<ax::mojom::AXRelativeBoundsDataView, ui::AXRelativeBounds>::
  17. Read(ax::mojom::AXRelativeBoundsDataView data, ui::AXRelativeBounds* out) {
  18. out->offset_container_id = data.offset_container_id();
  19. gfx::Transform transform;
  20. if (!data.ReadTransform(&transform))
  21. return false;
  22. if (!transform.IsIdentity())
  23. out->transform = std::make_unique<gfx::Transform>(transform);
  24. if (!data.ReadBounds(&out->bounds))
  25. return false;
  26. return true;
  27. }
  28. } // namespace mojo