2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
28 #include "AffineTransform.h"
29 #include "GraphicsContext.h"
31 #include "LayoutRect.h"
32 #include "PaintPhase.h"
34 #include <wtf/HashMap.h>
35 #include <wtf/ListHashSet.h>
39 class OverlapTestRequestClient;
42 class RenderLayerModelObject;
45 typedef HashMap<OverlapTestRequestClient*, IntRect> OverlapTestRequestMap;
48 * Paint the object and its children, clipped by (x|y|w|h).
49 * (tx|ty) is the calculated position of the parent
52 PaintInfo(GraphicsContext& newContext, const LayoutRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
53 RenderObject* newSubtreePaintRoot = nullptr, ListHashSet<RenderInline*>* newOutlineObjects = nullptr,
54 OverlapTestRequestMap* overlapTestRequests = nullptr, const RenderLayerModelObject* newPaintContainer = nullptr,
55 const RenderLayer* enclosingSelfPaintingLayer = nullptr, bool newRequireSecurityOriginAccessForWidgets = false)
58 , paintBehavior(newPaintBehavior)
59 , subtreePaintRoot(newSubtreePaintRoot)
60 , outlineObjects(newOutlineObjects)
61 , overlapTestRequests(overlapTestRequests)
62 , paintContainer(newPaintContainer)
63 , requireSecurityOriginAccessForWidgets(newRequireSecurityOriginAccessForWidgets)
64 , m_enclosingSelfPaintingLayer(enclosingSelfPaintingLayer)
65 , m_context(&newContext)
69 GraphicsContext& context() const
75 void setContext(GraphicsContext& context)
80 void updateSubtreePaintRootForChildren(const RenderObject* renderer)
82 if (!subtreePaintRoot)
85 // If we're the painting root, kids draw normally, and see root of nullptr.
86 if (subtreePaintRoot == renderer) {
87 subtreePaintRoot = nullptr;
92 bool shouldPaintWithinRoot(const RenderObject& renderer) const
94 return !subtreePaintRoot || subtreePaintRoot == &renderer;
97 bool forceTextColor() const { return forceBlackText() || forceWhiteText(); }
98 bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
99 bool forceWhiteText() const { return paintBehavior & PaintBehaviorForceWhiteText; }
100 Color forcedTextColor() const { return (forceBlackText()) ? Color::black : Color::white; }
102 bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; }
103 bool paintRootBackgroundOnly() const { return paintBehavior & PaintBehaviorRootBackgroundOnly; }
105 const RenderLayer* enclosingSelfPaintingLayer() const { return m_enclosingSelfPaintingLayer; }
107 void applyTransform(const AffineTransform& localToAncestorTransform)
109 if (localToAncestorTransform.isIdentity())
112 context().concatCTM(localToAncestorTransform);
114 if (rect.isInfinite())
117 FloatRect tranformedRect(localToAncestorTransform.inverse().value_or(AffineTransform()).mapRect(rect));
118 rect.setLocation(LayoutPoint(tranformedRect.location()));
119 rect.setSize(LayoutSize(tranformedRect.size()));
124 PaintBehavior paintBehavior;
125 RenderObject* subtreePaintRoot; // used to draw just one element and its visual children
126 ListHashSet<RenderInline*>* outlineObjects; // used to list outlines that should be painted by a block with inline children
127 OverlapTestRequestMap* overlapTestRequests;
128 const RenderLayerModelObject* paintContainer; // the layer object that originates the current painting
129 bool requireSecurityOriginAccessForWidgets { false };
130 const RenderLayer* m_enclosingSelfPaintingLayer { nullptr };
133 GraphicsContext* m_context;
136 } // namespace WebCore