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

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

Issue 1549693002: Optimize collapsed border painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Field instead of global HashMap Created 4 years, 12 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, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved.
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 if (!result.hitTestRequest().listBased()) 1615 if (!result.hitTestRequest().listBased())
1616 break; 1616 break;
1617 } 1617 }
1618 if (!result.hitTestRequest().listBased()) 1618 if (!result.hitTestRequest().listBased())
1619 break; 1619 break;
1620 } 1620 }
1621 1621
1622 return false; 1622 return false;
1623 } 1623 }
1624 1624
1625 void LayoutTableSection::removeCachedCollapsedBorders(const LayoutTableCell* cel l)
1626 {
1627 if (!table()->collapseBorders())
1628 return;
1629
1630 for (int side = CBSBefore; side <= CBSEnd; ++side)
1631 m_cellsCollapsedBorders.remove(std::make_pair(cell, side));
1632 }
1633
1634 bool LayoutTableSection::setCachedCollapsedBorder(const LayoutTableCell* cell, C ollapsedBorderSide side, const CollapsedBorderValue& border)
1635 {
1636 ASSERT(table()->collapseBorders());
1637 CellsCollapsedBordersMap::iterator it = m_cellsCollapsedBorders.find(std::ma ke_pair(cell, side));
1638 if (it == m_cellsCollapsedBorders.end()) {
1639 m_cellsCollapsedBorders.add(std::make_pair(cell, side), border);
1640 return true;
1641 }
1642 if (!it->value.equals(border)) {
1643 it->value = border;
1644 return true;
1645 }
1646 return false;
1647 }
1648
1649 const CollapsedBorderValue& LayoutTableSection::cachedCollapsedBorder(const Layo utTableCell* cell, CollapsedBorderSide side) const
1650 {
1651 ASSERT(table()->collapseBorders());
1652 CellsCollapsedBordersMap::const_iterator it = m_cellsCollapsedBorders.find(s td::make_pair(cell, side));
1653 ASSERT_WITH_SECURITY_IMPLICATION(it != m_cellsCollapsedBorders.end());
1654 return it->value;
1655 }
1656
1657 LayoutTableSection* LayoutTableSection::createAnonymousWithParent(const LayoutOb ject* parent) 1625 LayoutTableSection* LayoutTableSection::createAnonymousWithParent(const LayoutOb ject* parent)
1658 { 1626 {
1659 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp lay(parent->styleRef(), TABLE_ROW_GROUP); 1627 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp lay(parent->styleRef(), TABLE_ROW_GROUP);
1660 LayoutTableSection* newSection = new LayoutTableSection(nullptr); 1628 LayoutTableSection* newSection = new LayoutTableSection(nullptr);
1661 newSection->setDocumentForAnonymous(&parent->document()); 1629 newSection->setDocumentForAnonymous(&parent->document());
1662 newSection->setStyle(newStyle.release()); 1630 newSection->setStyle(newStyle.release());
1663 return newSection; 1631 return newSection;
1664 } 1632 }
1665 1633
1666 void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign ed effectiveColumn) const 1634 void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign ed effectiveColumn) const
1667 { 1635 {
1668 LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]); 1636 LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]);
1669 int horizontalBorderSpacing = table()->hBorderSpacing(); 1637 int horizontalBorderSpacing = table()->hBorderSpacing();
1670 1638
1671 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1639 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1672 if (!style()->isLeftToRightDirection()) 1640 if (!style()->isLeftToRightDirection())
1673 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1641 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1674 else 1642 else
1675 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1643 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1676 1644
1677 cell->setLogicalLocation(cellLocation); 1645 cell->setLogicalLocation(cellLocation);
1678 } 1646 }
1679 1647
1680 } // namespace blink 1648 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698