blob: 055f69cfb85a6ef8b568532b1e0e50429689cafe (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2018 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/core/frame/display_cutout_client_impl.h"
#include "third_party/blink/renderer/core/css/document_style_environment_variables.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
namespace blink {
namespace {
const char kSafeAreaInsetTopName[] = "safe-area-inset-top";
const char kSafeAreaInsetLeftName[] = "safe-area-inset-left";
const char kSafeAreaInsetBottomName[] = "safe-area-inset-bottom";
const char kSafeAreaInsetRightName[] = "safe-area-inset-right";
String GetPx(int value) {
return String::Format("%dpx", value);
}
} // namespace
DisplayCutoutClientImpl::DisplayCutoutClientImpl(
LocalFrame* frame,
mojom::blink::DisplayCutoutClientAssociatedRequest request)
: frame_(frame), binding_(this, std::move(request)) {}
void DisplayCutoutClientImpl::BindMojoRequest(
LocalFrame* frame,
mojom::blink::DisplayCutoutClientAssociatedRequest request) {
if (!frame)
return;
new DisplayCutoutClientImpl(frame, std::move(request));
}
void DisplayCutoutClientImpl::SetSafeArea(
mojom::blink::DisplayCutoutSafeAreaPtr safe_area) {
DocumentStyleEnvironmentVariables& vars =
frame_->GetDocument()->GetStyleEngine().EnsureEnvironmentVariables();
vars.SetVariable(kSafeAreaInsetTopName, GetPx(safe_area->top));
vars.SetVariable(kSafeAreaInsetLeftName, GetPx(safe_area->left));
vars.SetVariable(kSafeAreaInsetBottomName, GetPx(safe_area->bottom));
vars.SetVariable(kSafeAreaInsetRightName, GetPx(safe_area->right));
}
void DisplayCutoutClientImpl::Trace(Visitor* visitor) {
visitor->Trace(frame_);
}
} // namespace blink
|