Example #1
0
void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments, bool acceptNoArguments)
{
    RefPtrWillBeRawPtr<ScriptArguments> arguments = scriptArguments;
    if (!acceptNoArguments && (!arguments || !arguments->argumentCount()))
        return;

    if (scriptState && !scriptState->contextIsValid())
        arguments.clear();
    String message;
    if (arguments)
        arguments->getFirstArgumentAsString(message);
    RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, level, message);
    consoleMessage->setType(type);
    consoleMessage->setScriptState(scriptState);
    consoleMessage->setScriptArguments(arguments);
    consoleMessage->setCallStack(currentScriptCallStackForConsole(ScriptCallStack::maxCallStackSizeToCapture));
    reportMessageToConsole(consoleMessage.release());
}
Example #2
0
PassOwnPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature, CSSParserValueList* valueList)
{
    RefPtrWillBeRawPtr<CSSValue> cssValue;
    bool isValid = false;

    // Create value for media query expression that must have 1 or more values.
    if (valueList) {
        if (valueList->size() == 1) {
            CSSParserValue* value = valueList->current();

            if (featureWithCSSValueID(mediaFeature, value)) {
                // Media features that use CSSValueIDs.
                cssValue = CSSPrimitiveValue::createIdentifier(value->id);
                if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(cssValue.get())->getValueID()))
                    cssValue.clear();
            } else if (featureWithValidDensity(mediaFeature, value)) {
                // Media features that must have non-negative <density>, ie. dppx, dpi or dpcm.
                cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
            } else if (featureWithValidPositiveLenghtOrNumber(mediaFeature, value)) {
                // Media features that must have non-negative <lenght> or number value.
                cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
            } else if (featureWithPositiveInteger(mediaFeature, value)) {
                // Media features that must have non-negative integer value.
                cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_NUMBER);
            } else if (featureWithPositiveNumber(mediaFeature, value)) {
                // Media features that must have non-negative number value.
                cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_NUMBER);
            } else if (featureWithZeroOrOne(mediaFeature, value)) {
                // Media features that must have (0|1) value.
                cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_NUMBER);
            }

            isValid = cssValue;

        } else if (valueList->size() == 3 && featureWithAspectRatio(mediaFeature)) {
            // Create list of values.
            // Currently accepts only <integer>/<integer>.
            // Applicable to device-aspect-ratio and aspec-ratio.
            isValid = true;
            float numeratorValue = 0;
            float denominatorValue = 0;
            // The aspect-ratio must be <integer> (whitespace)? / (whitespace)? <integer>.
            for (unsigned i = 0; i < 3; ++i, valueList->next()) {
                const CSSParserValue* value = valueList->current();
                if (i != 1 && value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValue > 0 && value->isInt) {
                    if (!i)
                        numeratorValue = value->fValue;
                    else
                        denominatorValue = value->fValue;
                } else if (i == 1 && value->unit == CSSParserValue::Operator && value->iValue == '/') {
                    continue;
                } else {
                    isValid = false;
                    break;
                }
            }

            if (isValid)
                cssValue = CSSAspectRatioValue::create(numeratorValue, denominatorValue);
        }
    } else if (featureWithoutValue(mediaFeature)) {
        isValid = true;
    }

    if (!isValid)
        return nullptr;

    return adoptPtr(new MediaQueryExp(mediaFeature, cssValue));
}