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

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: Add TODO 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } 871 }
869 872
870 IntRect result; 873 IntRect result;
871 874
872 // 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 875 // 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
873 // 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 876 // 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
874 // builds and help us someday figure out why. We also put in a redundant ch eck of lastLineBox() to avoid the crash for now. 877 // builds and help us someday figure out why. We also put in a redundant ch eck of lastLineBox() to avoid the crash for now.
875 ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both e xist. 878 ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both e xist.
876 if (firstLineBox() && lastLineBox()) { 879 if (firstLineBox() && lastLineBox()) {
877 // Return the width of the minimal left side and the maximal right side. 880 // Return the width of the minimal left side and the maximal right side.
878 LayoutUnit logicalLeftSide = 0; 881 LayoutUnit logicalLeftSide;
879 LayoutUnit logicalRightSide = 0; 882 LayoutUnit logicalRightSide;
880 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBo x()) { 883 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBo x()) {
881 if (curr == firstLineBox() || curr->logicalLeft() < logicalLeftSide) 884 if (curr == firstLineBox() || curr->logicalLeft() < logicalLeftSide)
882 logicalLeftSide = curr->logicalLeft(); 885 logicalLeftSide = curr->logicalLeft();
883 if (curr == firstLineBox() || curr->logicalRight() > logicalRightSid e) 886 if (curr == firstLineBox() || curr->logicalRight() > logicalRightSid e)
884 logicalRightSide = curr->logicalRight(); 887 logicalRightSide = curr->logicalRight();
885 } 888 }
886 889
887 bool isHorizontal = style()->isHorizontalWritingMode(); 890 bool isHorizontal = style()->isHorizontalWritingMode();
888 891
889 LayoutUnit x = isHorizontal ? logicalLeftSide : firstLineBox()->x(); 892 LayoutUnit x = isHorizontal ? logicalLeftSide : firstLineBox()->x();
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1432
1430 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer, PaintInvalidationReason invalidationReason) const 1433 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer, PaintInvalidationReason invalidationReason) const
1431 { 1434 {
1432 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r, invalidationReason); 1435 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r, invalidationReason);
1433 1436
1434 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 1437 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
1435 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason); 1438 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason);
1436 } 1439 }
1437 1440
1438 } // namespace blink 1441 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutInline.h ('k') | third_party/WebKit/Source/core/layout/LayoutListMarker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698