2011-01-29 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Dan Bernstein.

        CSS3 gradients with em-based stops fail to repaint when font size changes
        https://bugs.webkit.org/show_bug.cgi?id=51845

        Mark as uncacheable gradidients whose color stops depend on font size,
        and don't attempt to put these into CSSImageGeneratorValue's image cache.
        This means we return a new gradient each time, which is fairly cheap, and
        fixes repaint issues under changing font size.

        Test: fast/repaint/gradients-em-stops-repaint.html

        * css/CSSGradientValue.cpp:
        (WebCore::CSSGradientValue::image):
        (WebCore::CSSGradientValue::isCacheable):
        * css/CSSGradientValue.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dcd3ca68
2011-01-29 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein.
CSS3 gradients with em-based stops fail to repaint when font size changes
https://bugs.webkit.org/show_bug.cgi?id=51845
Test repaint of a gradient with 'em' stops when the font size changes.
* fast/repaint/gradients-em-stops-repaint.html: Added.
* platform/mac/fast/repaint/gradients-em-stops-repaint-expected.checksum: Added.
* platform/mac/fast/repaint/gradients-em-stops-repaint-expected.png: Added.
* platform/mac/fast/repaint/gradients-em-stops-repaint-expected.txt: Added.
2011-01-29 Maciej Stachowiak <mjs@apple.com>
Unreviewed fix for last commit.
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
.box {
display: inline-block;
height: 120px;
width: 300px;
margin: 10px;
border: 1px solid black;
background-repeat: no-repeat;
font-size: 12pt;
}
.em-units > .box {
background-image: -webkit-linear-gradient(left, yellow, yellow 5em, green 5em);
background-image: -moz-linear-gradient(left, yellow, yellow 5em, green 5em);
}
.indicator {
background-color: black;
height: 20px;
}
</style>
<script type="text/javascript" src="resources/repaint.js"></script>
<script type="text/javascript">
function repaintTest()
{
document.getElementById("box4").style.fontSize = "36pt";
}
</script>
</script>
</head>
<body onload="runRepaintTest();">
<div class="em-units">
<div id="box3" class="box"><div class="indicator" style="width: 5em;"></div></div>
<div id="box4" class="box"><div class="indicator" style="width: 5em;"></div></div>
</div>
</body>
</html>
92fa2e6554c47d2d89f10a7a5563fff0
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x162
RenderBlock {HTML} at (0,0) size 800x162
RenderBody {BODY} at (8,8) size 784x146
RenderBlock {DIV} at (0,0) size 784x146
RenderBlock {DIV} at (10,10) size 302x122 [border: (1px solid #000000)]
RenderBlock {DIV} at (1,1) size 80x20 [bgcolor=#000000]
RenderText {#text} at (322,128) size 4x18
text run at (322,128) width 4: " "
RenderBlock {DIV} at (336,10) size 302x122 [border: (1px solid #000000)]
RenderBlock {DIV} at (1,1) size 240x20 [bgcolor=#000000]
RenderText {#text} at (0,0) size 0x0
2011-01-29 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein.
CSS3 gradients with em-based stops fail to repaint when font size changes
https://bugs.webkit.org/show_bug.cgi?id=51845
Mark as uncacheable gradidients whose color stops depend on font size,
and don't attempt to put these into CSSImageGeneratorValue's image cache.
This means we return a new gradient each time, which is fairly cheap, and
fixes repaint issues under changing font size.
Test: fast/repaint/gradients-em-stops-repaint.html
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::image):
(WebCore::CSSGradientValue::isCacheable):
* css/CSSGradientValue.h:
2011-01-29 Geoffrey Garen <ggaren@apple.com>
Undo try to fix the Qt build.
......@@ -43,22 +43,24 @@ namespace WebCore {
PassRefPtr<Image> CSSGradientValue::image(RenderObject* renderer, const IntSize& size)
{
if (!m_clients.contains(renderer))
return 0;
// Need to look up our size. Create a string of width*height to use as a hash key.
// FIXME: hashing based only on size is not sufficient. Color stops may use context-sensitive units (like em)
// that should force the color stop positions to be recomputed.
Image* result = getImage(renderer, size);
if (result)
return result;
if (size.isEmpty())
return 0;
bool cacheable = isCacheable();
if (cacheable) {
if (!m_clients.contains(renderer))
return 0;
// Need to look up our size. Create a string of width*height to use as a hash key.
Image* result = getImage(renderer, size);
if (result)
return result;
}
// We need to create an image.
RefPtr<Image> newImage = GeneratedImage::create(createGradient(renderer, size), size);
putImage(size, newImage);
if (cacheable)
putImage(size, newImage);
return newImage.release();
}
......@@ -405,6 +407,21 @@ FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimit
return result;
}
bool CSSGradientValue::isCacheable() const
{
for (size_t i = 0; i < m_stops.size(); ++i) {
const CSSGradientColorStop& stop = m_stops[i];
if (!stop.m_position)
continue;
unsigned short unitType = stop.m_position->primitiveType();
if (unitType == CSSPrimitiveValue::CSS_EMS || unitType == CSSPrimitiveValue::CSS_EXS || unitType == CSSPrimitiveValue::CSS_REMS)
return false;
}
return true;
}
String CSSLinearGradientValue::cssText() const
{
String result;
......
......@@ -81,6 +81,8 @@ protected:
// Resolve points/radii to front end values.
FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, const IntSize&);
bool isCacheable() const;
// Points. Some of these may be null for linear gradients.
RefPtr<CSSPrimitiveValue> m_firstX;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment