From 2537d1faca3cc23e6a227a703d41a7c4b2aa7786 Mon Sep 17 00:00:00 2001 From: Ahmad Saleem Date: Mon, 16 Jan 2023 22:17:50 +0000 Subject: [PATCH] `text-combine-upright: all` & `text-transform` don't work together `text-combine-upright: all` & `text-transform` don't work together https://bugs.webkit.org/show_bug.cgi?id=250657 Reviewed by NOBODY (OOPS!). This patch is to align WebKit with Gecko / Firefox and Blink / Chromium. Merge - https://src.chromium.org/viewvc/blink?view=rev&revision=167624 When we transform text, we set transformed text to RenderText::m_text. RenderCombineText overwrites the text at combineText() and use originalText() at combineTextIfNeeded() in painting. Therefore, text combine paints original text instead of transformed text. * Source/WebCore/rendering/RenderCombineText.h: Add "m_renderedText" as String definition * Source/WebCore/rendering/RenderCombineText.cpp: (RenderCombineText::combineTextIfNeeded): Change 'originalText' to "m_renderedText" and call it also while object replacement * LayoutTests/fast/text/text-combine-upright-text-transform.html: Add Test Case * LayoutTests/fast/text/text-combine-upright-text-transform-expected.html: Add Test Case Expectation --- .../text-combine-upright-text-transform-expected.html | 10 ++++++++++ .../fast/text/text-combine-upright-text-transform.html | 10 ++++++++++ Source/WebCore/rendering/RenderCombineText.cpp | 6 ++++-- Source/WebCore/rendering/RenderCombineText.h | 4 +++- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 LayoutTests/fast/text/text-combine-upright-text-transform-expected.html create mode 100644 LayoutTests/fast/text/text-combine-upright-text-transform.html diff --git a/LayoutTests/fast/text/text-combine-upright-text-transform-expected.html b/LayoutTests/fast/text/text-combine-upright-text-transform-expected.html new file mode 100644 index 000000000000..66d5f81627b0 --- /dev/null +++ b/LayoutTests/fast/text/text-combine-upright-text-transform-expected.html @@ -0,0 +1,10 @@ + + +Test text-combine-upright: all + text-transform

+text-transform: capitalize
+The following "a" should be upright and captalize: A

+text-transform: lowercase
+The following "A" should be upright and lowercase: a

+text-transform: uppercase
+The following "a" should be upright and uppercase: A

+ diff --git a/LayoutTests/fast/text/text-combine-upright-text-transform.html b/LayoutTests/fast/text/text-combine-upright-text-transform.html new file mode 100644 index 000000000000..41926218903a --- /dev/null +++ b/LayoutTests/fast/text/text-combine-upright-text-transform.html @@ -0,0 +1,10 @@ + + +Test text-combine-upright: all + text-transform

+text-transform: capitalize
+The following "a" should be upright and captalize: a

+text-transform: lowercase
+The following "A" should be upright and lowercase: A

+text-transform: uppercase
+The following "a" should be upright and uppercase: a

+ diff --git a/Source/WebCore/rendering/RenderCombineText.cpp b/Source/WebCore/rendering/RenderCombineText.cpp index babebff8109a..bda50583a61e 100644 --- a/Source/WebCore/rendering/RenderCombineText.cpp +++ b/Source/WebCore/rendering/RenderCombineText.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011-2023 Apple Inc. All rights reserved. + * Copyright (C) 2014 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -99,7 +100,7 @@ void RenderCombineText::combineTextIfNeeded() // An ancestor element may trigger us to lay out again, even when we're already combined. if (m_isCombined) - RenderText::setRenderedText(originalText()); + RenderText::setRenderedText(m_renderedText); m_isCombined = false; m_needsFontUpdate = false; @@ -185,6 +186,7 @@ void RenderCombineText::combineTextIfNeeded() if (m_isCombined) { static NeverDestroyed objectReplacementCharacterString(&objectReplacementCharacter, 1); + m_renderedText = text(); RenderText::setRenderedText(objectReplacementCharacterString.get()); m_combinedTextWidth = combinedTextWidth; m_combinedTextAscent = glyphOverflow.top; diff --git a/Source/WebCore/rendering/RenderCombineText.h b/Source/WebCore/rendering/RenderCombineText.h index c11ab464d982..81e8df84f40d 100644 --- a/Source/WebCore/rendering/RenderCombineText.h +++ b/Source/WebCore/rendering/RenderCombineText.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011-2023 Apple Inc. All rights reserved. + * Copyright (C) 2014 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -53,6 +54,7 @@ class RenderCombineText final : public RenderText { float m_combinedTextWidth { 0 }; float m_combinedTextAscent { 0 }; float m_combinedTextDescent { 0 }; + String m_renderedText; bool m_isCombined : 1; bool m_needsFontUpdate : 1; };