OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | |
3 * | |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | |
5 * | |
6 * Other contributors: | |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | |
8 * David Baron <dbaron@fas.harvard.edu> | |
9 * Christian Biesinger <cbiesinger@web.de> | |
10 * Randall Jesup <rjesup@wgate.com> | |
11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> | |
12 * Josh Soref <timeless@mac.com> | |
13 * Boris Zbarsky <bzbarsky@mit.edu> | |
14 * | |
15 * This library is free software; you can redistribute it and/or | |
16 * modify it under the terms of the GNU Lesser General Public | |
17 * License as published by the Free Software Foundation; either | |
18 * version 2.1 of the License, or (at your option) any later version. | |
19 * | |
20 * This library is distributed in the hope that it will be useful, | |
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
23 * Lesser General Public License for more details. | |
24 * | |
25 * You should have received a copy of the GNU Lesser General Public | |
26 * License along with this library; if not, write to the Free Software | |
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
A | |
28 * | |
29 * Alternatively, the contents of this file may be used under the terms | |
30 * of either the Mozilla Public License Version 1.1, found at | |
31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public | |
32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html | |
33 * (the "GPL"), in which case the provisions of the MPL or the GPL are | |
34 * applicable instead of those above. If you wish to allow use of your | |
35 * version of this file only under the terms of one of those two | |
36 * licenses (the MPL or the GPL) and not to allow others to use your | |
37 * version of this file under the LGPL, indicate your decision by | |
38 * deletingthe provisions above and replace them with the notice and | |
39 * other provisions required by the MPL or the GPL, as the case may be. | |
40 * If you do not delete the provisions above, a recipient may use your | |
41 * version of this file under any of the LGPL, the MPL or the GPL. | |
42 */ | |
43 | |
44 #include "config.h" | |
45 #include "core/rendering/RenderLayerBlendInfo.h" | |
46 | |
47 #include "core/rendering/RenderLayer.h" | |
48 #include "core/rendering/RenderLayerModelObject.h" | |
49 #include "core/rendering/compositing/CompositedLayerMapping.h" | |
50 #include "platform/RuntimeEnabledFeatures.h" | |
51 | |
52 namespace blink { | |
53 | |
54 RenderLayerBlendInfo::RenderLayerBlendInfo(RenderLayerModelObject& renderer) | |
55 : m_renderer(renderer) | |
56 , m_blendMode(blink::WebBlendModeNormal) | |
57 , m_childLayerHasBlendMode(false) | |
58 , m_childLayerHasBlendModeStatusDirty(false) | |
59 { | |
60 } | |
61 | |
62 bool RenderLayerBlendInfo::hasBlendMode() const | |
63 { | |
64 return RuntimeEnabledFeatures::cssCompositingEnabled() && m_renderer.hasBlen
dMode(); | |
65 } | |
66 | |
67 void RenderLayerBlendInfo::updateBlendMode() | |
68 { | |
69 if (!RuntimeEnabledFeatures::cssCompositingEnabled()) | |
70 return; | |
71 | |
72 blink::WebBlendMode newBlendMode = m_renderer.style()->blendMode(); | |
73 if (newBlendMode == m_blendMode) | |
74 return; | |
75 | |
76 bool hadBlendMode = m_blendMode != blink::WebBlendModeNormal; | |
77 m_blendMode = newBlendMode; | |
78 | |
79 RenderLayer* layer = m_renderer.layer(); | |
80 // Only update the flag if a blend mode is set or unset. | |
81 if (layer->parent() && (!hadBlendMode || !hasBlendMode())) | |
82 layer->parent()->blendInfo().dirtyAncestorChainBlendedDescendantStatus()
; | |
83 | |
84 if (layer->hasCompositedLayerMapping()) | |
85 layer->compositedLayerMapping()->setBlendMode(newBlendMode); | |
86 } | |
87 | |
88 void RenderLayerBlendInfo::dirtyAncestorChainBlendedDescendantStatus() | |
89 { | |
90 for (RenderLayer* layer = m_renderer.layer(); layer; layer = layer->parent()
) { | |
91 if (layer->blendInfo().childLayerHasBlendModeStatusDirty()) | |
92 break; | |
93 | |
94 layer->blendInfo().setChildLayerHasBlendModeStatusDirty(true); | |
95 | |
96 if (layer->stackingNode()->isStackingContext()) | |
97 break; | |
98 } | |
99 } | |
100 | |
101 void RenderLayerBlendInfo::setAncestorChainBlendedDescendant() | |
102 { | |
103 for (RenderLayer* layer = m_renderer.layer(); layer; layer = layer->parent()
) { | |
104 if (!layer->blendInfo().childLayerHasBlendModeStatusDirty() && layer->bl
endInfo().childLayerHasBlendMode()) | |
105 break; | |
106 | |
107 layer->blendInfo().setChildLayerHasBlendMode(true); | |
108 layer->blendInfo().setChildLayerHasBlendModeStatusDirty(false); | |
109 | |
110 if (layer->stackingNode()->isStackingContext()) | |
111 break; | |
112 } | |
113 } | |
114 | |
115 } // namespace blink | |
OLD | NEW |