OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) const | 154 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) const |
155 { | 155 { |
156 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); | 156 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); |
157 } | 157 } |
158 | 158 |
159 bool RootInlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo
cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay
outUnit lineBottom) | 159 bool RootInlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo
cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay
outUnit lineBottom) |
160 { | 160 { |
161 if (hasEllipsisBox() && visibleToHitTestRequest(result.hitTestRequest())) { | 161 if (hasEllipsisBox() && visibleToHitTestRequest(result.hitTestRequest())) { |
162 if (ellipsisBox()->nodeAtPoint(result, locationInContainer, accumulatedO
ffset, lineTop, lineBottom)) { | 162 if (ellipsisBox()->nodeAtPoint(result, locationInContainer, accumulatedO
ffset, lineTop, lineBottom)) { |
163 lineLayoutItem().updateHitTestResult(result, locationInContainer.poi
nt() - toLayoutSize(accumulatedOffset)); | 163 getLineLayoutItem().updateHitTestResult(result, locationInContainer.
point() - toLayoutSize(accumulatedOffset)); |
164 return true; | 164 return true; |
165 } | 165 } |
166 } | 166 } |
167 return InlineFlowBox::nodeAtPoint(result, locationInContainer, accumulatedOf
fset, lineTop, lineBottom); | 167 return InlineFlowBox::nodeAtPoint(result, locationInContainer, accumulatedOf
fset, lineTop, lineBottom); |
168 } | 168 } |
169 | 169 |
170 void RootInlineBox::move(const LayoutSize& delta) | 170 void RootInlineBox::move(const LayoutSize& delta) |
171 { | 171 { |
172 InlineFlowBox::move(delta); | 172 InlineFlowBox::move(delta); |
173 LayoutUnit blockDirectionDelta = isHorizontal() ? delta.height() : delta.wid
th(); | 173 LayoutUnit blockDirectionDelta = isHorizontal() ? delta.height() : delta.wid
th(); |
174 m_lineTop += blockDirectionDelta; | 174 m_lineTop += blockDirectionDelta; |
175 m_lineBottom += blockDirectionDelta; | 175 m_lineBottom += blockDirectionDelta; |
176 m_lineTopWithLeading += blockDirectionDelta; | 176 m_lineTopWithLeading += blockDirectionDelta; |
177 m_lineBottomWithLeading += blockDirectionDelta; | 177 m_lineBottomWithLeading += blockDirectionDelta; |
178 m_selectionBottom += blockDirectionDelta; | 178 m_selectionBottom += blockDirectionDelta; |
179 if (hasEllipsisBox()) | 179 if (hasEllipsisBox()) |
180 ellipsisBox()->move(delta); | 180 ellipsisBox()->move(delta); |
181 } | 181 } |
182 | 182 |
183 void RootInlineBox::childRemoved(InlineBox* box) | 183 void RootInlineBox::childRemoved(InlineBox* box) |
184 { | 184 { |
185 if (box->lineLayoutItem() == m_lineBreakObj) | 185 if (box->getLineLayoutItem() == m_lineBreakObj) |
186 setLineBreakInfo(0, 0, BidiStatus()); | 186 setLineBreakInfo(0, 0, BidiStatus()); |
187 | 187 |
188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == bo
x->lineLayoutItem(); prev = prev->prevRootBox()) { | 188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == bo
x->getLineLayoutItem(); prev = prev->prevRootBox()) { |
189 prev->setLineBreakInfo(0, 0, BidiStatus()); | 189 prev->setLineBreakInfo(0, 0, BidiStatus()); |
190 prev->markDirty(); | 190 prev->markDirty(); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 static inline void snapHeight(int& maxAscent, int& maxDescent, const ComputedSty
le& style) | 194 static inline void snapHeight(int& maxAscent, int& maxDescent, const ComputedSty
le& style) |
195 { | 195 { |
196 // If position is 0, add spaces to over/under equally. | 196 // If position is 0, add spaces to over/under equally. |
197 // https://drafts.csswg.org/css-snap-size/#snap-height | 197 // https://drafts.csswg.org/css-snap-size/#snap-height |
198 int unit = style.snapHeightUnit(); | 198 int unit = style.snapHeightUnit(); |
(...skipping 26 matching lines...) Expand all Loading... |
225 return LayoutUnit(); | 225 return LayoutUnit(); |
226 | 226 |
227 LayoutUnit maxPositionTop; | 227 LayoutUnit maxPositionTop; |
228 LayoutUnit maxPositionBottom; | 228 LayoutUnit maxPositionBottom; |
229 int maxAscent = 0; | 229 int maxAscent = 0; |
230 int maxDescent = 0; | 230 int maxDescent = 0; |
231 bool setMaxAscent = false; | 231 bool setMaxAscent = false; |
232 bool setMaxDescent = false; | 232 bool setMaxDescent = false; |
233 | 233 |
234 // Figure out if we're in no-quirks mode. | 234 // Figure out if we're in no-quirks mode. |
235 bool noQuirksMode = lineLayoutItem().document().inNoQuirksMode(); | 235 bool noQuirksMode = getLineLayoutItem().document().inNoQuirksMode(); |
236 | 236 |
237 m_baselineType = dominantBaseline(); | 237 m_baselineType = dominantBaseline(); |
238 | 238 |
239 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline
Type(), verticalPositionCache); | 239 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline
Type(), verticalPositionCache); |
240 | 240 |
241 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) | 241 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) |
242 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi
tionBottom); | 242 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi
tionBottom); |
243 | 243 |
244 if (lineLayoutItem().styleRef().snapHeightUnit()) | 244 if (getLineLayoutItem().styleRef().snapHeightUnit()) |
245 snapHeight(maxAscent, maxDescent, lineLayoutItem().styleRef()); | 245 snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef()); |
246 | 246 |
247 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); | 247 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); |
248 LayoutUnit lineTop = heightOfBlock; | 248 LayoutUnit lineTop = heightOfBlock; |
249 LayoutUnit lineBottom = heightOfBlock; | 249 LayoutUnit lineBottom = heightOfBlock; |
250 LayoutUnit lineTopIncludingMargins = heightOfBlock; | 250 LayoutUnit lineTopIncludingMargins = heightOfBlock; |
251 LayoutUnit lineBottomIncludingMargins = heightOfBlock; | 251 LayoutUnit lineBottomIncludingMargins = heightOfBlock; |
252 LayoutUnit selectionBottom = heightOfBlock; | 252 LayoutUnit selectionBottom = heightOfBlock; |
253 bool setLineTop = false; | 253 bool setLineTop = false; |
254 bool hasAnnotationsBefore = false; | 254 bool hasAnnotationsBefore = false; |
255 bool hasAnnotationsAfter = false; | 255 bool hasAnnotationsAfter = false; |
(...skipping 20 matching lines...) Expand all Loading... |
276 { | 276 { |
277 LayoutUnit maxLogicalTop; | 277 LayoutUnit maxLogicalTop; |
278 computeMaxLogicalTop(maxLogicalTop); | 278 computeMaxLogicalTop(maxLogicalTop); |
279 return maxLogicalTop; | 279 return maxLogicalTop; |
280 } | 280 } |
281 | 281 |
282 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const | 282 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const |
283 { | 283 { |
284 LayoutUnit result; | 284 LayoutUnit result; |
285 | 285 |
286 if (!lineLayoutItem().style()->isFlippedLinesWritingMode()) { | 286 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode()) { |
287 // Annotations under the previous line may push us down. | 287 // Annotations under the previous line may push us down. |
288 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) | 288 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) |
289 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); | 289 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); |
290 | 290 |
291 if (!hasAnnotationsBefore()) | 291 if (!hasAnnotationsBefore()) |
292 return result; | 292 return result; |
293 | 293 |
294 // Annotations over this line may push us further down. | 294 // Annotations over this line may push us further down. |
295 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox
()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe
fore()); | 295 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox
()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe
fore()); |
296 result = computeOverAnnotationAdjustment(highestAllowedPosition); | 296 result = computeOverAnnotationAdjustment(highestAllowedPosition); |
297 } else { | 297 } else { |
298 // Annotations under this line may push us up. | 298 // Annotations under this line may push us up. |
299 if (hasAnnotationsBefore()) | 299 if (hasAnnotationsBefore()) |
300 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBo
x()->lineBottom() : static_cast<LayoutUnit>(block().borderBefore())); | 300 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBo
x()->lineBottom() : static_cast<LayoutUnit>(block().borderBefore())); |
301 | 301 |
302 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) | 302 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) |
303 return result; | 303 return result; |
304 | 304 |
305 // We have to compute the expansion for annotations over the previous li
ne to see how much we should move. | 305 // We have to compute the expansion for annotations over the previous li
ne to see how much we should move. |
306 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(),
lineTop()) - result; | 306 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(),
lineTop()) - result; |
307 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos
ition); | 307 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos
ition); |
308 } | 308 } |
309 | 309 |
310 return result; | 310 return result; |
311 } | 311 } |
312 | 312 |
313 SelectionState RootInlineBox::selectionState() const | 313 SelectionState RootInlineBox::getSelectionState() const |
314 { | 314 { |
315 // Walk over all of the selected boxes. | 315 // Walk over all of the selected boxes. |
316 SelectionState state = SelectionNone; | 316 SelectionState state = SelectionNone; |
317 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { | 317 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { |
318 SelectionState boxState = box->selectionState(); | 318 SelectionState boxState = box->getSelectionState(); |
319 if ((boxState == SelectionStart && state == SelectionEnd) | 319 if ((boxState == SelectionStart && state == SelectionEnd) |
320 || (boxState == SelectionEnd && state == SelectionStart)) { | 320 || (boxState == SelectionEnd && state == SelectionStart)) { |
321 state = SelectionBoth; | 321 state = SelectionBoth; |
322 } else if (state == SelectionNone || ((boxState == SelectionStart || box
State == SelectionEnd) && (state == SelectionNone || state == SelectionInside)))
{ | 322 } else if (state == SelectionNone || ((boxState == SelectionStart || box
State == SelectionEnd) && (state == SelectionNone || state == SelectionInside)))
{ |
323 state = boxState; | 323 state = boxState; |
324 } else if (boxState == SelectionNone && state == SelectionStart) { | 324 } else if (boxState == SelectionNone && state == SelectionStart) { |
325 // We are past the end of the selection. | 325 // We are past the end of the selection. |
326 state = SelectionBoth; | 326 state = SelectionBoth; |
327 } | 327 } |
328 if (state == SelectionBoth) | 328 if (state == SelectionBoth) |
329 break; | 329 break; |
330 } | 330 } |
331 | 331 |
332 return state; | 332 return state; |
333 } | 333 } |
334 | 334 |
335 InlineBox* RootInlineBox::firstSelectedBox() const | 335 InlineBox* RootInlineBox::firstSelectedBox() const |
336 { | 336 { |
337 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { | 337 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { |
338 if (box->selectionState() != SelectionNone) | 338 if (box->getSelectionState() != SelectionNone) |
339 return box; | 339 return box; |
340 } | 340 } |
341 | 341 |
342 return nullptr; | 342 return nullptr; |
343 } | 343 } |
344 | 344 |
345 InlineBox* RootInlineBox::lastSelectedBox() const | 345 InlineBox* RootInlineBox::lastSelectedBox() const |
346 { | 346 { |
347 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { | 347 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { |
348 if (box->selectionState() != SelectionNone) | 348 if (box->getSelectionState() != SelectionNone) |
349 return box; | 349 return box; |
350 } | 350 } |
351 | 351 |
352 return nullptr; | 352 return nullptr; |
353 } | 353 } |
354 | 354 |
355 LayoutUnit RootInlineBox::selectionTop() const | 355 LayoutUnit RootInlineBox::selectionTop() const |
356 { | 356 { |
357 LayoutUnit selectionTop = m_lineTop; | 357 LayoutUnit selectionTop = m_lineTop; |
358 | 358 |
359 if (m_hasAnnotationsBefore) | 359 if (m_hasAnnotationsBefore) |
360 selectionTop -= !lineLayoutItem().style()->isFlippedLinesWritingMode() ?
computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m
_lineTop); | 360 selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode(
) ? computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustmen
t(m_lineTop); |
361 | 361 |
362 if (lineLayoutItem().style()->isFlippedLinesWritingMode() || !prevRootBox()) | 362 if (getLineLayoutItem().style()->isFlippedLinesWritingMode() || !prevRootBox
()) |
363 return selectionTop; | 363 return selectionTop; |
364 | 364 |
365 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); | 365 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); |
366 if (prevBottom < selectionTop && block().containsFloats()) { | 366 if (prevBottom < selectionTop && block().containsFloats()) { |
367 // This line has actually been moved further down, probably from a large
line-height, but possibly because the | 367 // This line has actually been moved further down, probably from a large
line-height, but possibly because the |
368 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous | 368 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous |
369 // line's bottom if the offsets are greater on both sides. | 369 // line's bottom if the offsets are greater on both sides. |
370 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, DoNot
IndentText); | 370 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, DoNot
IndentText); |
371 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, DoN
otIndentText); | 371 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, DoN
otIndentText); |
372 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, DoNo
tIndentText); | 372 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, DoNo
tIndentText); |
373 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionTop, Do
NotIndentText); | 373 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionTop, Do
NotIndentText); |
374 if (prevLeft > newLeft || prevRight < newRight) | 374 if (prevLeft > newLeft || prevRight < newRight) |
375 return selectionTop; | 375 return selectionTop; |
376 } | 376 } |
377 | 377 |
378 return prevBottom; | 378 return prevBottom; |
379 } | 379 } |
380 | 380 |
381 LayoutUnit RootInlineBox::selectionBottom() const | 381 LayoutUnit RootInlineBox::selectionBottom() const |
382 { | 382 { |
383 LayoutUnit selectionBottom = lineLayoutItem().document().inNoQuirksMode() ?
m_selectionBottom : m_lineBottom; | 383 LayoutUnit selectionBottom = getLineLayoutItem().document().inNoQuirksMode()
? m_selectionBottom : m_lineBottom; |
384 | 384 |
385 if (m_hasAnnotationsAfter) | 385 if (m_hasAnnotationsAfter) |
386 selectionBottom += !lineLayoutItem().style()->isFlippedLinesWritingMode(
) ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjust
ment(m_lineBottom); | 386 selectionBottom += !getLineLayoutItem().style()->isFlippedLinesWritingMo
de() ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdj
ustment(m_lineBottom); |
387 | 387 |
388 if (!lineLayoutItem().style()->isFlippedLinesWritingMode() || !nextRootBox()
) | 388 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode() || !nextRootBo
x()) |
389 return selectionBottom; | 389 return selectionBottom; |
390 | 390 |
391 LayoutUnit nextTop = nextRootBox()->selectionTop(); | 391 LayoutUnit nextTop = nextRootBox()->selectionTop(); |
392 if (nextTop > selectionBottom && block().containsFloats()) { | 392 if (nextTop > selectionBottom && block().containsFloats()) { |
393 // The next line has actually been moved further over, probably from a l
arge line-height, but possibly because the | 393 // The next line has actually been moved further over, probably from a l
arge line-height, but possibly because the |
394 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the next | 394 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the next |
395 // line's top if the offsets are greater on both sides. | 395 // line's top if the offsets are greater on both sides. |
396 LayoutUnit nextLeft = block().logicalLeftOffsetForLine(nextTop, DoNotInd
entText); | 396 LayoutUnit nextLeft = block().logicalLeftOffsetForLine(nextTop, DoNotInd
entText); |
397 LayoutUnit nextRight = block().logicalRightOffsetForLine(nextTop, DoNotI
ndentText); | 397 LayoutUnit nextRight = block().logicalRightOffsetForLine(nextTop, DoNotI
ndentText); |
398 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionBottom, D
oNotIndentText); | 398 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionBottom, D
oNotIndentText); |
399 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom,
DoNotIndentText); | 399 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom,
DoNotIndentText); |
400 if (nextLeft > newLeft || nextRight < newRight) | 400 if (nextLeft > newLeft || nextRight < newRight) |
401 return selectionBottom; | 401 return selectionBottom; |
402 } | 402 } |
403 | 403 |
404 return nextTop; | 404 return nextTop; |
405 } | 405 } |
406 | 406 |
407 LayoutUnit RootInlineBox::blockDirectionPointInLine() const | 407 LayoutUnit RootInlineBox::blockDirectionPointInLine() const |
408 { | 408 { |
409 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(),
selectionTop()) : std::min(lineBottom(), selectionBottom()); | 409 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(),
selectionTop()) : std::min(lineBottom(), selectionBottom()); |
410 } | 410 } |
411 | 411 |
412 LineLayoutBlockFlow RootInlineBox::block() const | 412 LineLayoutBlockFlow RootInlineBox::block() const |
413 { | 413 { |
414 return LineLayoutBlockFlow(lineLayoutItem()); | 414 return LineLayoutBlockFlow(getLineLayoutItem()); |
415 } | 415 } |
416 | 416 |
417 static bool isEditableLeaf(InlineBox* leaf) | 417 static bool isEditableLeaf(InlineBox* leaf) |
418 { | 418 { |
419 return leaf && leaf->lineLayoutItem().node() && leaf->lineLayoutItem().node(
)->hasEditableStyle(); | 419 return leaf && leaf->getLineLayoutItem().node() && leaf->getLineLayoutItem()
.node()->hasEditableStyle(); |
420 } | 420 } |
421 | 421 |
422 InlineBox* RootInlineBox::closestLeafChildForPoint(const LayoutPoint& pointInCon
tents, bool onlyEditableLeaves) | 422 InlineBox* RootInlineBox::closestLeafChildForPoint(const LayoutPoint& pointInCon
tents, bool onlyEditableLeaves) |
423 { | 423 { |
424 return closestLeafChildForLogicalLeftPosition(block().isHorizontalWritingMod
e() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves); | 424 return closestLeafChildForLogicalLeftPosition(block().isHorizontalWritingMod
e() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves); |
425 } | 425 } |
426 | 426 |
427 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(LayoutUnit left
Position, bool onlyEditableLeaves) | 427 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(LayoutUnit left
Position, bool onlyEditableLeaves) |
428 { | 428 { |
429 InlineBox* firstLeaf = firstLeafChild(); | 429 InlineBox* firstLeaf = firstLeafChild(); |
430 InlineBox* lastLeaf = lastLeafChild(); | 430 InlineBox* lastLeaf = lastLeafChild(); |
431 | 431 |
432 if (firstLeaf != lastLeaf) { | 432 if (firstLeaf != lastLeaf) { |
433 if (firstLeaf->isLineBreak()) | 433 if (firstLeaf->isLineBreak()) |
434 firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); | 434 firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); |
435 else if (lastLeaf->isLineBreak()) | 435 else if (lastLeaf->isLineBreak()) |
436 lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); | 436 lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); |
437 } | 437 } |
438 | 438 |
439 if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLea
f))) | 439 if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLea
f))) |
440 return firstLeaf; | 440 return firstLeaf; |
441 | 441 |
442 // Avoid returning a list marker when possible. | 442 // Avoid returning a list marker when possible. |
443 if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->lineLayoutItem()
.isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) { | 443 if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->getLineLayoutIte
m().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) { |
444 // The leftPosition coordinate is less or equal to left edge of the firs
tLeaf. | 444 // The leftPosition coordinate is less or equal to left edge of the firs
tLeaf. |
445 // Return it. | 445 // Return it. |
446 return firstLeaf; | 446 return firstLeaf; |
447 } | 447 } |
448 | 448 |
449 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->lineLayoutItem().
isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { | 449 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->getLineLayoutItem
().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { |
450 // The leftPosition coordinate is greater or equal to right edge of the
lastLeaf. | 450 // The leftPosition coordinate is greater or equal to right edge of the
lastLeaf. |
451 // Return it. | 451 // Return it. |
452 return lastLeaf; | 452 return lastLeaf; |
453 } | 453 } |
454 | 454 |
455 InlineBox* closestLeaf = nullptr; | 455 InlineBox* closestLeaf = nullptr; |
456 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi
neBreak()) { | 456 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi
neBreak()) { |
457 if (!leaf->lineLayoutItem().isListMarker() && (!onlyEditableLeaves || is
EditableLeaf(leaf))) { | 457 if (!leaf->getLineLayoutItem().isListMarker() && (!onlyEditableLeaves ||
isEditableLeaf(leaf))) { |
458 closestLeaf = leaf; | 458 closestLeaf = leaf; |
459 if (leftPosition < leaf->logicalRight()) { | 459 if (leftPosition < leaf->logicalRight()) { |
460 // The x coordinate is less than the right edge of the box. | 460 // The x coordinate is less than the right edge of the box. |
461 // Return it. | 461 // Return it. |
462 return leaf; | 462 return leaf; |
463 } | 463 } |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 return closestLeaf ? closestLeaf : lastLeaf; | 467 return closestLeaf ? closestLeaf : lastLeaf; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } else { | 544 } else { |
545 ascent = std::max(ascent, newAscent); | 545 ascent = std::max(ascent, newAscent); |
546 descent = std::max(descent, newDescent); | 546 descent = std::max(descent, newDescent); |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb
ackFontsMap& textBoxDataMap, int& ascent, int& descent, bool& affectsAscent, boo
l& affectsDescent) const | 550 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb
ackFontsMap& textBoxDataMap, int& ascent, int& descent, bool& affectsAscent, boo
l& affectsDescent) const |
551 { | 551 { |
552 bool ascentDescentSet = false; | 552 bool ascentDescentSet = false; |
553 | 553 |
554 if (box->lineLayoutItem().isAtomicInlineLevel()) { | 554 if (box->getLineLayoutItem().isAtomicInlineLevel()) { |
555 ascent = box->baselinePosition(baselineType()); | 555 ascent = box->baselinePosition(baselineType()); |
556 descent = roundToInt(box->lineHeight() - ascent); | 556 descent = roundToInt(box->lineHeight() - ascent); |
557 | 557 |
558 // Replaced elements always affect both the ascent and descent. | 558 // Replaced elements always affect both the ascent and descent. |
559 affectsAscent = true; | 559 affectsAscent = true; |
560 affectsDescent = true; | 560 affectsDescent = true; |
561 return; | 561 return; |
562 } | 562 } |
563 | 563 |
564 Vector<const SimpleFontData*>* usedFonts = nullptr; | 564 Vector<const SimpleFontData*>* usedFonts = nullptr; |
565 if (box->isText()) { | 565 if (box->isText()) { |
566 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn
lineTextBox(box)); | 566 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn
lineTextBox(box)); |
567 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; | 567 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; |
568 } | 568 } |
569 | 569 |
570 bool includeLeading = includeLeadingForBox(box); | 570 bool includeLeading = includeLeadingForBox(box); |
571 bool setUsedFontWithLeading = false; | 571 bool setUsedFontWithLeading = false; |
572 | 572 |
573 if (usedFonts && !usedFonts->isEmpty() && (box->lineLayoutItem().style(isFir
stLineStyle())->lineHeight().isNegative() && includeLeading)) { | 573 if (usedFonts && !usedFonts->isEmpty() && (box->getLineLayoutItem().style(is
FirstLineStyle())->lineHeight().isNegative() && includeLeading)) { |
574 usedFonts->append(box->lineLayoutItem().style(isFirstLineStyle())->font(
).primaryFont()); | 574 usedFonts->append(box->getLineLayoutItem().style(isFirstLineStyle())->fo
nt().primaryFont()); |
575 for (size_t i = 0; i < usedFonts->size(); ++i) { | 575 for (size_t i = 0; i < usedFonts->size(); ++i) { |
576 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); | 576 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); |
577 int usedFontAscent = fontMetrics.ascent(baselineType()); | 577 int usedFontAscent = fontMetrics.ascent(baselineType()); |
578 int usedFontDescent = fontMetrics.descent(baselineType()); | 578 int usedFontDescent = fontMetrics.descent(baselineType()); |
579 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height())
/ 2; | 579 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height())
/ 2; |
580 int usedFontAscentAndLeading = usedFontAscent + halfLeading; | 580 int usedFontAscentAndLeading = usedFontAscent + halfLeading; |
581 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont
AscentAndLeading; | 581 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont
AscentAndLeading; |
582 if (includeLeading) { | 582 if (includeLeading) { |
583 setAscentAndDescent(ascent, descent, usedFontAscentAndLeading, u
sedFontDescentAndLeading, ascentDescentSet); | 583 setAscentAndDescent(ascent, descent, usedFontAscentAndLeading, u
sedFontDescentAndLeading, ascentDescentSet); |
584 setUsedFontWithLeading = true; | 584 setUsedFontWithLeading = true; |
(...skipping 15 matching lines...) Expand all Loading... |
600 // If the top of our font box relative to the root box baseline is above
the root box baseline, then | 600 // If the top of our font box relative to the root box baseline is above
the root box baseline, then |
601 // we are contributing to the maxAscent value. Descent is similar. If an
y part of our font box is below | 601 // we are contributing to the maxAscent value. Descent is similar. If an
y part of our font box is below |
602 // the root box's baseline, then we contribute to the maxDescent value. | 602 // the root box's baseline, then we contribute to the maxDescent value. |
603 affectsAscent = ascentWithLeading - box->logicalTop() > 0; | 603 affectsAscent = ascentWithLeading - box->logicalTop() > 0; |
604 affectsDescent = descentWithLeading + box->logicalTop() > 0; | 604 affectsDescent = descentWithLeading + box->logicalTop() > 0; |
605 } | 605 } |
606 } | 606 } |
607 | 607 |
608 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
nCache& verticalPositionCache) | 608 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
nCache& verticalPositionCache) |
609 { | 609 { |
610 if (box->lineLayoutItem().isText()) | 610 if (box->getLineLayoutItem().isText()) |
611 return box->parent()->logicalTop(); | 611 return box->parent()->logicalTop(); |
612 | 612 |
613 LineLayoutBoxModel boxModel = box->boxModelObject(); | 613 LineLayoutBoxModel boxModel = box->boxModelObject(); |
614 ASSERT(boxModel.isInline()); | 614 ASSERT(boxModel.isInline()); |
615 if (!boxModel.isInline()) | 615 if (!boxModel.isInline()) |
616 return LayoutUnit(); | 616 return LayoutUnit(); |
617 | 617 |
618 // This method determines the vertical position for inline elements. | 618 // This method determines the vertical position for inline elements. |
619 bool firstLine = isFirstLineStyle(); | 619 bool firstLine = isFirstLineStyle(); |
620 if (firstLine && !boxModel.document().styleEngine().usesFirstLineRules()) | 620 if (firstLine && !boxModel.document().styleEngine().usesFirstLineRules()) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 674 |
675 // Store the cached value. | 675 // Store the cached value. |
676 if (isLayoutInline && !firstLine) | 676 if (isLayoutInline && !firstLine) |
677 verticalPositionCache.set(boxModel, baselineType(), verticalPosition); | 677 verticalPositionCache.set(boxModel, baselineType(), verticalPosition); |
678 | 678 |
679 return verticalPosition; | 679 return verticalPosition; |
680 } | 680 } |
681 | 681 |
682 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const | 682 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const |
683 { | 683 { |
684 return !(box->lineLayoutItem().isAtomicInlineLevel() || (box->lineLayoutItem
().isText() && !box->isText())); | 684 return !(box->getLineLayoutItem().isAtomicInlineLevel() || (box->getLineLayo
utItem().isText() && !box->isText())); |
685 } | 685 } |
686 | 686 |
687 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const | 687 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const |
688 { | 688 { |
689 Vector<InlineBox*> leafBoxesInLogicalOrder; | 689 Vector<InlineBox*> leafBoxesInLogicalOrder; |
690 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); | 690 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); |
691 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { | 691 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { |
692 if (leafBoxesInLogicalOrder[i]->lineLayoutItem().nonPseudoNode()) { | 692 if (leafBoxesInLogicalOrder[i]->getLineLayoutItem().nonPseudoNode()) { |
693 startBox = leafBoxesInLogicalOrder[i]; | 693 startBox = leafBoxesInLogicalOrder[i]; |
694 return startBox->lineLayoutItem().nonPseudoNode(); | 694 return startBox->getLineLayoutItem().nonPseudoNode(); |
695 } | 695 } |
696 } | 696 } |
697 startBox = nullptr; | 697 startBox = nullptr; |
698 return nullptr; | 698 return nullptr; |
699 } | 699 } |
700 | 700 |
701 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const | 701 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const |
702 { | 702 { |
703 Vector<InlineBox*> leafBoxesInLogicalOrder; | 703 Vector<InlineBox*> leafBoxesInLogicalOrder; |
704 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); | 704 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); |
705 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { | 705 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { |
706 if (leafBoxesInLogicalOrder[i - 1]->lineLayoutItem().nonPseudoNode()) { | 706 if (leafBoxesInLogicalOrder[i - 1]->getLineLayoutItem().nonPseudoNode())
{ |
707 endBox = leafBoxesInLogicalOrder[i - 1]; | 707 endBox = leafBoxesInLogicalOrder[i - 1]; |
708 return endBox->lineLayoutItem().nonPseudoNode(); | 708 return endBox->getLineLayoutItem().nonPseudoNode(); |
709 } | 709 } |
710 } | 710 } |
711 endBox = nullptr; | 711 endBox = nullptr; |
712 return nullptr; | 712 return nullptr; |
713 } | 713 } |
714 | 714 |
715 const char* RootInlineBox::boxName() const | 715 const char* RootInlineBox::boxName() const |
716 { | 716 { |
717 return "RootInlineBox"; | 717 return "RootInlineBox"; |
718 } | 718 } |
719 | 719 |
720 } // namespace blink | 720 } // namespace blink |
OLD | NEW |