Diff
Modified: trunk/Source/WTF/ChangeLog (288068 => 288069)
--- trunk/Source/WTF/ChangeLog 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WTF/ChangeLog 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1,3 +1,16 @@
+2022-01-15 Chris Dumez <[email protected]>
+
+ Introduce dynamicDowncast<>() for convenience
+ https://bugs.webkit.org/show_bug.cgi?id=235259
+
+ Reviewed by Darin Adler.
+
+ Introduce dynamicDowncast<>() for convenience. It can result in more concise code for the common pattern
+ where we call `is<T>(x)` and then `downcast<T>(x)`.
+
+ * wtf/TypeCasts.h:
+ (WTF::dynamicDowncast):
+
2022-01-14 Yusuke Suzuki <[email protected]>
Fix WTF::UUID's potential collision with empty and deleted values
Modified: trunk/Source/WTF/wtf/TypeCasts.h (288068 => 288069)
--- trunk/Source/WTF/wtf/TypeCasts.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WTF/wtf/TypeCasts.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -88,6 +88,21 @@
return static_cast<match_constness_t<Source, Target>*>(source);
}
+template<typename Target, typename Source>
+inline match_constness_t<Source, Target>* dynamicDowncast(Source& source)
+{
+ static_assert(!std::is_same_v<Source, Target>, "Unnecessary cast to same type");
+ static_assert(std::is_base_of_v<Source, Target>, "Should be a downcast");
+ return is<Target>(source) ? &static_cast<match_constness_t<Source, Target>&>(source) : nullptr;
+}
+template<typename Target, typename Source>
+inline match_constness_t<Source, Target>* dynamicDowncast(Source* source)
+{
+ static_assert(!std::is_same_v<Source, Target>, "Unnecessary cast to same type");
+ static_assert(std::is_base_of_v<Source, Target>, "Should be a downcast");
+ return is<Target>(source) ? static_cast<match_constness_t<Source, Target>*>(source) : nullptr;
+}
+
// Add support for type checking / casting using is<>() / downcast<>() helpers for a specific class.
#define SPECIALIZE_TYPE_TRAITS_BEGIN(ClassName) \
namespace WTF { \
@@ -120,3 +135,4 @@
using WTF::TypeCastTraits;
using WTF::is;
using WTF::downcast;
+using WTF::dynamicDowncast;
Modified: trunk/Source/WebCore/ChangeLog (288068 => 288069)
--- trunk/Source/WebCore/ChangeLog 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/ChangeLog 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1,3 +1,157 @@
+2022-01-15 Chris Dumez <[email protected]>
+
+ Introduce dynamicDowncast<>() for convenience
+ https://bugs.webkit.org/show_bug.cgi?id=235259
+
+ Reviewed by Darin Adler.
+
+ Start adopting dynamicDowncast<>().
+
+ * animation/WebAnimation.cpp:
+ (WebCore::WebAnimation::setTimeline):
+ (WebCore::WebAnimation::willChangeRenderer):
+ (WebCore::WebAnimation::timingDidChange):
+ (WebCore::WebAnimation::invalidateEffect):
+ (WebCore::WebAnimation::finishNotificationSteps):
+ (WebCore::WebAnimation::resolve):
+ (WebCore::WebAnimation::persist):
+ (WebCore::WebAnimation::commitStyles):
+ * bindings/js/JSEventListener.cpp:
+ (WebCore::JSEventListener::handleEvent):
+ * bindings/js/JSLazyEventListener.cpp:
+ (WebCore::isCloneInShadowTreeOfSVGUseElement):
+ (WebCore::JSLazyEventListener::initializeJSFunction const):
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::fontRangesForFamily):
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::insertRule):
+ * dom/Attr.cpp:
+ (WebCore::Attr::style):
+ * dom/BroadcastChannel.cpp:
+ (WebCore::BroadcastChannel::MainThreadBridge::ensureOnMainThread):
+ (WebCore::BroadcastChannel::isEligibleForMessaging const):
+ * dom/CharacterData.cpp:
+ (WebCore::CharacterData::parserAppendData):
+ (WebCore::CharacterData::setDataAndUpdate):
+ * dom/CharacterData.h:
+ (WebCore::Node::length const):
+ * dom/ComposedTreeAncestorIterator.h:
+ (WebCore::ComposedTreeAncestorIterator::traverseParent):
+ (WebCore::ComposedTreeAncestorAdapter::begin):
+ * dom/ComposedTreeIterator.h:
+ (WebCore::firstChildInComposedTreeIgnoringUserAgentShadow):
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::removeNodeWithScriptAssertion):
+ (WebCore::ContainerNode::removeSelfOrChildNodesForInsertion):
+ (WebCore::destroyRenderTreeIfNeeded):
+ (WebCore::containsIncludingHostElements):
+ (WebCore::checkAcceptChild):
+ * dom/ContainerNode.h:
+ (WebCore::Node::countChildNodes const):
+ (WebCore::Node::traverseToChildAt const):
+ (WebCore::Node::firstChild const):
+ (WebCore::Node::lastChild const):
+ * dom/Document.cpp:
+ (WebCore::widgetForElement):
+ (WebCore::Document::buildAccessKeyCache):
+ (WebCore::Document::adjustFocusedNodeOnNodeRemoval):
+ * dom/Element.cpp:
+ (WebCore::Element::insertedIntoAncestor):
+ (WebCore::Element::removedFromAncestor):
+ * dom/ElementInlines.h:
+ (WebCore::Node::parentElement const):
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchEvent):
+ * dom/MouseEvent.cpp:
+ (WebCore::MouseEvent::toElement const):
+ (WebCore::MouseEvent::fromElement const):
+ * dom/Node.cpp:
+ (WebCore::Node::renderBox const):
+ (WebCore::Node::renderBoxModelObject const):
+ (WebCore::Node::containingShadowRoot const):
+ (WebCore::Node::compareDocumentPosition):
+ * dom/Position.cpp:
+ (WebCore::Position::containerText const):
+ * dom/TextNodeTraversal.cpp:
+ (WebCore::TextNodeTraversal::contentsAsString):
+ * dom/TreeScope.cpp:
+ (WebCore::TreeScope::elementsFromPoint):
+ * dom/TypedElementDescendantIterator.h:
+ (WebCore::ElementDescendantRange<ElementType>::from const):
+ (WebCore::InclusiveElementDescendantRange<ElementType>::from const):
+ * dom/VisitedLinkState.cpp:
+ (WebCore::linkHashForElement):
+ * dom/messageports/MessagePortChannelProvider.cpp:
+ (WebCore::MessagePortChannelProvider::fromContext):
+ * editing/Editing.cpp:
+ (WebCore::enclosingBlock):
+ * html/HTMLOptGroupElement.cpp:
+ (WebCore::HTMLOptGroupElement::ownerSelectElement const):
+ * html/HTMLPlugInImageElement.cpp:
+ (WebCore::HTMLPlugInImageElement::renderEmbeddedObject const):
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::WebGLRenderingContextBase::create):
+ * layout/Verification.cpp:
+ (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
+ * page/AutoscrollController.cpp:
+ (WebCore::AutoscrollController::updateAutoscrollRenderer):
+ * page/DOMTimer.cpp:
+ (WebCore::DOMTimer::fired):
+ * page/DragController.cpp:
+ (WebCore::asFileInput):
+ (WebCore::DragController::operationForLoad):
+ * platform/DragImage.cpp:
+ (WebCore::ScopedNodeDragEnabler::ScopedNodeDragEnabler):
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (WebCore::SourceBufferPrivateAVFObjC::setCDMInstance):
+ * rendering/LegacyInlineFlowBox.cpp:
+ (WebCore::LegacyInlineFlowBox::computeLogicalBoxHeights):
+ (WebCore::placeChildInlineBoxesInBlockDirection):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutBlockChild):
+ (WebCore::RenderBlockFlow::marginValuesForChild const):
+ (WebCore::RenderBlockFlow::adjustBlockChildForPagination):
+ (WebCore::RenderBlockFlow::positionNewFloats):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::findAutoscrollable):
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::imageOrientation const):
+ * rendering/RenderFileUploadControl.cpp:
+ (WebCore::RenderFileUploadControl::uploadButton const):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::updateInnerContentRect):
+ (WebCore::RenderImage::paintIntoRect):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::mayAffectLayout const):
+ * rendering/RenderLayer.h:
+ (WebCore::RenderLayer::renderBox const):
+ * rendering/RenderLineBoxList.cpp:
+ (WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
+ * rendering/RenderListItem.cpp:
+ (WebCore::RenderListItem::updateValueNow const):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::offsetParent const):
+ * rendering/RenderTableCol.cpp:
+ (WebCore::RenderTableCol::table const):
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::writeDebugInfo):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::paintBoxDecorations):
+ * rendering/SelectionRangeData.cpp:
+ (WebCore::containingBlockBelowView):
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange):
+ * rendering/updating/RenderTreeUpdater.cpp:
+ (WebCore::RenderTreeUpdater::Parent::Parent):
+ * style/ChildChangeInvalidation.h:
+ (WebCore::Style::ChildChangeInvalidation::ChildChangeInvalidation):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::findViewAnchor const):
+ (WebCore::SVGSVGElement::findRootAnchor const):
+ * testing/Internals.cpp:
+ (WebCore::bitmapImageFromImageElement):
+ (WebCore::pdfDocumentImageFromImageElement):
+
2022-01-15 Darin Adler <[email protected]>
First step to fix hacked isReplaced: Rename isReplaced functions to isReplacedOrInlineBlock
Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (288068 => 288069)
--- trunk/Source/WebCore/animation/WebAnimation.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -244,8 +244,8 @@
if (m_startTime)
m_holdTime = std::nullopt;
- if (is<KeyframeEffect>(m_effect)) {
- if (auto target = downcast<KeyframeEffect>(m_effect.get())->targetStyleable()) {
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get())) {
+ if (auto target = keyframeEffect->targetStyleable()) {
// In the case of a declarative animation, we don't want to remove the animation from the relevant maps because
// while the timeline was set via the API, the element still has a transition or animation set up and we must
// not break the relationship.
@@ -725,8 +725,8 @@
void WebAnimation::willChangeRenderer()
{
- if (is<KeyframeEffect>(m_effect))
- downcast<KeyframeEffect>(*m_effect).willChangeRenderer();
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get()))
+ keyframeEffect->willChangeRenderer();
}
void WebAnimation::enqueueAnimationPlaybackEvent(const AtomString& type, std::optional<Seconds> currentTime, std::optional<Seconds> timelineTime)
@@ -838,9 +838,9 @@
m_shouldSkipUpdatingFinishedStateWhenResolving = false;
updateFinishedState(didSeek, synchronouslyNotify);
- if (is<KeyframeEffect>(m_effect)) {
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get())) {
updateRelevance();
- downcast<KeyframeEffect>(*m_effect).animationTimingDidChange();
+ keyframeEffect->animationTimingDidChange();
}
if (silently == Silently::No && m_timeline)
@@ -849,8 +849,8 @@
void WebAnimation::invalidateEffect()
{
- if (!isEffectInvalidationSuspended() && is<KeyframeEffect>(m_effect))
- downcast<KeyframeEffect>(*m_effect).invalidate();
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get()); !isEffectInvalidationSuspended() && keyframeEffect)
+ keyframeEffect->invalidate();
}
void WebAnimation::updateFinishedState(DidSeek didSeek, SynchronouslyNotify synchronouslyNotify)
@@ -962,8 +962,8 @@
// Otherwise, queue a task to dispatch finishEvent at animation. The task source for this task is the DOM manipulation task source.
enqueueAnimationPlaybackEvent(eventNames().finishEvent, currentTime(), m_timeline ? m_timeline->currentTime() : std::nullopt);
- if (is<KeyframeEffect>(m_effect)) {
- if (RefPtr target = downcast<KeyframeEffect>(*m_effect).target()) {
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get())) {
+ if (RefPtr target = keyframeEffect->target()) {
if (auto* page = target->document().page())
page->chrome().client().animationDidFinishForElement(*target);
}
@@ -1287,8 +1287,8 @@
updateFinishedState(DidSeek::No, SynchronouslyNotify::Yes);
m_shouldSkipUpdatingFinishedStateWhenResolving = false;
- if (is<KeyframeEffect>(m_effect))
- downcast<KeyframeEffect>(*m_effect).apply(targetStyle, resolutionContext, startTime);
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get()))
+ keyframeEffect->apply(targetStyle, resolutionContext, startTime);
}
void WebAnimation::setSuspended(bool isSuspended)
@@ -1417,11 +1417,10 @@
auto previousReplaceState = std::exchange(m_replaceState, ReplaceState::Persisted);
if (previousReplaceState == ReplaceState::Removed && m_timeline) {
- if (is<KeyframeEffect>(m_effect)) {
- auto& keyframeEffect = downcast<KeyframeEffect>(*m_effect);
- auto styleable = keyframeEffect.targetStyleable();
+ if (auto keyframeEffect = dynamicDowncast<KeyframeEffect>(m_effect.get())) {
+ auto styleable = keyframeEffect->targetStyleable();
styleable->animationWasAdded(*this);
- styleable->ensureKeyframeEffectStack().addEffect(keyframeEffect);
+ styleable->ensureKeyframeEffectStack().addEffect(*keyframeEffect);
}
}
}
@@ -1431,7 +1430,7 @@
// https://drafts.csswg.org/web-animations-1/#commit-computed-styles
// 1. Let targets be the set of all effect targets for animation effects associated with animation.
- auto* effect = is<KeyframeEffect>(m_effect) ? downcast<KeyframeEffect>(m_effect.get()) : nullptr;
+ auto* effect = dynamicDowncast<KeyframeEffect>(m_effect.get());
auto* target = effect ? effect->target() : nullptr;
// 2. For each target in targets:
Modified: trunk/Source/WebCore/bindings/js/JSEventListener.cpp (288068 => 288069)
--- trunk/Source/WebCore/bindings/js/JSEventListener.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/bindings/js/JSEventListener.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -151,7 +151,7 @@
if (!window->wrapped().isCurrentlyDisplayedInFrame())
return;
if (wasCreatedFromMarkup()) {
- Element* element = event.target()->isNode() && !downcast<Node>(*event.target()).isDocumentNode() && is<Element>(*event.target()) ? downcast<Element>(event.target()) : nullptr;
+ Element* element = event.target()->isNode() && !downcast<Node>(*event.target()).isDocumentNode() ? dynamicDowncast<Element>(*event.target()) : nullptr;
if (!scriptExecutionContext.contentSecurityPolicy()->allowInlineEventHandlers(sourceURL().string(), sourcePosition().m_line, code(), element))
return;
}
Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (288068 => 288069)
--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -84,19 +84,12 @@
#if ASSERT_ENABLED
static inline bool isCloneInShadowTreeOfSVGUseElement(Node& originalNode, EventTarget& eventTarget)
{
- if (!eventTarget.isNode())
+ auto* element = dynamicDowncast<SVGElement>(eventTarget);
+ if (!element || !element->correspondingElement())
return false;
- auto& node = downcast<Node>(eventTarget);
- if (!is<SVGElement>(node))
- return false;
-
- auto& element = downcast<SVGElement>(node);
- if (!element.correspondingElement())
- return false;
-
- ASSERT(element.isInShadowTree());
- return &originalNode == element.correspondingElement();
+ ASSERT(element->isInShadowTree());
+ return &originalNode == element->correspondingElement();
}
// This is to help find the underlying cause of <rdar://problem/24314027>.
@@ -131,7 +124,7 @@
if (!document.frame())
return nullptr;
- Element* element = m_originalNode && !m_originalNode->isDocumentNode() && is<Element>(*m_originalNode) ? downcast<Element>(m_originalNode.get()) : nullptr;
+ auto* element = dynamicDowncast<Element>(m_originalNode.get());
if (!document.contentSecurityPolicy()->allowInlineEventHandlers(m_sourceURL.string(), m_sourcePosition.m_line, m_code, element))
return nullptr;
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (288068 => 288069)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -355,7 +355,7 @@
if (resolveGenericFamilyFirst)
resolveAndAssignGenericFamily();
- Document* document = is<Document>(m_context) ? &downcast<Document>(*m_context) : nullptr;
+ auto* document = dynamicDowncast<Document>(m_context.get());
auto* face = m_cssFontFaceSet->fontFace(fontDescriptionForLookup->fontSelectionRequest(), familyForLookup);
if (face) {
if (document && RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (288068 => 288069)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -268,7 +268,7 @@
if (!rule)
return Exception { SyntaxError };
- RuleMutationScope mutationScope(this, RuleInsertion, is<StyleRuleKeyframes>(*rule) ? downcast<StyleRuleKeyframes>(rule.get()) : nullptr);
+ RuleMutationScope mutationScope(this, RuleInsertion, dynamicDowncast<StyleRuleKeyframes>(*rule));
bool success = m_contents.get().wrapperInsertRule(rule.releaseNonNull(), index);
if (!success)
Modified: trunk/Source/WebCore/dom/Attr.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/Attr.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/Attr.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -112,10 +112,11 @@
{
// This is not part of the DOM API, and therefore not available to webpages. However, WebKit SPI
// lets clients use this via the Objective-C and _javascript_ bindings.
- if (!is<StyledElement>(m_element))
+ auto styledElement = dynamicDowncast<StyledElement>(m_element);
+ if (!styledElement)
return nullptr;
m_style = MutableStyleProperties::create();
- downcast<StyledElement>(*m_element).collectPresentationalHintsForAttribute(qualifiedName(), value(), *m_style);
+ styledElement->collectPresentationalHintsForAttribute(qualifiedName(), value(), *m_style);
return &m_style->ensureCSSStyleDeclaration();
}
Modified: trunk/Source/WebCore/dom/BroadcastChannel.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/BroadcastChannel.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/BroadcastChannel.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -108,8 +108,8 @@
ASSERT(context->isContextThread());
Ref protectedThis { *this };
- if (is<Document>(*context))
- task(downcast<Document>(*context));
+ if (auto document = dynamicDowncast<Document>(*context))
+ task(*document);
else {
downcast<WorkerGlobalScope>(*context).thread().workerLoaderProxy().postTaskToLoader([protectedThis = WTFMove(protectedThis), task = WTFMove(task)](auto& context) {
task(downcast<Document>(context));
@@ -265,8 +265,8 @@
if (!context)
return false;
- if (is<Document>(*context))
- return downcast<Document>(*context).isFullyActive();
+ if (auto document = dynamicDowncast<Document>(*context))
+ return document->isFullyActive();
return !downcast<WorkerGlobalScope>(*context).isClosing();
}
Modified: trunk/Source/WebCore/dom/CharacterData.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/CharacterData.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/CharacterData.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -118,8 +118,8 @@
m_data.append(string.characters16() + offset, characterLengthLimit);
ASSERT(!renderer() || is<Text>(*this));
- if (is<Text>(*this))
- downcast<Text>(*this).updateRendererAfterContentChange(oldLength, 0);
+ if (auto text = dynamicDowncast<Text>(*this))
+ text->updateRendererAfterContentChange(oldLength, 0);
notifyParentAfterChange(childChange);
@@ -206,11 +206,11 @@
document().textInserted(*this, offsetOfReplacedData, newLength);
ASSERT(!renderer() || is<Text>(*this));
- if (is<Text>(*this))
- downcast<Text>(*this).updateRendererAfterContentChange(offsetOfReplacedData, oldLength);
+ if (auto text = dynamicDowncast<Text>(*this))
+ text->updateRendererAfterContentChange(offsetOfReplacedData, oldLength);
- if (is<ProcessingInstruction>(*this))
- downcast<ProcessingInstruction>(*this).checkStyleSheet();
+ if (auto processingIntruction = dynamicDowncast<ProcessingInstruction>(*this))
+ processingIntruction->checkStyleSheet();
if (document().frame())
document().frame()->selection().textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);
Modified: trunk/Source/WebCore/dom/CharacterData.h (288068 => 288069)
--- trunk/Source/WebCore/dom/CharacterData.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/CharacterData.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -72,8 +72,8 @@
inline unsigned Node::length() const
{
- if (is<CharacterData>(*this))
- return downcast<CharacterData>(*this).length();
+ if (auto characterData = dynamicDowncast<CharacterData>(*this))
+ return characterData->length();
return countChildNodes();
}
Modified: trunk/Source/WebCore/dom/ComposedTreeAncestorIterator.h (288068 => 288069)
--- trunk/Source/WebCore/dom/ComposedTreeAncestorIterator.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/ComposedTreeAncestorIterator.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -72,8 +72,8 @@
m_current = nullptr;
return *this;
}
- if (is<ShadowRoot>(*parent)) {
- m_current = downcast<ShadowRoot>(*parent).host();
+ if (auto shadowRoot = dynamicDowncast<ShadowRoot>(*parent)) {
+ m_current = shadowRoot->host();
return *this;
}
if (!is<Element>(*parent)) {
@@ -100,10 +100,10 @@
iterator begin()
{
- if (is<ShadowRoot>(m_node))
- return iterator(*downcast<ShadowRoot>(m_node).host());
- if (is<PseudoElement>(m_node))
- return iterator(*downcast<PseudoElement>(m_node).hostElement());
+ if (auto shadowRoot = dynamicDowncast<ShadowRoot>(m_node))
+ return iterator(*shadowRoot->host());
+ if (auto pseudoElement = dynamicDowncast<PseudoElement>(m_node))
+ return iterator(*pseudoElement->hostElement());
return iterator(m_node).traverseParent();
}
iterator end()
Modified: trunk/Source/WebCore/dom/ComposedTreeIterator.h (288068 => 288069)
--- trunk/Source/WebCore/dom/ComposedTreeIterator.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/ComposedTreeIterator.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -224,8 +224,8 @@
{
if (auto* shadowRoot = shadowRootIgnoringUserAgentShadow(node))
return shadowRoot->firstChild();
- if (is<HTMLSlotElement>(node)) {
- if (auto* assignedNodes = downcast<HTMLSlotElement>(node).assignedNodes())
+ if (auto slot = dynamicDowncast<HTMLSlotElement>(node)) {
+ if (auto* assignedNodes = slot->assignedNodes())
return assignedNodes->at(0).get();
}
return node.firstChild();
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -179,8 +179,8 @@
// FIXME: Merge these two code paths. It's a bug in the parser not to update connectedSubframeCount in time.
disconnectSubframesIfNeeded(*this, DescendantsOnly);
} else {
- if (is<ContainerNode>(childToRemove))
- disconnectSubframesIfNeeded(downcast<ContainerNode>(childToRemove), RootAndDescendants);
+ if (auto containerChild = dynamicDowncast<ContainerNode>(childToRemove))
+ disconnectSubframesIfNeeded(*containerChild, RootAndDescendants);
}
if (childToRemove.parentNode() != this)
@@ -276,25 +276,24 @@
ExceptionOr<void> ContainerNode::removeSelfOrChildNodesForInsertion(Node& child, NodeVector& nodesForInsertion)
{
- if (!is<DocumentFragment>(child)) {
- nodesForInsertion.append(child);
- RefPtr oldParent = child.parentNode();
- if (!oldParent)
+ if (auto fragment = dynamicDowncast<DocumentFragment>(child)) {
+ if (!fragment->hasChildNodes())
return { };
- return oldParent->removeChild(child);
- }
- auto& fragment = downcast<DocumentFragment>(child);
- if (!fragment.hasChildNodes())
- return { };
+ auto removedChildNodes = fragment->removeAllChildrenWithScriptAssertion(ContainerNode::ChildChange::Source::API);
+ nodesForInsertion.swap(removedChildNodes);
- auto removedChildNodes = fragment.removeAllChildrenWithScriptAssertion(ContainerNode::ChildChange::Source::API);
- nodesForInsertion.swap(removedChildNodes);
+ fragment->rebuildSVGExtensionsElementsIfNecessary();
+ fragment->dispatchSubtreeModifiedEvent();
- fragment.rebuildSVGExtensionsElementsIfNecessary();
- fragment.dispatchSubtreeModifiedEvent();
+ return { };
+ }
- return { };
+ nodesForInsertion.append(child);
+ RefPtr oldParent = child.parentNode();
+ if (!oldParent)
+ return { };
+ return oldParent->removeChild(child);
}
// FIXME: This function must get a new name.
@@ -313,14 +312,14 @@
static inline void destroyRenderTreeIfNeeded(Node& child)
{
- bool isElement = is<Element>(child);
- auto hasDisplayContents = isElement && downcast<Element>(child).hasDisplayContents();
+ auto childAsElement = dynamicDowncast<Element>(child);
+ auto hasDisplayContents = childAsElement && childAsElement->hasDisplayContents();
if (!child.renderer() && !hasDisplayContents)
return;
- if (isElement)
- RenderTreeUpdater::tearDownRenderers(downcast<Element>(child));
- else if (is<Text>(child))
- RenderTreeUpdater::tearDownRenderer(downcast<Text>(child));
+ if (childAsElement)
+ RenderTreeUpdater::tearDownRenderers(*childAsElement);
+ else if (auto text = dynamicDowncast<Text>(child))
+ RenderTreeUpdater::tearDownRenderer(*text);
}
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
@@ -365,8 +364,8 @@
return true;
const ContainerNode* parent = currentNode->parentNode();
if (!parent) {
- if (is<ShadowRoot>(currentNode))
- parent = downcast<ShadowRoot>(currentNode)->host();
+ if (auto shadowRoot = dynamicDowncast<ShadowRoot>(currentNode))
+ parent = shadowRoot->host();
else if (is<DocumentFragment>(*currentNode) && downcast<DocumentFragment>(*currentNode).isTemplateContent())
parent = static_cast<const TemplateContentDocumentFragment*>(currentNode)->host();
}
@@ -399,8 +398,8 @@
if (shouldValidateChildParent == ShouldValidateChildParent::Yes && refChild && refChild->parentNode() != &newParent)
return Exception { NotFoundError };
- if (is<Document>(newParent)) {
- if (!downcast<Document>(newParent).canAcceptChild(newChild, refChild, operation))
+ if (auto newParentDocument = dynamicDowncast<Document>(newParent)) {
+ if (!newParentDocument->canAcceptChild(newChild, refChild, operation))
return Exception { HierarchyRequestError };
} else if (!isChildTypeAllowed(newParent, newChild))
return Exception { HierarchyRequestError };
Modified: trunk/Source/WebCore/dom/ContainerNode.h (288068 => 288069)
--- trunk/Source/WebCore/dom/ContainerNode.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -174,30 +174,26 @@
inline unsigned Node::countChildNodes() const
{
- if (!is<ContainerNode>(*this))
- return 0;
- return downcast<ContainerNode>(*this).countChildNodes();
+ auto* containerNode = dynamicDowncast<ContainerNode>(*this);
+ return containerNode ? containerNode->countChildNodes() : 0;
}
inline Node* Node::traverseToChildAt(unsigned index) const
{
- if (!is<ContainerNode>(*this))
- return nullptr;
- return downcast<ContainerNode>(*this).traverseToChildAt(index);
+ auto* containerNode = dynamicDowncast<ContainerNode>(*this);
+ return containerNode ? containerNode->traverseToChildAt(index) : nullptr;
}
inline Node* Node::firstChild() const
{
- if (!is<ContainerNode>(*this))
- return nullptr;
- return downcast<ContainerNode>(*this).firstChild();
+ auto* containerNode = dynamicDowncast<ContainerNode>(*this);
+ return containerNode ? containerNode->firstChild() : nullptr;
}
inline Node* Node::lastChild() const
{
- if (!is<ContainerNode>(*this))
- return nullptr;
- return downcast<ContainerNode>(*this).lastChild();
+ auto* containerNode = dynamicDowncast<ContainerNode>(*this);
+ return containerNode ? containerNode->lastChild() : nullptr;
}
inline Node& Node::rootNode() const
Modified: trunk/Source/WebCore/dom/Document.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/Document.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/Document.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -470,12 +470,8 @@
static Widget* widgetForElement(Element* focusedElement)
{
- if (!focusedElement)
- return nullptr;
- auto* renderer = focusedElement->renderer();
- if (!is<RenderWidget>(renderer))
- return nullptr;
- return downcast<RenderWidget>(*renderer).widget();
+ auto* renderer = focusedElement ? dynamicDowncast<RenderWidget>(focusedElement->renderer()) : nullptr;
+ return renderer ? renderer->widget() : nullptr;
}
static bool acceptsEditingFocus(const Element& element)
@@ -895,13 +891,13 @@
m_accessKeyCache = makeUnique<HashMap<String, WeakPtr<Element>, ASCIICaseInsensitiveHash>>([this] {
HashMap<String, WeakPtr<Element>, ASCIICaseInsensitiveHash> map;
for (auto& node : composedTreeDescendants(*this)) {
- if (!is<Element>(node))
+ auto element = dynamicDowncast<Element>(node);
+ if (!element)
continue;
- auto& element = downcast<Element>(node);
- auto& key = element.attributeWithoutSynchronization(accesskeyAttr);
+ auto& key = element->attributeWithoutSynchronization(accesskeyAttr);
if (key.isEmpty())
continue;
- map.add(key, element);
+ map.add(key, *element);
}
return map;
}());
@@ -4499,7 +4495,7 @@
if (isNodeInSubtree(*focusedElement, node, nodeRemoval)) {
// FIXME: We should avoid synchronously updating the style inside setFocusedElement.
// FIXME: Object elements should avoid loading a frame synchronously in a post style recalc callback.
- SubframeLoadingDisabler disabler(is<ContainerNode>(node) ? &downcast<ContainerNode>(node) : nullptr);
+ SubframeLoadingDisabler disabler(dynamicDowncast<ContainerNode>(node));
setFocusedElement(nullptr, { { }, { }, FocusRemovalEventsMode::DoNotDispatch, { }, { } });
// Set the focus navigation starting node to the previous focused element so that
// we can fallback to the siblings or parent node for the next search.
Modified: trunk/Source/WebCore/dom/Element.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/Element.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/Element.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -2296,7 +2296,7 @@
bool becomeConnected = insertionType.connectedToDocument;
TreeScope* newScope = &parentOfInsertedTree.treeScope();
- HTMLDocument* newDocument = becomeConnected && is<HTMLDocument>(newScope->documentScope()) ? &downcast<HTMLDocument>(newScope->documentScope()) : nullptr;
+ auto* newDocument = becomeConnected ? dynamicDowncast<HTMLDocument>(newScope->documentScope()) : nullptr;
if (!insertionType.treeScopeChanged)
newScope = nullptr;
@@ -2358,7 +2358,7 @@
if (oldParentOfRemovedTree.isInTreeScope()) {
TreeScope* oldScope = &oldParentOfRemovedTree.treeScope();
Document* oldDocument = removalType.disconnectedFromDocument ? &oldScope->documentScope() : nullptr;
- HTMLDocument* oldHTMLDocument = oldDocument && is<HTMLDocument>(*oldDocument) ? &downcast<HTMLDocument>(*oldDocument) : nullptr;
+ auto* oldHTMLDocument = dynamicDowncast<HTMLDocument>(oldDocument);
if (!removalType.treeScopeChanged)
oldScope = nullptr;
Modified: trunk/Source/WebCore/dom/ElementInlines.h (288068 => 288069)
--- trunk/Source/WebCore/dom/ElementInlines.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/ElementInlines.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -61,8 +61,7 @@
inline Element* Node::parentElement() const
{
- ContainerNode* parent = parentNode();
- return is<Element>(parent) ? downcast<Element>(parent) : nullptr;
+ return dynamicDowncast<Element>(parentNode());
}
inline const Element* Element::rootElement() const
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/EventDispatcher.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -174,7 +174,7 @@
InputElementClickState clickHandlingState;
bool isActivationEvent = event.type() == eventNames().clickEvent;
- RefPtr<HTMLInputElement> inputForLegacyPreActivationBehavior = is<HTMLInputElement>(node) ? &downcast<HTMLInputElement>(node) : nullptr;
+ RefPtr inputForLegacyPreActivationBehavior = dynamicDowncast<HTMLInputElement>(node);
if (!inputForLegacyPreActivationBehavior && isActivationEvent && event.bubbles())
inputForLegacyPreActivationBehavior = findInputElementInEventPath(eventPath);
if (inputForLegacyPreActivationBehavior)
Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/MouseEvent.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -203,7 +203,7 @@
target = relatedTarget();
else
target = this->target();
- return is<Node>(target) ? &downcast<Node>(*target) : nullptr;
+ return dynamicDowncast<Node>(target);
}
RefPtr<Node> MouseEvent::fromElement() const
@@ -214,7 +214,7 @@
target = this->target();
else
target = relatedTarget();
- return is<Node>(target) ? &downcast<Node>(*target) : nullptr;
+ return dynamicDowncast<Node>(target);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Node.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/Node.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/Node.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -801,14 +801,12 @@
RenderBox* Node::renderBox() const
{
- RenderObject* renderer = this->renderer();
- return is<RenderBox>(renderer) ? downcast<RenderBox>(renderer) : nullptr;
+ return dynamicDowncast<RenderBox>(renderer());
}
RenderBoxModelObject* Node::renderBoxModelObject() const
{
- RenderObject* renderer = this->renderer();
- return is<RenderBoxModelObject>(renderer) ? downcast<RenderBoxModelObject>(renderer) : nullptr;
+ return dynamicDowncast<RenderBoxModelObject>(renderer());
}
LayoutRect Node::renderRect(bool* isReplaced)
@@ -1149,8 +1147,7 @@
ShadowRoot* Node::containingShadowRoot() const
{
- ContainerNode& root = treeScope().rootNode();
- return is<ShadowRoot>(root) ? downcast<ShadowRoot>(&root) : nullptr;
+ return dynamicDowncast<ShadowRoot>(treeScope().rootNode());
}
#if ASSERT_ENABLED
@@ -1644,8 +1641,8 @@
if (&otherNode == this)
return DOCUMENT_POSITION_EQUIVALENT;
- Attr* attr1 = is<Attr>(*this) ? downcast<Attr>(this) : nullptr;
- Attr* attr2 = is<Attr>(otherNode) ? &downcast<Attr>(otherNode) : nullptr;
+ auto* attr1 = dynamicDowncast<Attr>(*this);
+ auto* attr2 = dynamicDowncast<Attr>(otherNode);
Node* start1 = attr1 ? attr1->ownerElement() : this;
Node* start2 = attr2 ? attr2->ownerElement() : &otherNode;
Modified: trunk/Source/WebCore/dom/Position.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/Position.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/Position.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -185,7 +185,7 @@
{
switch (anchorType()) {
case PositionIsOffsetInAnchor:
- return m_anchorNode && is<Text>(*m_anchorNode) ? downcast<Text>(m_anchorNode.get()) : nullptr;
+ return dynamicDowncast<Text>(m_anchorNode.get());
case PositionIsBeforeAnchor:
case PositionIsAfterAnchor:
return nullptr;
Modified: trunk/Source/WebCore/dom/TextNodeTraversal.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/TextNodeTraversal.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/TextNodeTraversal.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -47,10 +47,10 @@
String contentsAsString(const Node& root)
{
- if (is<Text>(root))
- return downcast<Text>(root).data();
- if (is<ContainerNode>(root))
- return contentsAsString(downcast<ContainerNode>(root));
+ if (auto text = dynamicDowncast<Text>(root))
+ return text->data();
+ if (auto containerNode = dynamicDowncast<ContainerNode>(root))
+ return contentsAsString(*containerNode);
return String();
}
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -414,8 +414,8 @@
if (!node)
continue;
- if (is<PseudoElement>(node))
- node = downcast<PseudoElement>(*node).hostElement();
+ if (auto pseudoElement = dynamicDowncast<PseudoElement>(*node))
+ node = pseudoElement->hostElement();
// Prune duplicate entries. A pseudo ::before content above its parent
// node should only result in one entry.
Modified: trunk/Source/WebCore/dom/TypedElementDescendantIterator.h (288068 => 288069)
--- trunk/Source/WebCore/dom/TypedElementDescendantIterator.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/TypedElementDescendantIterator.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -170,8 +170,8 @@
template<typename ElementType> ElementDescendantIterator<ElementType> ElementDescendantRange<ElementType>::from(Element& descendant) const
{
ASSERT(descendant.isDescendantOf(m_root));
- if (is<ElementType>(descendant))
- return ElementDescendantIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
+ if (auto descendantElement = dynamicDowncast<ElementType>(descendant))
+ return ElementDescendantIterator<ElementType>(m_root, descendantElement);
ElementType* next = Traversal<ElementType>::next(descendant, &m_root);
return ElementDescendantIterator<ElementType>(m_root, next);
}
@@ -207,8 +207,8 @@
template<typename ElementType> ElementDescendantIterator<ElementType> InclusiveElementDescendantRange<ElementType>::from(Element& descendant) const
{
ASSERT(&m_root == &descendant || descendant.isDescendantOf(m_root));
- if (is<ElementType>(descendant))
- return ElementDescendantIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
+ if (auto descendantElement = dynamicDowncast<ElementType>(descendant))
+ return ElementDescendantIterator<ElementType>(m_root, descendantElement);
ElementType* next = Traversal<ElementType>::next(descendant, &m_root);
return ElementDescendantIterator<ElementType>(m_root, next);
}
Modified: trunk/Source/WebCore/dom/VisitedLinkState.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/VisitedLinkState.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/VisitedLinkState.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -71,10 +71,10 @@
inline static std::optional<SharedStringHash> linkHashForElement(const Element& element)
{
- if (is<HTMLAnchorElement>(element))
- return downcast<HTMLAnchorElement>(element).visitedLinkHash();
- if (is<SVGAElement>(element))
- return downcast<SVGAElement>(element).visitedLinkHash();
+ if (auto anchor = dynamicDowncast<HTMLAnchorElement>(element))
+ return anchor->visitedLinkHash();
+ if (auto anchor = dynamicDowncast<SVGAElement>(element))
+ return anchor->visitedLinkHash();
return std::nullopt;
}
Modified: trunk/Source/WebCore/dom/messageports/MessagePortChannelProvider.cpp (288068 => 288069)
--- trunk/Source/WebCore/dom/messageports/MessagePortChannelProvider.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/dom/messageports/MessagePortChannelProvider.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -57,11 +57,11 @@
MessagePortChannelProvider& MessagePortChannelProvider::fromContext(ScriptExecutionContext& context)
{
- if (is<Document>(context))
- return downcast<Document>(context).messagePortChannelProvider();
+ if (auto document = dynamicDowncast<Document>(context))
+ return document->messagePortChannelProvider();
- if (is<WorkletGlobalScope>(context))
- return downcast<WorkletGlobalScope>(context).messagePortChannelProvider();
+ if (auto workletScope = dynamicDowncast<WorkletGlobalScope>(context))
+ return workletScope->messagePortChannelProvider();
return downcast<WorkerGlobalScope>(context).messagePortChannelProvider();
}
Modified: trunk/Source/WebCore/editing/Editing.cpp (288068 => 288069)
--- trunk/Source/WebCore/editing/Editing.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/editing/Editing.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -321,8 +321,7 @@
// knowing about these kinds of special cases.
Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule)
{
- Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock, rule);
- return is<Element>(enclosingNode) ? downcast<Element>(enclosingNode) : nullptr;
+ return dynamicDowncast<Element>(enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock, rule));
}
TextDirection directionOfEnclosingBlock(const Position& position)
Modified: trunk/Source/WebCore/html/HTMLOptGroupElement.cpp (288068 => 288069)
--- trunk/Source/WebCore/html/HTMLOptGroupElement.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/html/HTMLOptGroupElement.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -122,8 +122,7 @@
HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const
{
- auto* parent = parentNode();
- return is<HTMLSelectElement>(parent) ? downcast<HTMLSelectElement>(parent) : nullptr;
+ return dynamicDowncast<HTMLSelectElement>(parentNode());
}
bool HTMLOptGroupElement::accessKeyAction(bool)
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (288068 => 288069)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -74,7 +74,7 @@
RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const
{
// HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers when using fallback content.
- return is<RenderEmbeddedObject>(renderer()) ? downcast<RenderEmbeddedObject>(renderer()) : nullptr;
+ return dynamicDowncast<RenderEmbeddedObject>(renderer());
}
bool HTMLPlugInImageElement::isImageType()
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (288068 => 288069)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -794,7 +794,7 @@
bool isPendingPolicyResolution = false;
HostWindow* hostWindow = nullptr;
- auto* canvasElement = is<HTMLCanvasElement>(canvas) ? &downcast<HTMLCanvasElement>(canvas) : nullptr;
+ auto* canvasElement = dynamicDowncast<HTMLCanvasElement>(canvas);
if (canvasElement) {
Document& document = canvasElement->document();
Modified: trunk/Source/WebCore/layout/Verification.cpp (288068 => 288069)
--- trunk/Source/WebCore/layout/Verification.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/layout/Verification.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -134,7 +134,7 @@
for (unsigned inlineBoxIndex = 0; inlineBoxIndex < inlineBoxes.size() && boxIndex < boxes.size(); ++inlineBoxIndex) {
auto& box = boxes[boxIndex];
auto* inlineBox = inlineBoxes[inlineBoxIndex];
- auto* inlineTextBox = is<WebCore::LegacyInlineTextBox>(inlineBox) ? downcast<WebCore::LegacyInlineTextBox>(inlineBox) : nullptr;
+ auto* inlineTextBox = dynamicDowncast<WebCore::LegacyInlineTextBox>(inlineBox);
bool matchingRuns = inlineTextBox ? checkForMatchingTextRuns(box, *inlineTextBox) : checkForMatchingNonTextRuns(box, *inlineBox);
if (!matchingRuns) {
Modified: trunk/Source/WebCore/page/AutoscrollController.cpp (288068 => 288069)
--- trunk/Source/WebCore/page/AutoscrollController.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/page/AutoscrollController.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -136,7 +136,7 @@
while (renderer && !(is<RenderBox>(*renderer) && downcast<RenderBox>(*renderer).canAutoscroll()))
renderer = renderer->parent();
- m_autoscrollRenderer = is<RenderBox>(renderer) ? downcast<RenderBox>(renderer) : nullptr;
+ m_autoscrollRenderer = dynamicDowncast<RenderBox>(renderer);
}
void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, const IntPoint& eventPosition, WallTime eventTime)
Modified: trunk/Source/WebCore/page/DOMTimer.cpp (288068 => 288069)
--- trunk/Source/WebCore/page/DOMTimer.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/page/DOMTimer.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -332,7 +332,7 @@
nestedTimers->startTracking();
#if ENABLE(CONTENT_CHANGE_OBSERVER)
- ContentChangeObserver::DOMTimerScope observingScope(is<Document>(context) ? &downcast<Document>(context) : nullptr, *this);
+ ContentChangeObserver::DOMTimerScope observingScope(dynamicDowncast<Document>(context), *this);
#endif
m_action->execute(context);
Modified: trunk/Source/WebCore/page/DragController.cpp (288068 => 288069)
--- trunk/Source/WebCore/page/DragController.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/page/DragController.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -343,10 +343,8 @@
auto* inputElement = &downcast<HTMLInputElement>(node);
// If this is a button inside of the a file input, move up to the file input.
- if (inputElement->isTextButton() && is<ShadowRoot>(inputElement->treeScope().rootNode())) {
- auto& host = *downcast<ShadowRoot>(inputElement->treeScope().rootNode()).host();
- inputElement = is<HTMLInputElement>(host) ? &downcast<HTMLInputElement>(host) : nullptr;
- }
+ if (inputElement->isTextButton())
+ inputElement = dynamicDowncast<HTMLInputElement>(inputElement->shadowHost());
return inputElement && inputElement->isFileUpload() ? inputElement : nullptr;
}
@@ -502,12 +500,8 @@
Document* document = m_page.mainFrame().documentAtPoint(dragData.clientPosition());
bool pluginDocumentAcceptsDrags = false;
-
- if (is<PluginDocument>(document)) {
- const Widget* widget = downcast<PluginDocument>(*document).pluginWidget();
- const PluginViewBase* pluginView = is<PluginViewBase>(widget) ? downcast<PluginViewBase>(widget) : nullptr;
-
- if (pluginView)
+ if (auto* pluginDocument = dynamicDowncast<PluginDocument>(document)) {
+ if (auto* pluginView = dynamicDowncast<PluginViewBase>(pluginDocument->pluginWidget()))
pluginDocumentAcceptsDrags = pluginView->shouldAllowNavigationFromDrags();
}
Modified: trunk/Source/WebCore/platform/DragImage.cpp (288068 => 288069)
--- trunk/Source/WebCore/platform/DragImage.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -80,7 +80,7 @@
struct ScopedNodeDragEnabler {
ScopedNodeDragEnabler(Frame& frame, Node& node)
- : element(is<Element>(node) ? &downcast<Element>(node) : nullptr)
+ : element(dynamicDowncast<Element>(node))
{
if (element)
element->setBeingDragged(true);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (288068 => 288069)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2022-01-16 01:33:25 UTC (rev 288069)
@@ -903,7 +903,7 @@
void SourceBufferPrivateAVFObjC::setCDMInstance(CDMInstance* instance)
{
#if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
- auto* fpsInstance = is<CDMInstanceFairPlayStreamingAVFObjC>(instance) ? downcast<CDMInstanceFairPlayStreamingAVFObjC>(instance) : nullptr;
+ auto* fpsInstance = dynamicDowncast<CDMInstanceFairPlayStreamingAVFObjC>(instance);
if (fpsInstance == m_cdmInstance)
return;
Modified: trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -577,7 +577,7 @@
if (child->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
- LegacyInlineFlowBox* inlineFlowBox = is<LegacyInlineFlowBox>(*child) ? downcast<LegacyInlineFlowBox>(child) : nullptr;
+ auto* inlineFlowBox = dynamicDowncast<LegacyInlineFlowBox>(*child);
bool affectsAscent = false;
bool affectsDescent = false;
@@ -667,7 +667,7 @@
continue;
}
- LegacyInlineFlowBox* inlineFlowBox = is<LegacyInlineFlowBox>(*child) ? downcast<LegacyInlineFlowBox>(child) : nullptr;
+ auto* inlineFlowBox = dynamicDowncast<LegacyInlineFlowBox>(*child);
bool childAffectsTopBottomPos = true;
if (child->verticalAlign() == VerticalAlign::Top && verticalAlignApplies(child->renderer()))
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -739,7 +739,7 @@
setLogicalTopForChild(child, logicalTopEstimate, ApplyLayoutDelta);
estimateFragmentRangeForBoxChild(child);
- RenderBlockFlow* childBlockFlow = is<RenderBlockFlow>(child) ? &downcast<RenderBlockFlow>(child) : nullptr;
+ auto* childBlockFlow = dynamicDowncast<RenderBlockFlow>(child);
bool markDescendantsWithFloats = false;
if (logicalTopEstimate != oldLogicalTop && !child.avoidsFloats() && childBlockFlow && childBlockFlow->containsFloats())
markDescendantsWithFloats = true;
@@ -993,7 +993,7 @@
LayoutUnit beforeMargin;
LayoutUnit afterMargin;
- RenderBlockFlow* childRenderBlock = is<RenderBlockFlow>(child) ? &downcast<RenderBlockFlow>(child) : nullptr;
+ auto* childRenderBlock = dynamicDowncast<RenderBlockFlow>(child);
// If the child has the same directionality as we do, then we can just return its
// margins in the same direction.
@@ -1471,7 +1471,7 @@
LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, LayoutUnit estimateWithoutPagination, RenderBox& child, bool atBeforeSideOfBlock)
{
- RenderBlock* childRenderBlock = is<RenderBlock>(child) ? &downcast<RenderBlock>(child) : nullptr;
+ auto* childRenderBlock = dynamicDowncast<RenderBlock>(child);
if (estimateWithoutPagination != logicalTopAfterClear) {
// Our guess prior to pagination movement was wrong. Before we attempt to paginate, let's try again at the new
@@ -2496,7 +2496,7 @@
// See if we have a pagination strut that is making us move down further.
// Note that an unsplittable child can't also have a pagination strut, so this
// is exclusive with the case above.
- RenderBlock* childBlock = is<RenderBlock>(childBox) ? &downcast<RenderBlock>(childBox) : nullptr;
+ auto* childBlock = dynamicDowncast<RenderBlock>(childBox);
if (childBlock && childBlock->paginationStrut()) {
newLogicalTop += childBlock->paginationStrut();
childBlock->setPaginationStrut(0);
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1057,7 +1057,7 @@
renderer = renderer->parent();
}
- return is<RenderBox>(renderer) ? downcast<RenderBox>(renderer) : nullptr;
+ return dynamicDowncast<RenderBox>(renderer);
}
void RenderBox::panScroll(const IntPoint& source)
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -2172,7 +2172,7 @@
ImageOrientation RenderElement::imageOrientation() const
{
- auto* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr;
+ auto* imageElement = dynamicDowncast<HTMLImageElement>(element());
return (imageElement && !imageElement->allowsOrientationOverride()) ? ImageOrientation(ImageOrientation::FromImage) : style().imageOrientation();
}
Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -243,8 +243,7 @@
HTMLInputElement* RenderFileUploadControl::uploadButton() const
{
ASSERT(inputElement().shadowRoot());
- Node* buttonNode = inputElement().shadowRoot()->firstChild();
- return is<HTMLInputElement>(buttonNode) ? downcast<HTMLInputElement>(buttonNode) : nullptr;
+ return dynamicDowncast<HTMLInputElement>(inputElement().shadowRoot()->firstChild());
}
String RenderFileUploadControl::buttonValue()
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -331,7 +331,7 @@
IntSize containerSize(replacedContentRect().size());
if (!containerSize.isEmpty()) {
URL imageSourceURL;
- if (HTMLImageElement* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr)
+ if (auto* imageElement = dynamicDowncast<HTMLImageElement>(element()))
imageSourceURL = document().completeURL(imageElement->imageSourceURL());
imageResource().setContainerContext(containerSize, imageSourceURL);
}
@@ -666,7 +666,7 @@
if (!img || img->isNull())
return ImageDrawResult::DidNothing;
- HTMLImageElement* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr;
+ auto* imageElement = dynamicDowncast<HTMLImageElement>(element());
// FIXME: Document when image != img.get().
Image* image = imageResource().image().get();
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -203,7 +203,7 @@
bool RenderInline::mayAffectLayout() const
{
auto* parentStyle = &parent()->style();
- RenderInline* parentRenderInline = is<RenderInline>(*parent()) ? downcast<RenderInline>(parent()) : nullptr;
+ auto* parentRenderInline = dynamicDowncast<RenderInline>(*parent());
auto hasHardLineBreakChildOnly = firstChild() && firstChild() == lastChild() && firstChild()->isBR();
bool checkFonts = document().inNoQuirksMode();
auto mayAffectLayout = (parentRenderInline && parentRenderInline->mayAffectLayout())
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -169,7 +169,7 @@
Page& page() const { return renderer().page(); }
RenderLayerModelObject& renderer() const { return m_renderer; }
- RenderBox* renderBox() const { return is<RenderBox>(renderer()) ? &downcast<RenderBox>(renderer()) : nullptr; }
+ RenderBox* renderBox() const { return dynamicDowncast<RenderBox>(renderer()); }
RenderLayer* parent() const { return m_parent; }
RenderLayer* previousSibling() const { return m_previous; }
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -310,7 +310,7 @@
if (!container.parent() || (is<RenderBlockFlow>(container) && container.selfNeedsLayout()))
return;
- RenderInline* inlineContainer = is<RenderInline>(container) ? &downcast<RenderInline>(container) : nullptr;
+ auto* inlineContainer = dynamicDowncast<RenderInline>(container);
LegacyInlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBox() : firstLineBox();
// If we have no first line box, then just bail early.
Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderListItem.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -210,7 +210,7 @@
void RenderListItem::updateValueNow() const
{
auto* list = enclosingList(*this);
- auto* orderedList = is<HTMLOListElement>(list) ? downcast<HTMLOListElement>(list) : nullptr;
+ auto* orderedList = dynamicDowncast<HTMLOListElement>(list);
// The start item is either the closest item before this one in the list that already has a value,
// or the first item in the list if none have before this have values yet.
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1781,7 +1781,7 @@
current = current->parent();
}
- return is<RenderBoxModelObject>(current) ? downcast<RenderBoxModelObject>(current) : nullptr;
+ return dynamicDowncast<RenderBoxModelObject>(current);
}
VisiblePosition RenderObject::createVisiblePosition(int offset, Affinity affinity) const
Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderTableCol.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -155,7 +155,7 @@
auto table = parent();
if (table && !is<RenderTable>(*table))
table = table->parent();
- return is<RenderTable>(table) ? downcast<RenderTable>(table) : nullptr;
+ return dynamicDowncast<RenderTable>(table);
}
RenderTableCol* RenderTableCol::enclosingColumnGroup() const
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -473,7 +473,7 @@
void writeDebugInfo(TextStream& ts, const RenderObject& object, OptionSet<RenderAsTextFlag> behavior)
{
if (behavior.contains(RenderAsTextFlag::ShowIDAndClass)) {
- if (Element* element = is<Element>(object.node()) ? downcast<Element>(object.node()) : nullptr) {
+ if (auto* element = dynamicDowncast<Element>(object.node())) {
if (element->hasID())
ts << " id=\"" << element->getIdAttribute() << "\"";
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -399,7 +399,7 @@
Element* documentElement = document().documentElement();
if (RenderElement* rootRenderer = documentElement ? documentElement->renderer() : nullptr) {
// The document element's renderer is currently forced to be a block, but may not always be.
- RenderBox* rootBox = is<RenderBox>(*rootRenderer) ? downcast<RenderBox>(rootRenderer) : nullptr;
+ auto* rootBox = dynamicDowncast<RenderBox>(*rootRenderer);
rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox->width() >= width() && rootBox->height() >= height();
rootObscuresBackground = rendererObscuresBackground(*rootRenderer);
}
Modified: trunk/Source/WebCore/rendering/SelectionRangeData.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/SelectionRangeData.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/SelectionRangeData.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -74,8 +74,7 @@
static RenderBlock* containingBlockBelowView(const RenderObject& renderer)
{
- auto* containingBlock = renderer.containingBlock();
- return is<RenderView>(containingBlock) ? nullptr : containingBlock;
+ return dynamicDowncast<RenderView>(renderer.containingBlock());
}
static SelectionContext collectSelectionData(const RenderRange& selection, bool repaintDifference)
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -625,7 +625,7 @@
ASSERT(is<RenderBox>(renderer) && downcast<RenderBlockFlow>(*newParent).multiColumnFlow()->spannerMap().contains(&downcast<RenderBox>(renderer)));
newEnclosingFragmentedFlow = downcast<RenderBlockFlow>(*newParent).multiColumnFlow();
}
- return newEnclosingFragmentedFlow != currentEnclosingFragment && is<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) ? downcast<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) : nullptr;
+ return newEnclosingFragmentedFlow != currentEnclosingFragment ? dynamicDowncast<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) : nullptr;
};
if (auto* newEnclosingMultiColumn = newMultiColumnForRenderer()) {
// Let the fragmented flow know that it has a new in-flow descendant.
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (288068 => 288069)
--- trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -65,7 +65,7 @@
namespace WebCore {
RenderTreeUpdater::Parent::Parent(ContainerNode& root)
- : element(is<Document>(root) ? nullptr : downcast<Element>(&root))
+ : element(dynamicDowncast<Element>(root))
, renderTreePosition(RenderTreePosition(*root.renderer()))
{
}
Modified: trunk/Source/WebCore/style/ChildChangeInvalidation.h (288068 => 288069)
--- trunk/Source/WebCore/style/ChildChangeInvalidation.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/style/ChildChangeInvalidation.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -61,7 +61,7 @@
};
inline ChildChangeInvalidation::ChildChangeInvalidation(ContainerNode& container, const ContainerNode::ChildChange& childChange)
- : m_parentElement(is<Element>(container) ? downcast<Element>(&container) : nullptr)
+ : m_parentElement(dynamicDowncast<Element>(container))
, m_childChange(childChange)
, m_isEnabled(m_parentElement ? m_parentElement->needsStyleInvalidation() : false)
, m_needsHasInvalidation(m_isEnabled && Scope::forNode(*m_parentElement).usesHasPseudoClass())
Modified: trunk/Source/WebCore/svg/SVGElement.h (288068 => 288069)
--- trunk/Source/WebCore/svg/SVGElement.h 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/svg/SVGElement.h 2022-01-16 01:33:25 UTC (rev 288069)
@@ -245,6 +245,7 @@
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGElement)
+ static bool isType(const WebCore::EventTarget& eventTarget) { return eventTarget.isNode() && static_cast<const WebCore::Node&>(eventTarget).isSVGElement(); }
static bool isType(const WebCore::Node& node) { return node.isSVGElement(); }
SPECIALIZE_TYPE_TRAITS_END()
Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (288068 => 288069)
--- trunk/Source/WebCore/svg/SVGSVGElement.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -572,14 +572,12 @@
SVGViewElement* SVGSVGElement::findViewAnchor(StringView fragmentIdentifier) const
{
- auto* anchorElement = document().findAnchor(fragmentIdentifier);
- return is<SVGViewElement>(anchorElement) ? downcast<SVGViewElement>(anchorElement): nullptr;
+ return dynamicDowncast<SVGViewElement>(document().findAnchor(fragmentIdentifier));
}
SVGSVGElement* SVGSVGElement::findRootAnchor(const SVGViewElement* viewElement) const
{
- auto* viewportElement = SVGLocatable::nearestViewportElement(viewElement);
- return is<SVGSVGElement>(viewportElement) ? downcast<SVGSVGElement>(viewportElement) : nullptr;
+ return dynamicDowncast<SVGSVGElement>(SVGLocatable::nearestViewportElement(viewElement));
}
SVGSVGElement* SVGSVGElement::findRootAnchor(StringView fragmentIdentifier) const
Modified: trunk/Source/WebCore/testing/Internals.cpp (288068 => 288069)
--- trunk/Source/WebCore/testing/Internals.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebCore/testing/Internals.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -957,15 +957,13 @@
static BitmapImage* bitmapImageFromImageElement(HTMLImageElement& element)
{
- auto* image = imageFromImageElement(element);
- return image && is<BitmapImage>(image) ? &downcast<BitmapImage>(*image) : nullptr;
+ return dynamicDowncast<BitmapImage>(imageFromImageElement(element));
}
#if USE(CG)
static PDFDocumentImage* pdfDocumentImageFromImageElement(HTMLImageElement& element)
{
- auto* image = imageFromImageElement(element);
- return image && is<PDFDocumentImage>(image) ? &downcast<PDFDocumentImage>(*image) : nullptr;
+ return dynamicDowncast<PDFDocumentImage>(imageFromImageElement(element));
}
#endif
Modified: trunk/Source/WebKit/ChangeLog (288068 => 288069)
--- trunk/Source/WebKit/ChangeLog 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKit/ChangeLog 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1,3 +1,17 @@
+2022-01-15 Chris Dumez <[email protected]>
+
+ Introduce dynamicDowncast<>() for convenience
+ https://bugs.webkit.org/show_bug.cgi?id=235259
+
+ Reviewed by Darin Adler.
+
+ Start adopting dynamicDowncast<>().
+
+ * WebProcess/FullScreen/WebFullScreenManager.cpp:
+ (WebKit::WebFullScreenManager::didEnterFullScreen):
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::paymentCoordinator):
+
2022-01-14 Wenson Hsieh <[email protected]>
[iOS] Occasional crash under -[UITargetedPreview initWithView:parameters:target:] when focusing form controls
Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp (288068 => 288069)
--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2022-01-16 01:33:25 UTC (rev 288069)
@@ -189,7 +189,7 @@
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement();
- setPIPStandbyElement(is<HTMLVideoElement>(currentPlaybackControlsElement) ? downcast<HTMLVideoElement>(currentPlaybackControlsElement) : nullptr);
+ setPIPStandbyElement(dynamicDowncast<HTMLVideoElement>(currentPlaybackControlsElement));
#endif
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (288068 => 288069)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-01-16 01:33:25 UTC (rev 288069)
@@ -256,8 +256,7 @@
{
if (!m_page)
return nullptr;
- auto& client = m_page->paymentCoordinator().client();
- return is<WebPaymentCoordinator>(client) ? downcast<WebPaymentCoordinator>(&client) : nullptr;
+ return dynamicDowncast<WebPaymentCoordinator>(m_page->paymentCoordinator().client());
}
#endif
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (288068 => 288069)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2022-01-16 01:33:25 UTC (rev 288069)
@@ -1,3 +1,17 @@
+2022-01-15 Chris Dumez <[email protected]>
+
+ Introduce dynamicDowncast<>() for convenience
+ https://bugs.webkit.org/show_bug.cgi?id=235259
+
+ Reviewed by Darin Adler.
+
+ Start adopting dynamicDowncast<>().
+
+ * DOM/DOMUIKitExtensions.mm:
+ (-[DOMHTMLElement structuralComplexityContribution]):
+ * WebView/WebHTMLRepresentation.mm:
+ (inputElementFromDOMElement):
+
2022-01-13 Tim Horton <[email protected]>
Fix a few Objective-C object leaks due to early returns in `init`
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm (288068 => 288069)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm 2022-01-16 01:33:25 UTC (rev 288069)
@@ -267,13 +267,10 @@
result = 0;
} else if (is<WebCore::RenderBlockFlow>(*renderer) || (is<RenderBlock>(*renderer) && downcast<RenderBlock>(*renderer).inlineContinuation())) {
BOOL noCost = NO;
- if (is<RenderBox>(*renderer)) {
- RenderBox& asBox = renderer->enclosingBox();
- RenderObject* parent = asBox.parent();
- RenderBox* parentRenderBox = is<RenderBox>(parent) ? downcast<RenderBox>(parent) : nullptr;
- if (parentRenderBox && asBox.width() == parentRenderBox->width()) {
+ if (auto renderBox = dynamicDowncast<RenderBox>(*renderer)) {
+ auto* parentRenderBox = dynamicDowncast<RenderBox>(renderBox->parent());
+ if (parentRenderBox && renderBox->width() == parentRenderBox->width())
noCost = YES;
- }
}
result = (noCost ? 0 : 1);
} else if (renderer->hasTransform()) {
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm (288068 => 288069)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm 2022-01-15 23:10:21 UTC (rev 288068)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm 2022-01-16 01:33:25 UTC (rev 288069)
@@ -301,7 +301,7 @@
static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
{
Element* node = core(element);
- return is<HTMLInputElement>(node) ? downcast<HTMLInputElement>(node) : nullptr;
+ return dynamicDowncast<HTMLInputElement>(node);
}
- (BOOL)elementDoesAutoComplete:(DOMElement *)element