LayoutTests:
authorddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2007 05:28:35 +0000 (05:28 +0000)
committerddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2007 05:28:35 +0000 (05:28 +0000)
        Reviewed by Hyatt.

        - test and updated results for http://bugs.webkit.org/show_bug.cgi?id=5164
          Non-integer percentages are incorrectly rounded down in Safari

        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.checksum:
        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.png:
        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.txt:
        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.checksum:
        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.png:
        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.txt:
        * css2.1/t09-c5526c-display-00-e-expected.checksum:
        * css2.1/t09-c5526c-display-00-e-expected.png:
        * css2.1/t09-c5526c-display-00-e-expected.txt:
        * fast/block/basic/011-expected.checksum:
        * fast/block/basic/011-expected.png:
        * fast/block/basic/011-expected.txt:
        * fast/css/percentage-non-integer-expected.checksum: Added.
        * fast/css/percentage-non-integer-expected.png: Added.
        * fast/css/percentage-non-integer-expected.txt: Added.
        * fast/css/percentage-non-integer.html: Added.
        * tables/mozilla/bugs/bug4385-expected.checksum:
        * tables/mozilla/bugs/bug4385-expected.png:
        * tables/mozilla/bugs/bug4385-expected.txt:
        * tables/mozilla_expected_failures/core/col_span2-expected.checksum:
        * tables/mozilla_expected_failures/core/col_span2-expected.txt:

WebCore:

        Reviewed by Hyatt.

        - fix http://bugs.webkit.org/show_bug.cgi?id=5164
          Non-integer percentages are incorrectly rounded down in Safari

        Test: fast/css/percentage-non-integer.html

        Added floating point constructor and accessors to Length for use with
        Percent lengths only. The raw value of a percent length is the integer
        part of a constant multiple of the original double value. The constant
        is percentScaleFactor, which is currently 128.

        Added assertions that the correct constructors and accessors are used
        depending on the type: the double-based percent(), setValue() and Length()
        for the Percent type, and the integer-based value(), setValue() and Length()
        for all other types.

        calcValue() and calcMinValue() work the same as before, regardless of the
        type.

        Added helpers for testing if the value is 0, positive, negative or undefined
        without having to check the type first.

        Added raw value accessors. These are useful for doing integer math and
        comparisons with scaled percent values or doing Length type-agnostic math.

        Changed the rest of the code to use the appropriate accessors and helpers.

        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::valueForLength):
        (WebCore::primitiveValueFromLength):
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/cssstyleselector.cpp:
        (WebCore::convertToLength):
        (WebCore::CSSStyleSelector::applyProperty):
        (WebCore::CSSStyleSelector::mapBackgroundSize):
        (WebCore::CSSStyleSelector::mapBackgroundXPosition):
        (WebCore::CSSStyleSelector::mapBackgroundYPosition):
        * platform/StringImpl.cpp:
        (WebCore::parseLength):
        * rendering/AutoTableLayout.cpp:
        (WebCore::AutoTableLayout::recalcColumn):
        (WebCore::AutoTableLayout::fullRecalc):
        (WebCore::AutoTableLayout::calcMinMaxWidth):
        (WebCore::AutoTableLayout::calcEffectiveWidth):
        (WebCore::AutoTableLayout::layout):
        (WebCore::AutoTableLayout::calcPercentages):
        * rendering/FixedTableLayout.cpp:
        (WebCore::FixedTableLayout::calcWidthArray):
        (WebCore::FixedTableLayout::layout):
        * rendering/Length.h:
        (WebCore::Length::Length):
        (WebCore::Length::value):
        (WebCore::Length::rawValue):
        (WebCore::Length::percent):
        (WebCore::Length::setValue):
        (WebCore::Length::setRawValue):
        (WebCore::Length::calcValue):
        (WebCore::Length::calcMinValue):
        (WebCore::Length::isUndefined):
        (WebCore::Length::isZero):
        (WebCore::Length::isPositive):
        (WebCore::Length::isNegative):
        * rendering/RenderBR.cpp:
        (WebCore::RenderBR::lineHeight):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::isSelfCollapsingBlock):
        * rendering/RenderBox.cpp:
        (WebCore::cacluateBackgroundSize):
        (WebCore::RenderBox::calcWidth):
        (WebCore::RenderBox::calcHeight):
        (WebCore::RenderBox::calcReplacedWidth):
        (WebCore::RenderBox::calcReplacedHeight):
        (WebCore::RenderBox::calcAbsoluteHorizontal):
        (WebCore::RenderBox::calcAbsoluteVertical):
        * rendering/RenderFlexibleBox.cpp:
        (WebCore::RenderFlexibleBox::allowedChildFlex):
        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::lineHeight):
        * rendering/RenderImage.cpp:
        (WebCore::RenderImage::calcReplacedWidth):
        (WebCore::RenderImage::calcReplacedHeight):
        * rendering/RenderLayer.cpp:
        (WebCore::Marquee::direction):
        (WebCore::Marquee::start):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::mustRepaintBackgroundOrBorder):
        (WebCore::RenderObject::lineHeight):
        * rendering/RenderSlider.cpp:
        (WebCore::RenderSlider::layout): Added FIXMEs.
        * rendering/RenderStyle.h:
        (WebCore::LengthBox::nonZero):
        (WebCore::RenderStyle::initialLineHeight):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::calcWidth):
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::addCell):
        (WebCore::RenderTableSection::layoutRows):

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

41 files changed:
LayoutTests/ChangeLog
LayoutTests/css2.1/t0804-c5507-padn-r-00-c-ag-expected.checksum
LayoutTests/css2.1/t0804-c5507-padn-r-00-c-ag-expected.png
LayoutTests/css2.1/t0804-c5507-padn-r-00-c-ag-expected.txt
LayoutTests/css2.1/t0804-c5509-padn-l-00-b-ag-expected.checksum
LayoutTests/css2.1/t0804-c5509-padn-l-00-b-ag-expected.png
LayoutTests/css2.1/t0804-c5509-padn-l-00-b-ag-expected.txt
LayoutTests/css2.1/t09-c5526c-display-00-e-expected.checksum
LayoutTests/css2.1/t09-c5526c-display-00-e-expected.png
LayoutTests/css2.1/t09-c5526c-display-00-e-expected.txt
LayoutTests/fast/block/basic/011-expected.checksum
LayoutTests/fast/block/basic/011-expected.png
LayoutTests/fast/block/basic/011-expected.txt
LayoutTests/fast/css/percentage-non-integer-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/percentage-non-integer-expected.png [new file with mode: 0644]
LayoutTests/fast/css/percentage-non-integer-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/percentage-non-integer.html [new file with mode: 0644]
LayoutTests/tables/mozilla/bugs/bug4385-expected.checksum
LayoutTests/tables/mozilla/bugs/bug4385-expected.png
LayoutTests/tables/mozilla/bugs/bug4385-expected.txt
LayoutTests/tables/mozilla_expected_failures/core/col_span2-expected.checksum
LayoutTests/tables/mozilla_expected_failures/core/col_span2-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/cssstyleselector.cpp
WebCore/platform/StringImpl.cpp
WebCore/rendering/AutoTableLayout.cpp
WebCore/rendering/FixedTableLayout.cpp
WebCore/rendering/Length.h
WebCore/rendering/RenderBR.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderFlexibleBox.cpp
WebCore/rendering/RenderFlow.cpp
WebCore/rendering/RenderImage.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderSlider.cpp
WebCore/rendering/RenderStyle.h
WebCore/rendering/RenderTable.cpp
WebCore/rendering/RenderTableSection.cpp

index 349dea1..550920f 100644 (file)
@@ -2,6 +2,35 @@
 
         Reviewed by Hyatt.
 
+        - test and updated results for http://bugs.webkit.org/show_bug.cgi?id=5164
+          Non-integer percentages are incorrectly rounded down in Safari
+
+        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.checksum:
+        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.png:
+        * css2.1/t0804-c5507-padn-r-00-c-ag-expected.txt:
+        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.checksum:
+        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.png:
+        * css2.1/t0804-c5509-padn-l-00-b-ag-expected.txt:
+        * css2.1/t09-c5526c-display-00-e-expected.checksum:
+        * css2.1/t09-c5526c-display-00-e-expected.png:
+        * css2.1/t09-c5526c-display-00-e-expected.txt:
+        * fast/block/basic/011-expected.checksum:
+        * fast/block/basic/011-expected.png:
+        * fast/block/basic/011-expected.txt:
+        * fast/css/percentage-non-integer-expected.checksum: Added.
+        * fast/css/percentage-non-integer-expected.png: Added.
+        * fast/css/percentage-non-integer-expected.txt: Added.
+        * fast/css/percentage-non-integer.html: Added.
+        * tables/mozilla/bugs/bug4385-expected.checksum:
+        * tables/mozilla/bugs/bug4385-expected.png:
+        * tables/mozilla/bugs/bug4385-expected.txt:
+        * tables/mozilla_expected_failures/core/col_span2-expected.checksum:
+        * tables/mozilla_expected_failures/core/col_span2-expected.txt:
+
+2007-01-03  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Hyatt.
+
         - test for http://bugs.webkit.org/show_bug.cgi?id=11744
           Setting the 'content' property dynamically has no effect
 
