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

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

Issue 2875253002: Introduce Position::IsEquivalent() (Closed)
Patch Set: 2017-05-12T17:24:00 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return ComparePositions(*this, other) > 0; 346 return ComparePositions(*this, other) > 0;
347 } 347 }
348 348
349 template <typename Strategy> 349 template <typename Strategy>
350 bool PositionTemplate<Strategy>::operator>=( 350 bool PositionTemplate<Strategy>::operator>=(
351 const PositionTemplate<Strategy>& other) const { 351 const PositionTemplate<Strategy>& other) const {
352 return ComparePositions(*this, other) >= 0; 352 return ComparePositions(*this, other) >= 0;
353 } 353 }
354 354
355 template <typename Strategy> 355 template <typename Strategy>
356 bool PositionTemplate<Strategy>::IsEquivalent(
357 const PositionTemplate<Strategy>& other) const {
358 if (IsNull())
359 return other.IsNull();
yoichio 2017/05/15 01:43:05 nlgtm because Nan != Nan generally.
yosin_UTC9 2017/05/15 04:08:15 IsNull() doesn't mean NaN. Also, Position::operato
360 if (anchor_type_ == other.anchor_type_)
361 return *this == other;
362 return ToOffsetInAnchor() == other.ToOffsetInAnchor();
363 }
364
365 template <typename Strategy>
356 bool PositionTemplate<Strategy>::AtFirstEditingPositionForNode() const { 366 bool PositionTemplate<Strategy>::AtFirstEditingPositionForNode() const {
357 if (IsNull()) 367 if (IsNull())
358 return true; 368 return true;
359 // FIXME: Position before anchor shouldn't be considered as at the first 369 // FIXME: Position before anchor shouldn't be considered as at the first
360 // editing position for node since that position resides outside of the node. 370 // editing position for node since that position resides outside of the node.
361 switch (anchor_type_) { 371 switch (anchor_type_) {
362 case PositionAnchorType::kOffsetInAnchor: 372 case PositionAnchorType::kOffsetInAnchor:
363 return offset_ == 0; 373 return offset_ == 0;
364 case PositionAnchorType::kBeforeChildren: 374 case PositionAnchorType::kBeforeChildren:
365 case PositionAnchorType::kBeforeAnchor: 375 case PositionAnchorType::kBeforeAnchor:
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 704 }
695 705
696 void showTree(const blink::Position* pos) { 706 void showTree(const blink::Position* pos) {
697 if (pos) 707 if (pos)
698 pos->ShowTreeForThis(); 708 pos->ShowTreeForThis();
699 else 709 else
700 LOG(INFO) << "Cannot showTree for <null>"; 710 LOG(INFO) << "Cannot showTree for <null>";
701 } 711 }
702 712
703 #endif 713 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698