Changeset 257196 in webkit


Ignore:
Timestamp:
Feb 23, 2020 1:41:42 PM (4 years ago)
Author:
Darin Adler
Message:

Follow up element iterator work by reducing includes and using is<> in a few more places
https://bugs.webkit.org/show_bug.cgi?id=207816

Reviewed by Antti Koivisto.

  • accessibility/AccessibilityTableColumn.cpp: Removed unneeded includes.
  • bindings/js/JSDOMWindowCustom.cpp: Ditto.
  • dom/CustomElementRegistry.cpp: Ditto.
  • dom/Node.cpp: Ditto.
  • editing/markup.cpp: Ditto.
  • html/GenericCachedHTMLCollection.cpp: Ditto.
  • html/HTMLCollection.cpp: Ditto.
  • html/HTMLFrameSetElement.cpp: Ditto.
  • html/track/TextTrackCue.cpp: Ditto.
  • page/scrolling/AxisScrollSnapOffsets.cpp: Ditto.
  • platform/DataListSuggestionsClient.h: Reduced includes, use forward declarations.
  • style/StyleResolver.cpp:

(WebCore::Style::isAtShadowBoundary): Use the is<ShadowRoot> function.

  • rendering/svg/RenderSVGResourceClipper.cpp:

(WebCore::RenderSVGResourceClipper::pathOnlyClipping): Use is<RenderSVGText> and
is<SVGGraphicsElement>, tweak coding style a tiny bit, and fix wording of comments.

  • svg/SVGAElement.cpp:

(WebCore::SVGAElement::createElementRenderer): Use is<SVGElement>.

  • svg/SVGElement.cpp: Removed unneeded includes.

(WebCore::SVGElement::isOutermostSVGSVGElement): Use is<SVGElement> and
is<SVGForeignObjectElement>.
(WebCore::SVGElement::reportAttributeParsingError): Use is<SVGElement>.
(WebCore::SVGElement::updateRelativeLengthsInformation): Use
is<SVGGraphicsElement> and is<SVGElement>, and use an if statement instead of
a while loop since this doesn't loop.

