blob: 397a58112584d3d74fdd33788f81fa6809b74141 (
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
54
55
56
57
58
|
// Copyright 2017 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.
#ifndef NGBfcRect_h
#define NGBfcRect_h
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_offset.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_logical_size.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
namespace blink {
// NGBfcRect is the position and size of a rect (typically a fragment)
// relative to a block formatting context.
struct CORE_EXPORT NGBfcRect {
NGBfcRect(const NGBfcOffset& start_offset, const NGBfcOffset& end_offset)
: start_offset(start_offset), end_offset(end_offset) {
DCHECK_GE(end_offset.line_offset, start_offset.line_offset);
DCHECK_GE(end_offset.block_offset, start_offset.block_offset);
}
bool IsEmpty() const;
LayoutUnit LineStartOffset() const { return start_offset.line_offset; }
LayoutUnit LineEndOffset() const { return end_offset.line_offset; }
LayoutUnit BlockStartOffset() const { return start_offset.block_offset; }
LayoutUnit BlockEndOffset() const { return end_offset.block_offset; }
NGBfcOffset LineEndBlockStartOffset() const {
return {LineEndOffset(), BlockStartOffset()};
}
LayoutUnit BlockSize() const {
if (end_offset.block_offset == LayoutUnit::Max())
return LayoutUnit::Max();
return end_offset.block_offset - start_offset.block_offset;
}
LayoutUnit InlineSize() const {
if (end_offset.line_offset == LayoutUnit::Max())
return LayoutUnit::Max();
return end_offset.line_offset - start_offset.line_offset;
}
NGLogicalSize Size() const { return {InlineSize(), BlockSize()}; }
bool operator==(const NGBfcRect& other) const;
bool operator!=(const NGBfcRect& other) const { return !(*this == other); }
NGBfcOffset start_offset;
NGBfcOffset end_offset;
};
} // namespace blink
#endif // NGBfcRect_h
|