2006-01-19 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2006 19:24:53 +0000 (19:24 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2006 19:24:53 +0000 (19:24 +0000)
        Reviewed by beth.

        Break classes in render_table out into separate files.
        Move render_block to RenderBlock.
        Move render_container to RenderContainer.

        * WebCore.xcodeproj/project.pbxproj:
        * bridge/mac/MacFrame.mm:
        * kcanvas/KCanvasContainer.h:
        * kcanvas/RenderForeignObject.h:
        * kcanvas/RenderSVGText.h:
        * khtml/editing/visible_units.cpp:
        * khtml/html/html_tableimpl.cpp:
        (WebCore::HTMLTableElementImpl::insertRow):
        * khtml/xml/dom2_rangeimpl.cpp:
        * khtml/xml/dom_position.cpp:
        * kwq/KWQRenderTreeDebug.cpp:
        * page/Frame.cpp:
        * rendering/InlineTextBox.cpp:
        * rendering/RenderBlock.cpp: Added.
        * rendering/RenderBlock.h: Added.
        * rendering/RenderContainer.cpp: Added.
        (WebCore::RenderContainer::addChild):
        * rendering/RenderContainer.h: Added.
        * rendering/RenderTable.cpp: Added.
        (WebCore::RenderTable::RenderTable):
        (WebCore::RenderTable::updateFirstLetter):
        * rendering/RenderTable.h: Added.
        * rendering/RenderTableCell.cpp: Added.
        (WebCore::RenderTableCell::RenderTableCell):
        (WebCore::RenderTableCell::updateFromElement):
        * rendering/RenderTableCell.h: Added.
        * rendering/RenderTableCol.cpp: Added.
        (WebCore::RenderTableCol::RenderTableCol):
        (WebCore::RenderTableCol::updateFromElement):
        * rendering/RenderTableCol.h: Added.
        * rendering/RenderTableRow.cpp: Added.
        (WebCore::RenderTableRow::RenderTableRow):
        * rendering/RenderTableRow.h: Added.
        * rendering/RenderTableSection.cpp: Added.
        (WebCore::RenderTableSection::RenderTableSection):
        * rendering/RenderTableSection.h: Added.
        * rendering/RenderText.cpp:
        * rendering/bidi.cpp:
        * rendering/render_block.cpp: Removed.
        * rendering/render_block.h: Removed.
        * rendering/render_box.cpp:
        * rendering/render_canvas.h:
        * rendering/render_container.cpp: Removed.
        * rendering/render_container.h: Removed.
        * rendering/render_flexbox.h:
        * rendering/render_flow.cpp:
        * rendering/render_flow.h:
        * rendering/render_form.h:
        * rendering/render_frames.h:
        * rendering/render_inline.cpp:
        * rendering/render_inline.h:
        * rendering/render_line.cpp:
        * rendering/render_list.h:
        * rendering/render_object.cpp:
        * rendering/render_replaced.h:
        * rendering/render_table.cpp: Removed.
        * rendering/render_table.h: Removed.
        * rendering/table_layout.cpp:

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

44 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/MacFrame.mm
WebCore/khtml/editing/visible_units.cpp
WebCore/khtml/html/html_tableimpl.cpp
WebCore/khtml/xml/DocumentImpl.cpp
WebCore/khtml/xml/DocumentImpl.h
WebCore/khtml/xml/dom2_rangeimpl.cpp
WebCore/khtml/xml/dom_position.cpp
WebCore/kwq/KWQRenderTreeDebug.cpp
WebCore/page/Frame.cpp
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/RenderBlock.cpp [moved from WebCore/rendering/render_block.cpp with 99% similarity]
WebCore/rendering/RenderBlock.h [moved from WebCore/rendering/render_block.h with 99% similarity]
WebCore/rendering/RenderContainer.cpp [moved from WebCore/rendering/render_container.cpp with 98% similarity]
WebCore/rendering/RenderContainer.h [moved from WebCore/rendering/render_container.h with 93% similarity]
WebCore/rendering/RenderTable.cpp [new file with mode: 0644]
WebCore/rendering/RenderTable.h [new file with mode: 0644]
WebCore/rendering/RenderTableCell.cpp [new file with mode: 0644]
WebCore/rendering/RenderTableCell.h [new file with mode: 0644]
WebCore/rendering/RenderTableCol.cpp [new file with mode: 0644]
WebCore/rendering/RenderTableCol.h [new file with mode: 0644]
WebCore/rendering/RenderTableRow.cpp [new file with mode: 0644]
WebCore/rendering/RenderTableRow.h [new file with mode: 0644]
WebCore/rendering/RenderTableSection.cpp [new file with mode: 0644]
WebCore/rendering/RenderTableSection.h [new file with mode: 0644]
WebCore/rendering/RenderText.cpp
WebCore/rendering/bidi.cpp
WebCore/rendering/render_box.cpp
WebCore/rendering/render_canvas.h
WebCore/rendering/render_flexbox.h
WebCore/rendering/render_flow.cpp
WebCore/rendering/render_flow.h
WebCore/rendering/render_form.h
WebCore/rendering/render_frames.h
WebCore/rendering/render_inline.cpp
WebCore/rendering/render_inline.h
WebCore/rendering/render_line.cpp
WebCore/rendering/render_list.h
WebCore/rendering/render_object.cpp
WebCore/rendering/render_replaced.h
WebCore/rendering/render_table.cpp [deleted file]
WebCore/rendering/render_table.h [deleted file]
WebCore/rendering/table_layout.cpp

index 104e9fe..6c83116 100644 (file)
 
 2006-01-19  Eric Seidel  <eseidel@apple.com>
 
+        Reviewed by beth.
+
+        Break classes in render_table out into separate files.
+        Move render_block to RenderBlock.
+        Move render_container to RenderContainer.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/mac/MacFrame.mm:
+        * kcanvas/KCanvasContainer.h:
+        * kcanvas/RenderForeignObject.h:
+        * kcanvas/RenderSVGText.h:
+        * khtml/editing/visible_units.cpp:
+        * khtml/html/html_tableimpl.cpp:
+        (WebCore::HTMLTableElementImpl::insertRow):
+        * khtml/xml/dom2_rangeimpl.cpp:
+        * khtml/xml/dom_position.cpp:
+        * kwq/KWQRenderTreeDebug.cpp:
+        * page/Frame.cpp:
+        * rendering/InlineTextBox.cpp:
+        * rendering/RenderBlock.cpp: Added.
+        * rendering/RenderBlock.h: Added.
+        * rendering/RenderContainer.cpp: Added.
+        (WebCore::RenderContainer::addChild):
+        * rendering/RenderContainer.h: Added.
+        * rendering/RenderTable.cpp: Added.
+        (WebCore::RenderTable::RenderTable):
+        (WebCore::RenderTable::updateFirstLetter):
+        * rendering/RenderTable.h: Added.
+        * rendering/RenderTableCell.cpp: Added.
+        (WebCore::RenderTableCell::RenderTableCell):
+        (WebCore::RenderTableCell::updateFromElement):
+        * rendering/RenderTableCell.h: Added.
+        * rendering/RenderTableCol.cpp: Added.
+        (WebCore::RenderTableCol::RenderTableCol):
+        (WebCore::RenderTableCol::updateFromElement):
+        * rendering/RenderTableCol.h: Added.
+        * rendering/RenderTableRow.cpp: Added.
+        (WebCore::RenderTableRow::RenderTableRow):
+        * rendering/RenderTableRow.h: Added.
+        * rendering/RenderTableSection.cpp: Added.
+        (WebCore::RenderTableSection::RenderTableSection):
+        * rendering/RenderTableSection.h: Added.
+        * rendering/RenderText.cpp:
+        * rendering/bidi.cpp:
+        * rendering/render_block.cpp: Removed.
+        * rendering/render_block.h: Removed.
+        * rendering/render_box.cpp:
+        * rendering/render_canvas.h:
+        * rendering/render_container.cpp: Removed.
+        * rendering/render_container.h: Removed.
+        * rendering/render_flexbox.h:
+        * rendering/render_flow.cpp:
+        * rendering/render_flow.h:
+        * rendering/render_form.h:
+        * rendering/render_frames.h:
+        * rendering/render_inline.cpp:
+        * rendering/render_inline.h:
+        * rendering/render_line.cpp:
+        * rendering/render_list.h:
+        * rendering/render_object.cpp:
+        * rendering/render_replaced.h:
+        * rendering/render_table.cpp: Removed.
+        * rendering/render_table.h: Removed.
+        * rendering/table_layout.cpp:
+
+2006-01-19  Eric Seidel  <eseidel@apple.com>
+
         Reviewed by darin.
 
         <embed> and <object> tags show up blank when going back/forward.
index 9906adf..aaf20f1 100644 (file)
                A8DF3FDB097FA0FC0052981B /* HTMLBaseFontElementImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF3FCB097FA0FB0052981B /* HTMLBaseFontElementImpl.cpp */; };
                A8DF3FDC097FA0FC0052981B /* HTMLNameCollectionImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF3FCC097FA0FB0052981B /* HTMLNameCollectionImpl.h */; };
                A8DF3FDD097FA0FC0052981B /* HTMLNameCollectionImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF3FCD097FA0FB0052981B /* HTMLNameCollectionImpl.cpp */; };
+               A8DF4AE80980C42C0052981B /* RenderTableCol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4ADE0980C42C0052981B /* RenderTableCol.cpp */; };
+               A8DF4AE90980C42C0052981B /* RenderTableCell.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4ADF0980C42C0052981B /* RenderTableCell.h */; };
+               A8DF4AEA0980C42C0052981B /* RenderTableCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */; };
+               A8DF4AEB0980C42C0052981B /* RenderTable.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE10980C42C0052981B /* RenderTable.h */; };
+               A8DF4AEC0980C42C0052981B /* RenderTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE20980C42C0052981B /* RenderTable.cpp */; };
+               A8DF4AED0980C42C0052981B /* RenderTableSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE30980C42C0052981B /* RenderTableSection.cpp */; };
+               A8DF4AEE0980C42C0052981B /* RenderTableRow.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE40980C42C0052981B /* RenderTableRow.h */; };
+               A8DF4AEF0980C42C0052981B /* RenderTableSection.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE50980C42C0052981B /* RenderTableSection.h */; };
+               A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */; };
+               A8DF4AF10980C42C0052981B /* RenderTableCol.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE70980C42C0052981B /* RenderTableCol.h */; };
+               A8DF4AF20980C42C0052981B /* RenderTableCol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4ADE0980C42C0052981B /* RenderTableCol.cpp */; };
+               A8DF4AF30980C42C0052981B /* RenderTableCell.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4ADF0980C42C0052981B /* RenderTableCell.h */; };
+               A8DF4AF40980C42C0052981B /* RenderTableCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */; };
+               A8DF4AF50980C42C0052981B /* RenderTable.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE10980C42C0052981B /* RenderTable.h */; };
+               A8DF4AF60980C42C0052981B /* RenderTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE20980C42C0052981B /* RenderTable.cpp */; };
+               A8DF4AF70980C42C0052981B /* RenderTableSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE30980C42C0052981B /* RenderTableSection.cpp */; };
+               A8DF4AF80980C42C0052981B /* RenderTableRow.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE40980C42C0052981B /* RenderTableRow.h */; };
+               A8DF4AF90980C42C0052981B /* RenderTableSection.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE50980C42C0052981B /* RenderTableSection.h */; };
+               A8DF4AFA0980C42C0052981B /* RenderTableRow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */; };
+               A8DF4AFB0980C42C0052981B /* RenderTableCol.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE70980C42C0052981B /* RenderTableCol.h */; };
                A8FD8B86087CB44C00DC3707 /* KWQWMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A85D7A8C0879EC64006A9172 /* KWQWMatrix.cpp */; };
                A8FD8B87087CB45700DC3707 /* KWQWMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = A85D7A8D0879EC64006A9172 /* KWQWMatrix.h */; };
                A8FEFB0A0979F472005839FD /* RenderForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB080979F472005839FD /* RenderForeignObject.h */; };
                BCEA485C097D93020094C9E4 /* render_applet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA481D097D93020094C9E4 /* render_applet.h */; };
                BCEA485D097D93020094C9E4 /* render_arena.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA481E097D93020094C9E4 /* render_arena.cpp */; };
                BCEA485E097D93020094C9E4 /* render_arena.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA481F097D93020094C9E4 /* render_arena.h */; };
-               BCEA485F097D93020094C9E4 /* render_block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4820097D93020094C9E4 /* render_block.cpp */; };
-               BCEA4860097D93020094C9E4 /* render_block.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4821097D93020094C9E4 /* render_block.h */; };
+               BCEA485F097D93020094C9E4 /* RenderBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4820097D93020094C9E4 /* RenderBlock.cpp */; };
+               BCEA4860097D93020094C9E4 /* RenderBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4821097D93020094C9E4 /* RenderBlock.h */; };
                BCEA4861097D93020094C9E4 /* render_box.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4822097D93020094C9E4 /* render_box.cpp */; };
                BCEA4862097D93020094C9E4 /* render_box.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4823097D93020094C9E4 /* render_box.h */; };
                BCEA4863097D93020094C9E4 /* render_br.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4824097D93020094C9E4 /* render_br.cpp */; };
                BCEA4868097D93020094C9E4 /* render_canvas.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4829097D93020094C9E4 /* render_canvas.h */; };
                BCEA4869097D93020094C9E4 /* render_canvasimage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482A097D93020094C9E4 /* render_canvasimage.cpp */; };
                BCEA486A097D93020094C9E4 /* render_canvasimage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482B097D93020094C9E4 /* render_canvasimage.h */; };
-               BCEA486B097D93020094C9E4 /* render_container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482C097D93020094C9E4 /* render_container.cpp */; };
-               BCEA486C097D93020094C9E4 /* render_container.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482D097D93020094C9E4 /* render_container.h */; };
+               BCEA486B097D93020094C9E4 /* RenderContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482C097D93020094C9E4 /* RenderContainer.cpp */; };
+               BCEA486C097D93020094C9E4 /* RenderContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482D097D93020094C9E4 /* RenderContainer.h */; };
                BCEA486D097D93020094C9E4 /* render_flexbox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482E097D93020094C9E4 /* render_flexbox.cpp */; };
                BCEA486E097D93020094C9E4 /* render_flexbox.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482F097D93020094C9E4 /* render_flexbox.h */; };
                BCEA486F097D93020094C9E4 /* render_flow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4830097D93020094C9E4 /* render_flow.cpp */; };
                BCEA4882097D93020094C9E4 /* render_replaced.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4843097D93020094C9E4 /* render_replaced.h */; };
                BCEA4883097D93020094C9E4 /* render_style.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4844097D93020094C9E4 /* render_style.cpp */; };
                BCEA4884097D93020094C9E4 /* render_style.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4845097D93020094C9E4 /* render_style.h */; };
-               BCEA4885097D93020094C9E4 /* render_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4846097D93020094C9E4 /* render_table.cpp */; };
-               BCEA4886097D93020094C9E4 /* render_table.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4847097D93020094C9E4 /* render_table.h */; };
                BCEA4887097D93020094C9E4 /* render_theme_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4848097D93020094C9E4 /* render_theme_mac.h */; };
                BCEA4888097D93020094C9E4 /* render_theme_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4849097D93020094C9E4 /* render_theme_mac.mm */; };
                BCEA4889097D93020094C9E4 /* render_theme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA484A097D93020094C9E4 /* render_theme.cpp */; };
                BCEA489B097D93020094C9E4 /* render_applet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA481D097D93020094C9E4 /* render_applet.h */; };
                BCEA489C097D93020094C9E4 /* render_arena.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA481E097D93020094C9E4 /* render_arena.cpp */; };
                BCEA489D097D93020094C9E4 /* render_arena.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA481F097D93020094C9E4 /* render_arena.h */; };
-               BCEA489E097D93020094C9E4 /* render_block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4820097D93020094C9E4 /* render_block.cpp */; };
-               BCEA489F097D93020094C9E4 /* render_block.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4821097D93020094C9E4 /* render_block.h */; };
+               BCEA489E097D93020094C9E4 /* RenderBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4820097D93020094C9E4 /* RenderBlock.cpp */; };
+               BCEA489F097D93020094C9E4 /* RenderBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4821097D93020094C9E4 /* RenderBlock.h */; };
                BCEA48A0097D93020094C9E4 /* render_box.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4822097D93020094C9E4 /* render_box.cpp */; };
                BCEA48A1097D93020094C9E4 /* render_box.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4823097D93020094C9E4 /* render_box.h */; };
                BCEA48A2097D93020094C9E4 /* render_br.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4824097D93020094C9E4 /* render_br.cpp */; };
                BCEA48A7097D93020094C9E4 /* render_canvas.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4829097D93020094C9E4 /* render_canvas.h */; };
                BCEA48A8097D93020094C9E4 /* render_canvasimage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482A097D93020094C9E4 /* render_canvasimage.cpp */; };
                BCEA48A9097D93020094C9E4 /* render_canvasimage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482B097D93020094C9E4 /* render_canvasimage.h */; };
-               BCEA48AA097D93020094C9E4 /* render_container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482C097D93020094C9E4 /* render_container.cpp */; };
-               BCEA48AB097D93020094C9E4 /* render_container.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482D097D93020094C9E4 /* render_container.h */; };
+               BCEA48AA097D93020094C9E4 /* RenderContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482C097D93020094C9E4 /* RenderContainer.cpp */; };
+               BCEA48AB097D93020094C9E4 /* RenderContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482D097D93020094C9E4 /* RenderContainer.h */; };
                BCEA48AC097D93020094C9E4 /* render_flexbox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA482E097D93020094C9E4 /* render_flexbox.cpp */; };
                BCEA48AD097D93020094C9E4 /* render_flexbox.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482F097D93020094C9E4 /* render_flexbox.h */; };
                BCEA48AE097D93020094C9E4 /* render_flow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4830097D93020094C9E4 /* render_flow.cpp */; };
                BCEA48C1097D93020094C9E4 /* render_replaced.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4843097D93020094C9E4 /* render_replaced.h */; };
                BCEA48C2097D93020094C9E4 /* render_style.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4844097D93020094C9E4 /* render_style.cpp */; };
                BCEA48C3097D93020094C9E4 /* render_style.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4845097D93020094C9E4 /* render_style.h */; };
-               BCEA48C4097D93020094C9E4 /* render_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4846097D93020094C9E4 /* render_table.cpp */; };
-               BCEA48C5097D93020094C9E4 /* render_table.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4847097D93020094C9E4 /* render_table.h */; };
                BCEA48C6097D93020094C9E4 /* render_theme_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4848097D93020094C9E4 /* render_theme_mac.h */; };
                BCEA48C7097D93020094C9E4 /* render_theme_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4849097D93020094C9E4 /* render_theme_mac.mm */; };
                BCEA48C8097D93020094C9E4 /* render_theme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA484A097D93020094C9E4 /* render_theme.cpp */; };
                A8DF3FCB097FA0FB0052981B /* HTMLBaseFontElementImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLBaseFontElementImpl.cpp; sourceTree = "<group>"; };
                A8DF3FCC097FA0FB0052981B /* HTMLNameCollectionImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLNameCollectionImpl.h; sourceTree = "<group>"; };
                A8DF3FCD097FA0FB0052981B /* HTMLNameCollectionImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLNameCollectionImpl.cpp; sourceTree = "<group>"; };
+               A8DF4ADE0980C42C0052981B /* RenderTableCol.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableCol.cpp; sourceTree = "<group>"; };
+               A8DF4ADF0980C42C0052981B /* RenderTableCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableCell.h; sourceTree = "<group>"; };
+               A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableCell.cpp; sourceTree = "<group>"; };
+               A8DF4AE10980C42C0052981B /* RenderTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTable.h; sourceTree = "<group>"; };
+               A8DF4AE20980C42C0052981B /* RenderTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTable.cpp; sourceTree = "<group>"; };
+               A8DF4AE30980C42C0052981B /* RenderTableSection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableSection.cpp; sourceTree = "<group>"; };
+               A8DF4AE40980C42C0052981B /* RenderTableRow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableRow.h; sourceTree = "<group>"; };
+               A8DF4AE50980C42C0052981B /* RenderTableSection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableSection.h; sourceTree = "<group>"; };
+               A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableRow.cpp; sourceTree = "<group>"; };
+               A8DF4AE70980C42C0052981B /* RenderTableCol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableCol.h; sourceTree = "<group>"; };
                A8FEFB080979F472005839FD /* RenderForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderForeignObject.h; sourceTree = "<group>"; };
                A8FEFB090979F472005839FD /* RenderForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderForeignObject.cpp; sourceTree = "<group>"; };
                A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElementImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGForeignObjectElementImpl.cpp; sourceTree = "<group>"; };
                BCEA481D097D93020094C9E4 /* render_applet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_applet.h; path = rendering/render_applet.h; sourceTree = SOURCE_ROOT; };
                BCEA481E097D93020094C9E4 /* render_arena.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_arena.cpp; path = rendering/render_arena.cpp; sourceTree = SOURCE_ROOT; };
                BCEA481F097D93020094C9E4 /* render_arena.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_arena.h; path = rendering/render_arena.h; sourceTree = SOURCE_ROOT; };
-               BCEA4820097D93020094C9E4 /* render_block.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_block.cpp; path = rendering/render_block.cpp; sourceTree = SOURCE_ROOT; };
-               BCEA4821097D93020094C9E4 /* render_block.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_block.h; path = rendering/render_block.h; sourceTree = SOURCE_ROOT; };
+               BCEA4820097D93020094C9E4 /* RenderBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBlock.cpp; sourceTree = "<group>"; };
+               BCEA4821097D93020094C9E4 /* RenderBlock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderBlock.h; sourceTree = "<group>"; };
                BCEA4822097D93020094C9E4 /* render_box.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_box.cpp; path = rendering/render_box.cpp; sourceTree = SOURCE_ROOT; };
                BCEA4823097D93020094C9E4 /* render_box.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_box.h; path = rendering/render_box.h; sourceTree = SOURCE_ROOT; };
                BCEA4824097D93020094C9E4 /* render_br.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_br.cpp; path = rendering/render_br.cpp; sourceTree = SOURCE_ROOT; };
                BCEA4829097D93020094C9E4 /* render_canvas.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_canvas.h; path = rendering/render_canvas.h; sourceTree = SOURCE_ROOT; };
                BCEA482A097D93020094C9E4 /* render_canvasimage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_canvasimage.cpp; path = rendering/render_canvasimage.cpp; sourceTree = SOURCE_ROOT; };
                BCEA482B097D93020094C9E4 /* render_canvasimage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_canvasimage.h; path = rendering/render_canvasimage.h; sourceTree = SOURCE_ROOT; };
-               BCEA482C097D93020094C9E4 /* render_container.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_container.cpp; path = rendering/render_container.cpp; sourceTree = SOURCE_ROOT; };
-               BCEA482D097D93020094C9E4 /* render_container.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_container.h; path = rendering/render_container.h; sourceTree = SOURCE_ROOT; };
+               BCEA482C097D93020094C9E4 /* RenderContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContainer.cpp; sourceTree = "<group>"; };
+               BCEA482D097D93020094C9E4 /* RenderContainer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderContainer.h; sourceTree = "<group>"; };
                BCEA482E097D93020094C9E4 /* render_flexbox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_flexbox.cpp; path = rendering/render_flexbox.cpp; sourceTree = SOURCE_ROOT; };
                BCEA482F097D93020094C9E4 /* render_flexbox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_flexbox.h; path = rendering/render_flexbox.h; sourceTree = SOURCE_ROOT; };
                BCEA4830097D93020094C9E4 /* render_flow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_flow.cpp; path = rendering/render_flow.cpp; sourceTree = SOURCE_ROOT; };
                BCEA4843097D93020094C9E4 /* render_replaced.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_replaced.h; path = rendering/render_replaced.h; sourceTree = SOURCE_ROOT; };
                BCEA4844097D93020094C9E4 /* render_style.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_style.cpp; path = rendering/render_style.cpp; sourceTree = SOURCE_ROOT; };
                BCEA4845097D93020094C9E4 /* render_style.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_style.h; path = rendering/render_style.h; sourceTree = SOURCE_ROOT; };
-               BCEA4846097D93020094C9E4 /* render_table.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_table.cpp; path = rendering/render_table.cpp; sourceTree = SOURCE_ROOT; };
-               BCEA4847097D93020094C9E4 /* render_table.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_table.h; path = rendering/render_table.h; sourceTree = SOURCE_ROOT; };
                BCEA4848097D93020094C9E4 /* render_theme_mac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = render_theme_mac.h; path = rendering/render_theme_mac.h; sourceTree = SOURCE_ROOT; };
                BCEA4849097D93020094C9E4 /* render_theme_mac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = render_theme_mac.mm; path = rendering/render_theme_mac.mm; sourceTree = SOURCE_ROOT; };
                BCEA484A097D93020094C9E4 /* render_theme.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = render_theme.cpp; path = rendering/render_theme.cpp; sourceTree = SOURCE_ROOT; };
                                BCEA481D097D93020094C9E4 /* render_applet.h */,
                                BCEA481E097D93020094C9E4 /* render_arena.cpp */,
                                BCEA481F097D93020094C9E4 /* render_arena.h */,
-                               BCEA4820097D93020094C9E4 /* render_block.cpp */,
-                               BCEA4821097D93020094C9E4 /* render_block.h */,
+                               BCEA4820097D93020094C9E4 /* RenderBlock.cpp */,
+                               BCEA4821097D93020094C9E4 /* RenderBlock.h */,
                                BCEA4822097D93020094C9E4 /* render_box.cpp */,
                                BCEA4823097D93020094C9E4 /* render_box.h */,
                                BCEA4824097D93020094C9E4 /* render_br.cpp */,
                                BCEA4829097D93020094C9E4 /* render_canvas.h */,
                                BCEA482A097D93020094C9E4 /* render_canvasimage.cpp */,
                                BCEA482B097D93020094C9E4 /* render_canvasimage.h */,
-                               BCEA482C097D93020094C9E4 /* render_container.cpp */,
-                               BCEA482D097D93020094C9E4 /* render_container.h */,
+                               BCEA482C097D93020094C9E4 /* RenderContainer.cpp */,
+                               BCEA482D097D93020094C9E4 /* RenderContainer.h */,
                                BCEA482E097D93020094C9E4 /* render_flexbox.cpp */,
                                BCEA482F097D93020094C9E4 /* render_flexbox.h */,
                                BCEA4830097D93020094C9E4 /* render_flow.cpp */,
                                BCEA4843097D93020094C9E4 /* render_replaced.h */,
                                BCEA4844097D93020094C9E4 /* render_style.cpp */,
                                BCEA4845097D93020094C9E4 /* render_style.h */,
-                               BCEA4846097D93020094C9E4 /* render_table.cpp */,
-                               BCEA4847097D93020094C9E4 /* render_table.h */,
                                BCEA4848097D93020094C9E4 /* render_theme_mac.h */,
                                BCEA4849097D93020094C9E4 /* render_theme_mac.mm */,
                                BCEA484A097D93020094C9E4 /* render_theme.cpp */,
                                BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
                                BCEA4850097D93020094C9E4 /* table_layout.cpp */,
                                BCEA4851097D93020094C9E4 /* table_layout.h */,
+                               A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */,
+                               A8DF4ADF0980C42C0052981B /* RenderTableCell.h */,
+                               A8DF4AE20980C42C0052981B /* RenderTable.cpp */,
+                               A8DF4AE10980C42C0052981B /* RenderTable.h */,
+                               A8DF4AE30980C42C0052981B /* RenderTableSection.cpp */,
+                               A8DF4AE50980C42C0052981B /* RenderTableSection.h */,
+                               A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */,
+                               A8DF4AE40980C42C0052981B /* RenderTableRow.h */,
+                               A8DF4ADE0980C42C0052981B /* RenderTableCol.cpp */,
+                               A8DF4AE70980C42C0052981B /* RenderTableCol.h */,
                        );
                        path = rendering;
                        sourceTree = "<group>";
                                BCEA485A097D93020094C9E4 /* InlineTextBox.h in Headers */,
                                BCEA485C097D93020094C9E4 /* render_applet.h in Headers */,
                                BCEA485E097D93020094C9E4 /* render_arena.h in Headers */,
-                               BCEA4860097D93020094C9E4 /* render_block.h in Headers */,
+                               BCEA4860097D93020094C9E4 /* RenderBlock.h in Headers */,
                                BCEA4862097D93020094C9E4 /* render_box.h in Headers */,
                                BCEA4864097D93020094C9E4 /* render_br.h in Headers */,
                                BCEA4866097D93020094C9E4 /* render_button.h in Headers */,
                                BCEA4868097D93020094C9E4 /* render_canvas.h in Headers */,
                                BCEA486A097D93020094C9E4 /* render_canvasimage.h in Headers */,
-                               BCEA486C097D93020094C9E4 /* render_container.h in Headers */,
+                               BCEA486C097D93020094C9E4 /* RenderContainer.h in Headers */,
                                BCEA486E097D93020094C9E4 /* render_flexbox.h in Headers */,
                                BCEA4870097D93020094C9E4 /* render_flow.h in Headers */,
                                BCEA4872097D93020094C9E4 /* render_form.h in Headers */,
                                BCEA4880097D93020094C9E4 /* render_object.h in Headers */,
                                BCEA4882097D93020094C9E4 /* render_replaced.h in Headers */,
                                BCEA4884097D93020094C9E4 /* render_style.h in Headers */,
