File: RenderObjectInlines.h

package info (click to toggle)
webkit2gtk 2.51.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 455,340 kB
  • sloc: cpp: 3,865,253; javascript: 197,710; ansic: 165,177; python: 49,241; asm: 21,868; ruby: 18,095; perl: 16,926; xml: 4,623; sh: 2,409; yacc: 2,356; java: 2,019; lex: 1,330; pascal: 372; makefile: 210
file content (184 lines) | stat: -rw-r--r-- 6,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
 * Copyright (C) 2023 Apple Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#pragma once

#include <WebCore/DocumentPage.h>
#include <WebCore/FloatQuad.h>
#include <WebCore/FrameDestructionObserverInlines.h>
#include <WebCore/LocalFrameInlines.h>
#include <WebCore/RenderElement.h>
#include <WebCore/RenderIFrame.h>
#include <WebCore/RenderObject.h>
#include <WebCore/RenderObjectDocument.h>
#include <WebCore/RenderObjectNode.h>
#include <WebCore/RenderObjectStyle.h>
#include <WebCore/RenderReplaced.h>
#include <WebCore/RenderStyleInlines.h>
#include <WebCore/RenderView.h>
#include <WebCore/VisibleRectContext.h>

namespace WebCore {

inline bool RenderObject::hasTransformOrPerspective() const { return hasTransformRelatedProperty() && (isTransformed() || style().hasPerspective()); }
inline bool RenderObject::isAtomicInlineLevelBox() const { return style().isDisplayInlineType() && !(style().display() == DisplayType::Inline && !isBlockLevelReplacedOrAtomicInline()); }
inline bool RenderObject::isTransformed() const { return hasTransformRelatedProperty() && (style().affectsTransform() || hasSVGTransform()); }
inline LocalFrameViewLayoutContext& RenderObject::layoutContext() const { return view().frameView().layoutContext(); }
inline TreeScope& RenderObject::treeScopeForSVGReferences() const { return Ref { m_node.get() }->treeScopeForSVGReferences(); }

inline const RenderStyle& RenderObject::firstLineStyle() const
{
    if (isRenderText())
        return checkedParent()->firstLineStyle();
    return downcast<RenderElement>(*this).firstLineStyle();
}

inline Ref<TreeScope> RenderObject::protectedTreeScopeForSVGReferences() const
{
    return treeScopeForSVGReferences();
}

inline LocalFrame& RenderObject::frame() const
{
    return *document().frame();
}

inline Ref<LocalFrame> RenderObject::protectedFrame() const
{
    return frame();
}

inline Page& RenderObject::page() const
{
    // The render tree will always be torn down before Frame is disconnected from Page,
    // so it's safe to assume Frame::page() is non-null as long as there are live RenderObjects.
    ASSERT(frame().page());
    return *frame().page();
}

inline Ref<Page> RenderObject::protectedPage() const
{
    return page();
}

inline Settings& RenderObject::settings() const
{
    return page().settings();
}

inline FloatQuad RenderObject::localToAbsoluteQuad(const FloatQuad& quad, OptionSet<MapCoordinatesMode> mode, bool* wasFixed) const
{
    return localToContainerQuad(quad, nullptr, mode, wasFixed);
}

inline void RenderObject::setNeedsLayout(MarkingBehavior markParents)
{
    ASSERT(!isSetNeedsLayoutForbidden());
    if (selfNeedsLayout())
        return;
    m_stateBitfields.setFlag(StateFlag::NeedsLayout);
    if (markParents == MarkContainingBlockChain)
        scheduleLayout(CheckedPtr { markContainingBlocksForLayout() }.get());
    if (hasLayer())
        setLayerNeedsFullRepaint();
}

inline void RenderObject::setNeedsLayoutAndPreferredWidthsUpdate()
{
    setNeedsLayout();
    setNeedsPreferredWidthsUpdate();
}

inline bool RenderObject::isNonReplacedAtomicInlineLevelBox() const
{
    // FIXME: Check if iframe should really behave like non-replaced here.
    return (is<RenderIFrame>(*this) && isInline()) || (!is<RenderReplaced>(*this) && isAtomicInlineLevelBox());
}

inline auto RenderObject::visibleRectContextForRepaint() -> VisibleRectContext
{
    return {
        .hasPositionFixedDescendant = false,
        .dirtyRectIsFlipped = false,
        .descendantNeedsEnclosingIntRect = false,
        .options = {
            VisibleRectContext::Option::ApplyContainerClip,
            VisibleRectContext::Option::ApplyCompositedContainerScrolls
        },
        .scrollMargin = { },
    };
}

inline auto RenderObject::visibleRectContextForSpatialNavigation() -> VisibleRectContext
{
    return {
        .hasPositionFixedDescendant = false,
        .dirtyRectIsFlipped = false,
        .descendantNeedsEnclosingIntRect = false,
        .options = {
            VisibleRectContext::Option::ApplyContainerClip,
            VisibleRectContext::Option::ApplyCompositedContainerScrolls,
            VisibleRectContext::Option::ApplyCompositedClips
        },
        .scrollMargin = { },
    };
}

inline auto RenderObject::visibleRectContextForRenderTreeAsText() -> VisibleRectContext
{
    return {
        .hasPositionFixedDescendant = false,
        .dirtyRectIsFlipped = false,
        .descendantNeedsEnclosingIntRect = false,
        .options = {
            VisibleRectContext::Option::ApplyContainerClip,
            VisibleRectContext::Option::ApplyCompositedContainerScrolls,
            VisibleRectContext::Option::ApplyCompositedClips,
            VisibleRectContext::Option::CalculateAccurateRepaintRect
        },
        .scrollMargin = { },
    };
}

inline LayoutRect RenderObject::absoluteClippedOverflowRectForRepaint() const
{
    return clippedOverflowRect(nullptr, visibleRectContextForRepaint());
}

inline LayoutRect RenderObject::absoluteClippedOverflowRectForSpatialNavigation() const
{
    return clippedOverflowRect(nullptr, visibleRectContextForSpatialNavigation());
}

inline LayoutRect RenderObject::absoluteClippedOverflowRectForRenderTreeAsText() const
{
    return clippedOverflowRect(nullptr, visibleRectContextForRenderTreeAsText());
}

inline LayoutRect RenderObject::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
{
    return clippedOverflowRect(repaintContainer, visibleRectContextForRepaint());
}

inline LayoutRect RenderObject::computeRectForRepaint(const LayoutRect& rect, const RenderLayerModelObject* repaintContainer) const
{
    return computeRects({ rect }, repaintContainer, visibleRectContextForRepaint()).clippedOverflowRect;
}

} // namespace WebCore