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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 1583783002: Use IndentTextOrNot instead of a bool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@568851-2
Patch Set: Update Created 4 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return false; 207 return false;
208 208
209 if (!shouldCollapseWhiteSpace(it.object().styleRef(), lineInfo, whitespacePo sition) || it.object().isBR()) 209 if (!shouldCollapseWhiteSpace(it.object().styleRef(), lineInfo, whitespacePo sition) || it.object().isBR())
210 return true; 210 return true;
211 211
212 UChar current = it.current(); 212 UChar current = it.current();
213 bool notJustWhitespace = current != spaceCharacter && current != tabulationC haracter && current != softHyphenCharacter && (current != newlineCharacter || it .object().preservesNewline()); 213 bool notJustWhitespace = current != spaceCharacter && current != tabulationC haracter && current != softHyphenCharacter && (current != newlineCharacter || it .object().preservesNewline());
214 return notJustWhitespace || isEmptyInline(it.object()); 214 return notJustWhitespace || isEmptyInline(it.object());
215 } 215 }
216 216
217 inline void setStaticPositions(LineLayoutBlockFlow block, LineLayoutBox child, b ool shouldIndentText) 217 inline void setStaticPositions(LineLayoutBlockFlow block, LineLayoutBox child, I ndentTextOrNot indentText)
218 { 218 {
219 ASSERT(child.isOutOfFlowPositioned()); 219 ASSERT(child.isOutOfFlowPositioned());
220 // FIXME: The math here is actually not really right. It's a best-guess appr oximation that 220 // FIXME: The math here is actually not really right. It's a best-guess appr oximation that
221 // will work for the common cases 221 // will work for the common cases
222 LineLayoutItem containerBlock = child.container(); 222 LineLayoutItem containerBlock = child.container();
223 LayoutUnit blockHeight = block.logicalHeight(); 223 LayoutUnit blockHeight = block.logicalHeight();
224 if (containerBlock.isLayoutInline()) { 224 if (containerBlock.isLayoutInline()) {
225 // A relative positioned inline encloses us. In this case, we also have to determine our 225 // A relative positioned inline encloses us. In this case, we also have to determine our
226 // position as though we were an inline. Set |staticInlinePosition| and |staticBlockPosition| on the relative positioned 226 // position as though we were an inline. Set |staticInlinePosition| and |staticBlockPosition| on the relative positioned
227 // inline so that we can obtain the value later. 227 // inline so that we can obtain the value later.
228 LineLayoutInline(containerBlock).layer()->setStaticInlinePosition(block. startAlignedOffsetForLine(blockHeight, shouldIndentText)); 228 LineLayoutInline(containerBlock).layer()->setStaticInlinePosition(block. startAlignedOffsetForLine(blockHeight, indentText));
229 LineLayoutInline(containerBlock).layer()->setStaticBlockPosition(blockHe ight); 229 LineLayoutInline(containerBlock).layer()->setStaticBlockPosition(blockHe ight);
230 230
231 // If |child| is a leading or trailing positioned object this is its onl y opportunity to ensure it moves with an inline 231 // If |child| is a leading or trailing positioned object this is its onl y opportunity to ensure it moves with an inline
232 // container changing width. 232 // container changing width.
233 child.moveWithEdgeOfInlineContainerIfNecessary(child.isHorizontalWriting Mode()); 233 child.moveWithEdgeOfInlineContainerIfNecessary(child.isHorizontalWriting Mode());
234 } 234 }
235 block.updateStaticInlinePositionForChild(child, blockHeight, shouldIndentTex t); 235 block.updateStaticInlinePositionForChild(child, blockHeight, indentText);
236 child.layer()->setStaticBlockPosition(blockHeight); 236 child.layer()->setStaticBlockPosition(blockHeight);
237 } 237 }
238 238
239 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s ince we really need to be building 239 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s ince we really need to be building
240 // line boxes even for containers that may ultimately collapse away. Otherwise w e'll never get positioned 240 // line boxes even for containers that may ultimately collapse away. Otherwise w e'll never get positioned
241 // elements quite right. In other words, we need to build this function's work i nto the normal line 241 // elements quite right. In other words, we need to build this function's work i nto the normal line
242 // object iteration process. 242 // object iteration process.
243 // NB. this function will insert any floating elements that would otherwise 243 // NB. this function will insert any floating elements that would otherwise
244 // be skipped but it will not position them. 244 // be skipped but it will not position them.
245 inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, co nst LineInfo& lineInfo) 245 inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, co nst LineInfo& lineInfo)
246 { 246 {
247 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi tespace)) { 247 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi tespace)) {
248 LineLayoutItem item = iterator.object(); 248 LineLayoutItem item = iterator.object();
249 if (item.isOutOfFlowPositioned()) 249 if (item.isOutOfFlowPositioned())
250 setStaticPositions(m_block, LineLayoutBox(item), false); 250 setStaticPositions(m_block, LineLayoutBox(item), DoNotIndentText);
251 else if (item.isFloating()) 251 else if (item.isFloating())
252 m_block.insertFloatingObject(LineLayoutBox(item)); 252 m_block.insertFloatingObject(LineLayoutBox(item));
253 iterator.increment(); 253 iterator.increment();
254 } 254 }
255 } 255 }
256 256
257 inline void BreakingContext::initializeForCurrentObject() 257 inline void BreakingContext::initializeForCurrentObject()
258 { 258 {
259 m_currentStyle = m_current.object().style(); 259 m_currentStyle = m_current.object().style();
260 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object()); 260 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object());
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 if (m_lastObject.isAtomicInlineLevel() && m_autoWrap && (!m_lastObject.i sImage() || m_allowImagesToBreak) && (!m_lastObject.isListMarker() || LineLayout ListMarker(m_lastObject).isInside()) 967 if (m_lastObject.isAtomicInlineLevel() && m_autoWrap && (!m_lastObject.i sImage() || m_allowImagesToBreak) && (!m_lastObject.isListMarker() || LineLayout ListMarker(m_lastObject).isInside())
968 && !m_lastObject.isRubyRun()) { 968 && !m_lastObject.isRubyRun()) {
969 m_width.commit(); 969 m_width.commit();
970 m_lineBreak.moveToStartOf(m_nextObject); 970 m_lineBreak.moveToStartOf(m_nextObject);
971 } 971 }
972 } 972 }
973 } 973 }
974 974
975 inline IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea k, const ComputedStyle& style) 975 inline IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea k, const ComputedStyle& style)
976 { 976 {
977 IndentTextOrNot shouldIndentText = DoNotIndentText; 977 IndentTextOrNot indentText = DoNotIndentText;
978 if (isFirstLine || (isAfterHardLineBreak && style.textIndentLine()) == TextI ndentEachLine) 978 if (isFirstLine || (isAfterHardLineBreak && style.textIndentLine()) == TextI ndentEachLine)
979 shouldIndentText = IndentText; 979 indentText = IndentText;
980 980
981 if (style.textIndentType() == TextIndentHanging) 981 if (style.textIndentType() == TextIndentHanging)
982 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 982 indentText = indentText == IndentText ? DoNotIndentText : IndentText;
983 983
984 return shouldIndentText; 984 return indentText;
985 } 985 }
986 986
987 } 987 }
988 988
989 #endif // BreakingContextInlineHeaders_h 989 #endif // BreakingContextInlineHeaders_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698