OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2014, Google Inc. All rights reserved. | |
pdr.
2014/07/28 16:23:52
Please use the new copyright boilerplate for new f
Shanmuga Pandi
2014/08/01 05:20:39
Done.
| |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 | |
33 #include "core/rendering/RenderLayerClipPathInfo.h" | |
34 | |
35 #include "core/fetch/DocumentResourceReference.h" | |
36 #include "core/rendering/RenderLayer.h" | |
37 #include "core/rendering/svg/RenderSVGResourceContainer.h" | |
38 | |
39 namespace blink { | |
40 | |
41 RenderLayerClipPathInfoMap* RenderLayerClipPathInfo::s_clipPathMap = 0; | |
pdr.
2014/07/28 16:23:52
This patch looks like it's nearly the exact same a
Stephen White
2014/07/29 15:12:26
+1 to this.
Shanmuga Pandi
2014/07/30 11:31:02
Yes. I agree.
But Can you let me know, how do we
Shanmuga Pandi
2014/08/01 05:20:39
I have removed unnecessary hashmap code, and added
| |
42 | |
43 RenderLayerClipPathInfo* RenderLayerClipPathInfo::clipPathInfoForRenderLayer(con st RenderLayer* layer) | |
44 { | |
45 if (!s_clipPathMap) | |
46 return 0; | |
47 RenderLayerClipPathInfoMap::iterator iter = s_clipPathMap->find(layer); | |
48 return (iter != s_clipPathMap->end()) ? iter->value : 0; | |
49 } | |
50 | |
51 RenderLayerClipPathInfo* RenderLayerClipPathInfo::createClipPathInfoForRenderLay erIfNeeded(RenderLayer* layer) | |
52 { | |
53 if (!s_clipPathMap) | |
54 s_clipPathMap = new RenderLayerClipPathInfoMap(); | |
55 | |
56 RenderLayerClipPathInfoMap::iterator iter = s_clipPathMap->find(layer); | |
57 if (iter != s_clipPathMap->end()) { | |
58 ASSERT(layer->hasClipPathInfo()); | |
59 return iter->value; | |
60 } | |
61 | |
62 RenderLayerClipPathInfo* clipPath = new RenderLayerClipPathInfo(layer); | |
63 s_clipPathMap->set(layer, clipPath); | |
64 layer->setHasClipPathInfo(true); | |
65 return clipPath; | |
66 } | |
67 | |
68 void RenderLayerClipPathInfo::removeClipPathInfoForRenderLayer(RenderLayer* laye r) | |
69 { | |
70 if (!s_clipPathMap) | |
71 return; | |
72 RenderLayerClipPathInfo* clipPath = s_clipPathMap->take(layer); | |
73 if (s_clipPathMap->isEmpty()) { | |
74 delete s_clipPathMap; | |
75 s_clipPathMap = 0; | |
76 } | |
77 if (!clipPath) { | |
78 ASSERT(!layer->hasClipPathInfo()); | |
79 return; | |
80 } | |
81 layer->setHasClipPathInfo(false); | |
82 delete clipPath; | |
83 } | |
84 | |
85 RenderLayerClipPathInfo::RenderLayerClipPathInfo(RenderLayer* layer) | |
86 : m_layer(layer) | |
87 { | |
88 } | |
89 | |
90 RenderLayerClipPathInfo::~RenderLayerClipPathInfo() | |
91 { | |
92 removeReferenceClipPathClients(); | |
93 } | |
94 | |
95 void RenderLayerClipPathInfo::updateReferenceClipPathClients(ClipPathOperation* clipPathOperation) | |
96 { | |
97 removeReferenceClipPathClients(); | |
98 if (clipPathOperation->type() != ClipPathOperation::REFERENCE) | |
f(malita)
2014/07/29 01:21:16
This should be an ASSERT.
Shanmuga Pandi
2014/07/30 11:31:02
Acknowledged.
| |
99 return; | |
100 ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPath Operation(clipPathOperation); | |
101 Element* clipPath = m_layer->renderer()->node()->document().getElementById(r eferenceClipPathOperation->fragment()); | |
102 if (!isSVGClipPathElement(clipPath)) | |
103 return; | |
104 if (clipPath->renderer()) | |
105 toRenderSVGResourceContainer(clipPath->renderer())->addClientRenderLayer (m_layer); | |
106 else | |
107 toSVGClipPathElement(clipPath)->addClient(m_layer->renderer()->node()); | |
108 | |
109 m_clipPathElement = PassRefPtr<SVGClipPathElement>(toSVGClipPathElement(clip Path)); | |
110 } | |
111 | |
112 void RenderLayerClipPathInfo::removeReferenceClipPathClients() | |
113 { | |
114 if (!m_clipPathElement) | |
115 return; | |
116 | |
117 if (m_clipPathElement->renderer()) | |
118 toRenderSVGResourceContainer(m_clipPathElement->renderer())->removeClien tRenderLayer(m_layer); | |
119 else | |
120 m_clipPathElement->removeClient(m_layer->renderer()->node()); | |
121 | |
122 m_clipPathElement.clear(); | |
123 } | |
124 | |
125 } // namespace blink | |
OLD | NEW |