Changeset 197779 in webkit


Ignore:
Timestamp:
Mar 8, 2016, 10:11:17 AM (9 years ago)
Author:
Antti Koivisto
Message:

Make Element const in ElementRuleCollector
https://bugs.webkit.org/show_bug.cgi?id=155170

Reviewed by Andreas Kling.

More const.

  • css/ElementRuleCollector.cpp:

(WebCore::ElementRuleCollector::ElementRuleCollector):
(WebCore::ElementRuleCollector::matchAllRules):

  • css/ElementRuleCollector.h:
  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::checkOne):
(WebCore::SelectorChecker::matchesFocusPseudoClass):

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::SelectorCodeGenerator::generateAddStyleRelationIfResolvingStyle):
(WebCore::SelectorCompiler::addStyleRelationFunction):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateContextFunctionCallTest):
(WebCore::SelectorCompiler::elementIsActive):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsFirstChild):
(WebCore::SelectorCompiler::elementIsHovered):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsOnlyChild):
(WebCore::SelectorCompiler::makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
(WebCore::SelectorCompiler::isPlaceholderShown):

  • cssjit/SelectorCompiler.h:
  • dom/StyledElement.h:

(WebCore::StyledElement::additionalPresentationAttributeStyle):
(WebCore::StyledElement::inlineStyle):
(WebCore::StyledElement::collectStyleForPresentationAttribute):
(WebCore::StyledElement::invalidateStyleAttribute):
(WebCore::StyledElement::presentationAttributeStyle):

  • html/HTMLTableCellElement.cpp:

(WebCore::HTMLTableCellElement::parseAttribute):
(WebCore::HTMLTableCellElement::additionalPresentationAttributeStyle):

  • html/HTMLTableCellElement.h:
  • html/HTMLTableColElement.cpp:

(WebCore::HTMLTableColElement::parseAttribute):
(WebCore::HTMLTableColElement::additionalPresentationAttributeStyle):

  • html/HTMLTableColElement.h:
  • html/HTMLTableElement.cpp:

(WebCore::leakBorderStyle):
(WebCore::HTMLTableElement::additionalPresentationAttributeStyle):

  • html/HTMLTableElement.h:
  • html/HTMLTableSectionElement.cpp:

(WebCore::HTMLTableSectionElement::create):
(WebCore::HTMLTableSectionElement::additionalPresentationAttributeStyle):

  • html/HTMLTableSectionElement.h:
  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
(WebCore::InspectorCSSAgent::forcePseudoState):

  • inspector/InspectorCSSAgent.h:
  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::pushNodePathToFrontend):
(WebCore::InspectorDOMAgent::boundNodeId):
(WebCore::InspectorDOMAgent::backendNodeIdForNode):

  • inspector/InspectorDOMAgent.h:
  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::handleMousePressImpl):
(WebCore::InspectorInstrumentation::forcePseudoStateImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::handleMousePress):
(WebCore::InspectorInstrumentation::forcePseudoState):

