2009-06-22 David Hyatt <hyatt@apple.com>
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2009 23:24:23 +0000 (23:24 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2009 23:24:23 +0000 (23:24 +0000)
        Reviewed by Sam Weinig.

        Add RenderDataGrid to the build.  Give it some basic default styling (that more or less matches a listbox).  It has a default size
        of 300x150.

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * css/html4.css:
        * html/HTMLDataGridElement.cpp:
        (WebCore::HTMLDataGridElement::createRenderer):
        * html/HTMLDataGridElement.h:
        * html/HTMLDataGridElement.idl:
        * rendering/RenderDataGrid.cpp: Added.
        (WebCore::RenderDataGrid::RenderDataGrid):
        (WebCore::RenderDataGrid::~RenderDataGrid):
        (WebCore::RenderDataGrid::calcPrefWidths):
        (WebCore::RenderDataGrid::paintObject):
        (WebCore::RenderDataGrid::valueChanged):
        (WebCore::RenderDataGrid::invalidateScrollbarRect):
        (WebCore::RenderDataGrid::isActive):
        * rendering/RenderDataGrid.h: Added.
        (WebCore::RenderDataGrid::renderName):
        (WebCore::RenderDataGrid::canHaveChildren):
        (WebCore::RenderDataGrid::scrollbarCornerPresent):

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

12 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/css/html4.css
WebCore/html/HTMLDataGridElement.cpp
WebCore/html/HTMLDataGridElement.h
WebCore/html/HTMLDataGridElement.idl
WebCore/rendering/RenderDataGrid.cpp [new file with mode: 0644]
WebCore/rendering/RenderDataGrid.h [new file with mode: 0644]

index 21ca788..e3abc49 100644 (file)
@@ -1,3 +1,33 @@
+2009-06-22  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Add RenderDataGrid to the build.  Give it some basic default styling (that more or less matches a listbox).  It has a default size
+        of 300x150.
+
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * css/html4.css:
+        * html/HTMLDataGridElement.cpp:
+        (WebCore::HTMLDataGridElement::createRenderer):
+        * html/HTMLDataGridElement.h:
+        * html/HTMLDataGridElement.idl:
+        * rendering/RenderDataGrid.cpp: Added.
+        (WebCore::RenderDataGrid::RenderDataGrid):
+        (WebCore::RenderDataGrid::~RenderDataGrid):
+        (WebCore::RenderDataGrid::calcPrefWidths):
+        (WebCore::RenderDataGrid::paintObject):
+        (WebCore::RenderDataGrid::valueChanged):
+        (WebCore::RenderDataGrid::invalidateScrollbarRect):
+        (WebCore::RenderDataGrid::isActive):
+        * rendering/RenderDataGrid.h: Added.
+        (WebCore::RenderDataGrid::renderName):
+        (WebCore::RenderDataGrid::canHaveChildren):
+        (WebCore::RenderDataGrid::scrollbarCornerPresent):
+
 2009-06-22  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dave Hyatt.
index ccf9a31..3ec41b0 100644 (file)
@@ -1618,6 +1618,8 @@ webcore_sources += \
        WebCore/rendering/RenderButton.h \
        WebCore/rendering/RenderCounter.cpp \
        WebCore/rendering/RenderCounter.h \
+       WebCore/rendering/RenderDataGrid.cpp \
+       WebCore/rendering/RenderDataGrid.h \
        WebCore/rendering/RenderFieldset.cpp \
        WebCore/rendering/RenderFieldset.h \
        WebCore/rendering/RenderFileUploadControl.cpp \
index 788478a..fc9bf7a 100644 (file)
@@ -1023,6 +1023,7 @@ SOURCES += \
     rendering/RenderBR.cpp \
     rendering/RenderButton.cpp \
     rendering/RenderCounter.cpp \
+    rendering/RenderDataGrid.cpp \
     rendering/RenderFieldset.cpp \
     rendering/RenderFileUploadControl.cpp \
     rendering/RenderFlexibleBox.cpp \
index 04bb3b0..a75d7cd 100644 (file)
                                RelativePath="..\rendering\RenderCounter.h"\r
                                >\r
                        </File>\r
+                        <File\r
+                               RelativePath="..\rendering\RenderDataGrid.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\rendering\RenderDataGrid.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\rendering\RenderFieldset.cpp"\r
                                >\r
index 56e5f80..1bf77a4 100644 (file)
                BC77CDBC0FEFF1420070887B /* HTMLDataGridCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC77CDBB0FEFF1420070887B /* HTMLDataGridCellElement.h */; };
                BC77CDCE0FEFF33B0070887B /* JSHTMLDataGridCellElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC77CDCC0FEFF33B0070887B /* JSHTMLDataGridCellElement.cpp */; };
                BC77CDCF0FEFF33B0070887B /* JSHTMLDataGridCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC77CDCD0FEFF33B0070887B /* JSHTMLDataGridCellElement.h */; };
