root/trunk/WebCore/rendering/RenderText.h

Revision 34693, 6.9 kB (checked in by timothy@apple.com, 1 month ago)

Fixes: Bug 19679: iframes with a height of 32,768px or greater do not layout correctly

WebCore:

2008-06-19 Timothy Hatcher <timothy@apple.com>

Changed all lineHeight, baselinePosition and verticalPositionHint
calls to return int instead of short. The short was overflowing
when a value greater than 32,767 was encountered.

Fixes: iframes with a height of 32,768px or greater do not layout correctly
https://bugs.webkit.org/show_bug.cgi?id=19679

Reviewed by Dave Hyatt.

Test: fast/css/line-height-overflow.html

  • rendering/RenderBR.cpp:
    (WebCore::RenderBR::baselinePosition):
  • rendering/RenderBR.h:
  • rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::lineHeight):
  • rendering/RenderBlock.h:
  • rendering/RenderFlow.cpp:
  • rendering/RenderFlow.h:
  • rendering/RenderListBox.cpp:
  • rendering/RenderListBox.h:
  • rendering/RenderListMarker.cpp:
    (WebCore::RenderListMarker::lineHeight):
  • rendering/RenderListMarker.h:
  • rendering/RenderObject.cpp:
    (WebCore::RenderObject::verticalPositionHint):
  • rendering/RenderObject.h:
    (WebCore::):
  • rendering/RenderPath.cpp:
    (WebCore::RenderPath::lineHeight):
  • rendering/RenderPath.h:
  • rendering/RenderReplaced.cpp:
    (WebCore::RenderReplaced::lineHeight):
  • rendering/RenderReplaced.h:
  • rendering/RenderSVGContainer.cpp:
    (WebCore::RenderSVGContainer::lineHeight):
  • rendering/RenderSVGContainer.h:
  • rendering/RenderSVGHiddenContainer.cpp:
    (WebCore::RenderSVGHiddenContainer::lineHeight):
  • rendering/RenderSVGHiddenContainer.h:
  • rendering/RenderSVGRoot.cpp:
    (WebCore::RenderSVGRoot::lineHeight):
  • rendering/RenderSVGRoot.h:
  • rendering/RenderSlider.cpp:
  • rendering/RenderSlider.h:
  • rendering/RenderTableCell.cpp:
  • rendering/RenderTableCell.h:
  • rendering/RenderTableCol.h:
  • rendering/RenderTableRow.h:
  • rendering/RenderTableSection.h:
  • rendering/RenderText.cpp:
  • rendering/RenderText.h:
  • rendering/RenderTextControl.cpp:
  • rendering/RenderTextControl.h:
  • rendering/RenderTheme.cpp:
  • rendering/RenderTheme.h:
  • rendering/RenderThemeMac.h:
  • rendering/RenderThemeMac.mm:
  • rendering/RenderThemeSafari.cpp:
  • rendering/RenderThemeSafari.h:

LayoutTests:

2008-06-19 Timothy Hatcher <timothy@apple.com>

Test for: iframes with a height of 32,768px or greater do not layout correctly
https://bugs.webkit.org/show_bug.cgi?id=19679

Reviewed by Dave Hyatt.

  • fast/css/line-height-overflow.html: Added.
  • platform/mac/fast/css/line-height-overflow-expected.txt: Added.
  • Property svn:eol-style set to native
Line 
1 /*
2  * (C) 1999 Lars Knoll (knoll@kde.org)
3  * (C) 2000 Dirk Mueller (mueller@kde.org)
4  * Copyright (C) 2004, 2005, 2006, 2007 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 RenderText_h
24 #define RenderText_h
25
26 #include "RenderObject.h"
27
28 namespace WebCore {
29
30 class InlineTextBox;
31 class StringImpl;
32
33 class RenderText : public RenderObject {
34 public:
35     RenderText(Node*, PassRefPtr<StringImpl>);
36 #ifndef NDEBUG
37     virtual ~RenderText();
38 #endif
39
40     virtual const char* renderName() const;
41
42     virtual bool isTextFragment() const;
43     virtual bool isWordBreak() const;
44
45     virtual PassRefPtr<StringImpl> originalText() const;
46
47     virtual void setStyle(RenderStyle*);
48
49     void extractTextBox(InlineTextBox*);
50     void attachTextBox(InlineTextBox*);
51     void removeTextBox(InlineTextBox*);
52
53     virtual void destroy();
54
55     StringImpl* text() const { return m_text.get(); }
56
57     virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun = false);
58     virtual InlineTextBox* createInlineTextBox();
59     virtual void dirtyLineBoxes(bool fullLayout, bool isRootInlineBox = false);
60
61     virtual void paint(PaintInfo&, int tx, int ty) { ASSERT_NOT_REACHED(); }
62     virtual void layout() { ASSERT_NOT_REACHED(); }
63
64     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction) { ASSERT_NOT_REACHED(); return false; }
65
66     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true);
67     virtual void addLineBoxRects(Vector<IntRect>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false);
68
69     virtual VisiblePosition positionForCoordinates(int x, int y);
70
71     const UChar* characters() const { return m_text->characters(); }
72     unsigned textLength() const { return m_text->length(); } // non virtual implementation of length()
73     virtual void position(InlineBox*);
74
75     virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos) const;
76     virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false) const;
77     virtual int width() const;
78     virtual int height() const;
79
80     virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
81
82     virtual int minPrefWidth() const;
83     virtual int maxPrefWidth() const;
84
85     void trimmedPrefWidths(int leadWidth,
86                            int& beginMinW, bool& beginWS,
87                            int& endMinW, bool& endWS,
88                            bool& hasBreakableChar, bool& hasBreak,
89                            int& beginMaxW, int& endMaxW,
90                            int& minW, int& maxW, bool& stripFrontSpaces);
91
92     // returns the minimum x position of all runs relative to the parent.
93     // defaults to 0.
94     int minXPos() const;
95
96     virtual int xPos() const;
97     virtual int yPos() const;
98
99     virtual int verticalPositionHint(bool firstLine) const;
100
101     void setText(PassRefPtr<StringImpl>, bool force = false);
102     void setTextWithOffset(PassRefPtr<StringImpl>, unsigned offset, unsigned len, bool force = false);
103
104     virtual bool canBeSelectionLeaf() const { return true; }
105     virtual SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
106     virtual void setSelectionState(SelectionState s);
107     virtual IntRect selectionRect(bool clipToVisibleContent = true);
108     virtual IntRect caretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
109
110     virtual int marginLeft() const { return style()->marginLeft().calcMinValue(0); }
111     virtual int marginRight() const { return style()->marginRight().calcMinValue(0); }
112
113     virtual IntRect absoluteClippedOverflowRect();
114
115     InlineTextBox* firstTextBox() const { return m_firstTextBox; }
116     InlineTextBox* lastTextBox() const { return m_lastTextBox; }
117
118     virtual int caretMinOffset() const;
119     virtual int caretMaxOffset() const;
120     virtual unsigned caretMaxRenderedOffset() const;
121
122     virtual int previousOffset(int current) const;
123     virtual int nextOffset(int current) const;
124
125     bool containsReversedText() const { return m_containsReversedText; }
126
127     InlineTextBox* findNextInlineTextBox(int offset, int& pos) const;
128
129     bool allowTabs() const { return !style()->collapseWhiteSpace(); }
130
131     void checkConsistency() const;
132
133 protected:
134     virtual void setTextInternal(PassRefPtr<StringImpl>);
135     virtual void calcPrefWidths(int leadWidth);
136     virtual UChar previousCharacter();
137
138 private:
139     // Make length() private so that callers that have a RenderText*
140     // will use the more efficient textLength() instead, while
141     // callers with a RenderObject* can continue to use length().
142     virtual unsigned length() const { return textLength(); }
143
144     void deleteTextBoxes();
145     bool containsOnlyWhitespace(unsigned from, unsigned len) const;
146     int widthFromCache(const Font&, int start, int len, int xPos) const;
147     bool isAllASCII() const { return m_isAllASCII; }
148
149     RefPtr<StringImpl> m_text;
150
151     InlineTextBox* m_firstTextBox;
152     InlineTextBox* m_lastTextBox;
153
154     int m_minWidth;
155     int m_maxWidth;
156     int m_beginMinWidth;
157     int m_endMinWidth;
158
159     unsigned m_selectionState : 3; // enums on Windows are signed, so this needs to be unsigned to prevent it turning negative.
160     bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
161     bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
162     bool m_hasTab : 1; // Whether or not we have a variable width tab character (e.g., <pre> with '\t').
163     bool m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre)
164     bool m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre)
165     bool m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific
166                            // line boxes, and this hint will enable layoutInlineChildren to avoid
167                            // just dirtying everything when character data is modified (e.g., appended/inserted
168                            // or removed).
169     bool m_containsReversedText : 1;
170     bool m_isAllASCII : 1;
171 };
172
173 #ifdef NDEBUG
174 inline void RenderText::checkConsistency() const
175 {
176 }
177 #endif
178
179 } // namespace WebCore
180
181 #endif // RenderText_h
182
Note: See TracBrowser for help on using the browser.