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

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

Issue 1995083003: Change LineWidth::fitsOnLine comparison logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: w/TestExpectations Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | 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) 2013 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 28 matching lines...) Expand all
39 class FloatingObject; 39 class FloatingObject;
40 class LineLayoutRubyRun; 40 class LineLayoutRubyRun;
41 41
42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; 42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace };
43 43
44 class LineWidth { 44 class LineWidth {
45 STACK_ALLOCATED(); 45 STACK_ALLOCATED();
46 public: 46 public:
47 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot); 47 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot);
48 48
49 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou tUnit::epsilon()); } 49 bool fitsOnLine() const
50 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava ilableWidth + LayoutUnit::epsilon()); } 50 {
51 return LayoutUnit::fromFloatFloor(currentWidth()) <= m_availableWidth;
52 }
53 bool fitsOnLine(float extra) const
54 {
55 float totalWidth = currentWidth() + extra;
56 return LayoutUnit::fromFloatFloor(totalWidth) <= m_availableWidth;
57 }
51 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const 58 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const
52 { 59 {
53 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon()) ; 60 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon()) ;
54 } 61 }
55 62
56 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point. Because 63 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point. Because
57 // currentWidth() is used by the code that lays out words in a single Layout Text, it's 64 // currentWidth() is used by the code that lays out words in a single Layout Text, it's
58 // expected that offsets will not be snapped until an InlineBox boundary is reached. 65 // expected that offsets will not be snapped until an InlineBox boundary is reached.
59 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } 66 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; }
60 67
(...skipping 27 matching lines...) Expand all
88 float m_left; 95 float m_left;
89 float m_right; 96 float m_right;
90 float m_availableWidth; 97 float m_availableWidth;
91 bool m_isFirstLine; 98 bool m_isFirstLine;
92 IndentTextOrNot m_indentText; 99 IndentTextOrNot m_indentText;
93 }; 100 };
94 101
95 } // namespace blink 102 } // namespace blink
96 103
97 #endif // LineWidth_h 104 #endif // LineWidth_h
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698