Large in-place attachment elements cause the document width to expand when inserted
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jan 2018 22:00:52 +0000 (22:00 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jan 2018 22:00:52 +0000 (22:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181614

Reviewed by Dan Bernstein.

Make in-place images and videos have a max-width of 100%, so that large attachments aren't inserted with full
display size, causing the document and viewport width to expand.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226915 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttachmentElement.cpp

index b3876a9..168fe0d 100644 (file)
@@ -1,3 +1,16 @@
+2018-01-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Large in-place attachment elements cause the document width to expand when inserted
+        https://bugs.webkit.org/show_bug.cgi?id=181614
+
+        Reviewed by Dan Bernstein.
+
+        Make in-place images and videos have a max-width of 100%, so that large attachments aren't inserted with full
+        display size, causing the document and viewport width to expand.
+
+        * html/HTMLAttachmentElement.cpp:
+        (WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary):
+
 2018-01-12  Keith Rollin  <krollin@apple.com>
 
         Logged JSON should escape "'s and \'s in strings.
index 1823f33..636e25e 100644 (file)
@@ -285,6 +285,7 @@ void HTMLAttachmentElement::populateShadowRootIfNecessary()
             image->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
             image->setAttributeWithoutSynchronization(draggableAttr, AtomicString("false"));
             image->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
+            image->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
         }
 
     } else if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType)) {
@@ -293,6 +294,7 @@ void HTMLAttachmentElement::populateShadowRootIfNecessary()
             video->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
             video->setAttributeWithoutSynchronization(controlsAttr, emptyString());
             video->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
+            video->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
         }
     }
 }