Title: [205997] trunk/Source/WebCore
Revision
205997
Author
[email protected]
Date
2016-09-15 14:57:33 -0700 (Thu, 15 Sep 2016)

Log Message

Move RenderObject::shouldRespectImageOrientation to RenderElement.
https://bugs.webkit.org/show_bug.cgi?id=162028

Reviewed by Antti Koivisto.

Tighten the type for imageSizeForRenderer/canRender so that RenderObject::shouldRespectImageOrientation could
be moved to RenderElement.

No change in functionality.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageSizeForRenderer):
* loader/cache/CachedImage.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::shouldRespectImageOrientation):
* rendering/RenderElement.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldRespectImageOrientation): Deleted.
* rendering/RenderObject.h:
* rendering/style/StyleCachedImage.cpp:
(WebCore::StyleCachedImage::canRender):
* rendering/style/StyleCachedImage.h:
* rendering/style/StyleImage.h:
(WebCore::StyleImage::canRender):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205996 => 205997)


--- trunk/Source/WebCore/ChangeLog	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/ChangeLog	2016-09-15 21:57:33 UTC (rev 205997)
@@ -1,3 +1,30 @@
+2016-09-15  Zalan Bujtas  <[email protected]>
+
+        Move RenderObject::shouldRespectImageOrientation to RenderElement.
+        https://bugs.webkit.org/show_bug.cgi?id=162028
+
+        Reviewed by Antti Koivisto.
+
+        Tighten the type for imageSizeForRenderer/canRender so that RenderObject::shouldRespectImageOrientation could
+        be moved to RenderElement.
+
+        No change in functionality.
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::imageSizeForRenderer):
+        * loader/cache/CachedImage.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::shouldRespectImageOrientation):
+        * rendering/RenderElement.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::shouldRespectImageOrientation): Deleted.
+        * rendering/RenderObject.h:
+        * rendering/style/StyleCachedImage.cpp:
+        (WebCore::StyleCachedImage::canRender):
+        * rendering/style/StyleCachedImage.h:
+        * rendering/style/StyleImage.h:
+        (WebCore::StyleImage::canRender):
+
 2016-09-15  Anders Carlsson  <[email protected]>
 
         Fix build.

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (205996 => 205997)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2016-09-15 21:57:33 UTC (rev 205997)
@@ -277,7 +277,7 @@
     return false;
 }
 
-LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType)
+LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType)
 {
     if (!m_image)
         return LayoutSize();

Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (205996 => 205997)


--- trunk/Source/WebCore/loader/cache/CachedImage.h	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h	2016-09-15 21:57:33 UTC (rev 205997)
@@ -64,7 +64,7 @@
     std::pair<Image*, float> brokenImage(float deviceScaleFactor) const; // Returns an image and the image's resolution scale factor.
     bool willPaintBrokenImage() const; 
 
-    bool canRender(const RenderObject* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
+    bool canRender(const RenderElement* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
 
     void setContainerSizeForRenderer(const CachedImageClient*, const LayoutSize&, float);
     bool usesImageContainerSize() const;
@@ -79,7 +79,7 @@
         IntrinsicSize
     };
     // This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom.
-    LayoutSize imageSizeForRenderer(const RenderObject*, float multiplier, SizeType = UsedSize); // returns the size of the complete image.
+    LayoutSize imageSizeForRenderer(const RenderElement*, float multiplier, SizeType = UsedSize); // returns the size of the complete image.
     void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
 
     bool isManuallyCached() const { return m_isManuallyCached; }

Modified: trunk/Source/WebCore/platform/DragImage.cpp (205996 => 205997)


--- trunk/Source/WebCore/platform/DragImage.cpp	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/platform/DragImage.cpp	2016-09-15 21:57:33 UTC (rev 205997)
@@ -31,6 +31,7 @@
 #include "FrameView.h"
 #include "ImageBuffer.h"
 #include "Range.h"
+#include "RenderElement.h"
 #include "RenderObject.h"
 #include "RenderView.h"
 
@@ -97,11 +98,12 @@
 #if ENABLE(CSS_IMAGE_ORIENTATION)
     if (node) {
         RenderObject* renderer = node->renderer();
-        if (!renderer)
+        if (!renderer || !is<RenderElement>(renderer))
             return nullptr;
 
-        orientation.setRespectImageOrientation(renderer->shouldRespectImageOrientation());
-        orientation.setImageOrientationEnum(renderer->style().imageOrientation());
+        auto& renderElement = downcast<RenderElement>(*renderer);
+        orientation.setRespectImageOrientation(renderElement.shouldRespectImageOrientation());
+        orientation.setImageOrientationEnum(renderElement.style().imageOrientation());
     }
 #else
     UNUSED_PARAM(node);

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (205996 => 205997)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2016-09-15 21:57:33 UTC (rev 205997)
@@ -37,6 +37,7 @@
 #include "HTMLAnchorElement.h"
 #include "HTMLBodyElement.h"
 #include "HTMLHtmlElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "Logging.h"
 #include "Page.h"
@@ -2191,6 +2192,18 @@
     return !document().view()->needsFullRepaint() && everHadLayout() && !hasSelfPaintingLayer();
 }
 
+RespectImageOrientationEnum RenderElement::shouldRespectImageOrientation() const
+{
+#if USE(CG) || USE(CAIRO)
+    // This can only be enabled for ports which honor the orientation flag in their drawing code.
+    if (document().isImageDocument())
+        return RespectImageOrientation;
+#endif
+    // Respect the image's orientation if it's being used as a full-page image or it's
+    // an <img> and the setting to respect it everywhere is set.
+    return (frame().settings().shouldRespectImageOrientation() && is<HTMLImageElement>(element())) ? RespectImageOrientation : DoNotRespectImageOrientation;
+}
+
 #if ENABLE(IOS_TEXT_AUTOSIZING)
 static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderObject& renderer)
 {

Modified: trunk/Source/WebCore/rendering/RenderElement.h (205996 => 205997)


--- trunk/Source/WebCore/rendering/RenderElement.h	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2016-09-15 21:57:33 UTC (rev 205997)
@@ -227,6 +227,8 @@
     RenderBlock* containingBlockForFixedPosition() const;
     RenderBlock* containingBlockForAbsolutePosition() const;
 
+    RespectImageOrientationEnum shouldRespectImageOrientation() const;
+
 protected:
     enum BaseTypeFlag {
         RenderLayerModelObjectFlag  = 1 << 0,

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (205996 => 205997)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2016-09-15 21:57:33 UTC (rev 205997)
@@ -1345,18 +1345,6 @@
     return isDescendantOf(&view());
 }
 
-RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const
-{
-#if USE(CG) || USE(CAIRO)
-    // This can only be enabled for ports which honor the orientation flag in their drawing code.
-    if (document().isImageDocument())
-        return RespectImageOrientation;
-#endif
-    // Respect the image's orientation if it's being used as a full-page image or it's
-    // an <img> and the setting to respect it everywhere is set.
-    return (frame().settings().shouldRespectImageOrientation() && is<HTMLImageElement>(node())) ? RespectImageOrientation : DoNotRespectImageOrientation;
-}
-
 static inline RenderElement* containerForElement(const RenderObject& renderer, const RenderLayerModelObject* repaintContainer, bool* repaintContainerSkipped)
 {
     // This method is extremely similar to containingBlock(), but with a few notable

Modified: trunk/Source/WebCore/rendering/RenderObject.h (205996 => 205997)


--- trunk/Source/WebCore/rendering/RenderObject.h	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2016-09-15 21:57:33 UTC (rev 205997)
@@ -793,8 +793,6 @@
         return outlineBoundsForRepaint(nullptr);
     }
 
-    RespectImageOrientationEnum shouldRespectImageOrientation() const;
-
 protected:
     //////////////////////////////////////////
     // Helper functions. Dangerous to use!

Modified: trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp (205996 => 205997)


--- trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp	2016-09-15 21:57:33 UTC (rev 205997)
@@ -101,7 +101,7 @@
     return const_cast<CSSValue*>(m_cssValue.ptr());
 }
 
-bool StyleCachedImage::canRender(const RenderObject* renderer, float multiplier) const
+bool StyleCachedImage::canRender(const RenderElement* renderer, float multiplier) const
 {
     if (!m_cachedImage)
         return false;

Modified: trunk/Source/WebCore/rendering/style/StyleCachedImage.h (205996 => 205997)


--- trunk/Source/WebCore/rendering/style/StyleCachedImage.h	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/style/StyleCachedImage.h	2016-09-15 21:57:33 UTC (rev 205997)
@@ -48,7 +48,7 @@
 
     PassRefPtr<CSSValue> cssValue() const override;
     
-    bool canRender(const RenderObject*, float multiplier) const override;
+    bool canRender(const RenderElement*, float multiplier) const override;
     bool isPending() const override;
     void load(CachedResourceLoader&, const ResourceLoaderOptions&) override;
     bool isLoaded() const override;

Modified: trunk/Source/WebCore/rendering/style/StyleImage.h (205996 => 205997)


--- trunk/Source/WebCore/rendering/style/StyleImage.h	2016-09-15 21:25:56 UTC (rev 205996)
+++ trunk/Source/WebCore/rendering/style/StyleImage.h	2016-09-15 21:57:33 UTC (rev 205997)
@@ -51,7 +51,7 @@
 
     virtual PassRefPtr<CSSValue> cssValue() const = 0;
 
-    virtual bool canRender(const RenderObject*, float /*multiplier*/) const { return true; }
+    virtual bool canRender(const RenderElement*, float /*multiplier*/) const { return true; }
     virtual bool isPending() const = 0;
     virtual void load(CachedResourceLoader&, const ResourceLoaderOptions&) = 0;
     virtual bool isLoaded() const { return true; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to