Chromium Code Reviews| Index: Source/core/rendering/RenderLayerClipPathInfo.cpp |
| diff --git a/Source/core/rendering/RenderLayerClipPathInfo.cpp b/Source/core/rendering/RenderLayerClipPathInfo.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dbc8bfb7bbf8d75996abfae5c9de9b7a120bc4d8 |
| --- /dev/null |
| +++ b/Source/core/rendering/RenderLayerClipPathInfo.cpp |
| @@ -0,0 +1,125 @@ |
| +/* |
| + * 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.
|
| + * |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions are |
| + * met: |
| + * |
| + * * Redistributions of source code must retain the above copyright |
| + * notice, this list of conditions and the following disclaimer. |
| + * * Redistributions in binary form must reproduce the above |
| + * copyright notice, this list of conditions and the following disclaimer |
| + * in the documentation and/or other materials provided with the |
| + * distribution. |
| + * * Neither the name of Google Inc. nor the names of its |
| + * contributors may be used to endorse or promote products derived from |
| + * this software without specific prior written permission. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + */ |
| + |
| +#include "config.h" |
| + |
| +#include "core/rendering/RenderLayerClipPathInfo.h" |
| + |
| +#include "core/fetch/DocumentResourceReference.h" |
| +#include "core/rendering/RenderLayer.h" |
| +#include "core/rendering/svg/RenderSVGResourceContainer.h" |
| + |
| +namespace blink { |
| + |
| +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
|
| + |
| +RenderLayerClipPathInfo* RenderLayerClipPathInfo::clipPathInfoForRenderLayer(const RenderLayer* layer) |
| +{ |
| + if (!s_clipPathMap) |
| + return 0; |
| + RenderLayerClipPathInfoMap::iterator iter = s_clipPathMap->find(layer); |
| + return (iter != s_clipPathMap->end()) ? iter->value : 0; |
| +} |
| + |
| +RenderLayerClipPathInfo* RenderLayerClipPathInfo::createClipPathInfoForRenderLayerIfNeeded(RenderLayer* layer) |
| +{ |
| + if (!s_clipPathMap) |
| + s_clipPathMap = new RenderLayerClipPathInfoMap(); |
| + |
| + RenderLayerClipPathInfoMap::iterator iter = s_clipPathMap->find(layer); |
| + if (iter != s_clipPathMap->end()) { |
| + ASSERT(layer->hasClipPathInfo()); |
| + return iter->value; |
| + } |
| + |
| + RenderLayerClipPathInfo* clipPath = new RenderLayerClipPathInfo(layer); |
| + s_clipPathMap->set(layer, clipPath); |
| + layer->setHasClipPathInfo(true); |
| + return clipPath; |
| +} |
| + |
| +void RenderLayerClipPathInfo::removeClipPathInfoForRenderLayer(RenderLayer* layer) |
| +{ |
| + if (!s_clipPathMap) |
| + return; |
| + RenderLayerClipPathInfo* clipPath = s_clipPathMap->take(layer); |
| + if (s_clipPathMap->isEmpty()) { |
| + delete s_clipPathMap; |
| + s_clipPathMap = 0; |
| + } |
| + if (!clipPath) { |
| + ASSERT(!layer->hasClipPathInfo()); |
| + return; |
| + } |
| + layer->setHasClipPathInfo(false); |
| + delete clipPath; |
| +} |
| + |
| +RenderLayerClipPathInfo::RenderLayerClipPathInfo(RenderLayer* layer) |
| + : m_layer(layer) |
| +{ |
| +} |
| + |
| +RenderLayerClipPathInfo::~RenderLayerClipPathInfo() |
| +{ |
| + removeReferenceClipPathClients(); |
| +} |
| + |
| +void RenderLayerClipPathInfo::updateReferenceClipPathClients(ClipPathOperation* clipPathOperation) |
| +{ |
| + removeReferenceClipPathClients(); |
| + 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.
|
| + return; |
| + ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(clipPathOperation); |
| + Element* clipPath = m_layer->renderer()->node()->document().getElementById(referenceClipPathOperation->fragment()); |
| + if (!isSVGClipPathElement(clipPath)) |
| + return; |
| + if (clipPath->renderer()) |
| + toRenderSVGResourceContainer(clipPath->renderer())->addClientRenderLayer(m_layer); |
| + else |
| + toSVGClipPathElement(clipPath)->addClient(m_layer->renderer()->node()); |
| + |
| + m_clipPathElement = PassRefPtr<SVGClipPathElement>(toSVGClipPathElement(clipPath)); |
| +} |
| + |
| +void RenderLayerClipPathInfo::removeReferenceClipPathClients() |
| +{ |
| + if (!m_clipPathElement) |
| + return; |
| + |
| + if (m_clipPathElement->renderer()) |
| + toRenderSVGResourceContainer(m_clipPathElement->renderer())->removeClientRenderLayer(m_layer); |
| + else |
| + m_clipPathElement->removeClient(m_layer->renderer()->node()); |
| + |
| + m_clipPathElement.clear(); |
| +} |
| + |
| +} // namespace blink |