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

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

Issue 1647313003: Continue converting to explicit LayoutUnit constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicitContstructors
Patch Set: Created 4 years, 10 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) 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // i.e. the VisiblePosition is: 236 // i.e. the VisiblePosition is:
237 // <LayoutInline editingBoundary=true>|<LayoutText> </LayoutText></Lay outInline> 237 // <LayoutInline editingBoundary=true>|<LayoutText> </LayoutText></Lay outInline>
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 = 0; 246 *extraWidthToEndOfLine = LayoutUnit();
247 247
248 LayoutRect caretRect = localCaretRectForEmptyElement(borderAndPaddingWidth() , 0); 248 LayoutRect caretRect = localCaretRectForEmptyElement(borderAndPaddingWidth() , 0);
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;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutItem( ).style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container-> style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
566 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height(); 566 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height();
567 if (isHorizontal) 567 if (isHorizontal) {
568 yield(LayoutRect(currBox->inlineBoxWrapper()->x() - currBox- >marginLeft(), logicalTop, currBox->size().width() + currBox->marginWidth(), log icalHeight)); 568 yield(LayoutRect(LayoutUnit(currBox->inlineBoxWrapper()->x() - currBox->marginLeft()), LayoutUnit(logicalTop),
569 else 569 LayoutUnit(currBox->size().width() + currBox->marginWidt h()), LayoutUnit(logicalHeight)));
570 yield(LayoutRect(logicalTop, currBox->inlineBoxWrapper()->y( ) - currBox->marginTop(), logicalHeight, currBox->size().height() + currBox->mar ginHeight())); 570 } else {
571 yield(LayoutRect(LayoutUnit(logicalTop), LayoutUnit(currBox- >inlineBoxWrapper()->y() - currBox->marginTop()),
572 LayoutUnit(logicalHeight), currBox->size().height() + cu rrBox->marginHeight()));
573 }
571 } 574 }
572 } else if (curr->isLayoutInline()) { 575 } else if (curr->isLayoutInline()) {
573 // 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.
574 LayoutInline* currInline = toLayoutInline(curr); 577 LayoutInline* currInline = toLayoutInline(curr);
575 if (!currInline->alwaysCreateLineBoxes()) { 578 if (!currInline->alwaysCreateLineBoxes()) {
576 currInline->generateCulledLineBoxRects(yield, container); 579 currInline->generateCulledLineBoxRects(yield, container);
577 } else { 580 } else {
578 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil dLine; childLine = childLine->nextLineBox()) { 581 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil dLine; childLine = childLine->nextLineBox()) {
579 RootInlineBox& rootBox = childLine->root(); 582 RootInlineBox& rootBox = childLine->root();
580 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutI tem().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - contain er->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); 583 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutI tem().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - contain er->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
581 int logicalHeight = container->style(rootBox.isFirstLineStyl e())->font().fontMetrics().height(); 584 int logicalHeight = container->style(rootBox.isFirstLineStyl e())->font().fontMetrics().height();
582 if (isHorizontal) { 585 if (isHorizontal) {
583 yield(LayoutRect(childLine->x() - childLine->marginLogic alLeft(), 586 yield(LayoutRect(LayoutUnit(childLine->x() - childLine-> marginLogicalLeft()),
584 logicalTop, 587 LayoutUnit(logicalTop),
585 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight(), 588 LayoutUnit(childLine->logicalWidth() + childLine->ma rginLogicalLeft() + childLine->marginLogicalRight()),
586 logicalHeight)); 589 LayoutUnit(logicalHeight)));
587 } else { 590 } else {
588 yield(LayoutRect(logicalTop, 591 yield(LayoutRect(LayoutUnit(logicalTop),
589 childLine->y() - childLine->marginLogicalLeft(), 592 LayoutUnit(childLine->y() - childLine->marginLogical Left()),
590 logicalHeight, 593 LayoutUnit(logicalHeight),
591 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight())); 594 LayoutUnit(childLine->logicalWidth() + childLine->ma rginLogicalLeft() + childLine->marginLogicalRight())));
592 } 595 }
593 } 596 }
594 } 597 }
595 } else if (curr->isText()) { 598 } else if (curr->isText()) {
596 LayoutText* currText = toLayoutText(curr); 599 LayoutText* currText = toLayoutText(curr);
597 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) { 600 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) {
598 RootInlineBox& rootBox = childText->root(); 601 RootInlineBox& rootBox = childText->root();
599 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutItem( ).style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container-> style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); 602 int logicalTop = rootBox.logicalTop() + (rootBox.lineLayoutItem( ).style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container-> style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
600 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height(); 603 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height();
601 if (isHorizontal) 604 if (isHorizontal)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 875 }
873 876
874 IntRect result; 877 IntRect result;
875 878
876 // See <rdar://problem/5289721>, for an unknown reason the linked list here is sometimes inconsistent, first is non-zero and last is zero. We have been 879 // See <rdar://problem/5289721>, for an unknown reason the linked list here is sometimes inconsistent, first is non-zero and last is zero. We have been
877 // unable to reproduce this at all (and consequently unable to figure ot why this is happening). The assert will hopefully catch the problem in debug 880 // unable to reproduce this at all (and consequently unable to figure ot why this is happening). The assert will hopefully catch the problem in debug
878 // builds and help us someday figure out why. We also put in a redundant ch eck of lastLineBox() to avoid the crash for now. 881 // builds and help us someday figure out why. We also put in a redundant ch eck of lastLineBox() to avoid the crash for now.
879 ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both e xist. 882 ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both e xist.
880 if (firstLineBox() && lastLineBox()) { 883 if (firstLineBox() && lastLineBox()) {
881 // Return the width of the minimal left side and the maximal right side. 884 // Return the width of the minimal left side and the maximal right side.
882 LayoutUnit logicalLeftSide = 0; 885 LayoutUnit logicalLeftSide;
883 LayoutUnit logicalRightSide = 0; 886 LayoutUnit logicalRightSide;
884 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBo x()) { 887 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBo x()) {
885 if (curr == firstLineBox() || curr->logicalLeft() < logicalLeftSide) 888 if (curr == firstLineBox() || curr->logicalLeft() < logicalLeftSide)
886 logicalLeftSide = curr->logicalLeft(); 889 logicalLeftSide = curr->logicalLeft();
887 if (curr == firstLineBox() || curr->logicalRight() > logicalRightSid e) 890 if (curr == firstLineBox() || curr->logicalRight() > logicalRightSid e)
888 logicalRightSide = curr->logicalRight(); 891 logicalRightSide = curr->logicalRight();
889 } 892 }
890 893
891 bool isHorizontal = style()->isHorizontalWritingMode(); 894 bool isHorizontal = style()->isHorizontalWritingMode();
892 895
893 LayoutUnit x = isHorizontal ? logicalLeftSide : firstLineBox()->x(); 896 LayoutUnit x = isHorizontal ? logicalLeftSide : firstLineBox()->x();
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 1436
1434 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer, PaintInvalidationReason invalidationReason) const 1437 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer, PaintInvalidationReason invalidationReason) const
1435 { 1438 {
1436 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r, invalidationReason); 1439 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r, invalidationReason);
1437 1440
1438 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 1441 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
1439 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason); 1442 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason);
1440 } 1443 }
1441 1444
1442 } // namespace blink 1445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698