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

Side by Side Diff: Source/core/rendering/line/BreakingContextInlineHeaders.h

Issue 142323003: Separate LineBreaker from RenderBlockLineLayout (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
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 * Copyright (C) 2013 Adobe Systems Incorporated. 5 * Copyright (C) 2013 Adobe Systems Incorporated.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 10 matching lines...) Expand all
21 * 21 *
22 */ 22 */
23 23
24 #ifndef BreakingContextInlineHeaders_h 24 #ifndef BreakingContextInlineHeaders_h
25 #define BreakingContextInlineHeaders_h 25 #define BreakingContextInlineHeaders_h
26 26
27 #include "core/rendering/InlineIterator.h" 27 #include "core/rendering/InlineIterator.h"
28 #include "core/rendering/InlineTextBox.h" 28 #include "core/rendering/InlineTextBox.h"
29 #include "core/rendering/RenderCombineText.h" 29 #include "core/rendering/RenderCombineText.h"
30 #include "core/rendering/RenderInline.h" 30 #include "core/rendering/RenderInline.h"
31 #include "core/rendering/RenderLayer.h"
32 #include "core/rendering/RenderListMarker.h"
33 #include "core/rendering/RenderRubyRun.h"
31 #include "core/rendering/break_lines.h" 34 #include "core/rendering/break_lines.h"
35 #include "core/rendering/line/LineBreaker.h"
32 #include "core/rendering/line/LineInfo.h" 36 #include "core/rendering/line/LineInfo.h"
33 #include "core/rendering/line/LineWidth.h" 37 #include "core/rendering/line/LineWidth.h"
34 #include "core/rendering/line/TrailingObjects.h" 38 #include "core/rendering/line/TrailingObjects.h"
35 #include "core/rendering/shapes/ShapeInsideInfo.h" 39 #include "core/rendering/shapes/ShapeInsideInfo.h"
36 #include "core/rendering/svg/RenderSVGInlineText.h" 40 #include "core/rendering/svg/RenderSVGInlineText.h"
37 41
38 namespace WebCore { 42 namespace WebCore {
39 43
40 // We don't let our line box tree for a single line get any deeper than this. 44 // We don't let our line box tree for a single line get any deeper than this.
41 const unsigned cMaxLineDepth = 200; 45 const unsigned cMaxLineDepth = 200;
42 46
43 struct RenderTextInfo {
44 RenderTextInfo();
45 ~RenderTextInfo();
46
47 RenderText* m_text;
48 LazyLineBreakIterator m_lineBreakIterator;
49 const Font* m_font;
50 };
51
52 class WordMeasurement { 47 class WordMeasurement {
53 public: 48 public:
54 WordMeasurement() 49 WordMeasurement()
55 : renderer(0) 50 : renderer(0)
56 , width(0) 51 , width(0)
57 , startOffset(0) 52 , startOffset(0)
58 , endOffset(0) 53 , endOffset(0)
59 { 54 {
60 } 55 }
61 56
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool m_collapseWhiteSpace; 160 bool m_collapseWhiteSpace;
166 bool m_startingNewParagraph; 161 bool m_startingNewParagraph;
167 bool m_allowImagesToBreak; 162 bool m_allowImagesToBreak;
168 bool m_atEnd; 163 bool m_atEnd;
169 164
170 LineMidpointState& m_lineMidpointState; 165 LineMidpointState& m_lineMidpointState;
171 166
172 TrailingObjects m_trailingObjects; 167 TrailingObjects m_trailingObjects;
173 }; 168 };
174 169
175 enum WhitespacePosition { LeadingWhitespace, TrailingWhitespace };
176
177 inline bool shouldCollapseWhiteSpace(const RenderStyle* style, const LineInfo& l ineInfo, WhitespacePosition whitespacePosition) 170 inline bool shouldCollapseWhiteSpace(const RenderStyle* style, const LineInfo& l ineInfo, WhitespacePosition whitespacePosition)
178 { 171 {
179 // CSS2 16.6.1 172 // CSS2 16.6.1
180 // If a space (U+0020) at the beginning of a line has 'white-space' set to ' normal', 'nowrap', or 'pre-line', it is removed. 173 // If a space (U+0020) at the beginning of a line has 'white-space' set to ' normal', 'nowrap', or 'pre-line', it is removed.
181 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal ', 'nowrap', or 'pre-line', it is also removed. 174 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal ', 'nowrap', or 'pre-line', it is also removed.
182 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-spac e' set to 'pre-wrap', UAs may visually collapse them. 175 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-spac e' set to 'pre-wrap', UAs may visually collapse them.
183 return style->collapseWhiteSpace() 176 return style->collapseWhiteSpace()
184 || (whitespacePosition == TrailingWhitespace && style->whiteSpace() == P RE_WRAP && (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); 177 || (whitespacePosition == TrailingWhitespace && style->whiteSpace() == P RE_WRAP && (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly()));
185 } 178 }
186 179
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 938
946 if (!m_current.object()->isFloatingOrOutOfFlowPositioned()) { 939 if (!m_current.object()->isFloatingOrOutOfFlowPositioned()) {
947 m_lastObject = m_current.object(); 940 m_lastObject = m_current.object();
948 if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage( ) || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMark er(m_lastObject)->isInside())) { 941 if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage( ) || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMark er(m_lastObject)->isInside())) {
949 m_width.commit(); 942 m_width.commit();
950 m_lineBreak.moveToStartOf(m_nextObject); 943 m_lineBreak.moveToStartOf(m_nextObject);
951 } 944 }
952 } 945 }
953 } 946 }
954 947
955 InlineIterator BreakingContext::handleEndOfLine() 948 inline IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea k, RenderStyle* style)
956 { 949 {
957 ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); 950 if (isFirstLine)
958 bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); 951 return IndentText;
952 if (isAfterHardLineBreak && style->textIndentLine() == TextIndentEachLine)
953 return IndentText;
959 954
960 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.object() || !m_lin eBreak.object()->isBR()) && segmentAllowsOverflow) { 955 return DoNotIndentText;
961 // we just add as much as possible
962 if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) {
963 m_lineBreak.moveTo(m_lastObject, m_lastObject->isText() ? m_lastObje ct->length() : 0);
964 } else if (m_lineBreak.object()) {
965 // Don't ever break in the middle of a word if we can help it.
966 // There's no room at all. We just have to be on this line,
967 // even though we'll spill out.
968 m_lineBreak.moveTo(m_current.object(), m_current.offset());
969 }
970 }
971
972 // FIXME Bug 100049: We do not need to consume input in a multi-segment line
973 // unless no segment will.
974 // make sure we consume at least one char/object.
975 if (m_lineBreak == m_resolver.position() && segmentAllowsOverflow)
976 m_lineBreak.increment();
977
978 // Sanity check our midpoints.
979 m_lineMidpointState.checkMidpoints(m_lineBreak);
980
981 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidpointState, m_lin eBreak, TrailingObjects::CollapseFirstSpace);
982
983 // We might have made lineBreak an iterator that points past the end
984 // of the object. Do this adjustment to make it point to the start
985 // of the next object instead to avoid confusing the rest of the
986 // code.
987 if (m_lineBreak.offset()) {
988 // This loop enforces the invariant that line breaks should never point
989 // at an empty inline. See http://crbug.com/305904.
990 do {
991 m_lineBreak.setOffset(m_lineBreak.offset() - 1);
992 m_lineBreak.increment();
993 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.object()));
994 }
995
996 return m_lineBreak;
997 } 956 }
998 957
999 } 958 }
1000 959
1001 #endif // BreakingContextInlineHeaders_h 960 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « Source/core/rendering/line/BreakingContext.cpp ('k') | Source/core/rendering/line/LineBreaker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698