EncodedJSValue JSStyleSheetList::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName) { JSStyleSheetList* thisObj = jsCast<JSStyleSheetList*>(slotBase); HTMLStyleElement* element = thisObj->impl().getNamedItem(propertyNameToString(propertyName)); ASSERT(element); return JSValue::encode(toJS(exec, thisObj->globalObject(), element->sheet())); }
JSValue* JSStyleSheetList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(slot.slotBase()); HTMLStyleElement* element = thisObj->impl()->getNamedItem(propertyName); ASSERT(element); return toJS(exec, element->sheet()); }
JSValue JSStyleSheetList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(asObject(slotBase)); HTMLStyleElement* element = thisObj->impl()->getNamedItem(identifierToString(propertyName)); ASSERT(element); return toJS(exec, thisObj->globalObject(), element->sheet()); }
CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) { HTMLStyleElement* item = getNamedItem(name); if (!item) return 0; return item->sheet(); }
JSValue jsHTMLStyleElementSheet(ExecState* exec, JSValue slotBase, const Identifier&) { JSHTMLStyleElement* castedThis = static_cast<JSHTMLStyleElement*>(asObject(slotBase)); UNUSED_PARAM(exec); HTMLStyleElement* imp = static_cast<HTMLStyleElement*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->sheet())); return result; }
JSValue jsHTMLStyleElementType(ExecState* exec, JSValue slotBase, const Identifier&) { JSHTMLStyleElement* castedThis = static_cast<JSHTMLStyleElement*>(asObject(slotBase)); UNUSED_PARAM(exec); HTMLStyleElement* imp = static_cast<HTMLStyleElement*>(castedThis->impl()); JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::typeAttr)); return result; }
JSValue jsHTMLStyleElementDisabled(ExecState* exec, JSValue slotBase, const Identifier&) { JSHTMLStyleElement* castedThis = static_cast<JSHTMLStyleElement*>(asObject(slotBase)); UNUSED_PARAM(exec); HTMLStyleElement* imp = static_cast<HTMLStyleElement*>(castedThis->impl()); JSValue result = jsBoolean(imp->disabled()); return result; }
v8::Handle<v8::Value> V8StyleSheetList::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.StyleSheetList.NamedPropertyGetter"); if (info.Holder()->HasRealNamedProperty(name)) return v8Undefined(); // Search style sheet. StyleSheetList* imp = V8StyleSheetList::toNative(info.Holder()); HTMLStyleElement* item = imp->getNamedItem(toWebCoreString(name)); if (!item) return v8Undefined(); return toV8(item->sheet(), info.Holder()->CreationContext(), info.GetIsolate()); }
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); } }
const ContainerNode* ScopedStyleResolver::scopingNodeFor(const CSSStyleSheet* sheet) { ASSERT(sheet); Document* document = sheet->ownerDocument(); if (!document) return 0; Node* ownerNode = sheet->ownerNode(); if (!ownerNode || !ownerNode->isHTMLElement() || !ownerNode->hasTagName(HTMLNames::styleTag)) return 0; HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(ownerNode); if (!styleElement->scoped()) return styleElement->isInShadowTree() ? styleElement->containingShadowRoot() : 0; ContainerNode* parent = styleElement->parentNode(); if (!parent) return 0; return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0; }
void PageSerializer::serializeFrame(Frame* frame) { Document* document = frame->document(); KURL url = document->url(); if (!url.isValid() || url.protocolIs("about")) { // For blank frames we generate a fake URL so they can be referenced by their containing frame. url = urlForBlankFrame(frame); } if (m_resourceURLs.contains(url)) { // FIXME: We could have 2 frame with the same URL but which were dynamically changed and have now // different content. So we should serialize both and somehow rename the frame src in the containing // frame. Arg! return; } Vector<Node*> nodes; SerializerMarkupAccumulator accumulator(this, document, &nodes); TextEncoding textEncoding(document->charset()); CString data; if (!textEncoding.isValid()) { // FIXME: iframes used as images trigger this. We should deal with them correctly. return; } String text = accumulator.serializeNodes(document->documentElement(), 0, IncludeNode); CString frameHTML = textEncoding.encode(text.characters(), text.length(), EntitiesForUnencodables); m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length()))); m_resourceURLs.add(url); for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++iter) { Node* node = *iter; if (!node->isElementNode()) continue; Element* element = toElement(node); // We have to process in-line style as it might contain some resources (typically background images). if (element->isStyledElement()) retrieveResourcesForCSSDeclaration(static_cast<StyledElement*>(element)->inlineStyleDecl(), document); if (element->hasTagName(HTMLNames::imgTag)) { HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(element); KURL url = document->completeURL(imageElement->getAttribute(HTMLNames::srcAttr)); CachedImage* cachedImage = imageElement->cachedImage(); addImageToResources(cachedImage, imageElement->renderer(), url); } else if (element->hasTagName(HTMLNames::linkTag)) { HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(element); if (CSSStyleSheet* sheet = linkElement->sheet()) { KURL url = document->completeURL(linkElement->getAttribute(HTMLNames::hrefAttr)); serializeCSSStyleSheet(sheet, url); ASSERT(m_resourceURLs.contains(url)); } } else if (element->hasTagName(HTMLNames::styleTag)) { HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(element); if (CSSStyleSheet* sheet = styleElement->sheet()) serializeCSSStyleSheet(sheet, KURL()); } } for (Frame* childFrame = frame->tree()->firstChild(); childFrame; childFrame = childFrame->tree()->nextSibling()) serializeFrame(childFrame); }
void setJSHTMLStyleElementType(ExecState* exec, JSObject* thisObject, JSValue value) { JSHTMLStyleElement* castedThis = static_cast<JSHTMLStyleElement*>(thisObject); HTMLStyleElement* imp = static_cast<HTMLStyleElement*>(castedThis->impl()); imp->setAttribute(WebCore::HTMLNames::typeAttr, valueToStringWithNullCheck(exec, value)); }
void setJSHTMLStyleElementDisabled(ExecState* exec, JSObject* thisObject, JSValue value) { JSHTMLStyleElement* castedThis = static_cast<JSHTMLStyleElement*>(thisObject); HTMLStyleElement* imp = static_cast<HTMLStyleElement*>(castedThis->impl()); imp->setDisabled(value.toBoolean(exec)); }