Reviewed by Hyatt and Darin.
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2006 09:35:14 +0000 (09:35 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2006 09:35:14 +0000 (09:35 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6665
        Implement NSView-less version of <input type="text">

        Initial implementation of new and improved text fields.
        This will only be turned on if an input element has khtml-appearance: textfield.

        * WebCore.xcodeproj/project.pbxproj: Added RenderTextField.h and RenderTextField.cpp
        * css/cssvalues.in: Fixed omitted button-bevel value.
          This was causing an off-by-one error when getting khtml-appearance value.
        * khtml/html/HTMLInputElementImpl.cpp: Added checks for khtml-appearance to decide
          when to use RenderTextField instead of RenderLineEdit.
        (DOM::HTMLInputElementImpl::selectionStart):
        (DOM::HTMLInputElementImpl::selectionEnd):
        (DOM::HTMLInputElementImpl::setSelectionStart):
        (DOM::HTMLInputElementImpl::setSelectionEnd):
        (DOM::HTMLInputElementImpl::select):
        (DOM::HTMLInputElementImpl::setSelectionRange):
        (DOM::HTMLInputElementImpl::createRenderer):
        (DOM::HTMLInputElementImpl::defaultEventHandler):
        * khtml/html/HTMLInputElementImpl.h:
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::isFocusable): Also allow editable elements with no parent to be focusable.
        * khtml/xml/NodeImpl.h:
        (WebCore::NodeImpl::setAttached): Added to set m_attached without having to call attach().
        * rendering/RenderTextField.cpp: Added.
        (khtml:::RenderBlock):
        (khtml::RenderTextField::~RenderTextField):
        (khtml::RenderTextField::addChild):
        (khtml::RenderTextField::removeChild):
        (khtml::RenderTextField::setStyle):
        (khtml::RenderTextField::getDivStyle):
        (khtml::RenderTextField::updateFromElement):
        (khtml::RenderTextField::selectionStart):
        (khtml::RenderTextField::selectionEnd):
        (khtml::RenderTextField::setSelectionStart):
        (khtml::RenderTextField::setSelectionEnd):
        (khtml::RenderTextField::select):
        (khtml::RenderTextField::setSelectionRange):
        * rendering/RenderTextField.h: Added.
        (khtml::RenderTextField::removeLeftoverAnonymousBoxes):
        (khtml::RenderTextField::renderName):
        * rendering/render_container.cpp:
        (RenderContainer::destroy): use renamed destroyLeftoverChildren.
        (RenderContainer::destroyLeftoverChildren): renamed from destroyLeftoverAnonymousChildren.
        * rendering/render_container.h:
        * rendering/render_flow.cpp:
        (RenderFlow::destroy): use renamed destroyLeftoverChildren.

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

12 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/css/cssvalues.in
WebCore/khtml/html/HTMLInputElementImpl.cpp
WebCore/khtml/html/HTMLInputElementImpl.h
WebCore/khtml/html/html_elementimpl.cpp
WebCore/khtml/xml/NodeImpl.h
WebCore/rendering/RenderTextField.cpp [new file with mode: 0644]
WebCore/rendering/RenderTextField.h [new file with mode: 0644]
WebCore/rendering/render_container.cpp
WebCore/rendering/render_container.h
WebCore/rendering/render_flow.cpp

index 64605f2..250e505 100644 (file)
@@ -1,3 +1,55 @@
+2006-01-19  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt and Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6665
+        Implement NSView-less version of <input type="text">
+        
+        Initial implementation of new and improved text fields.  
+        This will only be turned on if an input element has khtml-appearance: textfield.
+
+        * WebCore.xcodeproj/project.pbxproj: Added RenderTextField.h and RenderTextField.cpp
+        * css/cssvalues.in: Fixed omitted button-bevel value.  
+          This was causing an off-by-one error when getting khtml-appearance value.
+        * khtml/html/HTMLInputElementImpl.cpp: Added checks for khtml-appearance to decide 
+          when to use RenderTextField instead of RenderLineEdit.
+        (DOM::HTMLInputElementImpl::selectionStart):
+        (DOM::HTMLInputElementImpl::selectionEnd):
+        (DOM::HTMLInputElementImpl::setSelectionStart):
+        (DOM::HTMLInputElementImpl::setSelectionEnd):
+        (DOM::HTMLInputElementImpl::select):
+        (DOM::HTMLInputElementImpl::setSelectionRange):
+        (DOM::HTMLInputElementImpl::createRenderer):
+        (DOM::HTMLInputElementImpl::defaultEventHandler):
+        * khtml/html/HTMLInputElementImpl.h:
+        * khtml/html/html_elementimpl.cpp:
+        (HTMLElementImpl::isFocusable): Also allow editable elements with no parent to be focusable.
+        * khtml/xml/NodeImpl.h:
+        (WebCore::NodeImpl::setAttached): Added to set m_attached without having to call attach().
+        * rendering/RenderTextField.cpp: Added.
+        (khtml:::RenderBlock):
+        (khtml::RenderTextField::~RenderTextField):
+        (khtml::RenderTextField::addChild):
+        (khtml::RenderTextField::removeChild):
+        (khtml::RenderTextField::setStyle):
+        (khtml::RenderTextField::getDivStyle):
+        (khtml::RenderTextField::updateFromElement):
+        (khtml::RenderTextField::selectionStart):
+        (khtml::RenderTextField::selectionEnd):
+        (khtml::RenderTextField::setSelectionStart):
+        (khtml::RenderTextField::setSelectionEnd):
+        (khtml::RenderTextField::select):
+        (khtml::RenderTextField::setSelectionRange):
+        * rendering/RenderTextField.h: Added.
+        (khtml::RenderTextField::removeLeftoverAnonymousBoxes):
+        (khtml::RenderTextField::renderName):
+        * rendering/render_container.cpp:
+        (RenderContainer::destroy): use renamed destroyLeftoverChildren.
+        (RenderContainer::destroyLeftoverChildren): renamed from destroyLeftoverAnonymousChildren.
+        * rendering/render_container.h:
+        * rendering/render_flow.cpp:
+        (RenderFlow::destroy): use renamed destroyLeftoverChildren.
+
 2006-01-18  Darin Adler  <darin@apple.com>
 
         Reviewed by Hyatt.
index ffe8bcb..3fa8c2e 100644 (file)
                A8FEFB0B0979F472005839FD /* RenderForeignObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8FEFB090979F472005839FD /* RenderForeignObject.cpp */; };
                A8FEFB310979F4F6005839FD /* SVGForeignObjectElementImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElementImpl.cpp */; };
                A8FEFB320979F4F6005839FD /* SVGForeignObjectElementImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB300979F4F6005839FD /* SVGForeignObjectElementImpl.h */; };
