コード例 #1
0
void InspectorCSSOMWrappers::collect(ListType* listType)
{
    if (!listType)
        return;
    unsigned size = listType->length();
    for (unsigned i = 0; i < size; ++i) {
        CSSRule* cssRule = listType->item(i);
        switch (cssRule->type()) {
        case CSSRule::IMPORT_RULE:
            collect(downcast<CSSImportRule>(*cssRule).styleSheet());
            break;
        case CSSRule::MEDIA_RULE:
            collect(downcast<CSSMediaRule>(cssRule));
            break;
        case CSSRule::SUPPORTS_RULE:
            collect(downcast<CSSSupportsRule>(cssRule));
            break;
#if ENABLE(CSS_REGIONS)
        case CSSRule::WEBKIT_REGION_RULE:
            collect(downcast<WebKitCSSRegionRule>(cssRule));
            break;
#endif
        case CSSRule::STYLE_RULE:
            m_styleRuleToCSSOMWrapperMap.add(&downcast<CSSStyleRule>(*cssRule).styleRule(), downcast<CSSStyleRule>(cssRule));
            break;
        default:
            break;
        }
    }
}
コード例 #2
0
JSValue jsCSSRuleCssText(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCSSRule* castedThis = static_cast<JSCSSRule*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CSSRule* imp = static_cast<CSSRule*>(castedThis->impl());
    JSValue result = jsStringOrNull(exec, imp->cssText());
    return result;
}
コード例 #3
0
JSValue jsCSSRuleParentRule(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCSSRule* castedThis = static_cast<JSCSSRule*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CSSRule* imp = static_cast<CSSRule*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentRule()));
    return result;
}
コード例 #4
0
void setJSCSSRuleCssText(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSCSSRule* castedThis = static_cast<JSCSSRule*>(thisObject);
    CSSRule* imp = static_cast<CSSRule*>(castedThis->impl());
    ExceptionCode ec = 0;
    imp->setCssText(valueToStringWithNullCheck(exec, value), ec);
    setDOMException(exec, ec);
}
コード例 #5
0
JSValue jsCSSRuleType(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCSSRule* castedThis = static_cast<JSCSSRule*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CSSRule* imp = static_cast<CSSRule*>(castedThis->impl());
    JSValue result = jsNumber(imp->type());
    return result;
}
コード例 #6
0
CSSStyleRule* InspectorCSSStore::asCSSStyleRule(StyleBase* styleBase)
{
    if (!styleBase->isStyleRule())
        return 0;
    CSSRule* rule = static_cast<CSSRule*>(styleBase);
    if (rule->type() != CSSRule::STYLE_RULE)
        return 0;
    return static_cast<CSSStyleRule*>(rule);
}
コード例 #7
0
ファイル: CSSStyleSheet.cpp プロジェクト: sysrqb/chromium-src
bool CSSStyleSheet::isLoading()
{
    unsigned len = length();
    for (unsigned i = 0; i < len; ++i) {
        CSSRule* rule = item(i);
        if (rule->isImportRule() && static_cast<CSSImportRule*>(rule)->isLoading())
            return true;
    }
    return false;
}
コード例 #8
0
static void cssTextAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    CSSRule* imp = V8CSSRule::toNative(info.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, v, value);
    ExceptionCode ec = 0;
    imp->setCssText(v, ec);
    if (UNLIKELY(ec))
        setDOMException(ec, info.GetIsolate());
    return;
}
コード例 #9
0
ファイル: CSSRuleList.cpp プロジェクト: vizcount/work
CSSRuleList::CSSRuleList(CSSStyleSheet* styleSheet, bool omitCharsetRules)
    : m_styleSheet(styleSheet)
{
    if (styleSheet && omitCharsetRules) {
        m_styleSheet = 0;
        for (unsigned i = 0; i < styleSheet->length(); ++i) {
            CSSRule* rule = styleSheet->item(i);
            if (!rule->isCharsetRule())
                append(static_cast<CSSRule*>(rule));
        }
    }
}
コード例 #10
0
static v8::Handle<v8::Value> parentRuleAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    CSSRule* imp = V8CSSRule::toNative(info.Holder());
    RefPtr<CSSRule> result = imp->parentRule();
    v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();
    if (wrapper.IsEmpty()) {
        wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
        if (!wrapper.IsEmpty())
            V8DOMWrapper::setNamedHiddenReference(info.Holder(), "parentRule", wrapper);
    }
    return wrapper;
}
コード例 #11
0
ファイル: JSCSSRule.cpp プロジェクト: Gin-Rye/duibrowser
void JSCSSRule::putValueProperty(ExecState* exec, int token, JSValue* value)
{
    switch (token) {
    case CssTextAttrNum: {
        CSSRule* imp = static_cast<CSSRule*>(impl());
        ExceptionCode ec = 0;
        imp->setCssText(valueToStringWithNullCheck(exec, value), ec);
        setDOMException(exec, ec);
        break;
    }
    }
}
コード例 #12
0
ファイル: JSCSSRule.cpp プロジェクト: FilipBE/qtextended
JSValue* JSCSSRule::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case TypeAttrNum: {
        CSSRule* imp = static_cast<CSSRule*>(impl());

        return jsNumber(imp->type());
    }
    case CssTextAttrNum: {
        CSSRule* imp = static_cast<CSSRule*>(impl());

        return jsStringOrNull(imp->cssText());
    }
    case ParentStyleSheetAttrNum: {
        CSSRule* imp = static_cast<CSSRule*>(impl());

        return toJS(exec, WTF::getPtr(imp->parentStyleSheet()));
    }
    case ParentRuleAttrNum: {
        CSSRule* imp = static_cast<CSSRule*>(impl());

        return toJS(exec, WTF::getPtr(imp->parentRule()));
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
コード例 #13
0
ファイル: CSSStyleSheet.cpp プロジェクト: rhythmkay/webkit
RefPtr<CSSRuleList> CSSStyleSheet::rules()
{
    if (!canAccessRules())
        return nullptr;
    // IE behavior.
    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
    unsigned ruleCount = length();
    for (unsigned i = 0; i < ruleCount; ++i) {
        CSSRule* rule = item(i);
        if (rule->type() == CSSRule::CHARSET_RULE)
            continue;
        nonCharsetRules->rules().append(rule);
    }
    return nonCharsetRules;
}
コード例 #14
0
static CSSStyleSheet* findStyleSheet(StyleEngine* styleEngine, StyleRule* rule)
{
    // FIXME: StyleEngine has a bunch of different accessors for StyleSheet lists, is this the only one we need to care about?
    const Vector<RefPtr<CSSStyleSheet> >& stylesheets = styleEngine->activeAuthorStyleSheets();
    for (size_t i = 0; i < stylesheets.size(); ++i) {
        CSSStyleSheet* sheet = stylesheets[i].get();
        for (unsigned j = 0; j < sheet->length(); ++j) {
            CSSRule* cssRule = sheet->item(j);
            if (cssRule->type() != CSSRule::STYLE_RULE)
                continue;
            CSSStyleRule* cssStyleRule = toCSSStyleRule(cssRule);
            if (cssStyleRule->styleRule() == rule)
                return sheet;
        }
    }
    return 0;
}
コード例 #15
0
ファイル: css_rule.cpp プロジェクト: Fat-Zer/tdelibs
void CSSRule::assignOther( const CSSRule &other, RuleType thisType )
{
    if (other.type() != thisType ) {
	if ( impl ) impl->deref();
	impl = 0;
    } else
	CSSRule::operator = ( other );
}
コード例 #16
0
PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
{
    KURL url = finalURL();
    Document* document = findDocument();
    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
        return 0;
    // IE behavior.
    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
    unsigned ruleCount = length();
    for (unsigned i = 0; i < ruleCount; ++i) {
        CSSRule* rule = item(i);
        if (rule->isCharsetRule())
            continue;
        nonCharsetRules->rules().append(rule);
    }
    return nonCharsetRules.release();
}
コード例 #17
0
ファイル: ElementRuleCollector.cpp プロジェクト: domenic/mojo
CSSRule* ElementRuleCollector::findStyleRule(CSSRuleCollection* cssRules, StyleRule* styleRule)
{
    if (!cssRules)
        return 0;
    CSSRule* result = 0;
    for (unsigned i = 0; i < cssRules->length() && !result; ++i) {
        CSSRule* cssRule = cssRules->item(i);
        CSSRule::Type cssRuleType = cssRule->type();
        if (cssRuleType == CSSRule::STYLE_RULE) {
            CSSStyleRule* cssStyleRule = toCSSStyleRule(cssRule);
            if (cssStyleRule->styleRule() == styleRule)
                result = cssRule;
        } else {
            result = findStyleRule(nestedRuleList(cssRule), styleRule);
        }
    }
    return result;
}
コード例 #18
0
ファイル: CSSStyleSheet.cpp プロジェクト: sysrqb/chromium-src
void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
{
    Deque<CSSStyleSheet*> styleSheetQueue;
    styleSheetQueue.append(this);

    while (!styleSheetQueue.isEmpty()) {
        CSSStyleSheet* styleSheet = styleSheetQueue.takeFirst();

        for (unsigned i = 0; i < styleSheet->length(); ++i) {
            CSSRule* rule = styleSheet->item(i);
            if (rule->isImportRule()) {
                if (CSSStyleSheet* ruleStyleSheet = static_cast<CSSImportRule*>(rule)->styleSheet())
                    styleSheetQueue.append(ruleStyleSheet);
            }
            rule->addSubresourceStyleURLs(urls);
        }
    }
}
コード例 #19
0
ファイル: CSSStyleSheet.cpp プロジェクト: Chingliu/EAWebkit
void CSSStyleSheet::addSubresourceURLStrings(HashSet<String>& urls, const String& base) const
{        
    RefPtr<CSSRuleList> ruleList = const_cast<CSSStyleSheet*>(this)->cssRules();
    
    // Add the URLs for each child import rule, and recurse for the stylesheet belonging to each of those rules.
    for (unsigned i = 0; i < ruleList->length(); ++i) {
        CSSRule* rule = ruleList->item(i);
        if (rule->type() != CSSRule::IMPORT_RULE)
            continue;

        CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);
        CSSStyleSheet* ruleSheet = importRule->styleSheet();
        if (!ruleSheet)
            continue;

        KURL fullURL(KURL(base), importRule->href());
        urls.add(fullURL.string());
        ruleSheet->addSubresourceURLStrings(urls, fullURL.string());
    }
}
コード例 #20
0
ファイル: CSSStyleSheet.cpp プロジェクト: sysrqb/chromium-src
unsigned CSSStyleSheet::insertRule(const String& rule, unsigned index, ExceptionCode& ec)
{
    ec = 0;
    if (index > length()) {
        ec = INDEX_SIZE_ERR;
        return 0;
    }
    CSSParser p(useStrictParsing());
    RefPtr<CSSRule> r = p.parseRule(this, rule);

    if (!r) {
        ec = SYNTAX_ERR;
        return 0;
    }

    // Throw a HIERARCHY_REQUEST_ERR exception if the rule cannot be inserted at the specified index.  The best
    // example of this is an @import rule inserted after regular rules.
    if (index > 0) {
        if (r->isImportRule()) {
            // Check all the rules that come before this one to make sure they are only @charset and @import rules.
            for (unsigned i = 0; i < index; ++i) {
                if (!item(i)->isCharsetRule() && !item(i)->isImportRule()) {
                    ec = HIERARCHY_REQUEST_ERR;
                    return 0;
                }
            }
        } else if (r->isCharsetRule()) {
            // The @charset rule has to come first and there can be only one.
            ec = HIERARCHY_REQUEST_ERR;
            return 0;
        }
    }

    CSSRule* c = r.get();
    m_children.insert(index, r.release());
    c->insertedIntoParent();

    styleSheetChanged();

    return index;
}
コード例 #21
0
CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet,
                                           CSSRule* parentRule) const {
  CSSRule* rule = nullptr;
  StyleRuleBase* self = const_cast<StyleRuleBase*>(this);
  switch (type()) {
    case Style:
      rule = CSSStyleRule::create(toStyleRule(self), parentSheet);
      break;
    case Page:
      rule = CSSPageRule::create(toStyleRulePage(self), parentSheet);
      break;
    case FontFace:
      rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet);
      break;
    case Media:
      rule = CSSMediaRule::create(toStyleRuleMedia(self), parentSheet);
      break;
    case Supports:
      rule = CSSSupportsRule::create(toStyleRuleSupports(self), parentSheet);
      break;
    case Import:
      rule = CSSImportRule::create(toStyleRuleImport(self), parentSheet);
      break;
    case Keyframes:
      rule = CSSKeyframesRule::create(toStyleRuleKeyframes(self), parentSheet);
      break;
    case Namespace:
      rule = CSSNamespaceRule::create(toStyleRuleNamespace(self), parentSheet);
      break;
    case Viewport:
      rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet);
      break;
    case Keyframe:
    case Charset:
      ASSERT_NOT_REACHED();
      return nullptr;
  }
  if (parentRule)
    rule->setParentRule(parentRule);
  return rule;
}
コード例 #22
0
CSSRule* ElementRuleCollector::findStyleRule(CSSRuleCollection* cssRules,
                                             StyleRule* styleRule) {
  if (!cssRules)
    return nullptr;
  CSSRule* result = 0;
  for (unsigned i = 0; i < cssRules->length() && !result; ++i) {
    CSSRule* cssRule = cssRules->item(i);
    CSSRule::Type cssRuleType = cssRule->type();
    if (cssRuleType == CSSRule::kStyleRule) {
      CSSStyleRule* cssStyleRule = toCSSStyleRule(cssRule);
      if (cssStyleRule->styleRule() == styleRule)
        result = cssRule;
    } else if (cssRuleType == CSSRule::kImportRule) {
      CSSImportRule* cssImportRule = toCSSImportRule(cssRule);
      result = findStyleRule(cssImportRule->styleSheet(), styleRule);
    } else {
      result = findStyleRule(cssRule->cssRules(), styleRule);
    }
  }
  return result;
}
コード例 #23
0
ファイル: CSSStyleSheet.cpp プロジェクト: rzr/Tizen_Crosswalk
void CSSStyleSheet::extraCSSOMWrapperIndices(Vector<unsigned>& indices)
{
    indices.grow(m_extraChildRuleCSSOMWrappers.size());

    for (unsigned i = 0; i < m_extraChildRuleCSSOMWrappers.size(); ++i) {
        CSSRule* cssRule = m_extraChildRuleCSSOMWrappers[i].get();
        ASSERT(cssRule->type() == CSSRule::STYLE_RULE);
        StyleRule* styleRule = toCSSStyleRule(cssRule)->styleRule();

        bool didFindIndex = false;
        for (unsigned j = 0; j < m_contents->ruleCount(); ++j) {
            if (m_contents->ruleAt(j) == styleRule) {
                didFindIndex = true;
                indices[i] = j;
                break;
            }
        }
        ASSERT(didFindIndex);
        if (!didFindIndex)
            indices[i] = 0;
    }
}
コード例 #24
0
void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KURL& url)
{
    StringBuilder cssText;
    for (unsigned i = 0; i < styleSheet->length(); ++i) {
        CSSRule* rule = styleSheet->item(i);
        String itemText = rule->cssText();
        if (!itemText.isEmpty()) {
            cssText.append(itemText);
            if (i < styleSheet->length() - 1)
                cssText.append("\n\n");
        }
        Document* document = styleSheet->ownerDocument();
        // Some rules have resources associated with them that we need to retrieve.
        if (rule->type() == CSSRule::IMPORT_RULE) {
            CSSImportRule* importRule = toCSSImportRule(rule);
            KURL importURL = document->completeURL(importRule->href());
            if (m_resourceURLs.contains(importURL))
                continue;
            serializeCSSStyleSheet(importRule->styleSheet(), importURL);
        } else if (rule->type() == CSSRule::FONT_FACE_RULE) {
            retrieveResourcesForProperties(toCSSFontFaceRule(rule)->styleRule()->properties(), document);
        } else if (rule->type() == CSSRule::STYLE_RULE) {
            retrieveResourcesForProperties(toCSSStyleRule(rule)->styleRule()->properties(), document);
        }
    }

    if (url.isValid() && !m_resourceURLs.contains(url)) {
        // FIXME: We should check whether a charset has been specified and if none was found add one.
        WTF::TextEncoding textEncoding(styleSheet->contents()->charset());
        ASSERT(textEncoding.isValid());
        String textString = cssText.toString();
        CString text = textEncoding.normalizeAndEncode(textString, WTF::EntitiesForUnencodables);
        m_resources->append(SerializedResource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
        m_resourceURLs.add(url);
    }
}
コード例 #25
0
void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KURL& url)
{
    StringBuilder cssText;
    for (unsigned i = 0; i < styleSheet->length(); ++i) {
        CSSRule* rule = styleSheet->item(i);
        String itemText = rule->cssText();
        if (!itemText.isEmpty()) {
            cssText.append(itemText);
            if (i < styleSheet->length() - 1)
                cssText.append("\n\n");
        }
        Document* document = styleSheet->findDocument();
        // Some rules have resources associated with them that we need to retrieve.
        if (rule->isImportRule()) {
            CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);            
            KURL importURL = document->completeURL(importRule->href());
            if (m_resourceURLs.contains(importURL))
                continue;
            serializeCSSStyleSheet(importRule->styleSheet(), importURL);
        } else if (rule->isFontFaceRule()) {
            // FIXME: Add support for font face rule. It is not clear to me at this point if the actual otf/eot file can
            // be retrieved from the CSSFontFaceRule object.
        } else if (rule->isStyleRule())
            retrieveResourcesForCSSRule(static_cast<CSSStyleRule*>(rule), document);
    }

    if (url.isValid() && !m_resourceURLs.contains(url)) {
        // FIXME: We should check whether a charset has been specified and if none was found add one.
        TextEncoding textEncoding(styleSheet->charset());
        ASSERT(textEncoding.isValid());
        String textString = cssText.toString();
        CString text = textEncoding.encode(textString.characters(), textString.length(), EntitiesForUnencodables);
        m_resources->append(Resource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
        m_resourceURLs.add(url);
    }
}
コード例 #26
0
WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::item(unsigned index)
{
    CSSRule* rule = m_lstCSSRules->item(index);
    ASSERT(rule->isKeyframeRule());
    return static_cast<WebKitCSSKeyframeRule*>(rule);
}
コード例 #27
0
const WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::item(unsigned index) const
{
    CSSRule* rule = m_lstCSSRules.get()->item(index);
    return (rule && rule->isKeyframeRule()) ? static_cast<const WebKitCSSKeyframeRule*>(rule) : 0;
}
コード例 #28
0
ファイル: CSSStyleSheet.cpp プロジェクト: sysrqb/chromium-src
void CSSStyleSheet::append(PassRefPtr<CSSRule> child)
{
    CSSRule* c = child.get();
    m_children.append(child);
    c->insertedIntoParent();
}
コード例 #29
0
static v8::Handle<v8::Value> cssTextAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    CSSRule* imp = V8CSSRule::toNative(info.Holder());
    return v8StringOrNull(imp->cssText(), info.GetIsolate());
}
コード例 #30
0
static v8::Handle<v8::Value> typeAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    CSSRule* imp = V8CSSRule::toNative(info.Holder());
    return v8Integer(imp->type(), info.GetIsolate());
}