2010-06-13 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jun 2010 01:47:54 +0000 (01:47 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jun 2010 01:47:54 +0000 (01:47 +0000)
        Reviewed by Dan Bernstein.

        -webkit-transition font-size and font-family
        https://bugs.webkit.org/show_bug.cgi?id=33429

        When animating font-size, update the font with a saved
        version of the font selector to ensure that we don't clobber
        the font family.

        Test: transitions/font-family-during-transition.html

        * rendering/style/RenderStyle.cpp:
        (WebCore::RenderStyle::setBlendedFontSize):

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

LayoutTests/ChangeLog
LayoutTests/transitions/font-family-during-transition-expected.txt [new file with mode: 0644]
LayoutTests/transitions/font-family-during-transition.html [new file with mode: 0644]
LayoutTests/transitions/transition-test-helpers.js
WebCore/ChangeLog
WebCore/rendering/style/RenderStyle.cpp

index 34ac153..7038019 100644 (file)
@@ -1,3 +1,18 @@
+2010-06-13  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        -webkit-transition font-size and font-family
+        https://bugs.webkit.org/show_bug.cgi?id=33429
+
+        Test that checks that the correct font-family is being used during a font
+        size transition by comparing offsetWidth with a control element.
+        
+        * transitions/font-family-during-transition-expected.txt: Added.
+        * transitions/font-family-during-transition.html: Added.
+        * transitions/transition-test-helpers.js:
+        (expected):
+
 2010-06-13  Darin Adler  <darin@apple.com>
 
         Updated Windows-platform results for the fix for bug 40394.
diff --git a/LayoutTests/transitions/font-family-during-transition-expected.txt b/LayoutTests/transitions/font-family-during-transition-expected.txt
new file mode 100644 (file)
index 0000000..12c7587
--- /dev/null
@@ -0,0 +1,4 @@
+Here is some text 
+Here is some text
+PASS - "font-size" property for "box" element at 1s saw something close to: 15
+PASS: width was close to 115
diff --git a/LayoutTests/transitions/font-family-during-transition.html b/LayoutTests/transitions/font-family-during-transition.html
new file mode 100644 (file)
index 0000000..3315608
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+  #box {
+    display: inline;
+    font-size: 10px;
+    font-family: sans-serif;
+    -webkit-transition: font-size 2s linear;
+  }
+  
+  #control {
+    display: inline;
+    font-size: 15px;
+    font-family: sans-serif;
+  }
+  
+  #box.changed {
+    font-size: 20px;
+  }
+  </style>
+  
+  <script src="transition-test-helpers.js" type="text/javascript" charset="utf-8"></script>
+  <script type="text/javascript" charset="utf-8">
+    const expectedValues = [
+      // [time, element-id, property, expected-value, tolerance]
+      [1, 'box', 'font-size', 15, 2, checkSize],
+    ];
+
+    function checkSize()
+    {
+      var boxWidth = document.getElementById('box').offsetWidth;
+      var controlWidth = document.getElementById('control').offsetWidth;
+      var result = "";
+      if (isCloseEnough(boxWidth, controlWidth, 2))
+        result = "PASS: width was close to " + controlWidth;
+      else
+        result = "FAIL: width was " + boxWidth + ", should have been " + controlWidth;
+
+      return result;
+    }
+    
+    function setupTest()
+    {
+      document.getElementById('box').className = 'changed';
+    }
+
+    runTransitionTest(expectedValues, setupTest, true);
+  </script>
+</head>
+<body>
+  <div id="box">Here is some text</div>
+  <br>
+  <div id="control">Here is some text</div>
+  <div id="result"></div>
+</body>
+</html>
index 6c40ab8..d332c72 100644 (file)
@@ -55,6 +55,7 @@ function checkExpectedValue(expected, index)
     var property = expected[index][2];
     var expectedValue = expected[index][3];
     var tolerance = expected[index][4];
+    var postCompletionCallback = expected[index][5];
 
     var computedValue;
     var pass = false;
@@ -133,6 +134,9 @@ function checkExpectedValue(expected, index)
         result += "PASS - \"" + property + "\" property for \"" + elementId + "\" element at " + time + "s saw something close to: " + expectedValue + "<br>";
     else
         result += "FAIL - \"" + property + "\" property for \"" + elementId + "\" element at " + time + "s expected: " + expectedValue + " but saw: " + computedValue + "<br>";
+
+    if (postCompletionCallback)
+      result += postCompletionCallback();
 }
 
 function endTest()
index 0e0df06..e87d898 100644 (file)
@@ -1,3 +1,19 @@
+2010-06-13  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        -webkit-transition font-size and font-family
+        https://bugs.webkit.org/show_bug.cgi?id=33429
+        
+        When animating font-size, update the font with a saved
+        version of the font selector to ensure that we don't clobber
+        the font family.        
+
+        Test: transitions/font-family-during-transition.html
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::setBlendedFontSize):
+
 2010-06-13  Tony Chang  <tony@chromium.org>
 
         Build fix, not reviewed.
index 220e657..af4e055 100644 (file)
@@ -916,11 +916,12 @@ const Animation* RenderStyle::transitionForProperty(int property) const
 
 void RenderStyle::setBlendedFontSize(int size)
 {
+    FontSelector* currentFontSelector = font().fontSelector();
     FontDescription desc(fontDescription());
     desc.setSpecifiedSize(size);
     desc.setComputedSize(size);
     setFontDescription(desc);
-    font().update(font().fontSelector());
+    font().update(currentFontSelector);
 }
 
 void RenderStyle::getBoxShadowExtent(int &top, int &right, int &bottom, int &left) const