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

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 1301423005: Move lineDirectionPointForBlockDirectionNavigationOf() to FrameSelection.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-01T12:40:26 Created 5 years, 3 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 | « no previous file | Source/core/editing/VisiblePosition.h » ('j') | 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, 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 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 } 1173 }
1174 1174
1175 if (userTriggered == UserTriggered) 1175 if (userTriggered == UserTriggered)
1176 m_granularity = CharacterGranularity; 1176 m_granularity = CharacterGranularity;
1177 1177
1178 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_frame) || alter == AlterationExtend); 1178 m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_frame) || alter == AlterationExtend);
1179 1179
1180 return true; 1180 return true;
1181 } 1181 }
1182 1182
1183 // Abs x/y position of the caret ignoring transforms.
1184 // TODO(yosin) navigation with transforms should be smarter.
1185 static int lineDirectionPointForBlockDirectionNavigationOf(const VisiblePosition & visiblePosition)
1186 {
1187 if (visiblePosition.isNull())
1188 return 0;
1189
1190 LayoutObject* layoutObject;
1191 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject);
1192 if (localRect.isEmpty() || !layoutObject)
1193 return 0;
1194
1195 // This ignores transforms on purpose, for now. Vertical navigation is done
1196 // without consulting transforms, so that 'up' in transformed text is 'up'
1197 // relative to the text, not absolute 'up'.
1198 FloatPoint caretPoint = layoutObject->localToAbsolute(FloatPoint(localRect.l ocation()));
1199 LayoutObject* containingBlock = layoutObject->containingBlock();
1200 if (!containingBlock)
1201 containingBlock = layoutObject; // Just use ourselves to determine the w riting mode if we have no containing block.
1202 return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPo int.y();
1203 }
1204
1183 LayoutUnit FrameSelection::lineDirectionPointForBlockDirectionNavigation(EPositi onType type) 1205 LayoutUnit FrameSelection::lineDirectionPointForBlockDirectionNavigation(EPositi onType type)
1184 { 1206 {
1185 LayoutUnit x = 0; 1207 LayoutUnit x = 0;
1186 1208
1187 if (isNone()) 1209 if (isNone())
1188 return x; 1210 return x;
1189 1211
1190 Position pos; 1212 Position pos;
1191 switch (type) { 1213 switch (type) {
1192 case START: 1214 case START:
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 2091
2070 void showTree(const blink::FrameSelection* sel) 2092 void showTree(const blink::FrameSelection* sel)
2071 { 2093 {
2072 if (sel) 2094 if (sel)
2073 sel->showTreeForThis(); 2095 sel->showTreeForThis();
2074 else 2096 else
2075 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 2097 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
2076 } 2098 }
2077 2099
2078 #endif 2100 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698