source: webkit/trunk/Source/WebCore/rendering/RenderFullScreen.cpp

Last change on this file was 288067, checked in by Darin Adler, 3 years ago

First step to fix hacked isReplaced: Rename isReplaced functions to isReplacedOrInlineBlock
https://bugs.webkit.org/show_bug.cgi?id=235258

Reviewed by Alan Bujtas.

The isReplaced function returns true for things that are not CSS replaced
elements. That's confusing and not good. We want to straighten this out.
In this first step, we rename the isReplaced and setReplaced functions
to isReplacedOrInlineBlock and setReplacedOrInlineBlock. There are still
functions with out arguments named "isReplaced", which we can deal with
later. Other later clean-up and clarification could one day change what
bits we store in RenderStyle and possibly even remove this function entirely.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::nextContinuation):

  • accessibility/atk/WebKitAccessible.cpp:

(interfaceMaskFromObject):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::isNonReplacedInline):

  • dom/Node.cpp:

(WebCore::Node::renderRect):

  • dom/Position.cpp:

(WebCore::endsOfNodeAreVisuallyDistinctPositions):

  • editing/VisiblePosition.cpp:

(WebCore::VisiblePosition::leftVisuallyDistinctCandidate const):
(WebCore::VisiblePosition::rightVisuallyDistinctCandidate const):

  • layout/integration/LayoutIntegrationCoverage.cpp:

(WebCore::LayoutIntegration::canUseForChild):

  • layout/integration/LayoutIntegrationLineLayout.cpp:

(WebCore::LayoutIntegration::LineLayout::paint):

  • page/TextIndicator.cpp:

(WebCore::hasNonInlineOrReplacedElements):

  • page/ios/FrameIOS.mm:

(WebCore::Frame::renderRectForPoint const):

  • rendering/CaretRectComputation.cpp:

(WebCore::computeCaretRectForBox):

  • rendering/LegacyInlineBox.cpp:

(WebCore::LegacyInlineBox::adjustPosition):
(WebCore::LegacyInlineBox::canAccommodateEllipsis const):

  • rendering/LegacyInlineFlowBox.cpp:

(WebCore::LegacyInlineFlowBox::addToLine):
(WebCore::LegacyInlineFlowBox::computeOverAnnotationAdjustment const):
(WebCore::LegacyInlineFlowBox::computeUnderAnnotationAdjustment const):

  • rendering/LegacyInlineIterator.h:

(WebCore::isIteratorTarget):

  • rendering/LegacyLineLayout.cpp:

(WebCore::LegacyLineLayout::computeInlineDirectionPositionsForLine):
(WebCore::LegacyLineLayout::layoutLineBoxes):

  • rendering/LegacyRootInlineBox.cpp:

(WebCore::LegacyRootInlineBox::ascentAndDescentForBox const):
(WebCore::LegacyRootInlineBox::verticalPositionForBox):
(WebCore::LegacyRootInlineBox::includeLeadingForBox const):
(WebCore::LegacyRootInlineBox::includeFontForBox const):
(WebCore::LegacyRootInlineBox::includeGlyphsForBox const):
(WebCore::LegacyRootInlineBox::includeInitialLetterForBox const):
(WebCore::LegacyRootInlineBox::includeMarginForBox const):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::removePositionedObjectsIfNeeded):
(WebCore::RenderBlock::styleWillChange):
(WebCore::RenderBlock::simplifiedNormalFlowLayout):
(WebCore::RenderBlock::paintChild):
(WebCore::RenderBlock::positionForPoint):
(WebCore::RenderBlock::lineHeight const):
(WebCore::RenderBlock::baselinePosition const):
(WebCore::RenderBlock::firstLineBlock const):
(WebCore::findFirstLetterBlock):
(WebCore::RenderBlock::getFirstLetter):

  • rendering/RenderBlock.h:
  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::rebuildFloatingObjectSetFromIntrudingFloats):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
(WebCore::InlineMinMaxIterator::next):
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::offsetFromContainer const):
(WebCore::RenderBox::positionLineBox):
(WebCore::RenderBox::computeLogicalHeight const):
(WebCore::RenderBox::shouldTreatChildAsReplacedInTableCells const):
(WebCore::RenderBox::computePositionedLogicalWidth const):
(WebCore::RenderBox::computePositionedLogicalHeight const):
(WebCore::RenderBox::avoidsFloats const):
(WebCore::RenderBox::isUnsplittableForPagination const):
(WebCore::RenderBox::lineHeight const):
(WebCore::RenderBox::baselinePosition const):

  • rendering/RenderBox.h:

