Changeset 82792 in webkit
- Timestamp:
- Apr 3, 2011 1:29:40 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r82791 r82792 1 2011-04-03 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Dan Bernstein. 4 5 Split out handling of trailing spaces from layoutInlineChildren 6 https://bugs.webkit.org/show_bug.cgi?id=57432 7 8 There is much more we could split out from this function, but this is a start. 9 10 I suspect this is very hot code. Hopefully the compiler will do the right thing. 11 If it doesn't the Chromium PLT bots will tell us. 12 13 * rendering/RenderBlock.h: 14 * rendering/RenderBlockLineLayout.cpp: 15 (WebCore::RenderBlock::handleTrailingSpaces): 16 (WebCore::RenderBlock::layoutInlineChildren): 17 1 18 2011-03-21 Ryosuke Niwa <rniwa@webkit.org> 2 19 -
trunk/Source/WebCore/rendering/RenderBlock.h
r82611 r82792 350 350 void layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom); 351 351 void layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom); 352 BidiRun* handleTrailingSpaces(InlineBidiResolver&); 352 353 353 354 virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set. -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r82786 r82792 630 630 } 631 631 632 inline BidiRun* RenderBlock::handleTrailingSpaces(InlineBidiResolver& resolver) 633 { 634 if (!resolver.runCount() 635 || !resolver.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteSpace() 636 || !resolver.logicallyLastRun()->m_object->style()->autoWrap()) 637 return 0; 638 639 BidiRun* trailingSpaceRun = resolver.logicallyLastRun(); 640 RenderObject* lastObject = trailingSpaceRun->m_object; 641 if (!lastObject->isText()) 642 return 0; 643 644 RenderText* lastText = toRenderText(lastObject); 645 const UChar* characters = lastText->characters(); 646 int firstSpace = trailingSpaceRun->stop(); 647 while (firstSpace > trailingSpaceRun->start()) { 648 UChar current = characters[firstSpace - 1]; 649 if (!isCollapsibleSpace(current, lastText)) 650 break; 651 firstSpace--; 652 } 653 if (firstSpace == trailingSpaceRun->stop()) 654 return 0; 655 656 TextDirection direction = style()->direction(); 657 bool shouldReorder = trailingSpaceRun != (direction == LTR ? resolver.lastRun() : resolver.firstRun()); 658 if (firstSpace != trailingSpaceRun->start()) { 659 BidiContext* baseContext = resolver.context(); 660 while (BidiContext* parent = baseContext->parent()) 661 baseContext = parent; 662 663 BidiRun* newTrailingRun = new (renderArena()) BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->m_object, baseContext, OtherNeutral); 664 trailingSpaceRun->m_stop = firstSpace; 665 if (direction == LTR) 666 resolver.addRun(newTrailingRun); 667 else 668 resolver.prependRun(newTrailingRun); 669 trailingSpaceRun = newTrailingRun; 670 return trailingSpaceRun; 671 } 672 if (!shouldReorder) 673 return trailingSpaceRun; 674 675 if (direction == LTR) { 676 resolver.moveRunToEnd(trailingSpaceRun); 677 trailingSpaceRun->m_level = 0; 678 } else { 679 resolver.moveRunToBeginning(trailingSpaceRun); 680 trailingSpaceRun->m_level = 1; 681 } 682 return trailingSpaceRun; 683 } 684 632 685 void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom) 633 686 { … … 801 854 ASSERT(resolver.position() == end); 802 855 803 BidiRun* trailingSpaceRun = 0; 804 if (!previousLineBrokeCleanly && resolver.runCount() && resolver.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteSpace() 805 && resolver.logicallyLastRun()->m_object->style()->autoWrap()) { 806 trailingSpaceRun = resolver.logicallyLastRun(); 807 RenderObject* lastObject = trailingSpaceRun->m_object; 808 if (lastObject->isText()) { 809 RenderText* lastText = toRenderText(lastObject); 810 const UChar* characters = lastText->characters(); 811 int firstSpace = trailingSpaceRun->stop(); 812 while (firstSpace > trailingSpaceRun->start()) { 813 UChar current = characters[firstSpace - 1]; 814 if (!isCollapsibleSpace(current, lastText)) 815 break; 816 firstSpace--; 817 } 818 if (firstSpace == trailingSpaceRun->stop()) 819 trailingSpaceRun = 0; 820 else { 821 TextDirection direction = style()->direction(); 822 bool shouldReorder = trailingSpaceRun != (direction == LTR ? resolver.lastRun() : resolver.firstRun()); 823 if (firstSpace != trailingSpaceRun->start()) { 824 BidiContext* baseContext = resolver.context(); 825 while (BidiContext* parent = baseContext->parent()) 826 baseContext = parent; 827 828 BidiRun* newTrailingRun = new (renderArena()) BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->m_object, baseContext, OtherNeutral); 829 trailingSpaceRun->m_stop = firstSpace; 830 if (direction == LTR) 831 resolver.addRun(newTrailingRun); 832 else 833 resolver.prependRun(newTrailingRun); 834 trailingSpaceRun = newTrailingRun; 835 shouldReorder = false; 836 } 837 if (shouldReorder) { 838 if (direction == LTR) { 839 resolver.moveRunToEnd(trailingSpaceRun); 840 trailingSpaceRun->m_level = 0; 841 } else { 842 resolver.moveRunToBeginning(trailingSpaceRun); 843 trailingSpaceRun->m_level = 1; 844 } 845 } 846 } 847 } else 848 trailingSpaceRun = 0; 849 } 856 BidiRun* trailingSpaceRun = !previousLineBrokeCleanly ? handleTrailingSpaces(resolver) : 0; 850 857 851 858 // Now that the runs have been ordered, we create the line boxes.
Note: See TracChangeset
for help on using the changeset viewer.