-                               BCEA4886097D93020094C9E4 /* render_table.h in Headers */,
                                BCEA4887097D93020094C9E4 /* render_theme_mac.h in Headers */,
                                BCEA488A097D93020094C9E4 /* render_theme.h in Headers */,
                                BCEA488C097D93020094C9E4 /* RenderText.h in Headers */,
                                A8DF3FD0097FA0FC0052981B /* HTMLCollectionImpl.h in Headers */,
                                A8DF3FD2097FA0FC0052981B /* HTMLBaseFontElementImpl.h in Headers */,
                                A8DF3FD4097FA0FC0052981B /* HTMLNameCollectionImpl.h in Headers */,
+                               A8DF4AE90980C42C0052981B /* RenderTableCell.h in Headers */,
+                               A8DF4AEB0980C42C0052981B /* RenderTable.h in Headers */,
+                               A8DF4AEE0980C42C0052981B /* RenderTableRow.h in Headers */,
+                               A8DF4AEF0980C42C0052981B /* RenderTableSection.h in Headers */,
+                               A8DF4AF10980C42C0052981B /* RenderTableCol.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA4899097D93020094C9E4 /* InlineTextBox.h in Headers */,
                                BCEA489B097D93020094C9E4 /* render_applet.h in Headers */,
                                BCEA489D097D93020094C9E4 /* render_arena.h in Headers */,
-                               BCEA489F097D93020094C9E4 /* render_block.h in Headers */,
+                               BCEA489F097D93020094C9E4 /* RenderBlock.h in Headers */,
                                BCEA48A1097D93020094C9E4 /* render_box.h in Headers */,
                                BCEA48A3097D93020094C9E4 /* render_br.h in Headers */,
                                BCEA48A5097D93020094C9E4 /* render_button.h in Headers */,
                                BCEA48A7097D93020094C9E4 /* render_canvas.h in Headers */,
                                BCEA48A9097D93020094C9E4 /* render_canvasimage.h in Headers */,
-                               BCEA48AB097D93020094C9E4 /* render_container.h in Headers */,
+                               BCEA48AB097D93020094C9E4 /* RenderContainer.h in Headers */,
                                BCEA48AD097D93020094C9E4 /* render_flexbox.h in Headers */,
                                BCEA48AF097D93020094C9E4 /* render_flow.h in Headers */,
                                BCEA48B1097D93020094C9E4 /* render_form.h in Headers */,
                                BCEA48BF097D93020094C9E4 /* render_object.h in Headers */,
                                BCEA48C1097D93020094C9E4 /* render_replaced.h in Headers */,
                                BCEA48C3097D93020094C9E4 /* render_style.h in Headers */,
-                               BCEA48C5097D93020094C9E4 /* render_table.h in Headers */,
                                BCEA48C6097D93020094C9E4 /* render_theme_mac.h in Headers */,
                                BCEA48C9097D93020094C9E4 /* render_theme.h in Headers */,
                                BCEA48CB097D93020094C9E4 /* RenderText.h in Headers */,
                                A8DF3FD8097FA0FC0052981B /* HTMLCollectionImpl.h in Headers */,
                                A8DF3FDA097FA0FC0052981B /* HTMLBaseFontElementImpl.h in Headers */,
                                A8DF3FDC097FA0FC0052981B /* HTMLNameCollectionImpl.h in Headers */,
+                               A8DF4AF30980C42C0052981B /* RenderTableCell.h in Headers */,
+                               A8DF4AF50980C42C0052981B /* RenderTable.h in Headers */,
+                               A8DF4AF80980C42C0052981B /* RenderTableRow.h in Headers */,
+                               A8DF4AF90980C42C0052981B /* RenderTableSection.h in Headers */,
+                               A8DF4AFB0980C42C0052981B /* RenderTableCol.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA4859097D93020094C9E4 /* InlineTextBox.cpp in Sources */,
                                BCEA485B097D93020094C9E4 /* render_applet.cpp in Sources */,
                                BCEA485D097D93020094C9E4 /* render_arena.cpp in Sources */,
-                               BCEA485F097D93020094C9E4 /* render_block.cpp in Sources */,
+                               BCEA485F097D93020094C9E4 /* RenderBlock.cpp in Sources */,
                                BCEA4861097D93020094C9E4 /* render_box.cpp in Sources */,
                                BCEA4863097D93020094C9E4 /* render_br.cpp in Sources */,
                                BCEA4865097D93020094C9E4 /* render_button.cpp in Sources */,
                                BCEA4867097D93020094C9E4 /* render_canvas.cpp in Sources */,
                                BCEA4869097D93020094C9E4 /* render_canvasimage.cpp in Sources */,
-                               BCEA486B097D93020094C9E4 /* render_container.cpp in Sources */,
+                               BCEA486B097D93020094C9E4 /* RenderContainer.cpp in Sources */,
                                BCEA486D097D93020094C9E4 /* render_flexbox.cpp in Sources */,
                                BCEA486F097D93020094C9E4 /* render_flow.cpp in Sources */,
                                BCEA4871097D93020094C9E4 /* render_form.cpp in Sources */,
                                BCEA487F097D93020094C9E4 /* render_object.cpp in Sources */,
                                BCEA4881097D93020094C9E4 /* render_replaced.cpp in Sources */,
                                BCEA4883097D93020094C9E4 /* render_style.cpp in Sources */,
-                               BCEA4885097D93020094C9E4 /* render_table.cpp in Sources */,
                                BCEA4888097D93020094C9E4 /* render_theme_mac.mm in Sources */,
                                BCEA4889097D93020094C9E4 /* render_theme.cpp in Sources */,
                                BCEA488B097D93020094C9E4 /* RenderText.cpp in Sources */,
                                A8DF3FD1097FA0FC0052981B /* HTMLCollectionImpl.cpp in Sources */,
                                A8DF3FD3097FA0FC0052981B /* HTMLBaseFontElementImpl.cpp in Sources */,
                                A8DF3FD5097FA0FC0052981B /* HTMLNameCollectionImpl.cpp in Sources */,
+                               A8DF4AE80980C42C0052981B /* RenderTableCol.cpp in Sources */,
+                               A8DF4AEA0980C42C0052981B /* RenderTableCell.cpp in Sources */,
+                               A8DF4AEC0980C42C0052981B /* RenderTable.cpp in Sources */,
+                               A8DF4AED0980C42C0052981B /* RenderTableSection.cpp in Sources */,
+                               A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA4898097D93020094C9E4 /* InlineTextBox.cpp in Sources */,
                                BCEA489A097D93020094C9E4 /* render_applet.cpp in Sources */,
                                BCEA489C097D93020094C9E4 /* render_arena.cpp in Sources */,
-                               BCEA489E097D93020094C9E4 /* render_block.cpp in Sources */,
+                               BCEA489E097D93020094C9E4 /* RenderBlock.cpp in Sources */,
                                BCEA48A0097D93020094C9E4 /* render_box.cpp in Sources */,
                                BCEA48A2097D93020094C9E4 /* render_br.cpp in Sources */,
                                BCEA48A4097D93020094C9E4 /* render_button.cpp in Sources */,
                                BCEA48A6097D93020094C9E4 /* render_canvas.cpp in Sources */,
                                BCEA48A8097D93020094C9E4 /* render_canvasimage.cpp in Sources */,
-                               BCEA48AA097D93020094C9E4 /* render_container.cpp in Sources */,
+                               BCEA48AA097D93020094C9E4 /* RenderContainer.cpp in Sources */,
                                BCEA48AC097D93020094C9E4 /* render_flexbox.cpp in Sources */,
                                BCEA48AE097D93020094C9E4 /* render_flow.cpp in Sources */,
                                BCEA48B0097D93020094C9E4 /* render_form.cpp in Sources */,
                                BCEA48BE097D93020094C9E4 /* render_object.cpp in Sources */,
                                BCEA48C0097D93020094C9E4 /* render_replaced.cpp in Sources */,
                                BCEA48C2097D93020094C9E4 /* render_style.cpp in Sources */,
-                               BCEA48C4097D93020094C9E4 /* render_table.cpp in Sources */,
                                BCEA48C7097D93020094C9E4 /* render_theme_mac.mm in Sources */,
                                BCEA48C8097D93020094C9E4 /* render_theme.cpp in Sources */,
                                BCEA48CA097D93020094C9E4 /* RenderText.cpp in Sources */,
                                A8DF3FD9097FA0FC0052981B /* HTMLCollectionImpl.cpp in Sources */,
                                A8DF3FDB097FA0FC0052981B /* HTMLBaseFontElementImpl.cpp in Sources */,
                                A8DF3FDD097FA0FC0052981B /* HTMLNameCollectionImpl.cpp in Sources */,
+                               A8DF4AF20980C42C0052981B /* RenderTableCol.cpp in Sources */,
+                               A8DF4AF40980C42C0052981B /* RenderTableCell.cpp in Sources */,
+                               A8DF4AF60980C42C0052981B /* RenderTable.cpp in Sources */,
+                               A8DF4AF70980C42C0052981B /* RenderTableSection.cpp in Sources */,
+                               A8DF4AFA0980C42C0052981B /* RenderTableRow.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index f212251..6ba2f36 100644 (file)
 #import "render_image.h"
 #import "render_list.h"
 #import "render_style.h"
-#import "render_table.h"
 #import "render_theme.h"
+#import "RenderTableCell.h"
 #import "visible_position.h"
 #import "visible_text.h"
 #import "visible_units.h"
+
 #import <JavaScriptCore/NP_jsobject.h>
 #import <JavaScriptCore/WebScriptObjectPrivate.h>
 #import <JavaScriptCore/identifier.h>
index e5e83b0..9e6265a 100644 (file)
@@ -31,7 +31,7 @@
 #include "htmlnames.h"
 #include "helper.h"
 #include "InlineTextBox.h"
-#include "rendering/render_block.h"
+#include "RenderBlock.h"
 #include "visible_position.h"
 #include "visible_text.h"
 #include "DocumentImpl.h"
index 7ab8f13..743fe58 100644 (file)
@@ -37,7 +37,9 @@
 #include "dom_exception.h"
 #include "dom_node.h"
 #include "html_documentimpl.h"
-#include "render_table.h"
+#include "RenderTable.h"
+#include "RenderTableCell.h"
+#include "RenderTableCol.h"
 
 namespace WebCore {
 
@@ -222,7 +224,6 @@ HTMLElementImpl *HTMLTableElementImpl::insertRow( int index, int &exceptioncode
     if(!firstBody && !head && !foot)
         setTBody( new HTMLTableSectionElementImpl(tbodyTag, getDocument(), true /* implicit */) );
 
-    //kdDebug(6030) << k_funcinfo << index << endl;
     // IE treats index=-1 as default value meaning 'append after last'
     // This isn't in the DOM. So, not implemented yet.
     HTMLTableSectionElementImpl* section = 0L;
