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

Side by Side Diff: Source/core/rendering/RenderReplaced.cpp

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

Powered by Google App Engine
This is Rietveld 408576698