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

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

Issue 2291423002: Remove debugPosition() functions. (Closed)
Patch Set: Created 4 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
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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 // static 486 // static
487 template <typename Strategy> 487 template <typename Strategy>
488 PositionTemplate<Strategy> PositionTemplate<Strategy>::lastPositionInOrAfterNode (Node* node) 488 PositionTemplate<Strategy> PositionTemplate<Strategy>::lastPositionInOrAfterNode (Node* node)
489 { 489 {
490 if (!node) 490 if (!node)
491 return PositionTemplate<Strategy>(); 491 return PositionTemplate<Strategy>();
492 return Strategy::editingIgnoresContent(node) ? afterNode(node) : lastPositio nInNode(node); 492 return Strategy::editingIgnoresContent(node) ? afterNode(node) : lastPositio nInNode(node);
493 } 493 }
494 494
495 template <typename Strategy>
496 void PositionTemplate<Strategy>::debugPosition(const char* msg) const
497 {
498 static const char* const anchorTypes[] = {
499 "OffsetInAnchor",
500 "BeforeAnchor",
501 "AfterAnchor",
502 "BeforeChildren",
503 "AfterChildren",
504 "Invalid",
505 };
506
507 if (isNull()) {
508 fprintf(stderr, "Position [%s]: null\n", msg);
509 return;
510 }
511
512 const char* anchorType = anchorTypes[std::min(static_cast<size_t>(m_anchorTy pe), WTF_ARRAY_LENGTH(anchorTypes) - 1)];
513 if (m_anchorNode->isTextNode()) {
514 fprintf(stderr, "Position [%s]: %s [%p] %s, (%s) at %d\n", msg, anchorNo de()->nodeName().utf8().data(), anchorNode(), anchorType, m_anchorNode->nodeValu e().utf8().data(), m_offset);
515 return;
516 }
517
518 fprintf(stderr, "Position [%s]: %s [%p] %s at %d\n", msg, anchorNode()->node Name().utf8().data(), anchorNode(), anchorType, m_offset);
519 }
520
521 PositionInFlatTree toPositionInFlatTree(const Position& pos) 495 PositionInFlatTree toPositionInFlatTree(const Position& pos)
522 { 496 {
523 if (pos.isNull()) 497 if (pos.isNull())
524 return PositionInFlatTree(); 498 return PositionInFlatTree();
525 499
526 Node* const anchor = pos.anchorNode(); 500 Node* const anchor = pos.anchorNode();
527 if (pos.isOffsetInAnchor()) { 501 if (pos.isOffsetInAnchor()) {
528 if (anchor->isCharacterDataNode()) 502 if (anchor->isCharacterDataNode())
529 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode() ); 503 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode() );
530 DCHECK(!anchor->isSlotOrActiveInsertionPoint()); 504 DCHECK(!anchor->isSlotOrActiveInsertionPoint());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 677
704 void showTree(const blink::Position* pos) 678 void showTree(const blink::Position* pos)
705 { 679 {
706 if (pos) 680 if (pos)
707 pos->showTreeForThis(); 681 pos->showTreeForThis();
708 else 682 else
709 fprintf(stderr, "Cannot showTree for (nil)\n"); 683 fprintf(stderr, "Cannot showTree for (nil)\n");
710 } 684 }
711 685
712 #endif 686 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.h ('k') | third_party/WebKit/Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698