LEFT | RIGHT |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@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. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 8 * Copyright (C) 2018 Adobe Systems Incorporated. All rights reserved. |
8 * | 9 * |
9 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
13 * | 14 * |
14 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * Library General Public License for more details. | 18 * Library General Public License for more details. |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (!renderer.normalChildNeedsLayout()) | 398 if (!renderer.normalChildNeedsLayout()) |
398 return false; | 399 return false; |
399 | 400 |
400 auto* resources = SVGResourcesCache::cachedResourcesForRenderer(renderer); | 401 auto* resources = SVGResourcesCache::cachedResourcesForRenderer(renderer); |
401 if (!resources || !resources->filter()) | 402 if (!resources || !resources->filter()) |
402 return false; | 403 return false; |
403 | 404 |
404 return true; | 405 return true; |
405 } | 406 } |
406 | 407 |
| 408 inline FloatRect clipPathReferenceBox(const RenderElement& renderer, CSSBoxType
boxType) |
| 409 { |
| 410 FloatRect referenceBox; |
| 411 switch (boxType) { |
| 412 case CSSBoxType::BorderBox: |
| 413 case CSSBoxType::MarginBox: |
| 414 case CSSBoxType::StrokeBox: |
| 415 // FIXME: strokeBoundingBox() takes dasharray into account but shouldn't
. |
| 416 referenceBox = renderer.strokeBoundingBox(); |
| 417 break; |
| 418 case CSSBoxType::ViewBox: |
| 419 if (renderer.element()) { |
| 420 FloatSize viewportSize; |
| 421 SVGLengthContext(downcast<SVGElement>(renderer.element())).determine
Viewport(viewportSize); |
| 422 referenceBox.setSize(viewportSize); |
| 423 break; |
| 424 } |
| 425 FALLTHROUGH; |
| 426 case CSSBoxType::ContentBox: |
| 427 case CSSBoxType::FillBox: |
| 428 case CSSBoxType::PaddingBox: |
| 429 case CSSBoxType::BoxMissing: |
| 430 referenceBox = renderer.objectBoundingBox(); |
| 431 break; |
| 432 } |
| 433 return referenceBox; |
| 434 } |
| 435 |
| 436 inline bool isPointInCSSClippingArea(const RenderElement& renderer, const FloatP
oint& point) |
| 437 { |
| 438 ClipPathOperation* clipPathOperation = renderer.style().clipPath(); |
| 439 if (is<ShapeClipPathOperation>(clipPathOperation)) { |
| 440 auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation); |
| 441 FloatRect referenceBox = clipPathReferenceBox(renderer, clipPath.referen
ceBox()); |
| 442 if (!referenceBox.contains(point)) |
| 443 return false; |
| 444 return clipPath.pathForReferenceRect(referenceBox).contains(point, clipP
ath.windRule()); |
| 445 } |
| 446 if (is<BoxClipPathOperation>(clipPathOperation)) { |
| 447 auto& clipPath = downcast<BoxClipPathOperation>(*clipPathOperation); |
| 448 FloatRect referenceBox = clipPathReferenceBox(renderer, clipPath.referen
ceBox()); |
| 449 if (!referenceBox.contains(point)) |
| 450 return false; |
| 451 return clipPath.pathForReferenceRect(FloatRoundedRect {referenceBox}).co
ntains(point); |
| 452 } |
| 453 |
| 454 return true; |
| 455 } |
| 456 |
| 457 void SVGRenderSupport::clipContextToCSSClippingArea(GraphicsContext& context, co
nst RenderElement& renderer) |
| 458 { |
| 459 ClipPathOperation* clipPathOperation = renderer.style().clipPath(); |
| 460 if (is<ShapeClipPathOperation>(clipPathOperation)) { |
| 461 auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation); |
| 462 FloatRect referenceBox = clipPathReferenceBox(renderer, clipPath.referen
ceBox()); |
| 463 context.clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.w
indRule()); |
| 464 } |
| 465 if (is<BoxClipPathOperation>(clipPathOperation)) { |
| 466 auto& clipPath = downcast<BoxClipPathOperation>(*clipPathOperation); |
| 467 FloatRect referenceBox = clipPathReferenceBox(renderer, clipPath.referen
ceBox()); |
| 468 context.clipPath(clipPath.pathForReferenceRect(FloatRoundedRect {referen
ceBox})); |
| 469 } |
| 470 } |
| 471 |
407 bool SVGRenderSupport::pointInClippingArea(const RenderElement& renderer, const
FloatPoint& point) | 472 bool SVGRenderSupport::pointInClippingArea(const RenderElement& renderer, const
FloatPoint& point) |
408 { | 473 { |
| 474 ClipPathOperation* clipPathOperation = renderer.style().clipPath(); |
| 475 if (is<ShapeClipPathOperation>(clipPathOperation) || is<BoxClipPathOperation
>(clipPathOperation)) |
| 476 return isPointInCSSClippingArea(renderer, point); |
| 477 |
409 // We just take clippers into account to determine if a point is on the node
. The Specification may | 478 // We just take clippers into account to determine if a point is on the node
. The Specification may |
410 // change later and we also need to check maskers. | 479 // change later and we also need to check maskers. |
411 auto* resources = SVGResourcesCache::cachedResourcesForRenderer(renderer); | 480 auto* resources = SVGResourcesCache::cachedResourcesForRenderer(renderer); |
412 if (!resources) | 481 if (!resources) |
413 return true; | 482 return true; |
414 | 483 |
415 if (RenderSVGResourceClipper* clipper = resources->clipper()) | 484 if (RenderSVGResourceClipper* clipper = resources->clipper()) |
416 return clipper->hitTestClipContent(renderer.objectBoundingBox(), point); | 485 return clipper->hitTestClipContent(renderer.objectBoundingBox(), point); |
417 | 486 |
418 return true; | 487 return true; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 continue; | 562 continue; |
494 | 563 |
495 if (ancestor->computedStyle()->svgStyle().hasMasker()) | 564 if (ancestor->computedStyle()->svgStyle().hasMasker()) |
496 downcast<SVGGraphicsElement>(*ancestor).setShouldIsolateBlending(mas
kedAncestorShouldIsolateBlending); | 565 downcast<SVGGraphicsElement>(*ancestor).setShouldIsolateBlending(mas
kedAncestorShouldIsolateBlending); |
497 | 566 |
498 return; | 567 return; |
499 } | 568 } |
500 } | 569 } |
501 #endif | 570 #endif |
502 } | 571 } |
LEFT | RIGHT |