| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 break; | 2480 break; |
| 2481 } | 2481 } |
| 2482 return count; | 2482 return count; |
| 2483 } | 2483 } |
| 2484 | 2484 |
| 2485 int LayoutBlockFlow::firstLineBoxBaseline() const { | 2485 int LayoutBlockFlow::firstLineBoxBaseline() const { |
| 2486 if (isWritingModeRoot() && !isRubyRun()) | 2486 if (isWritingModeRoot() && !isRubyRun()) |
| 2487 return -1; | 2487 return -1; |
| 2488 if (!childrenInline()) | 2488 if (!childrenInline()) |
| 2489 return LayoutBlock::firstLineBoxBaseline(); | 2489 return LayoutBlock::firstLineBoxBaseline(); |
| 2490 if (firstLineBox()) | 2490 if (firstLineBox()) { |
| 2491 const SimpleFontData* fontData = style(true)->font().primaryFont(); |
| 2492 DCHECK(fontData); |
| 2493 if (!fontData) |
| 2494 return -1; |
| 2491 return (firstLineBox()->logicalTop() + | 2495 return (firstLineBox()->logicalTop() + |
| 2492 style(true)->getFontMetrics().ascent( | 2496 fontData->getFontMetrics().ascent(firstRootBox()->baselineType())) |
| 2493 firstRootBox()->baselineType())) | |
| 2494 .toInt(); | 2497 .toInt(); |
| 2498 } |
| 2495 return -1; | 2499 return -1; |
| 2496 } | 2500 } |
| 2497 | 2501 |
| 2498 int LayoutBlockFlow::inlineBlockBaseline( | 2502 int LayoutBlockFlow::inlineBlockBaseline( |
| 2499 LineDirectionMode lineDirection) const { | 2503 LineDirectionMode lineDirection) const { |
| 2500 // CSS2.1 states that the baseline of an 'inline-block' is: | 2504 // CSS2.1 states that the baseline of an 'inline-block' is: |
| 2501 // the baseline of the last line box in the normal flow, unless it has | 2505 // the baseline of the last line box in the normal flow, unless it has |
| 2502 // either no in-flow line boxes or if its 'overflow' property has a computed | 2506 // either no in-flow line boxes or if its 'overflow' property has a computed |
| 2503 // value other than 'visible', in which case the baseline is the bottom | 2507 // value other than 'visible', in which case the baseline is the bottom |
| 2504 // margin edge. | 2508 // margin edge. |
| 2505 // We likewise avoid using the last line box in the case of size containment, | 2509 // We likewise avoid using the last line box in the case of size containment, |
| 2506 // where the block's contents shouldn't be considered when laying out its | 2510 // where the block's contents shouldn't be considered when laying out its |
| 2507 // ancestors or siblings. | 2511 // ancestors or siblings. |
| 2508 | 2512 |
| 2509 if ((!style()->isOverflowVisible() && | 2513 if ((!style()->isOverflowVisible() && |
| 2510 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || | 2514 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || |
| 2511 style()->containsSize()) { | 2515 style()->containsSize()) { |
| 2512 // We are not calling baselinePosition here because the caller should add | 2516 // We are not calling baselinePosition here because the caller should add |
| 2513 // the margin-top/margin-right, not us. | 2517 // the margin-top/margin-right, not us. |
| 2514 return (lineDirection == HorizontalLine ? size().height() + marginBottom() | 2518 return (lineDirection == HorizontalLine ? size().height() + marginBottom() |
| 2515 : size().width() + marginLeft()) | 2519 : size().width() + marginLeft()) |
| 2516 .toInt(); | 2520 .toInt(); |
| 2517 } | 2521 } |
| 2518 if (isWritingModeRoot() && !isRubyRun()) | 2522 if (isWritingModeRoot() && !isRubyRun()) |
| 2519 return -1; | 2523 return -1; |
| 2520 if (!childrenInline()) | 2524 if (!childrenInline()) |
| 2521 return LayoutBlock::inlineBlockBaseline(lineDirection); | 2525 return LayoutBlock::inlineBlockBaseline(lineDirection); |
| 2522 if (lastLineBox()) | 2526 if (lastLineBox()) { |
| 2527 const SimpleFontData* fontData = |
| 2528 style(lastLineBox() == firstLineBox())->font().primaryFont(); |
| 2529 DCHECK(fontData); |
| 2530 if (!fontData) |
| 2531 return -1; |
| 2523 return (lastLineBox()->logicalTop() + | 2532 return (lastLineBox()->logicalTop() + |
| 2524 style(lastLineBox() == firstLineBox()) | 2533 fontData->getFontMetrics().ascent(lastRootBox()->baselineType())) |
| 2525 ->getFontMetrics() | |
| 2526 .ascent(lastRootBox()->baselineType())) | |
| 2527 .toInt(); | 2534 .toInt(); |
| 2535 } |
| 2528 if (!hasLineIfEmpty()) | 2536 if (!hasLineIfEmpty()) |
| 2529 return -1; | 2537 return -1; |
| 2530 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); | 2538 |
| 2539 const SimpleFontData* fontData = firstLineStyle()->font().primaryFont(); |
| 2540 DCHECK(fontData); |
| 2541 if (!fontData) |
| 2542 return -1; |
| 2543 |
| 2544 const FontMetrics& fontMetrics = fontData->getFontMetrics(); |
| 2531 return (fontMetrics.ascent() + | 2545 return (fontMetrics.ascent() + |
| 2532 (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - | 2546 (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - |
| 2533 fontMetrics.height()) / | 2547 fontMetrics.height()) / |
| 2534 2 + | 2548 2 + |
| 2535 (lineDirection == HorizontalLine ? borderTop() + paddingTop() | 2549 (lineDirection == HorizontalLine ? borderTop() + paddingTop() |
| 2536 : borderRight() + paddingRight())) | 2550 : borderRight() + paddingRight())) |
| 2537 .toInt(); | 2551 .toInt(); |
| 2538 } | 2552 } |
| 2539 | 2553 |
| 2540 void LayoutBlockFlow::removeFloatingObjectsFromDescendants() { | 2554 void LayoutBlockFlow::removeFloatingObjectsFromDescendants() { |
| (...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4534 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 4521 } | 4535 } |
| 4522 | 4536 |
| 4523 void LayoutBlockFlow::invalidateDisplayItemClients( | 4537 void LayoutBlockFlow::invalidateDisplayItemClients( |
| 4524 PaintInvalidationReason invalidationReason) const { | 4538 PaintInvalidationReason invalidationReason) const { |
| 4525 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4539 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
| 4526 invalidationReason); | 4540 invalidationReason); |
| 4527 } | 4541 } |
| 4528 | 4542 |
| 4529 } // namespace blink | 4543 } // namespace blink |
| OLD | NEW |