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

Side by Side Diff: third_party/WebKit/Source/core/editing/CaretBase.cpp

Issue 2406163004: Simplify the usage of PositionWithAffinity (Closed)
Patch Set: Created 4 years, 2 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, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 caretLayoutItem = containerItem; 97 caretLayoutItem = containerItem;
98 } 98 }
99 99
100 if (unrooted) 100 if (unrooted)
101 caretRect = LayoutRect(); 101 caretRect = LayoutRect();
102 } 102 }
103 103
104 void CaretBase::updateCaretRect(const PositionWithAffinity& caretPosition) { 104 void CaretBase::updateCaretRect(const PositionWithAffinity& caretPosition) {
105 m_caretLocalRect = LayoutRect(); 105 m_caretLocalRect = LayoutRect();
106 106
107 if (caretPosition.position().isNull()) 107 if (caretPosition.isNull())
108 return; 108 return;
109 109
110 DCHECK(caretPosition.position().anchorNode()->layoutObject()); 110 DCHECK(caretPosition.anchorNode()->layoutObject());
111 111
112 // First compute a rect local to the layoutObject at the selection start. 112 // First compute a rect local to the layoutObject at the selection start.
113 LayoutObject* layoutObject; 113 LayoutObject* layoutObject;
114 m_caretLocalRect = localCaretRectOfPosition(caretPosition, layoutObject); 114 m_caretLocalRect = localCaretRectOfPosition(caretPosition, layoutObject);
115 115
116 // Get the layoutObject that will be responsible for painting the caret 116 // Get the layoutObject that will be responsible for painting the caret
117 // (which is either the layoutObject we just found, or one of its containers). 117 // (which is either the layoutObject we just found, or one of its containers).
118 LayoutBlockItem caretPainterItem = 118 LayoutBlockItem caretPainterItem =
119 LayoutBlockItem(caretLayoutObject(caretPosition.position().anchorNode())); 119 LayoutBlockItem(caretLayoutObject(caretPosition.anchorNode()));
120 120
121 mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem, 121 mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem,
122 m_caretLocalRect); 122 m_caretLocalRect);
123 } 123 }
124 124
125 void CaretBase::updateCaretRect(const VisiblePosition& caretPosition) { 125 void CaretBase::updateCaretRect(const VisiblePosition& caretPosition) {
126 updateCaretRect(caretPosition.toPositionWithAffinity()); 126 updateCaretRect(caretPosition.toPositionWithAffinity());
127 } 127 }
128 128
129 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, 129 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 String CaretBase::debugName() const { 197 String CaretBase::debugName() const {
198 return "Caret"; 198 return "Caret";
199 } 199 }
200 200
201 LayoutRect CaretBase::visualRect() const { 201 LayoutRect CaretBase::visualRect() const {
202 return m_visualRect; 202 return m_visualRect;
203 } 203 }
204 204
205 } // namespace blink 205 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/editing/DragCaretController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698