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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp

Issue 1813663002: Don't collapse whitespace in contenteditable=plaintext-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // If we have first-letter pseudo style, transitions, or animations, do not share this style. 224 // If we have first-letter pseudo style, transitions, or animations, do not share this style.
225 if (style.hasPseudoStyle(PseudoIdFirstLetter) || style.transitions() || styl e.animations()) 225 if (style.hasPseudoStyle(PseudoIdFirstLetter) || style.transitions() || styl e.animations())
226 style.setUnique(); 226 style.setUnique();
227 227
228 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening. 228 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening.
229 if (style.preserves3D() && (style.overflowX() != OverflowVisible 229 if (style.preserves3D() && (style.overflowX() != OverflowVisible
230 || style.overflowY() != OverflowVisible 230 || style.overflowY() != OverflowVisible
231 || style.hasFilter())) 231 || style.hasFilter()))
232 style.setTransformStyle3D(TransformStyle3DFlat); 232 style.setTransformStyle3D(TransformStyle3DFlat);
233 233
234 adjustStyleForEditing(style);
235
234 bool isSVGElement = element && element->isSVGElement(); 236 bool isSVGElement = element && element->isSVGElement();
235 if (isSVGElement) { 237 if (isSVGElement) {
236 // Only the root <svg> element in an SVG document fragment tree honors c ss position 238 // Only the root <svg> element in an SVG document fragment tree honors c ss position
237 if (!(isSVGSVGElement(*element) && element->parentNode() && !element->pa rentNode()->isSVGElement())) 239 if (!(isSVGSVGElement(*element) && element->parentNode() && !element->pa rentNode()->isSVGElement()))
238 style.setPosition(ComputedStyle::initialPosition()); 240 style.setPosition(ComputedStyle::initialPosition());
239 241
240 // SVG text layout code expects us to be a block-level style element. 242 // SVG text layout code expects us to be a block-level style element.
241 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && style.isDisplayInlineType()) 243 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && style.isDisplayInlineType())
242 style.setDisplay(BLOCK); 244 style.setDisplay(BLOCK);
243 245
244 // Columns don't apply to svg text elements. 246 // Columns don't apply to svg text elements.
245 if (isSVGTextElement(*element)) 247 if (isSVGTextElement(*element))
246 style.clearMultiCol(); 248 style.clearMultiCol();
247 } 249 }
248 adjustStyleForAlignment(style, parentStyle); 250 adjustStyleForAlignment(style, parentStyle);
249 } 251 }
250 252
253 void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style)
254 {
255 if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY)
256 return;
257 // Collapsing whitespace is harmful in plain-text editing.
258 if (style.whiteSpace() == NORMAL)
259 style.setWhiteSpace(PRE_WRAP);
260 else if (style.whiteSpace() == NOWRAP)
261 style.setWhiteSpace(PRE);
262 else if (style.whiteSpace() == PRE_LINE)
263 style.setWhiteSpace(PRE_WRAP);
264 }
265
251 void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style) 266 void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style)
252 { 267 {
253 if (style.styleType() != PseudoIdFirstLetter) 268 if (style.styleType() != PseudoIdFirstLetter)
254 return; 269 return;
255 270
256 // Force inline display (except for floating first-letters). 271 // Force inline display (except for floating first-letters).
257 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 272 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
258 273
259 // CSS2 says first-letter can't be positioned. 274 // CSS2 says first-letter can't be positioned.
260 style.setPosition(StaticPosition); 275 style.setPosition(StaticPosition);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // We want to count vertical percentage paddings/margins on flex items b ecause our current 451 // We want to count vertical percentage paddings/margins on flex items b ecause our current
437 // behavior is different from the spec and we want to gather compatibili ty data. 452 // behavior is different from the spec and we want to gather compatibili ty data.
438 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) 453 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t())
439 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); 454 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical);
440 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) 455 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( ))
441 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); 456 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal);
442 } 457 }
443 } 458 }
444 459
445 } // namespace blink 460 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698