Diff
Modified: trunk/LayoutTests/ChangeLog (264026 => 264027)
--- trunk/LayoutTests/ChangeLog 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/LayoutTests/ChangeLog 2020-07-07 17:38:26 UTC (rev 264027)
@@ -1,3 +1,17 @@
+2020-07-07 Tim Horton <[email protected]>
+
+ <attachment> layout does not scale with Dynamic Type size changes
+ https://bugs.webkit.org/show_bug.cgi?id=214023
+ <rdar://problem/64914762>
+
+ Reviewed by Sam Weinig.
+
+ * TestExpectations:
+ * fast/attachment/attachment-dynamic-type-expected.txt: Added.
+ * fast/attachment/attachment-dynamic-type.html: Added.
+ * platform/ios/TestExpectations:
+ Add a test that ensures that changing the content size to XXXL also increases the size of the <attachment>.
+
2020-07-07 Truitt Savell <[email protected]>
[ iOS ] http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html is flaky timing out
Modified: trunk/LayoutTests/TestExpectations (264026 => 264027)
--- trunk/LayoutTests/TestExpectations 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/LayoutTests/TestExpectations 2020-07-07 17:38:26 UTC (rev 264027)
@@ -180,6 +180,7 @@
# This test only makes sense on iOS
fast/attachment/attachment-wrapping-action.html [ Skip ]
fast/attachment/attachment-borderless.html [ Skip ]
+fast/attachment/attachment-dynamic-type.html [ Skip ]
editing/selection/character-granularity-selected-range-after-dismissing-selection.html [ Skip ]
editing/selection/character-granularity-select-text-with-click-handler.html [ Skip ]
editing/selection/caret-after-tap-in-editable-selection.html [ Skip ]
Added: trunk/LayoutTests/fast/attachment/attachment-dynamic-type-expected.txt (0 => 264027)
--- trunk/LayoutTests/fast/attachment/attachment-dynamic-type-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-dynamic-type-expected.txt 2020-07-07 17:38:26 UTC (rev 264027)
@@ -0,0 +1,5 @@
+
+Default: 160 x 119
+Large: 160 x 119
+XXXLarge: 240 x 179
+
Added: trunk/LayoutTests/fast/attachment/attachment-dynamic-type.html (0 => 264027)
--- trunk/LayoutTests/fast/attachment/attachment-dynamic-type.html (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-dynamic-type.html 2020-07-07 17:38:26 UTC (rev 264027)
@@ -0,0 +1,22 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
+<html>
+<body>
+<attachment id="attachment" title=" " type="public.jpeg"></attachment>
+<pre id="log"></pre>
+<script>
+testRunner.dumpAsText();
+
+window._onload_ = function () {
+ var attachment = document.getElementById("attachment");
+
+ function logSize(s) { log.innerText += s + ": " + attachment.offsetWidth + " x " + attachment.offsetHeight + "\n"; }
+
+ logSize("Default");
+ internals.setContentSizeCategory("L");
+ logSize("Large");
+ internals.setContentSizeCategory("XXXL");
+ logSize("XXXLarge");
+}
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios/TestExpectations (264026 => 264027)
--- trunk/LayoutTests/platform/ios/TestExpectations 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2020-07-07 17:38:26 UTC (rev 264027)
@@ -2524,6 +2524,7 @@
fast/attachment/attachment-wrapping-action.html [ Pass ]
fast/attachment/attachment-borderless.html [ Pass ]
+fast/attachment/attachment-dynamic-type.html [ Pass ]
fast/images/pdf-as-image-dest-rect-change.html [ Pass ]
fast/events/page-visibility-iframe-move-test.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (264026 => 264027)
--- trunk/Source/WebCore/ChangeLog 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/ChangeLog 2020-07-07 17:38:26 UTC (rev 264027)
@@ -1,3 +1,42 @@
+2020-07-07 Tim Horton <[email protected]>
+
+ <attachment> layout does not scale with Dynamic Type size changes
+ https://bugs.webkit.org/show_bug.cgi?id=214023
+ <rdar://problem/64914762>
+
+ Reviewed by Sam Weinig.
+
+ Test: fast/attachment/attachment-dynamic-type.html
+
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::shortCaptionPointSizeWithContentSizeCategory):
+ (WebCore::attachmentDynamicTypeScaleFactor):
+ (WebCore::RenderAttachmentInfo::buildWrappedLines):
+ (WebCore::RenderThemeIOS::attachmentIntrinsicSize const):
+ Scale the <attachment> overall size and text line width by the Dynamic Type
+ scaling factor, determined by dividing the resolved point size of two
+ font descriptors created with the Large (default) category and the Current category.
+
+ * rendering/RenderAttachment.cpp:
+ (WebCore::RenderAttachment::layout):
+ * rendering/RenderTheme.h:
+ (WebCore::RenderTheme::attachmentShouldAllowWidthToShrink const):
+ * rendering/RenderThemeIOS.h:
+ Add a RenderTheme bit controlling the behavior introduced in r202117.
+ After r202117, <attachment> elements are never allowed to shrink. This
+ is fine for macOS, where we don't vary the Dynamic Type size, only the content,
+ but undesirable on iOS, where the size of the <attachment> is based solely
+ on Dynamic Type size (and thus can shrink when the size is reduced),
+ and not the content.
+
+ * Configurations/WebCoreTestSupport.xcconfig:
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ (WebCore::Internals::setContentSizeCategory):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ Add a Internals method to change the current Dynamic Type category.
+
2020-07-07 Alex Christensen <[email protected]>
Add WebCoreNSURLSession SPI to send HTTP/2 ping
Modified: trunk/Source/WebCore/Configurations/WebCoreTestSupport.xcconfig (264026 => 264027)
--- trunk/Source/WebCore/Configurations/WebCoreTestSupport.xcconfig 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/Configurations/WebCoreTestSupport.xcconfig 2020-07-07 17:38:26 UTC (rev 264027)
@@ -59,8 +59,7 @@
OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
OTHER_LDFLAGS[sdk=macos*] = $(ASAN_OTHER_LDFLAGS) -framework AppKit $(LIBWEBRTC_LDFLAGS);
-OTHER_LDFLAGS[sdk=iphoneos*] = $(ASAN_OTHER_LDFLAGS) -lAccessibility $(LIBWEBRTC_LDFLAGS);
-OTHER_LDFLAGS[sdk=iphonesimulator*] = $(ASAN_OTHER_LDFLAGS) -lAccessibility $(LIBWEBRTC_LDFLAGS);
+OTHER_LDFLAGS[sdk=iphone*] = $(ASAN_OTHER_LDFLAGS) -lAccessibility -framework CoreText $(LIBWEBRTC_LDFLAGS);
SECT_ORDER_FLAGS = ;
ENTITLEMENTS_REQUIRED = $(ENTITLEMENTS_REQUIRED_USE_INTERNAL_SDK_$(USE_INTERNAL_SDK))
Modified: trunk/Source/WebCore/PAL/ChangeLog (264026 => 264027)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-07-07 17:38:26 UTC (rev 264027)
@@ -1,3 +1,13 @@
+2020-07-07 Tim Horton <[email protected]>
+
+ <attachment> layout does not scale with Dynamic Type size changes
+ https://bugs.webkit.org/show_bug.cgi?id=214023
+ <rdar://problem/64914762>
+
+ Reviewed by Sam Weinig.
+
+ * pal/spi/cocoa/CoreTextSPI.h:
+
2020-07-05 Commit Queue <[email protected]>
Unreviewed, reverting r263960.
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (264026 => 264027)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2020-07-07 17:38:26 UTC (rev 264027)
@@ -150,6 +150,7 @@
extern const CFStringRef kCTFontDescriptorTextStyleEmphasized;
extern const CFStringRef kCTFontContentSizeCategoryL;
+extern const CFStringRef kCTFontContentSizeCategoryXXXL;
extern const CGFloat kCTFontWeightUltraLight;
extern const CGFloat kCTFontWeightThin;
Modified: trunk/Source/WebCore/rendering/RenderAttachment.cpp (264026 => 264027)
--- trunk/Source/WebCore/rendering/RenderAttachment.cpp 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/rendering/RenderAttachment.cpp 2020-07-07 17:38:26 UTC (rev 264027)
@@ -55,8 +55,12 @@
void RenderAttachment::layout()
{
LayoutSize newIntrinsicSize = theme().attachmentIntrinsicSize(*this);
- m_minimumIntrinsicWidth = std::max(m_minimumIntrinsicWidth, newIntrinsicSize.width());
- newIntrinsicSize.setWidth(m_minimumIntrinsicWidth);
+
+ if (!theme().attachmentShouldAllowWidthToShrink(*this)) {
+ m_minimumIntrinsicWidth = std::max(m_minimumIntrinsicWidth, newIntrinsicSize.width());
+ newIntrinsicSize.setWidth(m_minimumIntrinsicWidth);
+ }
+
setIntrinsicSize(newIntrinsicSize);
RenderReplaced::layout();
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (264026 => 264027)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2020-07-07 17:38:26 UTC (rev 264027)
@@ -262,6 +262,7 @@
#if ENABLE(ATTACHMENT_ELEMENT)
virtual LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const { return LayoutSize(); }
virtual int attachmentBaseline(const RenderAttachment&) const { return -1; }
+ virtual bool attachmentShouldAllowWidthToShrink(const RenderAttachment&) const { return false; }
#endif
enum class InnerSpinButtonLayout { Vertical, HorizontalUpLeft, HorizontalUpRight };
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (264026 => 264027)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-07-07 17:38:26 UTC (rev 264027)
@@ -136,6 +136,7 @@
#if ENABLE(ATTACHMENT_ELEMENT)
LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const override;
int attachmentBaseline(const RenderAttachment&) const override;
+ bool attachmentShouldAllowWidthToShrink(const RenderAttachment&) const override { return true; }
bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&) override;
#endif
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (264026 => 264027)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-07-07 17:38:26 UTC (rev 264027)
@@ -73,12 +73,13 @@
#import <CoreGraphics/CoreGraphics.h>
#import <CoreImage/CoreImage.h>
#import <objc/runtime.h>
-#import <pal/ios/UIKitSoftLink.h>
+#import <pal/spi/cocoa/CoreTextSPI.h>
#import <pal/spi/ios/UIKitSPI.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/ObjCRuntimeExtras.h>
#import <wtf/RefPtr.h>
#import <wtf/StdLibExtras.h>
+#import <pal/ios/UIKitSoftLink.h>
@interface WebCoreRenderThemeBundle : NSObject
@end
@@ -1417,6 +1418,22 @@
return adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
}
+static CGFloat shortCaptionPointSizeWithContentSizeCategory(CFStringRef contentSizeCategory)
+{
+ auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleShortCaption1, contentSizeCategory, 0));
+ auto pointSize = adoptCF(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontSizeAttribute));
+ return [dynamic_objc_cast<NSNumber>((__bridge id)pointSize.get()) floatValue];
+}
+
+static CGFloat attachmentDynamicTypeScaleFactor()
+{
+ CGFloat fixedPointSize = shortCaptionPointSizeWithContentSizeCategory(kCTFontContentSizeCategoryL);
+ CGFloat dynamicPointSize = shortCaptionPointSizeWithContentSizeCategory(RenderThemeIOS::singleton().contentSizeCategory());
+ if (!dynamicPointSize || !fixedPointSize)
+ return 1;
+ return std::max<CGFloat>(1, dynamicPointSize / fixedPointSize);
+}
+
static UIColor *attachmentTitleColor() { return [PAL::getUIColorClass() systemGrayColor]; }
static RetainPtr<CTFontRef> attachmentSubtitleFont() { return attachmentTitleFont(); }
@@ -1480,7 +1497,8 @@
RetainPtr<CTFramesetterRef> framesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedText.get()));
CFRange fitRange;
- CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(attachmentWrappingTextMaximumWidth, CGFLOAT_MAX), &fitRange);
+ CGFloat wrappingWidth = attachmentWrappingTextMaximumWidth * attachmentDynamicTypeScaleFactor();
+ CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(wrappingWidth, CGFLOAT_MAX), &fitRange);
RetainPtr<CGPathRef> textPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, textSize.width, textSize.height), nullptr));
RetainPtr<CTFrameRef> textFrame = adoptCF(CTFramesetterCreateFrame(framesetter.get(), fitRange, textPath.get(), nullptr));
@@ -1509,7 +1527,7 @@
RetainPtr<NSAttributedString> ellipsisString = adoptNS([[NSAttributedString alloc] initWithString:@"\u2026" attributes:textAttributes]);
RetainPtr<CTLineRef> ellipsisLine = adoptCF(CTLineCreateWithAttributedString((CFAttributedStringRef)ellipsisString.get()));
CTLineRef remainingLine = (CTLineRef)CFArrayGetValueAtIndex(CTFrameGetLines(remainingFrame.get()), 0);
- RetainPtr<CTLineRef> truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine, attachmentWrappingTextMaximumWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
+ RetainPtr<CTLineRef> truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine, wrappingWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
if (!truncatedLine)
truncatedLine = remainingLine;
@@ -1646,7 +1664,7 @@
LayoutSize RenderThemeIOS::attachmentIntrinsicSize(const RenderAttachment&) const
{
- return LayoutSize(FloatSize(attachmentSize));
+ return LayoutSize(FloatSize(attachmentSize) * attachmentDynamicTypeScaleFactor());
}
int RenderThemeIOS::attachmentBaseline(const RenderAttachment& attachment) const
Modified: trunk/Source/WebCore/testing/Internals.cpp (264026 => 264027)
--- trunk/Source/WebCore/testing/Internals.cpp 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/testing/Internals.cpp 2020-07-07 17:38:26 UTC (rev 264027)
@@ -158,6 +158,7 @@
#include "RenderListBox.h"
#include "RenderMenuList.h"
#include "RenderTheme.h"
+#include "RenderThemeIOS.h"
#include "RenderTreeAsText.h"
#include "RenderView.h"
#include "RenderedDocumentMarker.h"
@@ -330,6 +331,7 @@
#if PLATFORM(COCOA)
#include "SystemBattery.h"
+#include <pal/spi/cocoa/CoreTextSPI.h>
#include <wtf/spi/darwin/SandboxSPI.h>
#endif
@@ -581,6 +583,10 @@
HTMLCanvasElement::setMaxPixelMemoryForTesting(0); // This means use the default value.
DOMWindow::overrideTransientActivationDurationForTesting(WTF::nullopt);
+
+#if PLATFORM(IOS)
+ RenderThemeIOS::setContentSizeCategory(kCTFontContentSizeCategoryL);
+#endif
}
Internals::Internals(Document& document)
@@ -5900,4 +5906,23 @@
}
#endif
+void Internals::setContentSizeCategory(Internals::ContentSizeCategory category)
+{
+#if PLATFORM(IOS)
+ CFStringRef ctCategory = nil;
+ switch (category) {
+ case Internals::ContentSizeCategory::L:
+ ctCategory = kCTFontContentSizeCategoryL;
+ break;
+ case Internals::ContentSizeCategory::XXXL:
+ ctCategory = kCTFontContentSizeCategoryXXXL;
+ break;
+ }
+ RenderThemeIOS::setContentSizeCategory(ctCategory);
+ Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
+#else
+ UNUSED_PARAM(category);
+#endif
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.h (264026 => 264027)
--- trunk/Source/WebCore/testing/Internals.h 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/testing/Internals.h 2020-07-07 17:38:26 UTC (rev 264027)
@@ -1037,6 +1037,9 @@
unsigned mediaKeySessionInternalInstanceSessionObjectRefCount(const MediaKeySession&) const;
#endif
+ enum class ContentSizeCategory { L, XXXL };
+ void setContentSizeCategory(ContentSizeCategory);
+
private:
explicit Internals(Document&);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (264026 => 264027)
--- trunk/Source/WebCore/testing/Internals.idl 2020-07-07 17:22:54 UTC (rev 264026)
+++ trunk/Source/WebCore/testing/Internals.idl 2020-07-07 17:38:26 UTC (rev 264027)
@@ -100,6 +100,11 @@
"Interrupted"
};
+enum ContentSizeCategory {
+ "L",
+ "XXXL"
+};
+
[
ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
Conditional=VIDEO,
@@ -927,4 +932,6 @@
[Conditional=ENCRYPTED_MEDIA] unsigned long mediaKeysInternalInstanceObjectRefCount(MediaKeys mediaKeys);
[Conditional=ENCRYPTED_MEDIA] unsigned long mediaKeySessionInternalInstanceSessionObjectRefCount(MediaKeySession session);
+
+ void setContentSizeCategory(ContentSizeCategory category);
};