(WebCore::RenderBox::shouldComputeSizeAsReplaced const):

  • rendering/RenderBoxModelObject.h:

(WebCore::RenderBoxModelObject::canHaveBoxInfoInFragment const):

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
(WebCore::RenderDeprecatedFlexibleBox::clearLineClamp):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::getLeadingCorner const):
(WebCore::RenderElement::getTrailingCorner const):
(WebCore::RenderElement::absoluteAnchorRect const):

  • rendering/RenderFullScreen.cpp:

(WebCore::RenderFullScreen::RenderFullScreen):

  • rendering/RenderLineBoxList.cpp:

(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):

  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::RenderListMarker):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::containingBlockForPositionType):
(WebCore::RenderObject::caretMaxOffset const):

  • rendering/RenderObject.h:

(WebCore::RenderObject::hasIntrinsicAspectRatio const):
(WebCore::RenderObject::isReplacedOrInlineBlock const):
(WebCore::RenderObject::setReplacedOrInlineBlock):
(WebCore::RenderObject::RenderObjectBitfields::RenderObjectBitfields):
(WebCore::RenderObject::isAtomicInlineLevelBox const):
(WebCore::RenderObject::isReplaced const): Deleted.
(WebCore::RenderObject::setReplaced): Deleted.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::RenderReplaced):

  • rendering/RenderReplica.cpp:

(WebCore::RenderReplica::RenderReplica):

  • rendering/RenderRubyRun.cpp:

(WebCore::RenderRubyRun::RenderRubyRun):

  • rendering/line/BreakingContext.h:

(WebCore::BreakingContext::initializeForCurrentObject):
(WebCore::BreakingContext::canBreakAtThisPosition):
(WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):

  • rendering/line/LineBreaker.cpp:

(WebCore::LineBreaker::nextLineBreak):

  • rendering/updating/RenderTreeBuilderInline.cpp:

(WebCore::nextContinuation):
Renamed in all these places. Also added one FIXME for something
Alan pointed out we'd like to do in the future.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::removeOnlyThisLayer): Removed unhelpful use
of RenderLayer::reflection function just to find out whether the
RenderLayer::reflectionLayer function will return null or not.

  • rendering/RenderLayer.h: Removed unneeded RenderLayer::reflection.
  • rendering/RenderLayerCompositor.cpp: Removed an unneeded include

of RenderReplica.h.

  • Property svn:eol-style set to native