Location:
trunk/Source/WebCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r257194 r257196  
     12020-02-23  Darin Adler  <darin@apple.com>
     2
     3        Follow up element iterator work by reducing includes and using is<> in a few more places
     4        https://bugs.webkit.org/show_bug.cgi?id=207816
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * accessibility/AccessibilityTableColumn.cpp: Removed unneeded includes.
     9        * bindings/js/JSDOMWindowCustom.cpp: Ditto.
     10        * dom/CustomElementRegistry.cpp: Ditto.
     11        * dom/Node.cpp: Ditto.
     12        * editing/markup.cpp: Ditto.
     13        * html/GenericCachedHTMLCollection.cpp: Ditto.
     14        * html/HTMLCollection.cpp: Ditto.
     15        * html/HTMLFrameSetElement.cpp: Ditto.
     16        * html/track/TextTrackCue.cpp: Ditto.
     17        * page/scrolling/AxisScrollSnapOffsets.cpp: Ditto.
     18
     19        * platform/DataListSuggestionsClient.h: Reduced includes, use forward declarations.
     20
     21        * style/StyleResolver.cpp:
     22        (WebCore::Style::isAtShadowBoundary): Use the is<ShadowRoot> function.
     23
     24        * rendering/svg/RenderSVGResourceClipper.cpp:
     25        (WebCore::RenderSVGResourceClipper::pathOnlyClipping): Use is<RenderSVGText> and
     26        is<SVGGraphicsElement>, tweak coding style a tiny bit, and fix wording of comments.
     27
     28        * svg/SVGAElement.cpp:
     29        (WebCore::SVGAElement::createElementRenderer): Use is<SVGElement>.
     30
     31        * svg/SVGElement.cpp: Removed unneeded includes.
     32        (WebCore::SVGElement::isOutermostSVGSVGElement): Use is<SVGElement> and
     33        is<SVGForeignObjectElement>.
     34        (WebCore::SVGElement::reportAttributeParsingError): Use is<SVGElement>.
     35        (WebCore::SVGElement::updateRelativeLengthsInformation): Use
     36        is<SVGGraphicsElement> and is<SVGElement>, and use an if statement instead of
     37        a while loop since this doesn't loop.
     38
    1392020-02-22  Darin Adler  <darin@apple.com>
    240
  • trunk/Source/WebCore/accessibility/AccessibilityTableColumn.cpp

    r251798 r257196  
    3232#include "AXObjectCache.h"
    3333#include "AccessibilityTableCell.h"
    34 #include "HTMLCollection.h"
    3534#include "HTMLElement.h"
    3635#include "HTMLNames.h"
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r253483 r257196  
    2525#include "DOMWindowWebDatabase.h"
    2626#include "Frame.h"
    27 #include "HTMLCollection.h"
    2827#include "HTMLDocument.h"
    2928#include "HTMLFrameOwnerElement.h"
     
    3938#include "JSEventListener.h"
    4039#include "JSHTMLAudioElement.h"
    41 #include "JSHTMLCollection.h"
    4240#include "JSHTMLOptionElement.h"
    4341#include "JSIDBFactory.h"
  • trunk/Source/WebCore/dom/CustomElementRegistry.cpp

    r250735 r257196  
    3030#include "DOMWindow.h"
    3131#include "Document.h"
    32 #include "Element.h"
    33 #include "ElementTraversal.h"
    3432#include "JSCustomElementInterface.h"
    3533#include "JSDOMPromiseDeferred.h"
  • trunk/Source/WebCore/dom/Node.cpp

    r257036 r257196  
    4848#include "HTMLAreaElement.h"
    4949#include "HTMLBodyElement.h"
    50 #include "HTMLCollection.h"
    5150#include "HTMLElement.h"
    5251#include "HTMLImageElement.h"
  • trunk/Source/WebCore/editing/markup.cpp

    r254800 r257196  
    7676#include "StyleProperties.h"
    7777#include "TextIterator.h"
    78 #include "TypedElementDescendantIterator.h"
    7978#include "VisibleSelection.h"
    8079#include "VisibleUnits.h"
  • trunk/Source/WebCore/html/GenericCachedHTMLCollection.cpp

    r257194 r257196  
    2828
    2929#include "HTMLAppletElement.h"
    30 #include "HTMLDataListElement.h"
    3130#include "HTMLFieldSetElement.h"
    3231#include "HTMLNames.h"
  • trunk/Source/WebCore/html/HTMLCollection.cpp

    r248846 r257196  
    2424#include "HTMLCollection.h"
    2525
    26 #include "CachedHTMLCollection.h"
    2726#include "HTMLNames.h"
    2827#include "NodeRareData.h"
  • trunk/Source/WebCore/html/HTMLFrameSetElement.cpp

    r246490 r257196  
    3434#include "FrameLoaderClient.h"
    3535#include "HTMLBodyElement.h"
    36 #include "HTMLCollection.h"
    3736#include "HTMLFrameElement.h"
    3837#include "HTMLNames.h"
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    • Property svn:executable deleted
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r257125 r257196  
    3939#include "DOMRect.h"
    4040#include "Event.h"
    41 #include "HTMLCollection.h"
    4241#include "HTMLDivElement.h"
    4342#include "HTMLStyleElement.h"
  • trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp

    r254514 r257196  
    2828
    2929#include "ElementChildIterator.h"
    30 #include "HTMLCollection.h"
    3130#include "HTMLElement.h"
    3231#include "Length.h"
  • trunk/Source/WebCore/platform/DataListSuggestionsClient.h

    r235490 r257196  
    2828#if ENABLE(DATALIST_ELEMENT)
    2929
    30 #include "IntRect.h"
    31 #include <wtf/Vector.h>
     30#include <wtf/Forward.h>
    3231
    3332namespace WebCore {
     33
     34class IntRect;
    3435
    3536class DataListSuggestionsClient {
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp

    r254893 r257196  
    3030#include "HitTestResult.h"
    3131#include "IntRect.h"
    32 #include "RenderObject.h"
     32#include "RenderSVGText.h"
    3333#include "RenderStyle.h"
    3434#include "RenderView.h"
     
    7676bool RenderSVGResourceClipper::pathOnlyClipping(GraphicsContext& context, const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundingBox)
    7777{
    78     // If the current clip-path gets clipped itself, we have to fallback to masking.
     78    // If the current clip-path gets clipped itself, we have to fall back to masking.
    7979    if (style().clipPath())
    8080        return false;
    8181    WindRule clipRule = WindRule::NonZero;
    82     Path clipPath = Path();
     82    Path clipPath;
    8383
    8484    // If clip-path only contains one visible shape or path, we can use path-based clipping. Invisible
     
    8888    // See also http://www.w3.org/TR/SVG/painting.html#FillRuleProperty
    8989    for (Node* childNode = clipPathElement().firstChild(); childNode; childNode = childNode->nextSibling()) {
    90         RenderObject* renderer = childNode->renderer();
     90        auto* renderer = childNode->renderer();
    9191        if (!renderer)
    9292            continue;
    93         // Only shapes or paths are supported for direct clipping. We need to fallback to masking for texts.
    94         if (renderer->isSVGText())
    95             return false;
    96         if (!childNode->isSVGElement() || !downcast<SVGElement>(*childNode).isSVGGraphicsElement())
    97             continue;
    98         SVGGraphicsElement& styled = downcast<SVGGraphicsElement>(*childNode);
    99         const RenderStyle& style = renderer->style();
     93        // Only shapes or paths are supported for direct clipping. We need to fall back to masking for texts.
     94        if (is<RenderSVGText>(renderer))
     95            return false;
     96        if (!is<SVGGraphicsElement>(*childNode))
     97            continue;
     98        auto& style = renderer->style();
    10099        if (style.display() == DisplayType::None || style.visibility() != Visibility::Visible)
    101              continue;
    102         const SVGRenderStyle& svgStyle = style.svgStyle();
    103         // Current shape in clip-path gets clipped too. Fallback to masking.
     100            continue;
     101        // Current shape in clip-path gets clipped too. Fall back to masking.
    104102        if (style.clipPath())
    105103            return false;
    106         // Fallback to masking, if there is more than one clipping path.
    107         if (clipPath.isEmpty()) {
    108             clipPath = styled.toClipPath();
    109             clipRule = svgStyle.clipRule();
    110         } else
    111             return false;
    112     }
     104        // Fall back to masking if there is more than one clipping path.
     105        if (!clipPath.isEmpty())
     106            return false;
     107        clipPath = downcast<SVGGraphicsElement>(*childNode).toClipPath();
     108        clipRule = style.svgStyle().clipRule();
     109    }
     110
    113111    // Only one visible shape/path was found. Directly continue clipping and transform the content to userspace if necessary.
    114112    if (clipPathElement().clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
  • trunk/Source/WebCore/style/StyleResolver.cpp

    r256477 r257196  
    184184static inline bool isAtShadowBoundary(const Element& element)
    185185{
    186     auto* parentNode = element.parentNode();
    187     return parentNode && parentNode->isShadowRoot();
     186    return is<ShadowRoot>(element.parentNode());
    188187}
    189188
  • trunk/Source/WebCore/svg/SVGAElement.cpp

    r251318 r257196  
    103103RenderPtr<RenderElement> SVGAElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
    104104{
    105     if (parentNode() && parentNode()->isSVGElement() && downcast<SVGElement>(*parentNode()).isTextContent())
     105    if (is<SVGElement>(parentNode()) && downcast<SVGElement>(*parentNode()).isTextContent())
    106106        return createRenderer<RenderSVGInline>(*this, WTFMove(style));
    107 
    108107    return createRenderer<RenderSVGTransformableContainer>(*this, WTFMove(style));
    109108}
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r252546 r257196  
    2828
    2929#include "CSSPropertyParser.h"
    30 #include "DeprecatedCSSOMValue.h"
    3130#include "Document.h"
    32 #include "ElementIterator.h"
     31#include "ElementChildIterator.h"
    3332#include "Event.h"
    3433#include "EventNames.h"
     
    3635#include "HTMLNames.h"
    3736#include "HTMLParserIdioms.h"
    38 #include "RenderObject.h"
    39 #include "RenderSVGResource.h"
    4037#include "RenderSVGResourceFilter.h"
    4138#include "RenderSVGResourceMasker.h"
    4239#include "SVGDocumentExtensions.h"
    4340#include "SVGElementRareData.h"
     41#include "SVGForeignObjectElement.h"
    4442#include "SVGGraphicsElement.h"
    4543#include "SVGImageElement.h"
     
    5452#include "StyleAdjuster.h"
    5553#include "XMLNames.h"
    56 #include <wtf/Assertions.h>
    5754#include <wtf/HashMap.h>
    5855#include <wtf/IsoMallocInlines.h>
    5956#include <wtf/NeverDestroyed.h>
    6057#include <wtf/StdLibExtras.h>
    61 #include <wtf/text/WTFString.h>
    62 
    6358
    6459namespace WebCore {
     
    209204    // for a <symbol> element or a cloned <svg> element in the referenced tree. In that case
    210205    // we're always an inner <svg> element.
    211     if (isInShadowTree() && parentOrShadowHostElement() && parentOrShadowHostElement()->isSVGElement())
     206    if (isInShadowTree() && is<SVGElement>(parentOrShadowHostElement()))
    212207        return false;
    213208
     
    217212
    218213    // We act like an outermost SVG element, if we're a direct child of a <foreignObject> element.
    219     if (parentNode()->hasTagName(SVGNames::foreignObjectTag))
     214    if (is<SVGForeignObjectElement>(*parentNode()))
    220215        return true;
    221216
    222217    // This is true whenever this is the outermost SVG, even if there are HTML elements outside it
    223     return !parentNode()->isSVGElement();
     218    return !is<SVGElement>(*parentNode());
    224219}
    225220
     
    780775    // with the SVG content. In general, the SVG user agent will include the unknown
    781776    // elements in the DOM but will otherwise ignore unknown elements.
    782     if (!parentOrShadowHostElement() || parentOrShadowHostElement()->isSVGElement())
     777    if (!parentOrShadowHostElement() || is<SVGElement>(*parentOrShadowHostElement()))
    783778        return StyledElement::rendererIsNeeded(style);
    784779
     
    917912    }
    918913
    919     if (!element->isSVGGraphicsElement())
    920         return;
    921 
    922     // Find first styled parent node, and notify it that we've changed our relative length state.
    923     auto node = makeRefPtr(parentNode());
    924     while (node) {
    925         if (!node->isSVGElement())
    926             break;
    927 
    928         // Register us in the parent element map.
    929         downcast<SVGElement>(*node).updateRelativeLengthsInformation(hasRelativeLengths, this);
    930         break;
     914    if (is<SVGGraphicsElement>(*element)) {
     915        auto parent = makeRefPtr(parentNode());
     916        if (is<SVGElement>(parent))
     917            downcast<SVGElement>(*parent).updateRelativeLengthsInformation(hasRelativeLengths, this);
    931918    }
    932919}
Note: See TracChangeset for help on using the changeset viewer.