+               AB67D1A8097F3AE300F9392E /* RenderTextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */; };
+               AB67D1A9097F3AE300F9392E /* RenderTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextField.h */; };
+               AB67D1AA097F3AE300F9392E /* RenderTextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */; };
+               AB67D1AB097F3AE300F9392E /* RenderTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextField.h */; };
                AED9800C0976B38E000609F6 /* Selection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED9800A0976B38E000609F6 /* Selection.cpp */; };
                AED9800D0976B38E000609F6 /* Selection.h in Headers */ = {isa = PBXBuildFile; fileRef = AED9800B0976B38E000609F6 /* Selection.h */; };
                AED9800E0976B38E000609F6 /* Selection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED9800A0976B38E000609F6 /* Selection.cpp */; };
                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>"; };
                A8FEFB300979F4F6005839FD /* SVGForeignObjectElementImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGForeignObjectElementImpl.h; sourceTree = "<group>"; };
+               AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextField.cpp; sourceTree = "<group>"; };
+               AB67D1A7097F3AE300F9392E /* RenderTextField.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextField.h; sourceTree = "<group>"; };
                AED9800A0976B38E000609F6 /* Selection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Selection.cpp; path = editing/Selection.cpp; sourceTree = "<group>"; };
                AED9800B0976B38E000609F6 /* Selection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Selection.h; path = editing/Selection.h; sourceTree = "<group>"; };
                BC06F24906D18A7E004A6FA3 /* xsl_stylesheetimpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xsl_stylesheetimpl.cpp; path = xsl/xsl_stylesheetimpl.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F523D2F302DE443B018635CA /* rendering */ = {
                        isa = PBXGroup;
                        children = (
+                               AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */,
+                               AB67D1A7097F3AE300F9392E /* RenderTextField.h */,
                                BCEA4813097D93020094C9E4 /* bidi.cpp */,
                                BCEA4814097D93020094C9E4 /* bidi.h */,
                                BCEA4815097D93020094C9E4 /* break_lines.cpp */,
                                BCEA4890097D93020094C9E4 /* table_layout.h in Headers */,
                                BCEA4944097F0F5C0094C9E4 /* BrowserExtension.h in Headers */,
                                BCEA4947097F0F770094C9E4 /* BrowserExtensionMac.h in Headers */,
+                               AB67D1A9097F3AE300F9392E /* RenderTextField.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA48CB097D93020094C9E4 /* RenderText.h in Headers */,
                                BCEA48CD097D93020094C9E4 /* RenderTextFragment.h in Headers */,
                                BCEA48CF097D93020094C9E4 /* table_layout.h in Headers */,
+                               AB67D1AB097F3AE300F9392E /* RenderTextField.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA488F097D93020094C9E4 /* table_layout.cpp in Sources */,
                                937A36A7097E2E3200E4EE2F /* UserAgentStyleSheets.cpp in Sources */,
                                BCEA4948097F0F770094C9E4 /* BrowserExtensionMac.mm in Sources */,
+                               AB67D1A8097F3AE300F9392E /* RenderTextField.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCEA48CC097D93020094C9E4 /* RenderTextFragment.cpp in Sources */,
                                BCEA48CE097D93020094C9E4 /* table_layout.cpp in Sources */,
                                937A36A8097E2E3200E4EE2F /* UserAgentStyleSheets.cpp in Sources */,
+                               AB67D1AA097F3AE300F9392E /* RenderTextField.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index a4e7a2d..b0af53f 100644 (file)
@@ -445,6 +445,7 @@ radio
 push-button
 square-button
 button
+button-bevel
 listbox
 listitem
 menulist
index e77bfa3..6997cc9 100644 (file)
@@ -32,8 +32,9 @@
 #include "FormDataList.h"
 
 #include "cssproperties.h"
-#include "rendering/render_form.h"
-#include "rendering/render_button.h"
+#include "render_form.h"
+#include "render_button.h"
+#include "RenderTextField.h"
 #include "render_theme.h"
 #include "DocumentImpl.h"
 
@@ -282,8 +283,11 @@ int HTMLInputElementImpl::selectionStart()
     
     switch (m_type) {
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                 return static_cast<RenderTextField *>(m_render)->selectionStart();
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             return static_cast<RenderLineEdit *>(m_render)->selectionStart();
         default:
             break;
@@ -297,8 +301,11 @@ int HTMLInputElementImpl::selectionEnd()
     
     switch (m_type) {
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                 return static_cast<RenderTextField *>(m_render)->selectionEnd();
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             return static_cast<RenderLineEdit *>(m_render)->selectionEnd();
         default:
             break;
@@ -312,8 +319,11 @@ void HTMLInputElementImpl::setSelectionStart(int start)
     
     switch (m_type) {
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                 static_cast<RenderTextField *>(m_render)->setSelectionStart(start);
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             static_cast<RenderLineEdit *>(m_render)->setSelectionStart(start);
             break;
         default:
@@ -327,8 +337,11 @@ void HTMLInputElementImpl::setSelectionEnd(int end)
     
     switch (m_type) {
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                 static_cast<RenderTextField *>(m_render)->setSelectionEnd(end);
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             static_cast<RenderLineEdit *>(m_render)->setSelectionEnd(end);
             break;
         default:
@@ -345,8 +358,11 @@ void HTMLInputElementImpl::select(  )
             static_cast<RenderFileButton*>(m_render)->select();
             break;
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                 static_cast<RenderTextField *>(m_render)->select();
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             static_cast<RenderLineEdit*>(m_render)->select();
             break;
         case BUTTON:
@@ -368,8 +384,11 @@ void HTMLInputElementImpl::setSelectionRange(int start, int end)
     
     switch (m_type) {
         case PASSWORD:
-        case SEARCH:
         case TEXT:
+            if (m_render->style()->appearance() == TextFieldAppearance)
+                static_cast<RenderTextField *>(m_render)->setSelectionRange(start, end);
+            // Fall through for text fields that don't specify appearance
+        case SEARCH:
             static_cast<RenderLineEdit *>(m_render)->setSelectionRange(start, end);
             break;
         default:
@@ -572,6 +591,9 @@ RenderObject *HTMLInputElementImpl::createRenderer(RenderArena *arena, RenderSty
     {
     case TEXT:
     case PASSWORD:
+        if (style->appearance() == TextFieldAppearance)
+            return new (arena) RenderTextField(this);
+        // Fall through for text fields that don't specify appearance
     case SEARCH:
     case ISINDEX:  return new (arena) RenderLineEdit(this);
     case CHECKBOX:
index c7cc59b..a4ddd3d 100644 (file)
@@ -31,6 +31,7 @@ namespace khtml {
     class RenderLineEdit;
     class RenderFileButton;
     class RenderSlider;
+    class RenderTextField;
 }
 
 namespace DOM {
index 04802d7..0a3f39e 100644 (file)
@@ -461,7 +461,9 @@ void HTMLElementImpl::addHTMLAlignment(MappedAttributeImpl* attr)
 
 bool HTMLElementImpl::isFocusable() const
 {
-    return isContentEditable() && parent() && !parent()->isContentEditable();
+    // Added the check for !parent() so shadow elements, like those in engine-based textfields, can get focus.
+    // We may reevaluate this when we resolve outstanding focus issues with these shadow elements.
+    return isContentEditable() && ((parent() && !parent()->isContentEditable()) || !parent());
 }
 
 bool HTMLElementImpl::isContentEditable() const 
index 13e45f7..9b7382b 100644 (file)
@@ -210,6 +210,7 @@ public:
     bool hovered() const { return m_hovered; }
     bool focused() const { return m_focused; }
     bool attached() const   { return m_attached; }
+    void setAttached(bool b = true) { m_attached = b; }
     bool changed() const    { return m_changed; }
     bool hasChangedChild() const { return m_hasChangedChild; }
     bool isLink() const { return m_isLink; }
diff --git a/WebCore/rendering/RenderTextField.cpp b/WebCore/rendering/RenderTextField.cpp
new file mode 100644 (file)
index 0000000..da8675e
--- /dev/null
@@ -0,0 +1,158 @@
+/**
+ * Copyright (C) 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 "DocumentImpl.h"
+#include "RenderTextField.h"
+#include "RenderText.h"
+#include "htmlnames.h"
+#include "HTMLInputElementImpl.h"
+
+using namespace DOM;
+using namespace HTMLNames;
+
+namespace WebCore {
+
+RenderTextField::RenderTextField(NodeImpl* node)
+:RenderBlock(node)
+{
+}
+
+RenderTextField::~RenderTextField()
+{
+    // The renderer for the div has already been destroyed by destroyLeftoverChildren
+    if (m_div)
+        m_div->detach();
+}
+
+void RenderTextField::setStyle(RenderStyle* style)
+{
+    RenderBlock::setStyle(style);
+    if (m_div) {
+        RenderBlock* divRenderer = static_cast<RenderBlock*>(m_div->renderer());
+        RenderStyle* divStyle = createDivStyle(style);
+        if (divRenderer->firstChild())
+            divRenderer->firstChild()->setStyle(divStyle);
+        divRenderer->setStyle(divStyle);
+    }
+    setReplaced(isInline());
+}
+
+RenderStyle* RenderTextField::createDivStyle(RenderStyle* startStyle)
+{
+    RenderStyle* divStyle = new (renderArena()) RenderStyle();
+    divStyle->inheritFrom(startStyle);
+    divStyle->setDisplay(BLOCK);
+    divStyle->setOverflow(OHIDDEN);
+    divStyle->setWhiteSpace(NOWRAP);
+    divStyle->setUserModify(READ_WRITE);
+    
+    // FIXME: Remove these once we get the render theme up and working.
+    divStyle->setOutlineWidth(1);
+    divStyle->setOutlineStyle(SOLID);
+    divStyle->setPaddingTop(Length(2, Fixed));
+    divStyle->setPaddingBottom(Length(2, Fixed));
+    divStyle->setPaddingLeft(Length(2, Fixed));
+    divStyle->setPaddingRight(Length(2, Fixed));
+    divStyle->setWidth(Length(150, Fixed));
+    
+    return divStyle;
+}
+
+void RenderTextField::updateFromElement()
+{
+    if (element()->hasTagName(inputTag)) {
+        HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(element());
+        DOMString value = input->value();
+        if (value.isNull())
+            value = DOMString("");
+            
+        if (!m_div) {
+            // Create the div and give it a parent, renderer, and style
+            m_div = new HTMLDivElementImpl(document());
+            RenderBlock* divRenderer = new (renderArena()) RenderBlock(m_div.get());
+            m_div->setRenderer(divRenderer);
+            m_div->setAttached();
+            m_div->setInDocument(true);
+            // FIXME:  Address focus and event problems with this shadow DOM.
+            // For example, events should appear to occur on the input element, but must take affect on this div.
+            
+            RenderStyle* divStyle = createDivStyle(style());
+            divRenderer->setStyle(divStyle); 
+            
+            // Add div to Render tree
+            RenderBlock::addChild(divRenderer);
+        }
+        
+        TextImpl* text = static_cast<TextImpl*>(m_div->firstChild());
+        if (!text) {
+            // Add text node to DOM tree
+            text = new TextImpl(document(), value.impl());
+            int exception = 0;
+            m_div->appendChild(text, exception);
+        }
+        
+        if (!input->valueMatchesRenderer()) {
+            DOMString oldText = text->data();
+            value.replace(QChar('\\'), backslashAsCurrencySymbol());
+            if (value != oldText) {
+                int exception = 0;
+                text->setData(value, exception);
+                //FIXME: Update cursor as necessary
+            }
+            input->setValueMatchesRenderer();
+        }
+    }
+}
+
+
+int RenderTextField::selectionStart()
+{
+    // FIXME: Implement this.
+    return 0;
+}
+
+int RenderTextField::selectionEnd()
+{
+    // FIXME: Implement this.
+    return 0;
+}
+
+void RenderTextField::setSelectionStart(int start)
+{
+    // FIXME: Implement this.
+}
+void RenderTextField::setSelectionEnd(int end)
+{
+    // FIXME: Implement this.
+}
+    
+void RenderTextField::select()
+{
+    // FIXME: Implement this.
+}
+
+void RenderTextField::setSelectionRange(int start, int end)
+{
+    // FIXME: Implement this.
+}
+
+}
diff --git a/WebCore/rendering/RenderTextField.h b/WebCore/rendering/RenderTextField.h
new file mode 100644 (file)
index 0000000..212c412
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2006 Apple Computer
+ *
+ * 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 RenderTextField_H
+#define RenderTextField_H
+
+#include "render_flexbox.h"
+#include "html_blockimpl.h"
+
+namespace WebCore
+{
+
+class RenderTextField : public RenderBlock
+{
+public:
+    RenderTextField(DOM::NodeImpl* node);
+    virtual ~RenderTextField();
+
+    virtual void removeLeftoverAnonymousBoxes() {};
+
+    virtual void setStyle(RenderStyle* style);
+    RenderStyle* createDivStyle(RenderStyle* startStyle);
+    virtual void updateFromElement();
+
+    virtual const char *renderName() const { return "RenderTextField"; }
+    
+    int selectionStart();
+    int selectionEnd();
+    void setSelectionStart(int);
+    void setSelectionEnd(int);
+    
+    void select();
+    void setSelectionRange(int, int);
+
+protected:
+    RefPtr<HTMLDivElementImpl> m_div;
+};
+
+};
+#endif
index 124e6b1..5cbdde8 100644 (file)
@@ -56,17 +56,21 @@ RenderContainer::~RenderContainer()
 
 void RenderContainer::destroy()
 {
-    destroyLeftoverAnonymousChildren();
+    destroyLeftoverChildren();
     RenderBox::destroy();
 }
 
-void RenderContainer::destroyLeftoverAnonymousChildren()
+void RenderContainer::destroyLeftoverChildren()
 {
     while (m_first) {
         if (m_first->isListMarker())
             m_first->remove();  // List markers are owned by their enclosing list and so don't get destroyed by this container.
-        else
+        else {
+        // Destroy any anonymous children remaining in the render tree, as well as implicit (shadow) DOM elements like those used in the engine-based textfields.
+            if (m_first->element())
+                m_first->element()->setRenderer(0);
             m_first->destroy();
+        }
     }
 }
 
index 2ca3b35..df8742a 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual void removeChild(RenderObject *oldChild);
 
     virtual void destroy();
-    void destroyLeftoverAnonymousChildren();
+    void destroyLeftoverChildren();
     
     virtual RenderObject* removeChildNode(RenderObject* child);
     virtual void appendChildNode(RenderObject* child);
index 91a4024..8030baa 100644 (file)
@@ -186,7 +186,7 @@ void RenderFlow::destroy()
     
     // Make sure to destroy anonymous children first while they are still connected to the rest of the tree, so that they will
     // properly dirty line boxes that they are removed from.  Effects that do :before/:after only on hover could crash otherwise.
-    RenderContainer::destroyLeftoverAnonymousChildren();
+    RenderContainer::destroyLeftoverChildren();
     
     if (!documentBeingDestroyed()) {
         if (m_firstLineBox) {