15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2006 Apple Computer, Inc. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) Research In Motion Limited 2010. All rights reserved. 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is free software; you can redistribute it and/or 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modify it under the terms of the GNU Library General Public 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * License as published by the Free Software Foundation; either 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * version 2 of the License, or (at your option) any later version. 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is distributed in the hope that it will be useful, 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Library General Public License for more details. 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * You should have received a copy of the GNU Library General Public License 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * along with this library; see the file COPYING.LIB. If not, write to 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Boston, MA 02110-1301, USA. 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h" 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/svg/RenderSVGBlock.h" 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 26323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)#include "core/rendering/RenderView.h" 27f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#include "core/rendering/style/ShadowList.h" 2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/rendering/svg/SVGRenderSupport.h" 2953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/svg/SVGResourcesCache.h" 3053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/svg/SVGElement.h" 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 34926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)RenderSVGBlock::RenderSVGBlock(SVGElement* element) 358abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) : RenderBlockFlow(element) 365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)LayoutRect RenderSVGBlock::visualOverflowRect() const 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) LayoutRect borderRect = borderBoxRect(); 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 43f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) if (const ShadowList* textShadow = style()->textShadow()) 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) textShadow->adjustRectForShadow(borderRect); 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return borderRect; 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void RenderSVGBlock::updateFromStyle() 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RenderBlock::updateFromStyle(); 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // RenderSVGlock, used by Render(SVGText|ForeignObject), is not allowed to call setHasOverflowClip(true). 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // RenderBlock assumes a layer to be present when the overflow clip functionality is requested. Both 5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // Render(SVGText|ForeignObject) return 'NoLayer' on 'layerTypeRequired'. Fine for RenderSVGText. 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // If we want to support overflow rules for <foreignObject> we can choose between two solutions: 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // a) make RenderSVGForeignObject require layers and SVG layer aware 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010). 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Note: This does NOT affect overflow handling on outer/inner <svg> elements - this is handled 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // manually by RenderSVGRoot - which owns the documents enclosing root layer and thus works fine. 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setHasOverflowClip(false); 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void RenderSVGBlock::absoluteRects(Vector<IntRect>&, const LayoutPoint&) const 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used. 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT_NOT_REACHED(); 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void RenderSVGBlock::willBeDestroyed() 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SVGResourcesCache::clientDestroyed(this); 7751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) RenderBlockFlow::willBeDestroyed(); 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 80f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 8210f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (diff.needsFullLayout()) 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsBoundariesUpdate(); 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RenderBlock::styleDidChange(diff, oldStyle); 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SVGResourcesCache::clientStyleChanged(this, diff, style()); 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 89e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)void RenderSVGBlock::mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const 9009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 91e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) SVGRenderSupport::mapLocalToContainer(this, paintInvalidationContainer, transformState, wasFixed, paintInvalidationState); 9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)const RenderObject* RenderSVGBlock::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const 9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 9609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap); 9709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 9809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 99197021e6b966cfb06891637935ef33fff06433d1Ben MurdochLayoutRect RenderSVGBlock::clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) const 10009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 101e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) return SVGRenderSupport::clippedOverflowRectForPaintInvalidation(this, paintInvalidationContainer, paintInvalidationState); 10209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 10309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 1049e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)void RenderSVGBlock::computeFloatRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, FloatRect& paintInvalidationRect, const PaintInvalidationState* paintInvalidationState) const 10509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 1069e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles) SVGRenderSupport::computeFloatRectForPaintInvalidation(this, paintInvalidationContainer, paintInvalidationRect, paintInvalidationState); 10709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 10809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 10909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)bool RenderSVGBlock::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) 11009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 11109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) ASSERT_NOT_REACHED(); 11209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return false; 11309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 11409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 115197021e6b966cfb06891637935ef33fff06433d1Ben Murdochvoid RenderSVGBlock::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState) 116323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles){ 117c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) if (!shouldCheckForPaintInvalidation(paintInvalidationState)) 118323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) return; 119323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 120197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ForceHorriblySlowRectMapping slowRectMapping(&paintInvalidationState); 121197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch RenderBlockFlow::invalidateTreeIfNeeded(paintInvalidationState); 122323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)} 123323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 125