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

Side by Side Diff: Source/core/editing/VisibleUnits.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.cpp ('k') | no next file » | 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, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 rightWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(rightWordBre ak); 448 rightWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(rightWordBre ak);
449 449
450 // FIXME: How should we handle a non-editable position? 450 // FIXME: How should we handle a non-editable position?
451 if (rightWordBreak.isNull() && isEditablePosition(visiblePosition.deepEquiva lent())) { 451 if (rightWordBreak.isNull() && isEditablePosition(visiblePosition.deepEquiva lent())) {
452 TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition .deepEquivalent()); 452 TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition .deepEquivalent());
453 rightWordBreak = blockDirection == LTR ? endOfEditableContent(visiblePos ition) : startOfEditableContent(visiblePosition); 453 rightWordBreak = blockDirection == LTR ? endOfEditableContent(visiblePos ition) : startOfEditableContent(visiblePosition);
454 } 454 }
455 return rightWordBreak; 455 return rightWordBreak;
456 } 456 }
457 457
458 template <typename Strategy>
459 static ContainerNode* nonShadowBoundaryParentNode(Node* node)
460 {
461 ContainerNode* parent = Strategy::parent(*node);
462 return parent && !parent->isShadowRoot() ? parent : nullptr;
463 }
464
465 template <typename Strategy>
466 static Node* parentEditingBoundary(const PositionAlgorithm<Strategy>& position)
467 {
468 Node* const anchorNode = position.anchorNode();
469 if (!anchorNode)
470 return nullptr;
471
472 Node* documentElement = anchorNode->document().documentElement();
473 if (!documentElement)
474 return nullptr;
475
476 Node* boundary = position.computeContainerNode();
477 while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>( boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasE ditableStyle())
478 boundary = nonShadowBoundaryParentNode<Strategy>(boundary);
479
480 return boundary;
481 }
458 482
459 enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext }; 483 enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
460 484
461 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign ed offset, BoundarySearchContextAvailability, bool& needMoreContext); 485 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign ed offset, BoundarySearchContextAvailability, bool& needMoreContext);
462 486
463 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch Function searchFunction) 487 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch Function searchFunction)
464 { 488 {
465 Position pos = c.deepEquivalent(); 489 Position pos = c.deepEquivalent();
466 Node* boundary = parentEditingBoundary(pos); 490 Node* boundary = parentEditingBoundary(pos);
467 if (!boundary) 491 if (!boundary)
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 { 1946 {
1923 return mostBackwardCaretPosition<EditingStrategy>(position, rule); 1947 return mostBackwardCaretPosition<EditingStrategy>(position, rule);
1924 } 1948 }
1925 1949
1926 PositionInComposedTree mostBackwardCaretPosition(const PositionInComposedTree& p osition, EditingBoundaryCrossingRule rule) 1950 PositionInComposedTree mostBackwardCaretPosition(const PositionInComposedTree& p osition, EditingBoundaryCrossingRule rule)
1927 { 1951 {
1928 return mostBackwardCaretPosition<EditingInComposedTreeStrategy>(position, ru le); 1952 return mostBackwardCaretPosition<EditingInComposedTreeStrategy>(position, ru le);
1929 } 1953 }
1930 1954
1931 } 1955 }
OLDNEW
« no previous file with comments | « Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698