Diff
Modified: trunk/LayoutTests/ChangeLog (257549 => 257550)
--- trunk/LayoutTests/ChangeLog 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/LayoutTests/ChangeLog 2020-02-27 03:18:38 UTC (rev 257550)
@@ -1,3 +1,14 @@
+2020-02-26 Myles C. Maxfield <[email protected]>
+
+ [iPadOS] REGRESSION(r247667): Autosizing style changes don't invalidate RenderText's preferred logical widths
+ https://bugs.webkit.org/show_bug.cgi?id=208084
+ <rdar://problem/59463898>
+
+ Reviewed by Darin Adler.
+
+ * fast/text-autosizing/ios/idempotentmode/viewport-change-relayout-expected.html: Added.
+ * fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html: Added.
+
2020-02-26 Jack Lee <[email protected]>
Nullptr crash in WebCore::canHaveChildrenForEditing via CompositeEditCommand::insertNode
Added: trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout-expected.html (0 => 257550)
--- trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout-expected.html 2020-02-27 03:18:38 UTC (rev 257550)
@@ -0,0 +1,16 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta id="viewport" name="viewport" content="width=400, initial-scale=0.70">
+<script>
+if (window.internals) {
+ internals.settings.setTextAutosizingEnabled(true);
+ internals.settings.setTextAutosizingUsesIdempotentMode(true);
+}
+</script>
+</head>
+<body style="font: 17px 'Arial'; width: 631px; -webkit-text-size-adjust: none;">
+<div><em id="em">Japan</em> with Everything about modern and traditional emphasis</div>
+<div style="height: 4000px; background: green;"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html (0 => 257550)
--- trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html 2020-02-27 03:18:38 UTC (rev 257550)
@@ -0,0 +1,40 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta id="viewport" name="viewport" content="width=400, initial-scale=1">
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+if (window.internals) {
+ internals.settings.setTextAutosizingEnabled(true);
+ internals.settings.setTextAutosizingUsesIdempotentMode(true);
+}
+</script>
+</head>
+<body style="font: 14px 'Arial'; width: 631px;">
+<div><em id="em">Japan</em> with Everything about modern and traditional emphasis</div>
+<div style="height: 4000px; background: green;"></div>
+<script>
+function _waitForCondition(condition, completionHandler)
+{
+ if (condition())
+ completionHandler();
+ else
+ setTimeout(_waitForCondition, 5, condition, completionHandler);
+}
+
+const em = document.getElementById("em");
+em.getBoundingClientRect();
+window.setTimeout(function() {
+ document.getElementById("viewport").content = "width=400, initial-scale=0.70";
+ em.getBoundingClientRect();
+}, 0);
+_waitForCondition(function() {
+ return window.getComputedStyle(document.getElementById("em")).getPropertyValue("font-size") != "14px";
+}, function() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+});
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (257549 => 257550)
--- trunk/Source/WebCore/ChangeLog 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/ChangeLog 2020-02-27 03:18:38 UTC (rev 257550)
@@ -1,3 +1,34 @@
+2020-02-26 Myles C. Maxfield <[email protected]>
+
+ [iPadOS] REGRESSION(r247667): Autosizing style changes don't invalidate RenderText's preferred logical widths
+ https://bugs.webkit.org/show_bug.cgi?id=208084
+ <rdar://problem/59463898>
+
+ Reviewed by Darin Adler.
+
+ Just use RenderElement::setStyle(), which handles all the invalidations, instead of RenderElement::setNeedsLayout().
+
+ Do a little refactoring so we don't clone RenderStyles unless we need to.
+
+ Test: fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html
+
+ * page/Page.cpp:
+ (WebCore::Page::recomputeTextAutoSizingInAllFrames):
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::RenderStyle::isIdempotentTextAutosizingCandidate const):
+ * rendering/style/RenderStyle.h:
+ * rendering/style/TextSizeAdjustment.cpp:
+ (WebCore::AutosizeStatus::computeStatus):
+ (WebCore::AutosizeStatus::updateStatus):
+ * rendering/style/TextSizeAdjustment.h:
+ (WebCore::AutosizeStatus::operator== const):
+ (WebCore::AutosizeStatus::operator!= const):
+ * style/StyleAdjuster.cpp:
+ (WebCore::Style::Adjuster::adjustmentForTextAutosizing):
+ (WebCore::Style::Adjuster::adjustForTextAutosizing):
+ * style/StyleAdjuster.h:
+ (WebCore::Style::Adjuster::AdjustmentForTextAutosizing::operator bool const):
+
2020-02-26 Zalan Bujtas <[email protected]>
REGRESSION (r257507): [ macOS ] ASSERTION FAILED: blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox)
Modified: trunk/Source/WebCore/page/Page.cpp (257549 => 257550)
--- trunk/Source/WebCore/page/Page.cpp 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/page/Page.cpp 2020-02-27 03:18:38 UTC (rev 257550)
@@ -2985,9 +2985,14 @@
forEachDocument([] (Document& document) {
if (auto* renderView = document.renderView()) {
for (auto& renderer : descendantsOfType<RenderElement>(*renderView)) {
+ // Use the fact that descendantsOfType() returns parent nodes before child nodes.
+ // The adjustment is only valid if the parent nodes have already been updated.
if (auto* element = renderer.element()) {
- if (Style::Adjuster::adjustForTextAutosizing(renderer.mutableStyle(), *element))
- renderer.setNeedsLayout();
+ if (auto adjustment = Style::Adjuster::adjustmentForTextAutosizing(renderer.style(), *element)) {
+ auto newStyle = RenderStyle::clone(renderer.style());
+ Style::Adjuster::adjustForTextAutosizing(newStyle, *element, adjustment);
+ renderer.setStyle(WTFMove(newStyle));
+ }
}
}
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (257549 => 257550)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2020-02-27 03:18:38 UTC (rev 257550)
@@ -502,10 +502,13 @@
&& m_rareNonInheritedData->textOverflow == other.m_rareNonInheritedData->textOverflow;
}
-bool RenderStyle::isIdempotentTextAutosizingCandidate() const
+bool RenderStyle::isIdempotentTextAutosizingCandidate(Optional<AutosizeStatus> overrideStatus) const
{
// Refer to <rdar://problem/51826266> for more information regarding how this function was generated.
auto fields = OptionSet<AutosizeStatus::Fields>::fromRaw(m_inheritedFlags.autosizeStatus);
+ if (overrideStatus)
+ fields = overrideStatus->fields();
+
if (fields.contains(AutosizeStatus::Fields::AvoidSubtree))
return false;
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (257549 => 257550)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-02-27 03:18:38 UTC (rev 257550)
@@ -741,7 +741,7 @@
#if ENABLE(TEXT_AUTOSIZING)
TextSizeAdjustment textSizeAdjust() const { return m_rareInheritedData->textSizeAdjust; }
AutosizeStatus autosizeStatus() const;
- bool isIdempotentTextAutosizingCandidate() const;
+ bool isIdempotentTextAutosizingCandidate(Optional<AutosizeStatus> overrideStatus = WTF::nullopt) const;
#endif
TextSecurity textSecurity() const { return static_cast<TextSecurity>(m_rareInheritedData->textSecurity); }
Modified: trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp (257549 => 257550)
--- trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp 2020-02-27 03:18:38 UTC (rev 257550)
@@ -79,7 +79,7 @@
&& approximateNumberOfLines - std::floor(approximateNumberOfLines) <= thresholdForConsideringAnApproximateNumberOfLinesToBeCloseToAnInteger;
}
-void AutosizeStatus::updateStatus(RenderStyle& style)
+auto AutosizeStatus::computeStatus(const RenderStyle& style) -> AutosizeStatus
{
auto result = style.autosizeStatus().fields();
@@ -113,9 +113,14 @@
if (style.isFloating())
result.add(Fields::Floating);
- style.setAutosizeStatus(result);
+ return AutosizeStatus(result);
}
+void AutosizeStatus::updateStatus(RenderStyle& style)
+{
+ style.setAutosizeStatus(AutosizeStatus(computeStatus(style)));
+}
+
float AutosizeStatus::idempotentTextSize(float specifiedSize, float pageScale)
{
if (pageScale >= 1)
Modified: trunk/Source/WebCore/rendering/style/TextSizeAdjustment.h (257549 => 257550)
--- trunk/Source/WebCore/rendering/style/TextSizeAdjustment.h 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/rendering/style/TextSizeAdjustment.h 2020-02-27 03:18:38 UTC (rev 257550)
@@ -65,7 +65,11 @@
bool contains(Fields) const;
+ bool operator==(const AutosizeStatus& other) const { return fields() == other.fields(); }
+ bool operator!=(const AutosizeStatus& other) const { return !(*this == other); }
+
static float idempotentTextSize(float specifiedSize, float pageScale);
+ static AutosizeStatus computeStatus(const RenderStyle&);
static void updateStatus(RenderStyle&);
static bool probablyContainsASmallFixedNumberOfLines(const RenderStyle&);
Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (257549 => 257550)
--- trunk/Source/WebCore/style/StyleAdjuster.cpp 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp 2020-02-27 03:18:38 UTC (rev 257550)
@@ -568,15 +568,20 @@
return false;
}
-bool Adjuster::adjustForTextAutosizing(RenderStyle& style, const Element& element)
+auto Adjuster::adjustmentForTextAutosizing(const RenderStyle& style, const Element& element) -> AdjustmentForTextAutosizing
{
+ AdjustmentForTextAutosizing adjustmentForTextAutosizing;
+
auto& document = element.document();
if (!document.settings().textAutosizingEnabled() || !document.settings().textAutosizingUsesIdempotentMode())
- return false;
+ return adjustmentForTextAutosizing;
- AutosizeStatus::updateStatus(style);
+ auto newStatus = AutosizeStatus::computeStatus(style);
+ if (newStatus != style.autosizeStatus())
+ adjustmentForTextAutosizing.newStatus = newStatus;
+
if (style.textSizeAdjust().isNone())
- return false;
+ return adjustmentForTextAutosizing;
float initialScale = document.page() ? document.page()->initialScale() : 1;
auto adjustLineHeightIfNeeded = [&](auto computedFontSize) {
@@ -593,26 +598,24 @@
if (AutosizeStatus::probablyContainsASmallFixedNumberOfLines(style))
return;
- style.setLineHeight({ minimumLineHeight, Fixed });
+ adjustmentForTextAutosizing.newLineHeight = minimumLineHeight;
};
auto fontDescription = style.fontDescription();
auto initialComputedFontSize = fontDescription.computedSize();
auto specifiedFontSize = fontDescription.specifiedSize();
- bool isCandidate = style.isIdempotentTextAutosizingCandidate();
+ bool isCandidate = style.isIdempotentTextAutosizingCandidate(newStatus);
if (!isCandidate && WTF::areEssentiallyEqual(initialComputedFontSize, specifiedFontSize))
- return false;
+ return adjustmentForTextAutosizing;
auto adjustedFontSize = AutosizeStatus::idempotentTextSize(fontDescription.specifiedSize(), initialScale);
if (isCandidate && WTF::areEssentiallyEqual(initialComputedFontSize, adjustedFontSize))
- return false;
+ return adjustmentForTextAutosizing;
if (!hasTextChild(element))
- return false;
+ return adjustmentForTextAutosizing;
- fontDescription.setComputedSize(isCandidate ? adjustedFontSize : specifiedFontSize);
- style.setFontDescription(WTFMove(fontDescription));
- style.fontCascade().update(&document.fontSelector());
+ adjustmentForTextAutosizing.newFontSize = isCandidate ? adjustedFontSize : specifiedFontSize;
// FIXME: We should restore computed line height to its original value in the case where the element is not
// an idempotent text autosizing candidate; otherwise, if an element that is a text autosizing candidate contains
@@ -620,8 +623,29 @@
if (isCandidate)
adjustLineHeightIfNeeded(adjustedFontSize);
- return true;
+ return adjustmentForTextAutosizing;
}
+
+bool Adjuster::adjustForTextAutosizing(RenderStyle& style, const Element& element, AdjustmentForTextAutosizing adjustment)
+{
+ AutosizeStatus::updateStatus(style);
+ if (auto newFontSize = adjustment.newFontSize) {
+ auto fontDescription = style.fontDescription();
+ fontDescription.setComputedSize(*newFontSize);
+ style.setFontDescription(WTFMove(fontDescription));
+ style.fontCascade().update(&element.document().fontSelector());
+ }
+ if (auto newLineHeight = adjustment.newLineHeight)
+ style.setLineHeight({ *newLineHeight, Fixed });
+ if (auto newStatus = adjustment.newStatus)
+ style.setAutosizeStatus(*newStatus);
+ return adjustment.newFontSize || adjustment.newLineHeight;
+}
+
+bool Adjuster::adjustForTextAutosizing(RenderStyle& style, const Element& element)
+{
+ return adjustForTextAutosizing(style, element, adjustmentForTextAutosizing(style, element));
+}
#endif
}
Modified: trunk/Source/WebCore/style/StyleAdjuster.h (257549 => 257550)
--- trunk/Source/WebCore/style/StyleAdjuster.h 2020-02-27 02:56:46 UTC (rev 257549)
+++ trunk/Source/WebCore/style/StyleAdjuster.h 2020-02-27 03:18:38 UTC (rev 257550)
@@ -49,6 +49,14 @@
static void adjustAnimatedStyle(RenderStyle&, const RenderStyle* parentBoxStyle, OptionSet<AnimationImpact>);
#if ENABLE(TEXT_AUTOSIZING)
+ struct AdjustmentForTextAutosizing {
+ Optional<float> newFontSize;
+ Optional<float> newLineHeight;
+ Optional<AutosizeStatus> newStatus;
+ explicit operator bool() const { return newFontSize || newLineHeight || newStatus; }
+ };
+ static AdjustmentForTextAutosizing adjustmentForTextAutosizing(const RenderStyle&, const Element&);
+ static bool adjustForTextAutosizing(RenderStyle&, const Element&, AdjustmentForTextAutosizing);
static bool adjustForTextAutosizing(RenderStyle&, const Element&);
#endif