logo

etc_portage

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/etc_portage.git

0008-WebCore-html-ImageDocument.cpp-Enhance-Image-Viewer.patch (3210B)


  1. From 577a193afca81b7c367e84737efd39901f0cb136 Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Wed, 13 Mar 2019 07:55:17 +0100
  4. Subject: [PATCH 8/8] WebCore/html/ImageDocument.cpp: Enhance Image Viewer
  5. The following chances allows to center the image when viewed and avoids
  6. setting the now useless width/height attributes.
  7. ---
  8. Source/WebCore/html/ImageDocument.cpp | 24 ++++++++++--------------
  9. 1 file changed, 10 insertions(+), 14 deletions(-)
  10. diff --git a/Source/WebCore/html/ImageDocument.cpp b/Source/WebCore/html/ImageDocument.cpp
  11. index 0518ff867d..cd2a0c67aa 100644
  12. --- a/Source/WebCore/html/ImageDocument.cpp
  13. +++ b/Source/WebCore/html/ImageDocument.cpp
  14. @@ -226,16 +226,17 @@ void ImageDocument::createDocumentStructure()
  15. rootElement->appendChild(head);
  16. auto body = HTMLBodyElement::create(*this);
  17. - body->setAttribute(styleAttr, "margin: 0px");
  18. + body->setAttribute(styleAttr, "margin: 0; display: flex;");
  19. if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
  20. body->setInlineStyleProperty(CSSPropertyBackgroundColor, "white");
  21. rootElement->appendChild(body);
  22. auto imageElement = ImageDocumentElement::create(*this);
  23. - if (m_shouldShrinkImage)
  24. - imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto;");
  25. - else
  26. - imageElement->setAttribute(styleAttr, "-webkit-user-select:none;");
  27. + //imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto; object-fit:contain;");
  28. + imageElement->setInlineStyleProperty(CSSPropertyWebkitUserSelect, "none");
  29. + imageElement->setInlineStyleProperty(CSSPropertyDisplay, "block");
  30. + imageElement->setInlineStyleProperty(CSSPropertyMargin, "auto");
  31. + imageElement->setInlineStyleProperty(CSSPropertyObjectFit, "contain");
  32. imageElement->setLoadManually(true);
  33. imageElement->setSrc(url().string());
  34. imageElement->cachedImage()->setResponse(loader()->response());
  35. @@ -307,13 +308,9 @@ void ImageDocument::resizeImageToFit()
  36. if (!m_imageElement)
  37. return;
  38. - LayoutSize imageSize = this->imageSize();
  39. -
  40. - float scale = this->scale();
  41. - m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
  42. - m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
  43. -
  44. m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueZoomIn);
  45. + m_imageElement->setInlineStyleProperty(CSSPropertyMaxWidth, "100%");
  46. + m_imageElement->setInlineStyleProperty(CSSPropertyMaxHeight, "100%");
  47. }
  48. void ImageDocument::restoreImageSize()
  49. @@ -321,9 +318,8 @@ void ImageDocument::restoreImageSize()
  50. if (!m_imageElement || !m_imageSizeIsKnown)
  51. return;
  52. - LayoutSize imageSize = this->imageSize();
  53. - m_imageElement->setWidth(imageSize.width().toUnsigned());
  54. - m_imageElement->setHeight(imageSize.height().toUnsigned());
  55. + m_imageElement->removeInlineStyleProperty(CSSPropertyMaxWidth);
  56. + m_imageElement->removeInlineStyleProperty(CSSPropertyMaxHeight);
  57. if (imageFitsInWindow())
  58. m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
  59. --
  60. 2.19.2