OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 paintInfo.context->restore(); | 1599 paintInfo.context->restore(); |
1600 if (phase == PaintPhaseOutline) { | 1600 if (phase == PaintPhaseOutline) { |
1601 paintInfo.phase = PaintPhaseSelfOutline; | 1601 paintInfo.phase = PaintPhaseSelfOutline; |
1602 paintObject(paintInfo, tx, ty); | 1602 paintObject(paintInfo, tx, ty); |
1603 paintInfo.phase = phase; | 1603 paintInfo.phase = phase; |
1604 } else if (phase == PaintPhaseChildBlockBackground) | 1604 } else if (phase == PaintPhaseChildBlockBackground) |
1605 paintInfo.phase = phase; | 1605 paintInfo.phase = phase; |
1606 } | 1606 } |
1607 } | 1607 } |
1608 | 1608 |
1609 void RenderBlock::paintColumns(PaintInfo& paintInfo, int tx, int ty, bool painti
ngFloats) | 1609 void RenderBlock::paintColumnRules(PaintInfo& paintInfo, int tx, int ty) |
| 1610 { |
| 1611 const Color& ruleColor = style()->columnRuleColor(); |
| 1612 bool ruleTransparent = style()->columnRuleIsTransparent(); |
| 1613 EBorderStyle ruleStyle = style()->columnRuleStyle(); |
| 1614 int ruleWidth = style()->columnRuleWidth(); |
| 1615 int colGap = columnGap(); |
| 1616 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent && ruleWidth <= co
lGap; |
| 1617 if (!renderRule) |
| 1618 return; |
| 1619 |
| 1620 // We need to do multiple passes, breaking up our child painting into strips
. |
| 1621 int currXOffset = 0; |
| 1622 int ruleAdd = borderLeft() + paddingLeft(); |
| 1623 int ruleX = 0; |
| 1624 Vector<IntRect>* colRects = columnRects(); |
| 1625 unsigned colCount = colRects->size(); |
| 1626 for (unsigned i = 0; i < colCount; i++) { |
| 1627 // For each rect, we clip to the rect, and then we adjust our coords. |
| 1628 IntRect colRect = colRects->at(i); |
| 1629 |
| 1630 // Move to the next position. |
| 1631 if (style()->direction() == LTR) { |
| 1632 ruleX += colRect.width() + colGap / 2; |
| 1633 currXOffset += colRect.width() + colGap; |
| 1634 } else { |
| 1635 ruleX -= (colRect.width() + colGap / 2); |
| 1636 currXOffset -= (colRect.width() + colGap); |
| 1637 } |
| 1638 |
| 1639 // Now paint the column rule. |
| 1640 if (i < colCount - 1) { |
| 1641 int ruleStart = tx + ruleX - ruleWidth / 2 + ruleAdd; |
| 1642 int ruleEnd = ruleStart + ruleWidth; |
| 1643 int ruleTop = ty + borderTop() + paddingTop(); |
| 1644 int ruleBottom = ruleTop + contentHeight(); |
| 1645 drawLineForBoxSide(paintInfo.context, ruleStart, ruleTop, ruleEnd, r
uleBottom, |
| 1646 style()->direction() == LTR ? BSLeft : BSRight, r
uleColor, style()->color(), ruleStyle, 0, 0); |
| 1647 } |
| 1648 |
| 1649 ruleX = currXOffset; |
| 1650 } |
| 1651 } |
| 1652 |
| 1653 void RenderBlock::paintColumnContents(PaintInfo& paintInfo, int tx, int ty, bool
paintingFloats) |
1610 { | 1654 { |
1611 // We need to do multiple passes, breaking up our child painting into strips
. | 1655 // We need to do multiple passes, breaking up our child painting into strips
. |
1612 GraphicsContext* context = paintInfo.context; | 1656 GraphicsContext* context = paintInfo.context; |
1613 int currXOffset = 0; | 1657 int currXOffset = 0; |
1614 int currYOffset = 0; | 1658 int currYOffset = 0; |
1615 int ruleAdd = borderLeft() + paddingLeft(); | |
1616 int ruleX = 0; | |
1617 int colGap = columnGap(); | 1659 int colGap = columnGap(); |
1618 const Color& ruleColor = style()->columnRuleColor(); | |
1619 bool ruleTransparent = style()->columnRuleIsTransparent(); | |
1620 EBorderStyle ruleStyle = style()->columnRuleStyle(); | |
1621 int ruleWidth = style()->columnRuleWidth(); | |
1622 bool renderRule = !paintingFloats && ruleStyle > BHIDDEN && !ruleTransparent
&& ruleWidth <= colGap; | |
1623 Vector<IntRect>* colRects = columnRects(); | 1660 Vector<IntRect>* colRects = columnRects(); |
1624 unsigned colCount = colRects->size(); | 1661 unsigned colCount = colRects->size(); |
1625 for (unsigned i = 0; i < colCount; i++) { | 1662 for (unsigned i = 0; i < colCount; i++) { |
1626 // For each rect, we clip to the rect, and then we adjust our coords. | 1663 // For each rect, we clip to the rect, and then we adjust our coords. |
1627 IntRect colRect = colRects->at(i); | 1664 IntRect colRect = colRects->at(i); |
1628 colRect.move(tx, ty); | 1665 colRect.move(tx, ty); |
1629 context->save(); | 1666 context->save(); |
1630 | 1667 |
1631 // Each strip pushes a clip, since column boxes are specified as being | 1668 // Each strip pushes a clip, since column boxes are specified as being |
1632 // like overflow:hidden. | 1669 // like overflow:hidden. |
1633 context->clip(colRect); | 1670 context->clip(colRect); |
1634 | 1671 |
1635 // Adjust tx and ty to change where we paint. | 1672 // Adjust tx and ty to change where we paint. |
1636 PaintInfo info(paintInfo); | 1673 PaintInfo info(paintInfo); |
1637 info.rect.intersect(colRect); | 1674 info.rect.intersect(colRect); |
1638 | 1675 |
1639 // Adjust our x and y when painting. | 1676 // Adjust our x and y when painting. |
1640 int finalX = tx + currXOffset; | 1677 int finalX = tx + currXOffset; |
1641 int finalY = ty + currYOffset; | 1678 int finalY = ty + currYOffset; |
1642 if (paintingFloats) | 1679 if (paintingFloats) |
1643 paintFloats(info, finalX, finalY, paintInfo.phase == PaintPhaseSelec
tion || paintInfo.phase == PaintPhaseTextClip); | 1680 paintFloats(info, finalX, finalY, paintInfo.phase == PaintPhaseSelec
tion || paintInfo.phase == PaintPhaseTextClip); |
1644 else | 1681 else |
1645 paintContents(info, finalX, finalY); | 1682 paintContents(info, finalX, finalY); |
1646 | 1683 |
1647 // Move to the next position. | 1684 // Move to the next position. |
1648 if (style()->direction() == LTR) { | 1685 if (style()->direction() == LTR) |
1649 ruleX += colRect.width() + colGap / 2; | |
1650 currXOffset += colRect.width() + colGap; | 1686 currXOffset += colRect.width() + colGap; |
1651 } else { | 1687 else |
1652 ruleX -= (colRect.width() + colGap / 2); | |
1653 currXOffset -= (colRect.width() + colGap); | 1688 currXOffset -= (colRect.width() + colGap); |
1654 } | 1689 |
1655 | |
1656 currYOffset -= colRect.height(); | 1690 currYOffset -= colRect.height(); |
1657 | 1691 |
1658 context->restore(); | 1692 context->restore(); |
1659 | |
1660 // Now paint the column rule. | |
1661 if (renderRule && paintInfo.phase == PaintPhaseForeground && i < colCoun
t - 1) { | |
1662 int ruleStart = ruleX - ruleWidth / 2 + ruleAdd; | |
1663 int ruleEnd = ruleStart + ruleWidth; | |
1664 drawLineForBoxSide(paintInfo.context, tx + ruleStart, ty + borderTop
() + paddingTop(), tx + ruleEnd, ty + borderTop() + paddingTop() + contentHeight
(), | |
1665 style()->direction() == LTR ? BSLeft : BSRight, r
uleColor, style()->color(), ruleStyle, 0, 0); | |
1666 } | |
1667 | |
1668 ruleX = currXOffset; | |
1669 } | 1693 } |
1670 } | 1694 } |
1671 | 1695 |
1672 void RenderBlock::paintContents(PaintInfo& paintInfo, int tx, int ty) | 1696 void RenderBlock::paintContents(PaintInfo& paintInfo, int tx, int ty) |
1673 { | 1697 { |
1674 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. | 1698 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. |
1675 // It's ok not to draw, because later on, when all the stylesheets do load,
updateStyleSelector on the Document | 1699 // It's ok not to draw, because later on, when all the stylesheets do load,
updateStyleSelector on the Document |
1676 // will do a full repaint(). | 1700 // will do a full repaint(). |
1677 if (document()->didLayoutWithPendingStylesheets() && !isRenderView()) | 1701 if (document()->didLayoutWithPendingStylesheets() && !isRenderView()) |
1678 return; | 1702 return; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 else | 1756 else |
1733 document()->frame()->paintDragCaret(paintInfo.context, tx, ty, paint
Info.rect); | 1757 document()->frame()->paintDragCaret(paintInfo.context, tx, ty, paint
Info.rect); |
1734 } | 1758 } |
1735 } | 1759 } |
1736 | 1760 |
1737 void RenderBlock::paintObject(PaintInfo& paintInfo, int tx, int ty) | 1761 void RenderBlock::paintObject(PaintInfo& paintInfo, int tx, int ty) |
1738 { | 1762 { |
1739 PaintPhase paintPhase = paintInfo.phase; | 1763 PaintPhase paintPhase = paintInfo.phase; |
1740 | 1764 |
1741 // 1. paint background, borders etc | 1765 // 1. paint background, borders etc |
1742 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && | 1766 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && style()->visibility() == VISIBLE) { |
1743 hasBoxDecorations() && style()->visibility() == VISIBLE) { | 1767 if (hasBoxDecorations()) |
1744 paintBoxDecorations(paintInfo, tx, ty); | 1768 paintBoxDecorations(paintInfo, tx, ty); |
| 1769 if (hasColumns()) |
| 1770 paintColumnRules(paintInfo, tx, ty); |
1745 } | 1771 } |
1746 | 1772 |
1747 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { | 1773 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { |
1748 paintMask(paintInfo, tx, ty); | 1774 paintMask(paintInfo, tx, ty); |
1749 return; | 1775 return; |
1750 } | 1776 } |
1751 | 1777 |
1752 // We're done. We don't bother painting any children. | 1778 // We're done. We don't bother painting any children. |
1753 if (paintPhase == PaintPhaseBlockBackground) | 1779 if (paintPhase == PaintPhaseBlockBackground) |
1754 return; | 1780 return; |
1755 | 1781 |
1756 // Adjust our painting position if we're inside a scrolled layer (e.g., an o
verflow:auto div).s | 1782 // Adjust our painting position if we're inside a scrolled layer (e.g., an o
verflow:auto div).s |
1757 int scrolledX = tx; | 1783 int scrolledX = tx; |
1758 int scrolledY = ty; | 1784 int scrolledY = ty; |
1759 if (hasOverflowClip()) | 1785 if (hasOverflowClip()) |
1760 layer()->subtractScrolledContentOffset(scrolledX, scrolledY); | 1786 layer()->subtractScrolledContentOffset(scrolledX, scrolledY); |
1761 | 1787 |
1762 // 2. paint contents | 1788 // 2. paint contents |
1763 if (paintPhase != PaintPhaseSelfOutline) { | 1789 if (paintPhase != PaintPhaseSelfOutline) { |
1764 if (hasColumns()) | 1790 if (hasColumns()) |
1765 paintColumns(paintInfo, scrolledX, scrolledY); | 1791 paintColumnContents(paintInfo, scrolledX, scrolledY); |
1766 else | 1792 else |
1767 paintContents(paintInfo, scrolledX, scrolledY); | 1793 paintContents(paintInfo, scrolledX, scrolledY); |
1768 } | 1794 } |
1769 | 1795 |
1770 // 3. paint selection | 1796 // 3. paint selection |
1771 // FIXME: Make this work with multi column layouts. For now don't fill gaps
. | 1797 // FIXME: Make this work with multi column layouts. For now don't fill gaps
. |
1772 bool isPrinting = document()->printing(); | 1798 bool isPrinting = document()->printing(); |
1773 if (!isPrinting && !hasColumns()) | 1799 if (!isPrinting && !hasColumns()) |
1774 paintSelection(paintInfo, scrolledX, scrolledY); // Fill in gaps in sele
ction on lines and between blocks. | 1800 paintSelection(paintInfo, scrolledX, scrolledY); // Fill in gaps in sele
ction on lines and between blocks. |
1775 | 1801 |
1776 // 4. paint floats. | 1802 // 4. paint floats. |
1777 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection || pa
intPhase == PaintPhaseTextClip) { | 1803 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection || pa
intPhase == PaintPhaseTextClip) { |
1778 if (hasColumns()) | 1804 if (hasColumns()) |
1779 paintColumns(paintInfo, scrolledX, scrolledY, true); | 1805 paintColumnContents(paintInfo, scrolledX, scrolledY, true); |
1780 else | 1806 else |
1781 paintFloats(paintInfo, scrolledX, scrolledY, paintPhase == PaintPhas
eSelection || paintPhase == PaintPhaseTextClip); | 1807 paintFloats(paintInfo, scrolledX, scrolledY, paintPhase == PaintPhas
eSelection || paintPhase == PaintPhaseTextClip); |
1782 } | 1808 } |
1783 | 1809 |
1784 // 5. paint outline. | 1810 // 5. paint outline. |
1785 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& hasOutline() && style()->visibility() == VISIBLE) | 1811 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& hasOutline() && style()->visibility() == VISIBLE) |
1786 paintOutline(paintInfo.context, tx, ty, width(), height(), style()); | 1812 paintOutline(paintInfo.context, tx, ty, width(), height(), style()); |
1787 | 1813 |
1788 // 6. paint continuation outlines. | 1814 // 6. paint continuation outlines. |
1789 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutline
s)) { | 1815 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutline
s)) { |
(...skipping 3222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5012 return "RenderBlock (generated)"; | 5038 return "RenderBlock (generated)"; |
5013 if (isRelPositioned()) | 5039 if (isRelPositioned()) |
5014 return "RenderBlock (relative positioned)"; | 5040 return "RenderBlock (relative positioned)"; |
5015 if (isRunIn()) | 5041 if (isRunIn()) |
5016 return "RenderBlock (run-in)"; | 5042 return "RenderBlock (run-in)"; |
5017 return "RenderBlock"; | 5043 return "RenderBlock"; |
5018 } | 5044 } |
5019 | 5045 |
5020 } // namespace WebCore | 5046 } // namespace WebCore |
5021 | 5047 |
OLD | NEW |