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

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

Issue 2952983002: Make Position::FirstPositionInNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-23T10:37:43 Created 3 years, 6 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 template <typename Strategy> 483 template <typename Strategy>
484 int PositionTemplate<Strategy>::LastOffsetInNode(Node* node) { 484 int PositionTemplate<Strategy>::LastOffsetInNode(Node* node) {
485 return node->IsCharacterDataNode() 485 return node->IsCharacterDataNode()
486 ? node->MaxCharacterOffset() 486 ? node->MaxCharacterOffset()
487 : static_cast<int>(Strategy::CountChildren(*node)); 487 : static_cast<int>(Strategy::CountChildren(*node));
488 } 488 }
489 489
490 // static 490 // static
491 template <typename Strategy> 491 template <typename Strategy>
492 PositionTemplate<Strategy> PositionTemplate<Strategy>::FirstPositionInNode( 492 PositionTemplate<Strategy> PositionTemplate<Strategy>::FirstPositionInNode(
493 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 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 return PositionTemplate<Strategy>(anchor_node, 507 return PositionTemplate<Strategy>(anchor_node,
508 PositionAnchorType::kAfterChildren); 508 PositionAnchorType::kAfterChildren);
509 } 509 }
510 510
511 // static 511 // static
512 template <typename Strategy> 512 template <typename Strategy>
513 PositionTemplate<Strategy> 513 PositionTemplate<Strategy>
514 PositionTemplate<Strategy>::FirstPositionInOrBeforeNode(Node* node) { 514 PositionTemplate<Strategy>::FirstPositionInOrBeforeNode(Node* node) {
515 if (!node) 515 if (!node)
516 return PositionTemplate<Strategy>(); 516 return PositionTemplate<Strategy>();
517 return EditingIgnoresContent(*node) ? BeforeNode(*node) 517 return EditingIgnoresContent(*node) ? BeforeNode(*node)
518 : FirstPositionInNode(node); 518 : FirstPositionInNode(*node);
519 } 519 }
520 520
521 // static 521 // static
522 template <typename Strategy> 522 template <typename Strategy>
523 PositionTemplate<Strategy> 523 PositionTemplate<Strategy>
524 PositionTemplate<Strategy>::LastPositionInOrAfterNode(Node* node) { 524 PositionTemplate<Strategy>::LastPositionInOrAfterNode(Node* node) {
525 if (!node) 525 if (!node)
526 return PositionTemplate<Strategy>(); 526 return PositionTemplate<Strategy>();
527 return EditingIgnoresContent(*node) ? AfterNode(*node) 527 return EditingIgnoresContent(*node) ? AfterNode(*node)
528 : LastPositionInNode(node); 528 : LastPositionInNode(node);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 715
716 void showTree(const blink::Position* pos) { 716 void showTree(const blink::Position* pos) {
717 if (pos) 717 if (pos)
718 pos->ShowTreeForThis(); 718 pos->ShowTreeForThis();
719 else 719 else
720 LOG(INFO) << "Cannot showTree for <null>"; 720 LOG(INFO) << "Cannot showTree for <null>";
721 } 721 }
722 722
723 #endif 723 #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