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

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

Issue 1288063008: Move parentEditingBoundary() to VisibileUnits.cpp from Position.cpp. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-20T22:51:43 Rebase Created 5 years, 4 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
« no previous file with comments | « Source/core/editing/Position.h ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 PositionAlgorithm<Strategy> prevPosition = positions.upstream(CanCrossEditin gBoundary); 457 PositionAlgorithm<Strategy> prevPosition = positions.upstream(CanCrossEditin gBoundary);
458 if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableStyle()) 458 if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableStyle())
459 return true; 459 return true;
460 460
461 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt yle() 461 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt yle()
462 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt yle(); 462 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt yle();
463 } 463 }
464 464
465 template <typename Strategy> 465 template <typename Strategy>
466 static ContainerNode* nonShadowBoundaryParentNode(Node* node)
467 {
468 ContainerNode* parent = Strategy::parent(*node);
469 return parent && !parent->isShadowRoot() ? parent : nullptr;
470 }
471
472 template <typename Strategy>
473 static Node* parentEditingBoundaryAlgorithm(const PositionAlgorithm<Strategy>& p osition)
474 {
475 Node* const anchorNode = position.anchorNode();
476 if (!anchorNode)
477 return nullptr;
478
479 Node* documentElement = anchorNode->document().documentElement();
480 if (!documentElement)
481 return nullptr;
482
483 Node* boundary = position.computeContainerNode();
484 while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>( boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasE ditableStyle())
485 boundary = nonShadowBoundaryParentNode<Strategy>(boundary);
486
487 return boundary;
488 }
489
490 Node* parentEditingBoundary(const Position& position)
491 {
492 return parentEditingBoundaryAlgorithm<EditingStrategy>(position);
493 }
494
495 Node* parentEditingBoundary(const PositionInComposedTree& position)
496 {
497 return parentEditingBoundaryAlgorithm<EditingInComposedTreeStrategy>(positio n);
498 }
499
500 template <typename Strategy>
501 bool PositionAlgorithm<Strategy>::atStartOfTree() const 466 bool PositionAlgorithm<Strategy>::atStartOfTree() const
502 { 467 {
503 if (isNull()) 468 if (isNull())
504 return true; 469 return true;
505 return !Strategy::parent(*anchorNode()) && m_offset == 0; 470 return !Strategy::parent(*anchorNode()) && m_offset == 0;
506 } 471 }
507 472
508 template <typename Strategy> 473 template <typename Strategy>
509 bool PositionAlgorithm<Strategy>::atEndOfTree() const 474 bool PositionAlgorithm<Strategy>::atEndOfTree() const
510 { 475 {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 989
1025 void showTree(const blink::Position* pos) 990 void showTree(const blink::Position* pos)
1026 { 991 {
1027 if (pos) 992 if (pos)
1028 pos->showTreeForThis(); 993 pos->showTreeForThis();
1029 else 994 else
1030 fprintf(stderr, "Cannot showTree for (nil)\n"); 995 fprintf(stderr, "Cannot showTree for (nil)\n");
1031 } 996 }
1032 997
1033 #endif 998 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/Position.h ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698