[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mitz at apple.com mitz at apple.com
Wed Dec 22 13:31:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 114d328f37e8ae2c926d027a424e6d4a71383300
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 18 02:09:08 2010 +0000

    Canvas sizing ignores intrinsic size
    https://bugs.webkit.org/show_bug.cgi?id=46024
    
    Reviewed by Simon Fraser.
    
    WebCore:
    
    Updated fast/replaced/table-percent-height.html
    
    * rendering/RenderEmbeddedObject.cpp:
    (WebCore::RenderEmbeddedObject::RenderEmbeddedObject): If this is used as a proxy
    for <video>, behave like it has an intrinsic size (e.g. preserve aspect ratio when
    width is auto and height is specified).
    * rendering/RenderImage.cpp:
    (WebCore::RenderImage::calcAspectRatioWidth): Changed to explicitly invoke
    RenderBox::calcReplacedHeight(), now that RenderReplaced has its own implementation
    which we don’t want.
    (WebCore::RenderImage::calcAspectRatioHeight): Similarly with calcReplacedWidth().
    * rendering/RenderImage.h:
    * rendering/RenderReplaced.cpp:
    (WebCore::RenderReplaced::RenderReplaced): Initialize m_hasIntrinsicSize.
    (WebCore::lengthIsSpecified): Added this helper function, based on RenderImage’s
    is{Width,Height}Specified().
    (WebCore::RenderReplaced::calcReplacedWidth): Moved from RenderVideo all the way
    up here so other replaced objects could use this logic.
    (WebCore::RenderReplaced::calcReplacedHeight): Ditto.
    (WebCore::RenderReplaced::calcAspectRatioWidth): Ditto.
    (WebCore::RenderReplaced::calcAspectRatioHeight): Ditto.
    (WebCore::RenderReplaced::calcPrefWidths): Replaced with the RenderImage version
    of the logic.
    (WebCore::RenderReplaced::setIntrinsicSize): Added an assertion.
    * rendering/RenderReplaced.h:
    (WebCore::RenderReplaced::minimumReplacedHeight): Promoted from private to protected
    to allow RenderVideo to call through.
    (WebCore::RenderReplaced::setHasIntrinsicSize): Added this setter.
    * rendering/RenderVideo.cpp:
    (WebCore::RenderVideo::updateIntrinsicSize): Factor zoom into the intrinsic size,
    the way other RenderReplaced objects do.
    (WebCore::RenderVideo::calcReplacedWidth): Invoke the RenderReplaced implementation,
    which matches what used to be here, skipping over the RenderImage implementation.
    (WebCore::RenderVideo::calcReplacedHeight): Ditto.
    (WebCore::RenderVideo::minimumReplacedHeight): Ditto.
    * rendering/RenderVideo.h:
    
    LayoutTests:
    
    * fast/replaced/table-percent-height-expected.txt: Updated.
    * fast/replaced/table-percent-height.html: Changed to expect canvas to maintain
    its intrinsic ratio.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67770 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ea9862a..09175aa 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-17  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Canvas sizing ignores intrinsic size
+        https://bugs.webkit.org/show_bug.cgi?id=46024
+
+        * fast/replaced/table-percent-height-expected.txt: Updated.
+        * fast/replaced/table-percent-height.html: Changed to expect canvas to maintain
+        its intrinsic ratio.
+
 2010-09-17  Adam Barth  <abarth at webkit.org>
 
         Remove Leopard specific expected results because these now match Snow
diff --git a/LayoutTests/fast/replaced/table-percent-height-expected.txt b/LayoutTests/fast/replaced/table-percent-height-expected.txt
index d3fde71..11929be 100644
--- a/LayoutTests/fast/replaced/table-percent-height-expected.txt
+++ b/LayoutTests/fast/replaced/table-percent-height-expected.txt
@@ -28,7 +28,7 @@ Note, some of the button height tests fail on the Windows ports. See bug #34071.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS getWidth('canvas-75') is '300px'
+PASS getWidth('canvas-75') is '224px'
 PASS getHeight('canvas-75') is '112px'
 PASS getWidth('canvas-100') is '300px'
 PASS getHeight('canvas-100') is '150px'
diff --git a/LayoutTests/fast/replaced/table-percent-height.html b/LayoutTests/fast/replaced/table-percent-height.html
index 4171650..1b6f058 100644
--- a/LayoutTests/fast/replaced/table-percent-height.html
+++ b/LayoutTests/fast/replaced/table-percent-height.html
@@ -61,7 +61,7 @@ function test()
 {
     description("This test checks that replaced elements with percentage heights within table cells have the correct height.<br>Note, some of the button height tests fail on the Windows ports. See bug #34071.");
 
-    shouldBe("getWidth('canvas-75')", "'300px'");
+    shouldBe("getWidth('canvas-75')", "'224px'");
     shouldBe("getHeight('canvas-75')", "'112px'");
     shouldBe("getWidth('canvas-100')", "'300px'");
     shouldBe("getHeight('canvas-100')", "'150px'");
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c34cf35..e3e1ebf 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-09-17  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Canvas sizing ignores intrinsic size
+        https://bugs.webkit.org/show_bug.cgi?id=46024
+
+        Updated fast/replaced/table-percent-height.html
+
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::RenderEmbeddedObject): If this is used as a proxy
+        for <video>, behave like it has an intrinsic size (e.g. preserve aspect ratio when
+        width is auto and height is specified).
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::calcAspectRatioWidth): Changed to explicitly invoke
+        RenderBox::calcReplacedHeight(), now that RenderReplaced has its own implementation
+        which we don’t want.
+        (WebCore::RenderImage::calcAspectRatioHeight): Similarly with calcReplacedWidth().
+        * rendering/RenderImage.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::RenderReplaced): Initialize m_hasIntrinsicSize.
+        (WebCore::lengthIsSpecified): Added this helper function, based on RenderImage’s
+        is{Width,Height}Specified().
+        (WebCore::RenderReplaced::calcReplacedWidth): Moved from RenderVideo all the way
+        up here so other replaced objects could use this logic.
+        (WebCore::RenderReplaced::calcReplacedHeight): Ditto.
+        (WebCore::RenderReplaced::calcAspectRatioWidth): Ditto.
+        (WebCore::RenderReplaced::calcAspectRatioHeight): Ditto.
+        (WebCore::RenderReplaced::calcPrefWidths): Replaced with the RenderImage version
+        of the logic.
+        (WebCore::RenderReplaced::setIntrinsicSize): Added an assertion.
+        * rendering/RenderReplaced.h:
+        (WebCore::RenderReplaced::minimumReplacedHeight): Promoted from private to protected
+        to allow RenderVideo to call through.
+        (WebCore::RenderReplaced::setHasIntrinsicSize): Added this setter.
+        * rendering/RenderVideo.cpp:
+        (WebCore::RenderVideo::updateIntrinsicSize): Factor zoom into the intrinsic size,
+        the way other RenderReplaced objects do.
+        (WebCore::RenderVideo::calcReplacedWidth): Invoke the RenderReplaced implementation,
+        which matches what used to be here, skipping over the RenderImage implementation.
+        (WebCore::RenderVideo::calcReplacedHeight): Ditto.
+        (WebCore::RenderVideo::minimumReplacedHeight): Ditto.
+        * rendering/RenderVideo.h:
+
 2010-09-17  Darin Adler  <darin at apple.com>
 
         Build fix for platforms that compile Touch.
