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

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 13:00:13 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f3efed7a31788830c3682d00e10dd889929cd52a
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 3 23:04:12 2010 +0000

    2010-09-03  Peter Kasting  <pkasting at google.com>
    
            Reviewed by Simon Fraser.
    
            Report correct (unzoomed) image sizes for zoomed images.
            https://bugs.webkit.org/show_bug.cgi?id=42089
    
            * fast/images/resources/oval.png: Added.
            * fast/images/zoomed-img-size-expected.txt: Added.
            * fast/images/zoomed-img-size.html: Added.
    2010-09-03  Peter Kasting  <pkasting at google.com>
    
            Reviewed by Simon Fraser.
    
            Report correct (unzoomed) image sizes for zoomed images.
            https://bugs.webkit.org/show_bug.cgi?id=42089
    
            Test: fast/images/zoomed-img-size.html
    
            * css/CSSPrimitiveValue.cpp: Factor rounding code out to a templatized function so it can be shared.
            (WebCore::CSSPrimitiveValue::computeLengthInt):
            (WebCore::CSSPrimitiveValue::computeLengthIntForLength):
            (WebCore::CSSPrimitiveValue::computeLengthShort):
            * css/CSSPrimitiveValue.h: Factor rounding code out to a templatized function so it can be shared.
            (WebCore::roundForImpreciseConversion):
            * html/HTMLImageElement.cpp: Report unzoomed size to script that queries an image's width or height.
            (WebCore::HTMLImageElement::width):
            (WebCore::HTMLImageElement::height):
            * loader/ImageDocument.cpp: Report unzoomed size in the page title when viewing a standalone image.
            (WebCore::ImageDocumentParser::finish):
            * rendering/RenderObject.h: Use shared rounding code from CSSPrimitiveValue to compensate for inexactness in zoomed sizes.
            (WebCore::adjustForAbsoluteZoom):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66776 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b4dd2b5..1ffafb1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-03  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Simon Fraser.
+
+        Report correct (unzoomed) image sizes for zoomed images.
+        https://bugs.webkit.org/show_bug.cgi?id=42089
+
+        * fast/images/resources/oval.png: Added.
+        * fast/images/zoomed-img-size-expected.txt: Added.
+        * fast/images/zoomed-img-size.html: Added.
+
 2010-09-03  Zhenyao Mo  <zmo at google.com>
 
         Unreviewed.
