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

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

Issue 2962473002: Make Position::LastPositionInNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-26T14:00:00 Created 3 years, 5 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 const Node& anchor_node) { 493 const Node& anchor_node) {
494 if (anchor_node.IsTextNode()) 494 if (anchor_node.IsTextNode())
495 return PositionTemplate<Strategy>(anchor_node, 0); 495 return PositionTemplate<Strategy>(anchor_node, 0);
496 return PositionTemplate<Strategy>(&anchor_node, 496 return PositionTemplate<Strategy>(&anchor_node,
497 PositionAnchorType::kBeforeChildren); 497 PositionAnchorType::kBeforeChildren);
498 } 498 }
499 499
500 // static 500 // static
501 template <typename Strategy> 501 template <typename Strategy>
502 PositionTemplate<Strategy> PositionTemplate<Strategy>::LastPositionInNode( 502 PositionTemplate<Strategy> PositionTemplate<Strategy>::LastPositionInNode(
503 Node* anchor_node) { 503 const Node& anchor_node) {
504 if (anchor_node->IsTextNode()) { 504 if (anchor_node.IsTextNode()) {
505 return PositionTemplate<Strategy>(anchor_node, 505 return PositionTemplate<Strategy>(anchor_node,
506 LastOffsetInNode(*anchor_node)); 506 LastOffsetInNode(anchor_node));
507 } 507 }
508 return PositionTemplate<Strategy>(anchor_node, 508 return PositionTemplate<Strategy>(&anchor_node,
509 PositionAnchorType::kAfterChildren); 509 PositionAnchorType::kAfterChildren);
510 } 510 }
511 511
512 // static 512 // static
513 template <typename Strategy> 513 template <typename Strategy>
514 PositionTemplate<Strategy> 514 PositionTemplate<Strategy>
515 PositionTemplate<Strategy>::FirstPositionInOrBeforeNode(Node* node) { 515 PositionTemplate<Strategy>::FirstPositionInOrBeforeNode(Node* node) {
516 if (!node) 516 if (!node)
517 return PositionTemplate<Strategy>(); 517 return PositionTemplate<Strategy>();
518 return EditingIgnoresContent(*node) ? BeforeNode(*node) 518 return EditingIgnoresContent(*node) ? BeforeNode(*node)
519 : FirstPositionInNode(*node); 519 : FirstPositionInNode(*node);
520 } 520 }
521 521
522 // static 522 // static
523 template <typename Strategy> 523 template <typename Strategy>
524 PositionTemplate<Strategy> 524 PositionTemplate<Strategy>
525 PositionTemplate<Strategy>::LastPositionInOrAfterNode(Node* node) { 525 PositionTemplate<Strategy>::LastPositionInOrAfterNode(Node* node) {
526 if (!node) 526 if (!node)
527 return PositionTemplate<Strategy>(); 527 return PositionTemplate<Strategy>();
528 return EditingIgnoresContent(*node) ? AfterNode(*node) 528 return EditingIgnoresContent(*node) ? AfterNode(*node)
529 : LastPositionInNode(node); 529 : LastPositionInNode(*node);
530 } 530 }
531 531
532 PositionInFlatTree ToPositionInFlatTree(const Position& pos) { 532 PositionInFlatTree ToPositionInFlatTree(const Position& pos) {
533 if (pos.IsNull()) 533 if (pos.IsNull())
534 return PositionInFlatTree(); 534 return PositionInFlatTree();
535 535
536 Node* const anchor = pos.AnchorNode(); 536 Node* const anchor = pos.AnchorNode();
537 if (pos.IsOffsetInAnchor()) { 537 if (pos.IsOffsetInAnchor()) {
538 if (anchor->IsCharacterDataNode()) 538 if (anchor->IsCharacterDataNode())
539 return PositionInFlatTree(anchor, pos.ComputeOffsetInContainerNode()); 539 return PositionInFlatTree(anchor, pos.ComputeOffsetInContainerNode());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 715 }
716 716
717 void showTree(const blink::Position* pos) { 717 void showTree(const blink::Position* pos) {
718 if (pos) 718 if (pos)
719 pos->ShowTreeForThis(); 719 pos->ShowTreeForThis();
720 else 720 else
721 LOG(INFO) << "Cannot showTree for <null>"; 721 LOG(INFO) << "Cannot showTree for <null>";
722 } 722 }
723 723
724 #endif 724 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.h ('k') | third_party/WebKit/Source/core/editing/PositionIteratorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698