File indexing completed on 2024-04-28 15:23:59

0001 /*
0002  * This file is part of the html renderer for KDE.
0003  *
0004  * Copyright (C) 2001 Antti Koivisto (koivisto@kde.org)
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  */
0022 #ifndef render_container_h
0023 #define render_container_h
0024 
0025 #include "render_object.h"
0026 
0027 namespace khtml
0028 {
0029 
0030 /**
0031  * Base class for rendering objects that can have children
0032  */
0033 class RenderContainer : public RenderObject
0034 {
0035 public:
0036     RenderContainer(DOM::NodeImpl *node);
0037 
0038     RenderObject *firstChild() const override
0039     {
0040         return m_first;
0041     }
0042     RenderObject *lastChild() const override
0043     {
0044         return m_last;
0045     }
0046 
0047     bool childAllowed() const override
0048     {
0049         // Prevent normal children when we are replaced by generated content
0050         if (style()) {
0051             return style()->useNormalContent();
0052         }
0053         return true;
0054     }
0055 
0056     void addChild(RenderObject *newChild, RenderObject *beforeChild = nullptr) override;
0057 
0058     RenderObject *removeChildNode(RenderObject *child) override;
0059     void appendChildNode(RenderObject *child) override;
0060     void insertChildNode(RenderObject *child, RenderObject *before) override;
0061 
0062     void layout() override;
0063     void calcMinMaxWidth() override
0064     {
0065         setMinMaxKnown(true);
0066     }
0067 
0068     void removeSuperfluousAnonymousBlockChild(RenderObject *child) override;
0069 
0070     void setStyle(RenderStyle *_style) override;
0071 
0072     RenderPosition positionForCoordinates(int x, int y) override;
0073 
0074 protected:
0075     // Generate CSS content
0076     void createGeneratedContent();
0077     void updateReplacedContent();
0078 
0079     void updatePseudoChildren();
0080     void updatePseudoChild(RenderStyle::PseudoId type);
0081 
0082     RenderContainer *pseudoContainer(RenderStyle::PseudoId type) const;
0083     void addPseudoContainer(RenderObject *child);
0084 private:
0085 
0086     void setFirstChild(RenderObject *first)
0087     {
0088         m_first = first;
0089     }
0090     void setLastChild(RenderObject *last)
0091     {
0092         m_last = last;
0093     }
0094 
0095 protected:
0096 
0097     RenderObject *m_first;
0098     RenderObject *m_last;
0099 };
0100 
0101 }
0102 #endif