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

Side by Side Diff: third_party/WebKit/Source/core/paint/TableSectionPainter.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/TableSectionPainter.h" 5 #include "core/paint/TableSectionPainter.h"
6 6
7 #include "core/layout/LayoutTableCell.h" 7 #include "core/layout/LayoutTableCell.h"
8 #include "core/layout/LayoutTableCol.h" 8 #include "core/layout/LayoutTableCol.h"
9 #include "core/layout/LayoutTableRow.h" 9 #include "core/layout/LayoutTableRow.h"
10 #include "core/paint/BoxClipper.h" 10 #include "core/paint/BoxClipper.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 LayoutTable* table = m_layoutTableSection.table(); 43 LayoutTable* table = m_layoutTableSection.table();
44 LayoutPoint paginationOffset = paintOffset; 44 LayoutPoint paginationOffset = paintOffset;
45 LayoutUnit pageHeight = table->pageLogicalHeightForOffset(LayoutUnit()); 45 LayoutUnit pageHeight = table->pageLogicalHeightForOffset(LayoutUnit());
46 46
47 // Move paginationOffset to the top of the next page. 47 // Move paginationOffset to the top of the next page.
48 // The header may have a pagination strut before it so we need to account fo r that when establishing its position. 48 // The header may have a pagination strut before it so we need to account fo r that when establishing its position.
49 LayoutUnit headerGroupOffset = table->pageLogicalOffset(); 49 LayoutUnit headerGroupOffset = table->pageLogicalOffset();
50 if (LayoutTableRow* row = m_layoutTableSection.firstRow()) 50 if (LayoutTableRow* row = m_layoutTableSection.firstRow())
51 headerGroupOffset += m_layoutTableSection.paginationStrutForRow(row, tab le->pageLogicalOffset()); 51 headerGroupOffset += m_layoutTableSection.paginationStrutForRow(row, tab le->pageLogicalOffset());
52 LayoutUnit offsetToNextPage = pageHeight - intMod(headerGroupOffset, pageHei ght); 52 LayoutUnit offsetToNextPage = pageHeight - intMod(headerGroupOffset, pageHei ght);
53 paginationOffset.move(0, offsetToNextPage); 53 paginationOffset.move(0, offsetToNextPage.toInt());
54 // Now move paginationOffset to the top of the page the cull rect starts on. 54 // Now move paginationOffset to the top of the page the cull rect starts on.
55 if (paintInfo.cullRect().m_rect.y() > paginationOffset.y()) 55 if (paintInfo.cullRect().m_rect.y() > paginationOffset.y()) {
56 paginationOffset.move(0, pageHeight * static_cast<int>((paintInfo.cullRe ct().m_rect.y() - paginationOffset.y()) / pageHeight)); 56 // TODO(crbug.com/638981): Is the first conversion to int intentional?
Stephen Chennney 2016/08/22 17:46:10 I suspect so. Tables are still laid out at int res
Xianzhu 2016/08/22 18:14:38 Done.
57 paginationOffset.move(0, pageHeight.toInt() * ((paintInfo.cullRect().m_r ect.y() - paginationOffset.y()) / pageHeight).toInt());
58 }
57 LayoutUnit bottomBound = std::min(LayoutUnit(paintInfo.cullRect().m_rect.max Y()), paintOffset.y() + table->logicalHeight()); 59 LayoutUnit bottomBound = std::min(LayoutUnit(paintInfo.cullRect().m_rect.max Y()), paintOffset.y() + table->logicalHeight());
58 while (paginationOffset.y() < bottomBound) { 60 while (paginationOffset.y() < bottomBound) {
59 LayoutPoint nestedOffset = paginationOffset + LayoutPoint(0, m_layoutTab leSection.offsetForRepeatingHeader()); 61 // TODO(crbug.com/638981): Is the conversion to int (in LayoutPoint(0, . ..)) intentional?
Xianzhu 2016/08/22 18:14:38 Removed.
62 LayoutPoint nestedOffset = paginationOffset + LayoutPoint(0, m_layoutTab leSection.offsetForRepeatingHeader().toInt());
60 if (itemToPaint == PaintCollapsedBorders) 63 if (itemToPaint == PaintCollapsedBorders)
61 paintCollapsedSectionBorders(paintInfo, nestedOffset, currentBorderV alue); 64 paintCollapsedSectionBorders(paintInfo, nestedOffset, currentBorderV alue);
62 else 65 else
63 paintSection(paintInfo, nestedOffset); 66 paintSection(paintInfo, nestedOffset);
64 paginationOffset.move(0, pageHeight); 67 // TODO(crbug.com/638981): Is the conversion to int (in move(0, ...)) in tentional?
Xianzhu 2016/08/22 18:14:38 Removed.
68 paginationOffset.move(0, pageHeight.toInt());
65 } 69 }
66 } 70 }
67 71
68 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 72 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
69 { 73 {
70 paintSection(paintInfo, paintOffset); 74 paintSection(paintInfo, paintOffset);
71 LayoutTable* table = m_layoutTableSection.table(); 75 LayoutTable* table = m_layoutTableSection.table();
72 if (table->header() == m_layoutTableSection) 76 if (table->header() == m_layoutTableSection)
73 paintRepeatingHeaderGroup(paintInfo, paintOffset, CollapsedBorderValue() , PaintSection); 77 paintRepeatingHeaderGroup(paintInfo, paintOffset, CollapsedBorderValue() , PaintSection);
74 } 78 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableSectionBo xShadowNormal : DisplayItem::TableSectionBoxShadowInset; 304 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableSectionBo xShadowNormal : DisplayItem::TableSectionBoxShadowInset;
301 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableSection, type)) 305 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableSection, type))
302 return; 306 return;
303 307
304 LayoutRect bounds = BoxPainter(m_layoutTableSection).boundsForDrawingRecorde r(paintInfo, paintOffset); 308 LayoutRect bounds = BoxPainter(m_layoutTableSection).boundsForDrawingRecorde r(paintInfo, paintOffset);
305 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection , type, bounds); 309 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection , type, bounds);
306 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(paintOffset, m_layoutTableS ection.size()), m_layoutTableSection.styleRef(), shadowStyle); 310 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(paintOffset, m_layoutTableS ection.size()), m_layoutTableSection.styleRef(), shadowStyle);
307 } 311 }
308 312
309 } // namespace blink 313 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698