index c69c32f..bfe3c24 100644 (file)
@@ -1 +1 @@
-7711ab1b2502c95d804d4dfba8796ae0
\ No newline at end of file
+7f7132b79b97bb2b06e2727a324edecc
\ No newline at end of file
index 07f123d..80908b6 100644 (file)
Binary files a/LayoutTests/css2.1/t0804-c5507-padn-r-00-c-ag-expected.png and b/LayoutTests/css2.1/t0804-c5507-padn-r-00-c-ag-expected.png differ
index 6cdd6cc..daddf48 100644 (file)
@@ -20,5 +20,5 @@ layer at (0,0) size 800x150
           RenderText {#text} at (48,0) size 10x10
             text run at (48,0) width 10: "x"
         RenderBlock {P} at (0,80) size 106x10 [bgcolor=#000080]
-          RenderText {#text} at (49,0) size 10x10
-            text run at (49,0) width 10: "x"
+          RenderText {#text} at (48,0) size 10x10
+            text run at (48,0) width 10: "x"
index 2625e4c..bfe3c24 100644 (file)
@@ -1 +1 @@
-2b7595d0d1513f162454186d04d583bd
\ No newline at end of file
+7f7132b79b97bb2b06e2727a324edecc
\ No newline at end of file
index 39e9f0b..80908b6 100644 (file)
Binary files a/LayoutTests/css2.1/t0804-c5509-padn-l-00-b-ag-expected.png and b/LayoutTests/css2.1/t0804-c5509-padn-l-00-b-ag-expected.png differ
index fee084a..daddf48 100644 (file)
@@ -20,5 +20,5 @@ layer at (0,0) size 800x150
           RenderText {#text} at (48,0) size 10x10
             text run at (48,0) width 10: "x"
         RenderBlock {P} at (0,80) size 106x10 [bgcolor=#000080]
-          RenderText {#text} at (47,0) size 10x10
-            text run at (47,0) width 10: "x"
+          RenderText {#text} at (48,0) size 10x10
+            text run at (48,0) width 10: "x"
index a6dc871..b68a66b 100644 (file)
@@ -1 +1 @@
-9d0299b6d59c126fb7c9c410f535e55f
\ No newline at end of file
+25ed9975af1d56ff395d80fc87bacaac
\ No newline at end of file
index b1f6347..41f5002 100644 (file)
Binary files a/LayoutTests/css2.1/t09-c5526c-display-00-e-expected.png and b/LayoutTests/css2.1/t09-c5526c-display-00-e-expected.png differ
index 94c6bb8..b895241 100644 (file)
@@ -4,7 +4,7 @@ layer at (0,0) size 800x420
   RenderBlock {HTML} at (0,0) size 800x420 [color=#FFFFFF] [bgcolor=#0000FF]
     RenderBody {BODY} at (15,15) size 490x390 [bgcolor=#FFFFFF] [border: (5px solid #000000)]
       RenderBlock {DL} at (5,5) size 480x10
-        RenderBlock (floating) {DT} at (5,5) size 77x310 [bgcolor=#CC0000] [border: (5px solid #000000)]
+        RenderBlock (floating) {DT} at (5,5) size 79x310 [bgcolor=#CC0000] [border: (5px solid #000000)]
           RenderText {#text} at (15,14) size 31x12
             text run at (15,14) width 31: "toggle"
         RenderBlock (floating) {DD} at (95,5) size 380x310 [border: (10px solid #000000)]
index 5d5d94e..ad686e3 100644 (file)
@@ -1 +1 @@
-dc8e164fe2bf66b76a68b84faea8a7e7
\ No newline at end of file
+7b35526e2db3a84ab2cf05332f3c1c12
\ No newline at end of file
index 546ffb7..f13138f 100644 (file)
Binary files a/LayoutTests/fast/block/basic/011-expected.png and b/LayoutTests/fast/block/basic/011-expected.png differ
index 0546b28..312190e 100644 (file)
@@ -4,7 +4,7 @@ layer at (0,0) size 800x420
   RenderBlock {HTML} at (0,0) size 800x420 [color=#FFFFFF] [bgcolor=#0000FF]
     RenderBody {BODY} at (15,15) size 490x390 [bgcolor=#FFFFFF] [border: (5px solid #000000)]
       RenderBlock {DL} at (5,5) size 480x10
-        RenderBlock (floating) {DT} at (5,5) size 77x310 [bgcolor=#CC0000] [border: (5px solid #000000)]
+        RenderBlock (floating) {DT} at (5,5) size 79x310 [bgcolor=#CC0000] [border: (5px solid #000000)]
           RenderText {#text} at (15,14) size 31x12
             text run at (15,14) width 31: "toggle"
         RenderBlock (floating) {DD} at (95,5) size 380x310 [border: (10px solid #000000)]
diff --git a/LayoutTests/fast/css/percentage-non-integer-expected.checksum b/LayoutTests/fast/css/percentage-non-integer-expected.checksum
new file mode 100644 (file)
index 0000000..2273e61
--- /dev/null
@@ -0,0 +1 @@
+894253a73fdcd593dbb354e032c879ed
\ No newline at end of file
diff --git a/LayoutTests/fast/css/percentage-non-integer-expected.png b/LayoutTests/fast/css/percentage-non-integer-expected.png
new file mode 100644 (file)
index 0000000..5ae1c7e
Binary files /dev/null and b/LayoutTests/fast/css/percentage-non-integer-expected.png differ
diff --git a/LayoutTests/fast/css/percentage-non-integer-expected.txt b/LayoutTests/fast/css/percentage-non-integer-expected.txt
new file mode 100644 (file)
index 0000000..c5ca38a
--- /dev/null
@@ -0,0 +1,106 @@
+layer at (0,0) size 1013x585
+  RenderView at (0,0) size 800x585
+layer at (0,0) size 1013x585
+  RenderBlock {HTML} at (0,0) size 800x585
+    RenderBody {BODY} at (8,8) size 784x569
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#00FF00]
+        RenderBlock {DIV} at (0,0) size 100x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,4) size 1005x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,8) size 995x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,12) size 985x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,16) size 975x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,20) size 965x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,24) size 955x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,28) size 945x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,32) size 935x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,36) size 930x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,40) size 920x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,44) size 910x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,48) size 910x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,52) size 900x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,56) size 890x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,60) size 885x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,64) size 875x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,68) size 870x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,72) size 860x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,76) size 850x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,80) size 845x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,84) size 840x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,88) size 835x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,92) size 825x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+        RenderBlock {DIV} at (0,96) size 815x4
+          RenderBlock {DIV} at (0,0) size 100x4 [bgcolor=#0000007F]
+      RenderBlock (anonymous) at (0,100) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+layer at (8,126) size 293x10
+  RenderTable {TABLE} at (0,0) size 293x10
+    RenderTableSection {TBODY} at (0,0) size 293x10
+      RenderTableRow {TR} at (0,0) size 293x10
+        RenderTableCell {TD} at (0,5) size 11x0 [bgcolor=#00FF00] [r=0 c=0 rs=1 cs=1]
+        RenderTableCell {TD} at (11,5) size 10x0 [bgcolor=#000000] [r=0 c=1 rs=1 cs=1]
+        RenderTableCell {TD} at (21,5) size 13x0 [bgcolor=#00FF00] [r=0 c=2 rs=1 cs=1]
+        RenderTableCell {TD} at (34,5) size 10x0 [bgcolor=#000000] [r=0 c=3 rs=1 cs=1]
+        RenderTableCell {TD} at (44,5) size 15x0 [bgcolor=#00FF00] [r=0 c=4 rs=1 cs=1]
+        RenderTableCell {TD} at (59,5) size 10x0 [bgcolor=#000000] [r=0 c=5 rs=1 cs=1]
+        RenderTableCell {TD} at (69,5) size 17x0 [bgcolor=#00FF00] [r=0 c=6 rs=1 cs=1]
+        RenderTableCell {TD} at (86,5) size 10x0 [bgcolor=#000000] [r=0 c=7 rs=1 cs=1]
+        RenderTableCell {TD} at (96,5) size 20x0 [bgcolor=#00FF00] [r=0 c=8 rs=1 cs=1]
+        RenderTableCell {TD} at (116,5) size 10x0 [bgcolor=#000000] [r=0 c=9 rs=1 cs=1]
+        RenderTableCell {TD} at (126,5) size 21x0 [bgcolor=#00FF00] [r=0 c=10 rs=1 cs=1]
+        RenderTableCell {TD} at (147,5) size 10x0 [bgcolor=#000000] [r=0 c=11 rs=1 cs=1]
+        RenderTableCell {TD} at (157,5) size 23x0 [bgcolor=#00FF00] [r=0 c=12 rs=1 cs=1]
+        RenderTableCell {TD} at (180,5) size 10x0 [bgcolor=#000000] [r=0 c=13 rs=1 cs=1]
+        RenderTableCell {TD} at (190,5) size 25x0 [bgcolor=#00FF00] [r=0 c=14 rs=1 cs=1]
+        RenderTableCell {TD} at (215,5) size 10x0 [bgcolor=#000000] [r=0 c=15 rs=1 cs=1]
+        RenderTableCell {TD} at (225,5) size 27x0 [bgcolor=#00FF00] [r=0 c=16 rs=1 cs=1]
+        RenderTableCell {TD} at (252,5) size 10x0 [bgcolor=#000000] [r=0 c=17 rs=1 cs=1]
+        RenderTableCell {TD} at (262,5) size 30x0 [bgcolor=#00FF00] [r=0 c=18 rs=1 cs=1]
+        RenderTableCell {TD} at (292,5) size 1x0 [r=0 c=19 rs=1 cs=1]
+layer at (8,126) size 1000x10
+  RenderTable {TABLE} at (0,0) size 1000x10
+    RenderTableSection {TBODY} at (0,0) size 1000x10
+      RenderTableRow {TR} at (0,0) size 1000x10
+        RenderTableCell {TD} at (0,5) size 11x0 [bgcolor=#0000007F] [r=0 c=0 rs=1 cs=1]
+        RenderTableCell {TD} at (11,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=1 rs=1 cs=1]
+        RenderTableCell {TD} at (21,5) size 13x0 [bgcolor=#0000007F] [r=0 c=2 rs=1 cs=1]
+        RenderTableCell {TD} at (34,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=3 rs=1 cs=1]
+        RenderTableCell {TD} at (44,5) size 15x0 [bgcolor=#0000007F] [r=0 c=4 rs=1 cs=1]
+        RenderTableCell {TD} at (59,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=5 rs=1 cs=1]
+        RenderTableCell {TD} at (69,5) size 17x0 [bgcolor=#0000007F] [r=0 c=6 rs=1 cs=1]
+        RenderTableCell {TD} at (86,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=7 rs=1 cs=1]
+        RenderTableCell {TD} at (96,5) size 20x0 [bgcolor=#0000007F] [r=0 c=8 rs=1 cs=1]
+        RenderTableCell {TD} at (116,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=9 rs=1 cs=1]
+        RenderTableCell {TD} at (126,5) size 21x0 [bgcolor=#0000007F] [r=0 c=10 rs=1 cs=1]
+        RenderTableCell {TD} at (147,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=11 rs=1 cs=1]
+        RenderTableCell {TD} at (157,5) size 23x0 [bgcolor=#0000007F] [r=0 c=12 rs=1 cs=1]
+        RenderTableCell {TD} at (180,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=13 rs=1 cs=1]
+        RenderTableCell {TD} at (190,5) size 25x0 [bgcolor=#0000007F] [r=0 c=14 rs=1 cs=1]
+        RenderTableCell {TD} at (215,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=15 rs=1 cs=1]
+        RenderTableCell {TD} at (225,5) size 27x0 [bgcolor=#0000007F] [r=0 c=16 rs=1 cs=1]
+        RenderTableCell {TD} at (252,5) size 10x0 [bgcolor=#00FF007F] [r=0 c=17 rs=1 cs=1]
+        RenderTableCell {TD} at (262,5) size 30x0 [bgcolor=#0000007F] [r=0 c=18 rs=1 cs=1]
+        RenderTableCell {TD} at (292,5) size 708x0 [r=0 c=19 rs=1 cs=1]
diff --git a/LayoutTests/fast/css/percentage-non-integer.html b/LayoutTests/fast/css/percentage-non-integer.html
new file mode 100644 (file)
index 0000000..c912aa2
--- /dev/null
@@ -0,0 +1,93 @@
+<head>
+    <title>Test for http://bugs.webkit.org/show_bug.cgi?id=5164</title>
+    <style type="text/css">
+        div.bar { height: 4px; background-color: rgba(0, 0, 0, 0.5); }
+        td.green { background-color: green; }
+        td.black { background-color: black; }
+        td.red { background-color: #0f0; }
+        td.greenOverlay { background-color: rgba(0, 255, 0, 0.5); }
+        td.blackOverlay { background-color: rgba(0, 0, 0, 0.5); }
+        td.sep { width: 10px; }
+    </style>
+</head>
+<body>
+    <div style="background-color: #0f0; width: 100px; height: 100px;">
+        <div><div class="bar" style="width: 100px"></div></div>
+        <div style="width: 1005px"><div class="bar" style="width: 10%"></div></div>
+        <div style="width: 995px"><div class="bar" style="width: 10.1%"></div></div>
+        <div style="width: 985px"><div class="bar" style="width: 10.2%"></div></div>
+        <div style="width: 975px"><div class="bar" style="width: 10.3%"></div></div>
+        <div style="width: 965px"><div class="bar" style="width: 10.4%"></div></div>
+        <div style="width: 955px"><div class="bar" style="width: 10.5%"></div></div>
+        <div style="width: 945px"><div class="bar" style="width: 10.6%"></div></div>
+        <div style="width: 935px"><div class="bar" style="width: 10.7%"></div></div>
+        <div style="width: 930px"><div class="bar" style="width: 10.8%"></div></div>
+        <div style="width: 920px"><div class="bar" style="width: 10.9%"></div></div>
+        <div style="width: 910px"><div class="bar" style="width: 11%"></div></div>
+        <div style="width: 910px"><div class="bar" style="width: 11.1%"></div></div>
+        <div style="width: 900px"><div class="bar" style="width: 11.2%"></div></div>
+        <div style="width: 890px"><div class="bar" style="width: 11.3%"></div></div>
+        <div style="width: 885px"><div class="bar" style="width: 11.4%"></div></div>
+        <div style="width: 875px"><div class="bar" style="width: 11.5%"></div></div>
+        <div style="width: 870px"><div class="bar" style="width: 11.6%"></div></div>
+        <div style="width: 860px"><div class="bar" style="width: 11.7%"></div></div>
+        <div style="width: 850px"><div class="bar" style="width: 11.8%"></div></div>
+        <div style="width: 845px"><div class="bar" style="width: 11.9%"></div></div>
+        <div style="width: 840px"><div class="bar" style="width: 12%"></div></div>
+        <div style="width: 835px"><div class="bar" style="width: 12.1%"></div></div>
+        <div style="width: 825px"><div class="bar" style="width: 12.2%"></div></div>
+        <div style="width: 815px"><div class="bar" style="width: 12.3%"></div></div>
+    </div>
+    <br>
+    <div style="position: relative;">
+        <table style="position: absolute; top: 0; left: 0; " cellpadding="0" cellspacing="0">
+            <tr style="height: 10px;">
+                <td class="red" style="width: 11px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 13px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 15px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 17px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 20px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 21px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 23px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 25px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 27px;"></td>
+                <td class="black sep"></td>
+                <td class="red" style="width: 30px;"></td>
+                <td></td>
+            </tr>
+        </table>
+        <table style="position: absolute; top: 0; left: 0; width: 1000px;" cellpadding="0" cellspacing="0">
+            <tr style="height: 10px;">
+                <td class="blackOverlay" style="width: 1.2%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 1.4%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 1.6%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 1.8%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 2%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 2.2%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 2.4%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 2.6%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 2.8%;"></td>
+                <td class="greenOverlay sep"></td>
+                <td class="blackOverlay" style="width: 3%;"></td>
+                <td></td>
+            </tr>
+        </table>
+    </div>
+</body>
+</html>
index 371ca9b..1f992ca 100644 (file)
@@ -1 +1 @@
-ff5c33d0a2ce20927f83a1b91b20c392
\ No newline at end of file
+6707f72f5237fc83cb3b9964a9d36a65
\ No newline at end of file
index 20bf0a1..f031f72 100644 (file)
Binary files a/LayoutTests/tables/mozilla/bugs/bug4385-expected.png and b/LayoutTests/tables/mozilla/bugs/bug4385-expected.png differ
index 7d49ffd..2965ec5 100644 (file)
@@ -10,7 +10,7 @@ layer at (0,0) size 800x600
               RenderText {#text} at (2,2) size 12x18
                 text run at (2,2) width 12: "A"
           RenderTableRow {TR} at (0,26) size 782x22
-            RenderTableCell {TD} at (2,35) size 8x4 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (12,26) size 768x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (2,35) size 16x4 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (20,26) size 760x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 195x18
                 text run at (2,2) width 195: "This text is invariably wrapped"
index 65d27a9..3e07b4f 100644 (file)
@@ -492,10 +492,10 @@ layer at (0,0) size 785x5451
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 291x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 294x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 24x18
                 text run at (2,2) width 24: "100"
-            RenderTableCell {TD} at (301,32) size 90x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (304,32) size 87x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
             RenderTableCell {TD} at (396,32) size 97x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
@@ -513,10 +513,10 @@ layer at (0,0) size 785x5451
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 95x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 97x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 24x18
                 text run at (2,2) width 24: "100"
-            RenderTableCell {TD} at (105,32) size 286x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (107,32) size 284x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 24x18
                 text run at (2,2) width 24: "300"
             RenderTableCell {TD} at (396,32) size 97x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
@@ -643,13 +643,13 @@ layer at (0,0) size 785x5451
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x58
-            RenderTableCell {TD} at (5,50) size 66x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,50) size 70x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
-            RenderTableCell {TD} at (76,50) size 141x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (80,50) size 143x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 59x18
                 text run at (2,2) width 59: "auto-auto"
-            RenderTableCell {TD} at (222,50) size 217x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (228,50) size 211x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 89x18
                 text run at (2,2) width 89: "auto auto auto"
             RenderTableCell {TD} at (444,32) size 49x58 [border: (1px inset #808080)] [r=1 c=3 rs=1 cs=1]
@@ -669,20 +669,20 @@ layer at (0,0) size 785x5451
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 122x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 124x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
-            RenderTableCell {TD} at (132,32) size 125x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (134,32) size 123x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
             RenderTableCell {TD} at (262,32) size 231x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,59) size 498x22
-            RenderTableCell {TD} at (5,59) size 122x22 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,59) size 124x22 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
-            RenderTableCell {TD} at (132,59) size 361x22 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=2]
+            RenderTableCell {TD} at (134,59) size 359x22 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=2]
               RenderText {#text} at (2,2) size 95x18
                 text run at (2,2) width 95: "90% 90% 90%"
       RenderBlock (anonymous) at (0,2725) size 769x18
@@ -796,10 +796,10 @@ layer at (0,0) size 785x5451
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 139x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 142x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
-            RenderTableCell {TD} at (149,32) size 291x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (152,32) size 288x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 59x18
                 text run at (2,2) width 59: "auto-auto"
             RenderTableCell {TD} at (445,32) size 48x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
@@ -877,20 +877,20 @@ layer at (0,0) size 785x5451
       RenderTable {TABLE} at (0,3519) size 500x61 [border: (1px outset #808080)]
         RenderTableSection {TBODY} at (1,1) size 498x59
           RenderTableRow {TR} at (0,5) size 498x22
-            RenderTableCell {TD} at (5,5) size 435x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]
+            RenderTableCell {TD} at (5,5) size 434x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]
               RenderText {#text} at (2,2) size 194x18
                 text run at (2,2) width 194: "90% 90% 90% 90% 90% 90%"
-            RenderTableCell {TD} at (445,5) size 48x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (444,5) size 49x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 191x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 195x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 16x18
                 text run at (2,2) width 16: "10"
-            RenderTableCell {TD} at (201,32) size 239x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (205,32) size 234x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 16x18
                 text run at (2,2) width 16: "20"
-            RenderTableCell {TD} at (445,32) size 48x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (444,32) size 49x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
       RenderBlock (anonymous) at (0,3580) size 769x18
@@ -920,20 +920,20 @@ layer at (0,0) size 785x5451
       RenderTable {TABLE} at (0,3695) size 500x61 [border: (1px outset #808080)]
         RenderTableSection {TBODY} at (1,1) size 498x59
           RenderTableRow {TR} at (0,5) size 498x22
-            RenderTableCell {TD} at (5,5) size 434x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]
+            RenderTableCell {TD} at (5,5) size 435x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]
               RenderText {#text} at (2,2) size 161x18
                 text run at (2,2) width 161: "90% 50% 50% 50% 50%"
-            RenderTableCell {TD} at (444,5) size 49x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (445,5) size 48x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
           RenderTableRow {TR} at (0,32) size 498x22
-            RenderTableCell {TD} at (5,32) size 224x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (5,32) size 227x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 24x18
                 text run at (2,2) width 24: "100"
-            RenderTableCell {TD} at (234,32) size 205x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (237,32) size 203x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 89x18
                 text run at (2,2) width 89: "auto auto auto"
-            RenderTableCell {TD} at (444,32) size 49x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (445,32) size 48x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "auto"
       RenderBlock (anonymous) at (0,3756) size 769x36
index dda8ca6..62e11d3 100644 (file)
@@ -2,6 +2,107 @@
 
         Reviewed by Hyatt.
 
+        - fix http://bugs.webkit.org/show_bug.cgi?id=5164
+          Non-integer percentages are incorrectly rounded down in Safari
+
+        Test: fast/css/percentage-non-integer.html
+
+        Added floating point constructor and accessors to Length for use with
+        Percent lengths only. The raw value of a percent length is the integer
+        part of a constant multiple of the original double value. The constant
+        is percentScaleFactor, which is currently 128.
+        
+        Added assertions that the correct constructors and accessors are used
+        depending on the type: the double-based percent(), setValue() and Length()
+        for the Percent type, and the integer-based value(), setValue() and Length()
+        for all other types.
+        
+        calcValue() and calcMinValue() work the same as before, regardless of the
+        type.
+
+        Added helpers for testing if the value is 0, positive, negative or undefined
+        without having to check the type first.
+        
+        Added raw value accessors. These are useful for doing integer math and
+        comparisons with scaled percent values or doing Length type-agnostic math.
+
+        Changed the rest of the code to use the appropriate accessors and helpers.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForLength):
+        (WebCore::primitiveValueFromLength):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/cssstyleselector.cpp:
+        (WebCore::convertToLength):
+        (WebCore::CSSStyleSelector::applyProperty):
+        (WebCore::CSSStyleSelector::mapBackgroundSize):
+        (WebCore::CSSStyleSelector::mapBackgroundXPosition):
+        (WebCore::CSSStyleSelector::mapBackgroundYPosition):
+        * platform/StringImpl.cpp:
+        (WebCore::parseLength):
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        (WebCore::AutoTableLayout::fullRecalc):
+        (WebCore::AutoTableLayout::calcMinMaxWidth):
+        (WebCore::AutoTableLayout::calcEffectiveWidth):
+        (WebCore::AutoTableLayout::layout):
+        (WebCore::AutoTableLayout::calcPercentages):
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::FixedTableLayout::calcWidthArray):
+        (WebCore::FixedTableLayout::layout):
+        * rendering/Length.h:
+        (WebCore::Length::Length):
+        (WebCore::Length::value):
+        (WebCore::Length::rawValue):
+        (WebCore::Length::percent):
+        (WebCore::Length::setValue):
+        (WebCore::Length::setRawValue):
+        (WebCore::Length::calcValue):
+        (WebCore::Length::calcMinValue):
+        (WebCore::Length::isUndefined):
+        (WebCore::Length::isZero):
+        (WebCore::Length::isPositive):
+        (WebCore::Length::isNegative):
+        * rendering/RenderBR.cpp:
+        (WebCore::RenderBR::lineHeight):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::isSelfCollapsingBlock):
+        * rendering/RenderBox.cpp:
+        (WebCore::cacluateBackgroundSize):
+        (WebCore::RenderBox::calcWidth):
+        (WebCore::RenderBox::calcHeight):
+        (WebCore::RenderBox::calcReplacedWidth):
+        (WebCore::RenderBox::calcReplacedHeight):
+        (WebCore::RenderBox::calcAbsoluteHorizontal):
+        (WebCore::RenderBox::calcAbsoluteVertical):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::allowedChildFlex):
+        * rendering/RenderFlow.cpp:
+        (WebCore::RenderFlow::lineHeight):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::calcReplacedWidth):
+        (WebCore::RenderImage::calcReplacedHeight):
+        * rendering/RenderLayer.cpp:
+        (WebCore::Marquee::direction):
+        (WebCore::Marquee::start):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::mustRepaintBackgroundOrBorder):
+        (WebCore::RenderObject::lineHeight):
+        * rendering/RenderSlider.cpp:
+        (WebCore::RenderSlider::layout): Added FIXMEs.
+        * rendering/RenderStyle.h:
+        (WebCore::LengthBox::nonZero):
+        (WebCore::RenderStyle::initialLineHeight):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::calcWidth):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::addCell):
+        (WebCore::RenderTableSection::layoutRows):
+
+2007-01-03  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Hyatt.
+
         - fix http://bugs.webkit.org/show_bug.cgi?id=11744
           Setting the 'content' property dynamically has no effect
 
index 9b81095..21ae3d6 100644 (file)
@@ -168,7 +168,7 @@ static CSSValue* valueForLength(const Length& length)
         case MinIntrinsic:
             return new CSSPrimitiveValue(CSS_VAL_MIN_INTRINSIC);
         case Percent:
-            return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+            return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
         case Relative:
         case Static:
             // Should never be reached.
@@ -338,7 +338,7 @@ CSSPrimitiveValue* primitiveValueFromLength(Length length, RenderObject* rendere
 {
     String string;
     if (length.isPercent())
-        string = numberAsString(length.value()) + "%";
+        string = numberAsString(length.percent()) + "%";
     else if (length.isFixed())
         string = numberAsString(length.calcMinValue(0));
     else if (length.isAuto())
@@ -444,13 +444,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         String string;
         Length length(style->backgroundXPosition());
         if (length.isPercent())
-            string = numberAsString(length.value()) + "%";
+            string = numberAsString(length.percent()) + "%";
         else
             string = numberAsString(length.calcMinValue(renderer->contentWidth()));
         string += " ";
         length = style->backgroundYPosition();
         if (length.isPercent())
-            string += numberAsString(length.value()) + "%";
+            string += numberAsString(length.percent()) + "%";
         else
             string += numberAsString(length.calcMinValue(renderer->contentWidth()));
         return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
@@ -857,7 +857,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
     case CSS_PROP_LINE_HEIGHT: {
         Length length(style->lineHeight());
-        if (length.value() < 0)
+        if (length.isNegative())
             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
         if (length.isPercent()) {
             // This is imperfect, because it doesn't include the zoom factor and the real computation
@@ -865,7 +865,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             // On the other hand, since font-size doesn't include the zoom factor, we really can't do
             // that here either.
             float fontSize = style->fontDescription().specifiedSize();
-            return new CSSPrimitiveValue((int)(length.value() * fontSize) / 100, CSSPrimitiveValue::CSS_PX);
+            return new CSSPrimitiveValue((int)(length.percent() * fontSize) / 100, CSSPrimitiveValue::CSS_PX);
         }
         else {
             return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
index 828a2e3..9352702 100644 (file)
@@ -1778,9 +1778,9 @@ static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *st
         if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
         else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            l = Length(int(primitiveValue->getFloatValue()), Percent);
+            l = Length(primitiveValue->getFloatValue(), Percent);
         else if(type == CSSPrimitiveValue::CSS_NUMBER)
-            l = Length(int(primitiveValue->getFloatValue() * 100), Percent);
+            l = Length(primitiveValue->getFloatValue() * 100.0, Percent);
         else if (ok)
             *ok = false;
     }
@@ -2855,7 +2855,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                 l = Length(primitiveValue->computeLengthIntForLength(style), Fixed, 
                            primitiveValue->isQuirkValue());
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l = Length((int)primitiveValue->getFloatValue(), Percent);
+                l = Length(primitiveValue->getFloatValue(), Percent);
             else
                 return;
             if (id == CSS_PROP_PADDING_LEFT || id == CSS_PROP_PADDING_RIGHT ||
@@ -2938,7 +2938,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
                 l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
             else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l = Length((int)primitiveValue->getFloatValue(), Percent);
+                l = Length(primitiveValue->getFloatValue(), Percent);
             else
                 return;
             apply = true;
@@ -2994,7 +2994,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
           if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
           else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            l = Length(int(primitiveValue->getFloatValue()), Percent);
+            l = Length(primitiveValue->getFloatValue(), Percent);
 
           style->setVerticalAlign(LENGTH);
           style->setVerticalAlignLength(l);
@@ -3122,7 +3122,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         Length lineHeight;
         int type = primitiveValue->primitiveType();
         if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
-            lineHeight = Length(-100, Percent);
+            lineHeight = Length(-100.0, Percent);
         else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
             double multiplier = 1.0;
             // Scale for the font zoom factor only for types other than "em" and "ex", since those are
@@ -3134,7 +3134,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
             lineHeight = Length((style->fontSize() * int(primitiveValue->getFloatValue())) / 100, Fixed);
         else if (type == CSSPrimitiveValue::CSS_NUMBER)
-            lineHeight = Length(int(primitiveValue->getFloatValue() * 100), Percent);
+            lineHeight = Length(primitiveValue->getFloatValue() * 100.0, Percent);
         else
             return;
         style->setLineHeight(lineHeight);
@@ -3633,19 +3633,19 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             LengthBox& l = image.m_slices;
             RectImpl* r = borderImage->m_imageSliceRect.get();
             if (r->top()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.top = Length((int)r->top()->getFloatValue(), Percent);
+                l.top = Length(r->top()->getFloatValue(), Percent);
             else
                 l.top = Length((int)r->top()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->bottom()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.bottom = Length((int)r->bottom()->getFloatValue(), Percent);
+                l.bottom = Length(r->bottom()->getFloatValue(), Percent);
             else
                 l.bottom = Length((int)r->bottom()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->left()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.left = Length((int)r->left()->getFloatValue(), Percent);
+                l.left = Length(r->left()->getFloatValue(), Percent);
             else
                 l.left = Length((int)r->left()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->right()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.right = Length((int)r->right()->getFloatValue(), Percent);
+                l.right = Length(r->right()->getFloatValue(), Percent);
             else
                 l.right = Length((int)r->right()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             
@@ -4413,7 +4413,7 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value
     else if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG)
         firstLength = Length(first->computeLengthIntForLength(style), Fixed);
     else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE)
-        firstLength = Length((int)first->getFloatValue(), Percent);
+        firstLength = Length(first->getFloatValue(), Percent);
     else
         return;
 
@@ -4422,7 +4422,7 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value
     else if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG)
         secondLength = Length(second->computeLengthIntForLength(style), Fixed);
     else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE)
-        secondLength = Length((int)second->getFloatValue(), Percent);
+        secondLength = Length(second->getFloatValue(), Percent);
     else
         return;
     
@@ -4446,7 +4446,7 @@ void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, CSSValue*
     if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
     else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-        l = Length((int)primitiveValue->getFloatValue(), Percent);
+        l = Length(primitiveValue->getFloatValue(), Percent);
     else
         return;
     layer->setBackgroundXPosition(l);
@@ -4467,7 +4467,7 @@ void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, CSSValue*
     if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
     else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-        l = Length((int)primitiveValue->getFloatValue(), Percent);
+        l = Length(primitiveValue->getFloatValue(), Percent);
     else
         return;
     layer->setBackgroundYPosition(l);
index 3bb2e15..29651be 100644 (file)
@@ -301,7 +301,7 @@ static Length parseLength(const UChar* m_data, unsigned int m_length)
         if (i < m_length) {
             UChar next = m_data[i];
             if (next == '%')
-                return Length(r, Percent);
+                return Length(static_cast<double>(r), Percent);
             if (next == '*')
                 return Length(r, Relative);
         }
index 3aa6c8c..285dd85 100644 (file)
@@ -86,9 +86,10 @@ void AutoTableLayout::recalcColumn(int effCol)
                     }
 
                     Length w = cell->styleOrColWidth();
-                    if (w.value() > 32760)
-                        w.setValue(32760);
-                    if (w.value() < 0)
+                    // FIXME: What is this arbitrary value?
+                    if (w.rawValue() > 32760)
+                        w.setRawValue(32760);
+                    if (w.isNegative())
                         w.setValue(0);
                     switch(w.type()) {
                     case Fixed:
@@ -110,11 +111,13 @@ void AutoTableLayout::recalcColumn(int effCol)
                         break;
                     case Percent:
                         m_hasPercent = true;
-                        if (w.value() > 0 && (!l.width.isPercent() || w.value() > l.width.value()))
+                        if (w.isPositive() && (!l.width.isPercent() || w.rawValue() > l.width.rawValue()))
                             l.width = w;
                         break;
                     case Relative:
-                        if (w.isAuto() || (w.isRelative() && w.value() > l.width.value()))
+                        // FIXME: Need to understand this case and whether it makes sense to compare values
+                        // which are not necessarily of the same type.
+                        if (w.isAuto() || (w.isRelative() && w.value() > l.width.rawValue()))
                             l.width = w;
                     default:
                         break;
@@ -174,7 +177,7 @@ void AutoTableLayout::fullRecalc()
                 Length w = col->style()->width();
                 if (w.isAuto())
                     w = grpWidth;
-                if ((w.isFixed() && w.value() == 0) || (w.isPercent() && w.value() == 0))
+                if ((w.isFixed() || w.isPercent()) && w.isZero())
                     w = Length();
                 int cEffCol = m_table->colToEffCol(cCol);
 #ifdef DEBUG_LAYOUT
@@ -254,13 +257,13 @@ void AutoTableLayout::calcMinMaxWidth()
     int maxPercent = 0;
     int maxNonPercent = 0;
 
-    int remainingPercent = 100;
+    int remainingPercent = 100 * percentScaleFactor;
     for (unsigned int i = 0; i < m_layoutStruct.size(); i++) {
         minWidth += m_layoutStruct[i].effMinWidth;
         maxWidth += m_layoutStruct[i].effMaxWidth;
         if (m_layoutStruct[i].effWidth.isPercent()) {
-            int percent = min(m_layoutStruct[i].effWidth.value(), remainingPercent);
-            int pw = (m_layoutStruct[i].effMaxWidth * 100) / max(percent, 1);
+            int percent = min(m_layoutStruct[i].effWidth.rawValue(), remainingPercent);
+            int pw = (m_layoutStruct[i].effMaxWidth * 100 * percentScaleFactor) / max(percent, percentScaleFactor);
             remainingPercent -= percent;
             maxPercent = max(pw,  maxPercent);
         } else {
@@ -269,7 +272,8 @@ void AutoTableLayout::calcMinMaxWidth()
     }
 
     if (shouldScaleColumns(m_table)) {
-        maxNonPercent = (maxNonPercent * 100 + 50) / max(remainingPercent, 1);
+        // FIXME: Why 50?
+        maxNonPercent = (maxNonPercent * 100 + 50) * percentScaleFactor / max(remainingPercent, percentScaleFactor);
         maxWidth = max(maxNonPercent,  maxWidth);
         maxWidth = max(maxWidth, maxPercent);
     }
@@ -319,7 +323,7 @@ int AutoTableLayout::calcEffectiveWidth()
         int span = cell->colSpan();
 
         Length w = cell->styleOrColWidth();
-        if (!w.isRelative() && w.value() == 0)
+        if (!w.isRelative() && w.isZero())
             w = Length(); // make it Auto
 
         int col = m_table->colToEffCol(cell->col());
@@ -339,7 +343,7 @@ int AutoTableLayout::calcEffectiveWidth()
         while (lastCol < nEffCols && span > 0) {
             switch (m_layoutStruct[lastCol].width.type()) {
             case Percent:
-                totalPercent += m_layoutStruct[lastCol].width.value();
+                totalPercent += m_layoutStruct[lastCol].width.rawValue();
                 allColsAreFixed = false;
                 break;
             case Fixed:
@@ -367,7 +371,7 @@ int AutoTableLayout::calcEffectiveWidth()
                     allColsArePercent = false;
                 }
                 else
-                    totalPercent += m_layoutStruct[lastCol].effWidth.value();
+                    totalPercent += m_layoutStruct[lastCol].effWidth.rawValue();
                 allColsAreFixed = false;
             }
             span -= m_table->spanOfEffCol(lastCol);
@@ -383,7 +387,7 @@ int AutoTableLayout::calcEffectiveWidth()
 
         // adjust table max width if needed
         if (w.isPercent()) {
-            if (totalPercent > w.value() || allColsArePercent) {
+            if (totalPercent > w.rawValue() || allColsArePercent) {
                 // can't satify this condition, treat as variable
                 w = Length();
             } else {
@@ -391,10 +395,10 @@ int AutoTableLayout::calcEffectiveWidth()
 #ifdef DEBUG_LAYOUT
                 qDebug("    adjusting tMaxWidth (%d): spanMax=%d, value=%d, totalPercent=%d", tMaxWidth, spanMax, w.value, totalPercent);
 #endif
-                tMaxWidth = max(tMaxWidth, spanMax * 100 / w.value());
+                tMaxWidth = max(tMaxWidth, spanMax * 100 * percentScaleFactor / w.rawValue());
 
                 // all non percent columns in the span get percent vlaues to sum up correctly.
-                int percentMissing = w.value() - totalPercent;
+                int percentMissing = w.rawValue() - totalPercent;
                 int totalWidth = 0;
                 for (unsigned int pos = col; pos < lastCol; pos++) {
                     if (!(m_layoutStruct[pos].width.isPercent()))
@@ -410,7 +414,7 @@ int AutoTableLayout::calcEffectiveWidth()
                         totalWidth -= m_layoutStruct[pos].effMaxWidth;
                         percentMissing -= percent;
                         if (percent > 0)
-                            m_layoutStruct[pos].effWidth = Length(percent, Percent);
+                            m_layoutStruct[pos].effWidth.setRawValue(Percent, percent);
                         else
                             m_layoutStruct[pos].effWidth = Length();
                     }
@@ -573,7 +577,7 @@ void AutoTableLayout::layout()
         switch (width.type()) {
         case Percent:
             havePercent = true;
-            totalPercent += width.value();
+            totalPercent += width.rawValue();
             break;
         case Relative:
             haveRelative = true;
@@ -604,9 +608,9 @@ void AutoTableLayout::layout()
                 m_layoutStruct[i].calcWidth = w;
             }
         }
-        if (totalPercent > 100) {
+        if (totalPercent > 100 * percentScaleFactor) {
             // remove overallocated space from the last columns
-            int excess = tableWidth*(totalPercent-100)/100;
+            int excess = tableWidth*(totalPercent - 100 * percentScaleFactor) / (100 * percentScaleFactor);
             for (int i = nEffCols-1; i >= 0; i--) {
                 if (m_layoutStruct[i].effWidth.isPercent()) {
                     int w = m_layoutStruct[i].calcWidth;
@@ -687,14 +691,14 @@ void AutoTableLayout::layout()
 #endif
     
     // spread over percent colums
-    if (available > 0 && m_hasPercent && totalPercent < 100) {
+    if (available > 0 && m_hasPercent && totalPercent < 100 * percentScaleFactor) {
         // still have some width to spread, distribute weighted to percent columns
         for (int i = 0; i < nEffCols; i++) {
             Length &width = m_layoutStruct[i].effWidth;
             if (width.isPercent()) {
-                int w = available * width.value() / totalPercent;
+                int w = available * width.rawValue() / totalPercent;
                 available -= w;
-                totalPercent -= width.value();
+                totalPercent -= width.rawValue();
                 m_layoutStruct[i].calcWidth += w;
                 if (!available || !totalPercent) break;
             }
@@ -833,11 +837,12 @@ void AutoTableLayout::layout()
 
 void AutoTableLayout::calcPercentages() const
 {
-    m_totalPercent = 0;
+    unsigned totalPercent = 0;
     for (unsigned i = 0; i < m_layoutStruct.size(); i++) {
         if (m_layoutStruct[i].width.isPercent())
-            m_totalPercent += m_layoutStruct[i].width.value();
+            totalPercent += m_layoutStruct[i].width.rawValue();
     }
+    m_totalPercent = totalPercent / percentScaleFactor;
     m_percentagesDirty = false;
 }
 
index 7d4ba68..68432dd 100644 (file)
@@ -135,8 +135,8 @@ int FixedTableLayout::calcWidthArray(int tableWidth)
                         m_width[nEffCols-1] = Length();
                     }
                     int eSpan = m_table->spanOfEffCol(cCol+i);
-                    if ((w.isFixed() || w.isPercent()) && w.value() > 0) {
-                        m_width[cCol+i] = Length(w.value() * eSpan, w.type());
+                    if ((w.isFixed() || w.isPercent()) && w.isPositive()) {
+                        m_width[cCol+i].setRawValue(w.type(), w.rawValue() * eSpan);
                         usedWidth += effWidth * eSpan;
 #ifdef DEBUG_LAYOUT
                         qDebug("    setting effCol %d (span=%d) to m_width %d(type=%d)",
@@ -183,8 +183,9 @@ int FixedTableLayout::calcWidthArray(int tableWidth)
                 Length w = cell->styleOrColWidth();
                 int span = cell->colSpan();
                 int effWidth = 0;
-                if ((w.isFixed() || w.isPercent()) && w.value() > 0)
-                    effWidth = w.value();
+                // FIXME: This does not make sense (mixing percentages with absolute length)
+                if ((w.isFixed() || w.isPercent()) && w.isPositive())
+                    effWidth = w.isPercent() ? w.rawValue() / percentScaleFactor : w.value();
                 
 #ifdef DEBUG_LAYOUT
                 qDebug("    table cell: effCol=%d, span=%d: %d",  cCol, span, effWidth);
@@ -196,7 +197,7 @@ int FixedTableLayout::calcWidthArray(int tableWidth)
                     int eSpan = m_table->spanOfEffCol(cCol+i);
                     // only set if no col element has already set it.
                     if (m_width[cCol+i].isAuto() && w.type() != Auto) {
-                        m_width[cCol+i] = Length(w.value() * eSpan, w.type());
+                        m_width[cCol+i].setRawValue(w.type(), w.rawValue() * eSpan);
                         usedWidth += effWidth*eSpan;
 #ifdef DEBUG_LAYOUT
                         qDebug("    setting effCol %d (span=%d) to m_width %d(type=%d)",
@@ -259,21 +260,21 @@ void FixedTableLayout::layout()
     if (available > 0) {
         for (int i = 0; i < nEffCols; i++)
             if (m_width[i].isPercent())
-                totalPercent += m_width[i].value();
+                totalPercent += m_width[i].rawValue();
 
         // calculate how much to distribute to percent cells.
-        int base = tableWidth * totalPercent / 100;
+        int base = tableWidth * totalPercent / (100 * percentScaleFactor);
         if (base > available)
             base = available;
         else
-            totalPercent = 100;
+            totalPercent = 100 * percentScaleFactor;
 
 #ifdef DEBUG_LAYOUT
         qDebug("FixedTableLayout::layout: assigning percent m_width, base=%d, totalPercent=%d", base, totalPercent);
 #endif
         for (int i = 0; available > 0 && i < nEffCols; i++) {
             if (m_width[i].isPercent()) {
-                int w = base * m_width[i].value() / totalPercent;
+                int w = base * m_width[i].rawValue() / totalPercent;
                 available -= w;
                 calcWidth[i] = w;
             }
index 6a3b0fb..3d1ee42 100644 (file)
 #ifndef Length_H
 #define Length_H
 
+#include <wtf/Assertions.h>
+
 namespace WebCore {
 
     const int undefinedLength = -1;
+    const int percentScaleFactor = 128;
 
     enum LengthType { Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic };
 
@@ -43,17 +46,61 @@ namespace WebCore {
         Length(int v, LengthType t, bool q = false)
             : m_value((v * 16) | (q << 3) | t) // FIXME: Doesn't work if the passed-in value is very large!
         {
+            ASSERT(t != Percent);
+        }
+
+        Length(double v, LengthType t, bool q = false)
+            : m_value(static_cast<int>(v * percentScaleFactor) * 16 | (q << 3) | t)
+        {
+            ASSERT(t == Percent);
         }
 
         bool operator==(const Length& o) const { return m_value == o.m_value; }
         bool operator!=(const Length& o) const { return m_value != o.m_value; }
 
-        int value() const { return (m_value & ~0xF) / 16; }
+        int value() const {
+            ASSERT(type() != Percent);
+            return rawValue();
+        }
+
+        int rawValue() const { return (m_value & ~0xF) / 16; }
+
+        double percent() const
+        {
+            ASSERT(type() == Percent);
+            return static_cast<double>(rawValue()) / percentScaleFactor;
+        }
+
         LengthType type() const { return static_cast<LengthType>(m_value & 7); }
         bool quirk() const { return (m_value >> 3) & 1; }
 
-        void setValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; }
-        void setValue(int value) { m_value = value * 16 | (m_value & 0xF); }
+        void setValue(LengthType t, int value)
+        {
+            ASSERT(t != Percent);
+            setRawValue(t, value);
+        }
+
+        void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; }
+
+        void setValue(int value)
+        {
+            ASSERT(!value || type() != Percent);
+            setRawValue(value);
+        }
+
+        void setRawValue(int value) { m_value = value * 16 | (m_value & 0xF); }
+
+        void setValue(LengthType t, double value)
+        {
+            ASSERT(t == Percent);
+            m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0x8) | t;
+        }
+
+        void setValue(double value)
+        {
+            ASSERT(type() == Percent);
+            m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF);
+        }
 
         // note: works only for certain types, returns undefinedLength otherwise
         int calcValue(int maxValue) const
@@ -62,7 +109,7 @@ namespace WebCore {
                 case Fixed:
                     return value();
                 case Percent:
-                    return maxValue * value() / 100;
+                    return maxValue * rawValue() / (100 * percentScaleFactor);
                 case Auto:
                     return maxValue;
                 default:
@@ -76,13 +123,18 @@ namespace WebCore {
                 case Fixed:
                     return value();
                 case Percent:
-                    return maxValue * value() / 100;
+                    return maxValue * rawValue() / (100 * percentScaleFactor);
                 case Auto:
                 default:
                     return 0;
             }
         }
 
+        bool isUndefined() const { return rawValue() == undefinedLength; }
+        bool isZero() const { return !(m_value & ~0xF); }
+        bool isPositive() const { return rawValue() > 0; }
+        bool isNegative() const { return rawValue() < 0; }
+
         bool isAuto() const { return type() == Auto; }
         bool isRelative() const { return type() == Relative; }
         bool isPercent() const { return type() == Percent; }
index b7648e7..88cf527 100644 (file)
@@ -64,7 +64,7 @@ short RenderBR::lineHeight(bool firstLine, bool isRootLineBox) const
     if (firstLine) {
         RenderStyle* s = style(firstLine);
         Length lh = s->lineHeight();
-        if (lh.value() < 0) {
+        if (lh.isNegative()) {
             if (s == style()) {
                 if (m_lineHeight == -1)
                     m_lineHeight = RenderObject::lineHeight(false);
index 5f7bfa7..9edacf3 100644 (file)
@@ -392,7 +392,7 @@ bool RenderBlock::isSelfCollapsingBlock() const
     // (e) have specified that one of our margins can't collapse using a CSS extension
     if (m_height > 0 ||
         isTable() || (borderBottom() + paddingBottom() + borderTop() + paddingTop()) != 0 ||
-        style()->minHeight().value() > 0 || 
+        style()->minHeight().isPositive() || 
         style()->marginTopCollapse() == MSEPARATE || style()->marginBottomCollapse() == MSEPARATE)
         return false;
 
@@ -407,7 +407,7 @@ bool RenderBlock::isSelfCollapsingBlock() const
 
     // If the height is 0 or auto, then whether or not we are a self-collapsing block depends
     // on whether we have content that is all self-collapsing or not.
-    if (hasAutoHeight || ((style()->height().isFixed() || style()->height().isPercent()) && style()->height().value() == 0)) {
+    if (hasAutoHeight || ((style()->height().isFixed() || style()->height().isPercent()) && style()->height().isZero())) {
         // If the block has inline children, see if we generated any line boxes.  If we have any
         // line boxes, then we can't be self-collapsing, since we have content.
         if (childrenInline())
index acc2528..e3ff645 100644 (file)
@@ -400,21 +400,21 @@ static void cacluateBackgroundSize(const BackgroundLayer* bgLayer, int& scaledWi
         Length bgHeight = bgLayer->backgroundSize().height;
         
         if (bgWidth.isPercent())
-            scaledWidth = scaledWidth * bgWidth.value() / 100;
+            scaledWidth = bgWidth.calcValue(scaledWidth);
         else if (bgWidth.isFixed())
             scaledWidth = bgWidth.value();
         else if (bgWidth.isAuto()) {
             // If the width is auto and the height is not, we have to use the appropriate
             // scale to maintain our aspect ratio.
             if (bgHeight.isPercent()) {
-                int scaledH = scaledHeight * bgHeight.value() / 100;
+                int scaledH = bgHeight.calcValue(scaledHeight);
                 scaledWidth = bg->imageSize().width() * scaledH / bg->imageSize().height();
             } else if (bgHeight.isFixed())
                 scaledWidth = bg->imageSize().width() * bgHeight.value() / bg->imageSize().height();
         }
             
         if (bgHeight.isPercent())
-            scaledHeight = scaledHeight * bgHeight.value() / 100;
+            scaledHeight = bgHeight.calcValue(scaledHeight);
         else if (bgHeight.isFixed())
             scaledHeight = bgHeight.value();
         else if (bgHeight.isAuto()) {
@@ -1046,7 +1046,7 @@ void RenderBox::calcWidth()
         m_width = calcWidthUsing(Width, containerWidth);
         
         // Calculate MaxWidth
-        if (style()->maxWidth().value() != undefinedLength) {
+        if (!style()->maxWidth().isUndefined()) {
             int maxW = calcWidthUsing(MaxWidth, containerWidth);
             if (m_width > maxW) {
                 m_width = maxW;
@@ -1227,7 +1227,7 @@ void RenderBox::calcHeight()
             if (height == -1)
                 height = m_height;
             int minH = calcHeightUsing(style()->minHeight()); // Leave as -1 if unset.
-            int maxH = style()->maxHeight().value() == undefinedLength ? height : calcHeightUsing(style()->maxHeight());
+            int maxH = style()->maxHeight().isUndefined() ? height : calcHeightUsing(style()->maxHeight());
             if (maxH == -1)
                 maxH = height;
             height = min(maxH, height);
@@ -1355,7 +1355,7 @@ int RenderBox::calcReplacedWidth() const
 {
     int width = calcReplacedWidthUsing(style()->width());
     int minW = calcReplacedWidthUsing(style()->minWidth());
-    int maxW = style()->maxWidth().value() == undefinedLength ? width : calcReplacedWidthUsing(style()->maxWidth());
+    int maxW = style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth());
 
     return max(minW, min(width, maxW));
 }
@@ -1380,7 +1380,7 @@ int RenderBox::calcReplacedHeight() const
 {
     int height = calcReplacedHeightUsing(style()->height());
     int minH = calcReplacedHeightUsing(style()->minHeight());
-    int maxH = style()->maxHeight().value() == undefinedLength ? height : calcReplacedHeightUsing(style()->maxHeight());
+    int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight());
 
     return max(minH, min(height, maxH));
 }
@@ -1596,7 +1596,7 @@ void RenderBox::calcAbsoluteHorizontal()
                                  m_width, m_marginLeft, m_marginRight, m_x);
 
     // Calculate constraint equation values for 'max-width' case.calcContentBoxWidth(width.calcValue(containerWidth));
-    if (style()->maxWidth().value() != undefinedLength) {
+    if (!style()->maxWidth().isUndefined()) {
         int maxWidth;
         int maxMarginLeft;
         int maxMarginRight;
@@ -1616,7 +1616,7 @@ void RenderBox::calcAbsoluteHorizontal()
     }
 
     // Calculate constraint equation values for 'min-width' case.
-    if (style()->minWidth().value()) {
+    if (!style()->minWidth().isZero()) {
         int minWidth;
         int minMarginLeft;
         int minMarginRight;
@@ -1877,7 +1877,7 @@ void RenderBox::calcAbsoluteVertical()
     // see FIXME 3
 
     // Calculate constraint equation values for 'max-height' case.
-    if (style()->maxHeight().value() != undefinedLength) {
+    if (!style()->maxHeight().isUndefined()) {
         int maxHeight;
         int maxMarginTop;
         int maxMarginBottom;
@@ -1896,7 +1896,7 @@ void RenderBox::calcAbsoluteVertical()
     }
 
     // Calculate constraint equation values for 'min-height' case.
-    if (style()->minHeight().value()) {
+    if (!style()->minHeight().isZero()) {
         int minHeight;
         int minMarginTop;
         int minMarginBottom;
index 00b6072..d7f1af5 100644 (file)
@@ -1078,7 +1078,7 @@ int RenderFlexibleBox::allowedChildFlex(RenderObject* child, bool expanding, uns
             // FIXME: For now just handle fixed values.
             int maxW = INT_MAX;
             int w = child->overrideWidth() - (child->borderLeft() + child->borderRight() + child->paddingLeft() + child->paddingRight());
-            if (child->style()->maxWidth().value() != undefinedLength &&
+            if (!child->style()->maxWidth().isUndefined() &&
                 child->style()->maxWidth().isFixed())
                 maxW = child->style()->maxWidth().value();
             else if (child->style()->maxWidth().type() == Intrinsic)
@@ -1092,7 +1092,7 @@ int RenderFlexibleBox::allowedChildFlex(RenderObject* child, bool expanding, uns
             // FIXME: For now just handle fixed values.
             int maxH = INT_MAX;
             int h = child->overrideHeight() - (child->borderTop() + child->borderBottom() + child->paddingTop() + child->paddingBottom());
-            if (child->style()->maxHeight().value() != undefinedLength &&
+            if (!child->style()->maxHeight().isUndefined() &&
                 child->style()->maxHeight().isFixed())
                 maxH = child->style()->maxHeight().value();
             if (maxH == INT_MAX)
index 698d160..f6df5ea 100644 (file)
@@ -281,7 +281,7 @@ short RenderFlow::lineHeight(bool firstLine, bool isRootLineBox) const
     if (firstLine) {
         RenderStyle* s = style(firstLine);
         Length lh = s->lineHeight();
-        if (lh.value() < 0) {
+        if (lh.isNegative()) {
             if (s == style()) {
                 if (m_lineHeight == -1)
                     m_lineHeight = RenderObject::lineHeight(false);
index 9075018..476b4ec 100644 (file)
@@ -379,7 +379,7 @@ int RenderImage::calcReplacedWidth() const
         width = calcAspectRatioWidth();
 
     int minW = calcReplacedWidthUsing(style()->minWidth());
-    int maxW = style()->maxWidth().value() == undefinedLength ? width : calcReplacedWidthUsing(style()->maxWidth());
+    int maxW = style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth());
 
     return max(minW, min(width, maxW));
 }
@@ -393,7 +393,7 @@ int RenderImage::calcReplacedHeight() const
         height = calcAspectRatioHeight();
 
     int minH = calcReplacedHeightUsing(style()->minHeight());
-    int maxH = style()->maxHeight().value() == undefinedLength ? height : calcReplacedHeightUsing(style()->maxHeight());
+    int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight());
 
     return max(minH, min(height, maxH));
 }
index 90e121d..2205db5 100644 (file)
@@ -2079,7 +2079,7 @@ EMarqueeDirection Marquee::direction() const
     // Now we have the real direction.  Next we check to see if the increment is negative.
     // If so, then we reverse the direction.
     Length increment = m_layer->renderer()->style()->marqueeIncrement();
-    if (increment.value() < 0)
+    if (increment.isNegative())
         result = static_cast<EMarqueeDirection>(-result);
     
     return result;
@@ -2144,7 +2144,7 @@ int Marquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge)
 
 void Marquee::start()
 {
-    if (m_timer.isActive() || m_layer->renderer()->style()->marqueeIncrement().value() == 0)
+    if (m_timer.isActive() || m_layer->renderer()->style()->marqueeIncrement().isZero())
         return;
     
     if (!m_suspended && !m_stopped) {
index 8947054..14f0145 100644 (file)
@@ -836,7 +836,7 @@ bool RenderObject::mustRepaintBackgroundOrBorder() const
 
     // These are always percents or auto.
     if (shouldPaintBackgroundImage &&
-            (bgLayer->backgroundXPosition().value() != 0 || bgLayer->backgroundYPosition().value() != 0 ||
+            (!bgLayer->backgroundXPosition().isZero() || !bgLayer->backgroundYPosition().isZero() ||
              bgLayer->backgroundSize().width.isPercent() || bgLayer->backgroundSize().height.isPercent()))
         // The background image will shift unpredictably if the size changes.
         return true;
@@ -2662,7 +2662,7 @@ short RenderObject::lineHeight(bool firstLine, bool /*isRootLineBox*/) const
     Length lh = s->lineHeight();
 
     // its "unset", choose nice default
-    if (lh.value() < 0)
+    if (lh.isNegative())
         return s->font().lineSpacing();
 
     if (lh.isPercent())
index 38e01f7..0dccbd7 100644 (file)
@@ -211,10 +211,13 @@ void RenderSlider::layout()
         if (m_thumb->renderer()->style()->hasAppearance())
             theme()->adjustSliderThumbSize(m_thumb->renderer());
 
-        if (style()->appearance() == SliderVerticalAppearance)
+        if (style()->appearance() == SliderVerticalAppearance) {
+            // FIXME: Handle percentage widths correctly. See http://bugs.webkit.org/show_bug.cgi?id=12104
             m_thumb->renderer()->style()->setLeft(Length(m_width / 2 - m_thumb->renderer()->style()->width().value() / 2, Fixed));
-        else
+        } else {
+            // FIXME: Handle percentage heights correctly. See http://bugs.webkit.org/show_bug.cgi?id=12104
             m_thumb->renderer()->style()->setTop(Length(m_height / 2 - m_thumb->renderer()->style()->height().value() / 2, Fixed));
+        }
 
         if (relayoutChildren)
             setPositionFromValue(true);
index dcffbb4..109400e 100644 (file)
@@ -107,7 +107,7 @@ struct LengthBox {
     }
 
 
-    bool nonZero() const { return left.value() || right.value() || top.value() || bottom.value(); }
+    bool nonZero() const { return !(left.isZero() && right.isZero() && top.isZero() && bottom.isZero()); }
 };
 
 enum EPosition {
@@ -1770,7 +1770,7 @@ public:
     static EVerticalAlign initialVerticalAlign() { return BASELINE; }
     static int initialWidows() { return 2; }
     static int initialOrphans() { return 2; }
-    static Length initialLineHeight() { return Length(-100, Percent); }
+    static Length initialLineHeight() { return Length(-100.0, Percent); }
     static ETextAlign initialTextAlign() { return TAAUTO; }
     static ETextDecoration initialTextDecoration() { return TDNONE; }
     static int initialOutlineOffset() { return 0; }
index 614c742..f238236 100644 (file)
@@ -209,7 +209,7 @@ void RenderTable::calcWidth()
     int availableWidth = cb->contentWidth();
 
     LengthType widthType = style()->width().type();
-    if (widthType > Relative && style()->width().value() > 0) {
+    if (widthType > Relative && style()->width().isPositive()) {
         // Percent or fixed table
         m_width = style()->width().calcMinValue(availableWidth);
         if (m_minWidth > m_width)
index 0037c77..6455a7b 100644 (file)
@@ -190,12 +190,12 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderObject* row)
     if (rSpan == 1) {
         // we ignore height settings on rowspan cells
         Length height = cell->style()->height();
-        if (height.value() > 0 || (height.isRelative() && height.value() >= 0)) {
+        if (height.isPositive() || (height.isRelative() && height.value() >= 0)) {
             Length cRowHeight = grid[cRow].height;
             switch (height.type()) {
                 case Percent:
                     if (!(cRowHeight.isPercent()) ||
-                        (cRowHeight.isPercent() && cRowHeight.value() < height.value()))
+                        (cRowHeight.isPercent() && cRowHeight.rawValue() < height.rawValue()))
                         grid[cRow].height = height;
                         break;
                 case Fixed:
@@ -397,23 +397,23 @@ int RenderTableSection::layoutRows(int toAdd)
             if (grid[r].height.isAuto())
                 numAuto++;
             else if (grid[r].height.isPercent())
-                totalPercent += grid[r].height.value();
+                totalPercent += grid[r].height.rawValue();
         }
         if (totalPercent) {
             // try to satisfy percent
             int add = 0;
-            if (totalPercent > 100)
-                totalPercent = 100;
+            if (totalPercent > 100 * percentScaleFactor)
+                totalPercent = 100 * percentScaleFactor;
             int rh = rowPos[1] - rowPos[0];
             for (int r = 0; r < totalRows; r++) {
                 if (totalPercent > 0 && grid[r].height.isPercent()) {
-                    int toAdd = min(dh, (totalHeight * grid[r].height.value() / 100) - rh);
+                    int toAdd = min(dh, (totalHeight * grid[r].height.rawValue() / (100 * percentScaleFactor)) - rh);
                     // If toAdd is negative, then we don't want to shrink the row (this bug
                     // affected Outlook Web Access).
                     toAdd = max(0, toAdd);
                     add += toAdd;
                     dh -= toAdd;
-                    totalPercent -= grid[r].height.value();
+                    totalPercent -= grid[r].height.rawValue();
                 }
                 if (r < totalRows - 1)
                     rh = rowPos[r + 2] - rowPos[r + 1];