Title: [236290] trunk/Source/WebCore
Revision
236290
Author
[email protected]
Date
2018-09-20 16:11:56 -0700 (Thu, 20 Sep 2018)

Log Message

Adopt safe-area-insets on ImageDocument
https://bugs.webkit.org/show_bug.cgi?id=189774

Reviewed by Tim Horton.
rdar://problem/44624432

By having the safe-area insets on the image, we ensure that they only
grow the document if there is not enough space. This also ensures the image
does not have parts under UI elements.

* html/ImageDocument.cpp:
(WebCore::ImageDocument::createDocumentStructure):
(WebCore::ImageDocument::imageUpdated):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (236289 => 236290)


--- trunk/Source/WebCore/ChangeLog	2018-09-20 23:11:19 UTC (rev 236289)
+++ trunk/Source/WebCore/ChangeLog	2018-09-20 23:11:56 UTC (rev 236290)
@@ -1,3 +1,19 @@
+2018-09-20  Benjamin Poulain  <[email protected]>
+
+        Adopt safe-area-insets on ImageDocument
+        https://bugs.webkit.org/show_bug.cgi?id=189774
+
+        Reviewed by Tim Horton.
+        rdar://problem/44624432
+
+        By having the safe-area insets on the image, we ensure that they only
+        grow the document if there is not enough space. This also ensures the image
+        does not have parts under UI elements.
+
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::createDocumentStructure):
+        (WebCore::ImageDocument::imageUpdated):
+
 2018-09-20  Zalan Bujtas  <[email protected]>
 
         Release assert under RenderView::pageOrViewLogicalHeight

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (236289 => 236290)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2018-09-20 23:11:19 UTC (rev 236289)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2018-09-20 23:11:56 UTC (rev 236290)
@@ -233,9 +233,9 @@
     
     auto imageElement = ImageDocumentElement::create(*this);
     if (m_shouldShrinkImage)
-        imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto;");
+        imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);");
     else
-        imageElement->setAttribute(styleAttr, "-webkit-user-select:none;");
+        imageElement->setAttribute(styleAttr, "-webkit-user-select:none; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);");
     imageElement->setLoadManually(true);
     imageElement->setSrc(url().string());
     imageElement->cachedImage()->setResponse(loader()->response());
@@ -244,7 +244,7 @@
     if (m_shouldShrinkImage) {
 #if PLATFORM(IOS)
         // Set the viewport to be in device pixels (rather than the default of 980).
-        processViewport("width=device-width"_s, ViewportArguments::ImageDocument);
+        processViewport("width=device-width,viewport-fit=cover"_s, ViewportArguments::ImageDocument);
 #else
         auto listener = ImageEventListener::create(*this);
         if (RefPtr<DOMWindow> window = this->domWindow())
@@ -273,7 +273,8 @@
 #if PLATFORM(IOS)
         FloatSize screenSize = page()->chrome().screenSize();
         if (imageSize.width() > screenSize.width())
-            processViewport(String::format("width=%u", static_cast<unsigned>(imageSize.width().toInt())), ViewportArguments::ImageDocument);
+            processViewport(String::format("width=%u,viewport-fit=cover", static_cast<unsigned>(imageSize.width().toInt())), ViewportArguments::ImageDocument);
+
         if (page())
             page()->chrome().client().imageOrMediaDocumentSizeChanged(IntSize(imageSize.width(), imageSize.height()));
 #else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to