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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // FIXME: need to figure out how to make this return a valid rect, note
that | 238 // FIXME: need to figure out how to make this return a valid rect, note
that |
239 // there are no line boxes created in the above case. | 239 // there are no line boxes created in the above case. |
240 return LayoutRect(); | 240 return LayoutRect(); |
241 } | 241 } |
242 | 242 |
243 ASSERT_UNUSED(inlineBox, !inlineBox); | 243 ASSERT_UNUSED(inlineBox, !inlineBox); |
244 | 244 |
245 if (extraWidthToEndOfLine) | 245 if (extraWidthToEndOfLine) |
246 *extraWidthToEndOfLine = LayoutUnit(); | 246 *extraWidthToEndOfLine = LayoutUnit(); |
247 | 247 |
248 LayoutRect caretRect = localCaretRectForEmptyElement(borderAndPaddingWidth()
, 0); | 248 LayoutRect caretRect = localCaretRectForEmptyElement(borderAndPaddingWidth()
, LayoutUnit()); |
249 | 249 |
250 if (InlineBox* firstBox = firstLineBox()) { | 250 if (InlineBox* firstBox = firstLineBox()) { |
251 // FIXME: the call to roundedLayoutPoint() below is temporary and should
be removed once | 251 // FIXME: the call to roundedLayoutPoint() below is temporary and should
be removed once |
252 // the transition to LayoutUnit-based types is complete (crbug.com/32123
7) | 252 // the transition to LayoutUnit-based types is complete (crbug.com/32123
7) |
253 caretRect.moveBy(firstBox->topLeft()); | 253 caretRect.moveBy(firstBox->topLeft()); |
254 } | 254 } |
255 | 255 |
256 return caretRect; | 256 return caretRect; |
257 } | 257 } |
258 | 258 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 for (LayoutObject* curr = firstChild(); curr; curr = curr->nextSibling()) { | 555 for (LayoutObject* curr = firstChild(); curr; curr = curr->nextSibling()) { |
556 if (curr->isFloatingOrOutOfFlowPositioned()) | 556 if (curr->isFloatingOrOutOfFlowPositioned()) |
557 continue; | 557 continue; |
558 | 558 |
559 // We want to get the margin box in the inline direction, and then use o
ur font ascent/descent in the block | 559 // We want to get the margin box in the inline direction, and then use o
ur font ascent/descent in the block |
560 // direction (aligned to the root box's baseline). | 560 // direction (aligned to the root box's baseline). |
561 if (curr->isBox()) { | 561 if (curr->isBox()) { |
562 LayoutBox* currBox = toLayoutBox(curr); | 562 LayoutBox* currBox = toLayoutBox(curr); |
563 if (currBox->inlineBoxWrapper()) { | 563 if (currBox->inlineBoxWrapper()) { |
564 RootInlineBox& rootBox = currBox->inlineBoxWrapper()->root(); | 564 RootInlineBox& rootBox = currBox->inlineBoxWrapper()->root(); |
565 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutItem(
).style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->
style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); | 565 LayoutUnit logicalTop = rootBox.logicalTop() + (rootBox.lineLayo
utItem().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - cont
ainer->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); |
566 int logicalHeight = container->style(rootBox.isFirstLineStyle())
->font().fontMetrics().height(); | 566 LayoutUnit logicalHeight(container->style(rootBox.isFirstLineSty
le())->font().fontMetrics().height()); |
567 if (isHorizontal) { | 567 if (isHorizontal) { |
568 yield(LayoutRect(LayoutUnit(currBox->inlineBoxWrapper()->x()
- currBox->marginLeft()), LayoutUnit(logicalTop), | 568 yield(LayoutRect(LayoutUnit(currBox->inlineBoxWrapper()->x()
- currBox->marginLeft()), LayoutUnit(logicalTop), |
569 LayoutUnit(currBox->size().width() + currBox->marginWidt
h()), LayoutUnit(logicalHeight))); | 569 LayoutUnit(currBox->size().width() + currBox->marginWidt
h()), LayoutUnit(logicalHeight))); |
570 } else { | 570 } else { |
571 yield(LayoutRect(LayoutUnit(logicalTop), LayoutUnit(currBox-
>inlineBoxWrapper()->y() - currBox->marginTop()), | 571 yield(LayoutRect(LayoutUnit(logicalTop), LayoutUnit(currBox-
>inlineBoxWrapper()->y() - currBox->marginTop()), |
572 LayoutUnit(logicalHeight), currBox->size().height() + cu
rrBox->marginHeight())); | 572 LayoutUnit(logicalHeight), currBox->size().height() + cu
rrBox->marginHeight())); |
573 } | 573 } |
574 } | 574 } |
575 } else if (curr->isLayoutInline()) { | 575 } else if (curr->isLayoutInline()) { |
576 // If the child doesn't need line boxes either, then we can recur. | 576 // If the child doesn't need line boxes either, then we can recur. |
577 LayoutInline* currInline = toLayoutInline(curr); | 577 LayoutInline* currInline = toLayoutInline(curr); |
578 if (!currInline->alwaysCreateLineBoxes()) { | 578 if (!currInline->alwaysCreateLineBoxes()) { |
579 currInline->generateCulledLineBoxRects(yield, container); | 579 currInline->generateCulledLineBoxRects(yield, container); |
580 } else { | 580 } else { |
581 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil
dLine; childLine = childLine->nextLineBox()) { | 581 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil
dLine; childLine = childLine->nextLineBox()) { |
582 RootInlineBox& rootBox = childLine->root(); | 582 RootInlineBox& rootBox = childLine->root(); |
583 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutI
tem().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - contain
er->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); | 583 LayoutUnit logicalTop = rootBox.logicalTop() + (rootBox.line
LayoutItem().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() -
container->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); |
584 int logicalHeight = container->style(rootBox.isFirstLineStyl
e())->font().fontMetrics().height(); | 584 LayoutUnit logicalHeight(container->style(rootBox.isFirstLin
eStyle())->font().fontMetrics().height()); |
585 if (isHorizontal) { | 585 if (isHorizontal) { |
586 yield(LayoutRect(LayoutUnit(childLine->x() - childLine->
marginLogicalLeft()), | 586 yield(LayoutRect(LayoutUnit(childLine->x() - childLine->
marginLogicalLeft()), |
587 LayoutUnit(logicalTop), | 587 logicalTop, |
588 LayoutUnit(childLine->logicalWidth() + childLine->ma
rginLogicalLeft() + childLine->marginLogicalRight()), | 588 LayoutUnit(childLine->logicalWidth() + childLine->ma
rginLogicalLeft() + childLine->marginLogicalRight()), |
589 LayoutUnit(logicalHeight))); | 589 logicalHeight)); |
590 } else { | 590 } else { |
591 yield(LayoutRect(LayoutUnit(logicalTop), | 591 yield(LayoutRect(logicalTop, |
592 LayoutUnit(childLine->y() - childLine->marginLogical
Left()), | 592 LayoutUnit(childLine->y() - childLine->marginLogical
Left()), |
593 LayoutUnit(logicalHeight), | 593 logicalHeight, |
594 LayoutUnit(childLine->logicalWidth() + childLine->ma
rginLogicalLeft() + childLine->marginLogicalRight()))); | 594 LayoutUnit(childLine->logicalWidth() + childLine->ma
rginLogicalLeft() + childLine->marginLogicalRight()))); |
595 } | 595 } |
596 } | 596 } |
597 } | 597 } |
598 } else if (curr->isText()) { | 598 } else if (curr->isText()) { |
599 LayoutText* currText = toLayoutText(curr); | 599 LayoutText* currText = toLayoutText(curr); |
600 for (InlineTextBox* childText = currText->firstTextBox(); childText;
childText = childText->nextTextBox()) { | 600 for (InlineTextBox* childText = currText->firstTextBox(); childText;
childText = childText->nextTextBox()) { |
601 RootInlineBox& rootBox = childText->root(); | 601 RootInlineBox& rootBox = childText->root(); |
602 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutItem(
).style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->
style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); | 602 LayoutUnit logicalTop = LayoutUnit(rootBox.logicalTop() |
603 int logicalHeight = container->style(rootBox.isFirstLineStyle())
->font().fontMetrics().height(); | 603 + (rootBox.lineLayoutItem().style(rootBox.isFirstLineStyle()
)->font().fontMetrics().ascent() |
| 604 - container->style(rootBox.isFirstLineStyle())->font().fontM
etrics().ascent())); |
| 605 LayoutUnit logicalHeight(container->style(rootBox.isFirstLineSty
le())->font().fontMetrics().height()); |
604 if (isHorizontal) | 606 if (isHorizontal) |
605 yield(LayoutRect(childText->x(), logicalTop, childText->logi
calWidth(), logicalHeight)); | 607 yield(LayoutRect(childText->x(), logicalTop, childText->logi
calWidth(), logicalHeight)); |
606 else | 608 else |
607 yield(LayoutRect(logicalTop, childText->y(), logicalHeight,
childText->logicalWidth())); | 609 yield(LayoutRect(logicalTop, childText->y(), logicalHeight,
childText->logicalWidth())); |
608 } | 610 } |
609 } | 611 } |
610 } | 612 } |
611 } | 613 } |
612 | 614 |
613 namespace { | 615 namespace { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 LayoutPoint topLeft; | 702 LayoutPoint topLeft; |
701 if (InlineBox* firstBox = firstLineBoxIncludingCulling()) { | 703 if (InlineBox* firstBox = firstLineBoxIncludingCulling()) { |
702 topLeft = firstBox->topLeft(); | 704 topLeft = firstBox->topLeft(); |
703 } | 705 } |
704 return adjustedPositionRelativeToOffsetParent(topLeft).y(); | 706 return adjustedPositionRelativeToOffsetParent(topLeft).y(); |
705 } | 707 } |
706 | 708 |
707 static LayoutUnit computeMargin(const LayoutInline* layoutObject, const Length&
margin) | 709 static LayoutUnit computeMargin(const LayoutInline* layoutObject, const Length&
margin) |
708 { | 710 { |
709 if (margin.isFixed()) | 711 if (margin.isFixed()) |
710 return margin.value(); | 712 return LayoutUnit(margin.value()); |
711 if (margin.hasPercent()) | 713 if (margin.hasPercent()) |
712 return minimumValueForLength(margin, std::max(LayoutUnit(), layoutObject
->containingBlock()->availableLogicalWidth())); | 714 return minimumValueForLength(margin, std::max(LayoutUnit(), layoutObject
->containingBlock()->availableLogicalWidth())); |
713 return LayoutUnit(); | 715 return LayoutUnit(); |
714 } | 716 } |
715 | 717 |
716 LayoutRectOutsets LayoutInline::marginBoxOutsets() const | 718 LayoutRectOutsets LayoutInline::marginBoxOutsets() const |
717 { | 719 { |
718 return LayoutRectOutsets(marginTop(), marginRight(), marginBottom(), marginL
eft()); | 720 return LayoutRectOutsets(marginTop(), marginRight(), marginBottom(), marginL
eft()); |
719 } | 721 } |
720 | 722 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 if (overflowRect.isEmpty()) | 1057 if (overflowRect.isEmpty()) |
1056 return overflowRect; | 1058 return overflowRect; |
1057 | 1059 |
1058 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, overflowRect, pa
intInvalidationState); | 1060 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, overflowRect, pa
intInvalidationState); |
1059 return overflowRect; | 1061 return overflowRect; |
1060 } | 1062 } |
1061 | 1063 |
1062 LayoutRect LayoutInline::visualOverflowRect() const | 1064 LayoutRect LayoutInline::visualOverflowRect() const |
1063 { | 1065 { |
1064 LayoutRect overflowRect = linesVisualOverflowBoundingBox(); | 1066 LayoutRect overflowRect = linesVisualOverflowBoundingBox(); |
1065 LayoutUnit outlineOutset = style()->outlineOutsetExtent(); | 1067 LayoutUnit outlineOutset(style()->outlineOutsetExtent()); |
1066 if (outlineOutset) { | 1068 if (outlineOutset) { |
1067 Vector<LayoutRect> rects; | 1069 Vector<LayoutRect> rects; |
1068 // We have already included outline extents of line boxes in linesVisual
OverflowBoundingBox(), | 1070 // We have already included outline extents of line boxes in linesVisual
OverflowBoundingBox(), |
1069 // so the following just add outline rects for children and continuation
s. | 1071 // so the following just add outline rects for children and continuation
s. |
1070 addOutlineRectsForChildrenAndContinuations(rects, LayoutPoint(), outline
RectsShouldIncludeBlockVisualOverflow()); | 1072 addOutlineRectsForChildrenAndContinuations(rects, LayoutPoint(), outline
RectsShouldIncludeBlockVisualOverflow()); |
1071 if (!rects.isEmpty()) { | 1073 if (!rects.isEmpty()) { |
1072 LayoutRect outlineRect = unionRectEvenIfEmpty(rects); | 1074 LayoutRect outlineRect = unionRectEvenIfEmpty(rects); |
1073 outlineRect.inflate(outlineOutset); | 1075 outlineRect.inflate(outlineOutset); |
1074 overflowRect.unite(outlineRect); | 1076 overflowRect.unite(outlineRect); |
1075 } | 1077 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 InlineFlowBox* flowBox = createInlineFlowBox(); | 1287 InlineFlowBox* flowBox = createInlineFlowBox(); |
1286 m_lineBoxes.appendLineBox(flowBox); | 1288 m_lineBoxes.appendLineBox(flowBox); |
1287 return flowBox; | 1289 return flowBox; |
1288 } | 1290 } |
1289 | 1291 |
1290 LayoutUnit LayoutInline::lineHeight(bool firstLine, LineDirectionMode /*directio
n*/, LinePositionMode /*linePositionMode*/) const | 1292 LayoutUnit LayoutInline::lineHeight(bool firstLine, LineDirectionMode /*directio
n*/, LinePositionMode /*linePositionMode*/) const |
1291 { | 1293 { |
1292 if (firstLine && document().styleEngine().usesFirstLineRules()) { | 1294 if (firstLine && document().styleEngine().usesFirstLineRules()) { |
1293 const ComputedStyle* s = style(firstLine); | 1295 const ComputedStyle* s = style(firstLine); |
1294 if (s != style()) | 1296 if (s != style()) |
1295 return s->computedLineHeight(); | 1297 return LayoutUnit(s->computedLineHeight()); |
1296 } | 1298 } |
1297 | 1299 |
1298 return style()->computedLineHeight(); | 1300 return LayoutUnit(style()->computedLineHeight()); |
1299 } | 1301 } |
1300 | 1302 |
1301 int LayoutInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li
neDirectionMode direction, LinePositionMode linePositionMode) const | 1303 int LayoutInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li
neDirectionMode direction, LinePositionMode linePositionMode) const |
1302 { | 1304 { |
1303 ASSERT(linePositionMode == PositionOnContainingLine); | 1305 ASSERT(linePositionMode == PositionOnContainingLine); |
1304 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); | 1306 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); |
1305 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; | 1307 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; |
1306 } | 1308 } |
1307 | 1309 |
1308 LayoutSize LayoutInline::offsetForInFlowPositionedInline(const LayoutBox& child)
const | 1310 LayoutSize LayoutInline::offsetForInFlowPositionedInline(const LayoutBox& child)
const |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 | 1419 |
1418 AnnotatedRegionValue region; | 1420 AnnotatedRegionValue region; |
1419 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; | 1421 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; |
1420 region.bounds = LayoutRect(linesBoundingBox()); | 1422 region.bounds = LayoutRect(linesBoundingBox()); |
1421 | 1423 |
1422 LayoutObject* container = containingBlock(); | 1424 LayoutObject* container = containingBlock(); |
1423 if (!container) | 1425 if (!container) |
1424 container = this; | 1426 container = this; |
1425 | 1427 |
1426 FloatPoint absPos = container->localToAbsolute(); | 1428 FloatPoint absPos = container->localToAbsolute(); |
1427 region.bounds.setX(absPos.x() + region.bounds.x()); | 1429 region.bounds.setX(LayoutUnit(absPos.x() + region.bounds.x())); |
1428 region.bounds.setY(absPos.y() + region.bounds.y()); | 1430 region.bounds.setY(LayoutUnit(absPos.y() + region.bounds.y())); |
1429 | 1431 |
1430 regions.append(region); | 1432 regions.append(region); |
1431 } | 1433 } |
1432 | 1434 |
1433 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer, PaintInvalidationReason invalidationReason) const | 1435 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer, PaintInvalidationReason invalidationReason) const |
1434 { | 1436 { |
1435 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r, invalidationReason); | 1437 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r, invalidationReason); |
1436 | 1438 |
1437 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) | 1439 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) |
1438 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in
validationReason); | 1440 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in
validationReason); |
1439 } | 1441 } |
1440 | 1442 |
1441 } // namespace blink | 1443 } // namespace blink |
OLD | NEW |