Regression (r145601): out-of-bounds read in line breaking / new width cache
https://bugs.webkit.org/show_bug.cgi?id=113347

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-03-26
Reviewed by Geoffrey Garen.

The values zero and 0xffff have special values with the default HashTraits. Those values
are also valid values for UChar.

To avoid any table inconsitency, switch from UChar to uint32_t as the key type for
the WidthCache's single char map. The traits is also changed to allow zero as a normal
value.

This makes no space or time change over the previous code because:
-The struct KeyValuePair was already 64bits due to the ABI alignment restrictions on floats.
-The two hashes take the same number of instructions.

* platform/graphics/WidthCache.h:
(WidthCache):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146954 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Test if non-immediate descendants obscure background
https://bugs.webkit.org/show_bug.cgi?id=113137

Reviewed by Simon Fraser.

Source/WebCore: 

The current obscuration test only covers immediate children. We can find more cases by looking deeper into descendants.
        
The patch makes the test sufficiently smart to stop a heavy fully obscured gif animation on micrsoft.com.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::animationAdvanced):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):
        
    Invalidate parents to max test depth.

(WebCore::RenderBox::backgroundPaintedExtent):
        
    Background painting is pixel snapped.

(WebCore::isCandidateForOpaquenessTest):
(WebCore::RenderBox::foregroundIsKnownToBeOpaqueInRect):
        
    Separate foreground testing and make it recursive.
    Add fast bailout for common static positioned case.
    Remove maximum child count, the fast bailouts should prevent long tests.
    Add maximum depth so we know how deep we need to invalidate in styleDidChange.

(WebCore::RenderBox::computeBackgroundIsKnownToBeObscured):
(WebCore):
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::foregroundIsKnownToBeOpaqueInRect):
(WebCore):
(WebCore::RenderImage::computeBackgroundIsKnownToBeObscured):
        
* rendering/RenderImage.h:
(RenderImage):

LayoutTests: 

* fast/backgrounds/obscured-background-child-style-change-expected.html:
* fast/backgrounds/obscured-background-child-style-change.html:
* fast/repaint/obscured-background-no-repaint-expected.txt:
* fast/repaint/obscured-background-no-repaint.html:



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