OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 105 void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
106 { | 106 { |
107 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 107 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
108 | 108 |
109 if (!shouldPaint(paintInfo, paintOffset)) | 109 if (!shouldPaint(paintInfo, paintOffset)) |
110 return; | 110 return; |
111 | 111 |
112 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 112 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
113 | 113 |
114 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paint
Info.phase == PaintPhaseSelection)) | 114 if (hasBoxDecorations() && (paintInfo.getPhase() == PaintPhaseForeground ||
paintInfo.getPhase() == PaintPhaseSelection)) |
115 paintBoxDecorations(paintInfo, adjustedPaintOffset); | 115 paintBoxDecorations(paintInfo, adjustedPaintOffset); |
116 | 116 |
117 if (paintInfo.phase == PaintPhaseMask) { | 117 if (paintInfo.getPhase() == PaintPhaseMask) { |
118 paintMask(paintInfo, adjustedPaintOffset); | 118 paintMask(paintInfo, adjustedPaintOffset); |
119 return; | 119 return; |
120 } | 120 } |
121 | 121 |
122 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size()); | 122 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size()); |
123 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && style()->outlineWidth()) | 123 if ((paintInfo.getPhase() == PaintPhaseOutline || paintInfo.getPhase() == Pa
intPhaseSelfOutline) && style()->outlineWidth()) |
124 paintOutline(paintInfo, paintRect); | 124 paintOutline(paintInfo, paintRect); |
125 | 125 |
126 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection && !canHaveChildren()) | 126 if (paintInfo.getPhase() != PaintPhaseForeground && paintInfo.getPhase() !=
PaintPhaseSelection && !canHaveChildren()) |
127 return; | 127 return; |
128 | 128 |
129 if (!paintInfo.shouldPaintWithinRoot(this)) | 129 if (!paintInfo.shouldPaintWithinRoot(this)) |
130 return; | 130 return; |
131 | 131 |
132 bool drawSelectionTint = selectionState() != SelectionNone && !document()->p
rinting(); | 132 bool drawSelectionTint = selectionState() != SelectionNone && !document()->p
rinting(); |
133 if (paintInfo.phase == PaintPhaseSelection) { | 133 if (paintInfo.getPhase() == PaintPhaseSelection) { |
134 if (selectionState() == SelectionNone) | 134 if (selectionState() == SelectionNone) |
135 return; | 135 return; |
136 drawSelectionTint = false; | 136 drawSelectionTint = false; |
137 } | 137 } |
138 | 138 |
139 bool completelyClippedOut = false; | 139 bool completelyClippedOut = false; |
140 if (style()->hasBorderRadius()) { | 140 if (style()->hasBorderRadius()) { |
141 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); | 141 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); |
142 | 142 |
143 if (borderRect.isEmpty()) | 143 if (borderRect.isEmpty()) |
144 completelyClippedOut = true; | 144 completelyClippedOut = true; |
145 else { | 145 else { |
146 // Push a clip if we have a border radius, since we want to round th
e foreground content that gets painted. | 146 // Push a clip if we have a border radius, since we want to round th
e foreground content that gets painted. |
147 paintInfo.context->save(); | 147 paintInfo.getContext()->save(); |
148 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(pai
ntRect, | 148 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(pai
ntRect, |
149 paddingTop() + borderTop(), paddingBottom() + borderBottom(), pa
ddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true); | 149 paddingTop() + borderTop(), paddingBottom() + borderBottom(), pa
ddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true); |
150 clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect)
; | 150 clipRoundedInnerRect(paintInfo.getContext(), paintRect, roundedInner
Rect); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 if (!completelyClippedOut) { | 154 if (!completelyClippedOut) { |
155 paintReplaced(paintInfo, adjustedPaintOffset); | 155 paintReplaced(paintInfo, adjustedPaintOffset); |
156 | 156 |
157 if (style()->hasBorderRadius()) | 157 if (style()->hasBorderRadius()) |
158 paintInfo.context->restore(); | 158 paintInfo.getContext()->restore(); |
159 } | 159 } |
160 | 160 |
161 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of | 161 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of |
162 // surrounding content. | 162 // surrounding content. |
163 if (drawSelectionTint) { | 163 if (drawSelectionTint) { |
164 LayoutRect selectionPaintingRect = localSelectionRect(); | 164 LayoutRect selectionPaintingRect = localSelectionRect(); |
165 selectionPaintingRect.moveBy(adjustedPaintOffset); | 165 selectionPaintingRect.moveBy(adjustedPaintOffset); |
166 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect),
selectionBackgroundColor()); | 166 paintInfo.getContext()->fillRect(pixelSnappedIntRect(selectionPaintingRe
ct), selectionBackgroundColor()); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 170 bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
171 { | 171 { |
172 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Outline && paintInfo.phase != PaintPhaseSelfOutline | 172 if (paintInfo.getPhase() != PaintPhaseForeground && paintInfo.getPhase() !=
PaintPhaseOutline && paintInfo.getPhase() != PaintPhaseSelfOutline && paintInfo.
getPhase() != PaintPhaseSelection && paintInfo.getPhase() != PaintPhaseMask) |
173 && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != Pain
tPhaseMask) | |
174 return false; | 173 return false; |
175 | 174 |
176 if (!paintInfo.shouldPaintWithinRoot(this)) | 175 if (!paintInfo.shouldPaintWithinRoot(this)) |
177 return false; | 176 return false; |
178 | 177 |
179 // if we're invisible or haven't received a layout yet, then just bail. | 178 // if we're invisible or haven't received a layout yet, then just bail. |
180 if (style()->visibility() != VISIBLE) | 179 if (style()->visibility() != VISIBLE) |
181 return false; | 180 return false; |
182 | 181 |
183 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 182 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
184 | 183 |
185 // Early exit if the element touches the edges. | 184 // Early exit if the element touches the edges. |
186 LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y(); | 185 LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y(); |
187 LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY(); | 186 LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY(); |
188 if (isSelected() && m_inlineBoxWrapper) { | 187 if (isSelected() && m_inlineBoxWrapper) { |
189 LayoutUnit selTop = paintOffset.y() + m_inlineBoxWrapper->root()->select
ionTop(); | 188 LayoutUnit selTop = paintOffset.y() + m_inlineBoxWrapper->root()->select
ionTop(); |
190 LayoutUnit selBottom = paintOffset.y() + selTop + m_inlineBoxWrapper->ro
ot()->selectionHeight(); | 189 LayoutUnit selBottom = paintOffset.y() + selTop + m_inlineBoxWrapper->ro
ot()->selectionHeight(); |
191 top = min(selTop, top); | 190 top = min(selTop, top); |
192 bottom = max(selBottom, bottom); | 191 bottom = max(selBottom, bottom); |
193 } | 192 } |
194 | 193 |
195 LayoutRect localRepaintRect = paintInfo.rect; | 194 LayoutRect localRepaintRect = paintInfo.getRect(); |
196 localRepaintRect.inflate(maximalOutlineSize(paintInfo.phase)); | 195 localRepaintRect.inflate(maximalOutlineSize(paintInfo.getPhase())); |
197 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= localRepaintRect.m
axX() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= localRepaintRe
ct.x()) | 196 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= localRepaintRect.m
axX() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= localRepaintRe
ct.x()) |
198 return false; | 197 return false; |
199 | 198 |
200 if (top >= localRepaintRect.maxY() || bottom <= localRepaintRect.y()) | 199 if (top >= localRepaintRect.maxY() || bottom <= localRepaintRect.y()) |
201 return false; | 200 return false; |
202 | 201 |
203 return true; | 202 return true; |
204 } | 203 } |
205 | 204 |
206 static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderRepl
aced* replaced) | 205 static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderRepl
aced* replaced) |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 573 |
575 if (style()) { | 574 if (style()) { |
576 if (v) | 575 if (v) |
577 r.inflate(style()->outlineSize()); | 576 r.inflate(style()->outlineSize()); |
578 } | 577 } |
579 computeRectForRepaint(repaintContainer, r); | 578 computeRectForRepaint(repaintContainer, r); |
580 return r; | 579 return r; |
581 } | 580 } |
582 | 581 |
583 } | 582 } |
OLD | NEW |