diff --git a/WebCore/rendering/RenderEmbeddedObject.cpp b/WebCore/rendering/RenderEmbeddedObject.cpp
index 86fdae8..4179af3 100644
--- a/WebCore/rendering/RenderEmbeddedObject.cpp
+++ b/WebCore/rendering/RenderEmbeddedObject.cpp
@@ -79,6 +79,10 @@ RenderEmbeddedObject::RenderEmbeddedObject(Element* element)
     , m_mouseDownWasInMissingPluginIndicator(false)
 {
     view()->frameView()->setIsVisuallyNonEmpty();
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (element->hasTagName(videoTag) || element->hasTagName(audioTag))
+        setHasIntrinsicSize();
+#endif
 }
 
 RenderEmbeddedObject::~RenderEmbeddedObject()
diff --git a/WebCore/rendering/RenderImage.cpp b/WebCore/rendering/RenderImage.cpp
index a7f7df4..fcd779c 100644
--- a/WebCore/rendering/RenderImage.cpp
+++ b/WebCore/rendering/RenderImage.cpp
@@ -481,7 +481,7 @@ int RenderImage::calcAspectRatioWidth() const
         return 0;
     if (!m_imageResource->hasImage() || m_imageResource->errorOccurred())
         return size.width(); // Don't bother scaling.
