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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
index 8206cec2423b731be21597f5019e5d2dc235a9f9..cabca2c1c9c6e0f596ff47b762509922b00891f9 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
@@ -231,6 +231,8 @@ void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl
|| style.hasFilter()))
style.setTransformStyle3D(TransformStyle3DFlat);
+ adjustStyleForEditing(style);
+
bool isSVGElement = element && element->isSVGElement();
if (isSVGElement) {
// Only the root <svg> element in an SVG document fragment tree honors css position
@@ -248,6 +250,19 @@ void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl
adjustStyleForAlignment(style, parentStyle);
}
+void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style)
+{
+ if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY)
+ return;
+ // Collapsing whitespace is harmful in plain-text editing.
+ if (style.whiteSpace() == NORMAL)
+ style.setWhiteSpace(PRE_WRAP);
+ else if (style.whiteSpace() == NOWRAP)
+ style.setWhiteSpace(PRE);
+ else if (style.whiteSpace() == PRE_LINE)
+ style.setWhiteSpace(PRE_WRAP);
+}
+
void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style)
{
if (style.styleType() != PseudoIdFirstLetter)

Powered by Google App Engine
This is Rietveld 408576698