zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 1 | /* |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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. |
| 23 | * |
| 24 | */ |
| 25 | |
commit-queue@webkit.org | 46c0f52 | 2016-11-13 10:05:43 +0000 | [diff] [blame] | 26 | #pragma once |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 27 | |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 28 | #include "AffineTransform.h" |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 29 | #include "GraphicsContext.h" |
| 30 | #include "IntRect.h" |
eae@chromium.org | 9717cd8 | 2012-11-07 18:33:44 +0000 | [diff] [blame] | 31 | #include "LayoutRect.h" |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 32 | #include "PaintPhase.h" |
leviw@chromium.org | 848025e | 2012-05-03 21:07:32 +0000 | [diff] [blame] | 33 | #include <limits> |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 34 | #include <wtf/HashMap.h> |
| 35 | #include <wtf/ListHashSet.h> |
| 36 | |
| 37 | namespace WebCore { |
| 38 | |
| 39 | class OverlapTestRequestClient; |
| 40 | class RenderInline; |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 41 | class RenderLayerModelObject; |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 42 | class RenderObject; |
| 43 | |
| 44 | typedef HashMap<OverlapTestRequestClient*, IntRect> OverlapTestRequestMap; |
| 45 | |
| 46 | /* |
| 47 | * Paint the object and its children, clipped by (x|y|w|h). |
| 48 | * (tx|ty) is the calculated position of the parent |
| 49 | */ |
| 50 | struct PaintInfo { |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 51 | PaintInfo(GraphicsContext& newContext, const LayoutRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior, |
abucur@adobe.com | 7f9668a | 2014-05-16 13:22:00 +0000 | [diff] [blame] | 52 | RenderObject* newSubtreePaintRoot = nullptr, ListHashSet<RenderInline*>* newOutlineObjects = nullptr, |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 53 | OverlapTestRequestMap* overlapTestRequests = nullptr, const RenderLayerModelObject* newPaintContainer = nullptr) |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 54 | : rect(newRect) |
stavila@adobe.com | f1ddee6 | 2014-02-21 15:29:49 +0000 | [diff] [blame] | 55 | , phase(newPhase) |
| 56 | , paintBehavior(newPaintBehavior) |
| 57 | , subtreePaintRoot(newSubtreePaintRoot) |
stavila@adobe.com | f1ddee6 | 2014-02-21 15:29:49 +0000 | [diff] [blame] | 58 | , outlineObjects(newOutlineObjects) |
| 59 | , overlapTestRequests(overlapTestRequests) |
| 60 | , paintContainer(newPaintContainer) |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 61 | , m_context(&newContext) |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 62 | { |
| 63 | } |
| 64 | |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 65 | GraphicsContext& context() const |
| 66 | { |
| 67 | ASSERT(m_context); |
| 68 | return *m_context; |
| 69 | } |
| 70 | |
| 71 | void setContext(GraphicsContext& context) |
| 72 | { |
| 73 | m_context = &context; |
| 74 | } |
| 75 | |
simon.fraser@apple.com | e7b410b | 2013-05-19 22:52:34 +0000 | [diff] [blame] | 76 | void updateSubtreePaintRootForChildren(const RenderObject* renderer) |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 77 | { |
simon.fraser@apple.com | e7b410b | 2013-05-19 22:52:34 +0000 | [diff] [blame] | 78 | if (!subtreePaintRoot) |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 79 | return; |
| 80 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 81 | // If we're the painting root, kids draw normally, and see root of nullptr. |
simon.fraser@apple.com | e7b410b | 2013-05-19 22:52:34 +0000 | [diff] [blame] | 82 | if (subtreePaintRoot == renderer) { |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 83 | subtreePaintRoot = nullptr; |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 84 | return; |
| 85 | } |
| 86 | } |
| 87 | |
antti@apple.com | 6fa2c9f | 2013-10-06 22:55:54 +0000 | [diff] [blame] | 88 | bool shouldPaintWithinRoot(const RenderObject& renderer) const |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 89 | { |
antti@apple.com | 6fa2c9f | 2013-10-06 22:55:54 +0000 | [diff] [blame] | 90 | return !subtreePaintRoot || subtreePaintRoot == &renderer; |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 91 | } |
| 92 | |
commit-queue@webkit.org | baadf5f | 2014-08-05 23:40:24 +0000 | [diff] [blame] | 93 | bool forceTextColor() const { return forceBlackText() || forceWhiteText(); } |
simon.fraser@apple.com | 2bedf6f | 2013-01-16 20:00:52 +0000 | [diff] [blame] | 94 | bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; } |
commit-queue@webkit.org | baadf5f | 2014-08-05 23:40:24 +0000 | [diff] [blame] | 95 | bool forceWhiteText() const { return paintBehavior & PaintBehaviorForceWhiteText; } |
| 96 | Color forcedTextColor() const { return (forceBlackText()) ? Color::black : Color::white; } |
simon.fraser@apple.com | 2bedf6f | 2013-01-16 20:00:52 +0000 | [diff] [blame] | 97 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 98 | bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; } |
| 99 | bool paintRootBackgroundOnly() const { return paintBehavior & PaintBehaviorRootBackgroundOnly; } |
| 100 | |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 101 | void applyTransform(const AffineTransform& localToAncestorTransform) |
| 102 | { |
| 103 | if (localToAncestorTransform.isIdentity()) |
| 104 | return; |
| 105 | |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 106 | context().concatCTM(localToAncestorTransform); |
zimmermann@webkit.org | 0cfc11b | 2010-08-19 12:41:23 +0000 | [diff] [blame] | 107 | |
zalan@apple.com | ccc2ae3 | 2015-01-16 00:11:27 +0000 | [diff] [blame] | 108 | if (rect.isInfinite()) |
zimmermann@webkit.org | 0cfc11b | 2010-08-19 12:41:23 +0000 | [diff] [blame] | 109 | return; |
| 110 | |
utatane.tea@gmail.com | 4392696 | 2016-11-27 06:08:16 +0000 | [diff] [blame] | 111 | FloatRect tranformedRect(localToAncestorTransform.inverse().value_or(AffineTransform()).mapRect(rect)); |
zalan@apple.com | 5f08e99 | 2014-01-24 23:35:07 +0000 | [diff] [blame] | 112 | rect.setLocation(LayoutPoint(tranformedRect.location())); |
| 113 | rect.setSize(LayoutSize(tranformedRect.size())); |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 114 | } |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 115 | |
zalan@apple.com | 5f08e99 | 2014-01-24 23:35:07 +0000 | [diff] [blame] | 116 | LayoutRect rect; |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 117 | PaintPhase phase; |
simon.fraser@apple.com | 2bedf6f | 2013-01-16 20:00:52 +0000 | [diff] [blame] | 118 | PaintBehavior paintBehavior; |
simon.fraser@apple.com | e7b410b | 2013-05-19 22:52:34 +0000 | [diff] [blame] | 119 | RenderObject* subtreePaintRoot; // used to draw just one element and its visual children |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 120 | ListHashSet<RenderInline*>* outlineObjects; // used to list outlines that should be painted by a block with inline children |
| 121 | OverlapTestRequestMap* overlapTestRequests; |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 122 | const RenderLayerModelObject* paintContainer; // the layer object that originates the current painting |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 123 | |
| 124 | private: |
| 125 | GraphicsContext* m_context; |
zimmermann@webkit.org | 427c02f | 2010-06-29 12:14:53 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | } // namespace WebCore |