+               BC77CEB30FF017F20070887B /* RenderDataGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = BC77CEB20FF017F20070887B /* RenderDataGrid.h */; };
+               BC77CEC80FF01CBE0070887B /* RenderDataGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC77CEC70FF01CBE0070887B /* RenderDataGrid.cpp */; };
                BC7F44A80B9E324E00A9D081 /* ImageObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F44A70B9E324E00A9D081 /* ImageObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC7FA6200D1F0CBD00DB22A9 /* DynamicNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7FA61E0D1F0CBD00DB22A9 /* DynamicNodeList.cpp */; };
                BC7FA6210D1F0CBD00DB22A9 /* DynamicNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7FA61F0D1F0CBD00DB22A9 /* DynamicNodeList.h */; };
                BC77CDBB0FEFF1420070887B /* HTMLDataGridCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDataGridCellElement.h; sourceTree = "<group>"; };
                BC77CDCC0FEFF33B0070887B /* JSHTMLDataGridCellElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDataGridCellElement.cpp; sourceTree = "<group>"; };
                BC77CDCD0FEFF33B0070887B /* JSHTMLDataGridCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLDataGridCellElement.h; sourceTree = "<group>"; };
+               BC77CEB20FF017F20070887B /* RenderDataGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderDataGrid.h; sourceTree = "<group>"; };
+               BC77CEC70FF01CBE0070887B /* RenderDataGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDataGrid.cpp; sourceTree = "<group>"; };
                BC7B2AF80450824100A8000F /* Scrollbar.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Scrollbar.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BC7F44A70B9E324E00A9D081 /* ImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageObserver.h; sourceTree = "<group>"; };
                BC7FA61E0D1F0CBD00DB22A9 /* DynamicNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicNodeList.cpp; sourceTree = "<group>"; };
                                BCEA4827097D93020094C9E4 /* RenderButton.h */,
                                9392F1430AD185FE00691BD4 /* RenderCounter.cpp */,
                                9392F1410AD185F400691BD4 /* RenderCounter.h */,
+                               BC77CEC70FF01CBE0070887B /* RenderDataGrid.cpp */,
+                               BC77CEB20FF017F20070887B /* RenderDataGrid.h */,
                                A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */,
                                A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */,
                                066C772E0AB603FD00238CC4 /* RenderFileUploadControl.cpp */,
                                BC77CD4F0FEFE1610070887B /* JSHTMLDataGridRowElement.h in Headers */,
                                BC77CDBC0FEFF1420070887B /* HTMLDataGridCellElement.h in Headers */,
                                BC77CDCF0FEFF33B0070887B /* JSHTMLDataGridCellElement.h in Headers */,
+                               BC77CEB30FF017F20070887B /* RenderDataGrid.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC77CD4E0FEFE1610070887B /* JSHTMLDataGridRowElement.cpp in Sources */,
                                BC77CDB80FEFF1210070887B /* HTMLDataGridCellElement.cpp in Sources */,
                                BC77CDCE0FEFF33B0070887B /* JSHTMLDataGridCellElement.cpp in Sources */,
