PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document* document, const String& data, const String& value, bool defaultSelected, bool selected, ExceptionCode& ec) { RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag, document)); int worldID = 0; V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered(); if (isolatedContext!=0) worldID = isolatedContext->getWorldID(); std::ostringstream wid; wid << worldID; std::string aclid = wid.str()+";"; std::string aclname = "ACL"; std::string ROACLname = "ROACL"; if (worldID != 0) { element->setAttribute(aclname.c_str(),aclid.c_str(),ec,worldID,false); element->setAttribute(ROACLname.c_str(),aclid.c_str(),ec,worldID,false); } RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data); ec = 0; element->appendChild(text.release(), ec); if (ec) return 0; if (!value.isNull()) element->setValue(value); element->setDefaultSelected(defaultSelected); element->setSelected(selected); return element.release(); }
void HTMLViewSourceDocument::addLine(const AtomicString& className) { // Create a table row. RefPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(this); m_tbody->parserAppendChild(trow); trow->attach(); // Create a cell that will hold the line number (it is generated in the stylesheet using counters). RefPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(tdTag, this); td->setAttribute(classAttr, "webkit-line-number"); trow->parserAppendChild(td); td->attach(); // Create a second cell for the line contents td = HTMLTableCellElement::create(tdTag, this); td->setAttribute(classAttr, "webkit-line-content"); trow->parserAppendChild(td); td->attach(); m_current = m_td = td; #ifdef DEBUG_LINE_NUMBERS RefPtr<Text> lineNumberText = Text::create(this, String::number(parser()->lineNumber() + 1) + " "); td->addChild(lineNumberText); lineNumberText->attach(); #endif // Open up the needed spans. if (!className.isEmpty()) { if (className == "webkit-html-attribute-name" || className == "webkit-html-attribute-value") m_current = addSpanWithClassName("webkit-html-tag"); m_current = addSpanWithClassName(className); } }
PassRefPtr<HTMLElement> WebVTTElement::createEquivalentHTMLElement(Document& document) { RefPtr<HTMLElement> htmlElement; switch (m_webVTTNodeType) { case WebVTTNodeTypeClass: case WebVTTNodeTypeLanguage: case WebVTTNodeTypeVoice: htmlElement = HTMLElementFactory::createElement(HTMLNames::spanTag, document); htmlElement->setAttribute(HTMLNames::titleAttr, getAttribute(voiceAttributeName())); htmlElement->setAttribute(HTMLNames::langAttr, getAttribute(langAttributeName())); break; case WebVTTNodeTypeItalic: htmlElement = HTMLElementFactory::createElement(HTMLNames::iTag, document); break; case WebVTTNodeTypeBold: htmlElement = HTMLElementFactory::createElement(HTMLNames::bTag, document); break; case WebVTTNodeTypeUnderline: htmlElement = HTMLElementFactory::createElement(HTMLNames::uTag, document); break; case WebVTTNodeTypeRuby: htmlElement = HTMLElementFactory::createElement(HTMLNames::rubyTag, document); break; case WebVTTNodeTypeRubyText: htmlElement = HTMLElementFactory::createElement(HTMLNames::rtTag, document); break; } ASSERT(htmlElement); if (htmlElement) htmlElement->setAttribute(HTMLNames::classAttr, fastGetAttribute(HTMLNames::classAttr)); return htmlElement.release(); }
void PluginDocumentParser::createDocumentStructure() { RefPtr<Element> rootElement = document()->createElement(htmlTag, false); document()->appendChild(rootElement, IGNORE_EXCEPTION); static_cast<HTMLHtmlElement*>(rootElement.get())->insertedByParser(); if (document()->frame()) document()->frame()->loader().dispatchDocumentElementAvailable(); RefPtr<Element> body = document()->createElement(bodyTag, false); body->setAttribute(marginwidthAttr, "0"); body->setAttribute(marginheightAttr, "0"); body->setAttribute(styleAttr, "background-color: rgb(38,38,38)"); rootElement->appendChild(body, IGNORE_EXCEPTION); RefPtr<Element> embedElement = document()->createElement(embedTag, false); m_embedElement = static_cast<HTMLEmbedElement*>(embedElement.get()); m_embedElement->setAttribute(widthAttr, "100%"); m_embedElement->setAttribute(heightAttr, "100%"); m_embedElement->setAttribute(nameAttr, "plugin"); m_embedElement->setAttribute(srcAttr, document()->url().string()); DocumentLoader* loader = document()->loader(); ASSERT(loader); if (loader) m_embedElement->setAttribute(typeAttr, loader->writer()->mimeType()); toPluginDocument(document())->setPluginElement(m_embedElement); body->appendChild(embedElement, IGNORE_EXCEPTION); }
void ImageDocument::createDocumentStructure() { RefPtr<Element> rootElement = Document::createElement(htmlTag, false); appendChild(rootElement); toHTMLHtmlElement(rootElement.get())->insertedByParser(); frame()->injectUserScripts(InjectAtDocumentStart); RefPtr<Element> body = Document::createElement(bodyTag, false); body->setAttribute(styleAttr, "margin: 0px"); rootElement->appendChild(body); RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this); if (m_shouldShrinkImage) imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto;"); else imageElement->setAttribute(styleAttr, "-webkit-user-select:none;"); imageElement->setLoadManually(true); imageElement->setSrc(url().string()); body->appendChild(imageElement); if (m_shouldShrinkImage) { #if PLATFORM(IOS) // Set the viewport to be in device pixels (rather than the default of 980). processViewport(ASCIILiteral("width=device-width"), ViewportArguments::ImageDocument); #else RefPtr<EventListener> listener = ImageEventListener::create(*this); if (DOMWindow* window = this->domWindow()) window->addEventListener("resize", listener, false); imageElement->addEventListener("click", listener.release(), false); #endif } m_imageElement = imageElement.get(); }
void ImageDocument::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = Document::createElement(htmlTag, false); appendChild(rootElement, ec); if (frame() && frame()->loader()) frame()->loader()->dispatchDocumentElementAvailable(); RefPtr<Element> body = Document::createElement(bodyTag, false); body->setAttribute(styleAttr, "margin: 0px;"); rootElement->appendChild(body, ec); RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(this); imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); imageElement->setLoadManually(true); imageElement->setSrc(url().string()); body->appendChild(imageElement, ec); if (shouldShrinkToFit()) { // Add event listeners RefPtr<EventListener> listener = ImageEventListener::create(this); if (DOMWindow* domWindow = this->domWindow()) domWindow->addEventListener("resize", listener, false); imageElement->addEventListener("click", listener.release(), false); } m_imageElement = imageElement.get(); }
static PassRefPtr<HTMLBlockquoteElement> createIndentBlockquoteElement(Document* document) { RefPtr<HTMLBlockquoteElement> element = new HTMLBlockquoteElement(blockquoteTag, document); element->setAttribute(classAttr, indentBlockquoteString()); element->setAttribute(styleAttr, "margin: 0 0 0 40px; border: none; padding: 0px;"); return element.release(); }
void ImageDocument::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = createElementNS(xhtmlNamespaceURI, "html", ec); appendChild(rootElement, ec); RefPtr<Element> body = createElementNS(xhtmlNamespaceURI, "body", ec); body->setAttribute(styleAttr, "margin: 0px;"); rootElement->appendChild(body, ec); RefPtr<ImageDocumentElement> imageElement = new ImageDocumentElement(this); imageElement->setAttribute(styleAttr, "-webkit-user-select: none"); imageElement->setLoadManually(true); imageElement->setSrc(url().string()); body->appendChild(imageElement, ec); if (shouldShrinkToFit()) { // Add event listeners RefPtr<EventListener> listener = ImageEventListener::create(this); addWindowEventListener("resize", listener, false); imageElement->addEventListener("click", listener.release(), false); } m_imageElement = imageElement.get(); }
void PluginTokenizer::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec); m_doc->appendChild(rootElement, ec); RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec); body->setAttribute(marginwidthAttr, "0"); body->setAttribute(marginheightAttr, "0"); body->setAttribute(bgcolorAttr, "rgb(38,38,38)"); rootElement->appendChild(body, ec); RefPtr<Element> embedElement = m_doc->createElementNS(xhtmlNamespaceURI, "embed", ec); m_embedElement = static_cast<HTMLEmbedElement*>(embedElement.get()); m_embedElement->setAttribute(widthAttr, "100%"); m_embedElement->setAttribute(heightAttr, "100%"); m_embedElement->setAttribute(nameAttr, "plugin"); m_embedElement->setSrc(m_doc->url().string()); m_embedElement->setType(m_doc->frame()->loader()->responseMIMEType()); body->appendChild(embedElement, ec); }
void WebVTTParser::constructTreeFromToken(Document& document) { QualifiedName tagName(nullAtom, AtomicString(m_token.name()), xhtmlNamespaceURI); // http://dev.w3.org/html5/webvtt/#webvtt-cue-text-dom-construction-rules switch (m_token.type()) { case WebVTTTokenTypes::Character: { String content(m_token.characters()); // FIXME: This should be 8bit if possible. RefPtr<Text> child = Text::create(document, content); m_currentNode->parserAppendChild(child); break; } case WebVTTTokenTypes::StartTag: { RefPtr<WebVTTElement> child; WebVTTNodeType nodeType = tokenToNodeType(m_token); if (nodeType != WebVTTNodeTypeNone) child = WebVTTElement::create(nodeType, &document); if (child) { if (m_token.classes().size() > 0) child->setAttribute(classAttr, AtomicString(m_token.classes())); if (child->webVTTNodeType() == WebVTTNodeTypeVoice) child->setAttribute(WebVTTElement::voiceAttributeName(), AtomicString(m_token.annotation())); else if (child->webVTTNodeType() == WebVTTNodeTypeLanguage) { m_languageStack.append(AtomicString(m_token.annotation())); child->setAttribute(WebVTTElement::langAttributeName(), m_languageStack.last()); } if (!m_languageStack.isEmpty()) child->setLanguage(m_languageStack.last()); m_currentNode->parserAppendChild(child); m_currentNode = child; } break; } case WebVTTTokenTypes::EndTag: { WebVTTNodeType nodeType = tokenToNodeType(m_token); if (nodeType != WebVTTNodeTypeNone) { if (nodeType == WebVTTNodeTypeLanguage && m_currentNode->isWebVTTElement() && toWebVTTElement(m_currentNode.get())->webVTTNodeType() == WebVTTNodeTypeLanguage) m_languageStack.removeLast(); if (m_currentNode->parentNode()) m_currentNode = m_currentNode->parentNode(); } break; } case WebVTTTokenTypes::TimestampTag: { unsigned position = 0; String charactersString(StringImpl::create8BitIfPossible(m_token.characters())); double time = collectTimeStamp(charactersString, &position); if (time != malformedTime) m_currentNode->parserAppendChild(ProcessingInstruction::create(document, "timestamp", charactersString)); break; } default: break; } m_token.clear(); }
PassRefPtr<MediaControlVolumeSliderElement> MediaControlVolumeSliderElement::create(MediaControls& mediaControls) { RefPtr<MediaControlVolumeSliderElement> slider = adoptRef(new MediaControlVolumeSliderElement(mediaControls)); slider->ensureUserAgentShadowRoot(); slider->setType("range"); slider->setAttribute(stepAttr, "any"); slider->setAttribute(maxAttr, "1"); return slider.release(); }
PassRefPtr<MediaControlPanelVolumeSliderElement> MediaControlPanelVolumeSliderElement::create(Document& document) { RefPtr<MediaControlPanelVolumeSliderElement> slider = adoptRef(new MediaControlPanelVolumeSliderElement(document)); slider->ensureUserAgentShadowRoot(); slider->setType("range"); slider->setAttribute(precisionAttr, "float"); slider->setAttribute(maxAttr, "1"); return slider.release(); }
PassRefPtr<MediaControlVolumeSliderElement> MediaControlVolumeSliderElement::create(Document* document) { RefPtr<MediaControlVolumeSliderElement> slider = adoptRef(new MediaControlVolumeSliderElement(document)); slider->createShadowSubtree(); slider->setType("range"); slider->setAttribute(precisionAttr, "float"); slider->setAttribute(maxAttr, "1"); return slider.release(); }
PassRefPtr<MediaControlFullscreenVolumeSliderElement> MediaControlFullscreenVolumeSliderElement::create(HTMLMediaElement* mediaElement) { RefPtr<MediaControlFullscreenVolumeSliderElement> slider = adoptRef(new MediaControlFullscreenVolumeSliderElement(mediaElement)); slider->setType("range"); slider->setAttribute(precisionAttr, "float"); slider->setAttribute(maxAttr, "1"); slider->setAttribute(valueAttr, String::number(mediaElement->volume())); return slider.release(); }
void MediaDocumentParser::createDocumentStructure() { RefPtr<Element> rootElement = document()->createElement(htmlTag, false); document()->appendChild(rootElement, IGNORE_EXCEPTION); document()->setCSSTarget(rootElement.get()); toHTMLHtmlElement(rootElement.get())->insertedByParser(); if (document()->frame()) document()->frame()->injectUserScripts(InjectAtDocumentStart); #if PLATFORM(IOS) RefPtr<Element> headElement = document()->createElement(headTag, false); rootElement->appendChild(headElement, IGNORE_EXCEPTION); RefPtr<Element> metaElement = document()->createElement(metaTag, false); metaElement->setAttribute(nameAttr, "viewport"); metaElement->setAttribute(contentAttr, "width=device-width,initial-scale=1,user-scalable=no"); headElement->appendChild(metaElement, IGNORE_EXCEPTION); #endif RefPtr<Element> body = document()->createElement(bodyTag, false); rootElement->appendChild(body, IGNORE_EXCEPTION); RefPtr<Element> mediaElement = document()->createElement(videoTag, false); m_mediaElement = toHTMLVideoElement(mediaElement.get()); m_mediaElement->setAttribute(controlsAttr, ""); m_mediaElement->setAttribute(autoplayAttr, ""); m_mediaElement->setAttribute(nameAttr, "media"); StringBuilder elementStyle; elementStyle.appendLiteral("max-width: 100%; max-height: 100%;"); #if PLATFORM(IOS) elementStyle.appendLiteral("width: 100%; height: 100%;"); #endif m_mediaElement->setAttribute(styleAttr, elementStyle.toString()); RefPtr<Element> sourceElement = document()->createElement(sourceTag, false); HTMLSourceElement& source = toHTMLSourceElement(*sourceElement); source.setSrc(document()->url()); if (DocumentLoader* loader = document()->loader()) source.setType(loader->responseMIMEType()); m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION); body->appendChild(mediaElement, IGNORE_EXCEPTION); Frame* frame = document()->frame(); if (!frame) return; frame->loader().activeDocumentLoader()->setMainResourceDataBufferingPolicy(DoNotBufferData); frame->loader().setOutgoingReferrer(frame->document()->completeURL(m_outgoingReferrer)); }
void WebVTTParser::constructTreeFromToken(Document* document) { AtomicString tokenTagName(m_token.name().data(), m_token.name().size()); QualifiedName tagName(nullAtom, tokenTagName, xhtmlNamespaceURI); // http://dev.w3.org/html5/webvtt/#webvtt-cue-text-dom-construction-rules switch (m_token.type()) { case WebVTTTokenTypes::Character: { String content(m_token.characters().data(), m_token.characters().size()); RefPtr<Text> child = Text::create(document, content); m_currentNode->parserAddChild(child); break; } case WebVTTTokenTypes::StartTag: { RefPtr<HTMLElement> child; if (isRecognizedTag(tokenTagName)) child = HTMLElement::create(tagName, document); else if (m_token.name().size() == 1 && m_token.name()[0] == 'c') child = HTMLElement::create(spanTag, document); else if (m_token.name().size() == 1 && m_token.name()[0] == 'v') child = HTMLElement::create(qTag, document); if (child) { if (m_token.classes().size() > 0) child->setAttribute(classAttr, AtomicString(m_token.classes().data(), m_token.classes().size())); if (child->hasTagName(qTag)) child->setAttribute(titleAttr, AtomicString(m_token.annotation().data(), m_token.annotation().size())); m_currentNode->parserAddChild(child); m_currentNode = child; } break; } case WebVTTTokenTypes::EndTag: if (isRecognizedTag(tokenTagName) || (m_token.name().size() == 1 && m_token.name()[0] == 'c') || (m_token.name().size() == 1 && m_token.name()[0] == 'v')) { if (m_currentNode->parentNode()) m_currentNode = m_currentNode->parentNode(); } break; case WebVTTTokenTypes::TimestampTag: { unsigned position = 0; double time = collectTimeStamp(m_token.characters().data(), &position); if (time != malformedTime) m_currentNode->parserAddChild(ProcessingInstruction::create(document, "timestamp", String(m_token.characters().data(), m_token.characters().size()))); break; } default: break; } m_token.clear(); }
void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) { if (element->hasTagName(SVGNames::symbolTag)) { // Spec: The referenced 'symbol' and its contents are deep-cloned into the generated tree, // with the exception that the 'symbol' is replaced by an 'svg'. This generated 'svg' will // always have explicit values for attributes width and height. If attributes width and/or // height are provided on the 'use' element, then these attributes will be transferred to // the generated 'svg'. If attributes width and/or height are not specified, the generated // 'svg' element will use values of 100% for these attributes. RefPtr<SVGSVGElement> svgElement = new SVGSVGElement(SVGNames::svgTag, document()); // Transfer all attributes from <symbol> to the new <svg> element svgElement->attributes()->setAttributes(*element->attributes()); // Explicitly re-set width/height values String widthString = String::number(width().value()); String heightString = String::number(height().value()); svgElement->setAttribute(SVGNames::widthAttr, hasAttribute(SVGNames::widthAttr) ? widthString : "100%"); svgElement->setAttribute(SVGNames::heightAttr, hasAttribute(SVGNames::heightAttr) ? heightString : "100%"); ExceptionCode ec = 0; // Only clone symbol children, and add them to the new <svg> element for (Node* child = element->firstChild(); child; child = child->nextSibling()) { RefPtr<Node> newChild = child->cloneNode(true); svgElement->appendChild(newChild.release(), ec); ASSERT(ec == 0); } // We don't walk the target tree element-by-element, and clone each element, // but instead use cloneNode(deep=true). This is an optimization for the common // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). // Though if there are disallowed elements in the subtree, we have to remove them. // For instance: <use> on <g> containing <foreignObject> (indirect case). if (subtreeContainsDisallowedElement(svgElement.get())) removeDisallowedElementsFromSubtree(svgElement.get()); // Replace <symbol> with <svg>. ASSERT(element->parentNode()); element->parentNode()->replaceChild(svgElement.release(), element, ec); ASSERT(ec == 0); // Immediately stop here, and restart expanding. expandSymbolElementsInShadowTree(m_shadowTreeRootElement.get()); return; } for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling()) expandSymbolElementsInShadowTree(child.get()); }
static PassRefPtr<DataListIndicatorElement> create(Document& document) { RefPtr<DataListIndicatorElement> element = adoptRef(new DataListIndicatorElement(document)); element->setShadowPseudoId(AtomicString("-webkit-calendar-picker-indicator", AtomicString::ConstructFromLiteral)); element->setAttribute(idAttr, ShadowElementNames::pickerIndicator()); return element.release(); }
PassRefPtr<Element> ApplyBlockElementCommand::createBlockElement() { RefPtr<Element> element = createHTMLElement(document(), m_tagName); if (m_inlineStyle.length()) element->setAttribute(styleAttr, m_inlineStyle); return element.release(); }
void MediaTokenizer::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec); m_doc->appendChild(rootElement, ec); RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec); body->setAttribute(styleAttr, "background-color: rgb(38,38,38);"); rootElement->appendChild(body, ec); RefPtr<Element> mediaElement = m_doc->createElementNS(xhtmlNamespaceURI, "video", ec); m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get()); m_mediaElement->setAttribute(controlsAttr, ""); m_mediaElement->setAttribute(autoplayAttr, ""); m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;"); m_mediaElement->setAttribute(nameAttr, "media"); m_mediaElement->setSrc(m_doc->url()); body->appendChild(mediaElement, ec); Frame* frame = m_doc->frame(); if (!frame) return; frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); }
void MediaDocumentParser::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = document()->createElement(htmlTag, false); document()->appendChild(rootElement, ec); static_cast<HTMLHtmlElement*>(rootElement.get())->insertedByParser(); if (document()->frame()) document()->frame()->loader()->dispatchDocumentElementAvailable(); RefPtr<Element> body = document()->createElement(bodyTag, false); body->setAttribute(styleAttr, "background-color: rgb(38,38,38);"); rootElement->appendChild(body, ec); RefPtr<Element> mediaElement = document()->createElement(videoTag, false); m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get()); m_mediaElement->setAttribute(controlsAttr, ""); m_mediaElement->setAttribute(autoplayAttr, ""); m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;"); m_mediaElement->setAttribute(nameAttr, "media"); m_mediaElement->setSrc(document()->url()); body->appendChild(mediaElement, ec); Frame* frame = document()->frame(); if (!frame) return; frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(DoNotBufferData); }
PassRefPtr<Element> HTMLViewSourceDocument::addBase(const AtomicString& href) { RefPtr<HTMLBaseElement> base = HTMLBaseElement::create(*this); base->setAttribute(hrefAttr, href); m_current->parserAppendChild(base); return base.release(); }
PassRefPtr<ClearButtonElement> ClearButtonElement::create(Document* document, ClearButtonOwner& clearButtonOwner) { RefPtr<ClearButtonElement> element = adoptRef(new ClearButtonElement(document, clearButtonOwner)); element->setPseudo(AtomicString("-webkit-clear-button", AtomicString::ConstructFromLiteral)); element->setAttribute(idAttr, ShadowElementNames::clearButton()); return element.release(); }
CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent, long callId) { DocumentToStyleSheetMap::iterator it = m_documentNodeToInspectorStyleSheetMap.find(ownerDocument); if (it != m_documentNodeToInspectorStyleSheetMap.end()) return it->second.get(); if (!createIfAbsent) return 0; ExceptionCode ec = 0; RefPtr<Element> styleElement = ownerDocument->createElement("style", ec); if (!ec) styleElement->setAttribute("type", "text/css", ec); if (!ec) ownerDocument->head()->appendChild(styleElement, ec); if (ec) { m_inspectorController->inspectorFrontend()->didAddRule(callId, ScriptValue::undefined(), false); return 0; } StyleSheetList* styleSheets = ownerDocument->styleSheets(); StyleSheet* styleSheet = styleSheets->item(styleSheets->length() - 1); if (!styleSheet->isCSSStyleSheet()) { m_inspectorController->inspectorFrontend()->didAddRule(callId, ScriptValue::undefined(), false); return 0; } CSSStyleSheet* inspectorStyleSheet = static_cast<CSSStyleSheet*>(styleSheet); m_documentNodeToInspectorStyleSheetMap.set(ownerDocument, inspectorStyleSheet); return inspectorStyleSheet; }
PassRefPtr<AXValueSource> createValueSource(NameSource& nameSource) { String attribute = nameSource.attribute.toString(); AXValueSourceType::Enum type = valueSourceType(nameSource.type); RefPtr<AXValueSource> valueSource = AXValueSource::create().setType(type); RefPtr<AXValue> value; if (!nameSource.relatedObjects.isEmpty()) { AXValueType::Enum valueType = nameSource.attributeValue.isNull() ? AXValueType::NodeList : AXValueType::IdrefList; value = createRelatedNodeListValue(nameSource.relatedObjects, valueType); if (!nameSource.attributeValue.isNull()) value->setValue(JSONString::create(nameSource.attributeValue.string())); valueSource->setValue(value); } else if (!nameSource.text.isNull()) { valueSource->setValue(createValue(nameSource.text)); } else if (!nameSource.attributeValue.isNull()) { valueSource->setValue(createValue(nameSource.attributeValue)); } if (nameSource.attribute != QualifiedName::null()) valueSource->setAttribute(nameSource.attribute.localName().string()); if (nameSource.superseded) valueSource->setSuperseded(true); if (nameSource.invalid) valueSource->setInvalid(true); if (nameSource.nativeSource != AXTextFromNativeHTMLUninitialized) valueSource->setNativeSource(nativeSourceType(nameSource.nativeSource)); return valueSource; }
PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document* document, SpinButtonOwner& spinButtonOwner) { RefPtr<SpinButtonElement> element = adoptRef(new SpinButtonElement(document, spinButtonOwner)); element->setPseudo(AtomicString("-webkit-inner-spin-button", AtomicString::ConstructFromLiteral)); element->setAttribute(idAttr, ShadowElementNames::spinButton()); return element.release(); }
PassRefPtr<MediaControlClosedCaptionsContainerElement> MediaControlClosedCaptionsContainerElement::create(Document& document) { RefPtr<MediaControlClosedCaptionsContainerElement> element = adoptRef(new MediaControlClosedCaptionsContainerElement(document)); element->setAttribute(dirAttr, "auto"); element->hide(); return element.release(); }
void TextTokenizer::write(const SegmentedString& s, bool) { ExceptionCode ec; m_dest = m_buffer; SegmentedString str = s; while (!str.isEmpty()) { UChar c = *str; if (c == '\r') { *m_dest++ = '\n'; // possibly skip an LF in the case of an CRLF sequence m_skipLF = true; } else if (c == '\n') { if (!m_skipLF) *m_dest++ = c; else m_skipLF = false; } else { *m_dest++ = c; m_skipLF = false; } str.advance(); // Maybe enlarge the buffer checkBuffer(); } if (!m_preElement && !inViewSourceMode()) { RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); m_doc->appendChild(rootElement, ec); RefPtr<Element> body = m_doc->createElement(bodyTag, false); rootElement->appendChild(body, ec); RefPtr<Element> preElement = m_doc->createElement(preTag, false); preElement->setAttribute("style", "word-wrap: break-word; white-space: pre-wrap;", ec); body->appendChild(preElement, ec); m_preElement = preElement.get(); } String string = String(m_buffer, m_dest - m_buffer); if (inViewSourceMode()) { static_cast<HTMLViewSourceDocument*>(m_doc)->addViewSourceText(string); return; } unsigned charsLeft = string.length(); while (charsLeft) { // split large text to nodes of manageable size RefPtr<Text> text = Text::createWithLengthLimit(m_doc, string, charsLeft); m_preElement->appendChild(text, ec); } }
PassRefPtr<MediaControlTimelineElement> MediaControlTimelineElement::create(MediaControls& mediaControls) { RefPtr<MediaControlTimelineElement> timeline = adoptRef(new MediaControlTimelineElement(mediaControls)); timeline->ensureUserAgentShadowRoot(); timeline->setType("range"); timeline->setAttribute(stepAttr, "any"); return timeline.release(); }
PassRefPtr<Element> HTMLViewSourceDocument::addLink(const AtomicString& url, bool isAnchor) { if (m_current == m_tbody) addLine("webkit-html-tag"); // Now create a link for the attribute value instead of a span. RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*this); const char* classValue; if (isAnchor) classValue = "webkit-html-attribute-value webkit-html-external-link"; else classValue = "webkit-html-attribute-value webkit-html-resource-link"; anchor->setAttribute(classAttr, classValue); anchor->setAttribute(targetAttr, "_blank"); anchor->setAttribute(hrefAttr, url); m_current->parserAppendChild(anchor); return anchor.release(); }