| Index: third_party/WebKit/Source/core/paint/TableCollapsedBorderPainter.h
|
| diff --git a/third_party/WebKit/Source/core/paint/TableCollapsedBorderPainter.h b/third_party/WebKit/Source/core/paint/TableCollapsedBorderPainter.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..31e3b246a21efc24f22558ae9b560d1461d3dcf9
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/paint/TableCollapsedBorderPainter.h
|
| @@ -0,0 +1,196 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef TableCollapsedBorderPainter_h
|
| +#define TableCollapsedBorderPainter_h
|
| +
|
| +#include "core/layout/LayoutTableSection.h" // for LayoutTableSection::CellStruct
|
| +#include "core/style/BorderValue.h"
|
| +#include "core/style/CollapsedBorderValue.h"
|
| +#include "platform/graphics/paint/DisplayItem.h"
|
| +#include "wtf/Allocator.h"
|
| +
|
| +namespace blink {
|
| +
|
| +struct PaintInfo;
|
| +class CellSpan;
|
| +class BorderValue;
|
| +class LayoutObject;
|
| +class LayoutPoint;
|
| +class LayoutTable;
|
| +class LayoutTableCell;
|
| +class LayoutTableCol;
|
| +class LayoutTableRow;
|
| +class LayoutTableSection;
|
| +enum TextDirection;
|
| +
|
| +/*
|
| + * Paints all the borders inside a single section
|
| + */
|
| +class TableCollapsedBorderPainter {
|
| + STACK_ALLOCATED();
|
| +public:
|
| + TableCollapsedBorderPainter(const LayoutTableSection* layoutTableSection) : m_layoutTableSection(layoutTableSection)
|
| + {
|
| + m_hiddenBorder.setStyle(BorderStyleNone);
|
| + }
|
| +
|
| + void paintBorders(const PaintInfo&, const LayoutPoint&, const CellSpan&, const CellSpan&, const TableCollapsedBorderPainter& previousPainter);
|
| +
|
| + struct EdgeRecord {
|
| + EdgeRecord() : m_precedence(BorderPrecedenceOff) {};
|
| + EdgeRecord(const BorderValue& border, EBorderPrecedence precedence, Color resolvedColor) :
|
| + m_precedence(precedence),
|
| + m_border(border),
|
| + m_resolvedColor(resolvedColor) {};
|
| +
|
| + EBorderPrecedence m_precedence;
|
| + BorderValue m_border;
|
| + Color m_resolvedColor;
|
| + };
|
| +
|
| + // Ordered by winning order, do not modify
|
| + enum EdgeDirection { North, West, East, South, None};
|
| +
|
| +private:
|
| +
|
| + // Represents a visible edge in a table
|
| + struct VisibleEdgeRecord {
|
| + VisibleEdgeRecord(unsigned row, unsigned column, EdgeDirection direction, const BorderValue& border, EBorderPrecedence precedence, Color resolvedColor, bool forceRemoval = false) :
|
| + m_row(row),
|
| + m_column(column),
|
| + m_direction(direction),
|
| + m_precedence(precedence),
|
| + m_border(border),
|
| + m_resolvedColor(resolvedColor),
|
| + m_forceRemoval(forceRemoval)
|
| + {};
|
| +
|
| + unsigned m_row;
|
| + unsigned m_column;
|
| + EdgeDirection m_direction;
|
| + EBorderPrecedence m_precedence;
|
| + BorderValue m_border;
|
| + Color m_resolvedColor;
|
| + bool m_forceRemoval;
|
| + };
|
| +
|
| + typedef Vector<VisibleEdgeRecord> VisibleEdgeContainer;
|
| +
|
| + typedef Vector<EdgeRecord> EdgeRecordContainer;
|
| +
|
| + // Represents edge intersection
|
| + struct Intersection {
|
| + Intersection() : m_width(0), m_height(0), m_direction(None) {};
|
| + Intersection(LayoutUnit width, LayoutUnit height, EdgeDirection direction) :
|
| + m_width(width),
|
| + m_height(height),
|
| + m_direction(direction) {};
|
| + LayoutUnit m_width; // width of widest north-south edge
|
| + LayoutUnit m_height; // width of widest east-west edge
|
| + EdgeDirection m_direction; // direction of the winning edge
|
| + };
|
| +
|
| + typedef Vector<Intersection> IntersectionContainer;
|
| +
|
| + void initEdges(const CellSpan&, const CellSpan&, const TableCollapsedBorderPainter& previousPainter);
|
| + void populateEdges(const CellSpan&, const CellSpan&, const TableCollapsedBorderPainter& previousPainter);
|
| +
|
| +// Visible edges traversal
|
| + void getVisibleEdgesTable(VisibleEdgeContainer& edges, const LayoutTable *);
|
| + void getVisibleEdgesSection(VisibleEdgeContainer& edges);
|
| + void getVisibleEdgesColgroup(VisibleEdgeContainer& edges, const LayoutTableCol *);
|
| + void getVisibleEdgesCol(VisibleEdgeContainer& edges, const LayoutTableCol *);
|
| + void getVisibleEdgesRow(VisibleEdgeContainer& edges, const LayoutTableRow *);
|
| + void getVisibleEdgesCell(VisibleEdgeContainer& edges, const LayoutTableCell *, TextDirection);
|
| + void getVisibleEdgesSiblingSection(VisibleEdgeContainer& edges, const TableCollapsedBorderPainter& previousPainter);
|
| +
|
| +// Visible edges utils
|
| + void rotateBorders(TextDirection, WritingMode,
|
| + const BorderValue** topBorder,
|
| + const BorderValue** rightBorder,
|
| + const BorderValue** bottomBorder,
|
| + const BorderValue** leftBorder) const;
|
| +
|
| + void fillVisibleRect(VisibleEdgeContainer& edges,
|
| + unsigned startRow, unsigned startColumn, unsigned endRow, unsigned endColumn,
|
| + const ComputedStyle* borderStyle, TextDirection, WritingMode,
|
| + Color resolvedColor, EBorderPrecedence);
|
| + void fillHorizontalEdges(VisibleEdgeContainer& edges, unsigned row, unsigned startColumn, unsigned endColumn, const BorderValue &, EBorderPrecedence, Color resolvedColor);
|
| + void fillVerticalEdges(VisibleEdgeContainer& edges, unsigned column, unsigned startRow, unsigned endRow, const BorderValue &, EBorderPrecedence, Color resolvedColor);
|
| + void mergeVisibleEdges(VisibleEdgeContainer& edges);
|
| +
|
| + void initIntersections();
|
| + void initIntersection(unsigned row, unsigned col);
|
| +
|
| + LayoutRect getCellPhysicalPosition(unsigned row, unsigned effectiveColumn)
|
| + {
|
| + ASSERT(row != npos && effectiveColumn != npos);
|
| + return m_layoutTableSection->getCellPhysicalPosition(row, effectiveColumn);
|
| + };
|
| +
|
| +// Painting
|
| + LayoutRect cellRectAsBorder(const LayoutRect& cellRect, BoxSide, unsigned borderWidth, WritingMode, TextDirection);
|
| + LayoutRect edgePaintPosition(unsigned row, unsigned col, unsigned borderWidth, EdgeDirection, WritingMode, TextDirection);
|
| + void paintEdges(const PaintInfo&, const LayoutPoint&, const CellSpan& rows, const CellSpan& cols);
|
| + void paintOneEdge(const PaintInfo&, const LayoutPoint&, unsigned row, unsigned col, EdgeDirection, WritingMode, TextDirection);
|
| + void adjustForIntersections(LayoutRect& position, unsigned row, unsigned col, EdgeDirection, WritingMode, TextDirection);
|
| + void adjustForIntersectionsHorizontal(LayoutRect& position, EdgeDirection, bool isLTR,
|
| + const Intersection* startIntersection, bool winnerStart,
|
| + const Intersection* endIntersection, bool winnerEnd);
|
| + void adjustForIntersectionsFlippedBlocks(LayoutRect& position, EdgeDirection, bool isLTR,
|
| + const Intersection* startIntersection, bool winnerStart,
|
| + const Intersection* endIntersection, bool winnerEnd);
|
| + void adjustForIntersectionsFlippedLines(LayoutRect& position, EdgeDirection, bool isLTR,
|
| + const Intersection* startIntersection, bool winnerStart,
|
| + const Intersection* endIntersection, bool winnerEnd);
|
| +
|
| +
|
| +#ifndef NDEBUG
|
| +
|
| + void showEdge(unsigned row, unsigned col, EdgeDirection, EBorderPrecedence, const BorderValue&, Color) const;
|
| + void showEdges(bool showHidden = false) const;
|
| + void showVisibleEdges(const VisibleEdgeContainer& edges) const;
|
| + void showIntersections() const;
|
| + void showIntersection(unsigned row, unsigned col) const;
|
| +
|
| +#endif
|
| +
|
| + // Edges:
|
| + // Mental model for edges is that they originate at intersections (where cells meet)
|
| + // We store two edges for each intersection: East and South.
|
| + // We only store visible edges, not all edges in a section.
|
| + EdgeRecordContainer m_edges;
|
| +
|
| + // Limits for rows/cols stored in m_edges. effective
|
| + unsigned m_startVisibleRow;
|
| + unsigned m_startVisibleColumn;
|
| + unsigned m_endVisibleRow; // inclusive, +1 is out of bounds
|
| + unsigned m_endVisibleColumn; // inclusive, +1 is out of bounds
|
| +
|
| + // not-a-position edge index
|
| + static const unsigned npos = 0xFFFFFFFF;
|
| + // returns edge index for position, npos for none
|
| + unsigned edgeToIndex(unsigned row, unsigned column, EdgeDirection) const;
|
| +
|
| + // Intersections:
|
| + // Each intersection has width, height, and winning border
|
| + IntersectionContainer m_intersections;
|
| + unsigned m_maxIntersectionWidth;
|
| + unsigned m_maxIntersectionHeight;
|
| +
|
| + unsigned intersectionToIndex(unsigned row, unsigned column) const;
|
| +
|
| + const LayoutTableSection* m_layoutTableSection;
|
| +
|
| + // number of rows/cols in the section
|
| + unsigned m_numRows;
|
| + unsigned m_numEffectiveColumns;
|
| +
|
| + BorderValue m_hiddenBorder;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // TableCollapsedBorderPainter_h
|
|
|