haikuwebkit/Source/WebCore/dom/DOMRectInit.h

38 lines
1.5 KiB
C
Raw Permalink Normal View History

Implement DOMRect/DOMRectReadOnly https://bugs.webkit.org/show_bug.cgi?id=163464 Reviewed by Darin Adler. Source/WebCore: Implement the DOMRectInit/DOMRectReadOnly/DOMRect interfaces specified in https://dev.w3.org/fxtf/geometry/ DOMRects allow negative height/width and require double storage, so we can't just use FloatRect for storage. They also require handling of NaN and Infinity. To have the left/right/top/bottom accessors follow IEEE NaN rules, we need to use custom min/max functions that return NaN if either argument is NaN, so add nanPropagatingMin/nanPropagatingMax helpers to MathExtras.h. Test: fast/dom/domrect.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * dom/DOMRect.h: Added. (WebCore::DOMRect::create): (WebCore::DOMRect::fromRect): (WebCore::DOMRect::setX): (WebCore::DOMRect::setY): (WebCore::DOMRect::setWidth): (WebCore::DOMRect::setHeight): (WebCore::DOMRect::DOMRect): * dom/DOMRect.idl: Added. * dom/DOMRectInit.h: Added. * dom/DOMRectInit.idl: Added. * dom/DOMRectReadOnly.h: Added. (WebCore::DOMRectReadOnly::create): (WebCore::DOMRectReadOnly::fromRect): (WebCore::DOMRectReadOnly::x): (WebCore::DOMRectReadOnly::y): (WebCore::DOMRectReadOnly::width): (WebCore::DOMRectReadOnly::height): (WebCore::DOMRectReadOnly::top): (WebCore::DOMRectReadOnly::right): (WebCore::DOMRectReadOnly::bottom): (WebCore::DOMRectReadOnly::left): (WebCore::DOMRectReadOnly::DOMRectReadOnly): * dom/DOMRectReadOnly.idl: Added. Source/WTF: Implement min()/max() in a way that follows Math.min/Math.max, which return NaN if either argument is NaN. * wtf/MathExtras.h: (WTF::nanPropagatingMin): (WTF::nanPropagatingMax): LayoutTests: New test and new results for global constructor tests. * geometry/DOMRect-001-expected.txt: Added. * geometry/DOMRect-001.html: Added. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * js/dom/global-constructors-attributes-expected.txt: * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/181356@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-17 22:30:34 +00:00
/*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
namespace WebCore {
struct DOMRectInit {
double x { 0 };
double y { 0 };
double width { 0 };
double height { 0 };
};
}