WebKit Bugzilla
Attachment 368281 Details for
Bug 197250
: [iOS] Implement idempotent mode for text autosizing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197250-20190425160038.patch (text/plain), 28.08 KB, created by
Myles C. Maxfield
on 2019-04-25 16:00:39 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-04-25 16:00:39 PDT
Size:
28.08 KB
patch
obsolete
>Subversion Revision: 244667 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 392a5b91bb7cffa7a5f1952d2080cb02fa243f76..c9ccb8a20825082b2f1c9355ebbc13bd67a6c4a3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,48 @@ >+2019-04-25 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [iOS] Implement idempotent mode for text autosizing >+ https://bugs.webkit.org/show_bug.cgi?id=197250 >+ <rdar://problem/50211034> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Our text autosizing code has this interesting behavior where it is sensitive to the width of the text's container >+ and the number of lines of text inside the element. Not only is it sensitive to those things, but as those things >+ change, their values are stored inside the RenderObject itself and then never recomputed. This means that the text >+ autosizing parameters are sensitive to the entire history of an element. So, a newly created element with the same >+ style as an existing element can have dramatically different results. >+ >+ This patch adds a new mode for text autosizing, which isn't sensitive to either of those things, and therefore >+ maintains the invariant that a newly created element will behave the same as an existing element with the same style. >+ Instead of using container size, it instead uses the viewport's initial scale. As the viewport's initial scale >+ changes, new layouts will be triggered, which will cause the autosizing code to use the new value. >+ >+ Tests: fast/text-autosizing/ios/idempotent-autosizing-identity.html >+ fast/text-autosizing/ios/idempotent-autosizing.html >+ >+ * page/FrameViewLayoutContext.cpp: >+ (WebCore::FrameViewLayoutContext::applyTextSizingIfNeeded): >+ * page/Page.cpp: >+ (WebCore::Page::setInitialScale): WebKit will push the initial scale down into the page. >+ * page/Page.h: >+ (WebCore::Page::initialScale const): >+ * page/SettingsBase.h: >+ * page/cocoa/SettingsBaseCocoa.mm: >+ (WebCore::SettingsBase::textAutosizingUsesIdempotentMode): >+ (WebCore::SettingsBase::defaultTextAutosizingEnabled): >+ * rendering/RenderBlockFlow.cpp: >+ (WebCore::idempotentTextSize): Describe a piecewise-linear curve for the text size to follow. The curve scales >+ depending on the viewport's initial scale. >+ (WebCore::RenderBlockFlow::adjustComputedFontSizes): >+ * rendering/RenderBlockFlow.h: >+ * rendering/RenderElement.cpp: >+ (WebCore::includeNonFixedHeight): This new mode should consider max-height as well as height when determining if >+ content overflows. >+ (WebCore::RenderElement::adjustComputedFontSizesOnBlocks): >+ (WebCore::RenderElement::resetTextAutosizing): >+ * rendering/RenderElement.h: >+ * rendering/RenderObject.h: >+ > 2019-04-25 Timothy Hatcher <timothy@apple.com> > > Disable ContentChangeObserver on iOSMac. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 740eac9e0d5a95b6d8a9da19553cd49138f74add..96df670d49b97f784475e7b1203a984e430616b0 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,17 @@ >+2019-04-25 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [iOS] Implement idempotent mode for text autosizing >+ https://bugs.webkit.org/show_bug.cgi?id=197250 >+ <rdar://problem/50211034> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Push the initial scale down into the page. >+ >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::dynamicViewportSizeUpdate): >+ (WebKit::WebPage::viewportConfigurationChanged): >+ > 2019-04-25 Timothy Hatcher <timothy@apple.com> > > Only send a synthetic mouse out event if synthetic mouse move events were sent. >diff --git a/Source/WebCore/page/FrameViewLayoutContext.cpp b/Source/WebCore/page/FrameViewLayoutContext.cpp >index 5901de0fd96526b12d6125a5b11bc45ece5a342a..c61085c476383f0c4b3920b0d9b083475d411eff 100644 >--- a/Source/WebCore/page/FrameViewLayoutContext.cpp >+++ b/Source/WebCore/page/FrameViewLayoutContext.cpp >@@ -493,13 +493,14 @@ void FrameViewLayoutContext::applyTextSizingIfNeeded(RenderElement& layoutRoot) > auto& settings = layoutRoot.settings(); > if (!settings.textAutosizingEnabled() || renderView()->printing()) > return; >+ bool idempotentMode = settings.textAutosizingUsesIdempotentMode(); > auto minimumZoomFontSize = settings.minimumZoomFontSize(); >- if (!minimumZoomFontSize) >+ if (!idempotentMode && !minimumZoomFontSize) > return; > auto textAutosizingWidth = layoutRoot.page().textAutosizingWidth(); > if (auto overrideWidth = settings.textAutosizingWindowSizeOverride().width()) > textAutosizingWidth = overrideWidth; >- if (!textAutosizingWidth) >+ if (!idempotentMode && !textAutosizingWidth) > return; > layoutRoot.adjustComputedFontSizesOnBlocks(minimumZoomFontSize, textAutosizingWidth); > if (!layoutRoot.needsLayout()) >diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp >index 965eb475a85abaef1a91a7257137f57ab71f0ec7..067c341135314619b9f2330bf6995ade1d75406c 100644 >--- a/Source/WebCore/page/Page.cpp >+++ b/Source/WebCore/page/Page.cpp >@@ -1077,6 +1077,11 @@ void Page::setDeviceScaleFactor(float scaleFactor) > pageOverlayController().didChangeDeviceScaleFactor(); > } > >+void Page::setInitialScale(float initialScale) >+{ >+ m_initialScale = initialScale; >+} >+ > void Page::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection) > { > if (m_userInterfaceLayoutDirection == userInterfaceLayoutDirection) >diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h >index dcd1f2dfba3b1246dd395f57f718c179b9c3b4be..666144b2a038f3df374a1b5bfe8fae3ee052e714 100644 >--- a/Source/WebCore/page/Page.h >+++ b/Source/WebCore/page/Page.h >@@ -353,6 +353,9 @@ public: > float deviceScaleFactor() const { return m_deviceScaleFactor; } > WEBCORE_EXPORT void setDeviceScaleFactor(float); > >+ float initialScale() const { return m_initialScale; } >+ WEBCORE_EXPORT void setInitialScale(float); >+ > float topContentInset() const { return m_topContentInset; } > WEBCORE_EXPORT void setTopContentInset(float); > >@@ -834,6 +837,7 @@ private: > #if ENABLE(TEXT_AUTOSIZING) > float m_textAutosizingWidth { 0 }; > #endif >+ float m_initialScale { 1.0f }; > > bool m_suppressScrollbarAnimations { false }; > >diff --git a/Source/WebCore/page/Settings.yaml b/Source/WebCore/page/Settings.yaml >index e3e09eead5c005a84635342802ee3bcca93b0d59..e47d7eb4cb5d7c4ab3a121eb3ffe67a3a9accf59 100644 >--- a/Source/WebCore/page/Settings.yaml >+++ b/Source/WebCore/page/Settings.yaml >@@ -440,6 +440,10 @@ minimumZoomFontSize: > type: float > initial: defaultMinimumZoomFontSize() > conditional: TEXT_AUTOSIZING >+textAutosizingUsesIdempotentMode: >+ initial: defaultTextAutosizingUsesIdempotentMode() >+ onChange: setNeedsRecalcStyleInAllFrames >+ conditional: TEXT_AUTOSIZING > > subpixelAntialiasedLayerTextEnabled: > initial: false >diff --git a/Source/WebCore/page/SettingsBase.cpp b/Source/WebCore/page/SettingsBase.cpp >index a3533e910eb3583057c2129f8a9c3ed2559122cb..582f23b74bc32e2c802aa45864f2310d2c2170be 100644 >--- a/Source/WebCore/page/SettingsBase.cpp >+++ b/Source/WebCore/page/SettingsBase.cpp >@@ -96,6 +96,11 @@ bool SettingsBase::defaultTextAutosizingEnabled() > { > return false; > } >+ >+bool SettingsBase::defaultTextAutosizingUsesIdempotentMode() >+{ >+ return false; >+} > #endif > > bool SettingsBase::defaultDownloadableBinaryFontsEnabled() >diff --git a/Source/WebCore/page/SettingsBase.h b/Source/WebCore/page/SettingsBase.h >index 3533b8f9ad6371fc171df5d58b97b53f485d306a..42622f132c7d0c278a9cc218da982fcb200edfca 100644 >--- a/Source/WebCore/page/SettingsBase.h >+++ b/Source/WebCore/page/SettingsBase.h >@@ -113,6 +113,7 @@ public: > static const SettingsBase::ForcedAccessibilityValue defaultForcedPrefersReducedMotionAccessibilityValue = ForcedAccessibilityValue::System; > > WEBCORE_EXPORT static bool defaultTextAutosizingEnabled(); >+ static bool defaultTextAutosizingUsesIdempotentMode(); > WEBCORE_EXPORT static float defaultMinimumZoomFontSize(); > WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled(); > WEBCORE_EXPORT static bool defaultContentChangeObserverEnabled(); >diff --git a/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm b/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >index 0e413d2f2bbefec071c5c991173f265324fc35e5..ec232fcbebec50d5e8a96ca8605aaefa94f43163 100644 >--- a/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >+++ b/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >@@ -66,6 +66,11 @@ bool SettingsBase::platformDefaultMediaSourceEnabled() > return true; > } > >+bool SettingsBase::textAutosizingUsesIdempotentMode() >+{ >+ return false; >+} >+ > #else > > void SettingsBase::initializeDefaultFontFamilies() >@@ -83,7 +88,12 @@ void SettingsBase::initializeDefaultFontFamilies() > > bool SettingsBase::defaultTextAutosizingEnabled() > { >- return !deviceHasIPadCapability() || [[PAL::getUIApplicationClass() sharedApplication] _isClassic]; >+ return true; >+} >+ >+bool SettingsBase::defaultTextAutosizingUsesIdempotentMode() >+{ >+ return deviceHasIPadCapability() && ![[PAL::getUIApplicationClass() sharedApplication] _isClassic]; > } > > #endif >diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp >index 0ecf11fa2a62e80af165ea09abfbce021dce501c..12349c672544848cd901e785b155142a499e4c33 100644 >--- a/Source/WebCore/rendering/RenderBlockFlow.cpp >+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp >@@ -3723,12 +3723,41 @@ static inline float textMultiplier(RenderObject& renderer, float specifiedSize) > return std::max((1.0f / log10f(specifiedSize) * coefficient), 1.0f); > } > >-void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth) >+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); >+ for (auto& point : points) { >+ float fraction = 3.0f - 3.0f * pageScale; >+ point.setY(point.x() + (point.y() - point.x()) * fraction); >+ } >+ >+ if (specifiedSize <= 0) >+ return 0; >+ >+ float result = points[WTF_ARRAY_LENGTH(points) - 1].y(); >+ for (size_t i = 1; i < WTF_ARRAY_LENGTH(points); ++i) { >+ if (points[i].x() < specifiedSize) >+ continue; >+ float fraction = (specifiedSize - points[i - 1].x()) / (points[i].x() - points[i - 1].x()); >+ result = points[i - 1].y() + fraction * (points[i].y() - points[i - 1].y()); >+ break; >+ } >+ >+ return std::max(result, specifiedSize); >+} >+ >+void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth, float pageScale, bool idempotentMode) > { > LOG(TextAutosizing, "RenderBlockFlow %p adjustComputedFontSizes, size=%f visibleWidth=%f, width()=%f. Bailing: %d", this, size, visibleWidth, width().toFloat(), visibleWidth >= width()); > > // Don't do any work if the block is smaller than the visible area. >- if (visibleWidth >= width()) >+ if (!idempotentMode && visibleWidth >= width()) > return; > > unsigned lineCount; >@@ -3766,7 +3795,7 @@ void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth) > auto& fontDescription = oldStyle.fontDescription(); > float specifiedSize = fontDescription.specifiedSize(); > float scaledSize = roundf(specifiedSize * scale); >- if (scaledSize > 0 && scaledSize < minFontSize) { >+ if (idempotentMode || (scaledSize > 0 && scaledSize < minFontSize)) { > // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing. > // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915). > if (m_lineCountForTextAutosizing == NOT_SET) >@@ -3774,8 +3803,15 @@ void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth) > if (m_widthForTextAutosizing == -1) > m_widthForTextAutosizing = actualWidth; > >- float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(text, specifiedSize) : textMultiplier(text, specifiedSize); >- float candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier)); >+ float candidateNewSize; >+ if (idempotentMode) { >+ float lineTextSize = idempotentTextSize(specifiedSize, pageScale); >+ candidateNewSize = roundf(lineTextSize); >+ } else { >+ float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(text, specifiedSize) : textMultiplier(text, specifiedSize); >+ candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier)); >+ } >+ > if (candidateNewSize > specifiedSize && candidateNewSize != fontDescription.computedSize() && text.textNode() && oldStyle.textSizeAdjust().isAuto()) > document().textAutoSizing().addTextNode(*text.textNode(), candidateNewSize); > } >diff --git a/Source/WebCore/rendering/RenderBlockFlow.h b/Source/WebCore/rendering/RenderBlockFlow.h >index bdbbe3ceb5f7fb6450a16819ced5669ce13c7410..c4ce223aec575476f44008c81a1ae7940619b78c 100644 >--- a/Source/WebCore/rendering/RenderBlockFlow.h >+++ b/Source/WebCore/rendering/RenderBlockFlow.h >@@ -604,7 +604,7 @@ public: > > #if ENABLE(TEXT_AUTOSIZING) > int lineCountForTextAutosizing(); >- void adjustComputedFontSizes(float size, float visibleWidth); >+ void adjustComputedFontSizes(float size, float visibleWidth, float pageScale, bool idempotentMode); > void resetComputedFontSize() > { > m_widthForTextAutosizing = -1; >diff --git a/Source/WebCore/rendering/RenderElement.cpp b/Source/WebCore/rendering/RenderElement.cpp >index fbce49bced98f10339d02b4760231ffdaf9242d4..49d5ec3853ab1dfaf9a038c71389e60a73515794 100644 >--- a/Source/WebCore/rendering/RenderElement.cpp >+++ b/Source/WebCore/rendering/RenderElement.cpp >@@ -2123,6 +2123,8 @@ static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderOb > } > return RenderObject::FixedHeight; > } >+ if (renderer.document().settings().textAutosizingUsesIdempotentMode() && style.maxHeight().type() == Fixed && is<RenderBlock>(renderer) && style.maxHeight().value() <= downcast<RenderBlock>(renderer).layoutOverflowRect().maxY()) >+ return RenderObject::FixedHeight; > return RenderObject::FlexibleHeight; > } > >@@ -2132,9 +2134,12 @@ void RenderElement::adjustComputedFontSizesOnBlocks(float size, float visibleWid > if (!document) > return; > >+ auto pageScale = document->page() ? document->page()->initialScale() : 1.0f; >+ > Vector<int> depthStack; > int currentDepth = 0; > int newFixedDepth = 0; >+ auto idempotentMode = document->settings().textAutosizingUsesIdempotentMode(); > > // We don't apply autosizing to nodes with fixed height normally. > // But we apply it to nodes which are located deep enough >@@ -2147,8 +2152,8 @@ void RenderElement::adjustComputedFontSizesOnBlocks(float size, float visibleWid > depthStack.append(newFixedDepth); > > int stackSize = depthStack.size(); >- if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth)) >- downcast<RenderBlockFlow>(*descendent).adjustComputedFontSizes(size, visibleWidth); >+ if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (idempotentMode || !stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth)) >+ downcast<RenderBlockFlow>(*descendent).adjustComputedFontSizes(size, visibleWidth, pageScale, idempotentMode); > newFixedDepth = 0; > } > >@@ -2169,6 +2174,7 @@ void RenderElement::resetTextAutosizing() > Vector<int> depthStack; > int currentDepth = 0; > int newFixedDepth = 0; >+ auto idempotentMode = document->settings().textAutosizingUsesIdempotentMode(); > > for (RenderObject* descendent = traverseNext(this, includeNonFixedHeight, currentDepth, newFixedDepth); descendent; descendent = descendent->traverseNext(this, includeNonFixedHeight, currentDepth, newFixedDepth)) { > while (depthStack.size() > 0 && currentDepth <= depthStack[depthStack.size() - 1]) >@@ -2177,7 +2183,7 @@ void RenderElement::resetTextAutosizing() > depthStack.append(newFixedDepth); > > int stackSize = depthStack.size(); >- if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth)) >+ if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (idempotentMode || !stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth)) > downcast<RenderBlockFlow>(*descendent).resetComputedFontSize(); > newFixedDepth = 0; > } >diff --git a/Source/WebCore/rendering/RenderObject.h b/Source/WebCore/rendering/RenderObject.h >index 97626dfda8d83d28ac7b34117464aeb511868594..94b47f5c1975e6a03fa0d6f9470f641878816e7f 100644 >--- a/Source/WebCore/rendering/RenderObject.h >+++ b/Source/WebCore/rendering/RenderObject.h >@@ -154,7 +154,7 @@ public: > }; > > typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&); >- RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const; >+ RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const; > #endif > > WEBCORE_EXPORT RenderLayer* enclosingLayer() const; >diff --git a/Source/WebCore/testing/InternalSettings.cpp b/Source/WebCore/testing/InternalSettings.cpp >index 76f66837c6eeb70137551af997816df8c307ea7f..8a29924e8b6855fe81a803b522e7ab1f9c661e8d 100644 >--- a/Source/WebCore/testing/InternalSettings.cpp >+++ b/Source/WebCore/testing/InternalSettings.cpp >@@ -157,6 +157,7 @@ void InternalSettings::Backup::restoreTo(Settings& settings) > #if ENABLE(TEXT_AUTOSIZING) > settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled); > settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride); >+ settings.setTextAutosizingUsesIdempotentMode(m_originalTextAutosizingUsesIdempotentMode); > #endif > settings.setMediaTypeOverride(m_originalMediaTypeOverride); > settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing); >@@ -417,6 +418,18 @@ ExceptionOr<void> InternalSettings::setTextAutosizingWindowSizeOverride(int widt > return { }; > } > >+ExceptionOr<void> InternalSettings::setTextAutosizingUsesIdempotentMode(bool enabled) >+{ >+ if (!m_page) >+ return Exception { InvalidAccessError }; >+#if ENABLE(TEXT_AUTOSIZING) >+ settings().setTextAutosizingUsesIdempotentMode(enabled); >+#else >+ UNUSED_PARAM(enabled); >+#endif >+ return { }; >+} >+ > ExceptionOr<void> InternalSettings::setMediaTypeOverride(const String& mediaType) > { > if (!m_page) >diff --git a/Source/WebCore/testing/InternalSettings.h b/Source/WebCore/testing/InternalSettings.h >index c1788809dacb89452b972aa35bd9633cd3af0e43..919f38126a1854da45b2f310e8959b99b589dd64 100644 >--- a/Source/WebCore/testing/InternalSettings.h >+++ b/Source/WebCore/testing/InternalSettings.h >@@ -61,6 +61,7 @@ public: > ExceptionOr<void> setPictographFontFamily(const String& family, const String& script); > ExceptionOr<void> setTextAutosizingEnabled(bool); > ExceptionOr<void> setTextAutosizingWindowSizeOverride(int width, int height); >+ ExceptionOr<void> setTextAutosizingUsesIdempotentMode(bool); > ExceptionOr<void> setTextAutosizingFontScaleFactor(float); > ExceptionOr<void> setMediaTypeOverride(const String&); > ExceptionOr<void> setCanStartMedia(bool); >@@ -154,6 +155,7 @@ private: > > #if ENABLE(TEXT_AUTOSIZING) > bool m_originalTextAutosizingEnabled; >+ bool m_originalTextAutosizingUsesIdempotentMode; > IntSize m_originalTextAutosizingWindowSizeOverride; > #endif > >diff --git a/Source/WebCore/testing/InternalSettings.idl b/Source/WebCore/testing/InternalSettings.idl >index 31098444418debc8998ec98ecdf68c9825bc1385..20a3785837692e88f1be2118291473ff0b65cddc 100644 >--- a/Source/WebCore/testing/InternalSettings.idl >+++ b/Source/WebCore/testing/InternalSettings.idl >@@ -49,6 +49,7 @@ enum FontLoadTimingOverride { "Block", "Swap", "Failure" }; > > [MayThrowException] void setTextAutosizingEnabled(boolean enabled); > [MayThrowException] void setTextAutosizingWindowSizeOverride(long width, long height); >+ [MayThrowException] void setTextAutosizingUsesIdempotentMode(boolean enabled); > > // Media > [MayThrowException] void setCanStartMedia(boolean enabled); >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index 986d22461fe4c7a9c9ac0cc10de44a9fa21e3efa..ec80a106efa779d68e54a5175957b1216196e542 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -2851,7 +2851,8 @@ void WebPage::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const W > } > > LOG_WITH_STREAM(VisibleRects, stream << "WebPage::dynamicViewportSizeUpdate setting view layout size to " << viewLayoutSize); >- m_viewportConfiguration.setViewLayoutSize(viewLayoutSize); >+ if (m_viewportConfiguration.setViewLayoutSize(viewLayoutSize)) >+ viewportConfigurationChanged(); > IntSize newLayoutSize = m_viewportConfiguration.layoutSize(); > > if (setFixedLayoutSize(newLayoutSize)) >@@ -3030,10 +3031,12 @@ void WebPage::resetViewportDefaultConfiguration(WebFrame* frame, bool hasMobileD > > void WebPage::viewportConfigurationChanged(ZoomToInitialScale zoomToInitialScale) > { >+ double initialScale = m_viewportConfiguration.initialScale(); >+ m_page->setInitialScale(initialScale); >+ > if (setFixedLayoutSize(m_viewportConfiguration.layoutSize())) > resetTextAutosizing(); > >- double initialScale = m_viewportConfiguration.initialScale(); > double scale; > if (m_userHasChangedPageScaleFactor && zoomToInitialScale == ZoomToInitialScale::No) > scale = std::max(std::min(pageScaleFactor(), m_viewportConfiguration.maximumScale()), m_viewportConfiguration.minimumScale()); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index b6edc57eedc9966e45a0f7485236bae374e882c1..93e78396001f81b5516c7ad6c4ef667ed2248374 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,22 @@ >+2019-04-25 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [iOS] Implement idempotent mode for text autosizing >+ https://bugs.webkit.org/show_bug.cgi?id=197250 >+ <rdar://problem/50211034> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add two simple tests that make sure that fonts get autosized > 1x when the layout viewport is wide, >+ and that fonts don't get autosized when the layout viewport isn't wide. >+ >+ We don't want to add tons of tests to test exact values because the curve will likely be tweaked >+ in the future. >+ >+ * fast/text-autosizing/ios/idempotent-autosizing-expected.txt: Added. >+ * fast/text-autosizing/ios/idempotent-autosizing-identity-expected.txt: Added. >+ * fast/text-autosizing/ios/idempotent-autosizing-identity.html: Added. >+ * fast/text-autosizing/ios/idempotent-autosizing.html: Added. >+ > 2019-04-25 Shawn Roberts <sroberts@apple.com> > > fast/harness/render-tree-as-text-options.html Rebaselined test for windows >diff --git a/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-expected.txt b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a40f9163529d5ac7d18634b941c8de92df3c16d8 >--- /dev/null >+++ b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-expected.txt >@@ -0,0 +1,9 @@ >+PASS result is >= 13 >+PASS result is >= 7 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+Test >+Test >+Test >+Test >diff --git a/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity-expected.txt b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b3a6f6294a44c3a7f1bd6c459b218acf08ed5be3 >--- /dev/null >+++ b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity-expected.txt >@@ -0,0 +1,9 @@ >+PASS result is 12 >+PASS result is 6 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+Test >+Test >+Test >+Test >diff --git a/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity.html b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity.html >new file mode 100644 >index 0000000000000000000000000000000000000000..34215c5a4893f8962646d9f05f82abf5aff2a956 >--- /dev/null >+++ b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity.html >@@ -0,0 +1,31 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] --> >+<html> >+<head> >+<meta name="viewport" content="width=device-width, initial-scale=1"> >+<script> >+if (window.internals) { >+ window.internals.settings.setTextAutosizingEnabled(true); >+ window.internals.settings.setTextAutosizingUsesIdempotentMode(true); >+} >+</script> >+<script src="../../../../resources/js-test-pre.js"></script> >+</head> >+<body> >+<div style="background: green;"><span id="target" style="font-size: 12px;">Test</span></div> >+<div style="background: green;"><span style="font-size: 12px;">Test</span></div> >+<div style="background: green;"><span id="target2" style="font-size: 6px;">Test</span></div> >+<div style="background: green;"><span style="font-size: 6px;">Test</span></div> >+<script> >+let target = document.getElementById("target"); >+target.offsetWidth; >+let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size")); >+shouldBe("result", "12"); >+ >+target = document.getElementById("target2"); >+target.offsetWidth; >+result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size")); >+shouldBe("result", "6"); >+</script> >+<script src="../../../../resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing.html b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fc0c678adc8b04f3c1edce6e1c8dd811698d6ef6 >--- /dev/null >+++ b/LayoutTests/fast/text-autosizing/ios/idempotent-autosizing.html >@@ -0,0 +1,31 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] --> >+<html> >+<head> >+<meta name="viewport" content="initial-scale=0.6666"> >+<script> >+if (window.internals) { >+ window.internals.settings.setTextAutosizingEnabled(true); >+ window.internals.settings.setTextAutosizingUsesIdempotentMode(true); >+} >+</script> >+<script src="../../../../resources/js-test-pre.js"></script> >+</head> >+<body> >+<div style="background: green;"><span id="target" style="font-size: 12px;">Test</span></div> >+<div style="background: green;"><span style="font-size: 12px;">Test</span></div> >+<div style="background: green;"><span id="target2" style="font-size: 6px;">Test</span></div> >+<div style="background: green;"><span style="font-size: 6px;">Test</span></div> >+<script> >+let target = document.getElementById("target"); >+target.offsetWidth; >+let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size")); >+shouldBeGreaterThanOrEqual("result", "13"); >+ >+target = document.getElementById("target2"); >+target.offsetWidth; >+result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size")); >+shouldBeGreaterThanOrEqual("result", "7"); >+</script> >+<script src="../../../../resources/js-test-post.js"></script> >+</body> >+</html>
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 197250
:
368190
|
368202
|
368271
|
368273
|
368281
|
368283
|
368296
|
368302
|
368303