Changeset 269923 in webkit


Ignore:
Timestamp:
Nov 17, 2020 2:14:20 PM (3 years ago)
Author:
Andres Gonzalez
Message:

Implementation of AXCoreObject::innerHTML and outerHTML.
https://bugs.webkit.org/show_bug.cgi?id=219037

Reviewed by Chris Fleizach.

No change in functionality, debugging code.

  • Added innerHTML and outerHTmL methods to AXCoreObject for debugging

purposes.

  • The AXIsolatedObject implementation of these methods forwards the call

to the associated AXObject and does a lazy caching of the Inner/OuterHTML
properties.

  • The AXLogger class is now declared and defined only #if !LOG_DISABLED.
  • accessibility/AXLogger.cpp:

(WebCore::AXLogger::log):
(WebCore::operator<<):

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::innerHTML const):
(WebCore::AccessibilityObject::outerHTML const):

  • accessibility/AccessibilityObject.h:
  • accessibility/AccessibilityObjectInterface.h:
  • accessibility/isolatedtree/AXIsolatedObject.cpp:

(WebCore::AXIsolatedObject::innerHTML const):
(WebCore::AXIsolatedObject::outerHTML const):

  • accessibility/isolatedtree/AXIsolatedObject.h:
  • accessibility/isolatedtree/AXIsolatedTree.h:
  • accessibility/mac/WebAccessibilityObjectWrapperBase.mm:

