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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingStyleUtilities.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 | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.h » ('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) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 MutableStylePropertySet* styleToCheck) { 94 MutableStylePropertySet* styleToCheck) {
95 if (selection.isNone()) 95 if (selection.isNone())
96 return nullptr; 96 return nullptr;
97 97
98 Document& document = *selection.start().document(); 98 Document& document = *selection.start().document();
99 99
100 DCHECK(!document.needsLayoutTreeUpdate()); 100 DCHECK(!document.needsLayoutTreeUpdate());
101 DocumentLifecycle::DisallowTransitionScope disallowTransition( 101 DocumentLifecycle::DisallowTransitionScope disallowTransition(
102 document.lifecycle()); 102 document.lifecycle());
103 103
104 Position position = adjustedSelectionStartForStyleComputation(selection); 104 // TODO(editing-dev): We should make |position| to |const Position&| by
105 // integrating this expression and if-statement below.
106 Position position =
107 selection.isCaret()
108 ? createVisiblePosition(selection.start()).deepEquivalent()
109 : adjustedSelectionStartForStyleComputation(selection.start());
105 110
106 // If the pos is at the end of a text node, then this node is not fully 111 // If the pos is at the end of a text node, then this node is not fully
107 // selected. Move it to the next deep equivalent position to avoid removing 112 // selected. Move it to the next deep equivalent position to avoid removing
108 // the style from this node. 113 // the style from this node.
109 // e.g. if pos was at Position("hello", 5) in <b>hello<div>world</div></b>, we 114 // e.g. if pos was at Position("hello", 5) in <b>hello<div>world</div></b>, we
110 // want Position("world", 0) instead. 115 // want Position("world", 0) instead.
111 // We only do this for range because caret at Position("hello", 5) in 116 // We only do this for range because caret at Position("hello", 5) in
112 // <b>hello</b>world should give you font-weight: bold. 117 // <b>hello</b>world should give you font-weight: bold.
113 Node* positionNode = position.computeContainerNode(); 118 Node* positionNode = position.computeContainerNode();
114 if (selection.isRange() && positionNode && positionNode->isTextNode() && 119 if (selection.isRange() && positionNode && positionNode->isTextNode() &&
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 302 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
298 CSSComputedStyleDeclaration* ancestorStyle = 303 CSSComputedStyleDeclaration* ancestorStyle =
299 CSSComputedStyleDeclaration::create(ancestor); 304 CSSComputedStyleDeclaration::create(ancestor);
300 if (!hasTransparentBackgroundColor(ancestorStyle)) 305 if (!hasTransparentBackgroundColor(ancestorStyle))
301 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); 306 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor);
302 } 307 }
303 return nullptr; 308 return nullptr;
304 } 309 }
305 310
306 } // namespace blink 311 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698