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

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

Issue 2373483003: Ensure valid VisiblePosition input for absoluteCaretBoundsOf (Closed)
Patch Set: Ensure valid VP for absoluteCaretBoundsOf 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
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 2918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 } 2929 }
2930 2930
2931 bool isVisuallyEquivalentCandidate(const PositionInFlatTree& position) 2931 bool isVisuallyEquivalentCandidate(const PositionInFlatTree& position)
2932 { 2932 {
2933 return isVisuallyEquivalentCandidateAlgorithm<EditingInFlatTreeStrategy>(pos ition); 2933 return isVisuallyEquivalentCandidateAlgorithm<EditingInFlatTreeStrategy>(pos ition);
2934 } 2934 }
2935 2935
2936 template <typename Strategy> 2936 template <typename Strategy>
2937 static IntRect absoluteCaretBoundsOfAlgorithm(const VisiblePositionTemplate<Stra tegy>& visiblePosition) 2937 static IntRect absoluteCaretBoundsOfAlgorithm(const VisiblePositionTemplate<Stra tegy>& visiblePosition)
2938 { 2938 {
2939 // TODO(xiaochengh): Ensure that this function is called with a valid 2939 DCHECK(visiblePosition.isValid()) << visiblePosition;
2940 // |visiblePosition|, and add |DCHECK(visiblePosition.isValid())|;
2941 LayoutObject* layoutObject; 2940 LayoutObject* layoutObject;
2942 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject); 2941 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject);
2943 if (localRect.isEmpty() || !layoutObject) 2942 if (localRect.isEmpty() || !layoutObject)
2944 return IntRect(); 2943 return IntRect();
2945 2944
2946 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 2945 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
2947 } 2946 }
2948 2947
2949 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition) 2948 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition)
2950 { 2949 {
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 { 3477 {
3479 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3478 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3480 } 3479 }
3481 3480
3482 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) 3481 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3483 { 3482 {
3484 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); 3483 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3485 } 3484 }
3486 3485
3487 } // namespace blink 3486 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698