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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_UNPOSITIONED_FLOAT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_UNPOSITIONED_FLOAT_H_
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/block_break_token.h"
#include "third_party/blink/renderer/core/layout/block_node.h"
#include "third_party/blink/renderer/core/layout/geometry/bfc_offset.h"
#include "third_party/blink/renderer/core/layout/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/layout_result.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
namespace blink {
class ComputedStyle;
class ConstraintSpace;
// Struct that keeps all information needed to position floats in LayoutNG.
struct CORE_EXPORT UnpositionedFloat final {
STACK_ALLOCATED();
public:
UnpositionedFloat(BlockNode node,
const BlockBreakToken* token,
const LogicalSize available_size,
const LogicalSize percentage_size,
const BfcOffset& origin_bfc_offset,
const ConstraintSpace& parent_space,
const ComputedStyle& parent_style,
LayoutUnit fragmentainer_block_size,
LayoutUnit fragmentainer_block_offset,
bool is_hidden_for_paint)
: node(node),
token(token),
available_size(available_size),
percentage_size(percentage_size),
origin_bfc_offset(origin_bfc_offset),
parent_space(parent_space),
parent_style(parent_style),
fragmentainer_block_size(fragmentainer_block_size),
fragmentainer_block_offset(fragmentainer_block_offset),
is_hidden_for_paint(is_hidden_for_paint) {}
BlockNode node;
const BlockBreakToken* token = nullptr;
const LogicalSize available_size;
const LogicalSize percentage_size;
const BfcOffset origin_bfc_offset;
const ConstraintSpace& parent_space;
const ComputedStyle& parent_style;
LayoutUnit fragmentainer_block_size;
LayoutUnit fragmentainer_block_offset;
bool is_hidden_for_paint;
// layout_result and margins are used as a cache when measuring the
// inline_size of a float in an inline context.
const LayoutResult* layout_result = nullptr;
BoxStrut margins;
bool IsLineLeft(TextDirection cb_direction) const {
return node.Style().Floating(cb_direction) == EFloat::kLeft;
}
bool IsLineRight(TextDirection cb_direction) const {
return node.Style().Floating(cb_direction) == EFloat::kRight;
}
EClear ClearType(TextDirection cb_direction) const {
return node.Style().Clear(cb_direction);
}
// Same as blink::FragmentainerSpaceLeft(), but with a different signature.
LayoutUnit FragmentainerSpaceLeft() const {
LayoutUnit space = fragmentainer_block_size - fragmentainer_block_offset;
return space.ClampNegativeToZero();
}
// Same as blink::FragmentainerOffsetAtBfc(), but with a different signature.
LayoutUnit FragmentainerOffsetAtBfc() const {
return fragmentainer_block_offset - parent_space.ExpectedBfcBlockOffset();
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_UNPOSITIONED_FLOAT_H_
|