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

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

Issue 2372903003: Ensure valid VisiblePosition input for inSameBlock (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.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, 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 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda ryCrossingRule rule) 1916 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda ryCrossingRule rule)
1917 { 1917 {
1918 DCHECK(visiblePosition.isValid()) << visiblePosition; 1918 DCHECK(visiblePosition.isValid()) << visiblePosition;
1919 Position position = visiblePosition.deepEquivalent(); 1919 Position position = visiblePosition.deepEquivalent();
1920 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio n.computeContainerNode(), rule) : 0; 1920 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio n.computeContainerNode(), rule) : 0;
1921 return endBlock ? VisiblePosition::lastPositionInNode(endBlock) : VisiblePos ition(); 1921 return endBlock ? VisiblePosition::lastPositionInNode(endBlock) : VisiblePos ition();
1922 } 1922 }
1923 1923
1924 bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b) 1924 bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b)
1925 { 1925 {
1926 // TODO(xiaochengh): Ensure that this function is called with valid |a| and 1926 DCHECK(a.isValid()) << a;
1927 // |b|, and add |DCHECK(a.isValid())| and |DCHECK(b.isValid())| 1927 DCHECK(b.isValid()) << b;
1928 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode ()) == enclosingBlock(b.deepEquivalent().computeContainerNode()); 1928 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode ()) == enclosingBlock(b.deepEquivalent().computeContainerNode());
1929 } 1929 }
1930 1930
1931 bool isStartOfBlock(const VisiblePosition& pos) 1931 bool isStartOfBlock(const VisiblePosition& pos)
1932 { 1932 {
1933 DCHECK(pos.isValid()) << pos; 1933 DCHECK(pos.isValid()) << pos;
1934 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross EditingBoundary).deepEquivalent(); 1934 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross EditingBoundary).deepEquivalent();
1935 } 1935 }
1936 1936
1937 bool isEndOfBlock(const VisiblePosition& pos) 1937 bool isEndOfBlock(const VisiblePosition& pos)
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
3480 { 3480 {
3481 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3481 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3482 } 3482 }
3483 3483
3484 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) 3484 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3485 { 3485 {
3486 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); 3486 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3487 } 3487 }
3488 3488
3489 } // namespace blink 3489 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698