(-[WebAccessibilityObjectWrapperBase innerHTML]):
(-[WebAccessibilityObjectWrapperBase outerHTML]):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269921 r269923  
     12020-11-17  Andres Gonzalez  <andresg_22@apple.com>
     2
     3        Implementation of AXCoreObject::innerHTML and outerHTML.
     4        https://bugs.webkit.org/show_bug.cgi?id=219037
     5
     6        Reviewed by Chris Fleizach.
     7
     8        No change in functionality, debugging code.
     9
     10        - Added innerHTML and outerHTmL methods to AXCoreObject for debugging
     11        purposes.
     12        - The AXIsolatedObject implementation of these methods forwards the call
     13        to the associated AXObject and does a lazy caching of the Inner/OuterHTML
     14        properties.
     15        - The AXLogger class is now declared and defined only #if !LOG_DISABLED.
     16
     17        * accessibility/AXLogger.cpp:
     18        (WebCore::AXLogger::log):
     19        (WebCore::operator<<):
     20        * accessibility/AccessibilityObject.cpp:
     21        (WebCore::AccessibilityObject::innerHTML const):
     22        (WebCore::AccessibilityObject::outerHTML const):
     23        * accessibility/AccessibilityObject.h:
     24        * accessibility/AccessibilityObjectInterface.h:
     25        * accessibility/isolatedtree/AXIsolatedObject.cpp:
     26        (WebCore::AXIsolatedObject::innerHTML const):
     27        (WebCore::AXIsolatedObject::outerHTML const):
     28        * accessibility/isolatedtree/AXIsolatedObject.h:
     29        * accessibility/isolatedtree/AXIsolatedTree.h:
     30        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
     31        (-[WebAccessibilityObjectWrapperBase innerHTML]):
     32        (-[WebAccessibilityObjectWrapperBase outerHTML]):
     33
    1342020-11-17  Zalan Bujtas  <zalan@apple.com>
    235
  • trunk/Source/WebCore/accessibility/AXLogger.cpp

    r269859 r269923  
    2828
    2929#include "config.h"
     30
     31#if !LOG_DISABLED
    3032#include "AXLogger.h"
    3133
     
    5860void AXLogger::log(const String& message)
    5961{
    60 #if !LOG_DISABLED
    6162    LOG(Accessibility, "%s", message.utf8().data());
    62 #else
    63     UNUSED_PARAM(message);
    64 #endif
    6563}
    6664
     
    273271    if (role == AccessibilityRole::StaticText && parent)
    274272        objectWithInterestingHTML = parent;
    275     if (objectWithInterestingHTML) {
    276         if (auto* element = objectWithInterestingHTML->element())
    277             stream.dumpProperty("outerHTML", element->outerHTML());
    278     }
     273    if (objectWithInterestingHTML)
     274        stream.dumpProperty("outerHTML", objectWithInterestingHTML->outerHTML());
    279275
    280276    stream.dumpProperty("address", &object);
     
    315311
    316312} // namespace WebCore
     313
     314#endif // !LOG_DISABLED
  • trunk/Source/WebCore/accessibility/AXLogger.h

    r262224 r269923  
    2626#pragma once
    2727
     28#if !LOG_DISABLED
     29
    2830#include "AXObjectCache.h"
    2931#include "AccessibilityObjectInterface.h"
     
    4951};
    5052
    51 #if LOG_DISABLED
     53#define AXTRACE(methodName) AXLogger axLogger(methodName)
     54#define AXLOG(x) AXLogger::log(x)
     55
     56} // namespace WebCore
     57
     58#else
     59
    5260#define AXTRACE(methodName) (void)0
    5361#define AXLOG(x) (void)0
    54 #else
    55 #define AXTRACE(methodName) AXLogger axLogger(methodName)
    56 #define AXLOG(x) AXLogger::log(x)
    57 #endif // LOG_DISABLED
    5862
    59 } // namespace WebCore
     63#endif // !LOG_DISABLED
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r269568 r269923  
    35813581}
    35823582
     3583String AccessibilityObject::innerHTML() const
     3584{
     3585    auto* element = this->element();
     3586    return element ? element->innerHTML() : String();
     3587}
     3588
     3589String AccessibilityObject::outerHTML() const
     3590{
     3591    auto* element = this->element();
     3592    return element ? element->outerHTML() : String();
     3593}
     3594
    35833595namespace Accessibility {
    35843596
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r268610 r269923  
    784784    unsigned getLengthForTextRange() const;
    785785
     786    String innerHTML() const override;
     787    String outerHTML() const override;
     788
    786789private:
    787790    Optional<SimpleRange> rangeOfStringClosestToRangeInDirection(const SimpleRange&, AccessibilitySearchDirection, const Vector<String>&) const;
  • trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h

    r268610 r269923  
    14901490    virtual AccessibilityChildrenVector documentLinks() = 0;
    14911491
     1492    virtual String innerHTML() const = 0;
     1493    virtual String outerHTML() const = 0;
     1494
    14921495private:
    14931496    // Detaches this object from the objects it references and it is referenced by.
  • trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp

    r269692 r269923  
    20922092}
    20932093
     2094String AXIsolatedObject::innerHTML() const
     2095{
     2096    if (m_propertyMap.contains(AXPropertyName::InnerHTML))
     2097        return stringAttributeValue(AXPropertyName::InnerHTML);
     2098
     2099    return Accessibility::retrieveValueFromMainThread<String>([this] () -> String {
     2100        auto* axObject = associatedAXObject();
     2101        String value = axObject ? axObject->innerHTML().isolatedCopy() : String();
     2102
     2103        // Cache value so that there is no need to access the main thread in subsequent calls.
     2104        const_cast<AXIsolatedObject*>(this)->setProperty(AXPropertyName::InnerHTML, value);
     2105
     2106        return value;
     2107    });
     2108}
     2109
     2110String AXIsolatedObject::outerHTML() const
     2111{
     2112    if (m_propertyMap.contains(AXPropertyName::OuterHTML))
     2113        return stringAttributeValue(AXPropertyName::OuterHTML);
     2114
     2115    return Accessibility::retrieveValueFromMainThread<String>([this] () -> String {
     2116        auto* axObject = associatedAXObject();
     2117        String value = axObject ? axObject->outerHTML().isolatedCopy() : String();
     2118
     2119        // Cache value so that there is no need to access the main thread in subsequent calls.
     2120        const_cast<AXIsolatedObject*>(this)->setProperty(AXPropertyName::OuterHTML, value);
     2121
     2122        return value;
     2123    });
     2124}
     2125
    20942126} // namespace WebCore
    20952127
  • trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h

    r269692 r269923  
    648648    void updateBackingStore() override;
    649649
     650    String innerHTML() const override;
     651    String outerHTML() const override;
     652
    650653    AXIsolatedTreeID m_treeID;
    651654    RefPtr<AXIsolatedTree> m_cachedTree;
  • trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h

    r268454 r269923  
    127127    HorizontalScrollBar,
    128128    IdentifierAttribute,
     129    IncrementButton,
     130    InnerHTML,
    129131    InvalidStatus,
    130     IncrementButton,
    131132    IsAccessibilityIgnored,
    132133    IsActiveDescendantOfFocusedContainer,
     
    250251    NextSibling,
    251252    Orientation,
     253    OuterHTML,
    252254    Path,
    253255    PlaceholderValue,
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm

    r268585 r269923  
    602602}
    603603
    604 #ifndef NDEBUG
    605604- (NSString *)innerHTML
    606605{
    607     if (auto* element = self.axBackingObject->element())
    608         return element->innerHTML();
     606    if (auto* backingObject = self.axBackingObject)
     607        return backingObject->innerHTML();
    609608    return nil;
    610609}
     
    612611- (NSString *)outerHTML
    613612{
    614     if (auto* element = self.axBackingObject->element())
    615         return element->outerHTML();
     613    if (auto* backingObject = self.axBackingObject)
     614        return backingObject->outerHTML();
    616615    return nil;
    617616}
    618 #endif
    619617
    620618#pragma mark Search helpers
Note: See TracChangeset for help on using the changeset viewer.