File size: 7.0 KB
Line 
1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "config.h"
26
27#if ENABLE(FULLSCREEN_API)
28
29#include "RenderFullScreen.h"
30
31#include "FullscreenManager.h"
32#include "RenderBlockFlow.h"
33#include "RenderLayer.h"
34#include "RenderLayerCompositor.h"
35#include "RenderTreeBuilder.h"
36#include <wtf/IsoMallocInlines.h>
37
38namespace WebCore {
39
40WTF_MAKE_ISO_ALLOCATED_IMPL(RenderFullScreen);
41
42RenderFullScreenPlaceholder::RenderFullScreenPlaceholder(Document& document, RenderStyle&& style)
43 : RenderBlockFlow(document, WTFMove(style))
44{
45}
46
47bool RenderFullScreenPlaceholder::isRenderFullScreenPlaceholder() const
48{
49 return true;
50}
51
52WTF_MAKE_ISO_ALLOCATED_IMPL(RenderFullScreenPlaceholder);
53
54RenderFullScreen::RenderFullScreen(Document& document, RenderStyle&& style)
55 : RenderFlexibleBox(document, WTFMove(style))
56{
57 setReplacedOrInlineBlock(false);
58}
59
60RenderFullScreen::~RenderFullScreen()
61{
62 ASSERT(!m_placeholder);
63}
64
65static RenderStyle createFullScreenStyle()
66{
67 auto fullscreenStyle = RenderStyle::create();
68
69 // Create a stacking context:
70 fullscreenStyle.setUsedZIndex(INT_MAX);
71
72 fullscreenStyle.setFontDescription({ });
73 fullscreenStyle.fontCascade().update(nullptr);
74
75 fullscreenStyle.setDisplay(DisplayType::Flex);
76 fullscreenStyle.setJustifyContentPosition(ContentPosition::Center);
77 fullscreenStyle.setAlignItemsPosition(ItemPosition::Center);
78 fullscreenStyle.setFlexDirection(FlexDirection::Column);
79
80 fullscreenStyle.setPosition(PositionType::Fixed);
81 fullscreenStyle.setWidth(Length(100.0, LengthType::Percent));
82 fullscreenStyle.setHeight(Length(100.0, LengthType::Percent));
83 fullscreenStyle.setLeft(Length(0, LengthType::Fixed));
84 fullscreenStyle.setTop(Length(0, LengthType::Fixed));
85
86 fullscreenStyle.setBackgroundColor(Color::black);
87
88 return fullscreenStyle;
89}
90
91RenderPtr<RenderFullScreen> RenderFullScreen::wrapNewRenderer(RenderTreeBuilder& builder, RenderPtr<RenderElement> renderer, RenderElement& parent, Document& document)
92{
93 auto newFullscreenRenderer = createRenderer<RenderFullScreen>(document, createFullScreenStyle());
94 newFullscreenRenderer->initializeStyle();
95
96 auto& fullscreenRenderer = *newFullscreenRenderer;
97 if (!parent.isChildAllowed(fullscreenRenderer, fullscreenRenderer.style()))
98 return nullptr;
99
100 builder.attach(fullscreenRenderer, WTFMove(renderer));
101 fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
102
103 document.fullscreenManager().setFullscreenRenderer(builder, fullscreenRenderer);
104
105 return newFullscreenRenderer;
106}
107
108void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& document)
109{
110 // FIXME: This should be done by RenderTreeUpdater.
111 RenderTreeBuilder builder(*document.renderView());
112
113 auto newFullscreenRenderer = createRenderer<RenderFullScreen>(document, createFullScreenStyle());
114 newFullscreenRenderer->initializeStyle();
115
116 auto& fullscreenRenderer = *newFullscreenRenderer;
117 auto& parent = *renderer.parent();
118 if (!parent.isChildAllowed(fullscreenRenderer, fullscreenRenderer.style()))
119 return;
120
121 RenderBlock* containingBlock = renderer.containingBlock();
122 ASSERT(containingBlock);
123 // Since we are moving the |object| to a new parent |fullscreenRenderer|,
124 // the line box tree underneath our |containingBlock| is not longer valid.
125 containingBlock->deleteLines();
126
127 builder.attach(parent, WTFMove(newFullscreenRenderer), &renderer);
128
129 auto toMove = builder.detach(parent, renderer);
130
131 // Always just do a full layout to ensure that line boxes get deleted properly.
132 // Because objects moved from |parent| to |fullscreenRenderer|, we want to
133 // make new line boxes instead of leaving the old ones around.
134 parent.setNeedsLayoutAndPrefWidthsRecalc();
135 containingBlock->setNeedsLayoutAndPrefWidthsRecalc();
136
137 builder.attach(fullscreenRenderer, WTFMove(toMove));
138 fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
139
140 document.fullscreenManager().setFullscreenRenderer(builder, fullscreenRenderer);
141}
142
143void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
144{
145 RenderTreeBuilder builder(view());
146
147 requiresRenderTreeRebuild = false;
148 if (parent()) {
149 auto* child = firstChild();
150 // Things can get very complicated with anonymous block generation.
151 // We can restore correctly without rebuild in simple cases only.
152 // FIXME: We should have a mechanism for removing a block without reconstructing the tree.
153 if (child != lastChild())
154 requiresRenderTreeRebuild = true;
155 else if (child && child->isAnonymousBlock()) {
156 auto& anonymousBlock = downcast<RenderBlock>(*child);
157 if (anonymousBlock.firstChild() != anonymousBlock.lastChild())
158 requiresRenderTreeRebuild = true;
159 }
160
161 while ((child = firstChild())) {
162 if (child->isAnonymousBlock() && !requiresRenderTreeRebuild) {
163 if (auto* nonAnonymousChild = downcast<RenderBlock>(*child).firstChild())
164 child = nonAnonymousChild;
165 else {
166 builder.destroy(*child);
167 continue;
168 }
169 }
170 // We have to clear the override size, because as a flexbox, we
171 // may have set one on the child, and we don't want to leave that
172 // lying around on the child.
173 if (is<RenderBox>(*child))
174 downcast<RenderBox>(*child).clearOverridingContentSize();
175 auto childToMove = builder.detach(*child->parent(), *child);
176 builder.attach(*parent(), WTFMove(childToMove), this);
177 parent()->setNeedsLayoutAndPrefWidthsRecalc();
178 }
179 }
180 if (placeholder())
181 builder.destroy(*placeholder());
182 ASSERT(!placeholder());
183
184 builder.destroy(*this);
185}
186
187}
188
189#endif
Note: See TracBrowser for help on using the repository browser.