Location:
trunk/Source/WebCore
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197778 r197779  
     12016-03-08  Antti Koivisto  <antti@apple.com>
     2
     3        Make Element const in ElementRuleCollector
     4        https://bugs.webkit.org/show_bug.cgi?id=155170
     5
     6        Reviewed by Andreas Kling.
     7
     8        More const.
     9
     10        * css/ElementRuleCollector.cpp:
     11        (WebCore::ElementRuleCollector::ElementRuleCollector):
     12        (WebCore::ElementRuleCollector::matchAllRules):
     13        * css/ElementRuleCollector.h:
     14        * css/SelectorChecker.cpp:
     15        (WebCore::SelectorChecker::checkOne):
     16        (WebCore::SelectorChecker::matchesFocusPseudoClass):
     17        * cssjit/SelectorCompiler.cpp:
     18        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateAddStyleRelationIfResolvingStyle):
     19        (WebCore::SelectorCompiler::addStyleRelationFunction):
     20        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateContextFunctionCallTest):
     21        (WebCore::SelectorCompiler::elementIsActive):
     22        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsFirstChild):
     23        (WebCore::SelectorCompiler::elementIsHovered):
     24        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsOnlyChild):
     25        (WebCore::SelectorCompiler::makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
     26        (WebCore::SelectorCompiler::isPlaceholderShown):
     27        * cssjit/SelectorCompiler.h:
     28        * dom/StyledElement.h:
     29        (WebCore::StyledElement::additionalPresentationAttributeStyle):
     30        (WebCore::StyledElement::inlineStyle):
     31        (WebCore::StyledElement::collectStyleForPresentationAttribute):
     32        (WebCore::StyledElement::invalidateStyleAttribute):
     33        (WebCore::StyledElement::presentationAttributeStyle):
     34        * html/HTMLTableCellElement.cpp:
     35        (WebCore::HTMLTableCellElement::parseAttribute):
     36        (WebCore::HTMLTableCellElement::additionalPresentationAttributeStyle):
     37        * html/HTMLTableCellElement.h:
     38        * html/HTMLTableColElement.cpp:
     39        (WebCore::HTMLTableColElement::parseAttribute):
     40        (WebCore::HTMLTableColElement::additionalPresentationAttributeStyle):
     41        * html/HTMLTableColElement.h:
     42        * html/HTMLTableElement.cpp:
     43        (WebCore::leakBorderStyle):
     44        (WebCore::HTMLTableElement::additionalPresentationAttributeStyle):
     45        * html/HTMLTableElement.h:
     46        * html/HTMLTableSectionElement.cpp:
     47        (WebCore::HTMLTableSectionElement::create):
     48        (WebCore::HTMLTableSectionElement::additionalPresentationAttributeStyle):
     49        * html/HTMLTableSectionElement.h:
     50        * inspector/InspectorCSSAgent.cpp:
     51        (WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
     52        (WebCore::InspectorCSSAgent::forcePseudoState):
     53        * inspector/InspectorCSSAgent.h:
     54        * inspector/InspectorDOMAgent.cpp:
     55        (WebCore::InspectorDOMAgent::pushNodePathToFrontend):
     56        (WebCore::InspectorDOMAgent::boundNodeId):
     57        (WebCore::InspectorDOMAgent::backendNodeIdForNode):
     58        * inspector/InspectorDOMAgent.h:
     59        * inspector/InspectorInstrumentation.cpp:
     60        (WebCore::InspectorInstrumentation::handleMousePressImpl):
     61        (WebCore::InspectorInstrumentation::forcePseudoStateImpl):
     62        * inspector/InspectorInstrumentation.h:
     63        (WebCore::InspectorInstrumentation::handleMousePress):
     64        (WebCore::InspectorInstrumentation::forcePseudoState):
     65
    1662016-03-08  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    267
  • trunk/Source/WebCore/css/ElementRuleCollector.cpp

    r197764 r197779  
    7979};
    8080
    81 ElementRuleCollector::ElementRuleCollector(Element& element, const DocumentRuleSets& ruleSets, const SelectorFilter* selectorFilter)
     81ElementRuleCollector::ElementRuleCollector(const Element& element, const DocumentRuleSets& ruleSets, const SelectorFilter* selectorFilter)
    8282    : m_element(element)
    8383    , m_authorStyle(*ruleSets.authorStyle())
     
    8888}
    8989
    90 ElementRuleCollector::ElementRuleCollector(Element& element, const RuleSet& authorStyle, const SelectorFilter* selectorFilter)
     90ElementRuleCollector::ElementRuleCollector(const Element& element, const RuleSet& authorStyle, const SelectorFilter* selectorFilter)
    9191    : m_element(element)
    9292    , m_authorStyle(authorStyle)
     
    521521    // Now check author rules, beginning first with presentational attributes mapped from HTML.
    522522    if (is<StyledElement>(m_element)) {
    523         StyledElement& styledElement = downcast<StyledElement>(m_element);
     523        auto& styledElement = downcast<StyledElement>(m_element);
    524524        addElementStyleProperties(styledElement.presentationAttributeStyle());
    525525
     
    542542
    543543    if (matchAuthorAndUserStyles && is<StyledElement>(m_element)) {
    544         StyledElement& styledElement = downcast<StyledElement>(m_element);
     544        auto& styledElement = downcast<StyledElement>(m_element);
    545545        // Now check our inline style attribute.
    546546        if (styledElement.inlineStyle()) {
  • trunk/Source/WebCore/css/ElementRuleCollector.h

    r197764 r197779  
    4646class ElementRuleCollector {
    4747public:
    48     ElementRuleCollector(Element&, const DocumentRuleSets&, const SelectorFilter*);
    49     ElementRuleCollector(Element&, const RuleSet& authorStyle, const SelectorFilter*);
     48    ElementRuleCollector(const Element&, const DocumentRuleSets&, const SelectorFilter*);
     49    ElementRuleCollector(const Element&, const RuleSet& authorStyle, const SelectorFilter*);
    5050
    5151    void matchAllRules(bool matchAuthorAndUserStyles, bool includeSMILProperties);
     
    9292    void addMatchedRule(const MatchedRule&);
    9393
    94     Element& m_element;
     94    const Element& m_element;
    9595    const RuleSet& m_authorStyle;
    9696    const RuleSet* m_userStyle { nullptr };
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r197764 r197779  
    914914                addStyleRelation(checkingContext, element, Style::Relation::AffectedByHover);
    915915
    916                 if (element.hovered() || InspectorInstrumentation::forcePseudoState(const_cast<Element&>(element), CSSSelector::PseudoClassHover))
     916                if (element.hovered() || InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassHover))
    917917                    return true;
    918918            }
     
    922922                addStyleRelation(checkingContext, element, Style::Relation::AffectedByActive);
    923923
    924                 if (element.active() || InspectorInstrumentation::forcePseudoState(const_cast<Element&>(element), CSSSelector::PseudoClassActive))
     924                if (element.active() || InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassActive))
    925925                    return true;
    926926            }
     
    11511151bool SelectorChecker::matchesFocusPseudoClass(const Element& element)
    11521152{
    1153     if (InspectorInstrumentation::forcePseudoState(const_cast<Element&>(element), CSSSelector::PseudoClassFocus))
     1153    if (InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassFocus))
    11541154        return true;
    11551155    return element.focused() && isFrameFocused(element);
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r197764 r197779  
    21852185}
    21862186
    2187 static void addStyleRelationFunction(SelectorChecker::CheckingContext* checkingContext, Element* element)
     2187static void addStyleRelationFunction(SelectorChecker::CheckingContext* checkingContext, const Element* element)
    21882188{
    21892189    checkingContext->styleRelations.append({ *element, Style::Relation::AffectedByActive, 1 });
     
    30493049}
    30503050
    3051 static bool elementIsActive(Element* element)
     3051static bool elementIsActive(const Element* element)
    30523052{
    30533053    return element->active() || InspectorInstrumentation::forcePseudoState(*element, CSSSelector::PseudoClassActive);
     
    31553155}
    31563156
    3157 static bool elementIsHovered(Element* element)
     3157static bool elementIsHovered(const Element* element)
    31583158{
    31593159    return element->hovered() || InspectorInstrumentation::forcePseudoState(*element, CSSSelector::PseudoClassHover);
     
    33013301}
    33023302
    3303 static bool makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown(Element* element, SelectorChecker::CheckingContext* checkingContext)
     3303static bool makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown(const Element* element, SelectorChecker::CheckingContext* checkingContext)
    33043304{
    33053305    if (is<HTMLTextFormControlElement>(*element)) {
     
    33113311}
    33123312
    3313 static bool isPlaceholderShown(Element* element)
     3313static bool isPlaceholderShown(const Element* element)
    33143314{
    33153315    return is<HTMLTextFormControlElement>(*element) && downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
  • trunk/Source/WebCore/cssjit/SelectorCompiler.h

    r178011 r197779  
    7878};
    7979
    80 typedef unsigned (*RuleCollectorSimpleSelectorChecker)(Element*, unsigned*);
    81 typedef unsigned (*QuerySelectorSimpleSelectorChecker)(Element*);
     80typedef unsigned (*RuleCollectorSimpleSelectorChecker)(const Element*, unsigned*);
     81typedef unsigned (*QuerySelectorSimpleSelectorChecker)(const Element*);
    8282
    83 typedef unsigned (*RuleCollectorSelectorCheckerWithCheckingContext)(Element*, const SelectorChecker::CheckingContext*, unsigned*);
    84 typedef unsigned (*QuerySelectorSelectorCheckerWithCheckingContext)(Element*, const SelectorChecker::CheckingContext*);
     83typedef unsigned (*RuleCollectorSelectorCheckerWithCheckingContext)(const Element*, const SelectorChecker::CheckingContext*, unsigned*);
     84typedef unsigned (*QuerySelectorSelectorCheckerWithCheckingContext)(const Element*, const SelectorChecker::CheckingContext*);
    8585
    8686SelectorCompilationStatus compileSelector(const CSSSelector*, JSC::VM*, SelectorContext, JSC::MacroAssemblerCodeRef& outputCodeRef);
  • trunk/Source/WebCore/dom/StyledElement.h

    r197566 r197779  
    4444    virtual ~StyledElement();
    4545
    46     virtual const StyleProperties* additionalPresentationAttributeStyle() { return 0; }
     46    virtual const StyleProperties* additionalPresentationAttributeStyle() const { return nullptr; }
    4747    void invalidateStyleAttribute();
    4848
     
    6161    CSSStyleDeclaration* cssomStyle() final;
    6262
    63     const StyleProperties* presentationAttributeStyle();
     63    const StyleProperties* presentationAttributeStyle() const;
    6464    virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) { }
    6565
     
    101101}
    102102
    103 inline const StyleProperties* StyledElement::presentationAttributeStyle()
     103inline const StyleProperties* StyledElement::presentationAttributeStyle() const
    104104{
    105105    if (!elementData())
    106106        return nullptr;
    107107    if (elementData()->presentationAttributeStyleIsDirty())
    108         rebuildPresentationAttributeStyle();
     108        const_cast<StyledElement&>(*this).rebuildPresentationAttributeStyle();
    109109    return elementData()->presentationAttributeStyle();
    110110}
  • trunk/Source/WebCore/html/HTMLTableCellElement.cpp

    r197354 r197779  
    118118}
    119119
    120 const StyleProperties* HTMLTableCellElement::additionalPresentationAttributeStyle()
     120const StyleProperties* HTMLTableCellElement::additionalPresentationAttributeStyle() const
    121121{
    122122    if (HTMLTableElement* table = findParentTable())
  • trunk/Source/WebCore/html/HTMLTableCellElement.h

    r197563 r197779  
    5656    bool isPresentationAttribute(const QualifiedName&) const override;
    5757    void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
    58     const StyleProperties* additionalPresentationAttributeStyle() override;
     58    const StyleProperties* additionalPresentationAttributeStyle() const override;
    5959
    6060    bool isURLAttribute(const Attribute&) const override;
  • trunk/Source/WebCore/html/HTMLTableColElement.cpp

    r196893 r197779  
    8282}
    8383
    84 const StyleProperties* HTMLTableColElement::additionalPresentationAttributeStyle()
     84const StyleProperties* HTMLTableColElement::additionalPresentationAttributeStyle() const
    8585{
    8686    if (!hasTagName(colgroupTag))
  • trunk/Source/WebCore/html/HTMLTableColElement.h

    r197563 r197779  
    4646    bool isPresentationAttribute(const QualifiedName&) const override;
    4747    void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
    48     const StyleProperties* additionalPresentationAttributeStyle() override;
     48    const StyleProperties* additionalPresentationAttributeStyle() const override;
    4949
    5050    unsigned m_span;
  • trunk/Source/WebCore/html/HTMLTableElement.cpp

    r195452 r197779  
    444444}
    445445
    446 const StyleProperties* HTMLTableElement::additionalPresentationAttributeStyle()
     446const StyleProperties* HTMLTableElement::additionalPresentationAttributeStyle() const
    447447{
    448448    if (m_frameAttr)
  • trunk/Source/WebCore/html/HTMLTableElement.h

    r197563 r197779  
    7979
    8080    // Used to obtain either a solid or outset border decl and to deal with the frame and rules attributes.
    81     const StyleProperties* additionalPresentationAttributeStyle() override;
     81    const StyleProperties* additionalPresentationAttributeStyle() const override;
    8282
    8383    void addSubresourceAttributeURLs(ListHashSet<URL>&) const override;
  • trunk/Source/WebCore/html/HTMLTableSectionElement.cpp

    r191351 r197779  
    5050}
    5151
    52 const StyleProperties* HTMLTableSectionElement::additionalPresentationAttributeStyle()
     52const StyleProperties* HTMLTableSectionElement::additionalPresentationAttributeStyle() const
    5353{
    5454    if (HTMLTableElement* table = findParentTable())
  • trunk/Source/WebCore/html/HTMLTableSectionElement.h

    r197563 r197779  
    5959    HTMLTableSectionElement(const QualifiedName& tagName, Document&);
    6060
    61     const StyleProperties* additionalPresentationAttributeStyle() override;
     61    const StyleProperties* additionalPresentationAttributeStyle() const override;
    6262};
    6363
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r197563 r197779  
    530530}
    531531
    532 bool InspectorCSSAgent::forcePseudoState(Element& element, CSSSelector::PseudoClassType pseudoClassType)
     532bool InspectorCSSAgent::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoClassType)
    533533{
    534534    if (m_nodeIdToForcedPseudoState.isEmpty())
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.h

    r197563 r197779  
    104104    void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
    105105    void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
    106     bool forcePseudoState(Element&, CSSSelector::PseudoClassType);
     106    bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
    107107
    108108    void getComputedStyleForNode(ErrorString&, int nodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSComputedStyleProperty>>&) override;
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r195538 r197779  
    604604}
    605605
    606 int InspectorDOMAgent::boundNodeId(Node* node)
    607 {
    608     return m_documentNodeToIdMap.get(node);
     606int InspectorDOMAgent::boundNodeId(const Node* node)
     607{
     608    return m_documentNodeToIdMap.get(const_cast<Node*>(node));
    609609}
    610610
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r197563 r197779  
    180180    int pushNodeToFrontend(ErrorString&, int documentNodeId, Node*);
    181181    Node* nodeForId(int nodeId);
    182     int boundNodeId(Node*);
     182    int boundNodeId(const Node*);
    183183    void setDOMListener(DOMListener*);
    184184    BackendNodeId backendNodeIdForNode(Node*, const String& nodeGroup);
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r197599 r197779  
    292292}
    293293
    294 bool InspectorInstrumentation::forcePseudoStateImpl(InstrumentingAgents& instrumentingAgents, Element& element, CSSSelector::PseudoClassType pseudoState)
     294bool InspectorInstrumentation::forcePseudoStateImpl(InstrumentingAgents& instrumentingAgents, const Element& element, CSSSelector::PseudoClassType pseudoState)
    295295{
    296296    if (InspectorCSSAgent* cssAgent = instrumentingAgents.inspectorCSSAgent())
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r197599 r197779  
    138138    static bool handleMousePress(Frame&);
    139139    static bool handleTouchEvent(Frame&, Node&);
    140     static bool forcePseudoState(Element&, CSSSelector::PseudoClassType);
     140    static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
    141141
    142142    static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
     
    307307    static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
    308308    static bool handleMousePressImpl(InstrumentingAgents&);
    309     static bool forcePseudoStateImpl(InstrumentingAgents&, Element&, CSSSelector::PseudoClassType);
     309    static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
    310310
    311311    static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
     
    627627}
    628628
    629 inline bool InspectorInstrumentation::forcePseudoState(Element& element, CSSSelector::PseudoClassType pseudoState)
     629inline bool InspectorInstrumentation::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoState)
    630630{
    631631    FAST_RETURN_IF_NO_FRONTENDS(false);
Note: See TracChangeset for help on using the changeset viewer.