Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.h

Issue 2926823002: Introduce LocalCaretRect for refactoring Local{Caret,Selection}RectPosition() (Closed)
Patch Set: 2017-06-09T15:11:53 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool operator==(const InlineBoxPosition& other) const { 57 bool operator==(const InlineBoxPosition& other) const {
58 return inline_box == other.inline_box && 58 return inline_box == other.inline_box &&
59 offset_in_box == other.offset_in_box; 59 offset_in_box == other.offset_in_box;
60 } 60 }
61 61
62 bool operator!=(const InlineBoxPosition& other) const { 62 bool operator!=(const InlineBoxPosition& other) const {
63 return !operator==(other); 63 return !operator==(other);
64 } 64 }
65 }; 65 };
66 66
67 // This struct represents local caret rectangle in |layout_object|.
68 struct LocalCaretRect {
69 LayoutObject* layout_object = nullptr;
70 LayoutRect rect;
71
72 LocalCaretRect() = default;
73 LocalCaretRect(LayoutObject* layout_object, const LayoutRect& rect)
74 : layout_object(layout_object), rect(rect) {}
75
76 bool IsEmpty() const { return !layout_object || rect.IsEmpty(); }
77 };
78
67 // The print for |InlineBoxPosition| is available only for testing 79 // The print for |InlineBoxPosition| is available only for testing
68 // in "webkit_unit_tests", and implemented in 80 // in "webkit_unit_tests", and implemented in
69 // "core/editing/VisibleUnitsTest.cpp". 81 // "core/editing/VisibleUnitsTest.cpp".
70 std::ostream& operator<<(std::ostream&, const InlineBoxPosition&); 82 std::ostream& operator<<(std::ostream&, const InlineBoxPosition&);
71 83
72 CORE_EXPORT LayoutObject* AssociatedLayoutObjectOf(const Node&, 84 CORE_EXPORT LayoutObject* AssociatedLayoutObjectOf(const Node&,
73 int offset_in_node); 85 int offset_in_node);
74 86
75 // offset functions on Node 87 // offset functions on Node
76 CORE_EXPORT int CaretMinOffset(const Node*); 88 CORE_EXPORT int CaretMinOffset(const Node*);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 TextDirection primary_direction); 324 TextDirection primary_direction);
313 CORE_EXPORT InlineBoxPosition 325 CORE_EXPORT InlineBoxPosition
314 ComputeInlineBoxPosition(const PositionInFlatTree&, TextAffinity); 326 ComputeInlineBoxPosition(const PositionInFlatTree&, TextAffinity);
315 CORE_EXPORT InlineBoxPosition 327 CORE_EXPORT InlineBoxPosition
316 ComputeInlineBoxPosition(const PositionInFlatTree&, 328 ComputeInlineBoxPosition(const PositionInFlatTree&,
317 TextAffinity, 329 TextAffinity,
318 TextDirection primary_direction); 330 TextDirection primary_direction);
319 CORE_EXPORT InlineBoxPosition ComputeInlineBoxPosition(const VisiblePosition&); 331 CORE_EXPORT InlineBoxPosition ComputeInlineBoxPosition(const VisiblePosition&);
320 332
321 // Rect is local to the returned layoutObject 333 // Rect is local to the returned layoutObject
322 CORE_EXPORT LayoutRect LocalCaretRectOfPosition(const PositionWithAffinity&, 334 CORE_EXPORT LocalCaretRect
323 LayoutObject*&); 335 LocalCaretRectOfPosition(const PositionWithAffinity&);
324 CORE_EXPORT LayoutRect 336 CORE_EXPORT LocalCaretRect
325 LocalCaretRectOfPosition(const PositionInFlatTreeWithAffinity&, LayoutObject*&); 337 LocalCaretRectOfPosition(const PositionInFlatTreeWithAffinity&);
326 bool HasRenderedNonAnonymousDescendantsWithHeight(LayoutObject*); 338 bool HasRenderedNonAnonymousDescendantsWithHeight(LayoutObject*);
327 339
328 // Returns a hit-tested VisiblePosition for the given point in contents-space 340 // Returns a hit-tested VisiblePosition for the given point in contents-space
329 // coordinates. 341 // coordinates.
330 CORE_EXPORT VisiblePosition VisiblePositionForContentsPoint(const IntPoint&, 342 CORE_EXPORT VisiblePosition VisiblePositionForContentsPoint(const IntPoint&,
331 LocalFrame*); 343 LocalFrame*);
332 344
333 CORE_EXPORT bool RendersInDifferentPosition(const Position&, const Position&); 345 CORE_EXPORT bool RendersInDifferentPosition(const Position&, const Position&);
334 346
335 CORE_EXPORT Position SkipWhitespace(const Position&); 347 CORE_EXPORT Position SkipWhitespace(const Position&);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 const VisiblePosition&, 392 const VisiblePosition&,
381 EditableType); 393 EditableType);
382 394
383 Position PreviousRootInlineBoxCandidatePosition(Node*, 395 Position PreviousRootInlineBoxCandidatePosition(Node*,
384 const VisiblePosition&, 396 const VisiblePosition&,
385 EditableType); 397 EditableType);
386 398
387 } // namespace blink 399 } // namespace blink
388 400
389 #endif // VisibleUnits_h 401 #endif // VisibleUnits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionModifier.cpp ('k') | third_party/WebKit/Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698