-    return RenderReplaced::calcReplacedHeight() * size.width() / size.height();
+    return RenderBox::calcReplacedHeight() * size.width() / size.height();
 }
 
 int RenderImage::calcAspectRatioHeight() const
@@ -491,27 +491,7 @@ int RenderImage::calcAspectRatioHeight() const
         return 0;
     if (!m_imageResource->hasImage() || m_imageResource->errorOccurred())
         return size.height(); // Don't bother scaling.
-    return RenderReplaced::calcReplacedWidth() * size.height() / size.width();
-}
-
-void RenderImage::calcPrefWidths()
-{
-    ASSERT(prefWidthsDirty());
-
-    int borderAndPadding = borderAndPaddingWidth();
-    m_maxPrefWidth = calcReplacedWidth(false) + borderAndPadding;
-
-    if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)
-        m_maxPrefWidth = min(m_maxPrefWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
-
-    if (style()->width().isPercent() || style()->height().isPercent() || 
-        style()->maxWidth().isPercent() || style()->maxHeight().isPercent() ||
-        style()->minWidth().isPercent() || style()->minHeight().isPercent())
-        m_minPrefWidth = 0;
-    else
-        m_minPrefWidth = m_maxPrefWidth;
-
-    setPrefWidthsDirty(false);
+    return RenderBox::calcReplacedWidth() * size.height() / size.width();
 }
 
 } // namespace WebCore
diff --git a/WebCore/rendering/RenderImage.h b/WebCore/rendering/RenderImage.h
index 2b88c32..a8666ee 100644
--- a/WebCore/rendering/RenderImage.h
+++ b/WebCore/rendering/RenderImage.h
@@ -79,8 +79,6 @@ private:
     virtual int calcReplacedWidth(bool includeMaxWidth = true) const;
     virtual int calcReplacedHeight() const;
 
-    virtual void calcPrefWidths();
-
     int calcAspectRatioWidth() const;
     int calcAspectRatioHeight() const;
 
diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp
index 0da321e..b54a228 100644
--- a/WebCore/rendering/RenderReplaced.cpp
+++ b/WebCore/rendering/RenderReplaced.cpp
@@ -40,6 +40,7 @@ const int cDefaultHeight = 150;
 RenderReplaced::RenderReplaced(Node* node)
     : RenderBox(node)
     , m_intrinsicSize(cDefaultWidth, cDefaultHeight)
+    , m_hasIntrinsicSize(false)
 {
     setReplaced(true);
 }
@@ -47,6 +48,7 @@ RenderReplaced::RenderReplaced(Node* node)
 RenderReplaced::RenderReplaced(Node* node, const IntSize& intrinsicSize)
     : RenderBox(node)
     , m_intrinsicSize(intrinsicSize)
+    , m_hasIntrinsicSize(true)
 {
     setReplaced(true);
 }
@@ -192,21 +194,78 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, int& tx, int& ty)
     return true;
 }
 
