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

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

Issue 1549693002: Optimize collapsed border painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 25 matching lines...) Expand all
36 #include "platform/geometry/FloatQuad.h" 36 #include "platform/geometry/FloatQuad.h"
37 #include "platform/geometry/TransformState.h" 37 #include "platform/geometry/TransformState.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 using namespace HTMLNames; 41 using namespace HTMLNames;
42 42
43 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow { 43 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow {
44 unsigned bitfields; 44 unsigned bitfields;
45 int paddings[2]; 45 int paddings[2];
46 void* pointer;
46 }; 47 };
47 48
48 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), "Lay outTableCell should stay small"); 49 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), "Lay outTableCell should stay small");
49 static_assert(sizeof(CollapsedBorderValue) == 8, "CollapsedBorderValue should st ay small"); 50 static_assert(sizeof(CollapsedBorderValue) == 8, "CollapsedBorderValue should st ay small");
50 51
51 LayoutTableCell::LayoutTableCell(Element* element) 52 LayoutTableCell::LayoutTableCell(Element* element)
52 : LayoutBlockFlow(element) 53 : LayoutBlockFlow(element)
53 , m_absoluteColumnIndex(unsetColumnIndex) 54 , m_absoluteColumnIndex(unsetColumnIndex)
54 , m_cellWidthChanged(false) 55 , m_cellWidthChanged(false)
55 , m_intrinsicPaddingBefore(0) 56 , m_intrinsicPaddingBefore(0)
56 , m_intrinsicPaddingAfter(0) 57 , m_intrinsicPaddingAfter(0)
57 { 58 {
58 // We only update the flags when notified of DOM changes in colSpanOrRowSpan Changed() 59 // We only update the flags when notified of DOM changes in colSpanOrRowSpan Changed()
59 // so we need to set their initial values here in case something asks for co lSpan()/rowSpan() before then. 60 // so we need to set their initial values here in case something asks for co lSpan()/rowSpan() before then.
60 updateColAndRowSpanFlags(); 61 updateColAndRowSpanFlags();
61 } 62 }
62 63
63 void LayoutTableCell::willBeRemovedFromTree() 64 void LayoutTableCell::willBeRemovedFromTree()
64 { 65 {
65 LayoutBlockFlow::willBeRemovedFromTree(); 66 LayoutBlockFlow::willBeRemovedFromTree();
66 67
67 section()->setNeedsCellRecalc(); 68 section()->setNeedsCellRecalc();
68 section()->removeCachedCollapsedBorders(this);
69 } 69 }
70 70
71 unsigned LayoutTableCell::parseColSpanFromDOM() const 71 unsigned LayoutTableCell::parseColSpanFromDOM() const
72 { 72 {
73 ASSERT(node()); 73 ASSERT(node());
74 if (isHTMLTableCellElement(*node())) 74 if (isHTMLTableCellElement(*node()))
75 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), max ColumnIndex); 75 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), max ColumnIndex);
76 return 1; 76 return 1;
77 } 77 }
78 78
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 size_t count = borderValues.size(); 901 size_t count = borderValues.size();
902 for (size_t i = 0; i < count; ++i) { 902 for (size_t i = 0; i < count; ++i) {
903 if (borderValues[i].isSameIgnoringColor(borderValue)) 903 if (borderValues[i].isSameIgnoringColor(borderValue))
904 return; 904 return;
905 } 905 }
906 borderValues.append(borderValue); 906 borderValues.append(borderValue);
907 } 907 }
908 908
909 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo rderValues) 909 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo rderValues)
910 { 910 {
911 CollapsedBorderValue startBorder = computeCollapsedStartBorder(); 911 CollapsedBorderValues newValues = {
912 CollapsedBorderValue endBorder = computeCollapsedEndBorder(); 912 computeCollapsedStartBorder(),
913 CollapsedBorderValue beforeBorder = computeCollapsedBeforeBorder(); 913 computeCollapsedEndBorder(),
914 CollapsedBorderValue afterBorder = computeCollapsedAfterBorder(); 914 computeCollapsedBeforeBorder(),
915 LayoutTableSection* section = this->section(); 915 computeCollapsedAfterBorder()
916 bool changed = section->setCachedCollapsedBorder(this, CBSStart, startBorder ); 916 };
917 changed |= section->setCachedCollapsedBorder(this, CBSEnd, endBorder);
918 changed |= section->setCachedCollapsedBorder(this, CBSBefore, beforeBorder);
919 changed |= section->setCachedCollapsedBorder(this, CBSAfter, afterBorder);
920 917
921 // In slimming paint mode, we need to invalidate all cells with collapsed bo rder changed. 918 bool changed = false;
chrishtr 2016/05/05 15:31:36 Still gone?
Xianzhu 2016/05/05 17:38:49 It's now at new line 934-935.
922 // FIXME: Need a way to invalidate/repaint the borders only. crbug.com/45109 0#c5. 919 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() & & !newValues.beforeBorder.isVisible() && !newValues.afterBorder.isVisible()) {
920 changed = !!m_collapsedBorderValues;
921 m_collapsedBorderValues = nullptr;
922 } else if (!m_collapsedBorderValues) {
923 changed = true;
924 m_collapsedBorderValues = adoptPtr(new CollapsedBorderValues(newValues)) ;
925 } else {
926 changed = !m_collapsedBorderValues->startBorder.visuallyEquals(newValues .startBorder)
chrishtr 2016/05/05 15:31:36 Add a comment that we check visuallyEquals so that
Xianzhu 2016/05/05 17:38:49 Done.
chrishtr 2016/05/05 17:42:12 Don't see the added comment in this patch set?
Xianzhu 2016/05/05 17:45:15 Sorry, didn't press <Enter> after git cl upload.
927 || !m_collapsedBorderValues->endBorder.visuallyEquals(newValues.endB order)
928 || !m_collapsedBorderValues->beforeBorder.visuallyEquals(newValues.b eforeBorder)
929 || !m_collapsedBorderValues->afterBorder.visuallyEquals(newValues.af terBorder);
930 if (changed)
931 *m_collapsedBorderValues = newValues;
932 }
933
934 // If collapsed borders changed, invalidate the cell's display item client o n the table's backing.
935 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders o nly.
923 if (changed) 936 if (changed)
924 table()->invalidateDisplayItemClient(*this); 937 table()->invalidateDisplayItemClient(*this);
925 938
926 addBorderStyle(borderValues, startBorder); 939 addBorderStyle(borderValues, newValues.startBorder);
927 addBorderStyle(borderValues, endBorder); 940 addBorderStyle(borderValues, newValues.endBorder);
928 addBorderStyle(borderValues, beforeBorder); 941 addBorderStyle(borderValues, newValues.beforeBorder);
929 addBorderStyle(borderValues, afterBorder); 942 addBorderStyle(borderValues, newValues.afterBorder);
930 } 943 }
931 944
932 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde rValues) 945 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde rValues)
933 { 946 {
934 std::sort(borderValues.begin(), borderValues.end(), compareBorders); 947 std::sort(borderValues.begin(), borderValues.end(), compareBorders);
935 } 948 }
936 949
937 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c onst LayoutPoint& paintOffset) const 950 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c onst LayoutPoint& paintOffset) const
938 { 951 {
939 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset) ; 952 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset) ;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR ect) const 1006 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR ect) const
994 { 1007 {
995 // If this object has layer, the area of collapsed borders should be transpa rent 1008 // If this object has layer, the area of collapsed borders should be transpa rent
996 // to expose the collapsed borders painted on the underlying layer. 1009 // to expose the collapsed borders painted on the underlying layer.
997 if (hasLayer() && table()->collapseBorders()) 1010 if (hasLayer() && table()->collapseBorders())
998 return false; 1011 return false;
999 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); 1012 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect);
1000 } 1013 }
1001 1014
1002 } // namespace blink 1015 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698