Changeset 287832 in webkit
- Timestamp:
- Jan 10, 2022, 1:47:29 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 added
- 21 edited
-
ChangeLog (modified) (1 diff)
-
Sources.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
accessibility/AccessibilityRenderObject.cpp (modified) (3 diffs)
-
rendering/RenderTreeAsText.cpp (modified) (3 diffs)
-
rendering/svg/RenderSVGResource.cpp (modified) (3 diffs)
-
rendering/svg/RenderSVGResource.h (modified) (4 diffs)
-
rendering/svg/RenderSVGResourceFilter.cpp (modified) (1 diff)
-
rendering/svg/RenderSVGResourceFilter.h (modified) (1 diff)
-
rendering/svg/RenderSVGResourceGradient.cpp (modified) (2 diffs)
-
rendering/svg/RenderSVGResourceGradient.h (modified) (1 diff)
-
rendering/svg/RenderSVGResourcePattern.cpp (modified) (1 diff)
-
rendering/svg/RenderSVGResourcePattern.h (modified) (1 diff)
-
rendering/svg/RenderSVGResourceSolidColor.cpp (modified) (2 diffs)
-
rendering/svg/RenderSVGResourceSolidColor.h (modified) (2 diffs)
-
rendering/svg/RenderSVGShape.cpp (added)
-
rendering/svg/RenderSVGShape.h (added)
-
rendering/svg/RenderSVGShapeInlines.h (added)
-
rendering/svg/SVGRenderSupport.cpp (modified) (1 diff)
-
rendering/svg/SVGRenderTreeAsText.cpp (modified) (6 diffs)
-
rendering/svg/SVGRenderTreeAsText.h (modified) (2 diffs)
-
svg/SVGAnimateMotionElement.cpp (modified) (1 diff)
-
svg/SVGGeometryElement.cpp (modified) (5 diffs)
-
svg/SVGLineElement.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287829 r287832 1 2022-01-10 Nikolas Zimmermann <nzimmermann@igalia.com> 2 3 [LBSE] Begin layer-aware RenderSVGShape implementation 4 https://bugs.webkit.org/show_bug.cgi?id=234954 5 6 Reviewed by Rob Buis. 7 8 Begin implementing RenderSVGShape, based on the downstream version in the 9 LBSE branch. Many parts are 1:1 copies from LegacyRenderSVGShape, although 10 the core methods for layout / paint / hit-testing looks quite different in 11 RenderSVGShape -- the code is mostly adapted from layer-aware CSS renderers 12 such as RenderBox / RenderBlock taking SVG specifics into account. 13 14 This patch hooks in RenderSVGShape in all places that used to handle 15 LegacyRenderSVGShape, e.g. in AccessibilityRenderObject. However no 16 renderer inherits from RenderSVGShape yet -- a follow-up patch will 17 introduce RenderSVGRect. 18 19 Covered by existing tests, no change in behaviour. 20 21 * Sources.txt: 22 * WebCore.xcodeproj/project.pbxproj: 23 * accessibility/AccessibilityRenderObject.cpp: 24 (WebCore::AccessibilityRenderObject::supportsPath const): 25 (WebCore::AccessibilityRenderObject::elementPath const): 26 * rendering/RenderTreeAsText.cpp: 27 (WebCore::write): 28 * rendering/svg/RenderSVGResource.cpp: 29 (WebCore::RenderSVGResource::fillAndStrokePathOrShape const): 30 * rendering/svg/RenderSVGResource.h: 31 (WebCore::RenderSVGResource::postApplyResource): 32 * rendering/svg/RenderSVGResourceFilter.cpp: 33 (WebCore::RenderSVGResourceFilter::postApplyResource): 34 * rendering/svg/RenderSVGResourceFilter.h: 35 * rendering/svg/RenderSVGResourceGradient.cpp: 36 (WebCore::RenderSVGResourceGradient::postApplyResource): 37 * rendering/svg/RenderSVGResourceGradient.h: 38 * rendering/svg/RenderSVGResourcePattern.cpp: 39 (WebCore::RenderSVGResourcePattern::postApplyResource): 40 * rendering/svg/RenderSVGResourcePattern.h: 41 * rendering/svg/RenderSVGResourceSolidColor.cpp: 42 (WebCore::RenderSVGResourceSolidColor::postApplyResource): 43 * rendering/svg/RenderSVGResourceSolidColor.h: 44 * rendering/svg/RenderSVGShape.cpp: Added. 45 (WebCore::RenderSVGShape::RenderSVGShape): 46 (WebCore::RenderSVGShape::updateShapeFromElement): 47 (WebCore::RenderSVGShape::isEmpty const): 48 (WebCore::RenderSVGShape::fillShape const): 49 (WebCore::RenderSVGShape::strokeShape const): 50 (WebCore::RenderSVGShape::shapeDependentStrokeContains): 51 (WebCore::RenderSVGShape::shapeDependentFillContains const): 52 (WebCore::RenderSVGShape::fillContains): 53 (WebCore::RenderSVGShape::strokeContains): 54 (WebCore::RenderSVGShape::layout): 55 (WebCore::RenderSVGShape::nonScalingStrokePath const): 56 (WebCore::RenderSVGShape::setupNonScalingStrokeContext): 57 (WebCore::RenderSVGShape::nonScalingStrokeTransform const): 58 (WebCore::RenderSVGShape::shouldGenerateMarkerPositions const): 59 (WebCore::RenderSVGShape::fillShape): 60 (WebCore::RenderSVGShape::strokeShape): 61 (WebCore::RenderSVGShape::fillStrokeMarkers): 62 (WebCore::RenderSVGShape::paint): 63 (WebCore::RenderSVGShape::isPointInFill): 64 (WebCore::RenderSVGShape::isPointInStroke): 65 (WebCore::RenderSVGShape::getTotalLength const): 66 (WebCore::RenderSVGShape::getPointAtLength const): 67 (WebCore::RenderSVGShape::nodeAtPoint): 68 (WebCore::markerForType): 69 (WebCore::RenderSVGShape::computeMarkerBoundingBox const): 70 (WebCore::RenderSVGShape::calculateObjectBoundingBox const): 71 (WebCore::RenderSVGShape::calculateStrokeBoundingBox const): 72 (WebCore::RenderSVGShape::strokeWidth const): 73 (WebCore::RenderSVGShape::hasSmoothStroke const): 74 (WebCore::RenderSVGShape::drawMarkers): 75 (WebCore::RenderSVGShape::createPath const): 76 (WebCore::RenderSVGShape::processMarkerPositions): 77 (WebCore::RenderSVGShape::styleWillChange): 78 * rendering/svg/RenderSVGShape.h: Added. 79 (WebCore::RenderSVGShape::setNeedsShapeUpdate): 80 (WebCore::RenderSVGShape::hasPath const): 81 (WebCore::RenderSVGShape::path const): 82 (WebCore::RenderSVGShape::clearPath): 83 (WebCore::RenderSVGShape::hasNonScalingStroke const): 84 * rendering/svg/RenderSVGShapeInlines.h: Added. 85 (WebCore::RenderSVGShape::graphicsElement const): 86 * rendering/svg/SVGRenderSupport.cpp: 87 * rendering/svg/SVGRenderTreeAsText.cpp: 88 (WebCore::writeSVGPaintingResource): 89 (WebCore::writeSVGFillPaintingResource): 90 (WebCore::writeSVGStrokePaintingResource): 91 (WebCore::writeStyle): 92 (WebCore::writeSVGGraphicsElement): 93 (WebCore::operator<<): 94 (WebCore::write): 95 * rendering/svg/SVGRenderTreeAsText.h: 96 * svg/SVGAnimateMotionElement.cpp: 97 * svg/SVGGeometryElement.cpp: 98 (WebCore::SVGGeometryElement::getTotalLength const): 99 (WebCore::SVGGeometryElement::getPointAtLength const): 100 (WebCore::SVGGeometryElement::isPointInFill): 101 (WebCore::SVGGeometryElement::isPointInStroke): 102 * svg/SVGLineElement.cpp: 103 1 104 2022-01-09 Sam Weinig <weinig@apple.com> 2 105 -
trunk/Source/WebCore/Sources.txt
r287743 r287832 2495 2495 rendering/svg/RenderSVGResourceSolidColor.cpp 2496 2496 rendering/svg/RenderSVGRoot.cpp 2497 rendering/svg/RenderSVGShape.cpp 2497 2498 rendering/svg/RenderSVGTSpan.cpp 2498 2499 rendering/svg/RenderSVGText.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r287782 r287832 3274 3274 A10BB5851484E3A700B2E87A /* LegacyRenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */; }; 3275 3275 A10BB58B1484E3B300B2E87A /* LegacyRenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* LegacyRenderSVGShape.h */; }; 3276 A10BB58B1484E3B300C3F77B /* RenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300C3F77B /* RenderSVGShape.h */; }; 3276 3277 A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3277 3278 A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DC76914747BAB005E2471 /* StyleGridData.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4633 4634 CDF747F5270F83B1008FEEEC /* RenderSVGGradientStopInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F4270F83B1008FEEEC /* RenderSVGGradientStopInlines.h */; }; 4634 4635 CDF747F7270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F6270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h */; }; 4636 CDF747F7270F83B4107DEEEC /* RenderSVGShapeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */; }; 4635 4637 CDF747F9270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F8270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h */; }; 4636 4638 CDF747FB270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747FA270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h */; }; … … 13380 13382 A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRect.h; sourceTree = "<group>"; }; 13381 13383 A10BB5881484E3B300B2E87A /* LegacyRenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGShape.cpp; sourceTree = "<group>"; }; 13384 A10CC5881473E3B300B2A8BF /* RenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGShape.cpp; sourceTree = "<group>"; }; 13382 13385 A10BB5891484E3B300B2E87A /* LegacyRenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGShape.h; sourceTree = "<group>"; }; 13386 A10BB5891484E3B300C3F77B /* RenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGShape.h; sourceTree = "<group>"; }; 13383 13387 A10D6E942144C99800FDD14D /* JSPaymentResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentResponseCustom.cpp; sourceTree = "<group>"; }; 13384 13388 A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreviewLoaderClient.h; sourceTree = "<group>"; }; … … 16281 16285 CDF747F4270F83B1008FEEEC /* RenderSVGGradientStopInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGGradientStopInlines.h; sourceTree = "<group>"; }; 16282 16286 CDF747F6270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGShapeInlines.h; sourceTree = "<group>"; }; 16287 CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGShapeInlines.h; sourceTree = "<group>"; }; 16283 16288 CDF747F8270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceRadialGradientInlines.h; sourceTree = "<group>"; }; 16284 16289 CDF747FA270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceMaskerInlines.h; sourceTree = "<group>"; }; … … 18973 18978 436708A512D9CA5C00044234 /* RenderSVGRoot.cpp */, 18974 18979 436708A612D9DB4B00044234 /* RenderSVGRoot.h */, 18980 A10CC5881473E3B300B2A8BF /* RenderSVGShape.cpp */, 18981 A10BB5891484E3B300C3F77B /* RenderSVGShape.h */, 18982 CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */, 18975 18983 0854B0061255E4E600B9CDD0 /* RenderSVGText.cpp */, 18976 18984 0854B0071255E4E600B9CDD0 /* RenderSVGText.h */, … … 36751 36759 436708E312D9CA4B00044234 /* RenderSVGResourceSolidColor.h in Headers */, 36752 36760 436708E512D9DB4B00044234 /* RenderSVGRoot.h in Headers */, 36761 A10BB58B1484E3B300C3F77B /* RenderSVGShape.h in Headers */, 36762 CDF747F7270F83B4107DEEEC /* RenderSVGShapeInlines.h in Headers */, 36753 36763 0854B0191255E4E600B9CDD0 /* RenderSVGText.h in Headers */, 36754 36764 0854B01B1255E4E600B9CDD0 /* RenderSVGTextPath.h in Headers */, -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r287677 r287832 97 97 #include "RenderMenuList.h" 98 98 #include "RenderSVGRoot.h" 99 #include "RenderSVGShape.h" 99 100 #include "RenderTableCell.h" 100 101 #include "RenderText.h" … … 911 912 bool AccessibilityRenderObject::supportsPath() const 912 913 { 913 return is<RenderText>(renderer()) || is<LegacyRenderSVGShape>(renderer());914 return is<RenderText>(renderer()) || (renderer() && renderer()->isSVGShapeOrLegacySVGShape()); 914 915 } 915 916 … … 961 962 LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location(); 962 963 path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y())); 964 } 965 966 return path; 967 } 968 963 969 #if ENABLE(LAYER_BASED_SVG_ENGINE) 964 } else if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) { 970 if (is<RenderSVGShape>(renderer()) && downcast<RenderSVGShape>(*m_renderer).hasPath()) { 971 Path path = downcast<RenderSVGShape>(*m_renderer).path(); 972 973 // The SVG path is in terms of the parent's bounding box. The path needs to be offset to frame coordinates. 974 if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) { 965 975 LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location(); 966 976 path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y())); 977 } 978 979 return path; 980 } 967 981 #endif 968 }969 970 return path;971 }972 982 973 983 return Path(); -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r287677 r287832 40 40 #include "LegacyInlineTextBox.h" 41 41 #include "LegacyRenderSVGRoot.h" 42 #include "LegacyRenderSVGShape.h" 42 43 #include "Logging.h" 43 44 #include "PrintContext.h" … … 65 66 #include "RenderSVGResourceContainer.h" 66 67 #include "RenderSVGRoot.h" 68 #include "RenderSVGShape.h" 67 69 #include "RenderSVGText.h" 68 70 #include "RenderTableCell.h" … … 559 561 }; 560 562 563 #if ENABLE(LAYER_BASED_SVG_ENGINE) 564 if (is<RenderSVGShape>(o)) { 565 write(ts, downcast<RenderSVGShape>(o), behavior); 566 return; 567 } 568 #endif 561 569 if (is<LegacyRenderSVGShape>(o)) { 562 570 write(ts, downcast<LegacyRenderSVGShape>(o), behavior); -
trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp
r287076 r287832 27 27 #include "FrameView.h" 28 28 #include "LegacyRenderSVGRoot.h" 29 #include "LegacyRenderSVGShape.h" 29 30 #include "RenderSVGResourceClipper.h" 30 31 #include "RenderSVGResourceFilter.h" … … 32 33 #include "RenderSVGResourceSolidColor.h" 33 34 #include "RenderSVGRoot.h" 35 #include "RenderSVGShape.h" 34 36 #include "RenderView.h" 35 37 #include "SVGResourceElementClient.h" … … 244 246 } 245 247 246 } 248 void RenderSVGResource::fillAndStrokePathOrShape(GraphicsContext& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const RenderElement* shape) const 249 { 250 if (shape) { 251 ASSERT(shape->isSVGShapeOrLegacySVGShape()); 252 253 if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) { 254 if (is<LegacyRenderSVGShape>(shape)) 255 downcast<LegacyRenderSVGShape>(shape)->fillShape(context); 256 #if ENABLE(LAYER_BASED_SVG_ENGINE) 257 else if (is<RenderSVGShape>(shape)) 258 downcast<RenderSVGShape>(shape)->fillShape(context); 259 #endif 260 } 261 262 if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) { 263 if (is<LegacyRenderSVGShape>(shape)) 264 downcast<LegacyRenderSVGShape>(shape)->strokeShape(context); 265 #if ENABLE(LAYER_BASED_SVG_ENGINE) 266 else if (is<RenderSVGShape>(shape)) 267 downcast<RenderSVGShape>(shape)->strokeShape(context); 268 #endif 269 } 270 271 return; 272 } 273 274 if (!path) 275 return; 276 277 if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) 278 context.fillPath(*path); 279 if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) 280 context.strokePath(*path); 281 } 282 283 } -
trunk/Source/WebCore/rendering/svg/RenderSVGResource.h
r287677 r287832 20 20 #pragma once 21 21 22 #include "LegacyRenderSVGShape.h"23 22 #include "RenderStyleConstants.h" 23 #include <wtf/OptionSet.h> 24 24 #include <wtf/TypeCasts.h> 25 25 … … 48 48 class GraphicsContext; 49 49 class Path; 50 class RenderElement; 50 51 class RenderObject; 52 class RenderSVGResourceSolidColor; 51 53 class RenderStyle; 52 class RenderSVGResourceSolidColor;53 54 54 55 class RenderSVGResource { … … 61 62 62 63 virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) = 0; 63 virtual void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const LegacyRenderSVGShape*) { }64 virtual void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement* /* shape */) { } 64 65 virtual FloatRect resourceBoundingBox(const RenderObject&) = 0; 65 66 … … 72 73 73 74 static void markForLayoutAndParentResourceInvalidation(RenderObject&, bool needsLayout = true); 75 76 protected: 77 void fillAndStrokePathOrShape(GraphicsContext&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement* shape) const; 74 78 }; 75 79 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
r287829 r287832 173 173 } 174 174 175 void RenderSVGResourceFilter::postApplyResource(RenderElement& renderer, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path*, const LegacyRenderSVGShape*)175 void RenderSVGResourceFilter::postApplyResource(RenderElement& renderer, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path*, const RenderElement*) 176 176 { 177 177 ASSERT(context); -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.h
r287782 r287832 70 70 71 71 bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) override; 72 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const LegacyRenderSVGShape*) override;72 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement*) override; 73 73 74 74 FloatRect resourceBoundingBox(const RenderObject&) override; -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
r287677 r287832 180 180 } 181 181 182 void RenderSVGResourceGradient::postApplyResource(RenderElement& renderer, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const LegacyRenderSVGShape* shape)182 void RenderSVGResourceGradient::postApplyResource(RenderElement& renderer, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const RenderElement* shape) 183 183 { 184 184 ASSERT(context); … … 208 208 UNUSED_PARAM(renderer); 209 209 #endif 210 } else { 211 if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) { 212 if (path) 213 context->fillPath(*path); 214 else if (shape) 215 shape->fillShape(*context); 216 } 217 if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) { 218 if (path) 219 context->strokePath(*path); 220 else if (shape) 221 shape->strokeShape(*context); 222 } 223 } 210 } else 211 fillAndStrokePathOrShape(*context, resourceMode, path, shape); 224 212 225 213 context->restore(); -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.h
r287677 r287832 41 41 42 42 bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) final; 43 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const LegacyRenderSVGShape*) final;43 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement*) final; 44 44 FloatRect resourceBoundingBox(const RenderObject&) final { return FloatRect(); } 45 45 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
r287677 r287832 202 202 } 203 203 204 void RenderSVGResourcePattern::postApplyResource(RenderElement&, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const LegacyRenderSVGShape* shape)204 void RenderSVGResourcePattern::postApplyResource(RenderElement&, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const RenderElement* shape) 205 205 { 206 206 ASSERT(context); 207 207 ASSERT(!resourceMode.isEmpty()); 208 209 if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) { 210 if (path) 211 context->fillPath(*path); 212 else if (shape) 213 shape->fillShape(*context); 214 } 215 if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) { 216 if (path) 217 context->strokePath(*path); 218 else if (shape) 219 shape->strokeShape(*context); 220 } 221 208 fillAndStrokePathOrShape(*context, resourceMode, path, shape); 222 209 context->restore(); 223 210 } -
trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.h
r287677 r287832 49 49 50 50 bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) override; 51 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const LegacyRenderSVGShape*) override;51 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement*) override; 52 52 FloatRect resourceBoundingBox(const RenderObject&) override { return FloatRect(); } 53 53 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
r287677 r287832 24 24 #include "FrameView.h" 25 25 #include "GraphicsContext.h" 26 #include "RenderElement.h" 26 27 #include "RenderStyle.h" 27 28 #include "RenderView.h" 29 #include "SVGRenderSupport.h" 28 30 29 31 namespace WebCore { … … 68 70 } 69 71 70 void RenderSVGResourceSolidColor::postApplyResource(RenderElement&, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const LegacyRenderSVGShape* shape)72 void RenderSVGResourceSolidColor::postApplyResource(RenderElement&, GraphicsContext*& context, OptionSet<RenderSVGResourceMode> resourceMode, const Path* path, const RenderElement* shape) 71 73 { 72 74 ASSERT(context); 73 75 ASSERT(!resourceMode.isEmpty()); 74 75 if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) { 76 if (path) 77 context->fillPath(*path); 78 else if (shape) 79 shape->fillShape(*context); 80 } 81 if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) { 82 if (path) 83 context->strokePath(*path); 84 else if (shape) 85 shape->strokeShape(*context); 86 } 76 fillAndStrokePathOrShape(*context, resourceMode, path, shape); 87 77 } 88 78 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.h
r287677 r287832 21 21 22 22 #include "Color.h" 23 #include "FloatRect.h" 23 24 #include "RenderSVGResource.h" 24 25 25 26 namespace WebCore { 27 28 class RenderObject; 26 29 27 30 class RenderSVGResourceSolidColor final : public RenderSVGResource { … … 35 38 36 39 bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) override; 37 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const LegacyRenderSVGShape*) override;40 void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderElement*) override; 38 41 FloatRect resourceBoundingBox(const RenderObject&) override { return FloatRect(); } 39 42 -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp
r287731 r287832 30 30 #include "ElementAncestorIterator.h" 31 31 #include "LegacyRenderSVGRoot.h" 32 #include "LegacyRenderSVGShape.h" 32 33 #include "NodeRenderStyle.h" 33 34 #include "RenderChildIterator.h" -
trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
r287677 r287832 50 50 #include "RenderSVGResourceSolidColor.h" 51 51 #include "RenderSVGRoot.h" 52 #include "RenderSVGShapeInlines.h" 52 53 #include "RenderSVGText.h" 53 54 #include "SVGCircleElement.h" … … 152 153 } 153 154 154 static void writeSVGPaintingResource(TextStream& ts, RenderSVGResource* resource) 155 { 156 if (resource->resourceType() == SolidColorResourceType) { 157 ts << "[type=SOLID] [color=" << static_cast<RenderSVGResourceSolidColor*>(resource)->color() << "]"; 155 static void writeSVGPaintingResource(TextStream& ts, const RenderSVGResource& resource) 156 { 157 auto resourceType = resource.resourceType(); 158 if (resourceType == SolidColorResourceType) { 159 ts << "[type=SOLID] [color=" << downcast<RenderSVGResourceSolidColor>(resource).color() << "]"; 158 160 return; 159 161 } 160 162 163 if (resourceType == PatternResourceType) 164 ts << "[type=PATTERN]"; 165 else if (resourceType == LinearGradientResourceType) 166 ts << "[type=LINEAR-GRADIENT]"; 167 else if (resourceType == RadialGradientResourceType) 168 ts << "[type=RADIAL-GRADIENT]"; 169 161 170 // All other resources derive from RenderSVGResourceContainer 162 RenderSVGResourceContainer* container = static_cast<RenderSVGResourceContainer*>(resource); 163 SVGElement& element = container->element(); 164 165 if (resource->resourceType() == PatternResourceType) 166 ts << "[type=PATTERN]"; 167 else if (resource->resourceType() == LinearGradientResourceType) 168 ts << "[type=LINEAR-GRADIENT]"; 169 else if (resource->resourceType() == RadialGradientResourceType) 170 ts << "[type=RADIAL-GRADIENT]"; 171 172 ts << " [id=\"" << element.getIdAttribute() << "\"]"; 171 const auto& container = static_cast<const RenderSVGResourceContainer&>(resource); 172 ts << " [id=\"" << container.element().getIdAttribute() << "\"]"; 173 } 174 175 static void writeSVGFillPaintingResource(TextStream& ts, const RenderElement& renderer, const RenderSVGResource& fillPaintingResource) 176 { 177 TextStreamSeparator s(" "); 178 ts << " [fill={" << s; 179 writeSVGPaintingResource(ts, fillPaintingResource); 180 181 const auto& svgStyle = renderer.style().svgStyle(); 182 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); 183 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), WindRule::NonZero); 184 ts << "}]"; 185 } 186 187 static void writeSVGStrokePaintingResource(TextStream& ts, const RenderElement& renderer, const RenderSVGResource& strokePaintingResource, const SVGGraphicsElement& shape) 188 { 189 TextStreamSeparator s(" "); 190 ts << " [stroke={" << s; 191 writeSVGPaintingResource(ts, strokePaintingResource); 192 193 const auto& style = renderer.style(); 194 const auto& svgStyle = style.svgStyle(); 195 196 SVGLengthContext lengthContext(&shape); 197 double dashOffset = lengthContext.valueForLength(svgStyle.strokeDashOffset()); 198 double strokeWidth = lengthContext.valueForLength(style.strokeWidth()); 199 const auto& dashes = svgStyle.strokeDashArray(); 200 201 DashArray dashArray; 202 for (auto& length : dashes) 203 dashArray.append(length.value(lengthContext)); 204 205 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); 206 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); 207 writeIfNotDefault(ts, "miter limit", style.strokeMiterLimit(), 4.0f); 208 writeIfNotDefault(ts, "line cap", style.capStyle(), LineCap::Butt); 209 writeIfNotDefault(ts, "line join", style.joinStyle(), LineJoin::Miter); 210 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); 211 if (!dashArray.isEmpty()) 212 writeNameValuePair(ts, "dash array", dashArray); 213 214 if (is<SVGGeometryElement>(shape)) { 215 double pathLength = downcast<SVGGeometryElement>(shape).pathLength(); 216 writeIfNotDefault(ts, "path length", pathLength, 0.0); 217 } 218 219 ts << "}]"; 173 220 } 174 221 … … 182 229 writeIfNotDefault(ts, "image rendering", style.imageRendering(), RenderStyle::initialImageRendering()); 183 230 writeIfNotDefault(ts, "opacity", style.opacity(), RenderStyle::initialOpacity()); 231 184 232 if (is<LegacyRenderSVGShape>(renderer)) { 185 233 const auto& shape = downcast<LegacyRenderSVGShape>(renderer); 186 234 187 235 Color fallbackColor; 188 if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<LegacyRenderSVGShape&>(shape), shape.style(), fallbackColor)) { 189 TextStreamSeparator s(" "); 190 ts << " [stroke={" << s; 191 writeSVGPaintingResource(ts, strokePaintingResource); 192 193 SVGLengthContext lengthContext(&shape.graphicsElement()); 194 double dashOffset = lengthContext.valueForLength(svgStyle.strokeDashOffset()); 195 double strokeWidth = lengthContext.valueForLength(style.strokeWidth()); 196 const auto& dashes = svgStyle.strokeDashArray(); 197 198 DashArray dashArray; 199 for (auto& length : dashes) 200 dashArray.append(length.value(lengthContext)); 201 202 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); 203 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); 204 writeIfNotDefault(ts, "miter limit", style.strokeMiterLimit(), 4.0f); 205 writeIfNotDefault(ts, "line cap", style.capStyle(), LineCap::Butt); 206 writeIfNotDefault(ts, "line join", style.joinStyle(), LineJoin::Miter); 207 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); 208 if (!dashArray.isEmpty()) 209 writeNameValuePair(ts, "dash array", dashArray); 210 211 if (is<SVGGeometryElement>(shape.graphicsElement())) { 212 double pathLength = downcast<SVGGeometryElement>(shape.graphicsElement()).pathLength(); 213 writeIfNotDefault(ts, "path length", pathLength, 0.0); 214 } 215 216 ts << "}]"; 217 } 218 219 if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<LegacyRenderSVGShape&>(shape), shape.style(), fallbackColor)) { 220 TextStreamSeparator s(" "); 221 ts << " [fill={" << s; 222 writeSVGPaintingResource(ts, fillPaintingResource); 223 224 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); 225 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), WindRule::NonZero); 226 ts << "}]"; 227 } 236 if (auto* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<LegacyRenderSVGShape&>(shape), shape.style(), fallbackColor)) 237 writeSVGStrokePaintingResource(ts, renderer, *strokePaintingResource, shape.graphicsElement()); 238 239 if (auto* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<LegacyRenderSVGShape&>(shape), shape.style(), fallbackColor)) 240 writeSVGFillPaintingResource(ts, renderer, *fillPaintingResource); 241 228 242 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), WindRule::NonZero); 229 243 } 244 245 #if ENABLE(LAYER_BASED_SVG_ENGINE) 246 else if (is<LegacyRenderSVGShape>(renderer)) { 247 const auto& shape = downcast<RenderSVGShape>(renderer); 248 249 Color fallbackColor; 250 if (auto* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<RenderSVGShape&>(shape), shape.style(), fallbackColor)) 251 writeSVGStrokePaintingResource(ts, renderer, *strokePaintingResource, shape.graphicsElement()); 252 253 if (auto* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<RenderSVGShape&>(shape), shape.style(), fallbackColor)) 254 writeSVGFillPaintingResource(ts, renderer, *fillPaintingResource); 255 256 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), WindRule::NonZero); 257 } 258 #endif 230 259 231 260 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); … … 251 280 } 252 281 253 static TextStream& operator<<(TextStream& ts, const LegacyRenderSVGShape& shape) 254 { 255 writePositionAndStyle(ts, shape); 256 257 SVGGraphicsElement& svgElement = shape.graphicsElement(); 282 static void writeSVGGraphicsElement(TextStream& ts, SVGGraphicsElement& svgElement) 283 { 258 284 SVGLengthContext lengthContext(&svgElement); 259 285 … … 292 318 } else 293 319 ASSERT_NOT_REACHED(); 294 return ts; 295 } 320 } 321 322 static TextStream& operator<<(TextStream& ts, const LegacyRenderSVGShape& shape) 323 { 324 writePositionAndStyle(ts, shape); 325 writeSVGGraphicsElement(ts, shape.graphicsElement()); 326 return ts; 327 } 328 329 #if ENABLE(LAYER_BASED_SVG_ENGINE) 330 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape) 331 { 332 writePositionAndStyle(ts, shape); 333 writeSVGGraphicsElement(ts, shape.graphicsElement()); 334 return ts; 335 } 336 #endif 296 337 297 338 static void writeRenderSVGTextBox(TextStream& ts, const RenderSVGText& text) … … 552 593 } 553 594 595 #if ENABLE(LAYER_BASED_SVG_ENGINE) 596 void write(TextStream& ts, const RenderSVGShape& shape, OptionSet<RenderAsTextFlag> behavior) 597 { 598 writeStandardPrefix(ts, shape, behavior); 599 ts << shape << "\n"; 600 writeResources(ts, shape, behavior); 601 } 602 #endif 603 554 604 void write(TextStream& ts, const LegacyRenderSVGShape& shape, OptionSet<RenderAsTextFlag> behavior) 555 605 { -
trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h
r287677 r287832 46 46 class RenderSVGResourceContainer; 47 47 class RenderSVGRoot; 48 class RenderSVGShape; 48 49 class RenderSVGText; 49 50 class SVGUnitTypes; … … 51 52 // functions used by the main RenderTreeAsText code 52 53 void write(WTF::TextStream&, const LegacyRenderSVGRoot&, OptionSet<RenderAsTextFlag>); 54 void write(WTF::TextStream&, const LegacyRenderSVGShape&, OptionSet<RenderAsTextFlag>); 53 55 #if ENABLE(LAYER_BASED_SVG_ENGINE) 54 56 void write(WTF::TextStream&, const RenderSVGRoot&, OptionSet<RenderAsTextFlag>); 57 void write(WTF::TextStream&, const RenderSVGShape&, OptionSet<RenderAsTextFlag>); 55 58 #endif 56 void write(WTF::TextStream&, const LegacyRenderSVGShape&, OptionSet<RenderAsTextFlag>);57 59 void writeSVGGradientStop(WTF::TextStream&, const RenderSVGGradientStop&, OptionSet<RenderAsTextFlag>); 58 60 void writeSVGResourceContainer(WTF::TextStream&, const RenderSVGResourceContainer&, OptionSet<RenderAsTextFlag>); -
trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp
r287731 r287832 26 26 #include "ElementIterator.h" 27 27 #include "PathTraversalState.h" 28 #include "RenderElement.h" 28 29 #include "RenderSVGResource.h" 29 30 #include "SVGElementTypeHelpers.h" -
trunk/Source/WebCore/svg/SVGGeometryElement.cpp
r287677 r287832 27 27 #include "LegacyRenderSVGShape.h" 28 28 #include "RenderSVGResource.h" 29 #include "RenderSVGShape.h" 29 30 #include "SVGDocumentExtensions.h" 30 31 #include "SVGPathUtilities.h" … … 49 50 document().updateLayoutIgnorePendingStylesheets(); 50 51 51 auto* renderer = downcast<LegacyRenderSVGShape>(this->renderer());52 auto* renderer = this->renderer(); 52 53 if (!renderer) 53 54 return 0; 54 55 55 return renderer->getTotalLength(); 56 if (is<LegacyRenderSVGShape>(renderer)) 57 return downcast<LegacyRenderSVGShape>(renderer)->getTotalLength(); 58 59 #if ENABLE(LAYER_BASED_SVG_ENGINE) 60 if (is<RenderSVGShape>(renderer)) 61 return downcast<RenderSVGShape>(renderer)->getTotalLength(); 62 #endif 63 64 ASSERT_NOT_REACHED(); 65 return 0; 56 66 } 57 67 … … 60 70 document().updateLayoutIgnorePendingStylesheets(); 61 71 62 auto* renderer = downcast<LegacyRenderSVGShape>(this->renderer());63 72 auto* renderer = this->renderer(); 73 64 74 // Spec: If current element is a non-rendered element, throw an InvalidStateError. 65 75 if (!renderer) 66 76 return Exception { InvalidStateError }; 67 77 68 78 // Spec: Clamp distance to [0, length]. 69 79 distance = clampTo<float>(distance, 0, getTotalLength()); 70 80 71 81 // Spec: Return a newly created, detached SVGPoint object. 72 return SVGPoint::create(renderer->getPointAtLength(distance)); 82 if (is<LegacyRenderSVGShape>(renderer)) 83 return SVGPoint::create(downcast<LegacyRenderSVGShape>(renderer)->getPointAtLength(distance)); 84 85 #if ENABLE(LAYER_BASED_SVG_ENGINE) 86 if (is<RenderSVGShape>(renderer)) 87 return SVGPoint::create(downcast<RenderSVGShape>(renderer)->getPointAtLength(distance)); 88 #endif 89 90 ASSERT_NOT_REACHED(); 91 return Exception { InvalidStateError }; 73 92 } 74 93 … … 77 96 document().updateLayoutIgnorePendingStylesheets(); 78 97 79 auto* renderer = downcast<LegacyRenderSVGShape>(this->renderer());98 auto* renderer = this->renderer(); 80 99 if (!renderer) 81 100 return false; 82 101 83 102 FloatPoint point {static_cast<float>(pointInit.x), static_cast<float>(pointInit.y)}; 84 return renderer->isPointInFill(point); 103 if (is<LegacyRenderSVGShape>(renderer)) 104 return downcast<LegacyRenderSVGShape>(renderer)->isPointInFill(point); 105 106 #if ENABLE(LAYER_BASED_SVG_ENGINE) 107 if (is<RenderSVGShape>(renderer)) 108 return downcast<RenderSVGShape>(renderer)->isPointInFill(point); 109 #endif 110 111 ASSERT_NOT_REACHED(); 112 return false; 85 113 } 86 114 … … 89 117 document().updateLayoutIgnorePendingStylesheets(); 90 118 91 auto* renderer = downcast<LegacyRenderSVGShape>(this->renderer());119 auto* renderer = this->renderer(); 92 120 if (!renderer) 93 121 return false; 94 122 95 123 FloatPoint point {static_cast<float>(pointInit.x), static_cast<float>(pointInit.y)}; 96 return renderer->isPointInStroke(point); 124 if (is<LegacyRenderSVGShape>(renderer)) 125 return downcast<LegacyRenderSVGShape>(renderer)->isPointInStroke(point); 126 127 #if ENABLE(LAYER_BASED_SVG_ENGINE) 128 if (is<RenderSVGShape>(renderer)) 129 return downcast<RenderSVGShape>(renderer)->isPointInStroke(point); 130 #endif 131 132 ASSERT_NOT_REACHED(); 133 return false; 97 134 } 98 135 -
trunk/Source/WebCore/svg/SVGLineElement.cpp
r287677 r287832 23 23 #include "SVGLineElement.h" 24 24 25 #include "LegacyRenderSVGShape.h" 25 26 #include "RenderSVGResource.h" 26 27 #include "SVGLengthValue.h"
Note:
See TracChangeset
for help on using the changeset viewer.