+static inline bool lengthIsSpecified(Length length)
+{
+    LengthType lengthType = length.type();
+    return lengthType == Fixed || lengthType == Percent;
+}
+
+int RenderReplaced::calcReplacedWidth(bool includeMaxWidth) const
+{
+    int width;
+    if (lengthIsSpecified(style()->width()))
+        width = calcReplacedWidthUsing(style()->width());
+    else if (m_hasIntrinsicSize)
+        width = calcAspectRatioWidth();
+    else
+        width = intrinsicSize().width();
+
+    int minW = calcReplacedWidthUsing(style()->minWidth());
+    int maxW = !includeMaxWidth || style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth());
+
+    return max(minW, min(width, maxW));
+}
+
+int RenderReplaced::calcReplacedHeight() const
+{
+    int height;
+    if (lengthIsSpecified(style()->height()))
+        height = calcReplacedHeightUsing(style()->height());
+    else if (m_hasIntrinsicSize)
+        height = calcAspectRatioHeight();
+    else
+        height = intrinsicSize().height();
+
+    int minH = calcReplacedHeightUsing(style()->minHeight());
+    int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight());
+
+    return max(minH, min(height, maxH));
+}
+
+int RenderReplaced::calcAspectRatioWidth() const
+{
+    int intrinsicWidth = intrinsicSize().width();
+    int intrinsicHeight = intrinsicSize().height();
+    if (!intrinsicHeight)
+        return 0;
+    return RenderBox::calcReplacedHeight() * intrinsicWidth / intrinsicHeight;
+}
+
+int RenderReplaced::calcAspectRatioHeight() const
+{
+    int intrinsicWidth = intrinsicSize().width();
+    int intrinsicHeight = intrinsicSize().height();
+    if (!intrinsicWidth)
+        return 0;
+    return RenderBox::calcReplacedWidth() * intrinsicHeight / intrinsicWidth;
+}
+
 void RenderReplaced::calcPrefWidths()
 {
     ASSERT(prefWidthsDirty());
 
     int borderAndPadding = borderAndPaddingWidth();
-    int width = calcReplacedWidth(false) + borderAndPadding;
+    m_maxPrefWidth = calcReplacedWidth(false) + borderAndPadding;
 
     if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)
-        width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
+        m_maxPrefWidth = min(m_maxPrefWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
 
-    if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) {
+    if (style()->width().isPercent() || style()->height().isPercent()
+        || style()->maxWidth().isPercent() || style()->maxHeight().isPercent()
+        || style()->minWidth().isPercent() || style()->minHeight().isPercent())
         m_minPrefWidth = 0;
-        m_maxPrefWidth = width;
-    } else
-        m_minPrefWidth = m_maxPrefWidth = width;
+    else
+        m_minPrefWidth = m_maxPrefWidth;
 
     setPrefWidthsDirty(false);
 }
@@ -329,6 +388,7 @@ IntSize RenderReplaced::intrinsicSize() const
 
 void RenderReplaced::setIntrinsicSize(const IntSize& size)
 {
+    ASSERT(m_hasIntrinsicSize);
     m_intrinsicSize = size;
 }
 
diff --git a/WebCore/rendering/RenderReplaced.h b/WebCore/rendering/RenderReplaced.h
index b5c6179..8a0543c 100644
--- a/WebCore/rendering/RenderReplaced.h
+++ b/WebCore/rendering/RenderReplaced.h
@@ -37,6 +37,10 @@ protected:
 
     virtual IntSize intrinsicSize() const;
 
+    virtual int calcReplacedWidth(bool includeMaxWidth = true) const;
+    virtual int calcReplacedHeight() const;
+    virtual int minimumReplacedHeight() const { return 0; }
+
     virtual void setSelectionState(SelectionState);
 
     bool isSelected() const;
@@ -45,6 +49,7 @@ protected:
 
     void setIntrinsicSize(const IntSize&);
     virtual void intrinsicSizeChanged();
