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

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

Issue 2739023003: Make adjustedSelectionStartForStyleComputation() to take Position instead of VisibleSeleciton (Closed)
Patch Set: 2017-03-09T15:23:37 Created 3 years, 9 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 | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 element.hasTagName(h3Tag) || element.hasTagName(h4Tag) || 2041 element.hasTagName(h3Tag) || element.hasTagName(h4Tag) ||
2042 element.hasTagName(h5Tag); 2042 element.hasTagName(h5Tag);
2043 } 2043 }
2044 2044
2045 bool isBlockFlowElement(const Node& node) { 2045 bool isBlockFlowElement(const Node& node) {
2046 LayoutObject* layoutObject = node.layoutObject(); 2046 LayoutObject* layoutObject = node.layoutObject();
2047 return node.isElementNode() && layoutObject && 2047 return node.isElementNode() && layoutObject &&
2048 layoutObject->isLayoutBlockFlow(); 2048 layoutObject->isLayoutBlockFlow();
2049 } 2049 }
2050 2050
2051 Position adjustedSelectionStartForStyleComputation( 2051 Position adjustedSelectionStartForStyleComputation(const Position& position) {
2052 const VisibleSelection& selection) {
2053 // This function is used by range style computations to avoid bugs like: 2052 // This function is used by range style computations to avoid bugs like:
2054 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a 2053 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a
2055 // selection starting from end of line once 2054 // selection starting from end of line once
2056 // It is important to skip certain irrelevant content at the start of the 2055 // It is important to skip certain irrelevant content at the start of the
2057 // selection, so we do not wind up with a spurious "mixed" style. 2056 // selection, so we do not wind up with a spurious "mixed" style.
2058 2057
2059 VisiblePosition visiblePosition = createVisiblePosition(selection.start()); 2058 VisiblePosition visiblePosition = createVisiblePosition(position);
2060 if (visiblePosition.isNull()) 2059 if (visiblePosition.isNull())
2061 return Position(); 2060 return Position();
2062 2061
2063 // if the selection is a caret, just return the position, since the style
2064 // behind us is relevant
2065 if (selection.isCaret())
2066 return visiblePosition.deepEquivalent();
2067
2068 // if the selection starts just before a paragraph break, skip over it 2062 // if the selection starts just before a paragraph break, skip over it
2069 if (isEndOfParagraph(visiblePosition)) 2063 if (isEndOfParagraph(visiblePosition))
2070 return mostForwardCaretPosition( 2064 return mostForwardCaretPosition(
2071 nextPositionOf(visiblePosition).deepEquivalent()); 2065 nextPositionOf(visiblePosition).deepEquivalent());
2072 2066
2073 // otherwise, make sure to be at the start of the first selected node, 2067 // otherwise, make sure to be at the start of the first selected node,
2074 // instead of possibly at the end of the last node before the selection 2068 // instead of possibly at the end of the last node before the selection
2075 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); 2069 return mostForwardCaretPosition(visiblePosition.deepEquivalent());
2076 } 2070 }
2077 2071
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 return InputType::DeleteWordBackward; 2173 return InputType::DeleteWordBackward;
2180 if (granularity == LineBoundary) 2174 if (granularity == LineBoundary)
2181 return InputType::DeleteLineBackward; 2175 return InputType::DeleteLineBackward;
2182 return InputType::DeleteContentBackward; 2176 return InputType::DeleteContentBackward;
2183 default: 2177 default:
2184 return InputType::None; 2178 return InputType::None;
2185 } 2179 }
2186 } 2180 }
2187 2181
2188 } // namespace blink 2182 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698