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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp

Issue 2393693002: Reformat comments in core/layout/line (Closed)
Patch Set: Created 4 years, 2 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) 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 LayoutUnit RootInlineBox::lineHeight() const { 88 LayoutUnit RootInlineBox::lineHeight() const {
89 return boxModelObject().lineHeight( 89 return boxModelObject().lineHeight(
90 isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, 90 isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine,
91 PositionOfInteriorLineBoxes); 91 PositionOfInteriorLineBoxes);
92 } 92 }
93 93
94 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, 94 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr,
95 int blockEdge, 95 int blockEdge,
96 int lineBoxEdge, 96 int lineBoxEdge,
97 int ellipsisWidth) { 97 int ellipsisWidth) {
98 // First sanity-check the unoverflowed width of the whole line to see if there is sufficient room. 98 // First sanity-check the unoverflowed width of the whole line to see if there
99 // is sufficient room.
99 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; 100 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge;
100 if (logicalWidth() - delta < ellipsisWidth) 101 if (logicalWidth() - delta < ellipsisWidth)
101 return false; 102 return false;
102 103
103 // Next iterate over all the line boxes on the line. If we find a replaced el ement that intersects 104 // Next iterate over all the line boxes on the line. If we find a replaced
104 // then we refuse to accommodate the ellipsis. Otherwise we're ok. 105 // element that intersects then we refuse to accommodate the ellipsis.
106 // Otherwise we're ok.
105 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); 107 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth);
106 } 108 }
107 109
108 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, 110 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr,
109 bool ltr, 111 bool ltr,
110 LayoutUnit blockLeftEdge, 112 LayoutUnit blockLeftEdge,
111 LayoutUnit blockRightEdge, 113 LayoutUnit blockRightEdge,
112 LayoutUnit ellipsisWidth) { 114 LayoutUnit ellipsisWidth) {
113 // Create an ellipsis box. 115 // Create an ellipsis box.
114 EllipsisBox* ellipsisBox = 116 EllipsisBox* ellipsisBox =
115 new EllipsisBox(getLineLayoutItem(), ellipsisStr, this, ellipsisWidth, 117 new EllipsisBox(getLineLayoutItem(), ellipsisStr, this, ellipsisWidth,
116 logicalHeight().toFloat(), x().toInt(), y().toInt(), 118 logicalHeight().toFloat(), x().toInt(), y().toInt(),
117 !prevRootBox(), isHorizontal()); 119 !prevRootBox(), isHorizontal());
118 120
119 if (!gEllipsisBoxMap) 121 if (!gEllipsisBoxMap)
120 gEllipsisBoxMap = new EllipsisBoxMap(); 122 gEllipsisBoxMap = new EllipsisBoxMap();
121 gEllipsisBoxMap->add(this, ellipsisBox); 123 gEllipsisBoxMap->add(this, ellipsisBox);
122 setHasEllipsisBox(true); 124 setHasEllipsisBox(true);
123 125
124 // FIXME: Do we need an RTL version of this? 126 // FIXME: Do we need an RTL version of this?
125 if (ltr && 127 if (ltr &&
126 (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdge) { 128 (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdge) {
127 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); 129 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth());
128 return logicalWidth() + ellipsisWidth; 130 return logicalWidth() + ellipsisWidth;
129 } 131 }
130 132
131 // Now attempt to find the nearest glyph horizontally and place just to the ri ght (or left in RTL) 133 // Now attempt to find the nearest glyph horizontally and place just to the
132 // of that glyph. Mark all of the objects that intersect the ellipsis box as not painting (as being 134 // right (or left in RTL) of that glyph. Mark all of the objects that
133 // truncated). 135 // intersect the ellipsis box as not painting (as being truncated).
134 bool foundBox = false; 136 bool foundBox = false;
135 LayoutUnit truncatedWidth; 137 LayoutUnit truncatedWidth;
136 LayoutUnit position = 138 LayoutUnit position =
137 placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, 139 placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth,
138 truncatedWidth, foundBox); 140 truncatedWidth, foundBox);
139 ellipsisBox->setLogicalLeft(position); 141 ellipsisBox->setLogicalLeft(position);
140 return truncatedWidth; 142 return truncatedWidth;
141 } 143 }
142 144
143 LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, 145 LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 m_hasAnnotationsBefore = hasAnnotationsBefore; 286 m_hasAnnotationsBefore = hasAnnotationsBefore;
285 m_hasAnnotationsAfter = hasAnnotationsAfter; 287 m_hasAnnotationsAfter = hasAnnotationsAfter;
286 288
287 maxHeight = maxHeight.clampNegativeToZero(); 289 maxHeight = maxHeight.clampNegativeToZero();
288 290
289 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, 291 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock,
290 heightOfBlock + maxHeight, selectionBottom); 292 heightOfBlock + maxHeight, selectionBottom);
291 293
292 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment(); 294 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment();
293 if (annotationsAdjustment) { 295 if (annotationsAdjustment) {
294 // FIXME: Need to handle pagination here. We might have to move to the next page/column as a result of the 296 // FIXME: Need to handle pagination here. We might have to move to the next
295 // ruby expansion. 297 // page/column as a result of the ruby expansion.
296 moveInBlockDirection(annotationsAdjustment); 298 moveInBlockDirection(annotationsAdjustment);
297 heightOfBlock += annotationsAdjustment; 299 heightOfBlock += annotationsAdjustment;
298 } 300 }
299 301
300 return heightOfBlock + maxHeight; 302 return heightOfBlock + maxHeight;
301 } 303 }
302 304
303 LayoutUnit RootInlineBox::maxLogicalTop() const { 305 LayoutUnit RootInlineBox::maxLogicalTop() const {
304 LayoutUnit maxLogicalTop; 306 LayoutUnit maxLogicalTop;
305 computeMaxLogicalTop(maxLogicalTop); 307 computeMaxLogicalTop(maxLogicalTop);
(...skipping 20 matching lines...) Expand all
326 } else { 328 } else {
327 // Annotations under this line may push us up. 329 // Annotations under this line may push us up.
328 if (hasAnnotationsBefore()) 330 if (hasAnnotationsBefore())
329 result = computeUnderAnnotationAdjustment( 331 result = computeUnderAnnotationAdjustment(
330 prevRootBox() ? prevRootBox()->lineBottom() 332 prevRootBox() ? prevRootBox()->lineBottom()
331 : static_cast<LayoutUnit>(block().borderBefore())); 333 : static_cast<LayoutUnit>(block().borderBefore()));
332 334
333 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) 335 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter())
334 return result; 336 return result;
335 337
336 // We have to compute the expansion for annotations over the previous line t o see how much we should move. 338 // We have to compute the expansion for annotations over the previous line
339 // to see how much we should move.
337 LayoutUnit lowestAllowedPosition = 340 LayoutUnit lowestAllowedPosition =
338 std::max(prevRootBox()->lineBottom(), lineTop()) - result; 341 std::max(prevRootBox()->lineBottom(), lineTop()) - result;
339 result = 342 result =
340 prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPosition); 343 prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPosition);
341 } 344 }
342 345
343 return result; 346 return result;
344 } 347 }
345 348
346 SelectionState RootInlineBox::getSelectionState() const { 349 SelectionState RootInlineBox::getSelectionState() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode() 394 selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode()
392 ? computeOverAnnotationAdjustment(m_lineTop) 395 ? computeOverAnnotationAdjustment(m_lineTop)
393 : computeUnderAnnotationAdjustment(m_lineTop); 396 : computeUnderAnnotationAdjustment(m_lineTop);
394 397
395 if (getLineLayoutItem().style()->isFlippedLinesWritingMode() || 398 if (getLineLayoutItem().style()->isFlippedLinesWritingMode() ||
396 !prevRootBox()) 399 !prevRootBox())
397 return selectionTop; 400 return selectionTop;
398 401
399 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); 402 LayoutUnit prevBottom = prevRootBox()->selectionBottom();
400 if (prevBottom < selectionTop && block().containsFloats()) { 403 if (prevBottom < selectionTop && block().containsFloats()) {
401 // This line has actually been moved further down, probably from a large lin e-height, but possibly because the 404 // This line has actually been moved further down, probably from a large
402 // line was forced to clear floats. If so, let's check the offsets, and onl y be willing to use the previous 405 // line-height, but possibly because the line was forced to clear floats.
406 // If so, let's check the offsets, and only be willing to use the previous
403 // line's bottom if the offsets are greater on both sides. 407 // line's bottom if the offsets are greater on both sides.
404 LayoutUnit prevLeft = 408 LayoutUnit prevLeft =
405 block().logicalLeftOffsetForLine(prevBottom, DoNotIndentText); 409 block().logicalLeftOffsetForLine(prevBottom, DoNotIndentText);
406 LayoutUnit prevRight = 410 LayoutUnit prevRight =
407 block().logicalRightOffsetForLine(prevBottom, DoNotIndentText); 411 block().logicalRightOffsetForLine(prevBottom, DoNotIndentText);
408 LayoutUnit newLeft = 412 LayoutUnit newLeft =
409 block().logicalLeftOffsetForLine(selectionTop, DoNotIndentText); 413 block().logicalLeftOffsetForLine(selectionTop, DoNotIndentText);
410 LayoutUnit newRight = 414 LayoutUnit newRight =
411 block().logicalRightOffsetForLine(selectionTop, DoNotIndentText); 415 block().logicalRightOffsetForLine(selectionTop, DoNotIndentText);
412 if (prevLeft > newLeft || prevRight < newRight) 416 if (prevLeft > newLeft || prevRight < newRight)
(...skipping 12 matching lines...) Expand all
425 selectionBottom += !getLineLayoutItem().style()->isFlippedLinesWritingMode() 429 selectionBottom += !getLineLayoutItem().style()->isFlippedLinesWritingMode()
426 ? computeUnderAnnotationAdjustment(m_lineBottom) 430 ? computeUnderAnnotationAdjustment(m_lineBottom)
427 : computeOverAnnotationAdjustment(m_lineBottom); 431 : computeOverAnnotationAdjustment(m_lineBottom);
428 432
429 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode() || 433 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode() ||
430 !nextRootBox()) 434 !nextRootBox())
431 return selectionBottom; 435 return selectionBottom;
432 436
433 LayoutUnit nextTop = nextRootBox()->selectionTop(); 437 LayoutUnit nextTop = nextRootBox()->selectionTop();
434 if (nextTop > selectionBottom && block().containsFloats()) { 438 if (nextTop > selectionBottom && block().containsFloats()) {
435 // The next line has actually been moved further over, probably from a large line-height, but possibly because the 439 // The next line has actually been moved further over, probably from a large
436 // line was forced to clear floats. If so, let's check the offsets, and onl y be willing to use the next 440 // line-height, but possibly because the line was forced to clear floats.
441 // If so, let's check the offsets, and only be willing to use the next
437 // line's top if the offsets are greater on both sides. 442 // line's top if the offsets are greater on both sides.
438 LayoutUnit nextLeft = 443 LayoutUnit nextLeft =
439 block().logicalLeftOffsetForLine(nextTop, DoNotIndentText); 444 block().logicalLeftOffsetForLine(nextTop, DoNotIndentText);
440 LayoutUnit nextRight = 445 LayoutUnit nextRight =
441 block().logicalRightOffsetForLine(nextTop, DoNotIndentText); 446 block().logicalRightOffsetForLine(nextTop, DoNotIndentText);
442 LayoutUnit newLeft = 447 LayoutUnit newLeft =
443 block().logicalLeftOffsetForLine(selectionBottom, DoNotIndentText); 448 block().logicalLeftOffsetForLine(selectionBottom, DoNotIndentText);
444 LayoutUnit newRight = 449 LayoutUnit newRight =
445 block().logicalRightOffsetForLine(selectionBottom, DoNotIndentText); 450 block().logicalRightOffsetForLine(selectionBottom, DoNotIndentText);
446 if (nextLeft > newLeft || nextRight < newRight) 451 if (nextLeft > newLeft || nextRight < newRight)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 493 }
489 494
490 if (firstLeaf == lastLeaf && 495 if (firstLeaf == lastLeaf &&
491 (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) 496 (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
492 return firstLeaf; 497 return firstLeaf;
493 498
494 // Avoid returning a list marker when possible. 499 // Avoid returning a list marker when possible.
495 if (leftPosition <= firstLeaf->logicalLeft() && 500 if (leftPosition <= firstLeaf->logicalLeft() &&
496 !firstLeaf->getLineLayoutItem().isListMarker() && 501 !firstLeaf->getLineLayoutItem().isListMarker() &&
497 (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) { 502 (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) {
498 // The leftPosition coordinate is less or equal to left edge of the firstLea f. 503 // The leftPosition coordinate is less or equal to left edge of the
499 // Return it. 504 // firstLeaf. Return it.
500 return firstLeaf; 505 return firstLeaf;
501 } 506 }
502 507
503 if (leftPosition >= lastLeaf->logicalRight() && 508 if (leftPosition >= lastLeaf->logicalRight() &&
504 !lastLeaf->getLineLayoutItem().isListMarker() && 509 !lastLeaf->getLineLayoutItem().isListMarker() &&
505 (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { 510 (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) {
506 // The leftPosition coordinate is greater or equal to right edge of the last Leaf. 511 // The leftPosition coordinate is greater or equal to right edge of the
507 // Return it. 512 // lastLeaf. Return it.
508 return lastLeaf; 513 return lastLeaf;
509 } 514 }
510 515
511 InlineBox* closestLeaf = nullptr; 516 InlineBox* closestLeaf = nullptr;
512 for (InlineBox* leaf = firstLeaf; leaf; 517 for (InlineBox* leaf = firstLeaf; leaf;
513 leaf = leaf->nextLeafChildIgnoringLineBreak()) { 518 leaf = leaf->nextLeafChildIgnoringLineBreak()) {
514 if (!leaf->getLineLayoutItem().isListMarker() && 519 if (!leaf->getLineLayoutItem().isListMarker() &&
515 (!onlyEditableLeaves || isEditableLeaf(leaf))) { 520 (!onlyEditableLeaves || isEditableLeaf(leaf))) {
516 closestLeaf = leaf; 521 closestLeaf = leaf;
517 if (leftPosition < leaf->logicalRight()) { 522 if (leftPosition < leaf->logicalRight()) {
(...skipping 13 matching lines...) Expand all
531 static_cast<WTF::Unicode::CharDirection>(m_lineBreakBidiStatusLastStrong), 536 static_cast<WTF::Unicode::CharDirection>(m_lineBreakBidiStatusLastStrong),
532 static_cast<WTF::Unicode::CharDirection>(m_lineBreakBidiStatusLast), 537 static_cast<WTF::Unicode::CharDirection>(m_lineBreakBidiStatusLast),
533 m_lineBreakContext); 538 m_lineBreakContext);
534 } 539 }
535 540
536 void RootInlineBox::setLineBreakInfo(LineLayoutItem obj, 541 void RootInlineBox::setLineBreakInfo(LineLayoutItem obj,
537 unsigned breakPos, 542 unsigned breakPos,
538 const BidiStatus& status) { 543 const BidiStatus& status) {
539 // When setting lineBreakObj, the LayoutObject must not be a LayoutInline 544 // When setting lineBreakObj, the LayoutObject must not be a LayoutInline
540 // with no line boxes, otherwise all sorts of invariants are broken later. 545 // with no line boxes, otherwise all sorts of invariants are broken later.
541 // This has security implications because if the LayoutObject does not 546 // This has security implications because if the LayoutObject does not point
542 // point to at least one line box, then that LayoutInline can be deleted 547 // to at least one line box, then that LayoutInline can be deleted later
543 // later without resetting the lineBreakObj, leading to use-after-free. 548 // without resetting the lineBreakObj, leading to use-after-free.
544 ASSERT_WITH_SECURITY_IMPLICATION(!obj || obj.isText() || 549 ASSERT_WITH_SECURITY_IMPLICATION(!obj || obj.isText() ||
545 !(obj.isLayoutInline() && obj.isBox() && 550 !(obj.isLayoutInline() && obj.isBox() &&
546 !LineLayoutBox(obj).inlineBoxWrapper())); 551 !LineLayoutBox(obj).inlineBoxWrapper()));
547 552
548 m_lineBreakObj = obj; 553 m_lineBreakObj = obj;
549 m_lineBreakPos = breakPos; 554 m_lineBreakPos = breakPos;
550 m_lineBreakBidiStatusEor = status.eor; 555 m_lineBreakBidiStatusEor = status.eor;
551 m_lineBreakBidiStatusLastStrong = status.lastStrong; 556 m_lineBreakBidiStatusLastStrong = status.lastStrong;
552 m_lineBreakBidiStatusLast = status.last; 557 m_lineBreakBidiStatusLast = status.last;
553 m_lineBreakContext = status.context; 558 m_lineBreakContext = status.context;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 674 }
670 } 675 }
671 676
672 // If leading is included for the box, then we compute that box. 677 // If leading is included for the box, then we compute that box.
673 if (includeLeading && !setUsedFontWithLeading) { 678 if (includeLeading && !setUsedFontWithLeading) {
674 int ascentWithLeading = box->baselinePosition(baselineType()); 679 int ascentWithLeading = box->baselinePosition(baselineType());
675 int descentWithLeading = (box->lineHeight() - ascentWithLeading).toInt(); 680 int descentWithLeading = (box->lineHeight() - ascentWithLeading).toInt();
676 setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeading, 681 setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeading,
677 ascentDescentSet); 682 ascentDescentSet);
678 683
679 // Examine the font box for inline flows and text boxes to see if any part o f it is above the baseline. 684 // Examine the font box for inline flows and text boxes to see if any part
680 // If the top of our font box relative to the root box baseline is above the root box baseline, then 685 // of it is above the baseline. If the top of our font box relative to the
681 // we are contributing to the maxAscent value. Descent is similar. If any pa rt of our font box is below 686 // root box baseline is above the root box baseline, then we are
682 // the root box's baseline, then we contribute to the maxDescent value. 687 // contributing to the maxAscent value. Descent is similar. If any part of
688 // our font box is below the root box's baseline, then we contribute to the
689 // maxDescent value.
683 affectsAscent = ascentWithLeading - box->logicalTop() > 0; 690 affectsAscent = ascentWithLeading - box->logicalTop() > 0;
684 affectsDescent = descentWithLeading + box->logicalTop() > 0; 691 affectsDescent = descentWithLeading + box->logicalTop() > 0;
685 } 692 }
686 } 693 }
687 694
688 LayoutUnit RootInlineBox::verticalPositionForBox( 695 LayoutUnit RootInlineBox::verticalPositionForBox(
689 InlineBox* box, 696 InlineBox* box,
690 VerticalPositionCache& verticalPositionCache) { 697 VerticalPositionCache& verticalPositionCache) {
691 if (box->getLineLayoutItem().isText()) 698 if (box->getLineLayoutItem().isText())
692 return box->parent()->logicalTop(); 699 return box->parent()->logicalTop();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 boxModel.baselinePosition(baselineType(), firstLine, lineDirection) - 745 boxModel.baselinePosition(baselineType(), firstLine, lineDirection) -
739 fontMetrics.ascent(baselineType()); 746 fontMetrics.ascent(baselineType());
740 } else if (verticalAlign == VerticalAlignMiddle) { 747 } else if (verticalAlign == VerticalAlignMiddle) {
741 verticalPosition = LayoutUnit( 748 verticalPosition = LayoutUnit(
742 (verticalPosition - LayoutUnit(fontMetrics.xHeight() / 2) - 749 (verticalPosition - LayoutUnit(fontMetrics.xHeight() / 2) -
743 boxModel.lineHeight(firstLine, lineDirection) / 2 + 750 boxModel.lineHeight(firstLine, lineDirection) / 2 +
744 boxModel.baselinePosition(baselineType(), firstLine, lineDirection)) 751 boxModel.baselinePosition(baselineType(), firstLine, lineDirection))
745 .round()); 752 .round());
746 } else if (verticalAlign == VerticalAlignTextBottom) { 753 } else if (verticalAlign == VerticalAlignTextBottom) {
747 verticalPosition += fontMetrics.descent(baselineType()); 754 verticalPosition += fontMetrics.descent(baselineType());
748 // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case. 755 // lineHeight - baselinePosition is always 0 for replaced elements (except
756 // inline blocks), so don't bother wasting time in that case.
749 if (!boxModel.isAtomicInlineLevel() || 757 if (!boxModel.isAtomicInlineLevel() ||
750 boxModel.isInlineBlockOrInlineTable()) 758 boxModel.isInlineBlockOrInlineTable())
751 verticalPosition -= (boxModel.lineHeight(firstLine, lineDirection) - 759 verticalPosition -= (boxModel.lineHeight(firstLine, lineDirection) -
752 boxModel.baselinePosition( 760 boxModel.baselinePosition(
753 baselineType(), firstLine, lineDirection)); 761 baselineType(), firstLine, lineDirection));
754 } else if (verticalAlign == VerticalAlignBaselineMiddle) { 762 } else if (verticalAlign == VerticalAlignBaselineMiddle) {
755 verticalPosition += 763 verticalPosition +=
756 -boxModel.lineHeight(firstLine, lineDirection) / 2 + 764 -boxModel.lineHeight(firstLine, lineDirection) / 2 +
757 boxModel.baselinePosition(baselineType(), firstLine, lineDirection); 765 boxModel.baselinePosition(baselineType(), firstLine, lineDirection);
758 } else if (verticalAlign == VerticalAlignLength) { 766 } else if (verticalAlign == VerticalAlignLength) {
759 LayoutUnit lineHeight; 767 LayoutUnit lineHeight;
760 // Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Pe rcentages: refer to the 'line-height' of the element itself'. 768 // Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align:
769 // 'Percentages: refer to the 'line-height' of the element itself'.
761 if (boxModel.style()->getVerticalAlignLength().isPercentOrCalc()) 770 if (boxModel.style()->getVerticalAlignLength().isPercentOrCalc())
762 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight()); 771 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight());
763 else 772 else
764 lineHeight = boxModel.lineHeight(firstLine, lineDirection); 773 lineHeight = boxModel.lineHeight(firstLine, lineDirection);
765 verticalPosition -= valueForLength( 774 verticalPosition -= valueForLength(
766 boxModel.style()->getVerticalAlignLength(), lineHeight); 775 boxModel.style()->getVerticalAlignLength(), lineHeight);
767 } 776 }
768 } 777 }
769 778
770 // Store the cached value. 779 // Store the cached value.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 813 }
805 endBox = nullptr; 814 endBox = nullptr;
806 return nullptr; 815 return nullptr;
807 } 816 }
808 817
809 const char* RootInlineBox::boxName() const { 818 const char* RootInlineBox::boxName() const {
810 return "RootInlineBox"; 819 return "RootInlineBox";
811 } 820 }
812 821
813 } // namespace blink 822 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698