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

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

Issue 2739123002: Utilize EphemeralRange::commonAncestorContainer in createStyleAtSelectionStart (Closed)
Patch Set: 2017-03-09T18:34:12 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 | 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) 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 // If background color is transparent, traverse parent nodes until we hit a 143 // If background color is transparent, traverse parent nodes until we hit a
144 // different value or document root Also, if the selection is a range, ignore 144 // different value or document root Also, if the selection is a range, ignore
145 // the background color at the start of selection, and find the background 145 // the background color at the start of selection, and find the background
146 // color of the common ancestor. 146 // color of the common ancestor.
147 if (shouldUseBackgroundColorInEffect && 147 if (shouldUseBackgroundColorInEffect &&
148 (selection.isRange() || hasTransparentBackgroundColor(style->style()))) { 148 (selection.isRange() || hasTransparentBackgroundColor(style->style()))) {
149 const EphemeralRange range(selection.toNormalizedEphemeralRange()); 149 const EphemeralRange range(selection.toNormalizedEphemeralRange());
150 if (const CSSValue* value = 150 if (const CSSValue* value =
151 backgroundColorValueInEffect(Range::commonAncestorContainer( 151 backgroundColorValueInEffect(range.commonAncestorContainer()))
152 range.startPosition().computeContainerNode(),
153 range.endPosition().computeContainerNode())))
154 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); 152 style->setProperty(CSSPropertyBackgroundColor, value->cssText());
155 } 153 }
156 154
157 return style; 155 return style;
158 } 156 }
159 157
160 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) { 158 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) {
161 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride || 159 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride ||
162 valueID == CSSValueWebkitIsolate || 160 valueID == CSSValueWebkitIsolate ||
163 valueID == CSSValueWebkitIsolateOverride || 161 valueID == CSSValueWebkitIsolateOverride ||
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 295 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
298 CSSComputedStyleDeclaration* ancestorStyle = 296 CSSComputedStyleDeclaration* ancestorStyle =
299 CSSComputedStyleDeclaration::create(ancestor); 297 CSSComputedStyleDeclaration::create(ancestor);
300 if (!hasTransparentBackgroundColor(ancestorStyle)) 298 if (!hasTransparentBackgroundColor(ancestorStyle))
301 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); 299 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor);
302 } 300 }
303 return nullptr; 301 return nullptr;
304 } 302 }
305 303
306 } // namespace blink 304 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698