webengine/osswebengine/WebCore/rendering/InlineTextBox.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * This file is part of the DOM implementation for KDE.
       
     3  *
       
     4  * (C) 1999 Lars Knoll (knoll@kde.org)
       
     5  * (C) 2000 Dirk Mueller (mueller@kde.org)
       
     6  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
       
     7  *
       
     8  * This library is free software; you can redistribute it and/or
       
     9  * modify it under the terms of the GNU Library General Public
       
    10  * License as published by the Free Software Foundation; either
       
    11  * version 2 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This library is distributed in the hope that it will be useful,
       
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16  * Library General Public License for more details.
       
    17  *
       
    18  * You should have received a copy of the GNU Library General Public License
       
    19  * along with this library; see the file COPYING.LIB.  If not, write to
       
    20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    21  * Boston, MA 02110-1301, USA.
       
    22  *
       
    23  */
       
    24 
       
    25 #ifndef InlineTextBox_h
       
    26 #define InlineTextBox_h
       
    27 
       
    28 #include "DocumentMarker.h"
       
    29 #include "InlineRunBox.h"
       
    30 #include "RenderText.h"
       
    31 
       
    32 namespace WebCore {
       
    33 
       
    34 const unsigned short cNoTruncation = USHRT_MAX;
       
    35 const unsigned short cFullTruncation = USHRT_MAX - 1;
       
    36 
       
    37 class String;
       
    38 class StringImpl;
       
    39 class HitTestResult;
       
    40 class Position;
       
    41 
       
    42 struct CompositionUnderline;
       
    43 
       
    44 class InlineTextBox : public InlineRunBox {
       
    45 public:
       
    46     InlineTextBox(RenderObject* obj)
       
    47         : InlineRunBox(obj)
       
    48         , m_start(0)
       
    49         , m_len(0)
       
    50         , m_truncation(cNoTruncation)
       
    51     {
       
    52     }
       
    53 
       
    54     InlineTextBox* nextTextBox() const { return static_cast<InlineTextBox*>(nextLineBox()); }
       
    55     InlineTextBox* prevTextBox() const { return static_cast<InlineTextBox*>(prevLineBox()); }
       
    56 
       
    57     unsigned start() const { return m_start; }
       
    58     unsigned end() const { return m_len ? m_start + m_len - 1 : m_start; }
       
    59     unsigned len() const { return m_len; }
       
    60 
       
    61     void setStart(unsigned start) { m_start = start; }
       
    62     void setLen(unsigned len) { m_len = len; }
       
    63 
       
    64     void offsetRun(int d) { m_start += d; }
       
    65 
       
    66     virtual int selectionTop();
       
    67     virtual int selectionHeight();
       
    68 
       
    69     IntRect selectionRect(int absx, int absy, int startPos, int endPos);
       
    70     bool isSelected(int startPos, int endPos) const;
       
    71     void selectionStartEnd(int& sPos, int& ePos);
       
    72 
       
    73     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
       
    74     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
       
    75 
       
    76     RenderText* textObject() const;
       
    77 
       
    78     virtual void deleteLine(RenderArena*);
       
    79     virtual void extractLine();
       
    80     virtual void attachLine();
       
    81 
       
    82     virtual RenderObject::SelectionState selectionState();
       
    83 
       
    84     virtual void clearTruncation() { m_truncation = cNoTruncation; }
       
    85     virtual int placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool& foundBox);
       
    86 
       
    87     virtual bool isLineBreak() const;
       
    88 
       
    89     void setSpaceAdd(int add) { m_width -= m_toAdd; m_toAdd = add; m_width += m_toAdd; }
       
    90     int spaceAdd() { return m_toAdd; }
       
    91 
       
    92     virtual bool isInlineTextBox() { return true; }    
       
    93     virtual bool isText() const { return m_treatAsText; }
       
    94     void setIsText(bool b) { m_treatAsText = b; }
       
    95 
       
    96     void paintDecoration(GraphicsContext*, int tx, int ty, int decoration);
       
    97     void paintSelection(GraphicsContext*, int tx, int ty, RenderStyle*, const Font*);
       
    98     void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font*, int startPos, int endPos);
       
    99     void paintDocumentMarkers(GraphicsContext*, int tx, int ty, RenderStyle*, const Font*, bool background);
       
   100     void paintSpellingOrGrammarMarker(GraphicsContext*, int tx, int ty, DocumentMarker, RenderStyle*, const Font*, bool grammar);
       
   101     void paintTextMatchMarker(GraphicsContext*, int tx, int ty, DocumentMarker, RenderStyle*, const Font*);
       
   102     void paintCompositionUnderline(GraphicsContext*, int tx, int ty, const CompositionUnderline&);
       
   103 #if PLATFORM(MAC)
       
   104     void paintCustomHighlight(int tx, int ty, const AtomicString& type);
       
   105 #endif
       
   106     virtual int caretMinOffset() const;
       
   107     virtual int caretMaxOffset() const;
       
   108     virtual unsigned caretMaxRenderedOffset() const;
       
   109 
       
   110     int textPos() const;
       
   111     int offsetForPosition(int x, bool includePartialGlyphs = true) const;
       
   112     int positionForOffset(int offset) const;
       
   113 
       
   114     bool containsCaretOffset(int offset) const; // false for offset after line break
       
   115 
       
   116     int m_start;
       
   117     unsigned short m_len;
       
   118 
       
   119     unsigned short m_truncation; // Where to truncate when text overflow is applied.  We use special constants to
       
   120                       // denote no truncation (the whole run paints) and full truncation (nothing paints at all).
       
   121 
       
   122 private:
       
   123     friend class RenderText;
       
   124 };
       
   125 
       
   126 inline RenderText* InlineTextBox::textObject() const
       
   127 {
       
   128     return static_cast<RenderText*>(m_object);
       
   129 }
       
   130 
       
   131 } // namespace WebCore
       
   132 
       
   133 #endif // InlineTextBox_h