SelectorCompiler.h [plain text]
#ifndef SelectorCompiler_h
#define SelectorCompiler_h
#if ENABLE(CSS_SELECTOR_JIT)
#include "SelectorChecker.h"
#include <JavaScriptCore/MacroAssemblerCodeRef.h>
#define CSS_SELECTOR_JIT_PROFILING 0
namespace JSC {
class MacroAssemblerCodeRef;
class VM;
}
namespace WebCore {
class CSSSelector;
class Element;
class RenderStyle;
class SelectorCompilationStatus {
public:
enum Status {
NotCompiled,
CannotCompile,
SimpleSelectorChecker,
SelectorCheckerWithCheckingContext
};
SelectorCompilationStatus()
: m_status(NotCompiled)
{ }
SelectorCompilationStatus(Status status)
: m_status(status)
{ }
operator Status() const { return m_status; }
private:
Status m_status;
};
namespace SelectorCompiler {
struct CheckingContext {
SelectorChecker::Mode resolvingMode;
RenderStyle* elementStyle;
};
enum class SelectorContext {
RuleCollector,
QuerySelector
};
typedef unsigned (*SimpleSelectorChecker)(Element*);
typedef unsigned (*SelectorCheckerWithCheckingContext)(Element*, const CheckingContext*);
SelectorCompilationStatus compileSelector(const CSSSelector*, JSC::VM*, SelectorContext, JSC::MacroAssemblerCodeRef& outputCodeRef);
inline SimpleSelectorChecker simpleSelectorCheckerFunction(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker);
return reinterpret_cast<SimpleSelectorChecker>(executableAddress);
}
inline SelectorCheckerWithCheckingContext selectorCheckerFunctionWithCheckingContext(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
return reinterpret_cast<SelectorCheckerWithCheckingContext>(executableAddress);
}
} }
#endif // ENABLE(CSS_SELECTOR_JIT)
#endif // SelectorCompiler_h