Changeset 13868 in webkit
- Timestamp:
- Apr 14, 2006 1:15:00 AM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r13867 r13868 1 2006-04-14 David Hyatt <hyatt@apple.com> 2 3 Fix for 8333, make sure newlines in whitespace:pre (and friends) get 4 line boxes created for them. This resolves all the weird selection/navigation 5 issues that arise by not creating lines (and thus not having navigable positions 6 on those lines). 7 8 This checkin is also removing all of the layout test hacks that have piled 9 up, so layout test results are being regenerated completely. 10 11 Reviewed by eric 12 13 * dom/Position.cpp: 14 (WebCore::Position::downstream): 15 * editing/CompositeEditCommand.cpp: 16 (WebCore::CompositeEditCommand::moveParagraph): 17 * editing/DeleteSelectionCommand.cpp: 18 (WebCore::DeleteSelectionCommand::doApply): 19 * editing/visible_units.cpp: 20 (WebCore::startOfParagraph): 21 (WebCore::endOfParagraph): 22 * kwq/RenderTreeAsText.cpp: 23 (getTagName): 24 (operator<<): 25 * rendering/InlineTextBox.cpp: 26 (WebCore::InlineTextBox::selectionState): 27 (WebCore::InlineTextBox::isLineBreak): 28 (WebCore::InlineTextBox::nodeAtPoint): 29 (WebCore::InlineTextBox::paint): 30 (WebCore::InlineTextBox::offsetForPosition): 31 (WebCore::InlineTextBox::positionForOffset): 32 * rendering/InlineTextBox.h: 33 * rendering/RenderBR.cpp: 34 * rendering/RenderBR.h: 35 * rendering/RenderText.cpp: 36 (WebCore::RenderText::atLineWrap): 37 (WebCore::RenderText::caretRect): 38 (WebCore::RenderText::height): 39 (WebCore::RenderText::inlineBox): 40 * rendering/bidi.cpp: 41 (WebCore::RenderBlock::computeHorizontalPositionsForLine): 42 (WebCore::RenderBlock::layoutInlineChildren): 43 (WebCore::RenderBlock::findNextLineBreak): 44 * rendering/render_line.h: 45 (WebCore::InlineBox::isLineBreak): 46 1 47 2006-04-13 Darin Adler <darin@apple.com> 2 48 -
trunk/WebCore/dom/Position.cpp
r13865 r13868 433 433 434 434 if (box != textRenderer->lastTextBox() && 435 !box->nextOnLine() && 435 !box->nextOnLine() && 436 436 textOffset == box->start() + box->len()) { 437 437 return currentPos; -
trunk/WebCore/editing/CompositeEditCommand.cpp
r13859 r13868 690 690 691 691 // Deleting a paragraph leaves a placeholder (it always does when a whole paragraph is deleted). 692 // We remove it and prune it 's parents since we want to remove all traces of the paragraph we're moving.692 // We remove it and prune its parents since we want to remove all traces of the paragraph we're moving. 693 693 Node* placeholder = endingSelection().end().node(); 694 694 if (placeholder->hasTagName(brTag)) -
trunk/WebCore/editing/DeleteSelectionCommand.cpp
r13854 r13868 601 601 return; 602 602 603 // If the deletion is occur ing in a text field, let the frame call across the bridge to notify the form delegate.603 // If the deletion is occurring in a text field, let the frame call across the bridge to notify the form delegate. 604 604 Node* startNode = m_selectionToDelete.start().node(); 605 605 Node* ancestorNode = startNode ? startNode->shadowAncestorNode() : 0; … … 627 627 isEndOfParagraph(VisiblePosition(m_downstreamEnd)); 628 628 629 // Delete any text that may hinder our ability to fixup whitespace after the de tele629 // Delete any text that may hinder our ability to fixup whitespace after the delete 630 630 deleteInsignificantTextDownstream(m_trailingWhitespace); 631 631 -
trunk/WebCore/editing/visible_units.cpp
r13859 r13868 563 563 break; 564 564 if (r->isText()) { 565 // FIXME: Not clear what to do with pre-wrap or pre-line here. 566 if (style->whiteSpace() == PRE) { 565 if (style->preserveNewline()) { 567 566 const QChar* text = static_cast<RenderText*>(r)->text(); 568 567 int i = static_cast<RenderText*>(r)->length(); … … 624 623 if (r->isText() && r->caretMaxRenderedOffset() > 0) { 625 624 int length = static_cast<RenderText *>(r)->length(); 626 // FIXME: Not clear what to do with pre-wrap or pre-line here. 627 if (style->whiteSpace() == PRE) { 625 if (style->preserveNewline()) { 628 626 const QChar* text = static_cast<RenderText *>(r)->text(); 629 627 int o = n == startNode ? offset : 0; -
trunk/WebCore/rendering/InlineTextBox.cpp
r13859 r13868 80 80 { 81 81 RenderObject::SelectionState state = object()->selectionState(); 82 if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || 83 state == RenderObject::SelectionBoth) { 82 if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || state == RenderObject::SelectionBoth) { 84 83 int startPos, endPos; 85 84 object()->selectionStartEnd(startPos, endPos); 86 85 86 // If we're at a line wrap, then the selection is going to extend onto the next line (and thus needs to be thought of as 87 // extending beyond our box. 88 if (textObject()->atLineWrap(this, endPos)) 89 endPos++; 90 87 91 bool start = (state != RenderObject::SelectionEnd && startPos >= m_start && startPos < m_start + m_len); 88 92 bool end = (state != RenderObject::SelectionStart && endPos > m_start && endPos <= m_start + m_len); … … 219 223 } 220 224 225 bool InlineTextBox::isLineBreak() const 226 { 227 return object()->isBR() || (object()->style()->preserveNewline() && len() == 1 && (*textObject()->string())[start()] == '\n'); 228 } 229 221 230 bool InlineTextBox::nodeAtPoint(RenderObject::NodeInfo& i, int x, int y, int tx, int ty) 222 231 { 223 if ( object()->isBR())232 if (isLineBreak()) 224 233 return false; 225 234 … … 234 243 void InlineTextBox::paint(RenderObject::PaintInfo& i, int tx, int ty) 235 244 { 236 if ( object()->isBR() || !object()->shouldPaintWithinRoot(i) || object()->style()->visibility() != VISIBLE ||245 if (isLineBreak() || !object()->shouldPaintWithinRoot(i) || object()->style()->visibility() != VISIBLE || 237 246 m_truncation == cFullTruncation || i.phase == PaintPhaseOutline) 238 247 return; … … 684 693 int InlineTextBox::offsetForPosition(int _x, bool includePartialGlyphs) const 685 694 { 695 if (isLineBreak()) 696 return 0; 697 686 698 RenderText* text = static_cast<RenderText*>(m_object); 687 699 RenderStyle *style = text->style(m_firstLine); … … 694 706 int InlineTextBox::positionForOffset(int offset) const 695 707 { 708 if (isLineBreak()) 709 return m_x; 710 696 711 RenderText *text = static_cast<RenderText *>(m_object); 697 712 const Font *f = text->font(m_firstLine); -
trunk/WebCore/rendering/InlineTextBox.h
r13595 r13868 86 86 virtual int placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool& foundBox); 87 87 88 virtual bool isLineBreak() const; 89 88 90 // Overloaded new operator. Derived classes must override operator new 89 91 // in order to allocate out of the RenderArena. -
trunk/WebCore/rendering/RenderBR.cpp
r13393 r13868 108 108 } 109 109 110 IntRect RenderBR::caretRect(int offset, EAffinity affinity, int *extraWidthToEndOfLine)111 {112 // EDIT FIXME: This does not work yet. Some other changes are need before113 // an accurate position can be determined.114 115 int absx, absy;116 absolutePosition(absx, absy);117 118 if (extraWidthToEndOfLine)119 *extraWidthToEndOfLine = containingBlockWidth() - xPos();120 121 // FIXME: an older version of this code wasn't setting width at122 // all, using the default of 1...123 return IntRect(xPos() + absx, yPos() + absy, 1, lineHeight(false));124 }125 126 110 InlineBox *RenderBR::inlineBox(int offset, EAffinity affinity) 127 111 { -
trunk/WebCore/rendering/RenderBR.h
r13393 r13868 54 54 // overrides 55 55 virtual InlineBox* createInlineBox(bool, bool, bool isOnlyRun = false); 56 virtual void calcMinMaxWidth() {}57 virtual int minWidth() const { return 0; }58 virtual int maxWidth() const { return 0; }59 56 60 57 virtual bool isBR() const { return true; } … … 65 62 66 63 virtual VisiblePosition positionForCoordinates(int x, int y); 67 virtual IntRect caretRect(int offset, EAffinity affinity = UPSTREAM, int *extraWidthToEndOfLine = 0);68 64 69 65 virtual InlineBox *inlineBox(int offset, EAffinity affinity = UPSTREAM); -
trunk/WebCore/rendering/RenderText.cpp
r13859 r13868 352 352 { 353 353 if (box->nextTextBox() && !box->nextOnLine() && offset == box->m_start + box->m_len) { 354 // Take special care because in preformatted text, the newlines 355 // are in between the text boxes (i.e. not in any box's m_start 356 // thru m_start+m_len-1), even though they are rendered. 357 if (!style()->preserveNewline() || (*str)[offset] != '\n') 354 if (!style()->preserveNewline() || box->isLineBreak()) 358 355 return true; 359 356 } … … 372 369 if ((offset >= box->m_start) && (offset <= box->m_start + box->m_len)) { 373 370 // Check if downstream affinity would make us move to the next line. 374 if (a ffinity == DOWNSTREAM && atLineWrap(box, offset)) {371 if (atLineWrap(box, offset)) { 375 372 // Use the next text box 376 373 box = box->nextTextBox(); … … 920 917 int RenderText::height() const 921 918 { 922 // FIXME: Why use line-height? Shouldn't we be adding in the height of the last text box? -dwh923 919 int retval = 0; 924 920 if (firstTextBox()) 925 retval = lastTextBox()->m_y + l ineHeight(false) - firstTextBox()->m_y;921 retval = lastTextBox()->m_y + lastTextBox()->height() - firstTextBox()->m_y; 926 922 return retval; 927 923 } … … 1112 1108 for (InlineTextBox *box = firstTextBox(); box; box = box->nextTextBox()) { 1113 1109 if (offset >= box->m_start && offset <= box->m_start + box->m_len) { 1114 if (a ffinity == DOWNSTREAM && atLineWrap(box, offset))1110 if (atLineWrap(box, offset)) 1115 1111 return box->nextTextBox(); 1116 1112 return box; -
trunk/WebCore/rendering/RenderTreeAsText.cpp
r13867 r13868 103 103 if (n->isDocumentNode()) 104 104 return ""; 105 if (n->isTextNode())106 return "TEXT"; // FIXME: Remove once the layout tests are ready to change.107 105 if (n->isCommentNode()) 108 106 return "COMMENT"; 109 if (n->isHTMLElement())110 return n->nodeName().upper().deprecatedString(); // FIXME: We want to dump the real DOM name, not an uppercase name.111 107 return n->nodeName().deprecatedString(); 112 108 } … … 127 123 } 128 124 129 // FIXME: Will remove this <br> code once all layout tests pass. Until then, we can't really change 130 // all the results easily. 131 // FIXME: Will also remove the table row and section hacks once all layout tests pass. 132 bool usePositions = true; 133 bool useWidth = true; 134 bool useHeight = true; 135 if (o.isBR()) { 136 const RenderBR* br = static_cast<const RenderBR*>(&o); 137 usePositions = (br->firstTextBox() && br->firstTextBox()->isText()); 138 } else if (o.isTableRow()) 139 usePositions = useWidth = useHeight = false; 140 else if (o.isTableSection()) 141 useWidth = false; 142 143 IntRect r(usePositions ? o.xPos() : 0, usePositions ? o.yPos() : 0, useWidth ? o.width() : 0, useHeight ? o.height() : 0); 125 IntRect r(o.xPos(), o.yPos(), o.width(), o.height()); 144 126 ts << " " << r; 145 127 -
trunk/WebCore/rendering/bidi.cpp
r13859 r13868 102 102 static bool isLineEmpty = true; 103 103 static bool previousLineBrokeCleanly = true; 104 static bool skipTrailingNewline = false;105 104 static bool emptyRun = true; 106 105 static int numSpaces; … … 855 854 bool needsWordSpacing = false; 856 855 for (r = sFirstBidiRun; r; r = r->nextRun) { 857 if (!r->box || r->obj->isPositioned() )856 if (!r->box || r->obj->isPositioned() || r->box->isLineBreak()) 858 857 continue; // Positioned objects are only participating to figure out their 859 858 // correct static x position. They have no effect on the width. 859 // Similarly, line break boxes have no effect on the width. 860 860 if (r->obj->isText()) { 861 861 RenderText *rt = static_cast<RenderText *>(r->obj); … … 1631 1631 } 1632 1632 1633 if (end == start || skipTrailingNewline) {1633 if (end == start) { 1634 1634 bidi.adjustEmbedding = true; 1635 1635 end.increment(bidi); … … 1975 1975 bool prevLineBrokeCleanly = previousLineBrokeCleanly; 1976 1976 previousLineBrokeCleanly = false; 1977 skipTrailingNewline = false;1978 1977 1979 1978 while (o) { … … 2187 2186 2188 2187 if (c == '\n' || (o->style()->whiteSpace() != PRE && isBreakable(str, pos, strlen, nextBreakable, breakNBSP)) || midWordBreak) { 2188 bool stoppedIgnoringSpaces = false; 2189 2189 if (ignoringSpaces) { 2190 2190 if (!currentCharacterIsSpace) { … … 2196 2196 BidiIterator startMid ( 0, o, pos ); 2197 2197 addMidpoint(startMid); 2198 stoppedIgnoringSpaces = true; 2198 2199 } else { 2199 2200 // Just keep ignoring these spaces. … … 2250 2251 } 2251 2252 if (lBreak.obj && lBreak.obj->style()->preserveNewline() && lBreak.obj->isText() && static_cast<RenderText*>(lBreak.obj)->text()[lBreak.pos] == '\n') { 2253 if (!stoppedIgnoringSpaces && pos > 0) { 2254 // We need to stop right before the newline and then start up again. 2255 BidiIterator midpoint(0, o, pos); 2256 addMidpoint(BidiIterator(0, o, pos-1)); // Stop 2257 addMidpoint(BidiIterator(0, o, pos)); // Start 2258 } 2259 lBreak.increment(bidi); 2252 2260 previousLineBrokeCleanly = true; 2253 skipTrailingNewline = true;2254 2261 } 2255 2262 goto end; // Didn't fit. Jump to the end. … … 2264 2271 2265 2272 if (c == '\n' && o->style()->preserveNewline()) { 2273 if (!stoppedIgnoringSpaces && pos > 0) { 2274 // We need to stop right before the newline and then start up again. 2275 BidiIterator midpoint(0, o, pos); 2276 addMidpoint(BidiIterator(0, o, pos-1)); // Stop 2277 addMidpoint(BidiIterator(0, o, pos)); // Start 2278 } 2266 2279 lBreak.obj = o; 2267 2280 lBreak.pos = pos; 2281 lBreak.increment(bidi); 2268 2282 previousLineBrokeCleanly = true; 2269 skipTrailingNewline = true;2270 2283 return lBreak; 2271 2284 } -
trunk/WebCore/rendering/render_line.h
r13859 r13868 60 60 virtual void attachLine(); 61 61 62 virtual bool isLineBreak() const { return false; } 63 62 64 virtual void adjustPosition(int dx, int dy); 63 65
Note: See TracChangeset
for help on using the changeset viewer.