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

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-07T19:07:35 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 FloatQuad LocalToAbsoluteQuad() const;
Xiaocheng 2017/06/08 21:00:42 This function is only used within VisibleUnits.cpp
yosin_UTC9 2017/06/09 06:13:29 Done.
78 };
79
67 // The print for |InlineBoxPosition| is available only for testing 80 // The print for |InlineBoxPosition| is available only for testing
68 // in "webkit_unit_tests", and implemented in 81 // in "webkit_unit_tests", and implemented in
69 // "core/editing/VisibleUnitsTest.cpp". 82 // "core/editing/VisibleUnitsTest.cpp".
70 std::ostream& operator<<(std::ostream&, const InlineBoxPosition&); 83 std::ostream& operator<<(std::ostream&, const InlineBoxPosition&);
71 84
72 CORE_EXPORT LayoutObject* AssociatedLayoutObjectOf(const Node&, 85 CORE_EXPORT LayoutObject* AssociatedLayoutObjectOf(const Node&,
73 int offset_in_node); 86 int offset_in_node);
74 87
75 // offset functions on Node 88 // offset functions on Node
76 CORE_EXPORT int CaretMinOffset(const Node*); 89 CORE_EXPORT int CaretMinOffset(const Node*);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 TextDirection primary_direction); 326 TextDirection primary_direction);
314 CORE_EXPORT InlineBoxPosition 327 CORE_EXPORT InlineBoxPosition
315 ComputeInlineBoxPosition(const PositionInFlatTree&, TextAffinity); 328 ComputeInlineBoxPosition(const PositionInFlatTree&, TextAffinity);
316 CORE_EXPORT InlineBoxPosition 329 CORE_EXPORT InlineBoxPosition
317 ComputeInlineBoxPosition(const PositionInFlatTree&, 330 ComputeInlineBoxPosition(const PositionInFlatTree&,
318 TextAffinity, 331 TextAffinity,
319 TextDirection primary_direction); 332 TextDirection primary_direction);
320 CORE_EXPORT InlineBoxPosition ComputeInlineBoxPosition(const VisiblePosition&); 333 CORE_EXPORT InlineBoxPosition ComputeInlineBoxPosition(const VisiblePosition&);
321 334
322 // Rect is local to the returned layoutObject 335 // Rect is local to the returned layoutObject
323 CORE_EXPORT LayoutRect LocalCaretRectOfPosition(const PositionWithAffinity&, 336 CORE_EXPORT LocalCaretRect
324 LayoutObject*&); 337 LocalCaretRectOfPosition(const PositionWithAffinity&);
325 CORE_EXPORT LayoutRect 338 CORE_EXPORT LocalCaretRect
326 LocalCaretRectOfPosition(const PositionInFlatTreeWithAffinity&, LayoutObject*&); 339 LocalCaretRectOfPosition(const PositionInFlatTreeWithAffinity&);
327 bool HasRenderedNonAnonymousDescendantsWithHeight(LayoutObject*); 340 bool HasRenderedNonAnonymousDescendantsWithHeight(LayoutObject*);
328 341
329 // Returns a hit-tested VisiblePosition for the given point in contents-space 342 // Returns a hit-tested VisiblePosition for the given point in contents-space
330 // coordinates. 343 // coordinates.
331 CORE_EXPORT VisiblePosition VisiblePositionForContentsPoint(const IntPoint&, 344 CORE_EXPORT VisiblePosition VisiblePositionForContentsPoint(const IntPoint&,
332 LocalFrame*); 345 LocalFrame*);
333 346
334 CORE_EXPORT bool RendersInDifferentPosition(const Position&, const Position&); 347 CORE_EXPORT bool RendersInDifferentPosition(const Position&, const Position&);
335 348
336 CORE_EXPORT Position SkipWhitespace(const Position&); 349 CORE_EXPORT Position SkipWhitespace(const Position&);
(...skipping 26 matching lines...) Expand all
363 const VisiblePosition&, 376 const VisiblePosition&,
364 EditableType); 377 EditableType);
365 378
366 Position PreviousRootInlineBoxCandidatePosition(Node*, 379 Position PreviousRootInlineBoxCandidatePosition(Node*,
367 const VisiblePosition&, 380 const VisiblePosition&,
368 EditableType); 381 EditableType);
369 382
370 } // namespace blink 383 } // namespace blink
371 384
372 #endif // VisibleUnits_h 385 #endif // VisibleUnits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698