blob: 3a9c15a82b8f97e8cf1e4317d3c22caffacafa05 (
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 2016 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 THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_LOCAL_CARET_RECT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_LOCAL_CARET_RECT_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/editing/forward.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
namespace blink {
class LayoutObject;
// A transient struct representing a caret rect local to |layout_object|.
struct LocalCaretRect {
STACK_ALLOCATED();
public:
const LayoutObject* layout_object = nullptr;
LayoutRect rect;
LocalCaretRect() = default;
LocalCaretRect(const LayoutObject* layout_object, const LayoutRect& rect)
: layout_object(layout_object), rect(rect) {}
bool IsEmpty() const { return !layout_object || rect.IsEmpty(); }
};
// Rect is local to the returned layoutObject
// TODO(xiaochengh): Get rid of the default parameter.
CORE_EXPORT LocalCaretRect LocalCaretRectOfPosition(
const PositionWithAffinity&,
LayoutUnit* /* extra_width_to_end_of_line */ = nullptr);
CORE_EXPORT LocalCaretRect
LocalCaretRectOfPosition(const PositionInFlatTreeWithAffinity&);
LocalCaretRect LocalSelectionRectOfPosition(const PositionWithAffinity&);
// Bounds of (possibly transformed) caret in absolute coords
CORE_EXPORT IntRect AbsoluteCaretBoundsOf(const VisiblePosition&);
CORE_EXPORT IntRect AbsoluteCaretBoundsOf(const VisiblePositionInFlatTree&);
IntRect AbsoluteCaretRectOfPosition(
const PositionWithAffinity&,
LayoutUnit* extra_width_to_end_of_line = nullptr);
CORE_EXPORT IntRect AbsoluteSelectionBoundsOf(const VisiblePosition&);
CORE_EXPORT IntRect AbsoluteSelectionBoundsOf(const VisiblePositionInFlatTree&);
// Exposed to tests only. Implemented in LocalCaretRectTest.cpp.
bool operator==(const LocalCaretRect&, const LocalCaretRect&);
std::ostream& operator<<(std::ostream&, const LocalCaretRect&);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_LOCAL_CARET_RECT_H_
|