haikuwebkit/Source/WebCore/display/DisplayGeometryTypes.h

64 lines
2.2 KiB
C
Raw Permalink Normal View History

[LFC Display] Introduce type-safe rect types for the display tree https://bugs.webkit.org/show_bug.cgi?id=220214 Reviewed by Alan Bujtas. Introduce AbsoluteFloatRect, UnadjustedAbsoluteFloatRect and ViewFloatRect which are type-safe float rect types for the display tree. AbsoluteFloatRect is relative to document origin. UnadjustedAbsoluteFloatRect is similar, but is computed before scrolling and transforms are taken into account. ViewFloatRect is relative to the view. * WebCore.xcodeproj/project.pbxproj: * display/DisplayGeometryTypes.h: Copied from Source/WebCore/display/css/DisplayReplacedBox.h. (WebCore::Display::intersection): (WebCore::Display::unionRect): * display/DisplayTree.cpp: (WebCore::Display::Tree::setBoxNeedsDisplay const): * display/DisplayTree.h: * display/DisplayTreeBuilder.cpp: * display/css/DisplayBox.cpp: (WebCore::Display::Box::Box): (WebCore::Display::Box::setNeedsDisplay): * display/css/DisplayBox.h: (WebCore::Display::Box::Box): (WebCore::Display::Box::absoluteBoxRect const): (WebCore::Display::Box::absolutePaintingExtent const): * display/css/DisplayBoxClip.cpp: (WebCore::Display::BoxClip::pushClip): (WebCore::Display::BoxClip::pushRoundedClip): * display/css/DisplayBoxClip.h: (WebCore::Display::BoxClip::clipRect const): * display/css/DisplayBoxDecorationPainter.cpp: (WebCore::Display::BoxDecorationPainter::paintFillLayer const): * display/css/DisplayBoxFactory.cpp: (WebCore::Display::BoxFactory::displayBoxForRootBox const): (WebCore::Display::BoxFactory::displayBoxForLayoutBox const): (WebCore::Display::BoxFactory::displayBoxForTextRun const): (WebCore::Display::BoxFactory::setupBoxGeometry const): * display/css/DisplayBoxModelBox.cpp: (WebCore::Display::BoxModelBox::BoxModelBox): (WebCore::Display::BoxModelBox::clipForDescendants const): (WebCore::Display::BoxModelBox::absolutePaintingExtent const): * display/css/DisplayBoxModelBox.h: (WebCore::Display::BoxModelBox::BoxModelBox): (WebCore::Display::BoxModelBox::absoluteBorderBoxRect const): (WebCore::Display::BoxModelBox::absolutePaddingBoxRect const): (WebCore::Display::BoxModelBox::absoluteContentBoxRect const): (WebCore::Display::BoxModelBox::setAbsolutePaddingBoxRect): (WebCore::Display::BoxModelBox::setAbsoluteContentBoxRect): * display/css/DisplayContainerBox.cpp: (WebCore::Display::ContainerBox::ContainerBox): * display/css/DisplayContainerBox.h: * display/css/DisplayImageBox.cpp: (WebCore::Display::ImageBox::ImageBox): * display/css/DisplayImageBox.h: * display/css/DisplayReplacedBox.cpp: (WebCore::Display::ReplacedBox::ReplacedBox): * display/css/DisplayReplacedBox.h: (WebCore::Display::ReplacedBox::replacedContentRect const): (WebCore::Display::ReplacedBox::setReplacedContentRect): * display/css/DisplayStackingItem.h: (WebCore::Display::StackingItem::paintedContentBounds const): (WebCore::Display::StackingItem::paintedBoundsIncludingDescendantItems const): (WebCore::Display::StackingItem::setPaintedContentBounds): (WebCore::Display::StackingItem::setPaintedBoundsIncludingDescendantItems): * display/css/DisplayTextBox.cpp: (WebCore::Display::TextBox::TextBox): * display/css/DisplayTextBox.h: Canonical link: https://commits.webkit.org/240523@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-15 15:44:27 +00:00
/*
* Copyright (C) 2020 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
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "FloatRect.h"
namespace WebCore {
namespace Display {
// Absolute coordinates are anchored at the document origin.
class AbsoluteFloatRect : public FloatRect { };
// Absolute coordinates ignoring the effects of scrolling and transforms.
class UnadjustedAbsoluteFloatRect : public FloatRect { };
// View coordinates.
class ViewFloatRect : public FloatRect { };
template<typename T>
inline auto intersection(T& a, const T& b) -> typename std::enable_if_t<std::is_base_of_v<FloatRect, T>, T>
{
T c = a;
c.intersect(b);
return c;
}
template<typename T>
inline auto unionRect(T& a, const T& b) -> typename std::enable_if_t<std::is_base_of_v<FloatRect, T>, T>
{
T c = a;
c.unite(b);
return c;
}
} // namespace Display
} // namespace WebCore
#endif // ENABLE(LAYOUT_FORMATTING_CONTEXT)