diff --git a/LayoutTests/fast/images/resources/oval.png b/LayoutTests/fast/images/resources/oval.png
new file mode 100644
index 0000000..baa17fb
Binary files /dev/null and b/LayoutTests/fast/images/resources/oval.png differ
diff --git a/LayoutTests/fast/images/zoomed-img-size-expected.txt b/LayoutTests/fast/images/zoomed-img-size-expected.txt
new file mode 100755
index 0000000..f3bc6b6
--- /dev/null
+++ b/LayoutTests/fast/images/zoomed-img-size-expected.txt
@@ -0,0 +1,46 @@
+Ideally, all ovals below should be reported as having width=37, height=33. Currently rounding prevents us from doing this.
+
+
+Zoom 1% PASS: 100x100 close enough to 37x33
+
+
+Zoom 2% PASS: 50x50 close enough to 37x33
+
+
+Zoom 3% PASS: 33x33 close enough to 37x33
+
+
+Zoom 4% PASS: 25x25 close enough to 37x33
+
+
+Zoom 5% PASS: 20x20 close enough to 37x33
+
+
+Zoom 30% PASS: 36x30 close enough to 37x33
+
+
+Zoom 33% PASS: 36x30 close enough to 37x33
+
+
+Zoom 50% PASS: 36x32 close enough to 37x33
+
+
+Zoom 70% PASS: 35x32 close enough to 37x33
+
+
+Zoom 100% PASS: 37x33
+
+
+Zoom 111% PASS: 37x33
+
+
+Zoom 150% PASS: 37x33
+
+
+Zoom 333% PASS: 37x33
+
+
+Zoom 400% PASS: 37x33
+
+
+Zoom 1234% PASS: 37x33
diff --git a/LayoutTests/fast/images/zoomed-img-size.html b/LayoutTests/fast/images/zoomed-img-size.html
new file mode 100644
index 0000000..4e6a26d
--- /dev/null
+++ b/LayoutTests/fast/images/zoomed-img-size.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <script type="text/javascript">
+      if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+      function update() {
+        // These arrays will become unnecessary if we fix the rounding issues that make us not always report "37x33".
+        var expectedWidths = [100, 50, 33, 25, 20, 36, 36, 36, 35, 37, 37, 37, 37, 37, 37];
+        var expectedHeights = [100, 50, 33, 25, 20, 30, 30, 32, 32, 33, 33, 33, 33, 33, 33];
+        for (i = 0; i < 15; ++i) {
+          var oval = document.getElementById('oval' + i);
+          var status = document.getElementById('status' + i);
+          var sizes = document.getElementById('sizes' + i);
+          if ((oval.width == expectedWidths[i]) && (oval.height == expectedHeights[i])) {
+            status.style.color = "green";
+            status.innerHTML = "PASS";
+            sizes.innerHTML = oval.width + "x" + oval.height + (((oval.width != 37) || (oval.height != 33)) ? " close enough to 37x33" : "");
+          } else {
+            status.style.color = "red";
+            status.innerHTML = "FAIL";
+            sizes.innerHTML = oval.width + "x" + oval.height + " not close enough to 37x33";
+          }
+        }
+      }
+      window.onload = update;
+    </script>
+  </head>
+  <body>
+    <p>Ideally, all ovals below should be reported as having width=37, height=33.  Currently rounding prevents us from doing this.</p>
+    <img id="oval0" src="resources/oval.png" style="zoom: 1%">
+    <p>Zoom 1% <span id="status0"></span>: <span id="sizes0"></span></p>
+    <img id="oval1" src="resources/oval.png" style="zoom: 2%">
+    <p>Zoom 2% <span id="status1"></span>: <span id="sizes1"></span></p>
+    <img id="oval2" src="resources/oval.png" style="zoom: 3%">
+    <p>Zoom 3% <span id="status2"></span>: <span id="sizes2"></span></p>
+    <img id="oval3" src="resources/oval.png" style="zoom: 4%">
+    <p>Zoom 4% <span id="status3"></span>: <span id="sizes3"></span></p>
+    <img id="oval4" src="resources/oval.png" style="zoom: 5%">
+    <p>Zoom 5% <span id="status4"></span>: <span id="sizes4"></span></p>
+    <img id="oval5" src="resources/oval.png" style="zoom: 30%">
+    <p>Zoom 30% <span id="status5"></span>: <span id="sizes5"></span></p>
+    <img id="oval6" src="resources/oval.png" style="zoom: 33%">
+    <p>Zoom 33% <span id="status6"></span>: <span id="sizes6"></span></p>
+    <img id="oval7" src="resources/oval.png" style="zoom: 50%">
+    <p>Zoom 50% <span id="status7"></span>: <span id="sizes7"></span></p>
+    <img id="oval8" src="resources/oval.png" style="zoom: 70%">
+    <p>Zoom 70% <span id="status8"></span>: <span id="sizes8"></span></p>
+    <img id="oval9" src="resources/oval.png" style="zoom: 100%">
+    <p>Zoom 100% <span id="status9"></span>: <span id="sizes9"></span></p>
+    <img id="oval10" src="resources/oval.png" style="zoom: 111%">
+    <p>Zoom 111% <span id="status10"></span>: <span id="sizes10"></span></p>
+    <img id="oval11" src="resources/oval.png" style="zoom: 150%">
+    <p>Zoom 150% <span id="status11"></span>: <span id="sizes11"></span></p>
+    <img id="oval12" src="resources/oval.png" style="zoom: 333%">
+    <p>Zoom 333% <span id="status12"></span>: <span id="sizes12"></span></p>
+    <img id="oval13" src="resources/oval.png" style="zoom: 400%">
+    <p>Zoom 400% <span id="status13"></span>: <span id="sizes13"></span></p>
+    <img id="oval14" src="resources/oval.png" style="zoom: 1234%">
+    <p>Zoom 1234% <span id="status14"></span>: <span id="sizes14"></span></p>
+  </body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index afda76d..be7273b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-09-03  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Simon Fraser.
+
+        Report correct (unzoomed) image sizes for zoomed images.
+        https://bugs.webkit.org/show_bug.cgi?id=42089
+
+        Test: fast/images/zoomed-img-size.html
+
+        * css/CSSPrimitiveValue.cpp: Factor rounding code out to a templatized function so it can be shared.
+        (WebCore::CSSPrimitiveValue::computeLengthInt):
+        (WebCore::CSSPrimitiveValue::computeLengthIntForLength):
+        (WebCore::CSSPrimitiveValue::computeLengthShort):
+        * css/CSSPrimitiveValue.h: Factor rounding code out to a templatized function so it can be shared.
+        (WebCore::roundForImpreciseConversion):
+        * html/HTMLImageElement.cpp: Report unzoomed size to script that queries an image's width or height.
+        (WebCore::HTMLImageElement::width):
+        (WebCore::HTMLImageElement::height):
+        * loader/ImageDocument.cpp: Report unzoomed size in the page title when viewing a standalone image.
+        (WebCore::ImageDocumentParser::finish):
+        * rendering/RenderObject.h: Use shared rounding code from CSSPrimitiveValue to compensate for inexactness in zoomed sizes.
+        (WebCore::adjustForAbsoluteZoom):
+
 2010-09-03  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r66770.
diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp
index b4478b4..5c83e7c 100644
--- a/WebCore/css/CSSPrimitiveValue.cpp
+++ b/WebCore/css/CSSPrimitiveValue.cpp
@@ -305,82 +305,34 @@ void CSSPrimitiveValue::cleanup()
 
 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle)
 {
-    double result = computeLengthDouble(style, rootStyle);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > INT_MAX || result < INT_MIN)
-        return 0;
-    return static_cast<int>(result);
+    return roundForImpreciseConversion<int, INT_MAX, INT_MIN>(computeLengthDouble(style, rootStyle));
 }
 
 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    double result = computeLengthDouble(style, rootStyle, multiplier);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > INT_MAX || result < INT_MIN)
-        return 0;
-    return static_cast<int>(result);
+    return roundForImpreciseConversion<int, INT_MAX, INT_MIN>(computeLengthDouble(style, rootStyle, multiplier));
 }
 
-// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
+// Lengths expect an int that is only 28-bits, so we have to check for a
+// different overflow.
 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle)
 {
-    double result = computeLengthDouble(style, rootStyle);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > intMaxForLength || result < intMinForLength)
-        return 0;
-    return static_cast<int>(result);
+    return roundForImpreciseConversion<int, intMaxForLength, intMinForLength>(computeLengthDouble(style, rootStyle));
 }
 
-// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    double result = computeLengthDouble(style, rootStyle, multiplier);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > intMaxForLength || result < intMinForLength)
-        return 0;
-    return static_cast<int>(result);
+    return roundForImpreciseConversion<int, intMaxForLength, intMinForLength>(computeLengthDouble(style, rootStyle, multiplier));
 }
 
 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle)
 {
-    double result = computeLengthDouble(style, rootStyle);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > SHRT_MAX || result < SHRT_MIN)
-        return 0;
-    return static_cast<short>(result);
+    return roundForImpreciseConversion<short, SHRT_MAX, SHRT_MIN>(computeLengthDouble(style, rootStyle));
 }
 
 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    double result = computeLengthDouble(style, rootStyle, multiplier);
-
-    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
-    // need to go ahead and round if we're really close to the next integer value.
-    result += result < 0 ? -0.01 : +0.01;
-
-    if (result > SHRT_MAX || result < SHRT_MIN)
-        return 0;
-    return static_cast<short>(result);
+    return roundForImpreciseConversion<short, SHRT_MAX, SHRT_MIN>(computeLengthDouble(style, rootStyle, multiplier));
 }
 
 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, bool computingFontSize)
diff --git a/WebCore/css/CSSPrimitiveValue.h b/WebCore/css/CSSPrimitiveValue.h
index b11c7f0..bb3ea70 100644
--- a/WebCore/css/CSSPrimitiveValue.h
+++ b/WebCore/css/CSSPrimitiveValue.h
@@ -38,6 +38,15 @@ class RenderStyle;
 
 struct Length;
 
