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

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

Issue 2894803002: Use current selection when tab navigation. (Closed)
Patch Set: Fix selection direction Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 4101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4112 layout_text.AbsoluteRectsForRange(rects, start, end); 4112 layout_text.AbsoluteRectsForRange(rects, start, end);
4113 } 4113 }
4114 4114
4115 static void CollectAbsoluteBoundsForRange(unsigned start, 4115 static void CollectAbsoluteBoundsForRange(unsigned start,
4116 unsigned end, 4116 unsigned end,
4117 const LayoutText& layout_text, 4117 const LayoutText& layout_text,
4118 Vector<FloatQuad>& quads) { 4118 Vector<FloatQuad>& quads) {
4119 layout_text.AbsoluteQuadsForRange(quads, start, end); 4119 layout_text.AbsoluteQuadsForRange(quads, start, end);
4120 } 4120 }
4121 4121
4122 template <typename RectType> 4122 template <typename RectType, typename Strategy>
4123 static Vector<RectType> ComputeTextBounds(const EphemeralRange& range) { 4123 static Vector<RectType> ComputeTextBounds(
4124 const Position& start_position = range.StartPosition(); 4124 const EphemeralRangeTemplate<Strategy>& range) {
4125 const Position& end_position = range.EndPosition(); 4125 const PositionTemplate<Strategy>& start_position = range.StartPosition();
4126 const PositionTemplate<Strategy>& end_position = range.EndPosition();
4126 Node* const start_container = start_position.ComputeContainerNode(); 4127 Node* const start_container = start_position.ComputeContainerNode();
4127 DCHECK(start_container); 4128 DCHECK(start_container);
4128 Node* const end_container = end_position.ComputeContainerNode(); 4129 Node* const end_container = end_position.ComputeContainerNode();
4129 DCHECK(end_container); 4130 DCHECK(end_container);
4130 4131
4131 Vector<RectType> result; 4132 Vector<RectType> result;
4132 for (const Node& node : range.Nodes()) { 4133 for (const Node& node : range.Nodes()) {
4133 LayoutObject* const layout_object = node.GetLayoutObject(); 4134 LayoutObject* const layout_object = node.GetLayoutObject();
4134 if (!layout_object || !layout_object->IsText()) 4135 if (!layout_object || !layout_object->IsText())
4135 continue; 4136 continue;
4136 const LayoutText* layout_text = ToLayoutText(layout_object); 4137 const LayoutText* layout_text = ToLayoutText(layout_object);
4137 unsigned start_offset = 4138 unsigned start_offset =
4138 node == start_container ? start_position.OffsetInContainerNode() : 0; 4139 node == start_container ? start_position.OffsetInContainerNode() : 0;
4139 unsigned end_offset = node == end_container 4140 unsigned end_offset = node == end_container
4140 ? end_position.OffsetInContainerNode() 4141 ? end_position.OffsetInContainerNode()
4141 : std::numeric_limits<unsigned>::max(); 4142 : std::numeric_limits<unsigned>::max();
4142 CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text, 4143 CollectAbsoluteBoundsForRange(start_offset, end_offset, *layout_text,
4143 result); 4144 result);
4144 } 4145 }
4145 return result; 4146 return result;
4146 } 4147 }
4147 4148
4148 IntRect ComputeTextRect(const EphemeralRange& range) { 4149 template <typename Strategy>
4150 static IntRect ComputeTextRectTemplate(
4151 const EphemeralRangeTemplate<Strategy>& range) {
4149 IntRect result; 4152 IntRect result;
4150 const Vector<IntRect>& rects = ComputeTextBounds<IntRect>(range); 4153 const Vector<IntRect>& rects = ComputeTextBounds<IntRect, Strategy>(range);
4151 for (const IntRect& rect : rects) 4154 for (const IntRect& rect : rects)
4152 result.Unite(rect); 4155 result.Unite(rect);
4153 return result; 4156 return result;
4154 } 4157 }
4155 4158
4159 IntRect ComputeTextRect(const EphemeralRange& range) {
4160 return ComputeTextRectTemplate(range);
4161 }
4162
4163 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
4164 return ComputeTextRectTemplate(range);
4165 }
4166
4156 Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) { 4167 Vector<FloatQuad> ComputeTextQuads(const EphemeralRange& range) {
4157 return ComputeTextBounds<FloatQuad>(range); 4168 return ComputeTextBounds<FloatQuad>(range);
4158 } 4169 }
4159 4170
4160 } // namespace blink 4171 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698