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

Side by Side Diff: Source/core/rendering/RenderWidget.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, 2009, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2013 Google Inc. All rights reserved. 5 * Copyright (C) 2013 Google Inc. 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 229 void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
230 { 230 {
231 LayoutPoint adjustedPaintOffset = paintOffset + location(); 231 LayoutPoint adjustedPaintOffset = paintOffset + location();
232 232
233 // Tell the widget to paint now. This is the only time the widget is allowed 233 // Tell the widget to paint now. This is the only time the widget is allowed
234 // to paint itself. That way it will composite properly with z-indexed layer s. 234 // to paint itself. That way it will composite properly with z-indexed layer s.
235 IntPoint widgetLocation = m_widget->frameRect().location(); 235 IntPoint widgetLocation = m_widget->frameRect().location();
236 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p addingLeft()), 236 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p addingLeft()),
237 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); 237 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
238 IntRect paintRect = paintInfo.rect; 238 IntRect paintRect = paintInfo.getRect();
239 239
240 IntSize widgetPaintOffset = paintLocation - widgetLocation; 240 IntSize widgetPaintOffset = paintLocation - widgetLocation;
241 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer, 241 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
242 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing. 242 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
243 if (!widgetPaintOffset.isZero()) { 243 if (!widgetPaintOffset.isZero()) {
244 paintInfo.context->translate(widgetPaintOffset); 244 paintInfo.getContext()->translate(widgetPaintOffset);
245 paintRect.move(-widgetPaintOffset); 245 paintRect.move(-widgetPaintOffset);
246 } 246 }
247 m_widget->paint(paintInfo.context, paintRect); 247 m_widget->paint(paintInfo.getContext(), paintRect);
248 248
249 if (!widgetPaintOffset.isZero()) 249 if (!widgetPaintOffset.isZero())
250 paintInfo.context->translate(-widgetPaintOffset); 250 paintInfo.getContext()->translate(-widgetPaintOffset);
251 251
252 if (m_widget->isFrameView()) { 252 if (m_widget->isFrameView()) {
253 FrameView* frameView = toFrameView(m_widget.get()); 253 FrameView* frameView = toFrameView(m_widget.get());
254 bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || f rameView->hasCompositedContent(); 254 bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || f rameView->hasCompositedContent();
255 if (paintInfo.overlapTestRequests && runOverlapTests) { 255 if (paintInfo.getOverlapTestRequests() && runOverlapTests) {
256 ASSERT(!paintInfo.overlapTestRequests->contains(this)); 256 ASSERT(!paintInfo.getOverlapTestRequests()->contains(this));
257 paintInfo.overlapTestRequests->set(this, m_widget->frameRect()); 257 paintInfo.getOverlapTestRequests()->set(this, m_widget->frameRect()) ;
258 } 258 }
259 } 259 }
260 } 260 }
261 261
262 void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 262 void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
263 { 263 {
264 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); 264 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
265 265
266 if (!shouldPaint(paintInfo, paintOffset)) 266 if (!shouldPaint(paintInfo, paintOffset))
267 return; 267 return;
268 268
269 LayoutPoint adjustedPaintOffset = paintOffset + location(); 269 LayoutPoint adjustedPaintOffset = paintOffset + location();
270 270
271 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paint Info.phase == PaintPhaseSelection)) 271 if (hasBoxDecorations() && (paintInfo.getPhase() == PaintPhaseForeground || paintInfo.getPhase() == PaintPhaseSelection))
272 paintBoxDecorations(paintInfo, adjustedPaintOffset); 272 paintBoxDecorations(paintInfo, adjustedPaintOffset);
273 273
274 if (paintInfo.phase == PaintPhaseMask) { 274 if (paintInfo.getPhase() == PaintPhaseMask) {
275 paintMask(paintInfo, adjustedPaintOffset); 275 paintMask(paintInfo, adjustedPaintOffset);
276 return; 276 return;
277 } 277 }
278 278
279 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && hasOutline()) 279 if ((paintInfo.getPhase() == PaintPhaseOutline || paintInfo.getPhase() == Pa intPhaseSelfOutline) && hasOutline())
280 paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size())); 280 paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size()));
281 281
282 if (!m_frameView || paintInfo.phase != PaintPhaseForeground) 282 if (!m_frameView || paintInfo.getPhase() != PaintPhaseForeground)
283 return; 283 return;
284 284
285 if (style()->hasBorderRadius()) { 285 if (style()->hasBorderRadius()) {
286 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); 286 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());
287 287
288 if (borderRect.isEmpty()) 288 if (borderRect.isEmpty())
289 return; 289 return;
290 290
291 // Push a clip if we have a border radius, since we want to round the fo reground content that gets painted. 291 // Push a clip if we have a border radius, since we want to round the fo reground content that gets painted.
292 paintInfo.context->save(); 292 paintInfo.getContext()->save();
293 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR ect, 293 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR ect,
294 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin gLeft() + borderLeft(), paddingRight() + borderRight(), true, true); 294 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin gLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
295 clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect); 295 clipRoundedInnerRect(paintInfo.getContext(), borderRect, roundedInnerRec t);
296 } 296 }
297 297
298 if (m_widget) 298 if (m_widget)
299 paintContents(paintInfo, paintOffset); 299 paintContents(paintInfo, paintOffset);
300 300
301 if (style()->hasBorderRadius()) 301 if (style()->hasBorderRadius())
302 paintInfo.context->restore(); 302 paintInfo.getContext()->restore();
303 303
304 // Paint a partially transparent wash over selected widgets. 304 // Paint a partially transparent wash over selected widgets.
305 if (isSelected() && !document()->printing()) { 305 if (isSelected() && !document()->printing()) {
306 // FIXME: selectionRect() is in absolute, not painting coordinates. 306 // FIXME: selectionRect() is in absolute, not painting coordinates.
307 paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), select ionBackgroundColor()); 307 paintInfo.getContext()->fillRect(pixelSnappedIntRect(selectionRect()), s electionBackgroundColor());
308 } 308 }
309 309
310 if (hasLayer() && layer()->canResize()) 310 if (hasLayer() && layer()->canResize())
311 layer()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOf fset), paintInfo.rect); 311 layer()->paintResizer(paintInfo.getContext(), roundedIntPoint(adjustedPa intOffset), paintInfo.getRect());
312 } 312 }
313 313
314 void RenderWidget::setOverlapTestResult(bool isOverlapped) 314 void RenderWidget::setOverlapTestResult(bool isOverlapped)
315 { 315 {
316 ASSERT(m_widget); 316 ASSERT(m_widget);
317 ASSERT(m_widget->isFrameView()); 317 ASSERT(m_widget->isFrameView());
318 toFrameView(m_widget.get())->setIsOverlapped(isOverlapped); 318 toFrameView(m_widget.get())->setIsOverlapped(isOverlapped);
319 } 319 }
320 320
321 void RenderWidget::deref(RenderArena *arena) 321 void RenderWidget::deref(RenderArena *arena)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 CursorDirective RenderWidget::getCursor(const LayoutPoint& point, Cursor& cursor ) const 380 CursorDirective RenderWidget::getCursor(const LayoutPoint& point, Cursor& cursor ) const
381 { 381 {
382 if (widget() && widget()->isPluginView()) { 382 if (widget() && widget()->isPluginView()) {
383 // A plug-in is responsible for setting the cursor when the pointer is o ver it. 383 // A plug-in is responsible for setting the cursor when the pointer is o ver it.
384 return DoNotSetCursor; 384 return DoNotSetCursor;
385 } 385 }
386 return RenderReplaced::getCursor(point, cursor); 386 return RenderReplaced::getCursor(point, cursor);
387 } 387 }
388 388
389 } // namespace WebCore 389 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698