@@ -238,16 +239,13 @@ HTMLElementImpl *HTMLTableElementImpl::insertRow( int index, int &exceptioncode
         {
             section = static_cast<HTMLTableSectionElementImpl *>(node);
             lastSection = section;
-            //kdDebug(6030) << k_funcinfo << "section id=" << node->id() << " rows:" << section->numRows() << endl;
-            if ( !append )
-            {
+            if (!append) {
                 int rows = section->numRows();
                 if (rows >= index) {
                     found = true;
                     break;
                 } else
                     index -= rows;
-                //kdDebug(6030) << "       index is now " << index << endl;
             }
         }
     }
@@ -261,10 +259,9 @@ HTMLElementImpl *HTMLTableElementImpl::insertRow( int index, int &exceptioncode
         section = lastSection;
         index = section ? section->numRows() : 0;
     }
-    if ( section && (index >= 0 || append) ) {
-        //kdDebug(6030) << "Inserting row into section " << section << " at index " << index << endl;
-        return section->insertRow( index, exceptioncode );
-    } else {
+    if (section && (index >= 0 || append))
+        return section->insertRow(index, exceptioncode);
+    else {
         // No more sections => index is too big
         exceptioncode = DOMException::INDEX_SIZE_ERR;
         return 0L;
index a759ebd..769dbe0 100644 (file)
@@ -89,6 +89,8 @@ using XBL::XBLBindingManager;
 #include "SVGElementFactory.h"
 #include "SVGZoomEventImpl.h"
 #include "SVGStyleElementImpl.h"
+#include "SVGDocumentExtensions.h"
+#include "KSVGTimeScheduler.h"
 #endif
 
 namespace WebCore {
@@ -195,17 +197,18 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, FrameView *v)
     , m_transformSource(0)
 #endif
     , m_finishedParsing(this, SIGNAL(finishedParsing()))
-    , m_inPageCache(false)
     , m_savedRenderer(0)
     , m_passwordFields(0)
     , m_secureForms(0)
-    , m_createRenderers(true)
     , m_designMode(inherit)
+    , m_selfOnlyRefCount(0)
 #if __APPLE__
     , m_hasDashboardRegions(false)
     , m_dashboardRegionsDirty(false)
 #endif
-    , m_selfOnlyRefCount(0)
+    , m_accessKeyMapValid(false)
+    , m_createRenderers(true)
+    , m_inPageCache(false)
 {
     document.resetSkippingRef(this);
 
@@ -262,7 +265,6 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, FrameView *v)
     m_ignorePendingStylesheets = false;
 
     m_cssTarget = 0;
-    m_accessKeyMapValid = false;
 
     resetLinkColor();
     resetVisitedLinkColor();
@@ -1238,6 +1240,14 @@ void DocumentImpl::implicitClose()
     if (renderer() && KWQAccObjectCache::accessibilityEnabled())
         getAccObjectCache()->postNotification(renderer(), "AXLoadComplete");
 #endif
+
+#if SVG_SUPPORT
+    // FIXME: Officially, time 0 is when the outermost <svg> recieves its
+    // SVGLoad event, but we don't implement those yet.  This is close enough
+    // for now.  In some cases we should have fired earlier.
+    if (svgExtensions())
+        accessSVGExtensions()->timeScheduler()->startAnimations();
+#endif
 }
 
 void DocumentImpl::setParsing(bool b)
@@ -1347,7 +1357,6 @@ void DocumentImpl::setURL(const QString& url)
 
 void DocumentImpl::setStyleSheet(const DOMString &url, const DOMString &sheet)
 {
-//    kdDebug( 6030 ) << "HTMLDocument::setStyleSheet()" << endl;
     m_sheet = new CSSStyleSheetImpl(this, url);
     m_sheet->ref();
     m_sheet->parseString(sheet);
@@ -1819,7 +1828,8 @@ QStringList DocumentImpl::availableStyleSheets() const
 
 void DocumentImpl::recalcStyleSelector()
 {
-    if ( !m_render || !attached() ) return;
+    if (!m_render || !attached())
+        return;
 
     QPtrList<StyleSheetImpl> oldStyleSheets = m_styleSheets->styleSheets;
     m_styleSheets->styleSheets.clear();
@@ -1926,7 +1936,7 @@ void DocumentImpl::recalcStyleSelector()
                 if (title != m_preferredStylesheetSet)
                     sheet = 0; // don't use it
 
-                title = title.replace('&', QString::fromLatin1("&&"));
+                title = title.replace('&', "&&");
 
                 if (!m_availableSheets.contains(title))
                     m_availableSheets.append(title);
@@ -2969,6 +2979,20 @@ AttrImpl *DocumentImpl::createAttributeNS(const DOMString &namespaceURI, const D
                                                                        namespaceURI.impl()), DOMString("").impl()), false);
 }
 
+#if SVG_SUPPORT
+const SVGDocumentExtensions* DocumentImpl::svgExtensions()
+{
+    return m_svgExtensions.get();
+}
+
+SVGDocumentExtensions* DocumentImpl::accessSVGExtensions()
+{
+    if (!m_svgExtensions)
+        m_svgExtensions = new SVGDocumentExtensions(this);
+    return m_svgExtensions.get();
+}
+#endif
+
 void DocumentImpl::radioButtonChecked(HTMLInputElementImpl *caller, HTMLFormElementImpl *form)
 {
     // Without a name, there is no group.
index 938ccd2..7c2ff5f 100644 (file)
@@ -47,22 +47,13 @@ class QPaintDevice;
 class QPaintDeviceMetrics;
 class RenderArena;
 
-namespace khtml {
-    class CSSStyleSelector;
-    class DocLoader;
-    class Tokenizer;
-#if __APPLE__
-    struct DashboardRegionValue;
-#endif
-}
-
 #ifndef KHTML_NO_XBL
 namespace XBL {
     class XBLBindingManager;
 }
 #endif
 
-namespace DOM {
+namespace WebCore {
     class AbstractViewImpl;
     class AttrImpl;
     class CDATASectionImpl;
@@ -95,6 +86,13 @@ namespace DOM {
     class TextImpl;
     class TreeWalkerImpl;
     class NameNodeListImpl;
+    class CSSStyleSelector;
+    class DocLoader;
+    class Tokenizer;
+#if __APPLE__
+    struct DashboardRegionValue;
+#endif
+    class SVGDocumentExtensions;
 
     // A range of a node within a document that is "marked", such as being misspelled
     struct DocumentMarker
@@ -718,6 +716,11 @@ public:
     void radioButtonChecked(HTMLInputElementImpl *caller, HTMLFormElementImpl *form);
     HTMLInputElementImpl* checkedRadioButtonForGroup(DOMStringImpl* name, HTMLFormElementImpl *form);
     void removeRadioButtonGroup(DOMStringImpl* name, HTMLFormElementImpl *form);
+    
+#if SVG_SUPPORT
+    const SVGDocumentExtensions* svgExtensions();
+    SVGDocumentExtensions* accessSVGExtensions();
+#endif
 
 private:
     void updateTitle();
@@ -730,7 +733,6 @@ private:
     bool acceptsEditingFocus(NodeImpl *node);
 
     mutable DOMString m_domain;
-    bool m_inPageCache;
     RenderObject *m_savedRenderer;
     int m_passwordFields;
     int m_secureForms;
@@ -741,22 +743,26 @@ private:
     mutable HashCountedSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > m_duplicateIds;
     
     HashMap<DOMStringImpl*, ElementImpl*, CaseInsensitiveHash> m_elementsByAccessKey;
-    bool m_accessKeyMapValid;
-    bool m_createRenderers;
     
     InheritedBool m_designMode;
     
+    int m_selfOnlyRefCount;
+    typedef HashMap<DOMStringImpl*, HTMLInputElementImpl*, PointerHash<DOMStringImpl*> > NameToInputMap;
+    typedef HashMap<HTMLFormElementImpl*, NameToInputMap*, PointerHash<HTMLFormElementImpl*> > FormToGroupMap;
+    FormToGroupMap m_selectedRadioButtons;
+    
+#if SVG_SUPPORT
+    RefPtr<SVGDocumentExtensions> m_svgExtensions;
+#endif
+    
 #if __APPLE__
     QValueList<DashboardRegionValue> m_dashboardRegions;
     bool m_hasDashboardRegions;
     bool m_dashboardRegionsDirty;
 #endif
-
-    int m_selfOnlyRefCount;
-    typedef HashMap<DOMStringImpl*, HTMLInputElementImpl*, PointerHash<DOMStringImpl*> > NameToInputMap;
-    typedef HashMap<HTMLFormElementImpl*, NameToInputMap*, PointerHash<HTMLFormElementImpl*> > FormToGroupMap;
-    FormToGroupMap m_selectedRadioButtons;
+    bool m_accessKeyMapValid;
+    bool m_createRenderers;
+    bool m_inPageCache;
 };
 
 } //namespace
index c9ca05a..5068f96 100644 (file)
@@ -37,7 +37,7 @@
 #include "editing/visible_text.h"
 #include "xml/dom_position.h"
 
-#include "render_block.h"
+#include "RenderBlock.h"
 
 using khtml::createMarkup;
 using khtml::RenderBlock;
index 559a6f5..674d6e2 100644 (file)
 #include "text_affinity.h"
 #include "visible_position.h"
 #include "visible_units.h"
-#include "rendering/render_block.h"
-#include "rendering/render_flow.h"
-#include "rendering/render_line.h"
-#include "rendering/render_style.h"
+#include "RenderBlock.h"
+#include "render_flow.h"
+#include "render_line.h"
+#include "render_style.h"
 #include "InlineTextBox.h"
-#include "editing/visible_text.h"
+#include "visible_text.h"
 #include "htmlnames.h"
 
 #include <kxmlcore/Assertions.h>
index e228f4b..105ac9f 100644 (file)
@@ -32,7 +32,7 @@
 #include "FrameView.h"
 #include "render_canvas.h"
 #include "render_replaced.h"
-#include "render_table.h"
+#include "RenderTableCell.h"
 #include "InlineTextBox.h"
 #include "render_br.h"
 #include "SelectionController.h"
index 5c4f2f9..936cb7e 100644 (file)
@@ -62,7 +62,7 @@
 #include "kjs_window.h"
 #include "loader.h"
 #include "markup.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_canvas.h"
 #include "render_frames.h"
 #include "typing_command.h"
index 90b6636..76b5c7a 100644 (file)
@@ -28,7 +28,7 @@
 #include "break_lines.h"
 #include "kxmlcore/AlwaysInline.h"
 #include "render_arena.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "xml/dom2_rangeimpl.h"
 #include "DocumentImpl.h"
 #include <qpen.h>
similarity index 99%
rename from WebCore/rendering/render_block.cpp
rename to WebCore/rendering/RenderBlock.cpp
index e8cc838..dfadc1c 100644 (file)
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
  */
 
 #include "config.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 
 #include "DocumentImpl.h"
 #include "Frame.h"
 #include "SelectionController.h"
 #include "htmlnames.h"
 #include "render_canvas.h"
-#include "render_table.h"
+#include "RenderTableCell.h"
 #include "render_theme.h"
 #include "visible_position.h"
 #include <kdebug.h>
 
-using namespace DOM;
-
 namespace WebCore {
 
 using namespace HTMLNames;
 
-// -------------------------------------------------------------------------------------------------------
-
 // Our MarginInfo state used when laying out block children.
 RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, int top, int bottom)
 {
@@ -3560,9 +3555,5 @@ void RenderBlock::dump(QTextStream *stream, QString ind) const
 }
 #endif
 
-#undef DEBUG
-#undef DEBUG_LAYOUT
-#undef BOX_DEBUG
-
-} // namespace khtml
+} // namespace WebCore
 
similarity index 99%
rename from WebCore/rendering/render_block.h
rename to WebCore/rendering/RenderBlock.h
index cbd70c2..1fd0a3e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
  */
 
-#ifndef RENDER_BLOCK_H
-#define RENDER_BLOCK_H
+#ifndef RenderBlock_H
+#define RenderBlock_H
 
 #include <qptrlist.h>
 
@@ -34,11 +33,9 @@ typedef enum {
     DragCaret,
 } CaretType;
 
-namespace DOM {
-    class Position;
-}
+namespace WebCore {
 
-namespace khtml {
+class Position;
 
 class RenderBlock : public RenderFlow
 {
similarity index 98%
rename from WebCore/rendering/render_container.cpp
rename to WebCore/rendering/RenderContainer.cpp
index 5cbdde8..5d91ef5 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,8 +24,8 @@
  */
 
 #include "config.h"
-#include "render_container.h"
-#include "render_table.h"
+#include "RenderContainer.h"
+#include "RenderTable.h"
 #include "RenderTextFragment.h"
 #include "render_image.h"
 #include "render_canvas.h"
 #include "xml/dom_position.h"
 #include "visible_position.h"
 
-#include <kdebug.h>
 #include <assert.h>
 
 // For accessibility
 #include "KWQAccObjectCache.h" 
 
 using DOM::Position;
-using namespace khtml;
+namespace WebCore {
 
 RenderContainer::RenderContainer(DOM::NodeImpl* node)
     : RenderBox(node)
@@ -129,7 +128,6 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
                 needsTable = false;
             break;
         case NONE:
-            kdDebug( 6000 ) << "error in RenderObject::addChild()!!!!" << endl;
             break;
         }
     }
@@ -522,3 +520,5 @@ QValueList<IntRect> RenderContainer::lineBoxRects()
 }
 
 #undef DEBUG_LAYOUT
+
+}
similarity index 93%
rename from WebCore/rendering/render_container.h
rename to WebCore/rendering/RenderContainer.h
index df8742a..1c5e985 100644 (file)
@@ -2,6 +2,7 @@
  * This file is part of the html renderer for KDE.
  *
  * Copyright (C) 2001 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
  */
-#ifndef render_container_h
-#define render_container_h
+
+#ifndef RenderContainer_H
+#define RenderContainer_H
 
 #include "render_box.h"
 
-namespace DOM {
-    class Position;
-};
-
-namespace khtml
-{
+namespace WebCore {
 
+class Position;
 
 /**
  * Base class for rendering objects that can have children
@@ -74,5 +71,6 @@ protected:
     RenderObject *m_first;
     RenderObject *m_last;
 };
-};
+
+}
 #endif
diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp
new file mode 100644 (file)
index 0000000..22cd9ba
--- /dev/null
@@ -0,0 +1,744 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderTable.h"
+#include "RenderTableSection.h"
+#include "RenderTableCol.h"
+#include "RenderTableCell.h"
+#include "DocumentImpl.h"
+#include "table_layout.h"
+#include "htmlnames.h"
+#include <qtextstream.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderTable::RenderTable(NodeImpl* node)
+    : RenderBlock(node)
+{
+    tCaption = 0;
+    head = foot = firstBody = 0;
+    tableLayout = 0;
+    m_currentBorder = 0;
+    
+    rules = None;
+    frame = Void;
+    has_col_elems = false;
+    hspacing = 0;
+    vspacing = 0;
+    padding = 0;
+    needSectionRecalc = false;
+    padding = 0;
+
+    columnPos.resize(2);
+    columnPos.fill(0);
+    columns.resize(1);
+    columns.fill(ColumnStruct());
+
+    columnPos[0] = 0;
+}
+
+RenderTable::~RenderTable()
+{
+    delete tableLayout;
+}
+
+void RenderTable::setStyle(RenderStyle *_style)
+{
+    ETableLayout oldTableLayout = style() ? style()->tableLayout() : TAUTO;
+    RenderBlock::setStyle(_style);
+
+    // In the collapsed border model, there is no cell spacing.
+    hspacing = collapseBorders() ? 0 : style()->horizontalBorderSpacing();
+    vspacing = collapseBorders() ? 0 : style()->verticalBorderSpacing();
+    columnPos[0] = hspacing;
+
+    if (!tableLayout || style()->tableLayout() != oldTableLayout) {
+       delete tableLayout;
+
+        // According to the CSS2 spec, you only use fixed table layout if an
+        // explicit width is specified on the table.  Auto width implies auto table layout.
+       if (style()->tableLayout() == TFIXED && !style()->width().isAuto())
+           tableLayout = new FixedTableLayout(this);
+       else
+           tableLayout = new AutoTableLayout(this);
+    }
+}
+
+void RenderTable::addChild(RenderObject *child, RenderObject *beforeChild)
+{
+    RenderObject *o = child;
+
+    if (child->element() && child->element()->hasTagName(formTag)) {
+        RenderContainer::addChild(child,beforeChild);
+        return;
+    }
+
+    switch (child->style()->display()) {
+        case TABLE_CAPTION:
+            tCaption = static_cast<RenderBlock *>(child);
+            break;
+        case TABLE_COLUMN:
+        case TABLE_COLUMN_GROUP:
+            has_col_elems = true;
+            break;
+        case TABLE_HEADER_GROUP:
+            if (!head)
+                head = static_cast<RenderTableSection *>(child);
+            else if (!firstBody)
+                firstBody = static_cast<RenderTableSection *>(child);
+            break;
+        case TABLE_FOOTER_GROUP:
+            if (!foot) {
+                foot = static_cast<RenderTableSection *>(child);
+                break;
+            }
+            // fall through
+        case TABLE_ROW_GROUP:
+            if (!firstBody)
+                firstBody = static_cast<RenderTableSection *>(child);
+            break;
+        default:
+            if (!beforeChild && lastChild() &&
+                lastChild()->isTableSection() && lastChild()->isAnonymous()) {
+                o = lastChild();
+            } else {
+                RenderObject *lastBox = beforeChild;
+                RenderObject *nextToLastBox = beforeChild;
+                while (lastBox && lastBox->parent()->isAnonymous() &&
+                        !lastBox->isTableSection() && lastBox->style()->display() != TABLE_CAPTION) {
+                    nextToLastBox = lastBox;
+                    lastBox = lastBox->parent();
+                }
+                if (lastBox && lastBox->isAnonymous()) {
+                    lastBox->addChild(child, nextToLastBox);
+                    return;
+                } else {
+                    if (beforeChild && !beforeChild->isTableSection())
+                        beforeChild = 0;
+                    o = new (renderArena()) RenderTableSection(document() /* anonymous */);
+                    RenderStyle *newStyle = new (renderArena()) RenderStyle();
+                    newStyle->inheritFrom(style());
+                    newStyle->setDisplay(TABLE_ROW_GROUP);
+                    o->setStyle(newStyle);
+                    addChild(o, beforeChild);
+                }
+            }
+            o->addChild(child);
+            child->setNeedsLayoutAndMinMaxRecalc();
+            return;
+    }
+    RenderContainer::addChild(child,beforeChild);
+}
+
+
+
+void RenderTable::calcWidth()
+{
+    if (isPositioned())
+        calcAbsoluteHorizontal();
+
+    RenderBlock *cb = containingBlock();
+    int availableWidth = cb->contentWidth();
+
+    LengthType widthType = style()->width().type;
+    if (widthType > Relative && style()->width().value > 0) {
+       // Percent or fixed table
+        m_width = style()->width().minWidth(availableWidth);
+        if (m_minWidth > m_width) m_width = m_minWidth;
+    } else {
+        // An auto width table should shrink to fit within the line width if necessary in order to 
+        // avoid overlapping floats.
+        availableWidth = cb->lineWidth(m_y);
+        
+        // Subtract out any fixed margins from our available width for auto width tables.
+        int marginTotal = 0;
+        if (style()->marginLeft().type != Auto)
+            marginTotal += style()->marginLeft().width(availableWidth);
+        if (style()->marginRight().type != Auto)
+            marginTotal += style()->marginRight().width(availableWidth);
+            
+        // Subtract out our margins to get the available content width.
+        int availContentWidth = kMax(0, availableWidth - marginTotal);
+        
+        // Ensure we aren't bigger than our max width or smaller than our min width.
+        m_width = kMin(availContentWidth, m_maxWidth);
+    }
+    
+    m_width = kMax(m_width, m_minWidth);
+
+    // Finally, with our true width determined, compute our margins for real.
+    m_marginRight = 0;
+    m_marginLeft = 0;
+    calcHorizontalMargins(style()->marginLeft(),style()->marginRight(),availableWidth);
+}
+
+void RenderTable::layout()
+{
+    KHTMLAssert(needsLayout());
+    KHTMLAssert(minMaxKnown());
+    KHTMLAssert(!needSectionRecalc);
+
+    if (posChildNeedsLayout() && !normalChildNeedsLayout() && !selfNeedsLayout()) {
+        // All we have to is lay out our positioned objects.
+        layoutPositionedObjects(true);
+        setNeedsLayout(false);
+        return;
+    }
+
+    IntRect oldBounds, oldFullBounds;
+    bool checkForRepaint = checkForRepaintDuringLayout();
+    if (checkForRepaint)
+        getAbsoluteRepaintRectIncludingFloats(oldBounds, oldFullBounds);
+    
+    m_height = m_overflowHeight = 0;
+    initMaxMarginValues();
+    
+    //int oldWidth = m_width;
+    calcWidth();
+    m_overflowWidth = m_width;
+
+    // the optimisation below doesn't work since the internal table
+    // layout could have changed.  we need to add a flag to the table
+    // layout that tells us if something has changed in the min max
+    // calculations to do it correctly.
+//     if ( oldWidth != m_width || columns.size() + 1 != columnPos.size() )
+    tableLayout->layout();
+
+    setCellWidths();
+
+    // layout child objects
+    int calculatedHeight = 0;
+
+    RenderObject *child = firstChild();
+    while(child) {
+       if (child->needsLayout() && !(child->element() && child->element()->hasTagName(formTag)))
+           child->layout();
+       if (child->isTableSection()) {
+           static_cast<RenderTableSection *>(child)->calcRowHeight();
+           calculatedHeight += static_cast<RenderTableSection *>(child)->layoutRows(0);
+       }
+       child = child->nextSibling();
+    }
+
+    // ### collapse caption margin
+    if (tCaption && tCaption->style()->captionSide() != CAPBOTTOM) {
+        tCaption->setPos(tCaption->marginLeft(), m_height);
+        m_height += tCaption->height() + tCaption->marginTop() + tCaption->marginBottom();
+    }
+
+    int bpTop = borderTop() + (collapseBorders() ? 0 : paddingTop());
+    int bpBottom = borderBottom() + (collapseBorders() ? 0 : paddingBottom());
+    
+    m_height += bpTop;
+
+    int oldHeight = m_height;
+    calcHeight();
+    int newHeight = m_height;
+    m_height = oldHeight;
+
+    Length h = style()->height();
+    int th = 0;
+    if (isPositioned())
+        th = newHeight; // FIXME: Leave this alone for now but investigate later.
+    else if (h.isFixed())
+        th = h.value - (bpTop + bpBottom);  // Tables size as though CSS height includes border/padding.
+    else if (h.isPercent())
+        th = calcPercentageHeight(h);
+    th = kMax(0, th);
+
+    // layout rows
+    if (th > calculatedHeight) {
+       // we have to redistribute that height to get the constraint correctly
+       // just force the first body to the height needed
+       // ### FIXME This should take height constraints on all table sections into account and distribute
+       // accordingly. For now this should be good enough
+        if (firstBody) {
+            firstBody->calcRowHeight();
+            firstBody->layoutRows(th - calculatedHeight);
+        }
+        else if (!style()->htmlHacks()) {
+            // Completely empty tables (with no sections or anything) should at least honor specified height
+            // in strict mode.
+            m_height += th;
+        }
+    }
+    
+    int bl = borderLeft();
+    if (!collapseBorders())
+        bl += paddingLeft();
+
+    // position the table sections
+    if (head) {
+       head->setPos(bl, m_height);
+       m_height += head->height();
+    }
+    for (RenderObject *body = firstBody; body; body = body->nextSibling()) {
+       if (body != head && body != foot && body->isTableSection()) {
+           body->setPos(bl, m_height);
+           m_height += body->height();
+       }
+    }
+    if (foot) {
+       foot->setPos(bl, m_height);
+       m_height += foot->height();
+    }
+
+    m_height += bpBottom;
+               
+    if (tCaption && tCaption->style()->captionSide()==CAPBOTTOM) {
+        tCaption->setPos(tCaption->marginLeft(), m_height);
+        m_height += tCaption->height() + tCaption->marginTop() + tCaption->marginBottom();
+    }
+
+    // table can be containing block of positioned elements.
+    // ### only pass true if width or height changed.
+    layoutPositionedObjects( true );
+
+    // Repaint with our new bounds if they are different from our old bounds.
+    if (checkForRepaint)
+        repaintAfterLayoutIfNeeded(oldBounds, oldFullBounds);
+    
+    m_overflowHeight = kMax(m_overflowHeight, m_height);
+    m_overflowWidth = kMax(m_overflowWidth, m_width);
+
+    setNeedsLayout(false);
+}
+
+void RenderTable::setCellWidths()
+{
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
+       if ( child->isTableSection() )
+           static_cast<RenderTableSection *>(child)->setCellWidths();
+}
+
+void RenderTable::paint(PaintInfo& i, int _tx, int _ty)
+{
+    _tx += xPos();
+    _ty += yPos();
+
+    PaintAction paintAction = i.phase;
+    
+    int os = 2*maximalOutlineSize(paintAction);
+    if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + height() <= i.r.y() - os))
+        return;
+    if ((_tx >= i.r.x() + i.r.width() + os) || (_tx + width() <= i.r.x() - os))
+        return;
+
+    if ((paintAction == PaintActionBlockBackground || paintAction == PaintActionChildBlockBackground)
+        && shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE)
+        paintBoxDecorations(i, _tx, _ty);
+
+    // We're done.  We don't bother painting any children.
+    if (paintAction == PaintActionBlockBackground)
+        return;
+    // We don't paint our own background, but we do let the kids paint their backgrounds.
+    if (paintAction == PaintActionChildBlockBackgrounds)
+        paintAction = PaintActionChildBlockBackground;
+    PaintInfo paintInfo(i.p, i.r, paintAction, paintingRootForChildren(i));
+    
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
+        if (child->isTableSection() || child == tCaption)
+           child->paint(paintInfo, _tx, _ty);
+
+    if (collapseBorders() && paintAction == PaintActionChildBlockBackground && style()->visibility() == VISIBLE) {
+        // Collect all the unique border styles that we want to paint in a sorted list.  Once we
+        // have all the styles sorted, we then do individual passes, painting each style of border
+        // from lowest precedence to highest precedence.
+        paintInfo.phase = PaintActionCollapsedTableBorders;
+        QValueList<CollapsedBorderValue> borderStyles;
+        collectBorders(borderStyles);
+        QValueListIterator<CollapsedBorderValue> it = borderStyles.begin();
+        QValueListIterator<CollapsedBorderValue> end = borderStyles.end();
+        for (; it != end; ++it) {
+            m_currentBorder = &(*it);
+            for (RenderObject* child = firstChild(); child; child = child->nextSibling())
+                if (child->isTableSection())
+                    child->paint(paintInfo, _tx, _ty);
+        }
+    }
+        
+#ifdef BOX_DEBUG
+    outlineBox(i.p, _tx, _ty, "blue");
+#endif
+}
+
+void RenderTable::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
+{
+    int w = width();
+    int h = height();
+    
+    // Account for the caption.
+    if (tCaption) {
+        int captionHeight = (tCaption->height() + tCaption->marginBottom() +  tCaption->marginTop());
+        h -= captionHeight;
+        if (tCaption->style()->captionSide() != CAPBOTTOM)
+            _ty += captionHeight;
+    }
+
+    int my = kMax(_ty, i.r.y());
+    int mh;
+    if (_ty < i.r.y())
+        mh= kMax(0, h - (i.r.y() - _ty));
+    else
+        mh = kMin(i.r.height(), h);
+    
+    paintBackground(i.p, style()->backgroundColor(), style()->backgroundLayers(), my, mh, _tx, _ty, w, h);
+    
+    if (style()->hasBorder() && !collapseBorders())
+        paintBorder(i.p, _tx, _ty, w, h, style());
+}
+
+void RenderTable::calcMinMaxWidth()
+{
+    KHTMLAssert(!minMaxKnown());
+
+    if (needSectionRecalc)
+       recalcSections();
+
+    tableLayout->calcMinMaxWidth();
+
+    if (tCaption && tCaption->minWidth() > m_minWidth)
+        m_minWidth = tCaption->minWidth();
+
+    setMinMaxKnown();
+}
+
+void RenderTable::splitColumn(int pos, int firstSpan)
+{
+    // we need to add a new columnStruct
+    int oldSize = columns.size();
+    columns.resize(oldSize + 1);
+    int oldSpan = columns[pos].span;
+//     qDebug("splitColumn( %d,%d ), oldSize=%d, oldSpan=%d", pos, firstSpan, oldSize, oldSpan );
+    KHTMLAssert(oldSpan > firstSpan);
+    columns[pos].span = firstSpan;
+    memmove(columns.data() + pos + 1, columns.data() + pos, (oldSize-pos)*sizeof(ColumnStruct));
+    columns[pos+1].span = oldSpan - firstSpan;
+
+    // change width of all rows.
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
+       if (child->isTableSection()) {
+           RenderTableSection *section = static_cast<RenderTableSection *>(child);
+           if (section->cCol > pos)
+               section->cCol++;
+           int size = section->numRows();
+           for (int row = 0; row < size; ++row) {
+               section->grid[row].row->resize(oldSize + 1);
+               RenderTableSection::Row &r = *section->grid[row].row;
+               memmove(r.data() + pos + 1, r.data() + pos, (oldSize - pos) * sizeof(RenderTableSection::CellStruct));
+               r[pos + 1].cell = 0;
+                r[pos + 1].inColSpan = r[pos].inColSpan || r[pos].cell;
+           }
+       }
+    }
+    columnPos.resize(numEffCols() + 1);
+    setNeedsLayoutAndMinMaxRecalc();
+}
+
+void RenderTable::appendColumn(int span)
+{
+    // easy case.
+    int pos = columns.size();
+    int newSize = pos + 1;
+    columns.resize(newSize);
+    columns[pos].span = span;
+
+    // change width of all rows.
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
+       if (child->isTableSection()) {
+           RenderTableSection *section = static_cast<RenderTableSection *>(child);
+           int size = section->numRows();
+           for (int row = 0; row < size; ++row) {
+               section->grid[row].row->resize(newSize);
+                RenderTableSection::CellStruct& c = section->cellAt(row, pos);
+               c.cell = 0;
+               c.inColSpan = false;
+           }
+       }
+    }
+    columnPos.resize(numEffCols() + 1);
+    setNeedsLayoutAndMinMaxRecalc();
+}
+
+RenderTableCol *RenderTable::colElement(int col) {
+    if (!has_col_elems)
+       return 0;
+    RenderObject *child = firstChild();
+    int cCol = 0;
+    while (child) {
+       if (child->isTableCol()) {
+           RenderTableCol *colElem = static_cast<RenderTableCol *>(child);
+           int span = colElem->span();
+           if (!colElem->firstChild()) {
+               cCol += span;
+               if (cCol > col)
+                   return colElem;
+           }
+
+           RenderObject *next = child->firstChild();
+           if (!next)
+               next = child->nextSibling();
+           if (!next && child->parent()->isTableCol())
+               next = child->parent()->nextSibling();
+           child = next;
+       } else if (child == tCaption)
+            child = child->nextSibling();
+        else
+           break;
+    }
+    return 0;
+}
+
+void RenderTable::recalcSections()
+{
+    tCaption = 0;
+    head = foot = firstBody = 0;
+    has_col_elems = false;
+
+    // We need to get valid pointers to caption, head, foot and firstbody again
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
+       switch (child->style()->display()) {
+            case TABLE_CAPTION:
+                if (!tCaption) {
+                    tCaption = static_cast<RenderBlock*>(child);
+                    tCaption->setNeedsLayout(true);
+                }
+                break;
+            case TABLE_COLUMN:
+            case TABLE_COLUMN_GROUP:
+                has_col_elems = true;
+                break;
+            case TABLE_HEADER_GROUP: {
+                RenderTableSection *section = static_cast<RenderTableSection *>(child);
+                if (!head)
+                    head = section;
+                else if (!firstBody)
+                    firstBody = section;
+                if (section->needCellRecalc)
+                    section->recalcCells();
+                break;
+            }
+            case TABLE_FOOTER_GROUP: {
+                RenderTableSection *section = static_cast<RenderTableSection *>(child);
+                if (!foot)
+                    foot = section;
+                else if (!firstBody)
+                    firstBody = section;
+                if (section->needCellRecalc)
+                    section->recalcCells();
+                break;
+            }
+            case TABLE_ROW_GROUP: {
+                RenderTableSection *section = static_cast<RenderTableSection *>(child);
+                if (!firstBody)
+                    firstBody = section;
+                if (section->needCellRecalc)
+                    section->recalcCells();
+            }
+            default:
+                break;
+       }
+    }
+    needSectionRecalc = false;
+    setNeedsLayout(true);
+}
+
+RenderObject* RenderTable::removeChildNode(RenderObject* child)
+{
+    setNeedSectionRecalc();
+    return RenderContainer::removeChildNode(child);
+}
+
+int RenderTable::borderLeft() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderLeft();
+}
+    
+int RenderTable::borderRight() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderRight();
+}
+
+int RenderTable::borderTop() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderTop();
+}
+
+int RenderTable::borderBottom() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderBottom();
+}
+
+RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
+{
+    // Find the section and row to look in
+    int r = cell->row();
+    RenderTableSection* section = 0;
+    int rAbove = -1;
+    if (r > 0) {
+        // cell is not in the first row, so use the above row in its own section
+        section = cell->section();
+        rAbove = r-1;
+    } else {
+        // cell is at top of a section, use last row in previous section
+        for (RenderObject *prevSection = cell->section()->previousSibling();
+             prevSection && rAbove < 0;
+             prevSection = prevSection->previousSibling()) {
+            if (prevSection->isTableSection()) {
+                section = static_cast<RenderTableSection *>(prevSection);
+                if (section->numRows() > 0)
+                    rAbove = section->numRows()-1;
+            }
+        }
+    }
+
+    // Look up the cell in the section's grid, which requires effective col index
+    if (section && rAbove >= 0) {
+        int effCol = colToEffCol(cell->col());
+        RenderTableSection::CellStruct aboveCell;
+        // If we hit a span back up to a real cell.
+        do {
+            aboveCell = section->cellAt(rAbove, effCol);
+            effCol--;
+        } while (!aboveCell.cell && aboveCell.inColSpan && effCol >=0);
+        return aboveCell.cell;
+    } else
+        return 0;
+}
+
+RenderTableCell* RenderTable::cellBelow(const RenderTableCell* cell) const
+{
+    // Find the section and row to look in
+    int r = cell->row() + cell->rowSpan() - 1;
+    RenderTableSection* section = 0;
+    int rBelow = -1;
+    if (r < cell->section()->numRows() - 1) {
+        // The cell is not in the last row, so use the next row in the section.
+        section = cell->section();
+        rBelow= r+1;
+    } else {
+        // The cell is at the bottom of a section. Use the first row in the next section.
+        for (RenderObject* nextSection = cell->section()->nextSibling();
+             nextSection && rBelow < 0;
+             nextSection = nextSection->nextSibling()) {
+            if (nextSection->isTableSection()) {
+                section = static_cast<RenderTableSection *>(nextSection);
+                if (section->numRows() > 0)
+                    rBelow = 0;
+            }
+        }
+    }
+    
+    // Look up the cell in the section's grid, which requires effective col index
+    if (section && rBelow >= 0) {
+        int effCol = colToEffCol(cell->col());
+        RenderTableSection::CellStruct belowCell;
+        // If we hit a colspan back up to a real cell.
+        do {
+            belowCell = section->cellAt(rBelow, effCol);
+            effCol--;
+        } while (!belowCell.cell && belowCell.inColSpan && effCol >=0);
+        return belowCell.cell;
+    } else
+        return 0;
+}
+
+RenderTableCell* RenderTable::cellLeft(const RenderTableCell* cell) const
+{
+    RenderTableSection* section = cell->section();
+    int effCol = colToEffCol(cell->col());
+    if (effCol == 0)
+        return 0;
+    
+    // If we hit a colspan back up to a real cell.
+    RenderTableSection::CellStruct prevCell;
+    do {
+        prevCell = section->cellAt(cell->row(), effCol-1);
+        effCol--;
+    } while (!prevCell.cell && prevCell.inColSpan && effCol >=0);
+    return prevCell.cell;
+}
+
+RenderTableCell* RenderTable::cellRight(const RenderTableCell* cell) const
+{
+    int effCol = colToEffCol(cell->col() + cell->colSpan());
+    if (effCol >= numEffCols())
+        return 0;
+    return cell->section()->cellAt(cell->row(), effCol).cell;
+}
+
+RenderBlock* RenderTable::firstLineBlock() const
+{
+    return 0;
+}
+
+void RenderTable::updateFirstLetter()
+{
+}
+
+#ifndef NDEBUG
+void RenderTable::dump(QTextStream *stream, QString ind) const
+{
+    if (tCaption)
+       *stream << " tCaption";
+    if (head)
+       *stream << " head";
+    if (foot)
+       *stream << " foot";
+
+    *stream << endl << ind << "cspans:";
+    for ( unsigned int i = 0; i < columns.size(); i++ )
+       *stream << " " << columns[i].span;
+    *stream << endl << ind;
+
+    RenderBlock::dump(stream,ind);
+}
+#endif
+
+}
diff --git a/WebCore/rendering/RenderTable.h b/WebCore/rendering/RenderTable.h
new file mode 100644 (file)
index 0000000..4723edf
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef RenderTable_H
+#define RenderTable_H
+
+#include "RenderBlock.h"
+
+namespace WebCore {
+
+class RenderTableCol;
+class RenderTableCell;
+class RenderTableSection;
+class TableLayout;
+
+class RenderTable : public RenderBlock
+{
+public:
+    enum Rules {
+        None    = 0x00,
+        RGroups = 0x01,
+        CGroups = 0x02,
+        Groups  = 0x03,
+        Rows    = 0x05,
+        Cols    = 0x0a,
+        All     = 0x0f
+    };
+    enum Frame {
+        Void   = 0x00,
+        Above  = 0x01,
+        Below  = 0x02,
+        Lhs    = 0x04,
+        Rhs    = 0x08,
+        Hsides = 0x03,
+        Vsides = 0x0c,
+        Box    = 0x0f
+    };
+
+    RenderTable(DOM::NodeImpl* node);
+    ~RenderTable();
+
+    virtual const char *renderName() const { return "RenderTable"; }
+
+    virtual void setStyle(RenderStyle *style);
+
+    virtual bool isTable() const { return true; }
+
+    int getColumnPos(int col) const
+        { return columnPos[col]; }
+
+    int hBorderSpacing() const { return hspacing; }
+    int vBorderSpacing() const { return vspacing; }
+    
+    bool collapseBorders() const { return style()->borderCollapse(); }
+    int borderLeft() const;
+    int borderRight() const;
+    int borderTop() const;
+    int borderBottom() const;
+    
+    Rules getRules() const { return rules; }
+
+    const QColor &bgColor() const { return style()->backgroundColor(); }
+
+    uint cellPadding() const { return padding; }
+    void setCellPadding(uint p) { padding = p; }
+
+    // overrides
+    virtual int overflowHeight(bool includeInterior = true) const { return height(); }
+    virtual int overflowWidth(bool includeInterior = true) const { return width(); }
+    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
+    virtual void paint(PaintInfo& i, int tx, int ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
+    virtual void layout();
+    virtual void calcMinMaxWidth();
+
+    virtual RenderBlock* firstLineBlock() const;
+    virtual void updateFirstLetter();
+    
+    virtual void setCellWidths();
+
+    virtual void calcWidth();
+
+#ifndef NDEBUG
+    virtual void dump(QTextStream *stream, QString ind = "") const;
+#endif
+    struct ColumnStruct {
+       enum {
+           WidthUndefined = 0xffff
+       };
+       ColumnStruct() {
+           span = 1;
+           width = WidthUndefined;
+       }
+       ushort span;
+       uint width; // the calculated position of the column
+    };
+
+    Array<int> columnPos;
+    Array<ColumnStruct> columns;
+
+    void splitColumn(int pos, int firstSpan);
+    void appendColumn(int span);
+    int numEffCols() const { return columns.size(); }
+    int spanOfEffCol(int effCol) const { return columns[effCol].span; }
+    int colToEffCol(int col) const {
+       int c = 0;
+       int i = 0;
+       while (c < col && i < (int)columns.size()) {
+           c += columns[i].span;
+           i++;
+       }
+       return i;
+    }
+    int effColToCol(int effCol) const {
+       int c = 0;
+       for (int i = 0; i < effCol; i++)
+           c += columns[i].span;
+       return c;
+    }
+
+    int bordersPaddingAndSpacing() const {
+       return borderLeft() + borderRight() + 
+               (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols() + 1) * hBorderSpacing()));
+    }
+
+    RenderTableCol *colElement(int col);
+
+    void setNeedSectionRecalc() { needSectionRecalc = true; }
+
+    virtual RenderObject* removeChildNode(RenderObject* child);
+
+    RenderTableCell* cellAbove(const RenderTableCell* cell) const;
+    RenderTableCell* cellBelow(const RenderTableCell* cell) const;
+    RenderTableCell* cellLeft(const RenderTableCell* cell) const;
+    RenderTableCell* cellRight(const RenderTableCell* cell) const;
+    CollapsedBorderValue* currentBorderStyle() { return m_currentBorder; }
+    
+    bool hasSections() const { return head || foot || firstBody; }
+
+protected:
+
+    void recalcSections();
+
+    friend class AutoTableLayout;
+    friend class FixedTableLayout;
+
+    RenderBlock *tCaption;
+    RenderTableSection *head;
+    RenderTableSection *foot;
+    RenderTableSection *firstBody;
+
+    TableLayout *tableLayout;
+
+    CollapsedBorderValue* m_currentBorder;
+    
+    Frame frame                 : 4;
+    Rules rules                 : 4;
+
+    bool has_col_elems         : 1;
+    uint padding               : 22;
+    uint needSectionRecalc     : 1;
+    
+    short hspacing;
+    short vspacing;
+};
+
+}
+#endif
diff --git a/WebCore/rendering/RenderTableCell.cpp b/WebCore/rendering/RenderTableCell.cpp
new file mode 100644 (file)
index 0000000..480a627
--- /dev/null
@@ -0,0 +1,770 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderTableCell.h"
+#include "RenderTableCol.h"
+#include "htmlnames.h"
+#include "html_tableimpl.h"
+#include <qtextstream.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderTableCell::RenderTableCell(NodeImpl* _node)
+  : RenderBlock(_node)
+{
+  _col = -1;
+  _row = -1;
+  cSpan = rSpan = 1;
+  updateFromElement();
+  setShouldPaintBackgroundOrBorder(true);
+  _topExtra = 0;
+  _bottomExtra = 0;
+  m_percentageHeight = 0;
+}
+
+void RenderTableCell::destroy()
+{
+    if (parent() && section())
+        section()->setNeedCellRecalc();
+
+    RenderBlock::destroy();
+}
+
+void RenderTableCell::updateFromElement()
+{
+    int oldRSpan = rSpan;
+    int oldCSpan = cSpan;
+    NodeImpl* node = element();
+    if (node && (node->hasTagName(tdTag) || node->hasTagName(thTag))) {
+        HTMLTableCellElementImpl *tc = static_cast<HTMLTableCellElementImpl *>(node);
+        cSpan = tc->colSpan();
+        rSpan = tc->rowSpan();
+    }
+    if ((oldRSpan != rSpan || oldCSpan != cSpan) && style() && parent())
+        setNeedsLayoutAndMinMaxRecalc();
+}
+
+Length RenderTableCell::styleOrColWidth()
+{
+    Length w = style()->width();
+    if (colSpan() > 1 || !w.isAuto())
+        return w;
+    RenderTableCol* col = table()->colElement(_col);
+    if (col)
+        w = col->style()->width();
+    return w;
+}
+
+void RenderTableCell::calcMinMaxWidth()
+{
+    RenderBlock::calcMinMaxWidth();
+    if (element() && style()->autoWrap()) {
+        // See if nowrap was set.
+        Length w = styleOrColWidth();
+        DOMString nowrap = static_cast<ElementImpl*>(element())->getAttribute(nowrapAttr);
+        if (!nowrap.isNull() && w.isFixed())
+            // Nowrap is set, but we didn't actually use it because of the
+            // fixed width set on the cell.  Even so, it is a WinIE/Moz trait
+            // to make the minwidth of the cell into the fixed width.  They do this
+            // even in strict mode, so do not make this a quirk.  Affected the top
+            // of hiptop.com.
+            if (m_minWidth < w.value)
+                m_minWidth = w.value;
+    }
+}
+
+void RenderTableCell::calcWidth()
+{
+}
+
+void RenderTableCell::setWidth(int width)
+{
+    if (width != m_width) {
+       m_width = width;
+       m_widthChanged = true;
+    }
+}
+
+void RenderTableCell::layout()
+{
+    layoutBlock(m_widthChanged);
+    m_widthChanged = false;
+}
+
+void RenderTableCell::computeAbsoluteRepaintRect(IntRect& r, bool f)
+{
+    r.setY(r.y() + _topExtra);
+    RenderBlock::computeAbsoluteRepaintRect(r, f);
+}
+
+bool RenderTableCell::absolutePosition(int &xPos, int &yPos, bool f)
+{
+    bool ret = RenderBlock::absolutePosition(xPos, yPos, f);
+    if (ret)
+      yPos += _topExtra;
+    return ret;
+}
+
+short RenderTableCell::baselinePosition(bool) const
+{
+    RenderObject* o = firstChild();
+    int offset = paddingTop() + borderTop();
+    
+    if (!o)
+        return offset + contentHeight();
+    while (o->firstChild()) {
+       if (!o->isInline())
+           offset += o->paddingTop() + o->borderTop();
+       o = o->firstChild();
+    }
+    
+    if (!o->isInline())
+        return paddingTop() + borderTop() + contentHeight();
+
+    offset += o->baselinePosition(true);
+    return offset;
+}
+
+void RenderTableCell::setStyle(RenderStyle *style)
+{
+    style->setDisplay(TABLE_CELL);
+
+    if (style->whiteSpace() == KHTML_NOWRAP) {
+        // Figure out if we are really nowrapping or if we should just
+        // use normal instead.  If the width of the cell is fixed, then
+        // we don't actually use NOWRAP. 
+        if (style->width().isFixed())
+            style->setWhiteSpace(NORMAL);
+        else
+            style->setWhiteSpace(NOWRAP);
+    }
+
+    RenderBlock::setStyle(style);
+    setShouldPaintBackgroundOrBorder(true);
+}
+
+bool RenderTableCell::requiresLayer() {
+    return isPositioned() || style()->opacity() < 1.0f || hasOverflowClip();
+}
+
+// The following rules apply for resolving conflicts and figuring out which border
+// to use.
+// (1) Borders with the 'border-style' of 'hidden' take precedence over all other conflicting 
+// borders. Any border with this value suppresses all borders at this location.
+// (2) Borders with a style of 'none' have the lowest priority. Only if the border properties of all 
+// the elements meeting at this edge are 'none' will the border be omitted (but note that 'none' is 
+// the default value for the border style.)
+// (3) If none of the styles are 'hidden' and at least one of them is not 'none', then narrow borders 
+// are discarded in favor of wider ones. If several have the same 'border-width' then styles are preferred 
+// in this order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', and the lowest: 'inset'.
+// (4) If border styles differ only in color, then a style set on a cell wins over one on a row, 
+// which wins over a row group, column, column group and, lastly, table. It is undefined which color 
+// is used when two elements of the same type disagree.
+static CollapsedBorderValue compareBorders(const CollapsedBorderValue& border1, 
+                                           const CollapsedBorderValue& border2)
+{
+    // Sanity check the values passed in.  If either is null, return the other.
+    if (!border2.exists()) return border1;
+    if (!border1.exists()) return border2;
+    
+    // Rule #1 above.
+    if (border1.style() == BHIDDEN || border2.style() == BHIDDEN)
+        return CollapsedBorderValue(); // No border should exist at this location.
+    
+    // Rule #2 above.  A style of 'none' has lowest priority and always loses to any other border.
+    if (border2.style() == BNONE) return border1;
+    if (border1.style() == BNONE) return border2;
+    
+    // The first part of rule #3 above. Wider borders win.
+    if (border1.width() != border2.width())
+        return border1.width() > border2.width() ? border1 : border2;
+    
+    // The borders have equal width.  Sort by border style.
+    if (border1.style() != border2.style())
+        return border1.style() > border2.style() ? border1 : border2;
+    
+    // The border have the same width and style.  Rely on precedence (cell over row over row group, etc.)
+    return border1.precedence >= border2.precedence ? border1 : border2;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedLeftBorder() const
+{
+    // For border left, we need to check, in order of precedence:
+    // (1) Our left border.
+    CollapsedBorderValue result(&style()->borderLeft(), BCELL);
+    
+    // (2) The previous cell's right border.
+    RenderTableCell* prevCell = table()->cellLeft(this);
+    if (prevCell) {
+        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderRight(), BCELL));
+        if (!result.exists())
+            return result;
+    }
+    else if (col() == 0) {
+        // (3) Our row's left border.
+        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderLeft(), BROW));
+        if (!result.exists())
+            return result;
+        
+        // (4) Our row group's left border.
+        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderLeft(), BROWGROUP));
+        if (!result.exists())
+            return result;
+    }
+    
+    // (5) Our column's left border.
+    RenderTableCol* colElt = table()->colElement(col());
+    if (colElt) {
+        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
+        if (!result.exists())
+            return result;
+    }
+    
+    // (6) The previous column's right border.
+    if (col() > 0) {
+        colElt = table()->colElement(col() - 1);
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
+            if (!result.exists())
+                return result;
+        }
+    }
+    
+    if (col() == 0) {
+        // (7) The table's left border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderLeft(), BTABLE));
+        if (!result.exists())
+            return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedRightBorder() const
+{
+    RenderTable* tableElt = table();
+    bool inLastColumn = false;
+    int effCol = tableElt->colToEffCol(col() + colSpan() - 1);
+    if (effCol == tableElt->numEffCols() - 1)
+        inLastColumn = true;
+    
+    // For border right, we need to check, in order of precedence:
+    // (1) Our right border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderRight(), BCELL);
+    
+    // (2) The next cell's left border.
+    if (!inLastColumn) {
+        RenderTableCell* nextCell = tableElt->cellRight(this);
+        if (nextCell && nextCell->style()) {
+            result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderLeft(), BCELL));
+            if (!result.exists())
+                return result;
+        }
+    } else {
+        // (3) Our row's right border.
+        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderRight(), BROW));
+        if (!result.exists())
+            return result;
+        
+        // (4) Our row group's right border.
+        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderRight(), BROWGROUP));
+        if (!result.exists())
+            return result;
+    }
+    
+    // (5) Our column's right border.
+    RenderTableCol* colElt = table()->colElement(col()+colSpan() - 1);
+    if (colElt) {
+        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
+        if (!result.exists())
+            return result;
+    }
+    
+    // (6) The next column's left border.
+    if (!inLastColumn) {
+        colElt = tableElt->colElement(col()+colSpan());
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
+            if (!result.exists())
+                return result;
+        }
+    }
+    else {
+        // (7) The table's right border.
+        result = compareBorders(result, CollapsedBorderValue(&tableElt->style()->borderRight(), BTABLE));
+        if (!result.exists())
+            return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedTopBorder() const
+{
+    // For border top, we need to check, in order of precedence:
+    // (1) Our top border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderTop(), BCELL);
+    
+    RenderTableCell* prevCell = table()->cellAbove(this);
+    if (prevCell) {
+        // (2) A previous cell's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderBottom(), BCELL));
+        if (!result.exists()) 
+            return result;
+    }
+    
+    // (3) Our row's top border.
+    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderTop(), BROW));
+    if (!result.exists())
+        return result;
+    
+    // (4) The previous row's bottom border.
+    if (prevCell) {
+        RenderObject* prevRow = 0;
+        if (prevCell->section() == section())
+            prevRow = parent()->previousSibling();
+        else
+            prevRow = prevCell->section()->lastChild();
+    
+        if (prevRow) {
+            result = compareBorders(result, CollapsedBorderValue(&prevRow->style()->borderBottom(), BROW));
+            if (!result.exists())
+                return result;
+        }
+    }
+    
+    // Now check row groups.
+    RenderObject* currSection = parent()->parent();
+    if (row() == 0) {
+        // (5) Our row group's top border.
+        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderTop(), BROWGROUP));
+        if (!result.exists())
+            return result;
+        
+        // (6) Previous row group's bottom border.
+        for (currSection = currSection->previousSibling(); currSection;
+             currSection = currSection->previousSibling()) {
+            if (currSection->isTableSection()) {
+                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
+                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderBottom(), BROWGROUP));
+                if (!result.exists())
+                    return result;
+            }
+        }
+    }
+    
+    if (!currSection) {
+        // (8) Our column's top border.
+        RenderTableCol* colElt = table()->colElement(col());
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderTop(), BCOL));
+            if (!result.exists())
+                return result;
+        }
+        
+        // (9) The table's top border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderTop(), BTABLE));
+        if (!result.exists())
+            return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedBottomBorder() const
+{
+    // For border top, we need to check, in order of precedence:
+    // (1) Our bottom border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderBottom(), BCELL);
+    
+    RenderTableCell* nextCell = table()->cellBelow(this);
+    if (nextCell) {
+        // (2) A following cell's top border.
+        result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderTop(), BCELL));
+        if (!result.exists())
+            return result;
+    }
+    
+    // (3) Our row's bottom border. (FIXME: Deal with rowspan!)
+    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderBottom(), BROW));
+    if (!result.exists())
+        return result;
+    
+    // (4) The next row's top border.
+    if (nextCell) {
+        result = compareBorders(result, CollapsedBorderValue(&nextCell->parent()->style()->borderTop(), BROW));
+        if (!result.exists())
+            return result;
+    }
+    
+    // Now check row groups.
+    RenderObject* currSection = parent()->parent();
+    if (row() + rowSpan() >= static_cast<RenderTableSection*>(currSection)->numRows()) {
+        // (5) Our row group's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderBottom(), BROWGROUP));
+        if (!result.exists())
+            return result;
+        
+        // (6) Following row group's top border.
+        for (currSection = currSection->nextSibling(); currSection;
+             currSection = currSection->nextSibling()) {
+            if (currSection->isTableSection()) {
+                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
+                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderTop(), BROWGROUP));
+                if (!result.exists())
+                    return result;
+            }
+        }
+    }
+    
+    if (!currSection) {
+        // (8) Our column's bottom border.
+        RenderTableCol* colElt = table()->colElement(col());
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderBottom(), BCOL));
+            if (!result.exists()) return result;
+        }
+        
+        // (9) The table's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderBottom(), BTABLE));
+        if (!result.exists())
+            return result;
+    }
+    
+    return result;    
+}
+
+int RenderTableCell::borderLeft() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedLeftBorder();
+        if (border.exists())
+            return int(border.width() / 2.0 + 0.5); // Give the extra pixel to top and left.
+        return 0;
+    }
+    return RenderBlock::borderLeft();
+}
+    
+int RenderTableCell::borderRight() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedRightBorder();
+        if (border.exists())
+            return border.width() / 2;
+        return 0;
+    }
+    return RenderBlock::borderRight();
+}
+
+int RenderTableCell::borderTop() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedTopBorder();
+        if (border.exists())
+            return int(border.width() / 2.0 + 0.5); // Give the extra pixel to top and left.
+        return 0;
+    }
+    return RenderBlock::borderTop();
+}
+
+int RenderTableCell::borderBottom() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedBottomBorder();
+        if (border.exists())
+            return border.width() / 2;
+        return 0;
+    }
+    return RenderBlock::borderBottom();
+}
+
+#ifdef BOX_DEBUG
+static void outlineBox(QPainter *p, int _tx, int _ty, int w, int h)
+{
+    p->setPen(QPen(QColor("yellow"), 3, Qt::DotLine));
+    p->setBrush(Qt::NoBrush);
+    p->drawRect(_tx, _ty, w, h);
+}
+#endif
+
+void RenderTableCell::paint(PaintInfo& i, int _tx, int _ty)
+{
+    _tx += m_x;
+    _ty += m_y;
+
+    // check if we need to do anything at all...
+    int os = 2*maximalOutlineSize(i.phase);
+    if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + _topExtra + m_height + _bottomExtra <= i.r.y() - os))
+        return;
+
+    if (i.phase == PaintActionCollapsedTableBorders && style()->visibility() == VISIBLE) {
+        int w = width();
+        int h = height() + borderTopExtra() + borderBottomExtra();
+        paintCollapsedBorder(i.p, _tx, _ty, w, h);
+    }
+    else
+        RenderBlock::paintObject(i, _tx, _ty + _topExtra);
+
+#ifdef BOX_DEBUG
+    ::outlineBox( i.p, _tx, _ty, width(), height() + borderTopExtra() + borderBottomExtra());
+#endif
+}
+
+static EBorderStyle collapsedBorderStyle(EBorderStyle style)
+{
+    if (style == OUTSET)
+        style = GROOVE;
+    else if (style == INSET)
+        style = RIDGE;
+    return style;
+}
+
+struct CollapsedBorder {
+    CollapsedBorder(){}
+    
+    CollapsedBorderValue border;
+    RenderObject::BorderSide side;
+    bool shouldPaint;
+    int x1;
+    int y1;
+    int x2;
+    int y2;
+    EBorderStyle style;
+};
+
+class CollapsedBorders
+{
+public:
+    CollapsedBorders(int i) :count(0) {}
+    
+    void addBorder(const CollapsedBorderValue& b, RenderObject::BorderSide s, bool paint, 
+                   int _x1, int _y1, int _x2, int _y2,
+                   EBorderStyle _style)
+    {
+        if (b.exists() && paint) {
+            borders[count].border = b;
+            borders[count].side = s;
+            borders[count].shouldPaint = paint;
+            borders[count].x1 = _x1;
+            borders[count].x2 = _x2;
+            borders[count].y1 = _y1;
+            borders[count].y2 = _y2;
+            borders[count].style = _style;
+            count++;
+        }
+    }
+
+    CollapsedBorder* nextBorder() {
+        for (int i = 0; i < count; i++) {
+            if (borders[i].border.exists() && borders[i].shouldPaint) {
+                borders[i].shouldPaint = false;
+                return &borders[i];
+            }
+        }
+        
+        return 0;
+    }
+    
+    CollapsedBorder borders[4];
+    int count;
+};
+
+static void addBorderStyle(QValueList<CollapsedBorderValue>& borderStyles, CollapsedBorderValue borderValue)
+{
+    if (!borderValue.exists() || borderStyles.contains(borderValue))
+        return;
+    
+    QValueListIterator<CollapsedBorderValue> it = borderStyles.begin();
+    QValueListIterator<CollapsedBorderValue> end = borderStyles.end();
+    for (; it != end; ++it) {
+        CollapsedBorderValue result = compareBorders(*it, borderValue);
+        if (result == *it) {
+            borderStyles.insert(it, borderValue);
+            return;
+        }
+    }
+
+    borderStyles.append(borderValue);
+}
+
+void RenderTableCell::collectBorders(QValueList<CollapsedBorderValue>& borderStyles)
+{
+    addBorderStyle(borderStyles, collapsedLeftBorder());
+    addBorderStyle(borderStyles, collapsedRightBorder());
+    addBorderStyle(borderStyles, collapsedTopBorder());
+    addBorderStyle(borderStyles, collapsedBottomBorder());
+}
+
+void RenderTableCell::paintCollapsedBorder(QPainter* p, int _tx, int _ty, int w, int h)
+{
+    if (!table()->currentBorderStyle())
+        return;
+    
+    CollapsedBorderValue leftVal = collapsedLeftBorder();
+    CollapsedBorderValue rightVal = collapsedRightBorder();
+    CollapsedBorderValue topVal = collapsedTopBorder();
+    CollapsedBorderValue bottomVal = collapsedBottomBorder();
+     
+    // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location.
+    int topWidth = topVal.width();
+    int bottomWidth = bottomVal.width();
+    int leftWidth = leftVal.width();
+    int rightWidth = rightVal.width();
+    
+    _tx -= leftWidth / 2;
+    _ty -= topWidth / 2;
+    w += leftWidth / 2 + int(rightWidth / 2.0 + 0.5);
+    h += topWidth / 2 + int(bottomWidth / 2.0 + 0.5);
+    
+    bool tt = topVal.isTransparent();
+    bool bt = bottomVal.isTransparent();
+    bool rt = rightVal.isTransparent();
+    bool lt = leftVal.isTransparent();
+    
+    EBorderStyle ts = collapsedBorderStyle(topVal.style());
+    EBorderStyle bs = collapsedBorderStyle(bottomVal.style());
+    EBorderStyle ls = collapsedBorderStyle(leftVal.style());
+    EBorderStyle rs = collapsedBorderStyle(rightVal.style());
+    
+    bool render_t = ts > BHIDDEN && !tt;
+    bool render_l = ls > BHIDDEN && !lt;
+    bool render_r = rs > BHIDDEN && !rt;
+    bool render_b = bs > BHIDDEN && !bt;
+
+    // We never paint diagonals at the joins.  We simply let the border with the highest
+    // precedence paint on top of borders with lower precedence.  
+    CollapsedBorders borders(4);
+    borders.addBorder(topVal, BSTop, render_t, _tx, _ty, _tx + w, _ty + topWidth, ts);
+    borders.addBorder(bottomVal, BSBottom, render_b, _tx, _ty + h - bottomWidth, _tx + w, _ty + h, bs);
+    borders.addBorder(leftVal, BSLeft, render_l, _tx, _ty, _tx + leftWidth, _ty + h, ls);
+    borders.addBorder(rightVal, BSRight, render_r, _tx + w - rightWidth, _ty, _tx + w, _ty + h, rs);
+    
+    for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
+        if (border->border == *table()->currentBorderStyle())
+            drawBorder(p, border->x1, border->y1, border->x2, border->y2, border->side, 
+                       border->border.color(), style()->color(), border->style, 0, 0);
+    }
+}
+
+IntRect RenderTableCell::getAbsoluteRepaintRect()
+{
+    int ow = style() ? style()->outlineSize() : 0;
+    IntRect r(-ow, -ow - borderTopExtra(), 
+            overflowWidth(false) + ow * 2, overflowHeight(false) + borderTopExtra() + borderBottomExtra() + ow * 2);
+    computeAbsoluteRepaintRect(r);
+    return r;
+}
+
+void RenderTableCell::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
+{
+    RenderTable* tableElt = table();
+    if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
+        return;
+    
+    int w = width();
+    int h = height() + borderTopExtra() + borderBottomExtra();
+    _ty -= borderTopExtra();
+
+    QColor c = style()->backgroundColor();
+    if (!c.isValid() && parent()) // take from row
+        c = parent()->style()->backgroundColor();
+    if (!c.isValid() && parent() && parent()->parent()) // take from rowgroup
+        c = parent()->parent()->style()->backgroundColor();
+    if (!c.isValid()) {
+       // see if we have a col or colgroup for this
+       RenderTableCol *col = table()->colElement(_col);
+       if (col) {
+           c = col->style()->backgroundColor();
+           if (!c.isValid()) {
+               // try column group
+               RenderStyle *style = col->parent()->style();
+               if (style->display() == TABLE_COLUMN_GROUP)
+                   c = style->backgroundColor();
+           }
+       }
+    }
+
+    // FIXME: This code is just plain wrong.  Rows and columns should paint their backgrounds
+    // independent from the cell.
+    // ### get offsets right in case the bgimage is inherited.
+    const BackgroundLayer* bgLayer = style()->backgroundLayers();
+    if (!bgLayer->hasImage() && parent())
+        bgLayer = parent()->style()->backgroundLayers();
+    if (!bgLayer->hasImage() && parent() && parent()->parent())
+        bgLayer = parent()->parent()->style()->backgroundLayers();
+    if (!bgLayer->hasImage()) {
+       // see if we have a col or colgroup for this
+       RenderTableCol* col = table()->colElement(_col);
+       if (col) {
+           bgLayer = col->style()->backgroundLayers();
+           if (!bgLayer->hasImage()) {
+               // try column group
+               RenderStyle *style = col->parent()->style();
+               if (style->display() == TABLE_COLUMN_GROUP)
+                   bgLayer = style->backgroundLayers();
+           }
+       }
+    }
+
+    int my = kMax(_ty, i.r.y());
+    int end = kMin(i.r.y() + i.r.height(), _ty + h);
+    int mh = end - my;
+
+    if (bgLayer->hasImage() || c.isValid()) {
+       // We have to clip here because the backround would paint
+        // on top of the borders otherwise.
+        if (m_layer && tableElt->collapseBorders()) {
+            IntRect clipRect(_tx + borderLeft(), _ty + borderTop(), w - borderLeft() - borderRight(), h - borderTop() - borderBottom());
+            clipRect = i.p->xForm(clipRect);
+            i.p->save();
+            i.p->addClip(clipRect);
+        }
+        paintBackground(i.p, c, bgLayer, my, mh, _tx, _ty, w, h);
+        if (m_layer && tableElt->collapseBorders())
+            i.p->restore();
+    }
+
+    if (style()->hasBorder() && !tableElt->collapseBorders())
+        paintBorder(i.p, _tx, _ty, w, h, style());
+}
+
+#ifndef NDEBUG
+void RenderTableCell::dump(QTextStream *stream, QString ind) const
+{
+    *stream << " row=" << _row;
+    *stream << " col=" << _col;
+    *stream << " rSpan=" << rSpan;
+    *stream << " cSpan=" << cSpan;
+//    *stream << " nWrap=" << nWrap;
+
+    RenderBlock::dump(stream,ind);
+}
+#endif
+
+}
diff --git a/WebCore/rendering/RenderTableCell.h b/WebCore/rendering/RenderTableCell.h
new file mode 100644 (file)
index 0000000..cfbe275
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef RenderTableCell_H
+#define RenderTableCell_H
+
+#include "RenderBlock.h"
+#include "RenderTable.h"
+#include "RenderTableSection.h"
+
+namespace WebCore {
+
+class RenderTableCell : public RenderBlock
+{
+public:
+    RenderTableCell(DOM::NodeImpl* node);
+
+    virtual void destroy();
+
+    virtual const char *renderName() const { return "RenderTableCell"; }
+    virtual bool isTableCell() const { return true; }
+
+    // overrides RenderObject
+    virtual bool requiresLayer();
+
+    // ### FIX these two...
+    int cellIndex() const { return 0; }
+    void setCellIndex(int) { }
+
+    int colSpan() const { return cSpan; }
+    void setColSpan(int c) { cSpan = c; }
+
+    int rowSpan() const { return rSpan; }
+    void setRowSpan(int r) { rSpan = r; }
+
+    int col() const { return _col; }
+    void setCol(int col) { _col = col; }
+    int row() const { return _row; }
+    void setRow(int r) { _row = r; }
+
+    Length styleOrColWidth();
+
+    // overrides
+    virtual void calcMinMaxWidth();
+    virtual void calcWidth();
+    virtual void setWidth(int width);
+    virtual void setStyle(RenderStyle *style);
+
+    int borderLeft() const;
+    int borderRight() const;
+    int borderTop() const;
+    int borderBottom() const;
+
+    CollapsedBorderValue collapsedLeftBorder() const;
+    CollapsedBorderValue collapsedRightBorder() const;
+    CollapsedBorderValue collapsedTopBorder() const;
+    CollapsedBorderValue collapsedBottomBorder() const;
+    virtual void collectBorders(QValueList<CollapsedBorderValue>& borderStyles);
+
+    virtual void updateFromElement();
+
+    virtual void layout();
+    
+    void setCellTopExtra(int p) { _topExtra = p; }
+    void setCellBottomExtra(int p) { _bottomExtra = p; }
+
+    virtual void paint(PaintInfo& i, int tx, int ty);
+
+    void paintCollapsedBorder(QPainter* p, int x, int y, int w, int h);
+    
+    // lie position to outside observers
+    virtual int yPos() const { return m_y + _topExtra; }
+
+    virtual void computeAbsoluteRepaintRect(IntRect& r, bool f=false);
+    virtual bool absolutePosition(int &xPos, int &yPos, bool f = false);
+
+    virtual short baselinePosition(bool = false) const;
+
+    virtual int borderTopExtra() const { return _topExtra; }
+    virtual int borderBottomExtra() const { return _bottomExtra; }
+
+    RenderTable *table() const { return static_cast<RenderTable *>(parent()->parent()->parent()); }
+    RenderTableSection *section() const { return static_cast<RenderTableSection *>(parent()->parent()); }
+
+#ifndef NDEBUG
+    virtual void dump(QTextStream *stream, QString ind = "") const;
+#endif
+
+    virtual IntRect getAbsoluteRepaintRect();
+    
+protected:
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
+    
+    int _row;
+    int _col;
+    int rSpan;
+    int cSpan;
+    int _topExtra : 31;
+    bool nWrap : 1;
+    int _bottomExtra : 31;
+    bool m_widthChanged : 1;
+    
+    int m_percentageHeight;
+};
+
+}
+#endif
diff --git a/WebCore/rendering/RenderTableCol.cpp b/WebCore/rendering/RenderTableCol.cpp
new file mode 100644 (file)
index 0000000..3551e9c
--- /dev/null
@@ -0,0 +1,83 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderTableCol.h"
+#include "html_tableimpl.h"
+#include "htmlnames.h"
+#include <qtextstream.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderTableCol::RenderTableCol(NodeImpl* node)
+    : RenderContainer(node)
+{
+    // init RenderObject attributes
+    setInline(true);   // our object is not Inline
+
+    _span = 1;
+    updateFromElement();
+}
+
+void RenderTableCol::updateFromElement()
+{
+    int oldSpan = _span;
+    NodeImpl *node = element();
+    if (node && (node->hasTagName(colTag) || node->hasTagName(colgroupTag))) {
+        HTMLTableColElementImpl *tc = static_cast<HTMLTableColElementImpl *>(node);
+        _span = tc->span();
+    } else
+      _span = !(style() && style()->display() == TABLE_COLUMN_GROUP);
+    if (_span != oldSpan && style() && parent())
+        setNeedsLayoutAndMinMaxRecalc();
+}
+
+bool RenderTableCol::canHaveChildren() const
+{
+    // cols cannot have children.  This is actually necessary to fix a bug
+    // with libraries.uc.edu, which makes a <p> be a table-column.
+    return style()->display() == TABLE_COLUMN_GROUP;
+}
+
+void RenderTableCol::addChild(RenderObject *child, RenderObject *beforeChild)
+{
+    KHTMLAssert(child->style()->display() == TABLE_COLUMN);
+
+    // these have to come before the table definition!
+    RenderContainer::addChild(child, beforeChild);
+}
+
+#ifndef NDEBUG
+void RenderTableCol::dump(QTextStream *stream, QString ind) const
+{
+    *stream << " _span=" << _span;
+    RenderContainer::dump(stream, ind);
+}
+#endif
+
+}
diff --git a/WebCore/rendering/RenderTableCol.h b/WebCore/rendering/RenderTableCol.h
new file mode 100644 (file)
index 0000000..b49dab3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef RenderTableCol_H
+#define RenderTableCol_H
+
+#include "RenderContainer.h"
+
+namespace WebCore {
+
+class RenderTableCol : public RenderContainer
+{
+public:
+    RenderTableCol(DOM::NodeImpl* node);
+
+    virtual const char *renderName() const { return "RenderTableCol"; }
+
+    int span() const { return _span; }
+    void setSpan(int s) { _span = s; }
+
+    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
+
+    virtual bool isTableCol() const { return true; }
+
+    virtual short lineHeight(bool) const { return 0; }
+
+    virtual void updateFromElement();
+
+    virtual bool canHaveChildren() const;
+    
+#ifndef NDEBUG
+    virtual void dump(QTextStream *stream, QString ind = "") const;
+#endif
+
+protected:
+    int _span;
+};
+
+}
+#endif
diff --git a/WebCore/rendering/RenderTableRow.cpp b/WebCore/rendering/RenderTableRow.cpp
new file mode 100644 (file)
index 0000000..3f010f5
--- /dev/null
@@ -0,0 +1,142 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderTableRow.h"
+#include "RenderTableCell.h"
+#include "DocumentImpl.h"
+#include "htmlnames.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderTableRow::RenderTableRow(NodeImpl* node)
+    : RenderContainer(node)
+{
+    // init RenderObject attributes
+    setInline(false);   // our object is not Inline
+}
+
+void RenderTableRow::destroy()
+{
+    RenderTableSection *s = section();
+    if (s)
+        s->setNeedCellRecalc();
+    
+    RenderContainer::destroy();
+}
+
+void RenderTableRow::setStyle(RenderStyle* style)
+{
+    style->setDisplay(TABLE_ROW);
+    RenderContainer::setStyle(style);
+}
+
+void RenderTableRow::addChild(RenderObject *child, RenderObject *beforeChild)
+{
+    if (child->element() && child->element()->hasTagName(formTag)) {
+        RenderContainer::addChild(child,beforeChild);
+        return;
+    }
+
+    RenderTableCell *cell;
+
+    if (!child->isTableCell()) {
+       RenderObject *last = beforeChild;
+        if (!last)
+            last = lastChild();
+        RenderTableCell *cell = 0;
+        if (last && last->isAnonymous() && last->isTableCell())
+            cell = static_cast<RenderTableCell *>(last);
+        else {
+           cell = new (renderArena()) RenderTableCell(document() /* anonymous object */);
+           RenderStyle *newStyle = new (renderArena()) RenderStyle();
+           newStyle->inheritFrom(style());
+           newStyle->setDisplay(TABLE_CELL);
+           cell->setStyle(newStyle);
+           addChild(cell, beforeChild);
+        }
+        cell->addChild(child);
+        child->setNeedsLayoutAndMinMaxRecalc();
+        return;
+    } else
+        cell = static_cast<RenderTableCell *>(child);
+
+    static_cast<RenderTableSection *>(parent())->addCell(cell);
+
+    RenderContainer::addChild(cell,beforeChild);
+
+    if ((beforeChild || nextSibling()) && section())
+       section()->setNeedCellRecalc();
+}
+
+RenderObject* RenderTableRow::removeChildNode(RenderObject* child)
+{
+// RenderTableCell destroy should do it
+//     if ( section() )
+//     section()->setNeedCellRecalc();
+    return RenderContainer::removeChildNode(child);
+}
+
+#ifndef NDEBUG
+void RenderTableRow::dump(QTextStream *stream, QString ind) const
+{
+    RenderContainer::dump(stream,ind);
+}
+#endif
+
+void RenderTableRow::layout()
+{
+    KHTMLAssert(needsLayout());
+    KHTMLAssert(minMaxKnown());
+
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
+        if (child->isTableCell()) {
+            RenderTableCell *cell = static_cast<RenderTableCell *>(child);
+            if (child->needsLayout()) {
+                cell->calcVerticalMargins();
+                cell->layout();
+                cell->setCellTopExtra(0);
+                cell->setCellBottomExtra(0);
+            }
+        }
+    }
+    setNeedsLayout(false);
+}
+
+IntRect RenderTableRow::getAbsoluteRepaintRect()
+{
+    // For now, just repaint the whole table.
+    // FIXME: Find a better way to do this.
+    RenderTable* parentTable = table();
+    if (parentTable)
+        return parentTable->getAbsoluteRepaintRect();
+    else
+        return IntRect();
+}
+
+}
\ No newline at end of file
diff --git a/WebCore/rendering/RenderTableRow.h b/WebCore/rendering/RenderTableRow.h
new file mode 100644 (file)
index 0000000..b799cdc
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef RenderTableRow_H
+#define RenderTableRow_H
+
+#include "RenderContainer.h"
+#include "RenderTableSection.h"
+
+namespace WebCore {
+
+class RenderTableRow : public RenderContainer
+{
+public:
+    RenderTableRow(DOM::NodeImpl* node);
+
+    virtual void destroy();
+
+    virtual void setStyle(RenderStyle*);
+    virtual const char *renderName() const { return "RenderTableRow"; }
+
+    virtual bool isTableRow() const { return true; }
+
+    // overrides
+    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
+    virtual RenderObject* removeChildNode(RenderObject* child);
+
+    virtual short lineHeight(bool) const { return 0; }
+    virtual void position(int, int, int, int, int, bool, bool, int) {}
+
+    virtual void layout();
+    virtual IntRect getAbsoluteRepaintRect();
+    
+    RenderTable *table() const { return static_cast<RenderTable *>(parent()->parent()); }
+    RenderTableSection *section() const { return static_cast<RenderTableSection *>(parent()); }
+
+#ifndef NDEBUG
+    virtual void dump(QTextStream *stream, QString ind = "") const;
+#endif
+};
+
+}
+#endif
diff --git a/WebCore/rendering/RenderTableSection.cpp b/WebCore/rendering/RenderTableSection.cpp
new file mode 100644 (file)
index 0000000..787b8e8
--- /dev/null
@@ -0,0 +1,650 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderTableSection.h"
+#include "RenderTableCell.h"
+#include "RenderTableRow.h"
+#include "DocumentImpl.h"
+#include "htmlnames.h"
+#include <qtextstream.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderTableSection::RenderTableSection(NodeImpl* node)
+    : RenderContainer(node)
+{
+    // init RenderObject attributes
+    setInline(false);   // our object is not Inline
+    gridRows = 0;
+    cCol = 0;
+    cRow = -1;
+    needCellRecalc = false;
+}
+
+RenderTableSection::~RenderTableSection()
+{
+    clearGrid();
+}
+
+void RenderTableSection::destroy()
+{
+    // recalc cell info because RenderTable has unguarded pointers
+    // stored that point to this RenderTableSection.
+    if (table())
+        table()->setNeedSectionRecalc();
+
+    RenderContainer::destroy();
+}
+
+void RenderTableSection::setStyle(RenderStyle* _style)
+{
+    // we don't allow changing this one
+    if (style())
+        _style->setDisplay(style()->display());
+    else if (_style->display() != TABLE_FOOTER_GROUP && _style->display() != TABLE_HEADER_GROUP)
+        _style->setDisplay(TABLE_ROW_GROUP);
+
+    RenderContainer::setStyle(_style);
+}
+
+void RenderTableSection::addChild(RenderObject *child, RenderObject *beforeChild)
+{
+    RenderObject *row = child;
+
+    if (child->element() && child->element()->hasTagName(formTag)) {
+        RenderContainer::addChild(child,beforeChild);
+        return;
+    }
+    
+    if (!child->isTableRow()) {
+
+        if (!beforeChild)
+            beforeChild = lastChild();
+
+        if (beforeChild && beforeChild->isAnonymous())
+            row = beforeChild;
+        else {
+           RenderObject *lastBox = beforeChild;
+           while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableRow())
+               lastBox = lastBox->parent();
+           if (lastBox && lastBox->isAnonymous()) {
+               lastBox->addChild( child, beforeChild );
+               return;
+           } else {
+               row = new (renderArena()) RenderTableRow(document() /* anonymous table */);
+               RenderStyle *newStyle = new (renderArena()) RenderStyle();
+               newStyle->inheritFrom(style());
+               newStyle->setDisplay(TABLE_ROW);
+               row->setStyle(newStyle);
+               addChild(row, beforeChild);
+           }
+        }
+        row->addChild(child);
+        child->setNeedsLayoutAndMinMaxRecalc();
+        return;
+    }
+
+    if (beforeChild)
+       setNeedCellRecalc();
+
+    cRow++;
+    cCol = 0;
+
+    ensureRows(cRow+1);
+
+    if (!beforeChild) {
+        grid[cRow].height = child->style()->height();
+        if (grid[cRow].height.type == Relative)
+            grid[cRow].height = Length();
+    }
+
+
+    RenderContainer::addChild(child,beforeChild);
+}
+
+bool RenderTableSection::ensureRows(int numRows)
+{
+    int nRows = gridRows;
+    if (numRows > nRows) {
+        if (numRows > static_cast<int>(grid.size()))
+            if (!grid.resize(numRows*2+1))
+                return false;
+
+        gridRows = numRows;
+        int nCols = table()->numEffCols();
+        CellStruct emptyCellStruct;
+        emptyCellStruct.cell = 0;
+        emptyCellStruct.inColSpan = false;
+       for (int r = nRows; r < numRows; r++) {
+           grid[r].row = new Row(nCols);
+           grid[r].row->fill(emptyCellStruct);
+           grid[r].baseLine = 0;
+           grid[r].height = Length();
+       }
+    }
+
+    return true;
+}
+
+void RenderTableSection::addCell(RenderTableCell *cell)
+{
+    int rSpan = cell->rowSpan();
+    int cSpan = cell->colSpan();
+    Array<RenderTable::ColumnStruct> &columns = table()->columns;
+    int nCols = columns.size();
+
+    // ### mozilla still seems to do the old HTML way, even for strict DTD
+    // (see the annotation on table cell layouting in the CSS specs and the testcase below:
+    // <TABLE border>
+    // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
+    // <TR><TD colspan="2">5
+    // </TABLE>
+
+    while (cCol < nCols && (cellAt(cRow, cCol).cell || cellAt(cRow, cCol).inColSpan))
+       cCol++;
+
+    if (rSpan == 1) {
+       // we ignore height settings on rowspan cells
+       Length height = cell->style()->height();
+       if (height.value > 0 || (height.type == Relative && height.value >= 0)) {
+           Length cRowHeight = grid[cRow].height;
+           switch (height.type) {
+                case Percent:
+                    if (!(cRowHeight.type == Percent) ||
+                        (cRowHeight.type == Percent && cRowHeight.value < height.value))
+                        grid[cRow].height = height;
+                        break;
+                case Fixed:
+                    if (cRowHeight.type < Percent ||
+                        (cRowHeight.type == Fixed && cRowHeight.value < height.value))
+                        grid[cRow].height = height;
+                    break;
+                case Relative:
+                default:
+                    break;
+           }
+       }
+    }
+
+    // make sure we have enough rows
+    if (!ensureRows(cRow + rSpan))
+        return;
+
+    int col = cCol;
+    // tell the cell where it is
+    CellStruct currentCell;
+    currentCell.cell = cell;
+    currentCell.inColSpan = false;
+    while (cSpan) {
+       int currentSpan;
+       if (cCol >= nCols) {
+           table()->appendColumn(cSpan);
+           currentSpan = cSpan;
+       } else {
+           if (cSpan < columns[cCol].span)
+               table()->splitColumn(cCol, cSpan);
+           currentSpan = columns[cCol].span;
+       }
+
+       for (int r = 0; r < rSpan; r++) {
+            CellStruct& c = cellAt(cRow + r, cCol);
+            if (currentCell.cell && !c.cell)
+                c.cell = currentCell.cell;
+            if (currentCell.inColSpan)
+                c.inColSpan = true;
+       }
+       cCol++;
+       cSpan -= currentSpan;
+        currentCell.cell = 0;
+       currentCell.inColSpan = true;
+    }
+    if (cell) {
+       cell->setRow(cRow);
+       cell->setCol(table()->effColToCol(col));
+    }
+}
+
+
+
+void RenderTableSection::setCellWidths()
+{
+    Array<int> &columnPos = table()->columnPos;
+
+    int rows = gridRows;
+    for (int i = 0; i < rows; i++) {
+       Row &row = *grid[i].row;
+       int cols = row.size();
+       for (int j = 0; j < cols; j++) {
+           CellStruct current = row[j];
+            RenderTableCell *cell = current.cell;
+
+           if (!cell)
+               continue;
+           int endCol = j;
+           int cspan = cell->colSpan();
+           while (cspan && endCol < cols) {
+               cspan -= table()->columns[endCol].span;
+               endCol++;
+           }
+           int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
+           int oldWidth = cell->width();
+           if (w != oldWidth) {
+               cell->setNeedsLayout(true);
+               cell->setWidth(w);
+           }
+       }
+    }
+}
+
+
+void RenderTableSection::calcRowHeight()
+{
+    int indx;
+    RenderTableCell *cell;
+
+    int totalRows = gridRows;
+    int spacing = table()->vBorderSpacing();
+
+    rowPos.resize(totalRows + 1);
+    rowPos[0] = spacing;
+
+    for (int r = 0; r < totalRows; r++) {
+       rowPos[r + 1] = 0;
+
+       int baseline = 0;
+       int bdesc = 0;
+       int ch = grid[r].height.minWidth(0);
+       int pos = rowPos[r + 1] + ch + spacing;
+
+       if (pos > rowPos[r + 1])
+           rowPos[r + 1] = pos;
+
+       Row *row = grid[r].row;
+       int totalCols = row->size();
+       int totalRows = gridRows;
+
+       for (int c = 0; c < totalCols; c++) {
+           CellStruct current = cellAt(r, c);
+            cell = current.cell;
+           if (!cell || current.inColSpan)
+               continue;
+           if (r < totalRows - 1 && cellAt(r + 1, c).cell == cell)
+               continue;
+
+           if ((indx = r - cell->rowSpan() + 1) < 0)
+               indx = 0;
+
+            if (cell->overrideSize() != -1) {
+                cell->setOverrideSize(-1);
+                cell->setChildNeedsLayout(true, false);
+                cell->layoutIfNeeded();
+            }
+            
+            // Explicit heights use the border box in quirks mode.  In strict mode do the right
+            // thing and actually add in the border and padding.
+           ch = cell->style()->height().width(0) + 
+                (cell->style()->htmlHacks() ? 0 : (cell->paddingTop() + cell->paddingBottom() +
+                                                   cell->borderTop() + cell->borderBottom()));
+           if (cell->height() > ch)
+               ch = cell->height();
+
+            pos = rowPos[ indx ] + ch + spacing;
+
+           if (pos > rowPos[r + 1])
+               rowPos[r + 1] = pos;
+
+           // find out the baseline
+           EVerticalAlign va = cell->style()->verticalAlign();
+           if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP
+               || va == SUPER || va == SUB) {
+               int b = cell->baselinePosition();
+                if (b > cell->borderTop() + cell->paddingTop()) {
+                    if (b > baseline)
+                        baseline = b;
+
+                    int td = rowPos[indx] + ch - b;
+                    if (td > bdesc)
+                        bdesc = td;
+                }
+           }
+       }
+
+       //do we have baseline aligned elements?
+       if (baseline) {
+           // increase rowheight if baseline requires
+           int bRowPos = baseline + bdesc  + spacing ; // + 2*padding
+           if (rowPos[r + 1] < bRowPos)
+               rowPos[r + 1] = bRowPos;
+
+           grid[r].baseLine = baseline;
+       }
+
+       if (rowPos[r + 1] < rowPos[r])
+           rowPos[r + 1] = rowPos[r];
+    }
+}
+
+int RenderTableSection::layoutRows(int toAdd)
+{
+    int rHeight;
+    int rindx;
+    int totalRows = gridRows;
+    int hspacing = table()->hBorderSpacing();
+    int vspacing = table()->vBorderSpacing();
+    
+    if (toAdd && totalRows && (rowPos[totalRows] || !nextSibling())) {
+
+       int totalHeight = rowPos[totalRows] + toAdd;
+
+        int dh = toAdd;
+       int totalPercent = 0;
+       int numAuto = 0;
+       for (int r = 0; r < totalRows; r++) {
+           if (grid[r].height.type == Auto)
+               numAuto++;
+           else if (grid[r].height.type == Percent)
+               totalPercent += grid[r].height.value;
+       }
+       if (totalPercent) {
+           // try to satisfy percent
+           int add = 0;
+           if (totalPercent > 100)
+               totalPercent = 100;
+           int rh = rowPos[1] - rowPos[0];
+           for (int r = 0; r < totalRows; r++) {
+               if (totalPercent > 0 && grid[r].height.type == Percent) {
+                   int toAdd = kMin(dh, (totalHeight * grid[r].height.value / 100) - rh);
+                    // If toAdd is negative, then we don't want to shrink the row (this bug
+                    // affected Outlook Web Access).
+                    toAdd = kMax(0, toAdd);
+                   add += toAdd;
+                   dh -= toAdd;
+                   totalPercent -= grid[r].height.value;
+               }
+               if (r < totalRows - 1)
+                   rh = rowPos[r + 2] - rowPos[r + 1];
+                rowPos[r + 1] += add;
+           }
+       }
+       if (numAuto) {
+           // distribute over variable cols
+           int add = 0;
+           for (int r = 0; r < totalRows; r++) {
+               if (numAuto > 0 && grid[r].height.type == Auto) {
+                   int toAdd = dh/numAuto;
+                   add += toAdd;
+                   dh -= toAdd;
+                    numAuto--;
+               }
+                rowPos[r + 1] += add;
+           }
+       }
+        if (dh > 0 && rowPos[totalRows]) {
+           // if some left overs, distribute equally.
+            int tot = rowPos[totalRows];
+            int add = 0;
+            int prev = rowPos[0];
+            for (int r = 0; r < totalRows; r++) {
+                //weight with the original height
+                add += dh * (rowPos[r + 1] - prev) / tot;
+                prev = rowPos[r + 1];
+                rowPos[r + 1] += add;
+            }
+        }
+    }
+
+    int leftOffset = hspacing;
+
+    int nEffCols = table()->numEffCols();
+    for (int r = 0; r < totalRows; r++) {
+       Row *row = grid[r].row;
+       int totalCols = row->size();
+        for (int c = 0; c < nEffCols; c++) {
+            CellStruct current = cellAt(r, c);
+            RenderTableCell* cell = current.cell;
+            
+            if (!cell)
+                continue;
+            if (r < totalRows - 1 && cell == cellAt(r + 1, c).cell)
+               continue;
+
+            if ((rindx = r-cell->rowSpan() + 1) < 0)
+                rindx = 0;
+
+            rHeight = rowPos[r + 1] - rowPos[rindx] - vspacing;
+            
+            // Force percent height children to lay themselves out again.
+            // This will cause these children to grow to fill the cell.
+            // FIXME: There is still more work to do here to fully match WinIE (should
+            // it become necessary to do so).  In quirks mode, WinIE behaves like we
+            // do, but it will clip the cells that spill out of the table section.  In
+            // strict mode, Mozilla and WinIE both regrow the table to accommodate the
+            // new height of the cell (thus letting the percentages cause growth one
+            // time only).  We may also not be handling row-spanning cells correctly.
+            //
+            // Note also the oddity where replaced elements always flex, and yet blocks/tables do
+            // not necessarily flex.  WinIE is crazy and inconsistent, and we can't hope to
+            // match the behavior perfectly, but we'll continue to refine it as we discover new
+            // bugs. :)
+            bool cellChildrenFlex = false;
+            bool flexAllChildren = cell->style()->height().isFixed() || 
+                (!table()->style()->height().isAuto() && rHeight != cell->height());
+
+            for (RenderObject* o = cell->firstChild(); o; o = o->nextSibling()) {
+                if (!o->isText() && o->style()->height().isPercent() && (o->isReplaced() || o->scrollsOverflow() || flexAllChildren)) {
+                    // Tables with no sections do not flex.
+                    if (!o->isTable() || static_cast<RenderTable*>(o)->hasSections()) {
+                        o->setNeedsLayout(true, false);
+                        cell->setChildNeedsLayout(true, false);
+                        cellChildrenFlex = true;
+                    }
+                }
+            }
+            if (cellChildrenFlex) {
+                cell->setOverrideSize(kMax(0, 
+                                           rHeight - cell->borderTop() - cell->paddingTop() - 
+                                                     cell->borderBottom() - cell->paddingBottom()));
+                cell->layoutIfNeeded();
+
+                // Alignment within a cell is based off the calculated
+                // height, which becomes irrelevant once the cell has
+                // been resized based off its percentage. -dwh
+                cell->setCellTopExtra(0);
+                cell->setCellBottomExtra(0);
+            }
+            else {
+                EVerticalAlign va = cell->style()->verticalAlign();
+                int te = 0;
+                switch (va) {
+                    case SUB:
+                    case SUPER:
+                    case TEXT_TOP:
+                    case TEXT_BOTTOM:
+                    case BASELINE:
+                        te = getBaseline(r) - cell->baselinePosition() ;
+                        break;
+                    case TOP:
+                        te = 0;
+                        break;
+                    case MIDDLE:
+                        te = (rHeight - cell->height())/2;
+                        break;
+                    case BOTTOM:
+                        te = rHeight - cell->height();
+                        break;
+                    default:
+                        break;
+                }
+                
+                cell->setCellTopExtra(te);
+                cell->setCellBottomExtra(rHeight - cell->height() - te);
+            }
+            
+            int oldCellX = cell->xPos();
+            int oldCellY = cell->yPos();
+        
+            if (style()->direction() == RTL) {
+                cell->setPos(
+                   table()->columnPos[(int)totalCols] -
+                   table()->columnPos[table()->colToEffCol(cell->col()+cell->colSpan())] +
+                   leftOffset,
+                    rowPos[rindx]);
+            } else
+                cell->setPos(table()->columnPos[c] + leftOffset, rowPos[rindx]);
+
+            // If the cell moved, we have to repaint it as well as any floating/positioned
+            // descendants.  An exception is if we need a layout.  In this case, we know we're going to
+            // repaint ourselves (and the cell) anyway.
+            if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout())
+                cell->repaintDuringLayoutIfMoved(oldCellX, oldCellY);
+        }
+    }
+
+    m_height = rowPos[totalRows];
+    return m_height;
+}
+
+
+void RenderTableSection::paint(PaintInfo& i, int tx, int ty)
+{
+    unsigned int totalRows = gridRows;
+    unsigned int totalCols = table()->columns.size();
+
+    tx += m_x;
+    ty += m_y;
+
+    // check which rows and cols are visible and only paint these
+    // ### fixme: could use a binary search here
+    PaintAction paintAction = i.phase;
+    int x = i.r.x();
+    int y = i.r.y();
+    int w = i.r.width();
+    int h = i.r.height();
+
+    int os = 2 * maximalOutlineSize(paintAction);
+    unsigned int startrow = 0;
+    unsigned int endrow = totalRows;
+    for (; startrow < totalRows; startrow++)
+       if (ty + rowPos[startrow+1] >= y - os)
+           break;
+
+    for (; endrow > 0; endrow--)
+       if ( ty + rowPos[endrow-1] <= y + h + os)
+            break;
+
+    unsigned int startcol = 0;
+    unsigned int endcol = totalCols;
+    if (style()->direction() == LTR) {
+       for (; startcol < totalCols; startcol++) {
+           if (tx + table()->columnPos[startcol + 1] >= x - os)
+                break;
+       }
+       for (; endcol > 0; endcol--) {
+           if (tx + table()->columnPos[endcol - 1] <= x + w + os)
+               break;
+       }
+    }
+
+    if (startcol < endcol) {
+       // draw the cells
+       for (unsigned int r = startrow; r < endrow; r++) {
+           unsigned int c = startcol;
+           // since a cell can be -1 (indicating a colspan) we might have to search backwards to include it
+           while (c && cellAt(r, c).inColSpan)
+               c--;
+           for (; c < endcol; c++) {
+                CellStruct current = cellAt(r, c);
+                RenderTableCell *cell = current.cell;
+               
+                if (!cell || (cell->layer() && i.phase != PaintActionCollapsedTableBorders)) 
+                   continue;
+                
+                // Cells must always paint in the order in which they appear taking into account
+                // their upper left originating row/column.  For cells with rowspans, avoid repainting
+                // if we've already seen the cell.
+               if (r > startrow && (cellAt(r-1, c).cell == cell))
+                   continue;
+
+               cell->paint(i, tx, ty);
+           }
+       }
+    }
+}
+
+void RenderTableSection::recalcCells()
+{
+    cCol = 0;
+    cRow = -1;
+    clearGrid();
+    gridRows = 0;
+
+    for (RenderObject *row = firstChild(); row; row = row->nextSibling()) {
+       cRow++;
+       cCol = 0;
+       ensureRows(cRow + 1);
+       for (RenderObject *cell = row->firstChild(); cell; cell = cell->nextSibling())
+           if (cell->isTableCell())
+               addCell(static_cast<RenderTableCell *>(cell));
+    }
+    needCellRecalc = false;
+    setNeedsLayout(true);
+}
+
+void RenderTableSection::clearGrid()
+{
+    int rows = gridRows;
+    while (rows--)
+       delete grid[rows].row;
+}
+
+RenderObject* RenderTableSection::removeChildNode(RenderObject* child)
+{
+    setNeedCellRecalc();
+    return RenderContainer::removeChildNode(child);
+}
+
+#ifndef NDEBUG
+void RenderTableSection::dump(QTextStream *stream, QString ind) const
+{
+    *stream << endl << ind << "grid=(" << grid.size() << "," << table()->numEffCols() << ")" << endl << ind;
+    for (unsigned int r = 0; r < grid.size(); r++) {
+       for (int c = 0; c < table()->numEffCols(); c++) {
+           if (cellAt( r, c).cell && !cellAt(r, c).inColSpan)
+               *stream << "(" << cellAt(r, c).cell->row() << "," << cellAt(r, c).cell->col() << ","
+                       << cellAt(r, c).cell->rowSpan() << "," << cellAt(r, c).cell->colSpan() << ") ";
+           else
+               *stream << cellAt(r, c).cell << "null cell ";
+       }
+       *stream << endl << ind;
+    }
+    RenderContainer::dump(stream,ind);
+}
+#endif
+
+}
diff --git a/WebCore/rendering/RenderTableSection.h b/WebCore/rendering/RenderTableSection.h
new file mode 100644 (file)
index 0000000..b8b9487
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1997 Martin Jones (mjones@kde.org)
+ *           (C) 1997 Torben Weis (weis@kde.org)
+ *           (C) 1998 Waldo Bastian (bastian@kde.org)
+ *           (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef RenderTableSection_H
+#define RenderTableSection_H
+
+#include "RenderContainer.h"
+#include "RenderTable.h"
+
+namespace WebCore {
+
+class RenderTableCell;
+
+class RenderTableSection : public RenderContainer
+{
+public:
+    RenderTableSection(DOM::NodeImpl* node);
+    ~RenderTableSection();
+    virtual void destroy();
+
+    virtual void setStyle(RenderStyle *style);
+
+    virtual const char *renderName() const { return "RenderTableSection"; }
+
+    // overrides
+    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
+    virtual bool isTableSection() const { return true; }
+
+    virtual short lineHeight(bool) const { return 0; }
+    virtual void position(int, int, int, int, int, bool, bool, int) {}
+
+#ifndef NDEBUG
+    virtual void dump(QTextStream *stream, QString ind = "") const;
+#endif
+
+    void addCell(RenderTableCell *cell);
+
+    void setCellWidths();
+    void calcRowHeight();
+    int layoutRows(int height);
+
+    RenderTable *table() const { return static_cast<RenderTable *>(parent()); }
+
+    struct CellStruct {
+        RenderTableCell *cell;
+        bool inColSpan; // true for columns after the first in a colspan
+    };
+    typedef Array<CellStruct> Row;
+    struct RowStruct {
+       Row *row;
+       int baseLine;
+       Length height;
+    };
+
+    CellStruct& cellAt(int row,  int col) {
+       return (*grid[row].row)[col];
+    }
+    const CellStruct& cellAt(int row, int col) const {
+       return (*grid[row].row)[col];
+    }
+
+    virtual void paint(PaintInfo& i, int tx, int ty);
+
+    int numRows() const { return gridRows; }
+    int getBaseline(int row) {return grid[row].baseLine;}
+
+    void setNeedCellRecalc() {
+        needCellRecalc = true;
+        table()->setNeedSectionRecalc();
+    }
+
+    virtual RenderObject* removeChildNode(RenderObject* child);
+
+    // this gets a cell grid data structure. changing the number of
+    // columns is done by the table
+    Array<RowStruct> grid;
+    int gridRows;
+    Array<int> rowPos;
+
+    int cCol;
+    int cRow;
+    bool needCellRecalc;
+
+    void recalcCells();
+protected:
+    bool ensureRows(int numRows);
+    void clearGrid();
+};
+
+}
+#endif
index d4a31d5..e006fe4 100644 (file)
@@ -29,7 +29,7 @@
 #include "break_lines.h"
 #include "dom2_rangeimpl.h"
 #include "render_arena.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "visible_position.h"
 #include <kxmlcore/AlwaysInline.h>
 #include <qpen.h>
index 80ecf90..c9abf18 100644 (file)
@@ -28,7 +28,7 @@
 #include "FrameView.h"
 #include <kxmlcore/AlwaysInline.h>
 #include "render_arena.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_canvas.h"
 #include "InlineTextBox.h"
 
index d5fe448..28b0241 100644 (file)
  * Boston, MA 02111-1307, USA.
  *
  */
-// -------------------------------------------------------------------------
-//#define DEBUG_LAYOUT
-
 
 #include "config.h"
 #include <qpainter.h>
 #include <qpen.h>
 
-#include "rendering/render_box.h"
-#include "rendering/render_replaced.h"
-#include "rendering/render_canvas.h"
-#include "rendering/render_table.h"
+#include "render_box.h"
+#include "render_replaced.h"
+#include "render_canvas.h"
 #include "render_flexbox.h"
 #include "render_arena.h"
 #include "render_theme.h"
+#include "RenderTableCell.h"
 
 #include "DocumentImpl.h"
 #include "HTMLElementImpl.h"
index ec78781..7b0815d 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef render_canvas_h
 #define render_canvas_h
 
-#include "render_block.h"
+#include "RenderBlock.h"
 #include <kxmlcore/HashSet.h>
 
 class FrameView;
index 6875279..d60f847 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef RENDER_FLEXIBLE_BOX_H
 #define RENDER_FLEXIBLE_BOX_H
 
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_style.h"
 
 namespace khtml {
index 8030baa..bc43d2c 100644 (file)
 
 #include "rendering/render_flow.h"
 #include "InlineTextBox.h"
-#include "rendering/render_table.h"
 #include "rendering/render_canvas.h"
 #include "DocumentImpl.h"
 #include "render_inline.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_arena.h"
 #include "render_line.h"
 #include "htmlnames.h"
index f993c68..289f5b2 100644 (file)
 #ifndef RENDER_FLOW_H
 #define RENDER_FLOW_H
 
-#include "render_container.h"
+#include "RenderContainer.h"
 #include "bidi.h"
 #include "render_line.h"
 
-namespace khtml {
+namespace WebCore {
 
 /**
  * all geometry managing stuff is only in the block elements.
index ed72139..15f84a2 100644 (file)
@@ -25,9 +25,9 @@
 #ifndef RENDER_FORM_H
 #define RENDER_FORM_H
 
-#include "rendering/render_replaced.h"
-#include "rendering/render_image.h"
-#include "rendering/render_block.h"
+#include "render_replaced.h"
+#include "render_image.h"
+#include "RenderBlock.h"
 
 class QWidget;
 class QListboxItem;
@@ -41,13 +41,10 @@ class QListBox;
 #include "HTMLSelectElementImpl.h"
 #include "HTMLTextAreaElementImpl.h"
 
-namespace DOM {
-    class HTMLFormElementImpl;
-    class HTMLGenericFormElementImpl;
-};
-
-namespace khtml {
+namespace WebCore {
 
+class HTMLFormElementImpl;
+class HTMLGenericFormElementImpl;
 class DocLoader;
 
 // -------------------------------------------------------------------------
index 2da1306..705cf96 100644 (file)
 #ifndef __render_frames_h__
 #define __render_frames_h__
 
-#include "render_container.h"
-#include "rendering/render_replaced.h"
-#include "html/html_baseimpl.h"
+#include "RenderContainer.h"
+#include "render_replaced.h"
+#include "html_baseimpl.h"
+
 class FrameView;
 
-namespace DOM
+namespace WebCore
 {
   class HTMLFrameElementImpl;
   class HTMLElementImpl;
   class MouseEventImpl;
-};
 
-namespace khtml
-{
   struct ChildFrame;
 
 class RenderFrameSet : public RenderContainer
index 3810659..7e35966 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "DocumentImpl.h"
 #include "render_arena.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "visible_position.h"
 
 namespace WebCore {
index c44b441..b80aada 100644 (file)
@@ -86,7 +86,7 @@ private:
     bool m_isContinuation : 1; // Whether or not we're a continuation of an inline.
 };
 
-}; // namespace
+} // namespace
 
-#endif // RENDER_BLOCK_H
+#endif
 
index fa908dd..8099907 100644 (file)
 // -------------------------------------------------------------------------
 
 #include "config.h"
-#include <kdebug.h>
 #include <assert.h>
 #include <qpainter.h>
 #include <qpen.h>
 
-#include "rendering/render_flow.h"
 #include "InlineTextBox.h"
-#include "rendering/render_table.h"
 #include "DocumentImpl.h"
 #include "CachedImage.h"
 #include "render_inline.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_arena.h"
 #include "render_line.h"
-
-using namespace DOM;
+#include "RenderTableCell.h"
 
 #ifndef NDEBUG
 static bool inInlineBoxDetach;
 #endif
 
-namespace khtml {
+namespace WebCore {
     
 class EllipsisBox : public InlineBox
 {
index 7626424..e4ac78c 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef RENDER_LIST_H
 #define RENDER_LIST_H
 
-#include "render_block.h"
+#include "RenderBlock.h"
 
 // ### list-style-position, list-style-image is still missing
 
index 52da9f7..80b78d8 100644 (file)
 #include "visible_position.h"
 #include "htmlnames.h"
 #include "render_arena.h"
-#include "render_block.h"
+#include "RenderBlock.h"
 #include "render_canvas.h"
 #include "render_flexbox.h"
 #include "render_inline.h"
 #include "render_line.h"
 #include "render_list.h"
-#include "render_table.h"
+#include "RenderTable.h"
+#include "RenderTableRow.h"
+#include "RenderTableCol.h"
+#include "RenderTableCell.h"
+
 #include <assert.h>
 #include <kdebug.h>
 #include <qpainter.h>
index 4c14af1..3659116 100644 (file)
 #ifndef render_replaced_h
 #define render_replaced_h
 
-#include "render_container.h"
+#include "render_box.h"
 #include <qobject.h>
+
 class FrameView;
 class QWidget;
 
-namespace DOM {
-    class Position;
-}
+namespace WebCore {
 
-namespace khtml {
+    class Position;
 
 class RenderReplaced : public RenderBox
 {
diff --git a/WebCore/rendering/render_table.cpp b/WebCore/rendering/render_table.cpp
deleted file mode 100644 (file)
index ce20655..0000000
+++ /dev/null
@@ -1,2258 +0,0 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 1997 Martin Jones (mjones@kde.org)
- *           (C) 1997 Torben Weis (weis@kde.org)
- *           (C) 1998 Waldo Bastian (bastian@kde.org)
- *           (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-//#define TABLE_DEBUG
-//#define TABLE_PRINT
-//#define DEBUG_LAYOUT
-//#define BOX_DEBUG
-#include "config.h"
-#include "rendering/render_table.h"
-#include "rendering/table_layout.h"
-#include "html/html_tableimpl.h"
-#include "htmlnames.h"
-#include "DocumentImpl.h"
-
-#include <qapplication.h>
-#include <qstyle.h>
-
-#include <kdebug.h>
-#include <assert.h>
-
-using namespace khtml;
-using namespace DOM;
-using namespace HTMLNames;
-
-RenderTable::RenderTable(DOM::NodeImpl* node)
-    : RenderBlock(node)
-{
-    tCaption = 0;
-    head = foot = firstBody = 0;
-    tableLayout = 0;
-    m_currentBorder = 0;
-    
-    rules = None;
-    frame = Void;
-    has_col_elems = false;
-    hspacing = 0;
-    vspacing = 0;
-    padding = 0;
-    needSectionRecalc = false;
-    padding = 0;
-
-    columnPos.resize(2);
-    columnPos.fill(0);
-    columns.resize(1);
-    columns.fill(ColumnStruct());
-
-    columnPos[0] = 0;
-}
-
-RenderTable::~RenderTable()
-{
-    delete tableLayout;
-}
-
-void RenderTable::setStyle(RenderStyle *_style)
-{
-    ETableLayout oldTableLayout = style() ? style()->tableLayout() : TAUTO;
-    RenderBlock::setStyle(_style);
-
-    // In the collapsed border model, there is no cell spacing.
-    hspacing = collapseBorders() ? 0 : style()->horizontalBorderSpacing();
-    vspacing = collapseBorders() ? 0 : style()->verticalBorderSpacing();
-    columnPos[0] = hspacing;
-
-    if (!tableLayout || style()->tableLayout() != oldTableLayout) {
-       delete tableLayout;
-
-        // According to the CSS2 spec, you only use fixed table layout if an
-        // explicit width is specified on the table.  Auto width implies auto table layout.
-       if (style()->tableLayout() == TFIXED && !style()->width().isAuto())
-           tableLayout = new FixedTableLayout(this);
-       else
-           tableLayout = new AutoTableLayout(this);
-    }
-}
-
-void RenderTable::addChild(RenderObject *child, RenderObject *beforeChild)
-{
-    RenderObject *o = child;
-
-    if (child->element() && child->element()->hasTagName(formTag)) {
-        RenderContainer::addChild(child,beforeChild);
-        return;
-    }
-
-    switch (child->style()->display()) {
-        case TABLE_CAPTION:
-            tCaption = static_cast<RenderBlock *>(child);
-            break;
-        case TABLE_COLUMN:
-        case TABLE_COLUMN_GROUP:
-            has_col_elems = true;
-            break;
-        case TABLE_HEADER_GROUP:
-            if (!head)
-                head = static_cast<RenderTableSection *>(child);
-            else if (!firstBody)
-                firstBody = static_cast<RenderTableSection *>(child);
-            break;
-        case TABLE_FOOTER_GROUP:
-            if (!foot) {
-                foot = static_cast<RenderTableSection *>(child);
-                break;
-            }
-            // fall through
-        case TABLE_ROW_GROUP:
-            if (!firstBody)
-                firstBody = static_cast<RenderTableSection *>(child);
-            break;
-        default:
-            if (!beforeChild && lastChild() &&
-                lastChild()->isTableSection() && lastChild()->isAnonymous()) {
-                o = lastChild();
-            } else {
-                RenderObject *lastBox = beforeChild;
-                RenderObject *nextToLastBox = beforeChild;
-                while (lastBox && lastBox->parent()->isAnonymous() &&
-                        !lastBox->isTableSection() && lastBox->style()->display() != TABLE_CAPTION) {
-                    nextToLastBox = lastBox;
-                    lastBox = lastBox->parent();
-                }
-                if (lastBox && lastBox->isAnonymous()) {
-                    lastBox->addChild(child, nextToLastBox);
-                    return;
-                } else {
-                    if (beforeChild && !beforeChild->isTableSection())
-                        beforeChild = 0;
-                    o = new (renderArena()) RenderTableSection(document() /* anonymous */);
-                    RenderStyle *newStyle = new (renderArena()) RenderStyle();
-                    newStyle->inheritFrom(style());
-                    newStyle->setDisplay(TABLE_ROW_GROUP);
-                    o->setStyle(newStyle);
-                    addChild(o, beforeChild);
-                }
-            }
-            o->addChild(child);
-            child->setNeedsLayoutAndMinMaxRecalc();
-            return;
-    }
-    RenderContainer::addChild(child,beforeChild);
-}
-
-
-
-void RenderTable::calcWidth()
-{
-    if (isPositioned())
-        calcAbsoluteHorizontal();
-
-    RenderBlock *cb = containingBlock();
-    int availableWidth = cb->contentWidth();
-
-    LengthType widthType = style()->width().type;
-    if (widthType > Relative && style()->width().value > 0) {
-       // Percent or fixed table
-        m_width = style()->width().minWidth(availableWidth);
-        if (m_minWidth > m_width) m_width = m_minWidth;
-    } else {
-        // An auto width table should shrink to fit within the line width if necessary in order to 
-        // avoid overlapping floats.
-        availableWidth = cb->lineWidth(m_y);
-        
-        // Subtract out any fixed margins from our available width for auto width tables.
-        int marginTotal = 0;
-        if (style()->marginLeft().type != Auto)
-            marginTotal += style()->marginLeft().width(availableWidth);
-        if (style()->marginRight().type != Auto)
-            marginTotal += style()->marginRight().width(availableWidth);
-            
-        // Subtract out our margins to get the available content width.
-        int availContentWidth = kMax(0, availableWidth - marginTotal);
-        
-        // Ensure we aren't bigger than our max width or smaller than our min width.
-        m_width = kMin(availContentWidth, m_maxWidth);
-    }
-    
-    m_width = kMax(m_width, m_minWidth);
-
-    // Finally, with our true width determined, compute our margins for real.
-    m_marginRight = 0;
-    m_marginLeft = 0;
-    calcHorizontalMargins(style()->marginLeft(),style()->marginRight(),availableWidth);
-}
-
-void RenderTable::layout()
-{
-    KHTMLAssert(needsLayout());
-    KHTMLAssert(minMaxKnown());
-    KHTMLAssert(!needSectionRecalc);
-
-    if (posChildNeedsLayout() && !normalChildNeedsLayout() && !selfNeedsLayout()) {
-        // All we have to is lay out our positioned objects.
-        layoutPositionedObjects(true);
-        setNeedsLayout(false);
-        return;
-    }
-
-    IntRect oldBounds, oldFullBounds;
-    bool checkForRepaint = checkForRepaintDuringLayout();
-    if (checkForRepaint)
-        getAbsoluteRepaintRectIncludingFloats(oldBounds, oldFullBounds);
-    
-    m_height = m_overflowHeight = 0;
-    initMaxMarginValues();
-    
-    //int oldWidth = m_width;
-    calcWidth();
-    m_overflowWidth = m_width;
-
-    // the optimisation below doesn't work since the internal table
-    // layout could have changed.  we need to add a flag to the table
-    // layout that tells us if something has changed in the min max
-    // calculations to do it correctly.
-//     if ( oldWidth != m_width || columns.size() + 1 != columnPos.size() )
-    tableLayout->layout();
-
-    setCellWidths();
-
-    // layout child objects
-    int calculatedHeight = 0;
-
-    RenderObject *child = firstChild();
-    while(child) {
-       if (child->needsLayout() && !(child->element() && child->element()->hasTagName(formTag)))
-           child->layout();
-       if (child->isTableSection()) {
-           static_cast<RenderTableSection *>(child)->calcRowHeight();
-           calculatedHeight += static_cast<RenderTableSection *>(child)->layoutRows(0);
-       }
-       child = child->nextSibling();
-    }
-
-    // ### collapse caption margin
-    if (tCaption && tCaption->style()->captionSide() != CAPBOTTOM) {
-        tCaption->setPos(tCaption->marginLeft(), m_height);
-        m_height += tCaption->height() + tCaption->marginTop() + tCaption->marginBottom();
-    }
-
-    int bpTop = borderTop() + (collapseBorders() ? 0 : paddingTop());
-    int bpBottom = borderBottom() + (collapseBorders() ? 0 : paddingBottom());
-    
-    m_height += bpTop;
-
-    int oldHeight = m_height;
-    calcHeight();
-    int newHeight = m_height;
-    m_height = oldHeight;
-
-    Length h = style()->height();
-    int th = 0;
-    if (isPositioned())
-        th = newHeight; // FIXME: Leave this alone for now but investigate later.
-    else if (h.isFixed())
-        th = h.value - (bpTop + bpBottom);  // Tables size as though CSS height includes border/padding.
-    else if (h.isPercent())
-        th = calcPercentageHeight(h);
-    th = kMax(0, th);
-
-    // layout rows
-    if (th > calculatedHeight) {
-       // we have to redistribute that height to get the constraint correctly
-       // just force the first body to the height needed
-       // ### FIXME This should take height constraints on all table sections into account and distribute
-       // accordingly. For now this should be good enough
-        if (firstBody) {
-            firstBody->calcRowHeight();
-            firstBody->layoutRows(th - calculatedHeight);
-        }
-        else if (!style()->htmlHacks()) {
-            // Completely empty tables (with no sections or anything) should at least honor specified height
-            // in strict mode.
-            m_height += th;
-        }
-    }
-    
-    int bl = borderLeft();
-    if (!collapseBorders())
-        bl += paddingLeft();
-
-    // position the table sections
-    if (head) {
-       head->setPos(bl, m_height);
-       m_height += head->height();
-    }
-    for (RenderObject *body = firstBody; body; body = body->nextSibling()) {
-       if (body != head && body != foot && body->isTableSection()) {
-           body->setPos(bl, m_height);
-           m_height += body->height();
-       }
-    }
-    if (foot) {
-       foot->setPos(bl, m_height);
-       m_height += foot->height();
-    }
-
-    m_height += bpBottom;
-               
-    if (tCaption && tCaption->style()->captionSide()==CAPBOTTOM) {
-        tCaption->setPos(tCaption->marginLeft(), m_height);
-        m_height += tCaption->height() + tCaption->marginTop() + tCaption->marginBottom();
-    }
-
-    // table can be containing block of positioned elements.
-    // ### only pass true if width or height changed.
-    layoutPositionedObjects( true );
-
-    // Repaint with our new bounds if they are different from our old bounds.
-    if (checkForRepaint)
-        repaintAfterLayoutIfNeeded(oldBounds, oldFullBounds);
-    
-    m_overflowHeight = kMax(m_overflowHeight, m_height);
-    m_overflowWidth = kMax(m_overflowWidth, m_width);
-
-    setNeedsLayout(false);
-}
-
-void RenderTable::setCellWidths()
-{
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
-       if ( child->isTableSection() )
-           static_cast<RenderTableSection *>(child)->setCellWidths();
-}
-
-void RenderTable::paint(PaintInfo& i, int _tx, int _ty)
-{
-    _tx += xPos();
-    _ty += yPos();
-
-    PaintAction paintAction = i.phase;
-    
-    int os = 2*maximalOutlineSize(paintAction);
-    if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + height() <= i.r.y() - os))
-        return;
-    if ((_tx >= i.r.x() + i.r.width() + os) || (_tx + width() <= i.r.x() - os))
-        return;
-
-    if ((paintAction == PaintActionBlockBackground || paintAction == PaintActionChildBlockBackground)
-        && shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE)
-        paintBoxDecorations(i, _tx, _ty);
-
-    // We're done.  We don't bother painting any children.
-    if (paintAction == PaintActionBlockBackground)
-        return;
-    // We don't paint our own background, but we do let the kids paint their backgrounds.
-    if (paintAction == PaintActionChildBlockBackgrounds)
-        paintAction = PaintActionChildBlockBackground;
-    PaintInfo paintInfo(i.p, i.r, paintAction, paintingRootForChildren(i));
-    
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
-        if (child->isTableSection() || child == tCaption)
-           child->paint(paintInfo, _tx, _ty);
-
-    if (collapseBorders() && paintAction == PaintActionChildBlockBackground && style()->visibility() == VISIBLE) {
-        // Collect all the unique border styles that we want to paint in a sorted list.  Once we
-        // have all the styles sorted, we then do individual passes, painting each style of border
-        // from lowest precedence to highest precedence.
-        paintInfo.phase = PaintActionCollapsedTableBorders;
-        QValueList<CollapsedBorderValue> borderStyles;
-        collectBorders(borderStyles);
-        QValueListIterator<CollapsedBorderValue> it = borderStyles.begin();
-        QValueListIterator<CollapsedBorderValue> end = borderStyles.end();
-        for (; it != end; ++it) {
-            m_currentBorder = &(*it);
-            for (RenderObject* child = firstChild(); child; child = child->nextSibling())
-                if (child->isTableSection())
-                    child->paint(paintInfo, _tx, _ty);
-        }
-    }
-        
-#ifdef BOX_DEBUG
-    outlineBox(i.p, _tx, _ty, "blue");
-#endif
-}
-
-void RenderTable::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
-{
-    int w = width();
-    int h = height();
-    
-    // Account for the caption.
-    if (tCaption) {
-        int captionHeight = (tCaption->height() + tCaption->marginBottom() +  tCaption->marginTop());
-        h -= captionHeight;
-        if (tCaption->style()->captionSide() != CAPBOTTOM)
-            _ty += captionHeight;
-    }
-
-    int my = kMax(_ty, i.r.y());
-    int mh;
-    if (_ty < i.r.y())
-        mh= kMax(0, h - (i.r.y() - _ty));
-    else
-        mh = kMin(i.r.height(), h);
-    
-    paintBackground(i.p, style()->backgroundColor(), style()->backgroundLayers(), my, mh, _tx, _ty, w, h);
-    
-    if (style()->hasBorder() && !collapseBorders())
-        paintBorder(i.p, _tx, _ty, w, h, style());
-}
-
-void RenderTable::calcMinMaxWidth()
-{
-    KHTMLAssert(!minMaxKnown());
-
-    if (needSectionRecalc)
-       recalcSections();
-
-    tableLayout->calcMinMaxWidth();
-
-    if (tCaption && tCaption->minWidth() > m_minWidth)
-        m_minWidth = tCaption->minWidth();
-
-    setMinMaxKnown();
-}
-
-void RenderTable::splitColumn(int pos, int firstSpan)
-{
-    // we need to add a new columnStruct
-    int oldSize = columns.size();
-    columns.resize(oldSize + 1);
-    int oldSpan = columns[pos].span;
-//     qDebug("splitColumn( %d,%d ), oldSize=%d, oldSpan=%d", pos, firstSpan, oldSize, oldSpan );
-    KHTMLAssert(oldSpan > firstSpan);
-    columns[pos].span = firstSpan;
-    memmove(columns.data() + pos + 1, columns.data() + pos, (oldSize-pos)*sizeof(ColumnStruct));
-    columns[pos+1].span = oldSpan - firstSpan;
-
-    // change width of all rows.
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
-       if (child->isTableSection()) {
-           RenderTableSection *section = static_cast<RenderTableSection *>(child);
-           if (section->cCol > pos)
-               section->cCol++;
-           int size = section->numRows();
-           for (int row = 0; row < size; ++row) {
-               section->grid[row].row->resize(oldSize + 1);
-               RenderTableSection::Row &r = *section->grid[row].row;
-               memmove(r.data() + pos + 1, r.data() + pos, (oldSize - pos) * sizeof(RenderTableSection::CellStruct));
-               r[pos + 1].cell = 0;
-                r[pos + 1].inColSpan = r[pos].inColSpan || r[pos].cell;
-           }
-       }
-    }
-    columnPos.resize(numEffCols() + 1);
-    setNeedsLayoutAndMinMaxRecalc();
-}
-
-void RenderTable::appendColumn(int span)
-{
-    // easy case.
-    int pos = columns.size();
-    int newSize = pos + 1;
-    columns.resize(newSize);
-    columns[pos].span = span;
-
-    // change width of all rows.
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
-       if (child->isTableSection()) {
-           RenderTableSection *section = static_cast<RenderTableSection *>(child);
-           int size = section->numRows();
-           for (int row = 0; row < size; ++row) {
-               section->grid[row].row->resize(newSize);
-                RenderTableSection::CellStruct& c = section->cellAt(row, pos);
-               c.cell = 0;
-               c.inColSpan = false;
-           }
-       }
-    }
-    columnPos.resize(numEffCols() + 1);
-    setNeedsLayoutAndMinMaxRecalc();
-}
-
-RenderTableCol *RenderTable::colElement(int col) {
-    if (!has_col_elems)
-       return 0;
-    RenderObject *child = firstChild();
-    int cCol = 0;
-    while (child) {
-       if (child->isTableCol()) {
-           RenderTableCol *colElem = static_cast<RenderTableCol *>(child);
-           int span = colElem->span();
-           if (!colElem->firstChild()) {
-               cCol += span;
-               if (cCol > col)
-                   return colElem;
-           }
-
-           RenderObject *next = child->firstChild();
-           if (!next)
-               next = child->nextSibling();
-           if (!next && child->parent()->isTableCol())
-               next = child->parent()->nextSibling();
-           child = next;
-       } else if (child == tCaption)
-            child = child->nextSibling();
-        else
-           break;
-    }
-    return 0;
-}
-
-void RenderTable::recalcSections()
-{
-    tCaption = 0;
-    head = foot = firstBody = 0;
-    has_col_elems = false;
-
-    // We need to get valid pointers to caption, head, foot and firstbody again
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
-       switch (child->style()->display()) {
-            case TABLE_CAPTION:
-                if (!tCaption) {
-                    tCaption = static_cast<RenderBlock*>(child);
-                    tCaption->setNeedsLayout(true);
-                }
-                break;
-            case TABLE_COLUMN:
-            case TABLE_COLUMN_GROUP:
-                has_col_elems = true;
-                break;
-            case TABLE_HEADER_GROUP: {
-                RenderTableSection *section = static_cast<RenderTableSection *>(child);
-                if (!head)
-                    head = section;
-                else if (!firstBody)
-                    firstBody = section;
-                if (section->needCellRecalc)
-                    section->recalcCells();
-                break;
-            }
-            case TABLE_FOOTER_GROUP: {
-                RenderTableSection *section = static_cast<RenderTableSection *>(child);
-                if (!foot)
-                    foot = section;
-                else if (!firstBody)
-                    firstBody = section;
-                if (section->needCellRecalc)
-                    section->recalcCells();
-                break;
-            }
-            case TABLE_ROW_GROUP: {
-                RenderTableSection *section = static_cast<RenderTableSection *>(child);
-                if (!firstBody)
-                    firstBody = section;
-                if (section->needCellRecalc)
-                    section->recalcCells();
-            }
-            default:
-                break;
-       }
-    }
-    needSectionRecalc = false;
-    setNeedsLayout(true);
-}
-
-RenderObject* RenderTable::removeChildNode(RenderObject* child)
-{
-    setNeedSectionRecalc();
-    return RenderContainer::removeChildNode(child);
-}
-
-int RenderTable::borderLeft() const
-{
-    if (collapseBorders()) {
-        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
-        // but I'm working to get this changed.  For now, follow the spec.
-        return 0;
-    }
-    return RenderBlock::borderLeft();
-}
-    
-int RenderTable::borderRight() const
-{
-    if (collapseBorders()) {
-        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
-        // but I'm working to get this changed.  For now, follow the spec.
-        return 0;
-    }
-    return RenderBlock::borderRight();
-}
-
-int RenderTable::borderTop() const
-{
-    if (collapseBorders()) {
-        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
-        // but I'm working to get this changed.  For now, follow the spec.
-        return 0;
-    }
-    return RenderBlock::borderTop();
-}
-
-int RenderTable::borderBottom() const
-{
-    if (collapseBorders()) {
-        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
-        // but I'm working to get this changed.  For now, follow the spec.
-        return 0;
-    }
-    return RenderBlock::borderBottom();
-}
-
-RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
-{
-    // Find the section and row to look in
-    int r = cell->row();
-    RenderTableSection* section = 0;
-    int rAbove = -1;
-    if (r > 0) {
-        // cell is not in the first row, so use the above row in its own section
-        section = cell->section();
-        rAbove = r-1;
-    } else {
-        // cell is at top of a section, use last row in previous section
-        for (RenderObject *prevSection = cell->section()->previousSibling();
-             prevSection && rAbove < 0;
-             prevSection = prevSection->previousSibling()) {
-            if (prevSection->isTableSection()) {
-                section = static_cast<RenderTableSection *>(prevSection);
-                if (section->numRows() > 0)
-                    rAbove = section->numRows()-1;
-            }
-        }
-    }
-
-    // Look up the cell in the section's grid, which requires effective col index
-    if (section && rAbove >= 0) {
-        int effCol = colToEffCol(cell->col());
-        RenderTableSection::CellStruct aboveCell;
-        // If we hit a span back up to a real cell.
-        do {
-            aboveCell = section->cellAt(rAbove, effCol);
-            effCol--;
-        } while (!aboveCell.cell && aboveCell.inColSpan && effCol >=0);
-        return aboveCell.cell;
-    } else
-        return 0;
-}
-
-RenderTableCell* RenderTable::cellBelow(const RenderTableCell* cell) const
-{
-    // Find the section and row to look in
-    int r = cell->row() + cell->rowSpan() - 1;
-    RenderTableSection* section = 0;
-    int rBelow = -1;
-    if (r < cell->section()->numRows() - 1) {
-        // The cell is not in the last row, so use the next row in the section.
-        section = cell->section();
-        rBelow= r+1;
-    } else {
-        // The cell is at the bottom of a section. Use the first row in the next section.
-        for (RenderObject* nextSection = cell->section()->nextSibling();
-             nextSection && rBelow < 0;
-             nextSection = nextSection->nextSibling()) {
-            if (nextSection->isTableSection()) {
-                section = static_cast<RenderTableSection *>(nextSection);
-                if (section->numRows() > 0)
-                    rBelow = 0;
-            }
-        }
-    }
-    
-    // Look up the cell in the section's grid, which requires effective col index
-    if (section && rBelow >= 0) {
-        int effCol = colToEffCol(cell->col());
-        RenderTableSection::CellStruct belowCell;
-        // If we hit a colspan back up to a real cell.
-        do {
-            belowCell = section->cellAt(rBelow, effCol);
-            effCol--;
-        } while (!belowCell.cell && belowCell.inColSpan && effCol >=0);
-        return belowCell.cell;
-    } else
-        return 0;
-}
-
-RenderTableCell* RenderTable::cellLeft(const RenderTableCell* cell) const
-{
-    RenderTableSection* section = cell->section();
-    int effCol = colToEffCol(cell->col());
-    if (effCol == 0)
-        return 0;
-    
-    // If we hit a colspan back up to a real cell.
-    RenderTableSection::CellStruct prevCell;
-    do {
-        prevCell = section->cellAt(cell->row(), effCol-1);
-        effCol--;
-    } while (!prevCell.cell && prevCell.inColSpan && effCol >=0);
-    return prevCell.cell;
-}
-
-RenderTableCell* RenderTable::cellRight(const RenderTableCell* cell) const
-{
-    int effCol = colToEffCol(cell->col() + cell->colSpan());
-    if (effCol >= numEffCols())
-        return 0;
-    return cell->section()->cellAt(cell->row(), effCol).cell;
-}
-
-RenderBlock* RenderTable::firstLineBlock() const
-{
-    return 0;
-}
-
-void RenderTable::updateFirstLetter()
-{}
-
-#ifndef NDEBUG
-void RenderTable::dump(QTextStream *stream, QString ind) const
-{
-    if (tCaption)
-       *stream << " tCaption";
-    if (head)
-       *stream << " head";
-    if (foot)
-       *stream << " foot";
-
-    *stream << endl << ind << "cspans:";
-    for ( unsigned int i = 0; i < columns.size(); i++ )
-       *stream << " " << columns[i].span;
-    *stream << endl << ind;
-
-    RenderBlock::dump(stream,ind);
-}
-#endif
-
-// --------------------------------------------------------------------------
-
-RenderTableSection::RenderTableSection(DOM::NodeImpl* node)
-    : RenderContainer(node)
-{
-    // init RenderObject attributes
-    setInline(false);   // our object is not Inline
-    gridRows = 0;
-    cCol = 0;
-    cRow = -1;
-    needCellRecalc = false;
-}
-
-RenderTableSection::~RenderTableSection()
-{
-    clearGrid();
-}
-
-void RenderTableSection::destroy()
-{
-    // recalc cell info because RenderTable has unguarded pointers
-    // stored that point to this RenderTableSection.
-    if (table())
-        table()->setNeedSectionRecalc();
-
-    RenderContainer::destroy();
-}
-
-void RenderTableSection::setStyle(RenderStyle* _style)
-{
-    // we don't allow changing this one
-    if (style())
-        _style->setDisplay(style()->display());
-    else if (_style->display() != TABLE_FOOTER_GROUP && _style->display() != TABLE_HEADER_GROUP)
-        _style->setDisplay(TABLE_ROW_GROUP);
-
-    RenderContainer::setStyle(_style);
-}
-
-void RenderTableSection::addChild(RenderObject *child, RenderObject *beforeChild)
-{
-    RenderObject *row = child;
-
-    if (child->element() && child->element()->hasTagName(formTag)) {
-        RenderContainer::addChild(child,beforeChild);
-        return;
-    }
-    
-    if (!child->isTableRow()) {
-
-        if (!beforeChild)
-            beforeChild = lastChild();
-
-        if (beforeChild && beforeChild->isAnonymous())
-            row = beforeChild;
-        else {
-           RenderObject *lastBox = beforeChild;
-           while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableRow())
-               lastBox = lastBox->parent();
-           if (lastBox && lastBox->isAnonymous()) {
-               lastBox->addChild( child, beforeChild );
-               return;
-           } else {
-               row = new (renderArena()) RenderTableRow(document() /* anonymous table */);
-               RenderStyle *newStyle = new (renderArena()) RenderStyle();
-               newStyle->inheritFrom(style());
-               newStyle->setDisplay(TABLE_ROW);
-               row->setStyle(newStyle);
-               addChild(row, beforeChild);
-           }
-        }
-        row->addChild(child);
-        child->setNeedsLayoutAndMinMaxRecalc();
-        return;
-    }
-
-    if (beforeChild)
-       setNeedCellRecalc();
-
-    cRow++;
-    cCol = 0;
-
-    ensureRows(cRow+1);
-
-    if (!beforeChild) {
-        grid[cRow].height = child->style()->height();
-        if (grid[cRow].height.type == Relative)
-            grid[cRow].height = Length();
-    }
-
-
-    RenderContainer::addChild(child,beforeChild);
-}
-
-bool RenderTableSection::ensureRows(int numRows)
-{
-    int nRows = gridRows;
-    if (numRows > nRows) {
-        if (numRows > static_cast<int>(grid.size()))
-            if (!grid.resize(numRows*2+1))
-                return false;
-
-        gridRows = numRows;
-        int nCols = table()->numEffCols();
-        CellStruct emptyCellStruct;
-        emptyCellStruct.cell = 0;
-        emptyCellStruct.inColSpan = false;
-       for (int r = nRows; r < numRows; r++) {
-           grid[r].row = new Row(nCols);
-           grid[r].row->fill(emptyCellStruct);
-           grid[r].baseLine = 0;
-           grid[r].height = Length();
-       }
-    }
-
-    return true;
-}
-
-void RenderTableSection::addCell(RenderTableCell *cell)
-{
-    int rSpan = cell->rowSpan();
-    int cSpan = cell->colSpan();
-    Array<RenderTable::ColumnStruct> &columns = table()->columns;
-    int nCols = columns.size();
-
-    // ### mozilla still seems to do the old HTML way, even for strict DTD
-    // (see the annotation on table cell layouting in the CSS specs and the testcase below:
-    // <TABLE border>
-    // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
-    // <TR><TD colspan="2">5
-    // </TABLE>
-
-    while (cCol < nCols && (cellAt(cRow, cCol).cell || cellAt(cRow, cCol).inColSpan))
-       cCol++;
-
-    if (rSpan == 1) {
-       // we ignore height settings on rowspan cells
-       Length height = cell->style()->height();
-       if (height.value > 0 || (height.type == Relative && height.value >= 0)) {
-           Length cRowHeight = grid[cRow].height;
-           switch (height.type) {
-                case Percent:
-                    if (!(cRowHeight.type == Percent) ||
-                        (cRowHeight.type == Percent && cRowHeight.value < height.value))
-                        grid[cRow].height = height;
-                        break;
-                case Fixed:
-                    if (cRowHeight.type < Percent ||
-                        (cRowHeight.type == Fixed && cRowHeight.value < height.value))
-                        grid[cRow].height = height;
-                    break;
-                case Relative:
-                default:
-                    break;
-           }
-       }
-    }
-
-    // make sure we have enough rows
-    if (!ensureRows(cRow + rSpan))
-        return;
-
-    int col = cCol;
-    // tell the cell where it is
-    CellStruct currentCell;
-    currentCell.cell = cell;
-    currentCell.inColSpan = false;
-    while (cSpan) {
-       int currentSpan;
-       if (cCol >= nCols) {
-           table()->appendColumn(cSpan);
-           currentSpan = cSpan;
-       } else {
-           if (cSpan < columns[cCol].span)
-               table()->splitColumn(cCol, cSpan);
-           currentSpan = columns[cCol].span;
-       }
-
-       for (int r = 0; r < rSpan; r++) {
-            CellStruct& c = cellAt(cRow + r, cCol);
-            if (currentCell.cell && !c.cell)
-                c.cell = currentCell.cell;
-            if (currentCell.inColSpan)
-                c.inColSpan = true;
-       }
-       cCol++;
-       cSpan -= currentSpan;
-        currentCell.cell = 0;
-       currentCell.inColSpan = true;
-    }
-    if (cell) {
-       cell->setRow(cRow);
-       cell->setCol(table()->effColToCol(col));
-    }
-}
-
-
-
-void RenderTableSection::setCellWidths()
-{
-    Array<int> &columnPos = table()->columnPos;
-
-    int rows = gridRows;
-    for (int i = 0; i < rows; i++) {
-       Row &row = *grid[i].row;
-       int cols = row.size();
-       for (int j = 0; j < cols; j++) {
-           CellStruct current = row[j];
-            RenderTableCell *cell = current.cell;
-
-           if (!cell)
-               continue;
-           int endCol = j;
-           int cspan = cell->colSpan();
-           while (cspan && endCol < cols) {
-               cspan -= table()->columns[endCol].span;
-               endCol++;
-           }
-           int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
-           int oldWidth = cell->width();
-           if (w != oldWidth) {
-               cell->setNeedsLayout(true);
-               cell->setWidth(w);
-           }
-       }
-    }
-}
-
-
-void RenderTableSection::calcRowHeight()
-{
-    int indx;
-    RenderTableCell *cell;
-
-    int totalRows = gridRows;
-    int spacing = table()->vBorderSpacing();
-
-    rowPos.resize(totalRows + 1);
-    rowPos[0] = spacing;
-
-    for (int r = 0; r < totalRows; r++) {
-       rowPos[r + 1] = 0;
-
-       int baseline = 0;
-       int bdesc = 0;
-       int ch = grid[r].height.minWidth(0);
-       int pos = rowPos[r + 1] + ch + spacing;
-
-       if (pos > rowPos[r + 1])
-           rowPos[r + 1] = pos;
-
-       Row *row = grid[r].row;
-       int totalCols = row->size();
-       int totalRows = gridRows;
-
-       for (int c = 0; c < totalCols; c++) {
-           CellStruct current = cellAt(r, c);
-            cell = current.cell;
-           if (!cell || current.inColSpan)
-               continue;
-           if (r < totalRows - 1 && cellAt(r + 1, c).cell == cell)
-               continue;
-
-           if ((indx = r - cell->rowSpan() + 1) < 0)
-               indx = 0;
-
-            if (cell->overrideSize() != -1) {
-                cell->setOverrideSize(-1);
-                cell->setChildNeedsLayout(true, false);
-                cell->layoutIfNeeded();
-            }
-            
-            // Explicit heights use the border box in quirks mode.  In strict mode do the right
-            // thing and actually add in the border and padding.
-           ch = cell->style()->height().width(0) + 
-                (cell->style()->htmlHacks() ? 0 : (cell->paddingTop() + cell->paddingBottom() +
-                                                   cell->borderTop() + cell->borderBottom()));
-           if (cell->height() > ch)
-               ch = cell->height();
-
-            pos = rowPos[ indx ] + ch + spacing;
-
-           if (pos > rowPos[r + 1])
-               rowPos[r + 1] = pos;
-
-           // find out the baseline
-           EVerticalAlign va = cell->style()->verticalAlign();
-           if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP
-               || va == SUPER || va == SUB) {
-               int b = cell->baselinePosition();
-                if (b > cell->borderTop() + cell->paddingTop()) {
-                    if (b > baseline)
-                        baseline = b;
-
-                    int td = rowPos[indx] + ch - b;
-                    if (td > bdesc)
-                        bdesc = td;
-                }
-           }
-       }
-
-       //do we have baseline aligned elements?
-       if (baseline) {
-           // increase rowheight if baseline requires
-           int bRowPos = baseline + bdesc  + spacing ; // + 2*padding
-           if (rowPos[r + 1] < bRowPos)
-               rowPos[r + 1] = bRowPos;
-
-           grid[r].baseLine = baseline;
-       }
-
-       if (rowPos[r + 1] < rowPos[r])
-           rowPos[r + 1] = rowPos[r];
-    }
-}
-
-int RenderTableSection::layoutRows(int toAdd)
-{
-    int rHeight;
-    int rindx;
-    int totalRows = gridRows;
-    int hspacing = table()->hBorderSpacing();
-    int vspacing = table()->vBorderSpacing();
-    
-    if (toAdd && totalRows && (rowPos[totalRows] || !nextSibling())) {
-
-       int totalHeight = rowPos[totalRows] + toAdd;
-
-        int dh = toAdd;
-       int totalPercent = 0;
-       int numAuto = 0;
-       for (int r = 0; r < totalRows; r++) {
-           if (grid[r].height.type == Auto)
-               numAuto++;
-           else if (grid[r].height.type == Percent)
-               totalPercent += grid[r].height.value;
-       }
-       if (totalPercent) {
-           // try to satisfy percent
-           int add = 0;
-           if (totalPercent > 100)
-               totalPercent = 100;
-           int rh = rowPos[1] - rowPos[0];
-           for (int r = 0; r < totalRows; r++) {
-               if (totalPercent > 0 && grid[r].height.type == Percent) {
-                   int toAdd = kMin(dh, (totalHeight * grid[r].height.value / 100) - rh);
-                    // If toAdd is negative, then we don't want to shrink the row (this bug
-                    // affected Outlook Web Access).
-                    toAdd = kMax(0, toAdd);
-                   add += toAdd;
-                   dh -= toAdd;
-                   totalPercent -= grid[r].height.value;
-               }
-               if (r < totalRows - 1)
-                   rh = rowPos[r + 2] - rowPos[r + 1];
-                rowPos[r + 1] += add;
-           }
-       }
-       if (numAuto) {
-           // distribute over variable cols
-           int add = 0;
-           for (int r = 0; r < totalRows; r++) {
-               if (numAuto > 0 && grid[r].height.type == Auto) {
-                   int toAdd = dh/numAuto;
-                   add += toAdd;
-                   dh -= toAdd;
-                    numAuto--;
-               }
-                rowPos[r + 1] += add;
-           }
-       }
-        if (dh > 0 && rowPos[totalRows]) {
-           // if some left overs, distribute equally.
-            int tot = rowPos[totalRows];
-            int add = 0;
-            int prev = rowPos[0];
-            for (int r = 0; r < totalRows; r++) {
-                //weight with the original height
-                add += dh * (rowPos[r + 1] - prev) / tot;
-                prev = rowPos[r + 1];
-                rowPos[r + 1] += add;
-            }
-        }
-    }
-
-    int leftOffset = hspacing;
-
-    int nEffCols = table()->numEffCols();
-    for (int r = 0; r < totalRows; r++) {
-       Row *row = grid[r].row;
-       int totalCols = row->size();
-        for (int c = 0; c < nEffCols; c++) {
-            CellStruct current = cellAt(r, c);
-            RenderTableCell* cell = current.cell;
-            
-            if (!cell)
-                continue;
-            if (r < totalRows - 1 && cell == cellAt(r + 1, c).cell)
-               continue;
-
-            if ((rindx = r-cell->rowSpan() + 1) < 0)
-                rindx = 0;
-
-            rHeight = rowPos[r + 1] - rowPos[rindx] - vspacing;
-            
-            // Force percent height children to lay themselves out again.
-            // This will cause these children to grow to fill the cell.
-            // FIXME: There is still more work to do here to fully match WinIE (should
-            // it become necessary to do so).  In quirks mode, WinIE behaves like we
-            // do, but it will clip the cells that spill out of the table section.  In
-            // strict mode, Mozilla and WinIE both regrow the table to accommodate the
-            // new height of the cell (thus letting the percentages cause growth one
-            // time only).  We may also not be handling row-spanning cells correctly.
-            //
-            // Note also the oddity where replaced elements always flex, and yet blocks/tables do
-            // not necessarily flex.  WinIE is crazy and inconsistent, and we can't hope to
-            // match the behavior perfectly, but we'll continue to refine it as we discover new
-            // bugs. :)
-            bool cellChildrenFlex = false;
-            bool flexAllChildren = cell->style()->height().isFixed() || 
-                (!table()->style()->height().isAuto() && rHeight != cell->height());
-
-            for (RenderObject* o = cell->firstChild(); o; o = o->nextSibling()) {
-                if (!o->isText() && o->style()->height().isPercent() && (o->isReplaced() || o->scrollsOverflow() || flexAllChildren)) {
-                    // Tables with no sections do not flex.
-                    if (!o->isTable() || static_cast<RenderTable*>(o)->hasSections()) {
-                        o->setNeedsLayout(true, false);
-                        cell->setChildNeedsLayout(true, false);
-                        cellChildrenFlex = true;
-                    }
-                }
-            }
-            if (cellChildrenFlex) {
-                cell->setOverrideSize(kMax(0, 
-                                           rHeight - cell->borderTop() - cell->paddingTop() - 
-                                                     cell->borderBottom() - cell->paddingBottom()));
-                cell->layoutIfNeeded();
-
-                // Alignment within a cell is based off the calculated
-                // height, which becomes irrelevant once the cell has
-                // been resized based off its percentage. -dwh
-                cell->setCellTopExtra(0);
-                cell->setCellBottomExtra(0);
-            }
-            else {
-                EVerticalAlign va = cell->style()->verticalAlign();
-                int te = 0;
-                switch (va) {
-                    case SUB:
-                    case SUPER:
-                    case TEXT_TOP:
-                    case TEXT_BOTTOM:
-                    case BASELINE:
-                        te = getBaseline(r) - cell->baselinePosition() ;
-                        break;
-                    case TOP:
-                        te = 0;
-                        break;
-                    case MIDDLE:
-                        te = (rHeight - cell->height())/2;
-                        break;
-                    case BOTTOM:
-                        te = rHeight - cell->height();
-                        break;
-                    default:
-                        break;
-                }
-                
-                cell->setCellTopExtra(te);
-                cell->setCellBottomExtra(rHeight - cell->height() - te);
-            }
-            
-            int oldCellX = cell->xPos();
-            int oldCellY = cell->yPos();
-        
-            if (style()->direction() == RTL) {
-                cell->setPos(
-                   table()->columnPos[(int)totalCols] -
-                   table()->columnPos[table()->colToEffCol(cell->col()+cell->colSpan())] +
-                   leftOffset,
-                    rowPos[rindx]);
-            } else
-                cell->setPos(table()->columnPos[c] + leftOffset, rowPos[rindx]);
-
-            // If the cell moved, we have to repaint it as well as any floating/positioned
-            // descendants.  An exception is if we need a layout.  In this case, we know we're going to
-            // repaint ourselves (and the cell) anyway.
-            if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout())
-                cell->repaintDuringLayoutIfMoved(oldCellX, oldCellY);
-        }
-    }
-
-    m_height = rowPos[totalRows];
-    return m_height;
-}
-
-
-void RenderTableSection::paint(PaintInfo& i, int tx, int ty)
-{
-    unsigned int totalRows = gridRows;
-    unsigned int totalCols = table()->columns.size();
-
-    tx += m_x;
-    ty += m_y;
-
-    // check which rows and cols are visible and only paint these
-    // ### fixme: could use a binary search here
-    PaintAction paintAction = i.phase;
-    int x = i.r.x();
-    int y = i.r.y();
-    int w = i.r.width();
-    int h = i.r.height();
-
-    int os = 2 * maximalOutlineSize(paintAction);
-    unsigned int startrow = 0;
-    unsigned int endrow = totalRows;
-    for (; startrow < totalRows; startrow++)
-       if (ty + rowPos[startrow+1] >= y - os)
-           break;
-
-    for (; endrow > 0; endrow--)
-       if ( ty + rowPos[endrow-1] <= y + h + os)
-            break;
-
-    unsigned int startcol = 0;
-    unsigned int endcol = totalCols;
-    if (style()->direction() == LTR) {
-       for (; startcol < totalCols; startcol++) {
-           if (tx + table()->columnPos[startcol + 1] >= x - os)
-                break;
-       }
-       for (; endcol > 0; endcol--) {
-           if (tx + table()->columnPos[endcol - 1] <= x + w + os)
-               break;
-       }
-    }
-
-    if (startcol < endcol) {
-       // draw the cells
-       for (unsigned int r = startrow; r < endrow; r++) {
-           unsigned int c = startcol;
-           // since a cell can be -1 (indicating a colspan) we might have to search backwards to include it
-           while (c && cellAt(r, c).inColSpan)
-               c--;
-           for (; c < endcol; c++) {
-                CellStruct current = cellAt(r, c);
-                RenderTableCell *cell = current.cell;
-               
-                if (!cell || (cell->layer() && i.phase != PaintActionCollapsedTableBorders)) 
-                   continue;
-                
-                // Cells must always paint in the order in which they appear taking into account
-                // their upper left originating row/column.  For cells with rowspans, avoid repainting
-                // if we've already seen the cell.
-               if (r > startrow && (cellAt(r-1, c).cell == cell))
-                   continue;
-
-               cell->paint(i, tx, ty);
-           }
-       }
-    }
-}
-
-void RenderTableSection::recalcCells()
-{
-    cCol = 0;
-    cRow = -1;
-    clearGrid();
-    gridRows = 0;
-
-    for (RenderObject *row = firstChild(); row; row = row->nextSibling()) {
-       cRow++;
-       cCol = 0;
-       ensureRows(cRow + 1);
-       for (RenderObject *cell = row->firstChild(); cell; cell = cell->nextSibling())
-           if (cell->isTableCell())
-               addCell(static_cast<RenderTableCell *>(cell));
-    }
-    needCellRecalc = false;
-    setNeedsLayout(true);
-}
-
-void RenderTableSection::clearGrid()
-{
-    int rows = gridRows;
-    while (rows--)
-       delete grid[rows].row;
-}
-
-RenderObject* RenderTableSection::removeChildNode(RenderObject* child)
-{
-    setNeedCellRecalc();
-    return RenderContainer::removeChildNode(child);
-}
-
-#ifndef NDEBUG
-void RenderTableSection::dump(QTextStream *stream, QString ind) const
-{
-    *stream << endl << ind << "grid=(" << grid.size() << "," << table()->numEffCols() << ")" << endl << ind;
-    for (unsigned int r = 0; r < grid.size(); r++) {
-       for (int c = 0; c < table()->numEffCols(); c++) {
-           if (cellAt( r, c).cell && !cellAt(r, c).inColSpan)
-               *stream << "(" << cellAt(r, c).cell->row() << "," << cellAt(r, c).cell->col() << ","
-                       << cellAt(r, c).cell->rowSpan() << "," << cellAt(r, c).cell->colSpan() << ") ";
-           else
-               *stream << cellAt(r, c).cell << "null cell ";
-       }
-       *stream << endl << ind;
-    }
-    RenderContainer::dump(stream,ind);
-}
-#endif
-
-// -------------------------------------------------------------------------
-
-RenderTableRow::RenderTableRow(DOM::NodeImpl* node)
-    : RenderContainer(node)
-{
-    // init RenderObject attributes
-    setInline(false);   // our object is not Inline
-}
-
-void RenderTableRow::destroy()
-{
-    RenderTableSection *s = section();
-    if (s)
-        s->setNeedCellRecalc();
-    
-    RenderContainer::destroy();
-}
-
-void RenderTableRow::setStyle(RenderStyle* style)
-{
-    style->setDisplay(TABLE_ROW);
-    RenderContainer::setStyle(style);
-}
-
-void RenderTableRow::addChild(RenderObject *child, RenderObject *beforeChild)
-{
-    if (child->element() && child->element()->hasTagName(formTag)) {
-        RenderContainer::addChild(child,beforeChild);
-        return;
-    }
-
-    RenderTableCell *cell;
-
-    if (!child->isTableCell()) {
-       RenderObject *last = beforeChild;
-        if (!last)
-            last = lastChild();
-        RenderTableCell *cell = 0;
-        if (last && last->isAnonymous() && last->isTableCell())
-            cell = static_cast<RenderTableCell *>(last);
-        else {
-           cell = new (renderArena()) RenderTableCell(document() /* anonymous object */);
-           RenderStyle *newStyle = new (renderArena()) RenderStyle();
-           newStyle->inheritFrom(style());
-           newStyle->setDisplay(TABLE_CELL);
-           cell->setStyle(newStyle);
-           addChild(cell, beforeChild);
-        }
-        cell->addChild(child);
-        child->setNeedsLayoutAndMinMaxRecalc();
-        return;
-    } else
-        cell = static_cast<RenderTableCell *>(child);
-
-    static_cast<RenderTableSection *>(parent())->addCell(cell);
-
-    RenderContainer::addChild(cell,beforeChild);
-
-    if ((beforeChild || nextSibling()) && section())
-       section()->setNeedCellRecalc();
-}
-
-RenderObject* RenderTableRow::removeChildNode(RenderObject* child)
-{
-// RenderTableCell destroy should do it
-//     if ( section() )
-//     section()->setNeedCellRecalc();
-    return RenderContainer::removeChildNode(child);
-}
-
-#ifndef NDEBUG
-void RenderTableRow::dump(QTextStream *stream, QString ind) const
-{
-    RenderContainer::dump(stream,ind);
-}
-#endif
-
-void RenderTableRow::layout()
-{
-    KHTMLAssert(needsLayout());
-    KHTMLAssert(minMaxKnown());
-
-    for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
-        if (child->isTableCell()) {
-            RenderTableCell *cell = static_cast<RenderTableCell *>(child);
-            if (child->needsLayout()) {
-                cell->calcVerticalMargins();
-                cell->layout();
-                cell->setCellTopExtra(0);
-                cell->setCellBottomExtra(0);
-            }
-        }
-    }
-    setNeedsLayout(false);
-}
-
-IntRect RenderTableRow::getAbsoluteRepaintRect()
-{
-    // For now, just repaint the whole table.
-    // FIXME: Find a better way to do this.
-    RenderTable* parentTable = table();
-    if (parentTable)
-        return parentTable->getAbsoluteRepaintRect();
-    else
-        return IntRect();
-}
-
-// -------------------------------------------------------------------------
-
-RenderTableCell::RenderTableCell(DOM::NodeImpl* _node)
-  : RenderBlock(_node)
-{
-  _col = -1;
-  _row = -1;
-  cSpan = rSpan = 1;
-  updateFromElement();
-  setShouldPaintBackgroundOrBorder(true);
-  _topExtra = 0;
-  _bottomExtra = 0;
-  m_percentageHeight = 0;
-}
-
-void RenderTableCell::destroy()
-{
-    if (parent() && section())
-        section()->setNeedCellRecalc();
-
-    RenderBlock::destroy();
-}
-
-void RenderTableCell::updateFromElement()
-{
-    int oldRSpan = rSpan;
-    int oldCSpan = cSpan;
-    DOM::NodeImpl* node = element();
-    if (node && (node->hasTagName(tdTag) || node->hasTagName(thTag))) {
-        DOM::HTMLTableCellElementImpl *tc = static_cast<DOM::HTMLTableCellElementImpl *>(node);
-        cSpan = tc->colSpan();
-        rSpan = tc->rowSpan();
-    }
-    if ((oldRSpan != rSpan || oldCSpan != cSpan) && style() && parent())
-        setNeedsLayoutAndMinMaxRecalc();
-}
-    
-Length RenderTableCell::styleOrColWidth()
-{
-    Length w = style()->width();
-    if (colSpan() > 1 || !w.isAuto())
-        return w;
-    RenderTableCol* col = table()->colElement(_col);
-    if (col)
-        w = col->style()->width();
-    return w;
-}
-
-void RenderTableCell::calcMinMaxWidth()
-{
-    RenderBlock::calcMinMaxWidth();
-    if (element() && style()->autoWrap()) {
-        // See if nowrap was set.
-        Length w = styleOrColWidth();
-        DOMString nowrap = static_cast<ElementImpl*>(element())->getAttribute(nowrapAttr);
-        if (!nowrap.isNull() && w.isFixed())
-            // Nowrap is set, but we didn't actually use it because of the
-            // fixed width set on the cell.  Even so, it is a WinIE/Moz trait
-            // to make the minwidth of the cell into the fixed width.  They do this
-            // even in strict mode, so do not make this a quirk.  Affected the top
-            // of hiptop.com.
-            if (m_minWidth < w.value)
-                m_minWidth = w.value;
-    }
-}
-
-void RenderTableCell::calcWidth()
-{
-}
-
-void RenderTableCell::setWidth(int width)
-{
-    if (width != m_width) {
-       m_width = width;
-       m_widthChanged = true;
-    }
-}
-
-void RenderTableCell::layout()
-{
-    layoutBlock(m_widthChanged);
-    m_widthChanged = false;
-}
-
-void RenderTableCell::computeAbsoluteRepaintRect(IntRect& r, bool f)
-{
-    r.setY(r.y() + _topExtra);
-    RenderBlock::computeAbsoluteRepaintRect(r, f);
-}
-
-bool RenderTableCell::absolutePosition(int &xPos, int &yPos, bool f)
-{
-    bool ret = RenderBlock::absolutePosition(xPos, yPos, f);
-    if (ret)
-      yPos += _topExtra;
-    return ret;
-}
-
-short RenderTableCell::baselinePosition(bool) const
-{
-    RenderObject* o = firstChild();
-    int offset = paddingTop() + borderTop();
-    
-    if (!o)
-        return offset + contentHeight();
-    while (o->firstChild()) {
-       if (!o->isInline())
-           offset += o->paddingTop() + o->borderTop();
-       o = o->firstChild();
-    }
-    
-    if (!o->isInline())
-        return paddingTop() + borderTop() + contentHeight();
-
-    offset += o->baselinePosition(true);
-    return offset;
-}
-
-
-void RenderTableCell::setStyle(RenderStyle *style)
-{
-    style->setDisplay(TABLE_CELL);
-
-    if (style->whiteSpace() == KHTML_NOWRAP) {
-        // Figure out if we are really nowrapping or if we should just
-        // use normal instead.  If the width of the cell is fixed, then
-        // we don't actually use NOWRAP. 
-        if (style->width().isFixed())
-            style->setWhiteSpace(NORMAL);
-        else
-            style->setWhiteSpace(NOWRAP);
-    }
-
-    RenderBlock::setStyle(style);
-    setShouldPaintBackgroundOrBorder(true);
-}
-
-bool RenderTableCell::requiresLayer() {
-    return isPositioned() || style()->opacity() < 1.0f || hasOverflowClip();
-}
-
-// The following rules apply for resolving conflicts and figuring out which border
-// to use.
-// (1) Borders with the 'border-style' of 'hidden' take precedence over all other conflicting 
-// borders. Any border with this value suppresses all borders at this location.
-// (2) Borders with a style of 'none' have the lowest priority. Only if the border properties of all 
-// the elements meeting at this edge are 'none' will the border be omitted (but note that 'none' is 
-// the default value for the border style.)
-// (3) If none of the styles are 'hidden' and at least one of them is not 'none', then narrow borders 
-// are discarded in favor of wider ones. If several have the same 'border-width' then styles are preferred 
-// in this order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', and the lowest: 'inset'.
-// (4) If border styles differ only in color, then a style set on a cell wins over one on a row, 
-// which wins over a row group, column, column group and, lastly, table. It is undefined which color 
-// is used when two elements of the same type disagree.
-static CollapsedBorderValue compareBorders(const CollapsedBorderValue& border1, 
-                                           const CollapsedBorderValue& border2)
-{
-    // Sanity check the values passed in.  If either is null, return the other.
-    if (!border2.exists()) return border1;
-    if (!border1.exists()) return border2;
-    
-    // Rule #1 above.
-    if (border1.style() == BHIDDEN || border2.style() == BHIDDEN)
-        return CollapsedBorderValue(); // No border should exist at this location.
-    
-    // Rule #2 above.  A style of 'none' has lowest priority and always loses to any other border.
-    if (border2.style() == BNONE) return border1;
-    if (border1.style() == BNONE) return border2;
-    
-    // The first part of rule #3 above. Wider borders win.
-    if (border1.width() != border2.width())
-        return border1.width() > border2.width() ? border1 : border2;
-    
-    // The borders have equal width.  Sort by border style.
-    if (border1.style() != border2.style())
-        return border1.style() > border2.style() ? border1 : border2;
-    
-    // The border have the same width and style.  Rely on precedence (cell over row over row group, etc.)
-    return border1.precedence >= border2.precedence ? border1 : border2;
-}
-
-CollapsedBorderValue RenderTableCell::collapsedLeftBorder() const
-{
-    // For border left, we need to check, in order of precedence:
-    // (1) Our left border.
-    CollapsedBorderValue result(&style()->borderLeft(), BCELL);
-    
-    // (2) The previous cell's right border.
-    RenderTableCell* prevCell = table()->cellLeft(this);
-    if (prevCell) {
-        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderRight(), BCELL));
-        if (!result.exists())
-            return result;
-    }
-    else if (col() == 0) {
-        // (3) Our row's left border.
-        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderLeft(), BROW));
-        if (!result.exists())
-            return result;
-        
-        // (4) Our row group's left border.
-        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderLeft(), BROWGROUP));
-        if (!result.exists())
-            return result;
-    }
-    
-    // (5) Our column's left border.
-    RenderTableCol* colElt = table()->colElement(col());
-    if (colElt) {
-        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
-        if (!result.exists())
-            return result;
-    }
-    
-    // (6) The previous column's right border.
-    if (col() > 0) {
-        colElt = table()->colElement(col() - 1);
-        if (colElt) {
-            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
-            if (!result.exists())
-                return result;
-        }
-    }
-    
-    if (col() == 0) {
-        // (7) The table's left border.
-        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderLeft(), BTABLE));
-        if (!result.exists())
-            return result;
-    }
-    
-    return result;
-}
-
-CollapsedBorderValue RenderTableCell::collapsedRightBorder() const
-{
-    RenderTable* tableElt = table();
-    bool inLastColumn = false;
-    int effCol = tableElt->colToEffCol(col() + colSpan() - 1);
-    if (effCol == tableElt->numEffCols() - 1)
-        inLastColumn = true;
-    
-    // For border right, we need to check, in order of precedence:
-    // (1) Our right border.
-    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderRight(), BCELL);
-    
-    // (2) The next cell's left border.
-    if (!inLastColumn) {
-        RenderTableCell* nextCell = tableElt->cellRight(this);
-        if (nextCell && nextCell->style()) {
-            result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderLeft(), BCELL));
-            if (!result.exists())
-                return result;
-        }
-    } else {
-        // (3) Our row's right border.
-        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderRight(), BROW));
-        if (!result.exists())
-            return result;
-        
-        // (4) Our row group's right border.
-        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderRight(), BROWGROUP));
-        if (!result.exists())
-            return result;
-    }
-    
-    // (5) Our column's right border.
-    RenderTableCol* colElt = table()->colElement(col()+colSpan() - 1);
-    if (colElt) {
-        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
-        if (!result.exists())
-            return result;
-    }
-    
-    // (6) The next column's left border.
-    if (!inLastColumn) {
-        colElt = tableElt->colElement(col()+colSpan());
-        if (colElt) {
-            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
-            if (!result.exists())
-                return result;
-        }
-    }
-    else {
-        // (7) The table's right border.
-        result = compareBorders(result, CollapsedBorderValue(&tableElt->style()->borderRight(), BTABLE));
-        if (!result.exists())
-            return result;
-    }
-    
-    return result;
-}
-
-CollapsedBorderValue RenderTableCell::collapsedTopBorder() const
-{
-    // For border top, we need to check, in order of precedence:
-    // (1) Our top border.
-    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderTop(), BCELL);
-    
-    RenderTableCell* prevCell = table()->cellAbove(this);
-    if (prevCell) {
-        // (2) A previous cell's bottom border.
-        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderBottom(), BCELL));
-        if (!result.exists()) 
-            return result;
-    }
-    
-    // (3) Our row's top border.
-    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderTop(), BROW));
-    if (!result.exists())
-        return result;
-    
-    // (4) The previous row's bottom border.
-    if (prevCell) {
-        RenderObject* prevRow = 0;
-        if (prevCell->section() == section())
-            prevRow = parent()->previousSibling();
-        else
-            prevRow = prevCell->section()->lastChild();
-    
-        if (prevRow) {
-            result = compareBorders(result, CollapsedBorderValue(&prevRow->style()->borderBottom(), BROW));
-            if (!result.exists())
-                return result;
-        }
-    }
-    
-    // Now check row groups.
-    RenderObject* currSection = parent()->parent();
-    if (row() == 0) {
-        // (5) Our row group's top border.
-        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderTop(), BROWGROUP));
-        if (!result.exists())
-            return result;
-        
-        // (6) Previous row group's bottom border.
-        for (currSection = currSection->previousSibling(); currSection;
-             currSection = currSection->previousSibling()) {
-            if (currSection->isTableSection()) {
-                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
-                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderBottom(), BROWGROUP));
-                if (!result.exists())
-                    return result;
-            }
-        }
-    }
-    
-    if (!currSection) {
-        // (8) Our column's top border.
-        RenderTableCol* colElt = table()->colElement(col());
-        if (colElt) {
-            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderTop(), BCOL));
-            if (!result.exists())
-                return result;
-        }
-        
-        // (9) The table's top border.
-        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderTop(), BTABLE));
-        if (!result.exists())
-            return result;
-    }
-    
-    return result;
-}
-
-CollapsedBorderValue RenderTableCell::collapsedBottomBorder() const
-{
-    // For border top, we need to check, in order of precedence:
-    // (1) Our bottom border.
-    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderBottom(), BCELL);
-    
-    RenderTableCell* nextCell = table()->cellBelow(this);
-    if (nextCell) {
-        // (2) A following cell's top border.
-        result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderTop(), BCELL));
-        if (!result.exists())
-            return result;
-    }
-    
-    // (3) Our row's bottom border. (FIXME: Deal with rowspan!)
-    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderBottom(), BROW));
-    if (!result.exists())
-        return result;
-    
-    // (4) The next row's top border.
-    if (nextCell) {
-        result = compareBorders(result, CollapsedBorderValue(&nextCell->parent()->style()->borderTop(), BROW));
-        if (!result.exists())
-            return result;
-    }
-    
-    // Now check row groups.
-    RenderObject* currSection = parent()->parent();
-    if (row() + rowSpan() >= static_cast<RenderTableSection*>(currSection)->numRows()) {
-        // (5) Our row group's bottom border.
-        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderBottom(), BROWGROUP));
-        if (!result.exists())
-            return result;
-        
-        // (6) Following row group's top border.
-        for (currSection = currSection->nextSibling(); currSection;
-             currSection = currSection->nextSibling()) {
-            if (currSection->isTableSection()) {
-                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
-                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderTop(), BROWGROUP));
-                if (!result.exists())
-                    return result;
-            }
-        }
-    }
-    
-    if (!currSection) {
-        // (8) Our column's bottom border.
-        RenderTableCol* colElt = table()->colElement(col());
-        if (colElt) {
-            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderBottom(), BCOL));
-            if (!result.exists()) return result;
-        }
-        
-        // (9) The table's bottom border.
-        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderBottom(), BTABLE));
-        if (!result.exists())
-            return result;
-    }
-    
-    return result;    
-}
-
-int RenderTableCell::borderLeft() const
-{
-    if (table()->collapseBorders()) {
-        CollapsedBorderValue border = collapsedLeftBorder();
-        if (border.exists())
-            return int(border.width() / 2.0 + 0.5); // Give the extra pixel to top and left.
-        return 0;
-    }
-    return RenderBlock::borderLeft();
-}
-    
-int RenderTableCell::borderRight() const
-{
-    if (table()->collapseBorders()) {
-        CollapsedBorderValue border = collapsedRightBorder();
-        if (border.exists())
-            return border.width() / 2;
-        return 0;
-    }
-    return RenderBlock::borderRight();
-}
-
-int RenderTableCell::borderTop() const
-{
-    if (table()->collapseBorders()) {
-        CollapsedBorderValue border = collapsedTopBorder();
-        if (border.exists())
-            return int(border.width() / 2.0 + 0.5); // Give the extra pixel to top and left.
-        return 0;
-    }
-    return RenderBlock::borderTop();
-}
-
-int RenderTableCell::borderBottom() const
-{
-    if (table()->collapseBorders()) {
-        CollapsedBorderValue border = collapsedBottomBorder();
-        if (border.exists())
-            return border.width() / 2;
-        return 0;
-    }
-    return RenderBlock::borderBottom();
-}
-
-#ifdef BOX_DEBUG
-#include <qpainter.h>
-
-static void outlineBox(QPainter *p, int _tx, int _ty, int w, int h)
-{
-    p->setPen(QPen(QColor("yellow"), 3, Qt::DotLine));
-    p->setBrush(Qt::NoBrush);
-    p->drawRect(_tx, _ty, w, h);
-}
-#endif
-
-void RenderTableCell::paint(PaintInfo& i, int _tx, int _ty)
-{
-    _tx += m_x;
-    _ty += m_y;
-
-    // check if we need to do anything at all...
-    int os = 2*maximalOutlineSize(i.phase);
-    if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + _topExtra + m_height + _bottomExtra <= i.r.y() - os))
-        return;
-
-    if (i.phase == PaintActionCollapsedTableBorders && style()->visibility() == VISIBLE) {
-        int w = width();
-        int h = height() + borderTopExtra() + borderBottomExtra();
-        paintCollapsedBorder(i.p, _tx, _ty, w, h);
-    }
-    else
-        RenderBlock::paintObject(i, _tx, _ty + _topExtra);
-
-#ifdef BOX_DEBUG
-    ::outlineBox( i.p, _tx, _ty, width(), height() + borderTopExtra() + borderBottomExtra());
-#endif
-}
-
-static EBorderStyle collapsedBorderStyle(EBorderStyle style)
-{
-    if (style == OUTSET)
-        style = GROOVE;
-    else if (style == INSET)
-        style = RIDGE;
-    return style;
-}
-
-struct CollapsedBorder {
-    CollapsedBorder(){}
-    
-    CollapsedBorderValue border;
-    RenderObject::BorderSide side;
-    bool shouldPaint;
-    int x1;
-    int y1;
-    int x2;
-    int y2;
-    EBorderStyle style;
-};
-
-class CollapsedBorders
-{
-public:
-    CollapsedBorders(int i) :count(0) {}
-    
-    void addBorder(const CollapsedBorderValue& b, RenderObject::BorderSide s, bool paint, 
-                   int _x1, int _y1, int _x2, int _y2,
-                   EBorderStyle _style)
-    {
-        if (b.exists() && paint) {
-            borders[count].border = b;
-            borders[count].side = s;
-            borders[count].shouldPaint = paint;
-            borders[count].x1 = _x1;
-            borders[count].x2 = _x2;
-            borders[count].y1 = _y1;
-            borders[count].y2 = _y2;
-            borders[count].style = _style;
-            count++;
-        }
-    }
-
-    CollapsedBorder* nextBorder() {
-        for (int i = 0; i < count; i++) {
-            if (borders[i].border.exists() && borders[i].shouldPaint) {
-                borders[i].shouldPaint = false;
-                return &borders[i];
-            }
-        }
-        
-        return 0;
-    }
-    
-    CollapsedBorder borders[4];
-    int count;
-};
-
-static void addBorderStyle(QValueList<CollapsedBorderValue>& borderStyles, CollapsedBorderValue borderValue)
-{
-    if (!borderValue.exists() || borderStyles.contains(borderValue))
-        return;
-    
-    QValueListIterator<CollapsedBorderValue> it = borderStyles.begin();
-    QValueListIterator<CollapsedBorderValue> end = borderStyles.end();
-    for (; it != end; ++it) {
-        CollapsedBorderValue result = compareBorders(*it, borderValue);
-        if (result == *it) {
-            borderStyles.insert(it, borderValue);
-            return;
-        }
-    }
-
-    borderStyles.append(borderValue);
-}
-
-void RenderTableCell::collectBorders(QValueList<CollapsedBorderValue>& borderStyles)
-{
-    addBorderStyle(borderStyles, collapsedLeftBorder());
-    addBorderStyle(borderStyles, collapsedRightBorder());
-    addBorderStyle(borderStyles, collapsedTopBorder());
-    addBorderStyle(borderStyles, collapsedBottomBorder());
-}
-
-void RenderTableCell::paintCollapsedBorder(QPainter* p, int _tx, int _ty, int w, int h)
-{
-    if (!table()->currentBorderStyle())
-        return;
-    
-    CollapsedBorderValue leftVal = collapsedLeftBorder();
-    CollapsedBorderValue rightVal = collapsedRightBorder();
-    CollapsedBorderValue topVal = collapsedTopBorder();
-    CollapsedBorderValue bottomVal = collapsedBottomBorder();
-     
-    // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location.
-    int topWidth = topVal.width();
-    int bottomWidth = bottomVal.width();
-    int leftWidth = leftVal.width();
-    int rightWidth = rightVal.width();
-    
-    _tx -= leftWidth / 2;
-    _ty -= topWidth / 2;
-    w += leftWidth / 2 + int(rightWidth / 2.0 + 0.5);
-    h += topWidth / 2 + int(bottomWidth / 2.0 + 0.5);
-    
-    bool tt = topVal.isTransparent();
-    bool bt = bottomVal.isTransparent();
-    bool rt = rightVal.isTransparent();
-    bool lt = leftVal.isTransparent();
-    
-    EBorderStyle ts = collapsedBorderStyle(topVal.style());
-    EBorderStyle bs = collapsedBorderStyle(bottomVal.style());
-    EBorderStyle ls = collapsedBorderStyle(leftVal.style());
-    EBorderStyle rs = collapsedBorderStyle(rightVal.style());
-    
-    bool render_t = ts > BHIDDEN && !tt;
-    bool render_l = ls > BHIDDEN && !lt;
-    bool render_r = rs > BHIDDEN && !rt;
-    bool render_b = bs > BHIDDEN && !bt;
-
-    // We never paint diagonals at the joins.  We simply let the border with the highest
-    // precedence paint on top of borders with lower precedence.  
-    CollapsedBorders borders(4);
-    borders.addBorder(topVal, BSTop, render_t, _tx, _ty, _tx + w, _ty + topWidth, ts);
-    borders.addBorder(bottomVal, BSBottom, render_b, _tx, _ty + h - bottomWidth, _tx + w, _ty + h, bs);
-    borders.addBorder(leftVal, BSLeft, render_l, _tx, _ty, _tx + leftWidth, _ty + h, ls);
-    borders.addBorder(rightVal, BSRight, render_r, _tx + w - rightWidth, _ty, _tx + w, _ty + h, rs);
-    
-    for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
-        if (border->border == *table()->currentBorderStyle())
-            drawBorder(p, border->x1, border->y1, border->x2, border->y2, border->side, 
-                       border->border.color(), style()->color(), border->style, 0, 0);
-    }
-}
-
-IntRect RenderTableCell::getAbsoluteRepaintRect()
-{
-    int ow = style() ? style()->outlineSize() : 0;
-    IntRect r(-ow, -ow - borderTopExtra(), 
-            overflowWidth(false) + ow * 2, overflowHeight(false) + borderTopExtra() + borderBottomExtra() + ow * 2);
-    computeAbsoluteRepaintRect(r);
-    return r;
-}
-
-void RenderTableCell::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
-{
-    RenderTable* tableElt = table();
-    if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
-        return;
-    
-    int w = width();
-    int h = height() + borderTopExtra() + borderBottomExtra();
-    _ty -= borderTopExtra();
-
-    QColor c = style()->backgroundColor();
-    if (!c.isValid() && parent()) // take from row
-        c = parent()->style()->backgroundColor();
-    if (!c.isValid() && parent() && parent()->parent()) // take from rowgroup
-        c = parent()->parent()->style()->backgroundColor();
-    if (!c.isValid()) {
-       // see if we have a col or colgroup for this
-       RenderTableCol *col = table()->colElement(_col);
-       if (col) {
-           c = col->style()->backgroundColor();
-           if (!c.isValid()) {
-               // try column group
-               RenderStyle *style = col->parent()->style();
-               if (style->display() == TABLE_COLUMN_GROUP)
-                   c = style->backgroundColor();
-           }
-       }
-    }
-
-    // FIXME: This code is just plain wrong.  Rows and columns should paint their backgrounds
-    // independent from the cell.
-    // ### get offsets right in case the bgimage is inherited.
-    const BackgroundLayer* bgLayer = style()->backgroundLayers();
-    if (!bgLayer->hasImage() && parent())
-        bgLayer = parent()->style()->backgroundLayers();
-    if (!bgLayer->hasImage() && parent() && parent()->parent())
-        bgLayer = parent()->parent()->style()->backgroundLayers();
-    if (!bgLayer->hasImage()) {
-       // see if we have a col or colgroup for this
-       RenderTableCol* col = table()->colElement(_col);
-       if (col) {
-           bgLayer = col->style()->backgroundLayers();
-           if (!bgLayer->hasImage()) {
-               // try column group
-               RenderStyle *style = col->parent()->style();
-               if (style->display() == TABLE_COLUMN_GROUP)
-                   bgLayer = style->backgroundLayers();
-           }
-       }
-    }
-
-    int my = kMax(_ty, i.r.y());
-    int end = kMin(i.r.y() + i.r.height(), _ty + h);
-    int mh = end - my;
-
-    if (bgLayer->hasImage() || c.isValid()) {
-       // We have to clip here because the backround would paint
-        // on top of the borders otherwise.
-        if (m_layer && tableElt->collapseBorders()) {
-            IntRect clipRect(_tx + borderLeft(), _ty + borderTop(), w - borderLeft() - borderRight(), h - borderTop() - borderBottom());
-            clipRect = i.p->xForm(clipRect);
-            i.p->save();
-            i.p->addClip(clipRect);
-        }
-        paintBackground(i.p, c, bgLayer, my, mh, _tx, _ty, w, h);
-        if (m_layer && tableElt->collapseBorders())
-            i.p->restore();
-    }
-
-    if (style()->hasBorder() && !tableElt->collapseBorders())
-        paintBorder(i.p, _tx, _ty, w, h, style());
-}
-
-
-#ifndef NDEBUG
-void RenderTableCell::dump(QTextStream *stream, QString ind) const
-{
-    *stream << " row=" << _row;
-    *stream << " col=" << _col;
-    *stream << " rSpan=" << rSpan;
-    *stream << " cSpan=" << cSpan;
-//    *stream << " nWrap=" << nWrap;
-
-    RenderBlock::dump(stream,ind);
-}
-#endif
-
-// -------------------------------------------------------------------------
-
-RenderTableCol::RenderTableCol(DOM::NodeImpl* node)
-    : RenderContainer(node)
-{
-    // init RenderObject attributes
-    setInline(true);   // our object is not Inline
-
-    _span = 1;
-    updateFromElement();
-}
-
-void RenderTableCol::updateFromElement()
-{
-    int oldSpan = _span;
-    DOM::NodeImpl *node = element();
-    if (node && (node->hasTagName(colTag) || node->hasTagName(colgroupTag))) {
-        DOM::HTMLTableColElementImpl *tc = static_cast<DOM::HTMLTableColElementImpl *>(node);
-        _span = tc->span();
-    } else
-      _span = !(style() && style()->display() == TABLE_COLUMN_GROUP);
-    if (_span != oldSpan && style() && parent())
-        setNeedsLayoutAndMinMaxRecalc();
-}
-
-bool RenderTableCol::canHaveChildren() const
-{
-    // cols cannot have children.  This is actually necessary to fix a bug
-    // with libraries.uc.edu, which makes a <p> be a table-column.
-    return style()->display() == TABLE_COLUMN_GROUP;
-}
-
-void RenderTableCol::addChild(RenderObject *child, RenderObject *beforeChild)
-{
-    KHTMLAssert(child->style()->display() == TABLE_COLUMN);
-
-    // these have to come before the table definition!
-    RenderContainer::addChild(child, beforeChild);
-}
-
-#ifndef NDEBUG
-void RenderTableCol::dump(QTextStream *stream, QString ind) const
-{
-    *stream << " _span=" << _span;
-    RenderContainer::dump(stream, ind);
-}
-#endif
-
-#undef TABLE_DEBUG
-#undef DEBUG_LAYOUT
-#undef BOX_DEBUG
diff --git a/WebCore/rendering/render_table.h b/WebCore/rendering/render_table.h
deleted file mode 100644 (file)
index 8395650..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 1997 Martin Jones (mjones@kde.org)
- *           (C) 1997 Torben Weis (weis@kde.org)
- *           (C) 1998 Waldo Bastian (bastian@kde.org)
- *           (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef RENDER_TABLE_H
-#define RENDER_TABLE_H
-
-#include <qcolor.h>
-
-#include "render_block.h"
-#include "render_style.h"
-#include "khtmllayout.h"
-
-namespace DOM {
-    class DOMString;
-};
-
-namespace khtml {
-
-class RenderTable;
-class RenderTableSection;
-class RenderTableRow;
-class RenderTableCell;
-class RenderTableCol;
-class TableLayout;
-
-class RenderTable : public RenderBlock
-{
-public:
-    enum Rules {
-        None    = 0x00,
-        RGroups = 0x01,
-        CGroups = 0x02,
-        Groups  = 0x03,
-        Rows    = 0x05,
-        Cols    = 0x0a,
-        All     = 0x0f
-    };
-    enum Frame {
-        Void   = 0x00,
-        Above  = 0x01,
-        Below  = 0x02,
-        Lhs    = 0x04,
-        Rhs    = 0x08,
-        Hsides = 0x03,
-        Vsides = 0x0c,
-        Box    = 0x0f
-    };
-
-    RenderTable(DOM::NodeImpl* node);
-    ~RenderTable();
-
-    virtual const char *renderName() const { return "RenderTable"; }
-
-    virtual void setStyle(RenderStyle *style);
-
-    virtual bool isTable() const { return true; }
-
-    int getColumnPos(int col) const
-        { return columnPos[col]; }
-
-    int hBorderSpacing() const { return hspacing; }
-    int vBorderSpacing() const { return vspacing; }
-    
-    bool collapseBorders() const { return style()->borderCollapse(); }
-    int borderLeft() const;
-    int borderRight() const;
-    int borderTop() const;
-    int borderBottom() const;
-    
-    Rules getRules() const { return rules; }
-
-    const QColor &bgColor() const { return style()->backgroundColor(); }
-
-    uint cellPadding() const { return padding; }
-    void setCellPadding(uint p) { padding = p; }
-
-    // overrides
-    virtual int overflowHeight(bool includeInterior = true) const { return height(); }
-    virtual int overflowWidth(bool includeInterior = true) const { return width(); }
-    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
-    virtual void paint(PaintInfo& i, int tx, int ty);
-    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
-    virtual void layout();
-    virtual void calcMinMaxWidth();
-
-    virtual RenderBlock* firstLineBlock() const;
-    virtual void updateFirstLetter();
-    
-    virtual void setCellWidths();
-
-    virtual void calcWidth();
-
-#ifndef NDEBUG
-    virtual void dump(QTextStream *stream, QString ind = "") const;
-#endif
-    struct ColumnStruct {
-       enum {
-           WidthUndefined = 0xffff
-       };
-       ColumnStruct() {
-           span = 1;
-           width = WidthUndefined;
-       }
-       ushort span;
-       uint width; // the calculated position of the column
-    };
-
-    Array<int> columnPos;
-    Array<ColumnStruct> columns;
-
-    void splitColumn(int pos, int firstSpan);
-    void appendColumn(int span);
-    int numEffCols() const { return columns.size(); }
-    int spanOfEffCol(int effCol) const { return columns[effCol].span; }
-    int colToEffCol(int col) const {
-       int c = 0;
-       int i = 0;
-       while (c < col && i < (int)columns.size()) {
-           c += columns[i].span;
-           i++;
-       }
-       return i;
-    }
-    int effColToCol(int effCol) const {
-       int c = 0;
-       for (int i = 0; i < effCol; i++)
-           c += columns[i].span;
-       return c;
-    }
-
-    int bordersPaddingAndSpacing() const {
-       return borderLeft() + borderRight() + 
-               (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols() + 1) * hBorderSpacing()));
-    }
-
-    RenderTableCol *colElement(int col);
-
-    void setNeedSectionRecalc() { needSectionRecalc = true; }
-
-    virtual RenderObject* removeChildNode(RenderObject* child);
-
-    RenderTableCell* cellAbove(const RenderTableCell* cell) const;
-    RenderTableCell* cellBelow(const RenderTableCell* cell) const;
-    RenderTableCell* cellLeft(const RenderTableCell* cell) const;
-    RenderTableCell* cellRight(const RenderTableCell* cell) const;
-    CollapsedBorderValue* currentBorderStyle() { return m_currentBorder; }
-    
-    bool hasSections() const { return head || foot || firstBody; }
-
-protected:
-
-    void recalcSections();
-
-    friend class AutoTableLayout;
-    friend class FixedTableLayout;
-
-    RenderBlock *tCaption;
-    RenderTableSection *head;
-    RenderTableSection *foot;
-    RenderTableSection *firstBody;
-
-    TableLayout *tableLayout;
-
-    CollapsedBorderValue* m_currentBorder;
-    
-    Frame frame                 : 4;
-    Rules rules                 : 4;
-
-    bool has_col_elems         : 1;
-    uint padding               : 22;
-    uint needSectionRecalc     : 1;
-    
-    short hspacing;
-    short vspacing;
-};
-
-// -------------------------------------------------------------------------
-
-class RenderTableSection : public RenderContainer
-{
-public:
-    RenderTableSection(DOM::NodeImpl* node);
-    ~RenderTableSection();
-    virtual void destroy();
-
-    virtual void setStyle(RenderStyle *style);
-
-    virtual const char *renderName() const { return "RenderTableSection"; }
-
-    // overrides
-    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
-    virtual bool isTableSection() const { return true; }
-
-    virtual short lineHeight(bool) const { return 0; }
-    virtual void position(int, int, int, int, int, bool, bool, int) {}
-
-#ifndef NDEBUG
-    virtual void dump(QTextStream *stream, QString ind = "") const;
-#endif
-
-    void addCell(RenderTableCell *cell);
-
-    void setCellWidths();
-    void calcRowHeight();
-    int layoutRows(int height);
-
-    RenderTable *table() const { return static_cast<RenderTable *>(parent()); }
-
-    struct CellStruct {
-        RenderTableCell *cell;
-        bool inColSpan; // true for columns after the first in a colspan
-    };
-    typedef Array<CellStruct> Row;
-    struct RowStruct {
-       Row *row;
-       int baseLine;
-       Length height;
-    };
-
-    CellStruct& cellAt(int row,  int col) {
-       return (*grid[row].row)[col];
-    }
-    const CellStruct& cellAt(int row, int col) const {
-       return (*grid[row].row)[col];
-    }
-
-    virtual void paint(PaintInfo& i, int tx, int ty);
-
-    int numRows() const { return gridRows; }
-    int getBaseline(int row) {return grid[row].baseLine;}
-
-    void setNeedCellRecalc() {
-        needCellRecalc = true;
-        table()->setNeedSectionRecalc();
-    }
-
-    virtual RenderObject* removeChildNode(RenderObject* child);
-
-    // this gets a cell grid data structure. changing the number of
-    // columns is done by the table
-    Array<RowStruct> grid;
-    int gridRows;
-    Array<int> rowPos;
-
-    int cCol;
-    int cRow;
-    bool needCellRecalc;
-
-    void recalcCells();
-protected:
-    bool ensureRows(int numRows);
-    void clearGrid();
-};
-
-// -------------------------------------------------------------------------
-
-class RenderTableRow : public RenderContainer
-{
-public:
-    RenderTableRow(DOM::NodeImpl* node);
-
-    virtual void destroy();
-
-    virtual void setStyle(RenderStyle*);
-    virtual const char *renderName() const { return "RenderTableRow"; }
-
-    virtual bool isTableRow() const { return true; }
-
-    // overrides
-    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
-    virtual RenderObject* removeChildNode(RenderObject* child);
-
-    virtual short lineHeight(bool) const { return 0; }
-    virtual void position(int, int, int, int, int, bool, bool, int) {}
-
-    virtual void layout();
-    virtual IntRect getAbsoluteRepaintRect();
-    
-    RenderTable *table() const { return static_cast<RenderTable *>(parent()->parent()); }
-    RenderTableSection *section() const { return static_cast<RenderTableSection *>(parent()); }
-
-#ifndef NDEBUG
-    virtual void dump(QTextStream *stream, QString ind = "") const;
-#endif
-};
-
-// -------------------------------------------------------------------------
-
-class RenderTableCell : public RenderBlock
-{
-public:
-    RenderTableCell(DOM::NodeImpl* node);
-
-    virtual void destroy();
-
-    virtual const char *renderName() const { return "RenderTableCell"; }
-    virtual bool isTableCell() const { return true; }
-
-    // overrides RenderObject
-    virtual bool requiresLayer();
-
-    // ### FIX these two...
-    int cellIndex() const { return 0; }
-    void setCellIndex(int) { }
-
-    int colSpan() const { return cSpan; }
-    void setColSpan(int c) { cSpan = c; }
-
-    int rowSpan() const { return rSpan; }
-    void setRowSpan(int r) { rSpan = r; }
-
-    int col() const { return _col; }
-    void setCol(int col) { _col = col; }
-    int row() const { return _row; }
-    void setRow(int r) { _row = r; }
-
-    Length styleOrColWidth();
-
-    // overrides
-    virtual void calcMinMaxWidth();
-    virtual void calcWidth();
-    virtual void setWidth(int width);
-    virtual void setStyle(RenderStyle *style);
-
-    int borderLeft() const;
-    int borderRight() const;
-    int borderTop() const;
-    int borderBottom() const;
-
-    CollapsedBorderValue collapsedLeftBorder() const;
-    CollapsedBorderValue collapsedRightBorder() const;
-    CollapsedBorderValue collapsedTopBorder() const;
-    CollapsedBorderValue collapsedBottomBorder() const;
-    virtual void collectBorders(QValueList<CollapsedBorderValue>& borderStyles);
-
-    virtual void updateFromElement();
-
-    virtual void layout();
-    
-    void setCellTopExtra(int p) { _topExtra = p; }
-    void setCellBottomExtra(int p) { _bottomExtra = p; }
-
-    virtual void paint(PaintInfo& i, int tx, int ty);
-
-    void paintCollapsedBorder(QPainter* p, int x, int y, int w, int h);
-    
-    // lie position to outside observers
-    virtual int yPos() const { return m_y + _topExtra; }
-
-    virtual void computeAbsoluteRepaintRect(IntRect& r, bool f=false);
-    virtual bool absolutePosition(int &xPos, int &yPos, bool f = false);
-
-    virtual short baselinePosition(bool = false) const;
-
-    virtual int borderTopExtra() const { return _topExtra; }
-    virtual int borderBottomExtra() const { return _bottomExtra; }
-
-    RenderTable *table() const { return static_cast<RenderTable *>(parent()->parent()->parent()); }
-    RenderTableSection *section() const { return static_cast<RenderTableSection *>(parent()->parent()); }
-
-#ifndef NDEBUG
-    virtual void dump(QTextStream *stream, QString ind = "") const;
-#endif
-
-    virtual IntRect getAbsoluteRepaintRect();
-    
-protected:
-    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
-    
-    int _row;
-    int _col;
-    int rSpan;
-    int cSpan;
-    int _topExtra : 31;
-    bool nWrap : 1;
-    int _bottomExtra : 31;
-    bool m_widthChanged : 1;
-    
-    int m_percentageHeight;
-};
-
-
-// -------------------------------------------------------------------------
-
-class RenderTableCol : public RenderContainer
-{
-public:
-    RenderTableCol(DOM::NodeImpl* node);
-
-    virtual const char *renderName() const { return "RenderTableCol"; }
-
-    int span() const { return _span; }
-    void setSpan(int s) { _span = s; }
-
-    virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
-
-    virtual bool isTableCol() const { return true; }
-
-    virtual short lineHeight(bool) const { return 0; }
-
-    virtual void updateFromElement();
-
-    virtual bool canHaveChildren() const;
-    
-#ifndef NDEBUG
-    virtual void dump(QTextStream *stream, QString ind = "") const;
-#endif
-
-protected:
-    int _span;
-};
-
-};
-#endif
-
index 3947bda..7034b0c 100644 (file)
  */
 #include "config.h"
 #include "table_layout.h"
-#include "render_table.h"
-
-using namespace khtml;
-
-// #define DEBUG_LAYOUT
+#include "RenderTable.h"
+#include "RenderTableCol.h"
+#include "RenderTableSection.h"
+#include "RenderTableCell.h"
 
 /*
   The text below is from the CSS 2.1 specs.
@@ -79,6 +78,8 @@ _____________________________________________________
 
 */
 
+namespace WebCore {
+
 FixedTableLayout::FixedTableLayout( RenderTable *table )
     : TableLayout ( table )
 {
@@ -1163,3 +1164,5 @@ void AutoTableLayout::calcPercentages() const
 }
 
 #undef DEBUG_LAYOUT
+
+}