+    void setHasIntrinsicSize() { m_hasIntrinsicSize = true; }
 
     virtual void paint(PaintInfo&, int tx, int ty);
     bool shouldPaint(PaintInfo&, int& tx, int& ty);
@@ -60,7 +65,8 @@ private:
 
     virtual void calcPrefWidths();
 
-    virtual int minimumReplacedHeight() const { return 0; }
+    int calcAspectRatioWidth() const;
+    int calcAspectRatioHeight() const;
 
     virtual void paintReplaced(PaintInfo&, int /*tx*/, int /*ty*/) { }
 
@@ -74,6 +80,7 @@ private:
     virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
 
     IntSize m_intrinsicSize;
+    bool m_hasIntrinsicSize;
 };
 
 }
diff --git a/WebCore/rendering/RenderVideo.cpp b/WebCore/rendering/RenderVideo.cpp
index 3f4e2bf..25d786a 100644
--- a/WebCore/rendering/RenderVideo.cpp
+++ b/WebCore/rendering/RenderVideo.cpp
@@ -80,6 +80,7 @@ void RenderVideo::intrinsicSizeChanged()
 void RenderVideo::updateIntrinsicSize()
 {
     IntSize size = calculateIntrinsicSize();
+    size.scale(style()->effectiveZoom());
 
     // Never set the element size to zero when in a media document.
     if (size.isEmpty() && node()->ownerDocument() && node()->ownerDocument()->isMediaDocument())
@@ -250,53 +251,17 @@ void RenderVideo::updatePlayer()
 
 int RenderVideo::calcReplacedWidth(bool includeMaxWidth) const
 {
-    int width;
-    if (isWidthSpecified())
-        width = calcReplacedWidthUsing(style()->width());
-    else
-        width = calcAspectRatioWidth() * style()->effectiveZoom();
-
-    int minW = calcReplacedWidthUsing(style()->minWidth());
-    int maxW = !includeMaxWidth || style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth());
-
-    return max(minW, min(width, maxW));
+    return RenderReplaced::calcReplacedWidth(includeMaxWidth);
 }
 
 int RenderVideo::calcReplacedHeight() const
 {
-    int height;
-    if (isHeightSpecified())
-        height = calcReplacedHeightUsing(style()->height());
-    else
-        height = calcAspectRatioHeight() * style()->effectiveZoom();
-
-    int minH = calcReplacedHeightUsing(style()->minHeight());
-    int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight());
-
-    return max(minH, min(height, maxH));
-}
-
-int RenderVideo::calcAspectRatioWidth() const
-{
-    int intrinsicWidth = intrinsicSize().width();
-    int intrinsicHeight = intrinsicSize().height();
-    if (!intrinsicHeight)
-        return 0;
-    return RenderBox::calcReplacedHeight() * intrinsicWidth / intrinsicHeight;
-}
-
-int RenderVideo::calcAspectRatioHeight() const
-{
-    int intrinsicWidth = intrinsicSize().width();
-    int intrinsicHeight = intrinsicSize().height();
-    if (!intrinsicWidth)
-        return 0;
-    return RenderBox::calcReplacedWidth() * intrinsicHeight / intrinsicWidth;
+    return RenderReplaced::calcReplacedHeight();
 }
 
 int RenderVideo::minimumReplacedHeight() const 
 {
-    return 0; 
+    return RenderReplaced::minimumReplacedHeight(); 
 }
 
 #if USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/rendering/RenderVideo.h b/WebCore/rendering/RenderVideo.h
index dd7a531..2c47471 100644
--- a/WebCore/rendering/RenderVideo.h
+++ b/WebCore/rendering/RenderVideo.h
@@ -74,9 +74,6 @@ private:
     virtual int calcReplacedHeight() const;
     virtual int minimumReplacedHeight() const;
 
-    int calcAspectRatioWidth() const;
-    int calcAspectRatioHeight() const;
-
     void updatePlayer();
 
     IntSize m_cachedImageSize;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list