Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 2 | #include "modules/skparagraph/src/ParagraphImpl.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 3 | #include "modules/skparagraph/src/TextWrapper.h" |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 4 | |
| 5 | namespace skia { |
| 6 | namespace textlayout { |
| 7 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 8 | namespace { |
| 9 | SkScalar littleRound(SkScalar a) { |
| 10 | // This rounding is done to match Flutter tests. Must be removed.. |
| 11 | return SkScalarRoundToScalar(a * 100.0)/100.0; |
| 12 | } |
| 13 | } |
| 14 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 15 | // Since we allow cluster clipping when they don't fit |
| 16 | // we have to work with stretches - parts of clusters |
| 17 | void TextWrapper::lookAhead(SkScalar maxWidth, Cluster* endOfClusters) { |
| 18 | fWords.startFrom(fEndLine.startCluster(), fEndLine.startPos()); |
| 19 | fClusters.startFrom(fEndLine.startCluster(), fEndLine.startPos()); |
| 20 | fClip.startFrom(fEndLine.startCluster(), fEndLine.startPos()); |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 21 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 22 | for (auto cluster = fEndLine.endCluster(); cluster < endOfClusters; ++cluster) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 23 | // TODO: Trying to deal with flutter rounding problem. Must be removed... |
| 24 | auto width = fWords.width() + fClusters.width() + cluster->width(); |
| 25 | auto roundedWidth = littleRound(width); |
| 26 | if (cluster->isHardBreak()) { |
| 27 | } else if (maxWidth == 0.0f) { |
| 28 | // Do nothing |
| 29 | } else if (roundedWidth > maxWidth) { |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 30 | if (cluster->isWhitespaces()) { |
Julia Lavrova | 6e6333f | 2019-06-17 10:34:10 -0400 | [diff] [blame] | 31 | // It's the end of the word |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 32 | fClusters.extend(cluster); |
Julia Lavrova | 6e6333f | 2019-06-17 10:34:10 -0400 | [diff] [blame] | 33 | fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, getClustersTrimmedWidth()); |
| 34 | fWords.extend(fClusters); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 35 | break; |
| 36 | } |
| 37 | if (cluster->width() > maxWidth) { |
| 38 | // Break the cluster into parts by glyph position |
| 39 | auto delta = maxWidth - (fWords.width() + fClusters.width()); |
| 40 | fClip.extend(cluster, cluster->roundPos(delta)); |
| 41 | fTooLongCluster = true; |
| 42 | fTooLongWord = true; |
| 43 | break; |
| 44 | } |
| 45 | |
| 46 | // Walk further to see if there is a too long word, cluster or glyph |
| 47 | SkScalar nextWordLength = fClusters.width(); |
| 48 | for (auto further = cluster; further != endOfClusters; ++further) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 49 | if (further->isSoftBreak() || further->isHardBreak() || further->isWhitespaces()) { |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 50 | break; |
| 51 | } |
| 52 | nextWordLength += further->width(); |
| 53 | } |
| 54 | if (nextWordLength > maxWidth) { |
| 55 | // If the word is too long we can break it right now and hope it's enough |
| 56 | fTooLongWord = true; |
| 57 | } |
| 58 | |
| 59 | // TODO: this is the place when we use hyphenation |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 60 | fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, fTooLongWord ? maxWidth : nextWordLength); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 61 | break; |
| 62 | } |
| 63 | |
| 64 | fClusters.extend(cluster); |
| 65 | |
| 66 | // Keep adding clusters/words |
| 67 | if (fClusters.endOfWord()) { |
| 68 | fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, getClustersTrimmedWidth()); |
| 69 | fWords.extend(fClusters); |
| 70 | } |
| 71 | |
| 72 | if ((fHardLineBreak = cluster->isHardBreak())) { |
| 73 | // Stop at the hard line break |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void TextWrapper::moveForward() { |
| 80 | do { |
| 81 | if (fWords.width() > 0) { |
| 82 | fEndLine.extend(fWords); |
| 83 | } else if (fClusters.width() > 0) { |
| 84 | fEndLine.extend(fClusters); |
| 85 | fTooLongWord = false; |
Julia Lavrova | 2e30fde | 2019-10-09 09:43:02 -0400 | [diff] [blame] | 86 | } else if (fClip.width() > 0 || (fTooLongWord && fTooLongCluster)) { |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 87 | fEndLine.extend(fClip); |
| 88 | fTooLongWord = false; |
| 89 | fTooLongCluster = false; |
| 90 | } else { |
| 91 | break; |
| 92 | } |
| 93 | } while (fTooLongWord || fTooLongCluster); |
| 94 | } |
| 95 | |
| 96 | // Special case for start/end cluster since they can be clipped |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 97 | void TextWrapper::trimEndSpaces(TextAlign align) { |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 98 | // Remember the breaking position |
| 99 | fEndLine.saveBreak(); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 100 | // Skip all space cluster at the end |
| 101 | //bool left = align == TextAlign::kStart || align == TextAlign::kLeft; |
| 102 | bool right = align == TextAlign::kRight || align == TextAlign::kEnd; |
Julia Lavrova | 6e6333f | 2019-06-17 10:34:10 -0400 | [diff] [blame] | 103 | for (auto cluster = fEndLine.endCluster(); |
| 104 | cluster >= fEndLine.startCluster() && cluster->isWhitespaces(); |
| 105 | --cluster) { |
Julia Lavrova | 526df26 | 2019-08-21 17:49:44 -0400 | [diff] [blame] | 106 | if ((cluster->run()->leftToRight()) || |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 107 | (right && !cluster->run()->leftToRight()) || |
| 108 | align == TextAlign::kJustify || align == TextAlign::kCenter) { |
| 109 | fEndLine.trim(cluster); |
| 110 | continue; |
| 111 | } else { |
| 112 | break; |
| 113 | } |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 114 | } |
Julia Lavrova | 2e30fde | 2019-10-09 09:43:02 -0400 | [diff] [blame] | 115 | fEndLine.trim(); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | SkScalar TextWrapper::getClustersTrimmedWidth() { |
| 119 | // Move the end of the line to the left |
| 120 | SkScalar width = fClusters.width(); |
| 121 | auto cluster = fClusters.endCluster(); |
| 122 | for (; cluster > fClusters.startCluster() && cluster->isWhitespaces(); --cluster) { |
| 123 | width -= cluster->width(); |
| 124 | } |
| 125 | if (cluster >= fClusters.startCluster()) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 126 | if (cluster->isWhitespaces()) { |
| 127 | width -= cluster->width(); |
| 128 | } else { |
| 129 | width -= (cluster->width() - cluster->trimmedWidth(cluster->endPos())); |
| 130 | } |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 131 | } |
| 132 | return width; |
| 133 | } |
| 134 | |
| 135 | // Trim the beginning spaces in case of soft line break |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 136 | std::tuple<Cluster*, size_t, SkScalar> TextWrapper::trimStartSpaces(Cluster* endOfClusters) { |
| 137 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 138 | if (fHardLineBreak) { |
| 139 | // End of line is always end of cluster, but need to skip \n |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 140 | auto width = fEndLine.width(); |
| 141 | auto cluster = fEndLine.endCluster() + 1; |
| 142 | while (cluster < fEndLine.breakCluster() && cluster->isWhitespaces()) { |
| 143 | width += cluster->width(); |
| 144 | ++cluster; |
| 145 | } |
Julia Lavrova | af89d39 | 2019-08-09 15:19:26 -0400 | [diff] [blame] | 146 | return std::make_tuple(fEndLine.breakCluster() + 1, 0, width); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 147 | } |
| 148 | |
Julia Lavrova | c222856 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 149 | auto width = fEndLine.withWithGhostSpaces(); //fEndLine.width(); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 150 | auto cluster = fEndLine.breakCluster() + 1; |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 151 | while (cluster < endOfClusters && cluster->isWhitespaces()) { |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 152 | width += cluster->width(); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 153 | ++cluster; |
| 154 | } |
Julia Lavrova | af89d39 | 2019-08-09 15:19:26 -0400 | [diff] [blame] | 155 | return std::make_tuple(cluster, 0, width); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | void TextWrapper::breakTextIntoLines(ParagraphImpl* parent, |
| 159 | SkScalar maxWidth, |
| 160 | const AddLineToParagraph& addLine) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 161 | fHeight = 0; |
| 162 | fMinIntrinsicWidth = 0; |
| 163 | fMaxIntrinsicWidth = 0; |
| 164 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 165 | auto span = parent->clusters(); |
Julia Lavrova | 526df26 | 2019-08-21 17:49:44 -0400 | [diff] [blame] | 166 | if (span.size() == 0) { |
| 167 | return; |
| 168 | } |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 169 | auto maxLines = parent->paragraphStyle().getMaxLines(); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 170 | auto& ellipsisStr = parent->paragraphStyle().getEllipsis(); |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 171 | auto align = parent->paragraphStyle().effective_align(); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 172 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 173 | SkScalar softLineMaxIntrinsicWidth = 0; |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 174 | fEndLine = TextStretch(span.begin(), span.begin(), parent->strutForceHeight()); |
| 175 | auto end = span.end() - 1; |
| 176 | auto start = span.begin(); |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 177 | InternalLineMetrics maxRunMetrics; |
| 178 | auto needEllipsis = false; |
| 179 | auto endlessLine = maxLines == std::numeric_limits<size_t>::max(); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 180 | while (fEndLine.endCluster() != end) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 181 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 182 | reset(); |
| 183 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 184 | fEndLine.metrics().clean(); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 185 | lookAhead(maxWidth, end); |
| 186 | moveForward(); |
| 187 | |
| 188 | // Do not trim end spaces on the naturally last line of the left aligned text |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 189 | trimEndSpaces(align); |
| 190 | |
| 191 | // For soft line breaks add to the line all the spaces next to it |
| 192 | Cluster* startLine; |
| 193 | size_t pos; |
| 194 | SkScalar widthWithSpaces; |
| 195 | std::tie(startLine, pos, widthWithSpaces) = trimStartSpaces(end); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 196 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 197 | needEllipsis = |
| 198 | fEndLine.endCluster() < end - 1 && |
| 199 | SkScalarIsFinite(maxWidth) && |
| 200 | !ellipsisStr.isEmpty(); |
| 201 | |
| 202 | auto exceededLines = !endlessLine && fLineNumber >= maxLines; |
| 203 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 204 | // TODO: perform ellipsis work here |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 205 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 206 | // If the line is empty with the hard line break, let's take the paragraph font (flutter???) |
| 207 | if (fHardLineBreak && fEndLine.width() == 0) { |
Jason Simmons | 22bb52e | 2019-12-05 17:56:59 -0800 | [diff] [blame] | 208 | fEndLine.setMetrics(parent->getEmptyMetrics()); |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 209 | } |
| 210 | |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 211 | // Deal with placeholder clusters == runs[@size==1] |
| 212 | for (auto cluster = fEndLine.startCluster(); cluster <= fEndLine.endCluster(); ++cluster) { |
| 213 | if (cluster->run()->placeholder() != nullptr) { |
| 214 | SkASSERT(cluster->run()->size() == 1); |
| 215 | // Update the placeholder metrics so we can get the placeholder positions later |
| 216 | // and the line metrics (to make sure the placeholder fits) |
| 217 | cluster->run()->updateMetrics(&fEndLine.metrics()); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // Before we update the line metrics with struts, |
| 222 | // let's save it for GetRectsForRange(RectHeightStyle::kMax) |
| 223 | maxRunMetrics = fEndLine.metrics(); |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 224 | maxRunMetrics.fForceStrut = false; |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 225 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 226 | if (parent->strutEnabled()) { |
| 227 | // Make sure font metrics are not less than the strut |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 228 | parent->strutMetrics().updateLineMetrics(fEndLine.metrics()); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 229 | } |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 230 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 231 | // TODO: keep start/end/break info for text and runs but in a better way that below |
Julia Lavrova | 526df26 | 2019-08-21 17:49:44 -0400 | [diff] [blame] | 232 | TextRange text(fEndLine.startCluster()->textRange().start, fEndLine.endCluster()->textRange().end); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 233 | TextRange textWithSpaces(fEndLine.startCluster()->textRange().start, startLine->textRange().start); |
Julia Lavrova | 2e30fde | 2019-10-09 09:43:02 -0400 | [diff] [blame] | 234 | if (startLine == end) { |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 235 | textWithSpaces.end = parent->text().size(); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 236 | } |
Julia Lavrova | c222856 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 237 | ClusterRange clusters(fEndLine.startCluster() - start, fEndLine.endCluster() - start + 1); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 238 | ClusterRange clustersWithGhosts(fEndLine.startCluster() - start, startLine - start); |
| 239 | addLine(text, textWithSpaces, clusters, clustersWithGhosts, widthWithSpaces, |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 240 | fEndLine.startPos(), |
| 241 | fEndLine.endPos(), |
| 242 | SkVector::Make(0, fHeight), |
| 243 | SkVector::Make(fEndLine.width(), fEndLine.metrics().height()), |
| 244 | fEndLine.metrics(), |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 245 | needEllipsis && exceededLines && !fHardLineBreak); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 246 | |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 247 | parent->lines().back().setMaxRunMetrics(maxRunMetrics); |
| 248 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 249 | softLineMaxIntrinsicWidth += widthWithSpaces; |
| 250 | fMaxIntrinsicWidth = SkMaxScalar(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth); |
| 251 | if (fHardLineBreak) { |
| 252 | softLineMaxIntrinsicWidth = 0; |
| 253 | } |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 254 | // Start a new line |
| 255 | fHeight += fEndLine.metrics().height(); |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 256 | if (!fHardLineBreak || startLine != end) { |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 257 | fEndLine.clean(); |
| 258 | } |
| 259 | fEndLine.startFrom(startLine, pos); |
| 260 | parent->fMaxWidthWithTrailingSpaces = SkMaxScalar(parent->fMaxWidthWithTrailingSpaces, widthWithSpaces); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 261 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 262 | if (exceededLines || (needEllipsis && endlessLine && !fHardLineBreak)) { |
| 263 | fHardLineBreak = false; |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 264 | break; |
| 265 | } |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 266 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 267 | ++fLineNumber; |
| 268 | } |
| 269 | |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 270 | // We finished formatting the text but we need to scan the rest for some numbers |
| 271 | auto cluster = fEndLine.endCluster(); |
| 272 | while (cluster != end) { |
| 273 | fExceededMaxLines = true; |
| 274 | if (cluster->isHardBreak()) { |
| 275 | softLineMaxIntrinsicWidth = 0; |
| 276 | } else { |
| 277 | softLineMaxIntrinsicWidth += cluster->width(); |
| 278 | fMaxIntrinsicWidth = SkTMax(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth); |
| 279 | } |
| 280 | ++cluster; |
| 281 | } |
| 282 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 283 | if (fHardLineBreak) { |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 284 | |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 285 | // Last character is a line break |
| 286 | if (parent->strutEnabled()) { |
| 287 | // Make sure font metrics are not less than the strut |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 288 | parent->strutMetrics().updateLineMetrics(fEndLine.metrics()); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 289 | } |
Julia Lavrova | 5207f35 | 2019-06-21 12:22:32 -0400 | [diff] [blame] | 290 | TextRange empty(fEndLine.breakCluster()->textRange().start, fEndLine.breakCluster()->textRange().start); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 291 | TextRange hardBreak(fEndLine.breakCluster()->textRange().end, fEndLine.breakCluster()->textRange().end); |
Julia Lavrova | 526df26 | 2019-08-21 17:49:44 -0400 | [diff] [blame] | 292 | ClusterRange clusters(fEndLine.breakCluster() - start, fEndLine.endCluster() - start); |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 293 | addLine(empty, hardBreak, clusters, clusters, |
| 294 | 0, |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 295 | 0, |
| 296 | 0, |
| 297 | SkVector::Make(0, fHeight), |
| 298 | SkVector::Make(0, fEndLine.metrics().height()), |
| 299 | fEndLine.metrics(), |
Julia Lavrova | f3ed273 | 2019-09-05 14:35:17 -0400 | [diff] [blame] | 300 | needEllipsis); |
| 301 | fHeight += fEndLine.metrics().height(); |
Julia Lavrova | 916a904 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 302 | parent->lines().back().setMaxRunMetrics(maxRunMetrics); |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
| 306 | } // namespace textlayout |
| 307 | } // namespace skia |