| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 // just like a block. | 1430 // just like a block. |
| 1431 if (isAtomicInlineLevel() && linePositionMode == PositionOnContainingLine) | 1431 if (isAtomicInlineLevel() && linePositionMode == PositionOnContainingLine) |
| 1432 return LayoutBox::lineHeight(firstLine, direction, linePositionMode); | 1432 return LayoutBox::lineHeight(firstLine, direction, linePositionMode); |
| 1433 | 1433 |
| 1434 const ComputedStyle& style = styleRef(firstLine && document().styleEngine().
usesFirstLineRules()); | 1434 const ComputedStyle& style = styleRef(firstLine && document().styleEngine().
usesFirstLineRules()); |
| 1435 return LayoutUnit(style.computedLineHeight()); | 1435 return LayoutUnit(style.computedLineHeight()); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 int LayoutBlock::beforeMarginInLineDirection(LineDirectionMode direction) const | 1438 int LayoutBlock::beforeMarginInLineDirection(LineDirectionMode direction) const |
| 1439 { | 1439 { |
| 1440 return direction == HorizontalLine ? marginTop() : marginRight(); | 1440 return (direction == HorizontalLine ? marginTop() : marginRight()).toInt(); |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 int LayoutBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const | 1443 int LayoutBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const |
| 1444 { | 1444 { |
| 1445 // Inline blocks are replaced elements. Otherwise, just pass off to | 1445 // Inline blocks are replaced elements. Otherwise, just pass off to |
| 1446 // the base class. If we're being queried as though we're the root line | 1446 // the base class. If we're being queried as though we're the root line |
| 1447 // box, then the fact that we're an inline-block is irrelevant, and we behav
e | 1447 // box, then the fact that we're an inline-block is irrelevant, and we behav
e |
| 1448 // just like a block. | 1448 // just like a block. |
| 1449 if (isInline() && linePositionMode == PositionOnContainingLine) { | 1449 if (isInline() && linePositionMode == PositionOnContainingLine) { |
| 1450 // For "leaf" theme objects, let the theme decide what the baseline posi
tion is. | 1450 // For "leaf" theme objects, let the theme decide what the baseline posi
tion is. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1470 return beforeMarginInLineDirection(direction) + baselinePos; | 1470 return beforeMarginInLineDirection(direction) + baselinePos; |
| 1471 | 1471 |
| 1472 return LayoutBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); | 1472 return LayoutBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. | 1475 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. |
| 1476 // Note that inline-block counts as replaced here. | 1476 // Note that inline-block counts as replaced here. |
| 1477 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 1477 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); |
| 1478 | 1478 |
| 1479 const FontMetrics& fontMetrics = style(firstLine)->getFontMetrics(); | 1479 const FontMetrics& fontMetrics = style(firstLine)->getFontMetrics(); |
| 1480 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; | 1480 return (fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2).toInt(); |
| 1481 } | 1481 } |
| 1482 | 1482 |
| 1483 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU
nit replacedHeight) const | 1483 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU
nit replacedHeight) const |
| 1484 { | 1484 { |
| 1485 if (!document().inNoQuirksMode() && replacedHeight) | 1485 if (!document().inNoQuirksMode() && replacedHeight) |
| 1486 return replacedHeight; | 1486 return replacedHeight; |
| 1487 | 1487 |
| 1488 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; | 1488 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if
it should be moved | 1491 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if
it should be moved |
| 1492 // down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and LayoutGrid lack base
line calculation | 1492 // down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and LayoutGrid lack base
line calculation |
| 1493 // overrides, so the code is here just for them. Just walking the block children
in logical order | 1493 // overrides, so the code is here just for them. Just walking the block children
in logical order |
| 1494 // seems rather wrong for those two layout modes, though. | 1494 // seems rather wrong for those two layout modes, though. |
| 1495 | 1495 |
| 1496 int LayoutBlock::firstLineBoxBaseline() const | 1496 int LayoutBlock::firstLineBoxBaseline() const |
| 1497 { | 1497 { |
| 1498 ASSERT(!childrenInline()); | 1498 ASSERT(!childrenInline()); |
| 1499 if (isWritingModeRoot() && !isRubyRun()) | 1499 if (isWritingModeRoot() && !isRubyRun()) |
| 1500 return -1; | 1500 return -1; |
| 1501 | 1501 |
| 1502 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox())
{ | 1502 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox())
{ |
| 1503 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1503 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
| 1504 int result = curr->firstLineBoxBaseline(); | 1504 int result = curr->firstLineBoxBaseline(); |
| 1505 if (result != -1) | 1505 if (result != -1) |
| 1506 return curr->logicalTop() + result; // Translate to our coordina
te space. | 1506 return (curr->logicalTop() + result).toInt(); // Translate to ou
r coordinate space. |
| 1507 } | 1507 } |
| 1508 } | 1508 } |
| 1509 return -1; | 1509 return -1; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const | 1512 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const |
| 1513 { | 1513 { |
| 1514 ASSERT(!childrenInline()); | 1514 ASSERT(!childrenInline()); |
| 1515 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline
BlockBaseline()) || style()->containsSize()) { | 1515 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline
BlockBaseline()) || style()->containsSize()) { |
| 1516 // We are not calling LayoutBox::baselinePosition here because the calle
r should add the margin-top/margin-right, not us. | 1516 // We are not calling LayoutBox::baselinePosition here because the calle
r should add the margin-top/margin-right, not us. |
| 1517 return lineDirection == HorizontalLine ? size().height() + marginBottom(
) : size().width() + marginLeft(); | 1517 return (lineDirection == HorizontalLine ? size().height() + marginBottom
() : size().width() + marginLeft()).toInt(); |
| 1518 } | 1518 } |
| 1519 | 1519 |
| 1520 if (isWritingModeRoot() && !isRubyRun()) | 1520 if (isWritingModeRoot() && !isRubyRun()) |
| 1521 return -1; | 1521 return -1; |
| 1522 | 1522 |
| 1523 bool haveNormalFlowChild = false; | 1523 bool haveNormalFlowChild = false; |
| 1524 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox
()) { | 1524 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox
()) { |
| 1525 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1525 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
| 1526 haveNormalFlowChild = true; | 1526 haveNormalFlowChild = true; |
| 1527 int result = curr->inlineBlockBaseline(lineDirection); | 1527 int result = curr->inlineBlockBaseline(lineDirection); |
| 1528 if (result != -1) | 1528 if (result != -1) |
| 1529 return curr->logicalTop() + result; // Translate to our coordina
te space. | 1529 return (curr->logicalTop() + result).toInt(); // Translate to ou
r coordinate space. |
| 1530 } | 1530 } |
| 1531 } | 1531 } |
| 1532 if (!haveNormalFlowChild && hasLineIfEmpty()) { | 1532 if (!haveNormalFlowChild && hasLineIfEmpty()) { |
| 1533 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); | 1533 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); |
| 1534 return fontMetrics.ascent() | 1534 return (fontMetrics.ascent() |
| 1535 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 | 1535 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 |
| 1536 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight()); | 1536 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight())).toInt(); |
| 1537 } | 1537 } |
| 1538 return -1; | 1538 return -1; |
| 1539 } | 1539 } |
| 1540 | 1540 |
| 1541 const LayoutBlock* LayoutBlock::enclosingFirstLineStyleBlock() const | 1541 const LayoutBlock* LayoutBlock::enclosingFirstLineStyleBlock() const |
| 1542 { | 1542 { |
| 1543 const LayoutBlock* firstLineBlock = this; | 1543 const LayoutBlock* firstLineBlock = this; |
| 1544 bool hasPseudo = false; | 1544 bool hasPseudo = false; |
| 1545 while (true) { | 1545 while (true) { |
| 1546 hasPseudo = firstLineBlock->style()->hasPseudoStyle(PseudoIdFirstLine); | 1546 hasPseudo = firstLineBlock->style()->hasPseudoStyle(PseudoIdFirstLine); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda
ntSet->begin(); it != end; ++it) { | 1870 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda
ntSet->begin(); it != end; ++it) { |
| 1871 LayoutBox* currBox = *it; | 1871 LayoutBox* currBox = *it; |
| 1872 ASSERT(!currBox->needsLayout()); | 1872 ASSERT(!currBox->needsLayout()); |
| 1873 } | 1873 } |
| 1874 } | 1874 } |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 #endif | 1877 #endif |
| 1878 | 1878 |
| 1879 } // namespace blink | 1879 } // namespace blink |
| OLD | NEW |