WebKit Bugzilla
Attachment 369915 Details for
Bug 197808
: Move idempotent text autosizing to StyleTreeResolver
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-197808-20190514181014.patch (text/plain), 11.51 KB, created by
Myles C. Maxfield
on 2019-05-14 18:10:15 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-05-14 18:10:15 PDT
Size:
11.51 KB
patch
obsolete
>Subversion Revision: 245293 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7e2f5e6423b37dc0598e293e1e5c9a94b7796896..0ccc6ddc3d25eb4da6afd07a4da23c73542c3f3e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2019-05-14 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ Move idempotent text autosizing to StyleTreeResolver >+ https://bugs.webkit.org/show_bug.cgi?id=197808 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * css/CSSComputedStyleDeclaration.cpp: >+ (WebCore::ComputedStyleExtractor::valueForPropertyinStyle): >+ * css/CSSProperties.json: >+ * css/StyleResolver.cpp: >+ (WebCore::applyStyleToAutosizeStatus): >+ (WebCore::idempotentTextSize): >+ (WebCore::StyleResolver::adjustRenderStyle): >+ * page/FrameViewLayoutContext.cpp: >+ (WebCore::FrameViewLayoutContext::applyTextSizingIfNeeded): >+ * rendering/style/RenderStyle.cpp: >+ (WebCore::RenderStyle::RenderStyle): >+ * rendering/style/RenderStyle.h: >+ (WebCore::RenderStyle::autosizeStatus const): >+ (WebCore::RenderStyle::setAutosizeStatus): >+ * rendering/style/TextSizeAdjustment.h: >+ (WebCore::AutosizeStatus::shouldSkipSubtree const): >+ > 2019-05-14 Antti Koivisto <antti@apple.com> > > Event region computation should respect transforms >diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >index f2dc6b7bd26c55972f83597191f6fb9b9b75a8bd..c9f82fb8791404c9c19f2986d20be0e337c6a1ff 100644 >--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >@@ -2785,6 +2785,7 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyinStyle(const RenderSty > > switch (propertyID) { > case CSSPropertyInvalid: >+ case CSSPropertyWebkitTextAutosizingStatus: > break; > > case CSSPropertyBackgroundColor: >diff --git a/Source/WebCore/css/CSSProperties.json b/Source/WebCore/css/CSSProperties.json >index 8a4ef594286ef6103f8b76351e8210831fd5afce..9a7dd947d64b1d1bbd71bd5473d928c2a48ee5be 100644 >--- a/Source/WebCore/css/CSSProperties.json >+++ b/Source/WebCore/css/CSSProperties.json >@@ -6228,6 +6228,14 @@ > }, > "status": "non-standard" > }, >+ "-webkit-text-autosizing-status": { >+ "inherited": true, >+ "codegen-properties": { >+ "skip-builder": true, >+ "enable-if": "ENABLE_TEXT_AUTOSIZING" >+ }, >+ "status": "non-standard" >+ }, > "-webkit-text-emphasis": { > "inherited": true, > "codegen-properties": { >diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp >index 2da5ec114c4b8a371342b52503407e1273a096bb..a42954dcb444fe25927ddfb47a24a376baae836d 100644 >--- a/Source/WebCore/css/StyleResolver.cpp >+++ b/Source/WebCore/css/StyleResolver.cpp >@@ -873,6 +873,61 @@ static OptionSet<TouchAction> computeEffectiveTouchActions(const RenderStyle& st > } > #endif > >+#if ENABLE(TEXT_AUTOSIZING) >+static AutosizeStatus applyStyleToAutosizeStatus(AutosizeStatus result, const RenderStyle& style) >+{ >+ if (style.hasOutOfFlowPosition()) >+ result.foundOutOfFlowPosition = true; >+ if (style.floating() != Float::No) >+ result.foundFloat = true; >+ switch (style.display()) { >+ case DisplayType::InlineBlock: >+ result.foundInlineBlock = true; >+ break; >+ case DisplayType::None: >+ result.foundDisplayNone = true; >+ break; >+ default: // FIXME: Add more cases. >+ break; >+ } >+ if (style.height().isFixed()) >+ result.foundFixedHeight = true; >+ return result; >+} >+ >+static inline float idempotentTextSize(float specifiedSize, float pageScale) >+{ >+ // This describes a piecewise curve when the page scale is 2/3. >+ FloatPoint points[] = { {0.0f, 0.0f}, {6.0f, 12.0f}, {12.0f, 18.0f} }; >+ >+ // When the page scale is 1, the curve should be the identity. >+ // Linearly interpolate between the curve above and identity based on the page scale. >+ // Beware that depending on the specific values picked in the curve, this interpolation might change the shape of the curve for very small pageScales. >+ pageScale = std::min(std::max(pageScale, 0.5f), 1.0f); >+ auto scalePoint = [&](FloatPoint point) { >+ float fraction = 3.0f - 3.0f * pageScale; >+ point.setY(point.x() + (point.y() - point.x()) * fraction); >+ return point; >+ }; >+ >+ if (specifiedSize <= 0) >+ return 0; >+ >+ float result = scalePoint(points[WTF_ARRAY_LENGTH(points) - 1]).y(); >+ for (size_t i = 1; i < WTF_ARRAY_LENGTH(points); ++i) { >+ if (points[i].x() < specifiedSize) >+ continue; >+ auto leftPoint = scalePoint(points[i - 1]); >+ auto rightPoint = scalePoint(points[i]); >+ float fraction = (specifiedSize - leftPoint.x()) / (rightPoint.x() - leftPoint.x()); >+ result = leftPoint.y() + fraction * (rightPoint.y() - leftPoint.y()); >+ break; >+ } >+ >+ return std::max(result, specifiedSize); >+} >+#endif >+ > void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* element) > { > // If the composed tree parent has display:contents, the parent box style will be different from the parent style. >@@ -1123,6 +1178,17 @@ void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& par > style.setEffectiveTouchActions(computeEffectiveTouchActions(style, parentStyle.effectiveTouchActions())); > #endif > >+#if ENABLE(TEXT_AUTOSIZING) >+ auto newAutosizeStatus = applyStyleToAutosizeStatus(style.autosizeStatus(), style); >+ style.setAutosizeStatus(newAutosizeStatus); >+ if (!newAutosizeStatus.shouldSkipSubtree()) { >+ auto fontDescription = style.fontDescription(); >+ fontDescription.setComputedSize(idempotentTextSize(fontDescription.computedSize(), 0.66)); >+ style.setFontDescription(WTFMove(fontDescription)); >+ style.fontCascade().update(&document().fontSelector()); >+ } >+#endif >+ > if (element) > adjustRenderStyleForSiteSpecificQuirks(style, *element); > } >diff --git a/Source/WebCore/page/FrameViewLayoutContext.cpp b/Source/WebCore/page/FrameViewLayoutContext.cpp >index c61085c476383f0c4b3920b0d9b083475d411eff..84f37b13b5f787ef5d6be08b8b167d15f7b41aea 100644 >--- a/Source/WebCore/page/FrameViewLayoutContext.cpp >+++ b/Source/WebCore/page/FrameViewLayoutContext.cpp >@@ -491,9 +491,9 @@ bool FrameViewLayoutContext::canPerformLayout() const > void FrameViewLayoutContext::applyTextSizingIfNeeded(RenderElement& layoutRoot) > { > auto& settings = layoutRoot.settings(); >- if (!settings.textAutosizingEnabled() || renderView()->printing()) >- return; > bool idempotentMode = settings.textAutosizingUsesIdempotentMode(); >+ if (!settings.textAutosizingEnabled() || idempotentMode || renderView()->printing()) >+ return; > auto minimumZoomFontSize = settings.minimumZoomFontSize(); > if (!idempotentMode && !minimumZoomFontSize) > return; >diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp >index feeb708b2fb825c96850e13b4803a94b4067e211..c090fbcc8d1353e9c7c3160f6c62636a158bb883 100644 >--- a/Source/WebCore/rendering/style/RenderStyle.cpp >+++ b/Source/WebCore/rendering/style/RenderStyle.cpp >@@ -165,6 +165,13 @@ RenderStyle::RenderStyle(CreateDefaultStyleTag) > m_inheritedFlags.insideLink = static_cast<unsigned>(InsideLink::NotInside); > m_inheritedFlags.insideDefaultButton = false; > m_inheritedFlags.writingMode = initialWritingMode(); >+#if ENABLE(TEXT_AUTOSIZING) >+ m_inheritedFlags.textAutosizingFoundOutOfFlowPosition = false; >+ m_inheritedFlags.textAutosizingFoundFloat = false; >+ m_inheritedFlags.textAutosizingFoundInlineBlock = false; >+ m_inheritedFlags.textAutosizingFoundFixedHeight = false; >+ m_inheritedFlags.textAutosizingFoundDisplayNone = false; >+#endif > > m_nonInheritedFlags.effectiveDisplay = static_cast<unsigned>(initialDisplay()); > m_nonInheritedFlags.originalDisplay = static_cast<unsigned>(initialDisplay()); >diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h >index 68576ac4caf2fa7607649cc99aaaf9551c3a65a2..93982be530467bc84d939944c02a6104362a8687 100644 >--- a/Source/WebCore/rendering/style/RenderStyle.h >+++ b/Source/WebCore/rendering/style/RenderStyle.h >@@ -744,6 +744,15 @@ public: > > #if ENABLE(TEXT_AUTOSIZING) > TextSizeAdjustment textSizeAdjust() const { return m_rareInheritedData->textSizeAdjust; } >+ AutosizeStatus autosizeStatus() const >+ { >+ return { >+ static_cast<bool>(m_inheritedFlags.textAutosizingFoundOutOfFlowPosition), >+ static_cast<bool>(m_inheritedFlags.textAutosizingFoundFloat), >+ static_cast<bool>(m_inheritedFlags.textAutosizingFoundInlineBlock), >+ static_cast<bool>(m_inheritedFlags.textAutosizingFoundFixedHeight), >+ static_cast<bool>(m_inheritedFlags.textAutosizingFoundDisplayNone) }; >+ } > #endif > > TextSecurity textSecurity() const { return static_cast<TextSecurity>(m_rareInheritedData->textSecurity); } >@@ -1258,6 +1267,14 @@ public: > > #if ENABLE(TEXT_AUTOSIZING) > void setTextSizeAdjust(TextSizeAdjustment adjustment) { SET_VAR(m_rareInheritedData, textSizeAdjust, adjustment); } >+ void setAutosizeStatus(AutosizeStatus autosizeStatus) >+ { >+ m_inheritedFlags.textAutosizingFoundOutOfFlowPosition = autosizeStatus.foundOutOfFlowPosition; >+ m_inheritedFlags.textAutosizingFoundFloat = autosizeStatus.foundFloat; >+ m_inheritedFlags.textAutosizingFoundInlineBlock = autosizeStatus.foundInlineBlock; >+ m_inheritedFlags.textAutosizingFoundFixedHeight = autosizeStatus.foundFixedHeight; >+ m_inheritedFlags.textAutosizingFoundDisplayNone = autosizeStatus.foundDisplayNone; >+ } > #endif > > void setTextSecurity(TextSecurity security) { SET_VAR(m_rareInheritedData, textSecurity, static_cast<unsigned>(security)); } >@@ -1845,6 +1862,16 @@ private: > // CSS Text Layout Module Level 3: Vertical writing support > unsigned writingMode : 2; // WritingMode > // 48 bits >+ >+#if ENABLE(TEXT_AUTOSIZING) >+ // This is the state that the text autosizing code uses to determine whether or not to apply autosizing. >+ unsigned textAutosizingFoundOutOfFlowPosition : 1; >+ unsigned textAutosizingFoundFloat : 1; >+ unsigned textAutosizingFoundInlineBlock : 1; >+ unsigned textAutosizingFoundFixedHeight : 1; >+ unsigned textAutosizingFoundDisplayNone : 1; >+#endif >+ // 53 bits > }; > > // This constructor is used to implement the replace operation. >diff --git a/Source/WebCore/rendering/style/TextSizeAdjustment.h b/Source/WebCore/rendering/style/TextSizeAdjustment.h >index f37c30146bec604df7fddb57c92c7eb66caee401..8ae7925e3d443431064eac4ceacc615d09919376 100644 >--- a/Source/WebCore/rendering/style/TextSizeAdjustment.h >+++ b/Source/WebCore/rendering/style/TextSizeAdjustment.h >@@ -45,6 +45,19 @@ private: > float m_value; > }; > >+struct AutosizeStatus { >+ bool foundOutOfFlowPosition { false }; >+ bool foundFloat { false }; >+ bool foundInlineBlock { false }; >+ bool foundFixedHeight { false }; >+ bool foundDisplayNone { false }; >+ >+ bool shouldSkipSubtree() const >+ { >+ return foundOutOfFlowPosition || foundFloat || foundInlineBlock || foundFixedHeight || foundDisplayNone; >+ } >+}; >+ > } // namespace WebCore > > #endif // ENABLE(TEXT_AUTOSIZING)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197808
:
369628
|
369753
|
369914
|
369915
|
370290
|
370498
|
370542
|
370543
|
370558
|
370591
|
370606
|
370615
|
370617