mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-08 18:23:13 +08:00
Summary: I was watching a classic magnificent talk about modern C++ by Herb Sutter and I was totally sold on double down on using `auto` in our codebase. Surprisingly, 95% of the code base already follows Herb's guidence; I just changed the last 5% to make it consistent. All those changes must work *exactly* like it was before. The talk: https://youtu.be/xnqTKD8uD64?t=28m25s Reviewed By: mdvacca Differential Revision: D9753301 fbshipit-source-id: 9629aa485a5d6e51806cc96306c297284d4f90b8
40 lines
975 B
C++
40 lines
975 B
C++
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ScrollViewShadowNode.h"
|
|
|
|
#include <fabric/core/LayoutMetrics.h>
|
|
|
|
#include "ScrollViewLocalData.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
const char ScrollViewComponentName[] = "ScrollView";
|
|
|
|
void ScrollViewShadowNode::updateLocalData() {
|
|
ensureUnsealed();
|
|
|
|
auto contentBoundingRect = Rect {};
|
|
for (const auto &childNode : getLayoutableChildNodes()) {
|
|
contentBoundingRect.unionInPlace(childNode->getLayoutMetrics().frame);
|
|
}
|
|
|
|
const auto &localData = std::make_shared<const ScrollViewLocalData>(contentBoundingRect);
|
|
setLocalData(localData);
|
|
}
|
|
|
|
#pragma mark - LayoutableShadowNode
|
|
|
|
void ScrollViewShadowNode::layout(LayoutContext layoutContext) {
|
|
ConcreteViewShadowNode::layout(layoutContext);
|
|
updateLocalData();
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|