+                               BC77CEC80FF01CBE0070887B /* RenderDataGrid.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index af866dd..8f9c0b9 100644 (file)
@@ -929,6 +929,7 @@ This file contains the list of files needed to build WebCore.
         rendering/RenderBoxModelObject.cpp
         rendering/RenderButton.cpp
         rendering/RenderCounter.cpp
+        rendering/RenderDataGrid.cpp
         rendering/RenderFieldset.cpp
         rendering/RenderFileUploadControl.cpp
         rendering/RenderFlexibleBox.cpp
index 3e4d111..dc1f608 100644 (file)
@@ -297,7 +297,7 @@ button {
     -webkit-appearance: button;
 }
 
-input, textarea, keygen, select, button, isindex {
+input, textarea, keygen, select, button, isindex, datagrid {
     margin: 0__qem;
     font: -webkit-small-control;
     color: initial;
@@ -421,7 +421,9 @@ input[type="range"]::-webkit-slider-thumb {
     -webkit-appearance: sliderthumb-horizontal;
 }
 
-input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, input[type="file"]:disabled::-webkit-file-upload-button, button:disabled, select:disabled, keygen:disabled, optgroup:disabled, option:disabled {
+input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled,
+input[type="file"]:disabled::-webkit-file-upload-button, button:disabled,
+select:disabled, keygen:disabled, optgroup:disabled, option:disabled, datagrid:disabled {
     color: GrayText
 }
 
@@ -487,6 +489,20 @@ option {
     font-weight: normal;
 }
 
+/* datagrid */
+
+datagrid {
+    height: 150px; /* We don't use width:300px in CSS, since we want width:intrinsic and width:min-intrinsic to reset to 300 properly. */
+    -webkit-appearance: datagrid;
+    -webkit-box-sizing: border-box;
+    -webkit-rtl-ordering: logical;
+    color: black;
+    background-color: white;
+    cursor: default;
+    border: 1px inset gray;
+    white-space: initial;
+}
+
 /* inline elements */
 
 u, ins {
index d806bc4..5220c80 100644 (file)
@@ -27,6 +27,7 @@
 #include "HTMLDataGridElement.h"
 
 #include "HTMLNames.h"
+#include "RenderDataGrid.h"
 #include "Text.h"
 
 namespace WebCore {
@@ -45,6 +46,11 @@ bool HTMLDataGridElement::checkDTD(const Node* newChild)
     return newChild->hasTagName(dcolTag) || newChild->hasTagName(drowTag);
 }
 
+RenderObject* HTMLDataGridElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+    return new (arena) RenderDataGrid(this);
+}
+
 bool HTMLDataGridElement::autofocus() const
 {
     return hasAttribute(autofocusAttr);
@@ -75,14 +81,4 @@ void HTMLDataGridElement::setMultiple(bool multiple)
     setAttribute(multipleAttr, multiple ? "" : 0);
 }
 
-int HTMLDataGridElement::size() const
-{
-    return getAttribute(sizeAttr).toInt();
-}
-
-void HTMLDataGridElement::setSize(int size)
-{
-    setAttribute(sizeAttr, String::number(size));
-}
-
 }
index fc47732..ba0dc9a 100644 (file)
@@ -38,6 +38,8 @@ public:
     virtual int tagPriority() const { return 6; } // Same as <select>s
     virtual bool checkDTD(const Node*);
     
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
     bool autofocus() const;
     void setAutofocus(bool);
     
@@ -46,9 +48,6 @@ public:
     
     bool multiple() const;
     void setMultiple(bool);
-    
-    int size() const;
-    void setSize(int);
 };
 
 } //namespace
index b3a82c0..2f2c54d 100644 (file)
@@ -29,8 +29,6 @@ interface [GenerateConstructor] HTMLDataGridElement : HTMLElement {
     attribute boolean autofocus; // Whether or not the datagrid should autofocus.
     attribute boolean disabled; // Whether or not the datagrid can be interacted with.
     attribute boolean multiple; // Whether or not the datagrid supports multiple selection.
-    
-    attribute boolean size; // The number of rows that the datagrid should be sized to (excludes column headers).
 };
 
 }
