Example #1
0
void setJSCSSCharsetRuleEncoding(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSCSSCharsetRule* castedThis = static_cast<JSCSSCharsetRule*>(thisObject);
    CSSCharsetRule* imp = static_cast<CSSCharsetRule*>(castedThis->impl());
    ExceptionCode ec = 0;
    imp->setEncoding(valueToStringWithNullCheck(exec, value), ec);
    setDOMException(exec, ec);
}
Example #2
0
JSValue jsCSSCharsetRuleEncoding(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCSSCharsetRule* castedThis = static_cast<JSCSSCharsetRule*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CSSCharsetRule* imp = static_cast<CSSCharsetRule*>(castedThis->impl());
    JSValue result = jsStringOrNull(exec, imp->encoding());
    return result;
}
Example #3
0
static void encodingAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.CSSCharsetRule.encoding._set");
    CSSCharsetRule* imp = V8CSSCharsetRule::toNative(info.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<WithNullCheck>, v, value);
    ExceptionCode ec = 0;
    imp->setEncoding(v, ec);
    if (UNLIKELY(ec))
        V8Proxy::setDOMException(ec);
    return;
}
void JSCSSCharsetRule::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
    switch (token) {
    case EncodingAttrNum: {
        CSSCharsetRule* imp = static_cast<CSSCharsetRule*>(impl());

        ExceptionCode ec = 0;
        imp->setEncoding(valueToStringWithNullCheck(exec, value), ec);
        setDOMException(exec, ec);
        break;
    }
    }
}
JSValue* JSCSSCharsetRule::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case EncodingAttrNum: {
        CSSCharsetRule* imp = static_cast<CSSCharsetRule*>(impl());

        return jsStringOrNull(imp->encoding());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
Example #6
0
static v8::Handle<v8::Value> encodingAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.CSSCharsetRule.encoding._get");
    CSSCharsetRule* imp = V8CSSCharsetRule::toNative(info.Holder());
    return v8StringOrNull(imp->encoding());
}
Example #7
0
CSSRule* CSSStream::ParseRule(CSSStyleSheet* parentStyleSheet, CSSRule* parentRule, ICSSRuleListener* pListener)
{
//	stream->SkipSpaces();

	getnextc();

	if (m_c == L'/')
	{
		getnextc();
		//if (c == L'*')
		EatChar(L'*');
		{
			CSSCommentRule* p = new CSSCommentRule;
			//p->AddRef();

			p->m_textOffset[0] = stream.m_ipos-2;
			p->m_textOffset[1] = stream.m_ipos-2;
			p->m_textOffset[2] = stream.m_ipos;

			p->m_parentStyleSheet = parentStyleSheet;
			p->m_parentRule = parentRule;

			StringStream cssText;
			cssText << L"/*";

			while (!stream.eof())
			{
				if (stream.m_c == L'*')
				{
					stream.getnextc();
					if (stream.m_c == L'/')
					{
						stream.getnextc();
						break;
					}
				}

				cssText << (WCHAR)stream.m_c;
			}

			p->m_textOffset[3] = stream.m_ipos;

			stream.EatChar(L'*');
			stream.EatChar(L'/');

			p->m_textOffset[4] = stream.m_ipos;
			p->m_textOffset[5] = stream.m_ipos;

			cssText << L"*/";

			p->m_cssText = cssText->str();

			*pVal = p;
		}
	}
	else if (m_c == L'@')	// at-rule
	{
		ASSERT(0);
#if 0
		String id = stream.GetID();

		StringStream strbuilder;

		strbuilder << L"@";
		strbuilder << id;

		int curly = 0;

		while (!stream.eof())
		{
			strbuilder << (WCHAR)m_c;

			if (stream.m_c == L'{')
			{
				curly++;
			}
			else if (stream.m_c == L'}')
			{
				curly--;
				if (curly == 0)
					break;
			}
			else if (stream.m_c == L';')
			{
				if (curly == 0)
				{
					break;
				}
			}
		}

		// Read spaces
		while (!stream.eof())
		{
			if (!isspace(stream.m_c))
			{
				break;
			}
			strbuilder << (WCHAR)stream.m_c;
			stream.getnextc();
		}

		String cssText = strbuilder->str();

		pCallback->AtRule(id, cssText);

		if (id == L"charset")
		{
			CSSCharsetRule* p = new CSSCharsetRule;
			if (p)
			{
			//	p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;

				p->set_cssText(cssText);

				*pVal = p;
			}
		}
		else if (id == L"import")
		{
			CSSImportRule* p = new CSSImportRule;
			if (p)
			{
			//	p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;

				p->set_cssText(cssText);

				*pVal = p;
			}
		}
		else if (id == L"fontface")
		{
			CSSFontFaceRule* p = new CSSFontFaceRule;
			if (p)
			{
			//	p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;

				p->set_cssText(cssText);

				*pVal = p;
			}
		}
		else if (id == L"media")
		{
			CSSMediaRule* p = new CSSMediaRule;
			if (p)
			{
				//p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;

				p->set_cssText(cssText);

				*pVal = p;
			}
		}
		else if (id == L"color-profile")
		{
			SVGColorProfileRule* p = new SVGColorProfileRule;
			if (p)
			{
//				p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;

				p->set_cssText(cssText);

				*pVal = p;
			}
		}
		/*
		else if (!tcscmp(id, L"charset"))
		{
		}
		*/
		else // Unknown at-rule
		{
			CSSUnknownRule* p = new CSSUnknownRule;
			if (p)
			{
				//p->AddRef();
				p->m_parentStyleSheet = parentStyleSheet;
				p->m_parentRule = parentRule;
				p->set_cssText(cssText);

				*pVal = p;
			}
		}
#endif
	}
	else
	{
		ParseStyleRule();
		if (p)
		{
		//	p->m_textOffset[0] = stream.m_ipos;

			p->m_parentStyleSheet = parentStyleSheet;
			p->m_parentRule = parentRule;

			StringStream cssText;

		// Skip selectors
			while (!stream.eof())
			{
				cssText << (WCHAR)stream.m_c;

				if (m_c == L'{')
				{
					break;
				}

				stream.getnextc();
			}

			p->m_textOffset[1] = stream.m_ipos;

		// Skip style declaration
			stream.EatChar(L'{');
			int curly = 1;

			p->m_textOffset[2] = stream.m_ipos;

			while (!stream.eof())
			{
				cssText << (WCHAR)stream.m_c;

				p->m_textOffset[3] = stream.m_ipos;

				if (stream.m_c == '"')
				{
					stream.getnextc();

					//if (delimiter == L'\'' || L'\"')
					{
						while (!stream.eof())
						{
							cssText << (WCHAR)stream.m_c;

							if (stream.m_c == '\\')
							{
								stream.getnextc();
								cssText << (WCHAR)stream.m_c;
							}
							else if (stream.m_c == '"')
							{
								break;
							}
						}
					}
				}
				else if (stream.m_c == L'{')
				{
					curly++;
				}
				else if (stream.m_c == L'}')
				{
					curly--;
					if (curly == 0)
					{
						break;
					}
				}
			}

			p->m_textOffset[4] = stream.m_ipos;

			// Read spaces
			while (!stream.eof())
			{
				if (!isspace(stream.m_c))
				{
					break;
				}
				cssText << (WCHAR)stream.m_c;
				stream.getnextc();
			}

			p->m_textOffset[5] = stream.m_ipos;

			p->set_cssText(cssText->str());
			p->m_pListener = pListener;

			*pVal = p;
		}
	}
	return Success;
}