bool HTMLStyleElement::disabled() const { StyleSheet* styleSheet = sheet(); if (!styleSheet) return false; return styleSheet->disabled(); }
bool StyleSheetCandidate::canBeActivated(const String& currentPreferrableName) const { StyleSheet* sheet = this->sheet(); if (!sheet || sheet->disabled() || !sheet->isCSSStyleSheet()) return false; const AtomicString& title = this->title(); if (!isEnabledViaScript() && !title.isEmpty() && title != currentPreferrableName) return false; if (isAlternate() && title.isEmpty()) return false; return true; }
void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine* collections, Vector<RefPtr<StyleSheet> >& styleSheets, Vector<RefPtr<CSSStyleSheet> >& activeSheets) { if (document()->settings() && !document()->settings()->authorAndUserStylesEnabled()) return; DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin(); DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end(); for (DocumentOrderedList::iterator it = begin; it != end; ++it) { Node* node = *it; StyleSheet* sheet = 0; CSSStyleSheet* activeSheet = 0; if (!node->isHTMLElement() || !node->hasTagName(styleTag)) continue; Element* element = toElement(node); AtomicString title = element->getAttribute(titleAttr); bool enabledViaScript = false; sheet = toHTMLStyleElement(node)->sheet(); if (sheet && !sheet->disabled() && sheet->isCSSStyleSheet()) activeSheet = static_cast<CSSStyleSheet*>(sheet); // FIXME: clarify how PREFERRED or ALTERNATE works in shadow trees. // Should we set preferred/selected stylesheets name in shadow trees and // use the name in document? AtomicString rel = element->getAttribute(relAttr); if (!enabledViaScript && sheet && !title.isEmpty()) { if (collections->preferredStylesheetSetName().isEmpty()) { if (element->hasLocalName(styleTag) || !rel.contains("alternate")) { collections->setPreferredStylesheetSetName(title); collections->setSelectedStylesheetSetName(title); } } if (title != collections->preferredStylesheetSetName()) activeSheet = 0; } if (rel.contains("alternate") && title.isEmpty()) activeSheet = 0; if (sheet) styleSheets.append(sheet); if (activeSheet) activeSheets.append(activeSheet); } }
void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine* engine, StyleSheetCollection& collection) { DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin(); DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end(); for (DocumentOrderedList::iterator it = begin; it != end; ++it) { Node* node = *it; StyleSheet* sheet = 0; CSSStyleSheet* activeSheet = 0; if (!isHTMLStyleElement(*node)) continue; HTMLStyleElement* element = toHTMLStyleElement(node); const AtomicString& title = element->fastGetAttribute(titleAttr); bool enabledViaScript = false; sheet = element->sheet(); if (sheet && !sheet->disabled() && sheet->isCSSStyleSheet()) activeSheet = toCSSStyleSheet(sheet); // FIXME: clarify how PREFERRED or ALTERNATE works in shadow trees. // Should we set preferred/selected stylesheets name in shadow trees and // use the name in document? if (!enabledViaScript && sheet && !title.isEmpty()) { if (engine->preferredStylesheetSetName().isEmpty()) { engine->setPreferredStylesheetSetName(title); engine->setSelectedStylesheetSetName(title); } if (title != engine->preferredStylesheetSetName()) activeSheet = 0; } const AtomicString& rel = element->fastGetAttribute(relAttr); if (rel.contains("alternate") && title.isEmpty()) activeSheet = 0; if (sheet) collection.appendSheetForList(sheet); if (activeSheet) collection.appendActiveStyleSheet(activeSheet); } }
JSValue* JSStyleSheet::getValueProperty(ExecState* exec, int token) const { switch (token) { case TypeAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return jsStringOrNull(exec, imp->type()); } case DisabledAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return jsBoolean(imp->disabled()); } case OwnerNodeAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return toJS(exec, WTF::getPtr(imp->ownerNode())); } case ParentStyleSheetAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return toJS(exec, WTF::getPtr(imp->parentStyleSheet())); } case HrefAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return jsStringOrNull(exec, imp->href()); } case TitleAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return jsStringOrNull(exec, imp->title()); } case MediaAttrNum: { StyleSheet* imp = static_cast<StyleSheet*>(impl()); return toJS(exec, WTF::getPtr(imp->media())); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
static v8::Handle<v8::Value> disabledAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.StyleSheet.disabled._get"); StyleSheet* imp = V8StyleSheet::toNative(info.Holder()); return v8Boolean(imp->disabled()); }
static v8::Handle<v8::Value> disabledAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { StyleSheet* imp = V8StyleSheet::toNative(info.Holder()); return v8Boolean(imp->disabled(), info.GetIsolate()); }