mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
81c895fb3f
Summary: Fix warnings about implicit type truncation. ## Changelog [Internal] [Fixed] - Fix various C++ warnings Pull Request resolved: https://github.com/facebook/react-native/pull/31002 Test Plan: Almost all the changes here are simply making explicit conversions which are already occurring. With the exception of a couple of constants being changed from doubles to floats. With these changes I am able to remove a bunch of warning suppressions in react-native-windows. Reviewed By: shergin Differential Revision: D26900502 Pulled By: rozele fbshipit-source-id: d5e415282815c2212a840a863713287bbf118c10
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "TextMeasureCache.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
static Rect rectFromDynamic(folly::dynamic const &data) {
|
|
Point origin;
|
|
origin.x = static_cast<Float>(data.getDefault("x", 0).getDouble());
|
|
origin.y = static_cast<Float>(data.getDefault("y", 0).getDouble());
|
|
Size size;
|
|
size.width = static_cast<Float>(data.getDefault("width", 0).getDouble());
|
|
size.height = static_cast<Float>(data.getDefault("height", 0).getDouble());
|
|
Rect frame;
|
|
frame.origin = origin;
|
|
frame.size = size;
|
|
return frame;
|
|
}
|
|
|
|
LineMeasurement::LineMeasurement(
|
|
std::string text,
|
|
Rect frame,
|
|
Float descender,
|
|
Float capHeight,
|
|
Float ascender,
|
|
Float xHeight)
|
|
: text(text),
|
|
frame(frame),
|
|
descender(descender),
|
|
capHeight(capHeight),
|
|
ascender(ascender) {}
|
|
|
|
LineMeasurement::LineMeasurement(folly::dynamic const &data)
|
|
: text(data.getDefault("text", "").getString()),
|
|
frame(rectFromDynamic(data)),
|
|
descender(
|
|
static_cast<Float>(data.getDefault("descender", 0).getDouble())),
|
|
capHeight(
|
|
static_cast<Float>(data.getDefault("capHeight", 0).getDouble())),
|
|
ascender(static_cast<Float>(data.getDefault("ascender", 0).getDouble())),
|
|
xHeight(static_cast<Float>(data.getDefault("xHeight", 0).getDouble())) {}
|
|
|
|
bool LineMeasurement::operator==(LineMeasurement const &rhs) const {
|
|
return std::tie(
|
|
this->text,
|
|
this->frame,
|
|
this->descender,
|
|
this->capHeight,
|
|
this->ascender,
|
|
this->xHeight) ==
|
|
std::tie(
|
|
rhs.text,
|
|
rhs.frame,
|
|
rhs.descender,
|
|
rhs.capHeight,
|
|
rhs.ascender,
|
|
rhs.xHeight);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|