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

Unified Diff: third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/SelectionModifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp
diff --git a/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp b/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp
index e1bcd3d9762f428ff549df615c0578a04aa3d26e..48c63c5e39c83a46fa1197eaa7571431192cc3f3 100644
--- a/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp
+++ b/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp
@@ -74,24 +74,25 @@ LayoutBlock* CaretDisplayItemClient::CaretLayoutBlock(const Node* node) {
}
static LayoutRect MapCaretRectToCaretPainter(
- LayoutItem caret_layout_item,
- LayoutBlockItem caret_painter_item,
- const LayoutRect& passed_caret_rect) {
+ const LayoutBlockItem& caret_painter_item,
+ const LocalCaretRect& caret_rect) {
// FIXME: This shouldn't be called on un-rooted subtrees.
// FIXME: This should probably just use mapLocalToAncestor.
// Compute an offset between the caretLayoutItem and the caretPainterItem.
+ LayoutItem caret_layout_item = LayoutItem(caret_rect.layout_object);
DCHECK(caret_layout_item.IsDescendantOf(caret_painter_item));
- LayoutRect caret_rect = passed_caret_rect;
+ LayoutRect result_rect = caret_rect.rect;
+ caret_painter_item.FlipForWritingMode(result_rect);
while (caret_layout_item != caret_painter_item) {
LayoutItem container_item = caret_layout_item.Container();
if (container_item.IsNull())
return LayoutRect();
- caret_rect.Move(caret_layout_item.OffsetFromContainer(container_item));
+ result_rect.Move(caret_layout_item.OffsetFromContainer(container_item));
caret_layout_item = container_item;
}
- return caret_rect;
+ return result_rect;
}
LayoutRect CaretDisplayItemClient::ComputeCaretRect(
@@ -102,19 +103,13 @@ LayoutRect CaretDisplayItemClient::ComputeCaretRect(
DCHECK(caret_position.AnchorNode()->GetLayoutObject());
// First compute a rect local to the layoutObject at the selection start.
- LayoutObject* layout_object;
- const LayoutRect& caret_local_rect =
- LocalCaretRectOfPosition(caret_position, layout_object);
+ const LocalCaretRect& caret_rect = LocalCaretRectOfPosition(caret_position);
// Get the layoutObject that will be responsible for painting the caret
// (which is either the layoutObject we just found, or one of its containers).
- LayoutBlockItem caret_painter_item =
+ const LayoutBlockItem caret_painter_item =
LayoutBlockItem(CaretLayoutBlock(caret_position.AnchorNode()));
- LayoutRect caret_local_rect_with_writing_mode = caret_local_rect;
- caret_painter_item.FlipForWritingMode(caret_local_rect_with_writing_mode);
- return MapCaretRectToCaretPainter(LayoutItem(layout_object),
- caret_painter_item,
- caret_local_rect_with_writing_mode);
+ return MapCaretRectToCaretPainter(caret_painter_item, caret_rect);
}
void CaretDisplayItemClient::ClearPreviousVisualRect(const LayoutBlock& block) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/SelectionModifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698