Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Library General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Library General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Library General Public License
     17  * along with this library; see the file COPYING.LIB.  If not, write to
     18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     19  * Boston, MA 02110-1301, USA.
     20  *
     21  */
     22 
     23 #ifndef RenderListMarker_h
     24 #define RenderListMarker_h
     25 
     26 #include "RenderBox.h"
     27 
     28 namespace WebCore {
     29 
     30 class RenderListItem;
     31 
     32 String listMarkerText(EListStyleType, int value);
     33 
     34 // Used to render the list item's marker.
     35 // The RenderListMarker always has to be a child of a RenderListItem.
     36 class RenderListMarker : public RenderBox {
     37 public:
     38     RenderListMarker(RenderListItem*);
     39     virtual ~RenderListMarker();
     40 
     41     virtual void calcPrefWidths();
     42 
     43     const String& text() const { return m_text; }
     44 
     45     bool isInside() const;
     46 
     47 private:
     48     virtual const char* renderName() const { return "RenderListMarker"; }
     49 
     50     virtual bool isListMarker() const { return true; }
     51 
     52     virtual void paint(PaintInfo&, int tx, int ty);
     53 
     54     virtual void layout();
     55 
     56     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
     57 
     58     virtual InlineBox* createInlineBox();
     59 
     60     virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
     61     virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const;
     62 
     63     bool isImage() const;
     64     bool isText() const { return !isImage(); }
     65 
     66     virtual void setSelectionState(SelectionState);
     67     virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
     68     virtual bool canBeSelectionLeaf() const { return true; }
     69 
     70     void updateMargins();
     71 
     72     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     73     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     74 
     75     IntRect getRelativeMarkerRect();
     76     IntRect localSelectionRect();
     77 
     78     String m_text;
     79     RefPtr<StyleImage> m_image;
     80     RenderListItem* m_listItem;
     81 };
     82 
     83 inline RenderListMarker* toRenderListMarker(RenderObject* object)
     84 {
     85     ASSERT(!object || object->isListMarker());
     86     return static_cast<RenderListMarker*>(object);
     87 }
     88 
     89 inline const RenderListMarker* toRenderListMarker(const RenderObject* object)
     90 {
     91     ASSERT(!object || object->isListMarker());
     92     return static_cast<const RenderListMarker*>(object);
     93 }
     94 
     95 // This will catch anyone doing an unnecessary cast.
     96 void toRenderListMarker(const RenderListMarker*);
     97 
     98 } // namespace WebCore
     99 
    100 #endif // RenderListMarker_h
    101