Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: Source/core/rendering/svg/RenderSVGRoot.cpp

Issue 220853002: SVG does not respect overflow:visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // At this point LayoutRepainter already grabbed the old bounds, 186 // At this point LayoutRepainter already grabbed the old bounds,
187 // recalculate them now so repaintAfterLayout() uses the new bounds. 187 // recalculate them now so repaintAfterLayout() uses the new bounds.
188 if (m_needsBoundariesOrTransformUpdate) { 188 if (m_needsBoundariesOrTransformUpdate) {
189 updateCachedBoundaries(); 189 updateCachedBoundaries();
190 m_needsBoundariesOrTransformUpdate = false; 190 m_needsBoundariesOrTransformUpdate = false;
191 } 191 }
192 192
193 m_overflow.clear(); 193 m_overflow.clear();
194 addVisualEffectOverflow(); 194 addVisualEffectOverflow();
195
196 if (!shouldApplyViewportClip()) {
197 FloatRect contentRepaintRect = repaintRectInLocalCoordinates();
198 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintR ect);
199 addVisualOverflow(enclosingLayoutRect(contentRepaintRect));
200 }
201
195 updateLayerTransform(); 202 updateLayerTransform();
196 m_hasBoxDecorations = isDocumentElement() ? calculateHasBoxDecorations() : h asBoxDecorations(); 203 m_hasBoxDecorations = isDocumentElement() ? calculateHasBoxDecorations() : h asBoxDecorations();
197 invalidateBackgroundObscurationStatus(); 204 invalidateBackgroundObscurationStatus();
198 205
199 repainter.repaintAfterLayout(); 206 repainter.repaintAfterLayout();
200 clearNeedsLayout(); 207 clearNeedsLayout();
201 } 208 }
202 209
210 bool RenderSVGRoot::shouldApplyViewportClip() const
211 {
212 // the outermost svg is clipped if auto, and svg document roots are always c lipped
213 // When the svg is stand-alone (isDocumentElement() == true) the viewport cl ipping should always
214 // be applied, noting that the window scrollbars should be hidden if overflo w=hidden.
215 return style()->overflowX() == OHIDDEN
216 || style()->overflowX() == OAUTO
217 || style()->overflowX() == OSCROLL
218 || this->isDocumentElement();
219 }
220
203 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset) 221 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset)
204 { 222 {
205 // An empty viewport disables rendering. 223 // An empty viewport disables rendering.
206 if (pixelSnappedBorderBoxRect().isEmpty()) 224 if (pixelSnappedBorderBoxRect().isEmpty())
207 return; 225 return;
208 226
209 // Don't paint, if the context explicitly disabled it. 227 // Don't paint, if the context explicitly disabled it.
210 if (paintInfo.context->paintingDisabled()) 228 if (paintInfo.context->paintingDisabled())
211 return; 229 return;
212 230
213 // An empty viewBox also disables rendering. 231 // An empty viewBox also disables rendering.
214 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) 232 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute)
215 SVGSVGElement* svg = toSVGSVGElement(node()); 233 SVGSVGElement* svg = toSVGSVGElement(node());
216 ASSERT(svg); 234 ASSERT(svg);
217 if (svg->hasEmptyViewBox()) 235 if (svg->hasEmptyViewBox())
218 return; 236 return;
219 237
220 // Don't paint if we don't have kids, except if we have filters we should pa int those. 238 // Don't paint if we don't have kids, except if we have filters we should pa int those.
221 if (!firstChild()) { 239 if (!firstChild()) {
222 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(this); 240 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(this);
223 if (!resources || !resources->filter()) 241 if (!resources || !resources->filter())
224 return; 242 return;
225 } 243 }
226 244
227 // Make a copy of the PaintInfo because applyTransform will modify the damag e rect. 245 // Make a copy of the PaintInfo because applyTransform will modify the damag e rect.
228 PaintInfo childPaintInfo(paintInfo); 246 PaintInfo childPaintInfo(paintInfo);
229 childPaintInfo.context->save(); 247 childPaintInfo.context->save();
230 248
231 // Apply initial viewport clip - not affected by overflow handling 249 // Apply initial viewport clip
232 childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintOffse t))); 250 if (shouldApplyViewportClip())
251 childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintO ffset)));
233 252
234 // Convert from container offsets (html renderers) to a relative transform ( svg renderers). 253 // Convert from container offsets (html renderers) to a relative transform ( svg renderers).
235 // Transform from our paint container's coordinate system to our local coord s. 254 // Transform from our paint container's coordinate system to our local coord s.
236 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); 255 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
237 childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffs et.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform()); 256 childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffs et.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform());
238 257
239 // SVGRenderingContext must be destroyed before we restore the childPaintInf o.context, because a filter may have 258 // SVGRenderingContext must be destroyed before we restore the childPaintInf o.context, because a filter may have
240 // changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter. 259 // changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter.
241 { 260 {
242 SVGRenderingContext renderingContext; 261 SVGRenderingContext renderingContext;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // (does not have background/border/etc.) 357 // (does not have background/border/etc.)
339 358
340 // Return early for any cases where we don't actually paint. 359 // Return early for any cases where we don't actually paint.
341 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) 360 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
342 return LayoutRect(); 361 return LayoutRect();
343 362
344 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space. 363 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space.
345 FloatRect contentRepaintRect = repaintRectInLocalCoordinates(); 364 FloatRect contentRepaintRect = repaintRectInLocalCoordinates();
346 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ; 365 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ;
347 366
348 // Apply initial viewport clip - not affected by overflow settings 367 // Apply initial viewport clip, overflow:visible content is added to visualO verflow
368 // but the most common case is that overflow is hidden, so always intersect.
349 contentRepaintRect.intersect(pixelSnappedBorderBoxRect()); 369 contentRepaintRect.intersect(pixelSnappedBorderBoxRect());
350 370
351 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect); 371 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect);
352 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow. 372 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow.
353 if (m_hasBoxDecorations || hasRenderOverflow()) { 373 if (m_hasBoxDecorations || hasRenderOverflow()) {
354 // The selectionRect can project outside of the overflowRect, so take th eir union 374 // The selectionRect can project outside of the overflowRect, so take th eir union
355 // for repainting to avoid selection painting glitches. 375 // for repainting to avoid selection painting glitches.
356 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect()); 376 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect());
357 repaintRect.unite(decoratedRepaintRect); 377 repaintRect.unite(decoratedRepaintRect);
358 } 378 }
359 379
360 // Compute the repaint rect in the parent coordinate space. 380 // Compute the repaint rect in the parent coordinate space.
361 LayoutRect rect = enclosingIntRect(repaintRect); 381 LayoutRect rect = enclosingIntRect(repaintRect);
362 RenderReplaced::computeRectForRepaint(repaintContainer, rect); 382 RenderReplaced::computeRectForRepaint(repaintContainer, rect);
363 return rect; 383 return rect;
364 } 384 }
365 385
366 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const 386 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const
367 { 387 {
368 // Apply our local transforms (except for x/y translation), then our shadow, 388 // Apply our local transforms (except for x/y translation), then our shadow,
369 // and then call RenderBox's method to handle all the normal CSS Box model b its 389 // and then call RenderBox's method to handle all the normal CSS Box model b its
370 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect); 390 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect);
371 391
372 // Apply initial viewport clip - not affected by overflow settings 392 // Apply initial viewport clip
373 repaintRect.intersect(pixelSnappedBorderBoxRect()); 393 if (shouldApplyViewportClip())
394 repaintRect.intersect(pixelSnappedBorderBoxRect());
374 395
375 LayoutRect rect = enclosingIntRect(repaintRect); 396 LayoutRect rect = enclosingIntRect(repaintRect);
376 RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed); 397 RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed);
377 repaintRect = rect; 398 repaintRect = rect;
378 } 399 }
379 400
380 // This method expects local CSS box coordinates. 401 // This method expects local CSS box coordinates.
381 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform 402 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform
382 // to convert from SVG viewport coordinates to local CSS box coordinates. 403 // to convert from SVG viewport coordinates to local CSS box coordinates.
383 void RenderSVGRoot::mapLocalToContainer(const RenderLayerModelObject* repaintCon tainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed ) const 404 void RenderSVGRoot::mapLocalToContainer(const RenderLayerModelObject* repaintCon tainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed ) const
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 updateHitTestResult(result, pointInBorderBox); 453 updateHitTestResult(result, pointInBorderBox);
433 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect)) 454 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect))
434 return true; 455 return true;
435 } 456 }
436 } 457 }
437 458
438 return false; 459 return false;
439 } 460 }
440 461
441 } 462 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGRoot.h ('k') | Source/core/rendering/svg/SVGRenderSupport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698