mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / GetMatchedStyles Method

A CSS3 Selector string of the element we wish to inspect its style.

If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

A Boolean if we prefer the output in XML format instead of JSON which is the default.

GetMatchedStyles Method
Description

Resolves the CSS3 stylesheets that compose the end-style of an HTML5 element.

Syntax
Visual Basic
Public Function GetMatchedStyles( _
   ByVal Selector As String, _
   ByVal ToXML As Boolean _
) As String
Parameters
Selector

A CSS3 Selector string of the element we wish to inspect its style.

If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

ToXML

A Boolean if we prefer the output in XML format instead of JSON which is the default.

Return Type

An XML or JSON string with all the CSS3 stylesheets, including User Agent styles, attribute styles and inline styles, that compose the end-style of an HTML5 element.

Remarks

The result of this method provides the information required in order to generate a detailed list of stylesheets and how stylesheet rules compose the end-style of an HTML5 element.

The functionality can be used to reproduce the CSS3 inspector of Chromium DevTools.

Example
Private Sub HTML5_ReadSelectorCSS()

    Dim XML As String
    XML = WebKitX.GetMatchedStyles(CurrentSelector, True)
    frm_Panel_CSS3.ReadCSS WebKitX.URL, CurrentSelector, XML, StyleSheets

End Sub


Private Sub WebKitX_OnDevToolsWebSocket(ByVal Data As String)
    
    On Error Resume Next
    If InStr(Data, "CSS.styleSheetAdded") > 0 Then
        Dim xDOM As Object
        Set xDOM = XML_DOM(JSONtoXML(Data))
        StyleSheets.Add xDOM.selectSingleNode("//styleSheetId").Text, xDOM.selectSingleNode("//sourceURL").Text
    End If
    Err.Clear

End Sub

Public Function XML_DOM(Optional sAnyXML) As IXMLDOMDocument
    Dim xDOM As DOMDocument30
    Set xDOM = New DOMDocument30
    xDOM.Async = False
    xDOM.resolveExternals = False
    xDOM.validateOnParse = False
    If Not IsMissing(sAnyXML) Then
        If IsObject(sAnyXML) Then
            xDOM.Load sAnyXML
        ElseIf sAnyXML <> vbNullString Then
            If InStrB(sAnyXML, "<") Then
                xDOM.loadXML sAnyXML
            Else
                xDOM.Load sAnyXML
            End If
        End If
    End If
    xDOM.SetProperty "SelectionLanguage", "XPath"
    xDOM.SetProperty "SelectionNamespaces", vbNullString
    Set XML_DOM = xDOM
End Function
See Also