Changeset 186858 in webkit


Ignore:
Timestamp:
Jul 15, 2015 2:19:29 PM (9 years ago)
Author:
timothy_horton@apple.com
Message:

Factor rect shrink-wrapping code out of RenderThemeMac for future reuse
https://bugs.webkit.org/show_bug.cgi?id=146973
<rdar://problem/21643094>

Reviewed by Anders Carlsson.

Test: fast/shrink-wrap/rect-shrink-wrap.html

  • WebCore.xcodeproj/project.pbxproj:

Add DOMPath.cpp and PathUtilities.{h, cpp}.

  • bindings/js/JSDOMBinding.h:

(WebCore::NativeValueTraits<double>::nativeValue):
Make it possible to use sequence<double> in IDL files.

  • bindings/scripts/CodeGeneratorJS.pm:

Export JSDOMPath for use in Internals.

  • html/canvas/DOMPath.cpp: Added.

(WebCore::DOMPath::~DOMPath):

  • html/canvas/DOMPath.h:

Out-of-line the DOMPath destructor so as not to anger the bindings
integrity checker (otherwise, the address of the DOMPath destructor
is different in WebCoreTestSupport and WebCore, causing us to fail
the vtable equality test).

  • platform/graphics/Path.h:

Forward declare FloatRect instead of including it unnecessarily.
Export ensurePlatformPath().

  • platform/graphics/PathUtilities.cpp: Added.

(WebCore::addShrinkWrapRightCorner):
(WebCore::addShrinkWrapLeftCorner):
(WebCore::addShrinkWrappedPathForRects):
These parts are extracted from RenderThemeMac, with two changes:

+ support for arbitrarily-aligned rects

(the other version assumed they were horizontally center-aligned)

+ support for overlapping rects

(the other version assumed they touched but did not overlap)

There are still things missing:

+ support for a fallback when the shape is too hard to shrink-wrap

And things broken:

+ if the distance between two edges is smaller than the corner radius,

we'll end up with a sharp edge in the path

Both of these cases are covered in the layout test and can be improved.

(WebCore::rectsIntersectOrTouch):
Rect intersection with <= instead of <.

(WebCore::contiguousRectGroupsFromRects):
Given a set of rects, find all of the contiguous regions. We'll
shrink-wrap each region independently.

(WebCore::PathUtilities::pathWithShrinkWrappedRects):

  • platform/graphics/PathUtilities.h: Added.

Add PathUtilities, where the shrink-wrapping code lives.

  • rendering/RenderThemeMac.mm:

(WebCore::paintAttachmentTitleBackground):
(WebCore::addAttachmentTitleBackgroundRightCorner): Deleted.
(WebCore::addAttachmentTitleBackgroundLeftCorner): Deleted.
Remove shrink-wrapping implementation and make use of the one in PathUtilities.

  • testing/Internals.cpp:

(WebCore::Internals::pathWithShrinkWrappedRects):

  • testing/Internals.h:
  • testing/Internals.idl:

Expose pathWithShrinkWrappedRects to tests via Internals.
It takes a sequence<double> where every four values are the x, y, w, h
of a rect, and returns a DOMPath which can be used with Canvas.

  • fast/shrink-wrap/rect-shrink-wrap-expected.png: Added.
  • fast/shrink-wrap/rect-shrink-wrap-expected.txt: Added.
  • fast/shrink-wrap/rect-shrink-wrap.html: Added.

Add a test of both working and broken (indicated by comments in the test)
shrink-wrapping cases.

