render_frame_metadata_mojom_traits.cc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 "cc/mojom/render_frame_metadata_mojom_traits.h"
  5. #include "build/build_config.h"
  6. #include "mojo/public/cpp/base/time_mojom_traits.h"
  7. #include "services/viz/public/cpp/compositing/selection_mojom_traits.h"
  8. #include "services/viz/public/cpp/compositing/vertical_scroll_direction_mojom_traits.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. #include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
  11. #include "ui/gfx/mojom/selection_bound_mojom_traits.h"
  12. namespace mojo {
  13. // static
  14. bool StructTraits<cc::mojom::DelegatedInkBrowserMetadataDataView,
  15. cc::DelegatedInkBrowserMetadata>::
  16. Read(cc::mojom::DelegatedInkBrowserMetadataDataView data,
  17. cc::DelegatedInkBrowserMetadata* out) {
  18. out->delegated_ink_is_hovering = data.delegated_ink_is_hovering();
  19. return true;
  20. }
  21. // static
  22. bool StructTraits<
  23. cc::mojom::RenderFrameMetadataDataView,
  24. cc::RenderFrameMetadata>::Read(cc::mojom::RenderFrameMetadataDataView data,
  25. cc::RenderFrameMetadata* out) {
  26. out->is_scroll_offset_at_top = data.is_scroll_offset_at_top();
  27. out->is_mobile_optimized = data.is_mobile_optimized();
  28. out->device_scale_factor = data.device_scale_factor();
  29. out->page_scale_factor = data.page_scale_factor();
  30. out->external_page_scale_factor = data.external_page_scale_factor();
  31. out->top_controls_height = data.top_controls_height();
  32. out->top_controls_shown_ratio = data.top_controls_shown_ratio();
  33. #if BUILDFLAG(IS_ANDROID)
  34. out->bottom_controls_height = data.bottom_controls_height();
  35. out->bottom_controls_shown_ratio = data.bottom_controls_shown_ratio();
  36. out->top_controls_min_height_offset = data.top_controls_min_height_offset();
  37. out->bottom_controls_min_height_offset =
  38. data.bottom_controls_min_height_offset();
  39. out->min_page_scale_factor = data.min_page_scale_factor();
  40. out->max_page_scale_factor = data.max_page_scale_factor();
  41. out->root_overflow_y_hidden = data.root_overflow_y_hidden();
  42. out->has_transparent_background = data.has_transparent_background();
  43. #endif
  44. return data.ReadRootScrollOffset(&out->root_scroll_offset) &&
  45. data.ReadSelection(&out->selection) &&
  46. data.ReadDelegatedInkMetadata(&out->delegated_ink_metadata) &&
  47. #if BUILDFLAG(IS_ANDROID)
  48. data.ReadScrollableViewportSize(&out->scrollable_viewport_size) &&
  49. data.ReadRootLayerSize(&out->root_layer_size) &&
  50. #endif
  51. data.ReadViewportSizeInPixels(&out->viewport_size_in_pixels) &&
  52. data.ReadLocalSurfaceId(&out->local_surface_id) &&
  53. data.ReadNewVerticalScrollDirection(
  54. &out->new_vertical_scroll_direction) &&
  55. data.ReadPreviousSurfacesVisualUpdateDuration(
  56. &out->previous_surfaces_visual_update_duration) &&
  57. data.ReadCurrentSurfaceVisualUpdateDuration(
  58. &out->current_surface_visual_update_duration) &&
  59. data.ReadRootBackgroundColor(&out->root_background_color);
  60. }
  61. } // namespace mojo