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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 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 * This file is part of the layout object implementation for KHTML. 2 * This file is part of the layout object implementation for KHTML.
3 * 3 *
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * Copyright (C) 2003 Apple Computer, Inc. 6 * Copyright (C) 2003 Apple Computer, Inc.
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return !blockFlow->isFloatingOrOutOfFlowPositioned() && blockFlow->style()-> height().isAuto(); 128 return !blockFlow->isFloatingOrOutOfFlowPositioned() && blockFlow->style()-> height().isAuto();
129 } 129 }
130 130
131 static int getHeightForLineCount(const LayoutBlockFlow* blockFlow, int lineCount , bool includeBottom, int& count) 131 static int getHeightForLineCount(const LayoutBlockFlow* blockFlow, int lineCount , bool includeBottom, int& count)
132 { 132 {
133 if (blockFlow->style()->visibility() != EVisibility::Visible) 133 if (blockFlow->style()->visibility() != EVisibility::Visible)
134 return -1; 134 return -1;
135 if (blockFlow->childrenInline()) { 135 if (blockFlow->childrenInline()) {
136 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex tRootBox()) { 136 for (RootInlineBox* box = blockFlow->firstRootBox(); box; box = box->nex tRootBox()) {
137 if (++count == lineCount) 137 if (++count == lineCount)
138 return box->lineBottom() + (includeBottom ? (blockFlow->borderBo ttom() + blockFlow->paddingBottom()) : LayoutUnit()); 138 return (box->lineBottom() + (includeBottom ? (blockFlow->borderB ottom() + blockFlow->paddingBottom()) : LayoutUnit())).toInt();
139 } 139 }
140 return -1; 140 return -1;
141 } 141 }
142 142
143 LayoutBox* normalFlowChildWithoutLines = nullptr; 143 LayoutBox* normalFlowChildWithoutLines = nullptr;
144 for (LayoutBox* obj = blockFlow->firstChildBox(); obj; obj = obj->nextSiblin gBox()) { 144 for (LayoutBox* obj = blockFlow->firstChildBox(); obj; obj = obj->nextSiblin gBox()) {
145 if (obj->isLayoutBlockFlow() && shouldCheckLines(toLayoutBlockFlow(obj)) ) { 145 if (obj->isLayoutBlockFlow() && shouldCheckLines(toLayoutBlockFlow(obj)) ) {
146 int result = getHeightForLineCount(toLayoutBlockFlow(obj), lineCount , false, count); 146 int result = getHeightForLineCount(toLayoutBlockFlow(obj), lineCount , false, count);
147 if (result != -1) 147 if (result != -1)
148 return result + obj->location().y() + (includeBottom ? (blockFlo w->borderBottom() + blockFlow->paddingBottom()) : LayoutUnit()); 148 return (result + obj->location().y() + (includeBottom ? (blockFl ow->borderBottom() + blockFlow->paddingBottom()) : LayoutUnit())).toInt();
149 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { 149 } else if (!obj->isFloatingOrOutOfFlowPositioned()) {
150 normalFlowChildWithoutLines = obj; 150 normalFlowChildWithoutLines = obj;
151 } 151 }
152 } 152 }
153 if (normalFlowChildWithoutLines && lineCount == 0) 153 if (normalFlowChildWithoutLines && lineCount == 0)
154 return normalFlowChildWithoutLines->location().y() + normalFlowChildWith outLines->size().height(); 154 return (normalFlowChildWithoutLines->location().y() + normalFlowChildWit houtLines->size().height()).toInt();
155 155
156 return -1; 156 return -1;
157 } 157 }
158 158
159 static RootInlineBox* lineAtIndex(const LayoutBlockFlow* blockFlow, int i) 159 static RootInlineBox* lineAtIndex(const LayoutBlockFlow* blockFlow, int i)
160 { 160 {
161 ASSERT(i >= 0); 161 ASSERT(i >= 0);
162 162
163 if (blockFlow->style()->visibility() != EVisibility::Visible) 163 if (blockFlow->style()->visibility() != EVisibility::Visible)
164 return nullptr; 164 return nullptr;
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1019
1020 // FIXME: Directions of src/destBlock could be different from our direct ion and from one another. 1020 // FIXME: Directions of src/destBlock could be different from our direct ion and from one another.
1021 if (!srcBlock.style()->isLeftToRightDirection()) 1021 if (!srcBlock.style()->isLeftToRightDirection())
1022 continue; 1022 continue;
1023 1023
1024 bool leftToRight = destBlock.style()->isLeftToRightDirection(); 1024 bool leftToRight = destBlock.style()->isLeftToRightDirection();
1025 if (!leftToRight) 1025 if (!leftToRight)
1026 continue; 1026 continue;
1027 1027
1028 LayoutUnit blockRightEdge = destBlock.logicalRightOffsetForLine(lastVisi bleLine->y(), DoNotIndentText); 1028 LayoutUnit blockRightEdge = destBlock.logicalRightOffsetForLine(lastVisi bleLine->y(), DoNotIndentText);
1029 if (!lastVisibleLine->lineCanAccommodateEllipsis(leftToRight, blockRight Edge, lastVisibleLine->x() + lastVisibleLine->logicalWidth(), totalWidth)) 1029 if (!lastVisibleLine->lineCanAccommodateEllipsis(leftToRight, blockRight Edge.toInt(), (lastVisibleLine->x() + lastVisibleLine->logicalWidth()).toInt(), totalWidth))
1030 continue; 1030 continue;
1031 1031
1032 // Let the truncation code kick in. 1032 // Let the truncation code kick in.
1033 // FIXME: the text alignment should be recomputed after the width change s due to truncation. 1033 // FIXME: the text alignment should be recomputed after the width change s due to truncation.
1034 LayoutUnit blockLeftEdge = destBlock.logicalLeftOffsetForLine(lastVisibl eLine->y(), DoNotIndentText); 1034 LayoutUnit blockLeftEdge = destBlock.logicalLeftOffsetForLine(lastVisibl eLine->y(), DoNotIndentText);
1035 lastVisibleLine->placeEllipsis(ellipsisStr, leftToRight, blockLeftEdge, blockRightEdge, LayoutUnit(totalWidth)); 1035 lastVisibleLine->placeEllipsis(ellipsisStr, leftToRight, blockLeftEdge, blockRightEdge, LayoutUnit(totalWidth));
1036 destBlock.setHasMarkupTruncation(true); 1036 destBlock.setHasMarkupTruncation(true);
1037 } 1037 }
1038 } 1038 }
1039 1039
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 if (minHeight.isFixed() || minHeight.isAuto()) { 1108 if (minHeight.isFixed() || minHeight.isAuto()) {
1109 LayoutUnit minHeight(child->style()->minHeight().value()); 1109 LayoutUnit minHeight(child->style()->minHeight().value());
1110 LayoutUnit height = contentHeightForChild(child); 1110 LayoutUnit height = contentHeightForChild(child);
1111 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero() ; 1111 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero() ;
1112 return allowedShrinkage; 1112 return allowedShrinkage;
1113 } 1113 }
1114 return LayoutUnit(); 1114 return LayoutUnit();
1115 } 1115 }
1116 1116
1117 } // namespace blink 1117 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutButton.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutFieldset.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698