Location:
trunk
Files:
7 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r186840 r186858  
     12015-07-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Factor rect shrink-wrapping code out of RenderThemeMac for future reuse
     4        https://bugs.webkit.org/show_bug.cgi?id=146973
     5        <rdar://problem/21643094>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        * fast/shrink-wrap/rect-shrink-wrap-expected.png: Added.
     10        * fast/shrink-wrap/rect-shrink-wrap-expected.txt: Added.
     11        * fast/shrink-wrap/rect-shrink-wrap.html: Added.
     12        Add a test of both working and broken (indicated by comments in the test)
     13        shrink-wrapping cases.
     14
    1152015-07-15  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/Source/WebCore/CMakeLists.txt

    r186803 r186858  
    17431743    html/canvas/CanvasRenderingContext2D.cpp
    17441744    html/canvas/CanvasStyle.cpp
     1745    html/canvas/DOMPath.cpp
    17451746    html/canvas/EXTBlendMinMax.cpp
    17461747    html/canvas/EXTFragDepth.cpp
     
    21722173    platform/graphics/Path.cpp
    21732174    platform/graphics/PathTraversalState.cpp
     2175    platform/graphics/PathUtilities.cpp
    21742176    platform/graphics/Pattern.cpp
    21752177    platform/graphics/PlatformTimeRanges.cpp
  • trunk/Source/WebCore/ChangeLog

    r186857 r186858  
     12015-07-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Factor rect shrink-wrapping code out of RenderThemeMac for future reuse
     4        https://bugs.webkit.org/show_bug.cgi?id=146973
     5        <rdar://problem/21643094>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        Test: fast/shrink-wrap/rect-shrink-wrap.html
     10
     11        * WebCore.xcodeproj/project.pbxproj:
     12        Add DOMPath.cpp and PathUtilities.{h, cpp}.
     13
     14        * bindings/js/JSDOMBinding.h:
     15        (WebCore::NativeValueTraits<double>::nativeValue):
     16        Make it possible to use sequence<double> in IDL files.
     17
     18        * bindings/scripts/CodeGeneratorJS.pm:
     19        Export JSDOMPath for use in Internals.
     20
     21        * html/canvas/DOMPath.cpp: Added.
     22        (WebCore::DOMPath::~DOMPath):
     23        * html/canvas/DOMPath.h:
     24        Out-of-line the DOMPath destructor so as not to anger the bindings
     25        integrity checker (otherwise, the address of the DOMPath destructor
     26        is different in WebCoreTestSupport and WebCore, causing us to fail
     27        the vtable equality test).
     28
     29        * platform/graphics/Path.h:
     30        Forward declare FloatRect instead of including it unnecessarily.
     31        Export ensurePlatformPath().
     32
     33        * platform/graphics/PathUtilities.cpp: Added.
     34        (WebCore::addShrinkWrapRightCorner):
     35        (WebCore::addShrinkWrapLeftCorner):
     36        (WebCore::addShrinkWrappedPathForRects):
     37        These parts are extracted from RenderThemeMac, with two changes:
     38            + support for arbitrarily-aligned rects
     39              (the other version assumed they were horizontally center-aligned)
     40            + support for overlapping rects
     41              (the other version assumed they touched but did not overlap)
     42
     43        There are still things missing:
     44            + support for a fallback when the shape is too hard to shrink-wrap
     45
     46        And things broken:
     47            + if the distance between two edges is smaller than the corner radius,
     48              we'll end up with a sharp edge in the path
     49
     50        Both of these cases are covered in the layout test and can be improved.
     51
     52        (WebCore::rectsIntersectOrTouch):
     53        Rect intersection with <= instead of <.
     54
     55        (WebCore::contiguousRectGroupsFromRects):
     56        Given a set of rects, find all of the contiguous regions. We'll
     57        shrink-wrap each region independently.
     58
     59        (WebCore::PathUtilities::pathWithShrinkWrappedRects):
     60        * platform/graphics/PathUtilities.h: Added.
     61        Add PathUtilities, where the shrink-wrapping code lives.
     62
     63        * rendering/RenderThemeMac.mm:
     64        (WebCore::paintAttachmentTitleBackground):
     65        (WebCore::addAttachmentTitleBackgroundRightCorner): Deleted.
     66        (WebCore::addAttachmentTitleBackgroundLeftCorner): Deleted.
     67        Remove shrink-wrapping implementation and make use of the one in PathUtilities.
     68
     69        * testing/Internals.cpp:
     70        (WebCore::Internals::pathWithShrinkWrappedRects):
     71        * testing/Internals.h:
     72        * testing/Internals.idl:
     73        Expose pathWithShrinkWrappedRects to tests via Internals.
     74        It takes a sequence<double> where every four values are the x, y, w, h
     75        of a rect, and returns a DOMPath which can be used with Canvas.
     76
    1772015-07-15  Enrica Casucci  <enrica@apple.com>
    278
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r186856 r186858  
    11251125                2D4F96F71A1ECC240098BF88 /* TextIndicatorWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D4F96F31A1ECC240098BF88 /* TextIndicatorWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11261126                2D4F96F81A1ECC240098BF88 /* TextIndicatorWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4F96F41A1ECC240098BF88 /* TextIndicatorWindow.mm */; };
     1127                2D5002F81B56D7810020AAF7 /* DOMPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5002F71B56D7810020AAF7 /* DOMPath.cpp */; };
     1128                2D5002FB1B56D7990020AAF7 /* PathUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */; };
     1129                2D5002FC1B56D7990020AAF7 /* PathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5002FA1B56D7990020AAF7 /* PathUtilities.h */; };
    11271130                2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D58D8531A15F65F00A5F726 /* DataDetection.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11281131                2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D58D8541A15F65F00A5F726 /* DataDetection.mm */; };
     
    83028305                2D4F96F31A1ECC240098BF88 /* TextIndicatorWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextIndicatorWindow.h; sourceTree = "<group>"; };
    83038306                2D4F96F41A1ECC240098BF88 /* TextIndicatorWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextIndicatorWindow.mm; sourceTree = "<group>"; };
     8307                2D5002F71B56D7810020AAF7 /* DOMPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMPath.cpp; sourceTree = "<group>"; };
     8308                2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathUtilities.cpp; sourceTree = "<group>"; };
     8309                2D5002FA1B56D7990020AAF7 /* PathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PathUtilities.h; sourceTree = "<group>"; };
    83048310                2D58D8531A15F65F00A5F726 /* DataDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetection.h; sourceTree = "<group>"; };
    83058311                2D58D8541A15F65F00A5F726 /* DataDetection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetection.mm; sourceTree = "<group>"; };
     
    1617916185                                49484FBF102CF23C00187DD3 /* CanvasStyle.cpp */,
    1618016186                                49484FC0102CF23C00187DD3 /* CanvasStyle.h */,
     16187                                2D5002F71B56D7810020AAF7 /* DOMPath.cpp */,
    1618116188                                FB91392016AE4B0B001FE682 /* DOMPath.h */,
    1618216189                                FB91392116AE4B0B001FE682 /* DOMPath.idl */,
     
    2103021037                                A88DD4880B4629B000C02990 /* PathTraversalState.cpp */,
    2103121038                                A88DD4860B4629A300C02990 /* PathTraversalState.h */,
     21039                                2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */,
     21040                                2D5002FA1B56D7990020AAF7 /* PathUtilities.h */,
    2103221041                                A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
    2103321042                                A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
     
    2414624155                                06027CAD0B1CBFC000884B2D /* ContextMenuItem.h in Headers */,
    2414724156                                7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */,
     24157                                2D5002FC1B56D7990020AAF7 /* PathUtilities.h in Headers */,
    2414824158                                759CB837192DA9190012BC64 /* ControlStates.h in Headers */,
    2414924159                                FD31602912B0267600C1A359 /* ConvolverNode.h in Headers */,
     
    2974029750                                AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerIOS.mm in Sources */,
    2974129751                                297BE3D816C03CCE003316BD /* PlatformSpeechSynthesizerMac.mm in Sources */,
     29752                                2D5002FB1B56D7990020AAF7 /* PathUtilities.cpp in Sources */,
    2974229753                                1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */,
    2974329754                                074E82BA18A69F0E007EF54C /* PlatformTimeRanges.cpp in Sources */,
     
    3051330524                                7A93868518DCC14500B8263D /* VTTScanner.cpp in Sources */,
    3051430525                                A14832B1187F61E100DA63A6 /* WAKAppKitStubs.m in Sources */,
     30526                                2D5002F81B56D7810020AAF7 /* DOMPath.cpp in Sources */,
    3051530527                                A14832B3187F629100DA63A6 /* WAKClipView.m in Sources */,
    3051630528                                A14832B5187F62FC00DA63A6 /* WAKResponder.m in Sources */,
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r186414 r186858  
    508508};
    509509
     510template<> struct NativeValueTraits<double> {
     511    static inline bool nativeValue(JSC::ExecState* exec, JSC::JSValue jsValue, double& indexedValue)
     512    {
     513        indexedValue = jsValue.toNumber(exec);
     514        return !exec->hadException();
     515    }
     516};
     517
    510518template<typename T, typename JST> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState* exec, JSC::JSValue value, T* (*toT)(JSC::JSValue value))
    511519{
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r186323 r186858  
    241241    "JSCSSStyleDeclaration" => 1,
    242242    "JSDocument" => 1,
     243    "JSDOMPath" => 1,
    243244    "JSDOMWindow" => 1,
    244245    "JSElement" => 1,
  • trunk/Source/WebCore/html/canvas/DOMPath.h

    r177733 r186858  
    3636namespace WebCore {
    3737
    38 class DOMPath final : public RefCounted<DOMPath>, public CanvasPathMethods {
     38class WEBCORE_EXPORT DOMPath final : public RefCounted<DOMPath>, public CanvasPathMethods {
    3939    WTF_MAKE_FAST_ALLOCATED;
    4040public:
     41    WEBCORE_EXPORT virtual ~DOMPath();
     42
    4143    static Ref<DOMPath> create() { return adoptRef(*new DOMPath); }
    4244    static Ref<DOMPath> create(const Path& path) { return adoptRef(*new DOMPath(path)); }
  • trunk/Source/WebCore/platform/graphics/Path.h

    r182828 r186858  
    2929#define Path_h
    3030
     31#include "FloatRect.h"
    3132#include "WindRule.h"
    3233#include <wtf/FastMalloc.h>
     
    5758    class AffineTransform;
    5859    class FloatPoint;
    59     class FloatRect;
    6060    class FloatRoundedRect;
    6161    class FloatSize;
     
    145145        PlatformPathPtr platformPath() const { return m_path; }
    146146        // ensurePlatformPath() will allocate a PlatformPath if it has not yet been and will never return null.
    147         PlatformPathPtr ensurePlatformPath();
     147        WEBCORE_EXPORT PlatformPathPtr ensurePlatformPath();
    148148
    149149        WEBCORE_EXPORT void apply(void* info, PathApplierFunction) const;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r186399 r186858  
    5353#import "Page.h"
    5454#import "PaintInfo.h"
     55#import "PathUtilities.h"
    5556#import "RenderAttachment.h"
    5657#import "RenderLayer.h"
     
    23802381}
    23812382
    2382 static void addAttachmentTitleBackgroundRightCorner(Path& path, const FloatRect* fromRect, const FloatRect* toRect)
    2383 {
    2384     FloatSize horizontalRadius(attachmentTitleBackgroundRadius, 0);
    2385     FloatSize verticalRadius(0, attachmentTitleBackgroundRadius);
    2386 
    2387     if (!fromRect) {
    2388         // For the first (top) rect:
    2389 
    2390         path.moveTo(toRect->minXMinYCorner() + horizontalRadius);
    2391 
    2392         // Across the top, towards the right.
    2393         path.addLineTo(toRect->maxXMinYCorner() - horizontalRadius);
    2394 
    2395         // Arc the top corner.
    2396         path.addArcTo(toRect->maxXMinYCorner(), toRect->maxXMinYCorner() + verticalRadius, attachmentTitleBackgroundRadius);
    2397 
    2398         // Down the right.
    2399         path.addLineTo(toRect->maxXMaxYCorner() - verticalRadius);
    2400     } else if (!toRect) {
    2401         // For the last rect:
    2402 
    2403         // Arc the bottom corner.
    2404         path.addArcTo(fromRect->maxXMaxYCorner(), fromRect->maxXMaxYCorner() - horizontalRadius, attachmentTitleBackgroundRadius);
    2405     } else {
    2406         // For middle rects:
    2407 
    2408         float widthDifference = toRect->width() - fromRect->width();
    2409 
    2410         // Skip over very similar-width rects, because we can't make
    2411         // sensible curves between them.
    2412         if (fabs(widthDifference) < std::numeric_limits<float>::epsilon())
    2413             return;
    2414 
    2415         if (widthDifference < 0) {
    2416             // Arc the outer corner.
    2417             path.addArcTo(FloatPoint(fromRect->maxX(), toRect->y()), FloatPoint(fromRect->maxX(), toRect->y()) - horizontalRadius, attachmentTitleBackgroundRadius);
    2418 
    2419             // Across the bottom, towards the left.
    2420             path.addLineTo(toRect->maxXMinYCorner() + horizontalRadius);
    2421 
    2422             // Arc the inner corner.
    2423             path.addArcTo(toRect->maxXMinYCorner(), toRect->maxXMinYCorner() + verticalRadius, attachmentTitleBackgroundRadius);
    2424         } else {
    2425             // Arc the inner corner.
    2426             path.addArcTo(FloatPoint(fromRect->maxX(), toRect->y()), FloatPoint(fromRect->maxX(), toRect->y()) + horizontalRadius, attachmentTitleBackgroundRadius);
    2427 
    2428             // Across the bottom, towards the right.
    2429             path.addLineTo(toRect->maxXMinYCorner() - horizontalRadius);
    2430 
    2431             // Arc the outer corner.
    2432             path.addArcTo(toRect->maxXMinYCorner(), toRect->maxXMinYCorner() + verticalRadius, attachmentTitleBackgroundRadius);
    2433         }
    2434 
    2435         // Down the right.
    2436         path.addLineTo(toRect->maxXMaxYCorner() - verticalRadius);
    2437     }
    2438 }
    2439 
    2440 static void addAttachmentTitleBackgroundLeftCorner(Path& path, const FloatRect* fromRect, const FloatRect* toRect)
    2441 {
    2442     FloatSize horizontalRadius(attachmentTitleBackgroundRadius, 0);
    2443     FloatSize verticalRadius(0, attachmentTitleBackgroundRadius);
    2444 
    2445     if (!fromRect) {
    2446         // For the first (bottom) rect:
    2447 
    2448         // Across the bottom, towards the left.
    2449         path.addLineTo(toRect->minXMaxYCorner() + horizontalRadius);
    2450 
    2451         // Arc the bottom corner.
    2452         path.addArcTo(toRect->minXMaxYCorner(), toRect->minXMaxYCorner() - verticalRadius, attachmentTitleBackgroundRadius);
    2453 
    2454         // Up the left.
    2455         path.addLineTo(toRect->minXMinYCorner() + verticalRadius);
    2456     } else if (!toRect) {
    2457         // For the last (top) rect:
    2458 
    2459         // Arc the top corner.
    2460         path.addArcTo(fromRect->minXMinYCorner(), fromRect->minXMinYCorner() + horizontalRadius, attachmentTitleBackgroundRadius);
    2461     } else {
    2462         // For middle rects:
    2463         float widthDifference = toRect->width() - fromRect->width();
    2464 
    2465         // Skip over very similar-width rects, because we can't make
    2466         // sensible curves between them.
    2467         if (fabs(widthDifference) < std::numeric_limits<float>::epsilon())
    2468             return;
    2469 
    2470         if (widthDifference < 0) {
    2471             // Arc the inner corner.
    2472             path.addArcTo(FloatPoint(fromRect->x(), toRect->maxY()), FloatPoint(fromRect->x(), toRect->maxY()) + horizontalRadius, attachmentTitleBackgroundRadius);
    2473 
    2474             // Across the bottom, towards the right.
    2475             path.addLineTo(toRect->minXMaxYCorner() - horizontalRadius);
    2476 
    2477             // Arc the outer corner.
    2478             path.addArcTo(toRect->minXMaxYCorner(), toRect->minXMaxYCorner() - verticalRadius, attachmentTitleBackgroundRadius);
    2479         } else {
    2480             // Arc the outer corner.
    2481             path.addArcTo(FloatPoint(fromRect->x(), toRect->maxY()), FloatPoint(fromRect->x(), toRect->maxY()) - horizontalRadius, attachmentTitleBackgroundRadius);
    2482 
    2483             // Across the bottom, towards the left.
    2484             path.addLineTo(toRect->minXMaxYCorner() + horizontalRadius);
    2485 
    2486             // Arc the inner corner.
    2487             path.addArcTo(toRect->minXMaxYCorner(), toRect->minXMaxYCorner() - verticalRadius, attachmentTitleBackgroundRadius);
    2488         }
    2489        
    2490         // Up the right.
    2491         path.addLineTo(toRect->minXMinYCorner() + verticalRadius);
    2492     }
    2493 }
    2494 
    24952383static void paintAttachmentTitleBackground(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
    24962384{
     
    24982386        return;
    24992387
    2500     Path backgroundPath;
    2501 
    2502     for (size_t i = 0; i <= layout.lines.size(); ++i)
    2503         addAttachmentTitleBackgroundRightCorner(backgroundPath, i ? &layout.lines[i - 1].backgroundRect : nullptr, i < layout.lines.size() ? &layout.lines[i].backgroundRect : nullptr);
    2504 
    2505     for (size_t i = 0; i <= layout.lines.size(); ++i) {
    2506         size_t reverseIndex = layout.lines.size() - i;
    2507         addAttachmentTitleBackgroundLeftCorner(backgroundPath, reverseIndex < layout.lines.size() ? &layout.lines[reverseIndex].backgroundRect : nullptr, reverseIndex ? &layout.lines[reverseIndex - 1].backgroundRect : nullptr);
    2508     }
    2509 
    2510     backgroundPath.closeSubpath();
     2388    Vector<FloatRect> backgroundRects;
     2389
     2390    for (size_t i = 0; i < layout.lines.size(); ++i)
     2391        backgroundRects.append(layout.lines[i].backgroundRect);
    25112392
    25122393    Color backgroundColor;
     
    25172398
    25182399    context.setFillColor(backgroundColor, ColorSpaceDeviceRGB);
     2400
     2401    Path backgroundPath = PathUtilities::pathWithShrinkWrappedRects(backgroundRects, attachmentTitleBackgroundRadius);
    25192402    context.fillPath(backgroundPath);
    25202403}
  • trunk/Source/WebCore/testing/Internals.cpp

    r186388 r186858  
    4040#include "ContentDistributor.h"
    4141#include "Cursor.h"
     42#include "DOMPath.h"
    4243#include "DOMStringList.h"
    4344#include "DOMWindow.h"
     
    8889#include "PageCache.h"
    8990#include "PageOverlay.h"
     91#include "PathUtilities.h"
    9092#include "PlatformMediaSessionManager.h"
    9193#include "PrintContext.h"
     
    29202922}
    29212923
    2922 }
     2924PassRefPtr<DOMPath> Internals::pathWithShrinkWrappedRects(Vector<double> rectComponents, ExceptionCode& ec)
     2925{
     2926    if (rectComponents.size() % 4) {
     2927        ec = INVALID_ACCESS_ERR;
     2928        return nullptr;
     2929    }
     2930
     2931    Vector<FloatRect> rects;
     2932    while (!rectComponents.isEmpty()) {
     2933        double height = rectComponents.takeLast();
     2934        double width = rectComponents.takeLast();
     2935        double y = rectComponents.takeLast();
     2936        double x = rectComponents.takeLast();
     2937
     2938        rects.append(FloatRect(x, y, width, height));
     2939    }
     2940
     2941    rects.reverse();
     2942
     2943    // FIXME: radius should be a parameter instead of fixed as 8.
     2944    Path path = PathUtilities::pathWithShrinkWrappedRects(rects, 8);
     2945    return DOMPath::create(path);
     2946}
     2947
     2948}
  • trunk/Source/WebCore/testing/Internals.h

    r186388 r186858  
    4545class ClientRect;
    4646class ClientRectList;
     47class DOMPath;
    4748class DOMStringList;
    4849class DOMWindow;
     
    415416#endif
    416417
     418    PassRefPtr<DOMPath> pathWithShrinkWrappedRects(Vector<double>, ExceptionCode&);
     419
    417420private:
    418421    explicit Internals(Document*);
  • trunk/Source/WebCore/testing/Internals.idl

    r186388 r186858  
    376376    [RaisesException] DOMString scrollSnapOffsets(Element element);
    377377#endif
     378
     379    [RaisesException] DOMPath pathWithShrinkWrappedRects(sequence<double> rectComponents);
    378380};
Note: See TracChangeset for help on using the changeset viewer.