Commit 37a0f625 authored by harrison's avatar harrison

LayoutTests:

        Reviewed by Geoff and John.

        <rdar://problem/4558879> -[DOMCSSPrimitiveValue setStringValue:] throws an exception (12)

        * fast/dom/setPrimitiveValue-expected.checksum: Added.
        * fast/dom/setPrimitiveValue-expected.png: Added.
        * fast/dom/setPrimitiveValue-expected.txt: Added.
        * fast/dom/setPrimitiveValue.html: Added.

WebCore:

        Reviewed by Geoff and John.

        <rdar://problem/4558879> -[DOMCSSPrimitiveValue setStringValue:] throws an exception (12)
        
        Problem was the primitive value was getting reset to a generic state before the parameter
        check that relies on that state.

        Test: fast/dom/setPrimitiveValue.html

        * css/CSSPrimitiveValue.cpp:
        (WebCore::CSSPrimitiveValue::setFloatValue):
        (WebCore::CSSPrimitiveValue::setStringValue):
        Move parameter checks ahead of call to cleanup().



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14775 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aad695b2
2006-06-08 David Harrison <harrison@apple.com>
Reviewed by Geoff and John.
<rdar://problem/4558879> -[DOMCSSPrimitiveValue setStringValue:] throws an exception (12)
* fast/dom/setPrimitiveValue-expected.checksum: Added.
* fast/dom/setPrimitiveValue-expected.png: Added.
* fast/dom/setPrimitiveValue-expected.txt: Added.
* fast/dom/setPrimitiveValue.html: Added.
2006-06-08 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed by Darin.
d50673b5a0ea42979f459964548a7a43
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x579
RenderBlock (anonymous) at (0,0) size 784x18
RenderText {#text} at (0,0) size 551x18
text run at (0,0) width 551: "This test checks that a primitive CSS values can be set without generating an exception."
RenderText {#text} at (0,0) size 0x0
RenderBlock {PRE} at (0,31) size 784x0
layer at (250,100) size 76x18
RenderBlock (positioned) {DIV} at (250,100) size 76x18
RenderText {#text} at (0,0) size 76x18
text run at (0,0) width 76: "Hello world"
<html>
<head>
<style>
div.test {
position: absolute;
left: 250px;
top: 100px;
background-image: url(stars.gif);
}
</style>
<script>
function runTest()
{
var helloText = document.getElementById("hello");
var positionField = document.getElementById("style position");
var position = 50.0;
var textRule = document.styleSheets[0].cssRules[0];
var s = textRule.style;
var leftValue = s.getPropertyCSSValue("left");
var bgImageValue = s.getPropertyCSSValue("background-image");
try
{
leftValue.setFloatValue(leftValue.primitiveType, parseFloat(position));
}
catch (e)
{
alert("setFloatValue " + e.message);
}
try
{
bgImageValue.setStringValue(bgImageValue.primitiveType, "stripes.gif");
}
catch (e)
{
alert("setStringValue " + e.message);
}
}
</script>
</head>
<body onload="runTest();">
This test checks that a primitive CSS values can be set without generating an exception.
<div class="test" id="hello">Hello world</div>
<pre id="console"></pre>
</body>
</html>
2006-06-08 David Harrison <harrison@apple.com>
Reviewed by Geoff and John.
<rdar://problem/4558879> -[DOMCSSPrimitiveValue setStringValue:] throws an exception (12)
Problem was the primitive value was getting reset to a generic state before the parameter
check that relies on that state.
Test: fast/dom/setPrimitiveValue.html
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::setFloatValue):
(WebCore::CSSPrimitiveValue::setStringValue):
Move parameter checks ahead of call to cleanup().
2006-06-08 Alice Liu <alice.liu@apple.com>
Reviewed by Justin.
......
......@@ -274,12 +274,15 @@ double CSSPrimitiveValue::computeLengthFloat(RenderStyle *style, bool applyZoomF
void CSSPrimitiveValue::setFloatValue( unsigned short unitType, double floatValue, ExceptionCode& ec)
{
ec = 0;
cleanup();
// ### check if property supports this type
if (m_type > CSS_DIMENSION) {
ec = SYNTAX_ERR;
return;
}
cleanup();
//if(m_type > CSS_DIMENSION) throw DOMException(INVALID_ACCESS_ERR);
m_value.num = floatValue;
m_type = unitType;
......@@ -336,13 +339,16 @@ double CSSPrimitiveValue::getFloatValue(unsigned short unitType)
void CSSPrimitiveValue::setStringValue( unsigned short stringType, const String &stringValue, ExceptionCode& ec)
{
ec = 0;
cleanup();
//if(m_type < CSS_STRING) throw DOMException(INVALID_ACCESS_ERR);
//if(m_type > CSS_ATTR) throw DOMException(INVALID_ACCESS_ERR);
if (m_type < CSS_STRING || m_type > CSS_ATTR) {
ec = SYNTAX_ERR;
return;
}
cleanup();
if (stringType != CSS_IDENT) {
m_value.string = stringValue.impl();
m_value.string->ref();
......
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