Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1164933006: Create LineLayout api (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase + nits Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.cpp ('k') | Source/core/layout/LayoutBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 14 matching lines...) Expand all
25 #include "core/dom/AXObjectCache.h" 25 #include "core/dom/AXObjectCache.h"
26 #include "core/layout/BidiRunForLine.h" 26 #include "core/layout/BidiRunForLine.h"
27 #include "core/layout/LayoutCounter.h" 27 #include "core/layout/LayoutCounter.h"
28 #include "core/layout/LayoutFlowThread.h" 28 #include "core/layout/LayoutFlowThread.h"
29 #include "core/layout/LayoutListMarker.h" 29 #include "core/layout/LayoutListMarker.h"
30 #include "core/layout/LayoutObject.h" 30 #include "core/layout/LayoutObject.h"
31 #include "core/layout/LayoutRubyRun.h" 31 #include "core/layout/LayoutRubyRun.h"
32 #include "core/layout/LayoutView.h" 32 #include "core/layout/LayoutView.h"
33 #include "core/layout/TextRunConstructor.h" 33 #include "core/layout/TextRunConstructor.h"
34 #include "core/layout/VerticalPositionCache.h" 34 #include "core/layout/VerticalPositionCache.h"
35 #include "core/layout/api/LineLayoutItem.h"
35 #include "core/layout/line/BreakingContextInlineHeaders.h" 36 #include "core/layout/line/BreakingContextInlineHeaders.h"
36 #include "core/layout/line/GlyphOverflow.h" 37 #include "core/layout/line/GlyphOverflow.h"
37 #include "core/layout/line/LayoutTextInfo.h" 38 #include "core/layout/line/LayoutTextInfo.h"
38 #include "core/layout/line/LineLayoutState.h" 39 #include "core/layout/line/LineLayoutState.h"
39 #include "core/layout/line/LineWidth.h" 40 #include "core/layout/line/LineWidth.h"
40 #include "core/layout/line/TrailingFloatsRootInlineBox.h" 41 #include "core/layout/line/TrailingFloatsRootInlineBox.h"
41 #include "core/layout/line/WordMeasurement.h" 42 #include "core/layout/line/WordMeasurement.h"
42 #include "core/layout/svg/line/SVGRootInlineBox.h" 43 #include "core/layout/svg/line/SVGRootInlineBox.h"
43 #include "platform/fonts/Character.h" 44 #include "platform/fonts/Character.h"
44 #include "platform/text/BidiResolver.h" 45 #include "platform/text/BidiResolver.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 const BidiStatus& cleanLineBidiStatus) 777 const BidiStatus& cleanLineBidiStatus)
777 { 778 {
778 const ComputedStyle& styleToUse = styleRef(); 779 const ComputedStyle& styleToUse = styleRef();
779 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated (); 780 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated ();
780 LineMidpointState& lineMidpointState = resolver.midpointState(); 781 LineMidpointState& lineMidpointState = resolver.midpointState();
781 InlineIterator endOfLine = resolver.position(); 782 InlineIterator endOfLine = resolver.position();
782 bool checkForEndLineMatch = layoutState.endLine(); 783 bool checkForEndLineMatch = layoutState.endLine();
783 LayoutTextInfo layoutTextInfo; 784 LayoutTextInfo layoutTextInfo;
784 VerticalPositionCache verticalPositionCache; 785 VerticalPositionCache verticalPositionCache;
785 786
786 LineBreaker lineBreaker(this); 787 LineBreaker lineBreaker(LineLayoutBlockFlow(this));
787 788
788 while (!endOfLine.atEnd()) { 789 while (!endOfLine.atEnd()) {
789 bool logicalWidthIsAvailable = false; 790 bool logicalWidthIsAvailable = false;
790 791
791 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end? 792 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end?
792 if (checkForEndLineMatch) { 793 if (checkForEndLineMatch) {
793 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus)); 794 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus));
794 if (layoutState.endLineMatched()) { 795 if (layoutState.endLineMatched()) {
795 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0); 796 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
796 break; 797 break;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } else { 875 } else {
875 setLogicalHeight(lineBox->lineBottomWithLeading()); 876 setLogicalHeight(lineBox->lineBottomWithLeading());
876 } 877 }
877 } 878 }
878 } 879 }
879 } 880 }
880 } 881 }
881 882
882 if (!logicalWidthIsAvailable) { 883 if (!logicalWidthIsAvailable) {
883 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) 884 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i)
884 setStaticPositions(this, lineBreaker.positionedObjects()[i]); 885 setStaticPositions(LineLayoutBlockFlow(this), lineBreaker.positi onedObjects()[i]);
885 886
886 if (!layoutState.lineInfo().isEmpty()) 887 if (!layoutState.lineInfo().isEmpty())
887 layoutState.lineInfo().setFirstLine(false); 888 layoutState.lineInfo().setFirstLine(false);
888 clearFloats(lineBreaker.clear()); 889 clearFloats(lineBreaker.clear());
889 890
890 if (m_floatingObjects && lastRootBox()) { 891 if (m_floatingObjects && lastRootBox()) {
891 const FloatingObjectSet& floatingObjectSet = m_floatingObjects-> set(); 892 const FloatingObjectSet& floatingObjectSet = m_floatingObjects-> set();
892 FloatingObjectSetIterator it = floatingObjectSet.begin(); 893 FloatingObjectSetIterator it = floatingObjectSet.begin();
893 FloatingObjectSetIterator end = floatingObjectSet.end(); 894 FloatingObjectSetIterator end = floatingObjectSet.end();
894 if (layoutState.lastFloat()) { 895 if (layoutState.lastFloat()) {
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 } 1736 }
1736 setLogicalHeight(savedLogicalHeight); 1737 setLogicalHeight(savedLogicalHeight);
1737 } 1738 }
1738 layoutState.setFloatIndex(numCleanFloats); 1739 layoutState.setFloatIndex(numCleanFloats);
1739 1740
1740 layoutState.lineInfo().setFirstLine(!last); 1741 layoutState.lineInfo().setFirstLine(!last);
1741 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak()); 1742 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak());
1742 1743
1743 if (last) { 1744 if (last) {
1744 setLogicalHeight(last->lineBottomWithLeading()); 1745 setLogicalHeight(last->lineBottomWithLeading());
1745 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); 1746 InlineIterator iter = InlineIterator(LineLayoutBlockFlow(this), LineLayo utItem(last->lineBreakObj()), last->lineBreakPos());
1746 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); 1747 resolver.setPosition(iter, numberOfIsolateAncestors(iter));
1747 resolver.setStatus(last->lineBreakBidiStatus()); 1748 resolver.setStatus(last->lineBreakBidiStatus());
1748 } else { 1749 } else {
1749 TextDirection direction = style()->direction(); 1750 TextDirection direction = style()->direction();
1750 if (style()->unicodeBidi() == Plaintext) 1751 if (style()->unicodeBidi() == Plaintext)
1751 direction = determinePlaintextDirectionality(this); 1752 direction = determinePlaintextDirectionality(this);
1752 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); 1753 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ())));
1753 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, resolver.runs(), &resolver), 0); 1754 InlineIterator iter = InlineIterator(LineLayoutBlockFlow(this), bidiFirs tSkippingEmptyInlines(LineLayoutBlockFlow(this), resolver.runs(), &resolver), 0) ;
1754 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); 1755 resolver.setPosition(iter, numberOfIsolateAncestors(iter));
1755 } 1756 }
1756 return curr; 1757 return curr;
1757 } 1758 }
1758 1759
1759 1760
1760 bool LayoutBlockFlow::lineBoxHasBRWithClearance(RootInlineBox* curr) 1761 bool LayoutBlockFlow::lineBoxHasBRWithClearance(RootInlineBox* curr)
1761 { 1762 {
1762 // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without difficulty. 1763 // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without difficulty.
1763 if (!curr->endsWithBreak()) 1764 if (!curr->endsWithBreak())
(...skipping 23 matching lines...) Expand all
1787 last = curr; 1788 last = curr;
1788 } 1789 }
1789 1790
1790 if (!last) 1791 if (!last)
1791 return; 1792 return;
1792 1793
1793 // At this point, |last| is the first line in a run of clean lines that ends with the last line 1794 // At this point, |last| is the first line in a run of clean lines that ends with the last line
1794 // in the block. 1795 // in the block.
1795 1796
1796 RootInlineBox* prev = last->prevRootBox(); 1797 RootInlineBox* prev = last->prevRootBox();
1797 cleanLineStart = InlineIterator(this, prev->lineBreakObj(), prev->lineBreakP os()); 1798 cleanLineStart = InlineIterator(LineLayoutItem(this), LineLayoutItem(prev->l ineBreakObj()), prev->lineBreakPos());
1798 cleanLineBidiStatus = prev->lineBreakBidiStatus(); 1799 cleanLineBidiStatus = prev->lineBreakBidiStatus();
1799 layoutState.setEndLineLogicalTop(prev->lineBottomWithLeading()); 1800 layoutState.setEndLineLogicalTop(prev->lineBottomWithLeading());
1800 1801
1801 for (RootInlineBox* line = last; line; line = line->nextRootBox()) 1802 for (RootInlineBox* line = last; line; line = line->nextRootBox())
1802 line->extractLine(); // Disconnect all line boxes from their layout obje cts while preserving 1803 line->extractLine(); // Disconnect all line boxes from their layout obje cts while preserving
1803 // their connections to one another. 1804 // their connections to one another.
1804 1805
1805 layoutState.setEndLine(last); 1806 layoutState.setEndLine(last);
1806 } 1807 }
1807 1808
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1884 }
1884 1885
1885 return false; 1886 return false;
1886 } 1887 }
1887 1888
1888 bool LayoutBlockFlow::generatesLineBoxesForInlineChild(LayoutObject* inlineObj) 1889 bool LayoutBlockFlow::generatesLineBoxesForInlineChild(LayoutObject* inlineObj)
1889 1890
1890 { 1891 {
1891 ASSERT(inlineObj->parent() == this); 1892 ASSERT(inlineObj->parent() == this);
1892 1893
1893 InlineIterator it(this, inlineObj, 0); 1894 InlineIterator it(LineLayoutBlockFlow(this), LineLayoutItem(inlineObj), 0);
1894 // FIXME: We should pass correct value for WhitespacePosition. 1895 // FIXME: We should pass correct value for WhitespacePosition.
1895 while (!it.atEnd() && !requiresLineBox(it)) 1896 while (!it.atEnd() && !requiresLineBox(it))
1896 it.increment(); 1897 it.increment();
1897 1898
1898 return !it.atEnd(); 1899 return !it.atEnd();
1899 } 1900 }
1900 1901
1901 1902
1902 void LayoutBlockFlow::addOverflowFromInlineChildren() 1903 void LayoutBlockFlow::addOverflowFromInlineChildren()
1903 { 1904 {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2070 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2070 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2071 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2071 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2072 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2072 2073
2073 if (!style()->isLeftToRightDirection()) 2074 if (!style()->isLeftToRightDirection())
2074 return logicalWidth() - logicalLeft; 2075 return logicalWidth() - logicalLeft;
2075 return logicalLeft; 2076 return logicalLeft;
2076 } 2077 }
2077 2078
2078 } 2079 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.cpp ('k') | Source/core/layout/LayoutBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698