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

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

Issue 2786573002: Use EphemeralRange instead of Range in Range::isNodeFullyContainded (Closed)
Patch Set: update Created 3 years, 8 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, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 int comparePositions(const PositionWithAffinity& a, 287 int comparePositions(const PositionWithAffinity& a,
288 const PositionWithAffinity& b) { 288 const PositionWithAffinity& b) {
289 return comparePositions(a.position(), b.position()); 289 return comparePositions(a.position(), b.position());
290 } 290 }
291 291
292 int comparePositions(const VisiblePosition& a, const VisiblePosition& b) { 292 int comparePositions(const VisiblePosition& a, const VisiblePosition& b) {
293 return comparePositions(a.deepEquivalent(), b.deepEquivalent()); 293 return comparePositions(a.deepEquivalent(), b.deepEquivalent());
294 } 294 }
295 295
296 bool isNodeFullyContained(const EphemeralRange& range, Node& node) {
297 if (range.isNull())
298 return false;
299
300 if (!NodeTraversal::commonAncestor(*range.startPosition().anchorNode(), node))
301 return false;
302
303 return comparePositions(range.startPosition(), Position::beforeNode(&node)) <=
yosin_UTC9 2017/03/29 07:18:42 nit: We can use Position::operator<=(), which is a
yoichio 2017/03/29 07:42:20 Done.
304 0 &&
305 comparePositions(Position::afterNode(&node), range.endPosition()) <= 0;
306 }
307
296 // TODO(editing-dev): We should implement real version which refers 308 // TODO(editing-dev): We should implement real version which refers
297 // "user-select" CSS property. 309 // "user-select" CSS property.
298 // TODO(editing-dev): We should make |SelectionAdjuster| to use this funciton 310 // TODO(editing-dev): We should make |SelectionAdjuster| to use this funciton
299 // instead of |isSelectionBondary()|. 311 // instead of |isSelectionBondary()|.
300 bool isUserSelectContain(const Node& node) { 312 bool isUserSelectContain(const Node& node) {
301 return isHTMLTextAreaElement(node) || isHTMLInputElement(node) || 313 return isHTMLTextAreaElement(node) || isHTMLInputElement(node) ||
302 isHTMLSelectElement(node); 314 isHTMLSelectElement(node);
303 } 315 }
304 316
305 enum EditableLevel { Editable, RichlyEditable }; 317 enum EditableLevel { Editable, RichlyEditable };
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 return InputType::DeleteWordBackward; 2155 return InputType::DeleteWordBackward;
2144 if (granularity == LineBoundary) 2156 if (granularity == LineBoundary)
2145 return InputType::DeleteLineBackward; 2157 return InputType::DeleteLineBackward;
2146 return InputType::DeleteContentBackward; 2158 return InputType::DeleteContentBackward;
2147 default: 2159 default:
2148 return InputType::None; 2160 return InputType::None;
2149 } 2161 }
2150 } 2162 }
2151 2163
2152 } // namespace blink 2164 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698