diff --git a/WebCore/rendering/RenderDataGrid.cpp b/WebCore/rendering/RenderDataGrid.cpp
new file mode 100644 (file)
index 0000000..32e67a4
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "RenderDataGrid.h"
+
+#include "FocusController.h"
+#include "Frame.h"
+#include "GraphicsContext.h"
+#include "Page.h"
+#include "Scrollbar.h"
+
+using std::min;
+
+namespace WebCore {
+
+static const int cDefaultWidth = 300;
+
+RenderDataGrid::RenderDataGrid(Element* elt)
+    : RenderBlock(elt)
+{
+}
+
+RenderDataGrid::~RenderDataGrid()
+{
+}
+
+void RenderDataGrid::calcPrefWidths()
+{
+    m_minPrefWidth = 0;
+    m_maxPrefWidth = 0;
+
+    if (style()->width().isFixed() && style()->width().value() > 0)
+        m_minPrefWidth = m_maxPrefWidth = calcContentBoxWidth(style()->width().value());
+    else
+        m_maxPrefWidth = calcContentBoxWidth(cDefaultWidth);
+
+    if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
+        m_maxPrefWidth = max(m_maxPrefWidth, calcContentBoxWidth(style()->minWidth().value()));
+        m_minPrefWidth = max(m_minPrefWidth, calcContentBoxWidth(style()->minWidth().value()));
+    } else if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent()))
+        m_minPrefWidth = 0;
+    else
+        m_minPrefWidth = m_maxPrefWidth;
+
+    if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+        m_maxPrefWidth = min(m_maxPrefWidth, calcContentBoxWidth(style()->maxWidth().value()));
+        m_minPrefWidth = min(m_minPrefWidth, calcContentBoxWidth(style()->maxWidth().value()));
+    }
+
+    int toAdd = paddingLeft() + paddingRight() + borderLeft() + borderRight();
+    m_minPrefWidth += toAdd;
+    m_maxPrefWidth += toAdd;
+                                
+    setPrefWidthsDirty(false);
+}
+
+void RenderDataGrid::paintObject(PaintInfo& paintInfo, int tx, int ty)
+{
+    if (style()->visibility() != VISIBLE)
+        return;
+
+    // FIXME: Column and cell foregrounds will paint here.
+    
+    // Paint our background and border.
+    RenderBlock::paintObject(paintInfo, tx, ty);
+    
+    // FIXME: Row, cell and column backgrounds will paint here.
+}
+
+// Scrolling implementation functions
+void RenderDataGrid::valueChanged(Scrollbar*)
+{
+    // FIXME: Implement.
+}
+
+void RenderDataGrid::invalidateScrollbarRect(Scrollbar*, const IntRect&)
+{
+    // FIXME: Implement.
+}
+
+bool RenderDataGrid::isActive() const
+{
+    Page* page = document()->frame()->page();
+    return page && page->focusController()->isActive();
+}
+
+}
diff --git a/WebCore/rendering/RenderDataGrid.h b/WebCore/rendering/RenderDataGrid.h
new file mode 100644 (file)
index 0000000..a6566d7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RenderDataGrid_h
+#define RenderDataGrid_h
+
+#include "RenderBlock.h"
+#include "ScrollbarClient.h"
+
+namespace WebCore {
+
+class RenderDataGrid : public RenderBlock, private ScrollbarClient {
+public:
+    RenderDataGrid(Element*);
+    ~RenderDataGrid();
+    
+    virtual const char* renderName() const { return "RenderDataGrid"; }
+
+    virtual bool canHaveChildren() const { return false; }
+    
+    virtual void calcPrefWidths();
+    
+    virtual void paintObject(PaintInfo&, int tx, int ty);
+
+private:
+    // ScrollbarClient interface.
+    virtual void valueChanged(Scrollbar*);
+    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
+    virtual bool isActive() const;
+    virtual bool scrollbarCornerPresent() const { return false; } // We don't support resize on data grids yet.  If we did this would have to change.
+
+    RefPtr<Scrollbar> m_vBar;
+};
+
+}
+
+#endif // RenderDataGrid_h