+template<typename T, T max, T min> inline T roundForImpreciseConversion(double value)
+{
+    // Dimension calculations are imprecise, often resulting in values of e.g.
+    // 44.99998.  We need to go ahead and round if we're really close to the
+    // next integer value.
+    value += (value < 0) ? -0.01 : +0.01;
+    return ((value > max) || (value < min)) ? 0 : static_cast<T>(value);
+}
+
 class CSSPrimitiveValue : public CSSValue {
 public:
     enum UnitTypes {
diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp
index b7ece78..d223b1e 100644
--- a/WebCore/html/HTMLImageElement.cpp
+++ b/WebCore/html/HTMLImageElement.cpp
@@ -267,10 +267,8 @@ int HTMLImageElement::width(bool ignorePendingStylesheets) const
             return width;
 
         // if the image is available, use its width
-        if (m_imageLoader.image()) {
-            float zoomFactor = document()->view() ? document()->view()->pageZoomFactor() : 1.0f;
-            return m_imageLoader.image()->imageSize(zoomFactor).width();
-        }
+        if (m_imageLoader.image())
+            return m_imageLoader.image()->imageSize(1.0f).width();
     }
 
     if (ignorePendingStylesheets)
@@ -278,7 +276,8 @@ int HTMLImageElement::width(bool ignorePendingStylesheets) const
     else
         document()->updateLayout();
 
-    return renderBox() ? renderBox()->contentWidth() : 0;
+    RenderBox* box = renderBox();
+    return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
 }
 
 int HTMLImageElement::height(bool ignorePendingStylesheets) const
@@ -291,10 +290,8 @@ int HTMLImageElement::height(bool ignorePendingStylesheets) const
             return height;
 
         // if the image is available, use its height
-        if (m_imageLoader.image()) {
-            float zoomFactor = document()->view() ? document()->view()->pageZoomFactor() : 1.0f;
-            return m_imageLoader.image()->imageSize(zoomFactor).height();
-        }
+        if (m_imageLoader.image())
+            return m_imageLoader.image()->imageSize(1.0f).height();
     }
 
     if (ignorePendingStylesheets)
@@ -302,7 +299,8 @@ int HTMLImageElement::height(bool ignorePendingStylesheets) const
     else
         document()->updateLayout();
 
-    return renderBox() ? renderBox()->contentHeight() : 0;
+    RenderBox* box = renderBox();
+    return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;
 }
 
 int HTMLImageElement::naturalWidth() const
diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp
index cc3c85c..6951b7b 100644
--- a/WebCore/loader/ImageDocument.cpp
+++ b/WebCore/loader/ImageDocument.cpp
@@ -152,7 +152,9 @@ void ImageDocumentParser::finish()
 
         cachedImage->setResponse(document()->frame()->loader()->documentLoader()->response());
 
-        IntSize size = cachedImage->imageSize(pageZoomFactor(document()));
+        // Report the natural image size in the page title, regardless of zoom
+        // level.
+        IntSize size = cachedImage->imageSize(1.0f);
         if (size.width()) {
             // Compute the title, we use the decoded filename of the resource, falling
             // back on the (decoded) hostname if there is no path.
diff --git a/WebCore/rendering/RenderObject.h b/WebCore/rendering/RenderObject.h
index 9fbaf91..b8aa8a9 100644
--- a/WebCore/rendering/RenderObject.h
+++ b/WebCore/rendering/RenderObject.h
@@ -28,6 +28,7 @@
 
 #include "AffineTransform.h"
 #include "CachedResourceClient.h"
+#include "CSSPrimitiveValue.h"
 #include "Document.h"
 #include "Element.h"
 #include "FloatQuad.h"
@@ -986,13 +987,14 @@ inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi
 
 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
 {
-    float zoomFactor = renderer->style()->effectiveZoom();
+    double zoomFactor = renderer->style()->effectiveZoom();
     if (zoomFactor == 1)
         return value;
     // Needed because computeLengthInt truncates (rather than rounds) when scaling up.
     if (zoomFactor > 1)
         value++;
-    return static_cast<int>(value / zoomFactor);
+
+    return roundForImpreciseConversion<int, INT_MAX, INT_MIN>(value / zoomFactor);
 }
 
 inline void adjustIntRectForAbsoluteZoom(IntRect& rect, RenderObject* renderer)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list