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

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: overflow affects root svg's scrollbars 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 m_overflow.clear(); 224 m_overflow.clear();
225 addVisualEffectOverflow(); 225 addVisualEffectOverflow();
226 updateLayerTransform(); 226 updateLayerTransform();
227 m_hasBoxDecorations = isDocumentElement() ? calculateHasBoxDecorations() : h asBoxDecorations(); 227 m_hasBoxDecorations = isDocumentElement() ? calculateHasBoxDecorations() : h asBoxDecorations();
228 invalidateBackgroundObscurationStatus(); 228 invalidateBackgroundObscurationStatus();
229 229
230 repainter.repaintAfterLayout(); 230 repainter.repaintAfterLayout();
231 clearNeedsLayout(); 231 clearNeedsLayout();
232 } 232 }
233 233
234 bool RenderSVGRoot::shouldApplyViewportClip() const
235 {
236 // the outermost svg is clipped if auto, and svg document roots are always c lipped
237 // When the svg is standalone (isRoot() == true) the viewport clipping shoul d always
238 // be applied, noting that the window scrollbars should be hidden if overflo w=hidden.
239 return style()->overflowX() == OHIDDEN || style()->overflowX() == OAUTO || t his->isRoot();
fs 2014/04/15 15:43:07 isRoot() was recently renamed isDocumentElement().
Erik Dahlström (inactive) 2014/04/16 15:53:49 Fixed.
240 }
241
234 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset) 242 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint Offset)
235 { 243 {
236 // An empty viewport disables rendering. 244 // An empty viewport disables rendering.
237 if (pixelSnappedBorderBoxRect().isEmpty()) 245 if (pixelSnappedBorderBoxRect().isEmpty())
238 return; 246 return;
239 247
240 // Don't paint, if the context explicitly disabled it. 248 // Don't paint, if the context explicitly disabled it.
241 if (paintInfo.context->paintingDisabled()) 249 if (paintInfo.context->paintingDisabled())
242 return; 250 return;
243 251
244 // An empty viewBox also disables rendering. 252 // An empty viewBox also disables rendering.
245 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) 253 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute)
246 SVGSVGElement* svg = toSVGSVGElement(node()); 254 SVGSVGElement* svg = toSVGSVGElement(node());
247 ASSERT(svg); 255 ASSERT(svg);
248 if (svg->hasEmptyViewBox()) 256 if (svg->hasEmptyViewBox())
249 return; 257 return;
250 258
251 // Don't paint if we don't have kids, except if we have filters we should pa int those. 259 // Don't paint if we don't have kids, except if we have filters we should pa int those.
252 if (!firstChild()) { 260 if (!firstChild()) {
253 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(this); 261 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(this);
254 if (!resources || !resources->filter()) 262 if (!resources || !resources->filter())
255 return; 263 return;
256 } 264 }
257 265
258 // Make a copy of the PaintInfo because applyTransform will modify the damag e rect. 266 // Make a copy of the PaintInfo because applyTransform will modify the damag e rect.
259 PaintInfo childPaintInfo(paintInfo); 267 PaintInfo childPaintInfo(paintInfo);
260 childPaintInfo.context->save(); 268 childPaintInfo.context->save();
261 269
262 // Apply initial viewport clip - not affected by overflow handling 270 // Apply initial viewport clip
263 childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintOffse t))); 271 if (shouldApplyViewportClip())
272 childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintO ffset)));
264 273
265 // Convert from container offsets (html renderers) to a relative transform ( svg renderers). 274 // Convert from container offsets (html renderers) to a relative transform ( svg renderers).
266 // Transform from our paint container's coordinate system to our local coord s. 275 // Transform from our paint container's coordinate system to our local coord s.
267 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); 276 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
268 childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffs et.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform()); 277 childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffs et.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform());
269 278
270 // SVGRenderingContext must be destroyed before we restore the childPaintInf o.context, because a filter may have 279 // SVGRenderingContext must be destroyed before we restore the childPaintInf o.context, because a filter may have
271 // changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter. 280 // changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter.
272 { 281 {
273 SVGRenderingContext renderingContext; 282 SVGRenderingContext renderingContext;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 378
370 // Return early for any cases where we don't actually paint. 379 // Return early for any cases where we don't actually paint.
371 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) 380 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
372 return LayoutRect(); 381 return LayoutRect();
373 382
374 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space. 383 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space.
375 FloatRect contentRepaintRect = repaintRectInLocalCoordinates(); 384 FloatRect contentRepaintRect = repaintRectInLocalCoordinates();
376 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ; 385 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ;
377 386
378 // Apply initial viewport clip - not affected by overflow settings 387 // Apply initial viewport clip - not affected by overflow settings
379 contentRepaintRect.intersect(pixelSnappedBorderBoxRect()); 388 contentRepaintRect.intersect(pixelSnappedBorderBoxRect());
fs 2014/04/15 15:48:42 This is a recent addition that also clips to the v
380 389
381 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect); 390 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect);
382 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow. 391 // If the box is decorated or is overflowing, extend it to include the borde r-box and overflow.
383 if (m_hasBoxDecorations || hasRenderOverflow()) { 392 if (m_hasBoxDecorations || hasRenderOverflow()) {
384 // The selectionRect can project outside of the overflowRect, so take th eir union 393 // The selectionRect can project outside of the overflowRect, so take th eir union
385 // for repainting to avoid selection painting glitches. 394 // for repainting to avoid selection painting glitches.
386 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect()); 395 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect());
387 repaintRect.unite(decoratedRepaintRect); 396 repaintRect.unite(decoratedRepaintRect);
388 } 397 }
389 398
390 // Compute the repaint rect in the parent coordinate space. 399 // Compute the repaint rect in the parent coordinate space.
391 LayoutRect rect = enclosingIntRect(repaintRect); 400 LayoutRect rect = enclosingIntRect(repaintRect);
392 RenderReplaced::computeRectForRepaint(repaintContainer, rect); 401 RenderReplaced::computeRectForRepaint(repaintContainer, rect);
393 return rect; 402 return rect;
394 } 403 }
395 404
396 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const 405 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const
397 { 406 {
398 // Apply our local transforms (except for x/y translation), then our shadow, 407 // Apply our local transforms (except for x/y translation), then our shadow,
399 // and then call RenderBox's method to handle all the normal CSS Box model b its 408 // and then call RenderBox's method to handle all the normal CSS Box model b its
400 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect); 409 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect);
401 410
402 // Apply initial viewport clip - not affected by overflow settings 411 // Apply initial viewport clip
403 repaintRect.intersect(pixelSnappedBorderBoxRect()); 412 if (shouldApplyViewportClip())
413 repaintRect.intersect(pixelSnappedBorderBoxRect());
404 414
405 LayoutRect rect = enclosingIntRect(repaintRect); 415 LayoutRect rect = enclosingIntRect(repaintRect);
406 RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed); 416 RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed);
407 repaintRect = rect; 417 repaintRect = rect;
408 } 418 }
409 419
410 // This method expects local CSS box coordinates. 420 // This method expects local CSS box coordinates.
411 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform 421 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform
412 // to convert from SVG viewport coordinates to local CSS box coordinates. 422 // to convert from SVG viewport coordinates to local CSS box coordinates.
413 void RenderSVGRoot::mapLocalToContainer(const RenderLayerModelObject* repaintCon tainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed ) const 423 void RenderSVGRoot::mapLocalToContainer(const RenderLayerModelObject* repaintCon tainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed ) const
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 485
476 bool RenderSVGRoot::hasRelativeLogicalHeight() const 486 bool RenderSVGRoot::hasRelativeLogicalHeight() const
477 { 487 {
478 SVGSVGElement* svg = toSVGSVGElement(node()); 488 SVGSVGElement* svg = toSVGSVGElement(node());
479 ASSERT(svg); 489 ASSERT(svg);
480 490
481 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent(); 491 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent();
482 } 492 }
483 493
484 } 494 }
OLDNEW
« Source/core/css/resolver/StyleAdjuster.cpp ('K') | « Source/core/rendering/svg/RenderSVGRoot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698