void HTMLImageElement::insertedIntoDocument()
{
    if (document()->isHTMLDocument()) {
        HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
        document->addNamedItem(m_name);
        document->addExtraNamedItem(m_id);
    }

    // If we have been inserted from a renderer-less document,
    // our loader may have not fetched the image, so do it now.
    if (!m_imageLoader.image())
        m_imageLoader.updateFromElement();

    HTMLElement::insertedIntoDocument();
}
Пример #2
0
/**
 * blur - this method removes the focus from this element
 *
 * params - none
 * return - void
 */
JSBool jhtml_input_blur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	HTMLElement *pElem = (HTMLElement *) jhutil_GetPrivate(cx, obj);

	if (!pElem)
	{
		return JS_TRUE;
	}
	HTMLDocument *pDoc = (pElem)? pElem->GetDocument() : 0;
	if (pDoc && pDoc->Body())
	{
		pDoc->Body()->Focus();
	}
	*rval = JSVAL_VOID;
	return JS_TRUE;
}
Пример #3
0
void HTMLFormElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == actionAttr) {
        bool oldURLWasSecure = formWouldHaveSecureSubmission(m_url);
        m_url = parseURL(attr->value());
        bool newURLIsSecure = formWouldHaveSecureSubmission(m_url);

        if (m_attached && (oldURLWasSecure != newURLIsSecure))
            if (newURLIsSecure)
                document()->secureFormAdded();
            else
                document()->secureFormRemoved();
    }
    else if (attr->name() == targetAttr)
        m_target = attr->value();
    else if (attr->name() == methodAttr) {
        if (equalIgnoringCase(attr->value(), "post"))
            m_post = true;
        else if (equalIgnoringCase(attr->value(), "get"))
            m_post = false;
    } else if (attr->name() == enctypeAttr)
        parseEnctype(attr->value());
    else if (attr->name() == accept_charsetAttr)
        // space separated list of charsets the server
        // accepts - see rfc2045
        m_acceptcharset = attr->value();
    else if (attr->name() == acceptAttr) {
        // ignore this one for the moment...
    } else if (attr->name() == autocompleteAttr)
        m_autocomplete = !equalIgnoringCase(attr->value(), "off");
    else if (attr->name() == onsubmitAttr)
        setHTMLEventListener(submitEvent, attr);
    else if (attr->name() == onresetAttr)
        setHTMLEventListener(resetEvent, attr);
    else if (attr->name() == nameAttr) {
        String newNameAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
            doc->removeNamedItem(oldNameAttr);
            doc->addNamedItem(newNameAttr);
        }
        oldNameAttr = newNameAttr;
    } else
        HTMLElement::parseMappedAttribute(attr);
}
Пример #4
0
void HTMLIFrameElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == widthAttr)
        addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
    else if (attr->name() == heightAttr)
        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
    else if (attr->name() == alignAttr)
        addHTMLAlignment(attr);
    else if (attr->name() == nameAttr) {
        String newNameAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
            doc->removeDocExtraNamedItem(oldNameAttr);
            doc->addDocExtraNamedItem(newNameAttr);
        }
        oldNameAttr = newNameAttr;
    } else
        HTMLFrameElement::parseMappedAttribute(attr);
}
Пример #5
0
void HTMLIFrameElement::insertedIntoDocument()
{
    if (document()->isHTMLDocument()) {
        HTMLDocument *doc = static_cast<HTMLDocument *>(document());
        doc->addDocExtraNamedItem(oldNameAttr);
    }

    HTMLElement::insertedIntoDocument();
    
    // Load the frame
    m_name = getAttribute(nameAttr);
    if (m_name.isNull())
        m_name = getAttribute(idAttr);
    
    if (Frame* parentFrame = document()->frame()) {
        m_name = parentFrame->tree()->uniqueChildName(m_name);
        
        openURL();
    }    
}
Пример #6
0
void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
    if (name == nameAttr) {
        if (inDocument() && document()->isHTMLDocument() && !isInShadowTree()) {
            HTMLDocument* document = toHTMLDocument(this->document());
            document->removeExtraNamedItem(m_name);
            document->addExtraNamedItem(value);
        }
        m_name = value;
    } else if (name == sandboxAttr) {
        String invalidTokens;
        setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
        if (!invalidTokens.isNull())
            document()->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
    } else if (name == seamlessAttr) {
        // If we're adding or removing the seamless attribute, we need to force the content document to recalculate its StyleResolver.
        if (contentDocument())
            contentDocument()->styleResolverChanged(DeferRecalcStyle);
    } else
        HTMLFrameElementBase::parseAttribute(name, value);
}
Пример #7
0
void HTMLImageElement::insertedIntoDocument()
{
    if (document()->isHTMLDocument()) {
        HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
        document->addNamedItem(m_name);
        document->addExtraNamedItem(m_id);
    }

    // If we have been inserted from a renderer-less document,
    // our loader may have not fetched the image, so do it now.
    if (!m_imageLoader.image())
        m_imageLoader.updateFromElement();

    HTMLElement::insertedIntoDocument();

    Request* req = cache()->loader()->requestForUrl(src().string());
    if (!req)
        return;

    req->setNode(PassRefPtr<Node>(this));
}
Пример #8
0
void HTMLAppletElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == altAttr ||
        attr->name() == archiveAttr ||
        attr->name() == codeAttr ||
        attr->name() == codebaseAttr ||
        attr->name() == mayscriptAttr ||
        attr->name() == objectAttr) {
        // Do nothing.
    } else if (attr->name() == nameAttr) {
        String newNameAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
            doc->removeNamedItem(oldNameAttr);
            doc->addNamedItem(newNameAttr);
        }
        oldNameAttr = newNameAttr;
    } else if (attr->name() == idAttr) {
        String newIdAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
            doc->removeDocExtraNamedItem(oldIdAttr);
            doc->addDocExtraNamedItem(newIdAttr);
        }
        oldIdAttr = newIdAttr;
        // also call superclass
        HTMLPlugInElement::parseMappedAttribute(attr);
    } else
        HTMLPlugInElement::parseMappedAttribute(attr);
}
Пример #9
0
void HTMLAppletElement::parseMappedAttribute(MappedAttribute* attr)
{
    if (attr->name() == altAttr ||
        attr->name() == archiveAttr ||
        attr->name() == codeAttr ||
        attr->name() == codebaseAttr ||
        attr->name() == mayscriptAttr ||
        attr->name() == objectAttr) {
        // Do nothing.
    } else if (attr->name() == nameAttr) {
        const AtomicString& newName = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else if (attr->name() == idAttr) {
        const AtomicString& newId = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeExtraNamedItem(m_id);
            document->addExtraNamedItem(newId);
        }
        m_id = newId;
        // also call superclass
        HTMLPlugInElement::parseMappedAttribute(attr);
    } else
        HTMLPlugInElement::parseMappedAttribute(attr);
}
Пример #10
0
void HTMLEmbedElement::parseMappedAttribute(MappedAttribute* attr)
{
    const AtomicString& value = attr->value();
  
    if (attr->name() == typeAttr) {
        m_serviceType = value.string().lower();
        int pos = m_serviceType.find(";");
        if (pos != -1)
            m_serviceType = m_serviceType.left(pos);
        if (!isImageType() && m_imageLoader)
            m_imageLoader.clear();
    } else if (attr->name() == codeAttr)
        m_url = parseURL(value.string());
    else if (attr->name() == srcAttr) {
        m_url = parseURL(value.string());
        if (renderer() && isImageType()) {
            if (!m_imageLoader)
                m_imageLoader.set(new HTMLImageLoader(this));
            m_imageLoader->updateFromElement();
        }
    } else if (attr->name() == pluginpageAttr || attr->name() == pluginspageAttr)
        m_pluginPage = value;
    else if (attr->name() == hiddenAttr) {
        if (equalIgnoringCase(value.string(), "yes") || equalIgnoringCase(value.string(), "true")) {
            // FIXME: Not dynamic, since we add this but don't remove it, but it may be OK for now
            // that this rarely-used attribute won't work properly if you remove it.
            addCSSLength(attr, CSSPropertyWidth, "0");
            addCSSLength(attr, CSSPropertyHeight, "0");
        }
    } else if (attr->name() == nameAttr) {
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(value);
        }
        m_name = value;
    } else
        HTMLPlugInElement::parseMappedAttribute(attr);
}
Пример #11
0
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());

    if (info.Length() > 2) {
        if (RefPtr<LocalFrame> frame = htmlDocument->frame()) {
            // Fetch the global object for the frame.
            v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame.get(), DOMWrapperWorld::current(info.GetIsolate()));
            // Bail out if we cannot get the context.
            if (context.IsEmpty())
                return;
            v8::Local<v8::Object> global = context->Global();
            // Get the open property of the global object.
            v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsolate(), "open"));
            // Failed; return without throwing (new) exception.
            if (function.IsEmpty())
                return;
            // If the open property is not a function throw a type error.
            if (!function->IsFunction()) {
                throwTypeError("open is not a function", info.GetIsolate());
                return;
            }
            // Wrap up the arguments and call the function.
            OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::Value>[info.Length()]);
            for (int i = 0; i < info.Length(); i++)
                params[i] = info[i];

            v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Function>::Cast(function), global, info.Length(), params.get()));
            return;
        }
    }

    ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Document", info.Holder(), info.GetIsolate());
    htmlDocument->open(callingDOMWindow(info.GetIsolate())->document(), exceptionState);
    if (exceptionState.throwIfNeeded())
        return;

    v8SetReturnValue(info, info.Holder());
}
Пример #12
0
void HTMLEmbedElement::insertedIntoDocument()
{
    if (document()->isHTMLDocument()) {
        HTMLDocument *doc = static_cast<HTMLDocument *>(document());
        doc->addNamedItem(oldNameAttr);
    }

    String width = getAttribute(widthAttr);
    String height = getAttribute(heightAttr);
    if (!width.isEmpty() || !height.isEmpty()) {
        Node* n = parent();
        while (n && !n->hasTagName(objectTag))
            n = n->parent();
        if (n) {
            if (!width.isEmpty())
                static_cast<HTMLObjectElement*>(n)->setAttribute(widthAttr, width);
            if (!height.isEmpty())
                static_cast<HTMLObjectElement*>(n)->setAttribute(heightAttr, height);
        }
    }

    HTMLPlugInElement::insertedIntoDocument();
}
Пример #13
0
/**
 * blur - This method removes the focus from this element
 *
 * params - none;
 * return - void;
 */
JSBool jhtml_anchor_blur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	LOG_HTMLDOM("jhtml_anchor_blur\n");

	if (JS_GetClass(obj) == &JSHtmlAnchorElement)
	{
		HTMLElement *pElem = (HTMLElement *) jhutil_GetPrivate(cx, obj);

		if (!pElem)
		{
			return JS_TRUE;
		}

		HTMLDocument *pDoc = (pElem)? pElem->GetDocument() : 0;
		if (pDoc && pDoc->Body())
		{
			pDoc->Body()->Focus();
		}
	}

	*rval = JSVAL_VOID;
	return JS_TRUE;
}
JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
    JSHTMLDocument* thisObj = jsCast<JSHTMLDocument*>(asObject(slotBase));
    HTMLDocument* document = toHTMLDocument(thisObj->impl());

    AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
    if (!atomicPropertyName || !document->documentNamedItemMap().contains(atomicPropertyName))
        return jsUndefined();

    if (UNLIKELY(!document->documentNamedItemMap().containsSingle(atomicPropertyName))) {
        RefPtr<HTMLCollection> collection = document->documentNamedItems(atomicPropertyName);
        ASSERT(!collection->isEmpty());
        ASSERT(!collection->hasExactlyOneItem());
        return toJS(exec, thisObj->globalObject(), WTF::getPtr(collection));
    }

    Node* node = document->documentNamedItemMap().getElementByDocumentNamedItem(atomicPropertyName, document);
    Frame* frame;
    if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
        return toJS(exec, frame);

    return toJS(exec, thisObj->globalObject(), node);
}
Пример #15
0
void HTMLFormElement::parseMappedAttribute(Attribute* attr)
{
    if (attr->name() == actionAttr)
        m_attributes.parseAction(attr->value());
    else if (attr->name() == targetAttr)
        m_attributes.setTarget(attr->value());
    else if (attr->name() == methodAttr)
        m_attributes.parseMethodType(attr->value());
    else if (attr->name() == enctypeAttr)
        m_attributes.parseEncodingType(attr->value());
    else if (attr->name() == accept_charsetAttr)
        // space separated list of charsets the server
        // accepts - see rfc2045
        m_attributes.setAcceptCharset(attr->value());
    else if (attr->name() == acceptAttr) {
        // ignore this one for the moment...
    } else if (attr->name() == autocompleteAttr) {
        m_autocomplete = !equalIgnoringCase(attr->value(), "off");
        if (!m_autocomplete)
            document()->registerForDocumentActivationCallbacks(this);
        else
            document()->unregisterForDocumentActivationCallbacks(this);
    } else if (attr->name() == onsubmitAttr)
        setAttributeEventListener(eventNames().submitEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == onresetAttr)
        setAttributeEventListener(eventNames().resetEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == nameAttr) {
        const AtomicString& newName = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else
        HTMLElement::parseMappedAttribute(attr);
}
Пример #16
0
void HTMLImageElement::parseMappedAttribute(Attribute* attr)
{
    const QualifiedName& attrName = attr->name();
    if (attrName == altAttr) {
        if (renderer() && renderer()->isImage())
            toRenderImage(renderer())->updateAltText();
    } else if (attrName == srcAttr)
        m_imageLoader.updateFromElementIgnoringPreviousError();
    else if (attrName == widthAttr)
        addCSSLength(attr, CSSPropertyWidth, attr->value());
    else if (attrName == heightAttr)
        addCSSLength(attr, CSSPropertyHeight, attr->value());
    else if (attrName == borderAttr) {
        // border="noborder" -> border="0"
        applyBorderAttribute(attr);
    } else if (attrName == vspaceAttr) {
        addCSSLength(attr, CSSPropertyMarginTop, attr->value());
        addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
    } else if (attrName == hspaceAttr) {
        addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
        addCSSLength(attr, CSSPropertyMarginRight, attr->value());
    } else if (attrName == alignAttr)
        addHTMLAlignment(attr);
    else if (attrName == valignAttr)
        addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
    else if (attrName == usemapAttr)
        setIsLink(!attr->isNull());
    else if (attrName == onabortAttr)
        setAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(this, attr));
    else if (attrName == onloadAttr)
        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
    else if (attrName == onbeforeloadAttr)
        setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
    else if (attrName == compositeAttr) {
        if (!parseCompositeOperator(attr->value(), m_compositeOperator))
            m_compositeOperator = CompositeSourceOver;
    } else if (attrName == nameAttr) {
        const AtomicString& newName = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else if (isIdAttributeName(attr->name())) {
        const AtomicString& newId = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeExtraNamedItem(m_id);
            document->addExtraNamedItem(newId);
        }
        m_id = newId;
        // also call superclass
        HTMLElement::parseMappedAttribute(attr);
    } else
        HTMLElement::parseMappedAttribute(attr);
}
Пример #17
0
void HTMLObjectElement::parseMappedAttribute(Attribute* attr)
{
    if (attr->name() == typeAttr) {
        m_serviceType = attr->value().lower();
        size_t pos = m_serviceType.find(";");
        if (pos != notFound)
            m_serviceType = m_serviceType.left(pos);
        if (renderer())
            setNeedsWidgetUpdate(true);
        if (!isImageType() && m_imageLoader)
            m_imageLoader.clear();
    } else if (attr->name() == dataAttr) {
        m_url = stripLeadingAndTrailingHTMLSpaces(attr->value());
        if (renderer()) {
            setNeedsWidgetUpdate(true);
            if (isImageType()) {
                if (!m_imageLoader)
                    m_imageLoader = adoptPtr(new HTMLImageLoader(this));
                m_imageLoader->updateFromElementIgnoringPreviousError();
            }
        }
    } else if (attr->name() == classidAttr) {
        m_classId = attr->value();
        if (renderer())
            setNeedsWidgetUpdate(true);
    } else if (attr->name() == onloadAttr)
        setAttributeEventListener(eventNames().loadEvent, NULL_METHOD_RESULT(this, attr));
    else if (attr->name() == onbeforeloadAttr)
        setAttributeEventListener(eventNames().beforeloadEvent, NULL_METHOD_RESULT(this, attr));
    else if (attr->name() == nameAttr) {
        const AtomicString& newName = attr->value();
        if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else if (attr->name() == borderAttr) {
        addCSSLength(attr, CSSPropertyBorderWidth, attr->value().toInt() ? attr->value() : "0");
        addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
    } else if (isIdAttributeName(attr->name())) {
        const AtomicString& newId = attr->value();
        if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeExtraNamedItem(m_id);
            document->addExtraNamedItem(newId);
        }
        m_id = newId;
        // also call superclass
        HTMLPlugInImageElement::parseMappedAttribute(attr);
    } else
        HTMLPlugInImageElement::parseMappedAttribute(attr);
}
Пример #18
0
JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
    JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(asObject(slotBase));
    HTMLDocument* document = static_cast<HTMLDocument*>(thisObj->impl());

    String name = identifierToString(propertyName);
    RefPtr<HTMLCollection> collection = document->documentNamedItems(name);

    unsigned length = collection->length();
    if (!length)
        return jsUndefined();

    if (length == 1) {
        Node* node = collection->firstItem();

        Frame* frame;
        if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
            return toJS(exec, frame);

        return toJS(exec, node);
    } 

    return toJS(exec, collection.get());
}
Пример #19
0
JSValue* JSHTMLDocument::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
    JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());
    HTMLDocument* doc = static_cast<HTMLDocument*>(thisObj->impl());

    String name = propertyName;
    RefPtr<HTMLCollection> collection = doc->documentNamedItems(name);

    unsigned length = collection->length();
    if (!length)
        return jsUndefined();

    if (length == 1) {
        Node* node = collection->firstItem();

        Frame* frame;
        if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
            return Window::retrieve(frame);

        return toJS(exec, node);
    }

    return toJS(exec, collection.get());
}
Пример #20
0
void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
{
    String val = attr->value();
    int pos;
    if (attr->name() == typeAttr) {
        m_serviceType = val.lower();
        pos = m_serviceType.find(";");
        if (pos != -1)
          m_serviceType = m_serviceType.left(pos);
        if (renderer())
          m_needWidgetUpdate = true;
        if (!isImageType() && m_imageLoader) {
          delete m_imageLoader;
          m_imageLoader = 0;
        }
    } else if (attr->name() == dataAttr) {
        m_url = parseURL(val);
        if (renderer())
          m_needWidgetUpdate = true;
        if (renderer() && isImageType()) {
          if (!m_imageLoader)
              m_imageLoader = new HTMLImageLoader(this);
          m_imageLoader->updateFromElement();
        }
    } else if (attr->name() == classidAttr) {
        m_classId = val;
        if (renderer())
          m_needWidgetUpdate = true;
    } else if (attr->name() == onloadAttr) {
        setHTMLEventListener(loadEvent, attr);
    } else if (attr->name() == onunloadAttr) {
        setHTMLEventListener(unloadEvent, attr);
    } else if (attr->name() == nameAttr) {
            String newNameAttr = attr->value();
            if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
                HTMLDocument *doc = static_cast<HTMLDocument *>(document());
                doc->removeNamedItem(oldNameAttr);
                doc->addNamedItem(newNameAttr);
            }
            oldNameAttr = newNameAttr;
    } else if (attr->name() == idAttr) {
        String newIdAttr = attr->value();
        if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* doc = static_cast<HTMLDocument*>(document());
            doc->removeDocExtraNamedItem(oldIdAttr);
            doc->addDocExtraNamedItem(newIdAttr);
        }
        oldIdAttr = newIdAttr;
        // also call superclass
        HTMLPlugInElement::parseMappedAttribute(attr);
    } else
        HTMLPlugInElement::parseMappedAttribute(attr);
}
Пример #21
0
void HTMLObjectElement::parseMappedAttribute(Attribute* attr)
{
    String val = attr->value();
    int pos;
    if (attr->name() == typeAttr) {
        m_serviceType = val.lower();
        pos = m_serviceType.find(";");
        if (pos != -1)
          m_serviceType = m_serviceType.left(pos);
        if (renderer())
          m_needWidgetUpdate = true;
        if (!isImageType() && m_imageLoader)
          m_imageLoader.clear();
    } else if (attr->name() == dataAttr) {
        m_url = deprecatedParseURL(val);
        if (renderer())
          m_needWidgetUpdate = true;
        if (renderer() && isImageType()) {
          if (!m_imageLoader)
              m_imageLoader.set(new HTMLImageLoader(this));
          m_imageLoader->updateFromElementIgnoringPreviousError();
        }
    } else if (attr->name() == classidAttr) {
        m_classId = val;
        if (renderer())
          m_needWidgetUpdate = true;
    } else if (attr->name() == onloadAttr)
        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == onbeforeloadAttr)
        setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == nameAttr) {
        const AtomicString& newName = attr->value();
        if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else if (isIdAttributeName(attr->name())) {
        const AtomicString& newId = attr->value();
        if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeExtraNamedItem(m_id);
            document->addExtraNamedItem(newId);
        }
        m_id = newId;
        // also call superclass
        HTMLPlugInElement::parseMappedAttribute(attr);
    } else
        HTMLPlugInElement::parseMappedAttribute(attr);
}
HTMLDocument* DOMImplementation::createHTMLDocument(const String& title)
{
    DocumentInit init = DocumentInit::fromContext(document().contextDocument())
        .withRegistrationContext(document().registrationContext());
    HTMLDocument* d = HTMLDocument::create(init);
    d->open();
    d->write("<!doctype html><html><head></head><body></body></html>");
    if (!title.isNull()) {
        HTMLHeadElement* headElement = d->head();
        DCHECK(headElement);
        HTMLTitleElement* titleElement = HTMLTitleElement::create(*d);
        headElement->appendChild(titleElement);
        titleElement->appendChild(d->createTextNode(title), ASSERT_NO_EXCEPTION);
    }
    d->setSecurityOrigin(document().getSecurityOrigin());
    d->setContextFeatures(document().contextFeatures());
    return d;
}
void testBoundary(HTMLDocument& document, HTMLTextFormControlElement& textControl)
{
    for (unsigned i = 0; i < textControl.innerEditorValue().length(); i++) {
        textControl.setSelectionRange(i, i);
        Position position = document.frame()->selection().start();
        SCOPED_TRACE(::testing::Message() << "offset " << position.computeEditingOffset() << " of " << nodePositionAsStringForTesting(position.anchorNode()).ascii().data());
        {
            SCOPED_TRACE("HTMLTextFormControlElement::startOfWord");
            testFunctionEquivalence(position, HTMLTextFormControlElement::startOfWord, startOfWord);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::endOfWord");
            testFunctionEquivalence(position, HTMLTextFormControlElement::endOfWord, endOfWord);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::startOfSentence");
            testFunctionEquivalence(position, HTMLTextFormControlElement::startOfSentence, startOfSentence);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::endOfSentence");
            testFunctionEquivalence(position, HTMLTextFormControlElement::endOfSentence, endOfSentence);
        }
    }
}
void V8HTMLDocument::writelnMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
    htmlDocument->writeln(writeHelperGetString(args), activeDOMWindow()->document());
}
Пример #25
0
void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr)
{
    const QualifiedName& attrName = attr->name();
    if (attrName == altAttr) {
        if (renderer() && renderer()->isImage())
            static_cast<RenderImage*>(renderer())->updateAltText();
    } else if (attrName == srcAttr)
        m_imageLoader.updateFromElement();
    else if (attrName == widthAttr)
        addCSSLength(attr, CSSPropertyWidth, attr->value());
    else if (attrName == heightAttr)
        addCSSLength(attr, CSSPropertyHeight, attr->value());
    else if (attrName == borderAttr) {
        // border="noborder" -> border="0"
        addCSSLength(attr, CSSPropertyBorderWidth, attr->value().toInt() ? attr->value() : "0");
        addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
        addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
    } else if (attrName == vspaceAttr) {
        addCSSLength(attr, CSSPropertyMarginTop, attr->value());
        addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
    } else if (attrName == hspaceAttr) {
        addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
        addCSSLength(attr, CSSPropertyMarginRight, attr->value());
    } else if (attrName == alignAttr)
        addHTMLAlignment(attr);
    else if (attrName == valignAttr)
        addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
    else if (attrName == usemapAttr) {
        if (attr->value().string()[0] == '#')
            usemap = attr->value();
        else
            usemap = document()->completeURL(parseURL(attr->value())).string();
        setIsLink(!attr->isNull());
    } else if (attrName == ismapAttr)
        ismap = true;
    else if (attrName == onabortAttr)
        setInlineEventListenerForTypeAndAttribute(eventNames().abortEvent, attr);
    else if (attrName == onloadAttr)
        setInlineEventListenerForTypeAndAttribute(eventNames().loadEvent, attr);
    else if (attrName == compositeAttr) {
        if (!parseCompositeOperator(attr->value(), m_compositeOperator))
            m_compositeOperator = CompositeSourceOver;
    } else if (attrName == nameAttr) {
        const AtomicString& newName = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeNamedItem(m_name);
            document->addNamedItem(newName);
        }
        m_name = newName;
    } else if (attr->name() == idAttr) {
        const AtomicString& newId = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
            document->removeExtraNamedItem(m_id);
            document->addExtraNamedItem(newId);
        }
        m_id = newId;
        // also call superclass
        HTMLElement::parseMappedAttribute(attr);
    } else
        HTMLElement::parseMappedAttribute(attr);
}
Пример #26
0
/**
 * HTMLCollection item(long) method
 *
 * param  - index - the index of the element to get
 * return - the HTMLElement at index
 */
JSBool jhtml_collection_item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	int index;
	int32 dIndex = 0;
	WebcJSScript *jsscr = (WebcJSScript *) jhutil_GetContextPrivate(cx);
	WebcJSDocumentContext *jsmgr = (jsscr)? jsscr->GetJSMgr() : 0;
	if (!jsmgr)
	{
		return JS_FALSE;
	}
	HTMLDocument *pDoc = jsmgr->GetDocument();
	if (!pDoc)
	{
		return JS_FALSE;
	}

	//if we have at least 1 argument and it is a number
	if (argc > 0 && JSVAL_IS_INT(argv[0]))
	{
		//convert the jsval to a number
		JS_ValueToInt32(cx, argv[0], &dIndex);
		index = (int)dIndex;
		HTMLElementType ele_type = HTML_ELEMENT_NONE;
		jhtml_collection *pColl = (jhtml_collection*)jhutil_GetPrivate(cx, obj);
		if (!pColl)
		{
			return JS_FALSE;
		}
		HTMLElement *pElem = 0;
		switch(pColl->finderType)
		{
			case DOCUMENT_IMAGES:
				ele_type = HTML_IMAGE_ELEMENT;
				break;

			case DOCUMENT_ANCHORS:
				ele_type = HTML_ANCHOR_ELEMENT;
				break;

			case TABLE_ROWS:
				ele_type = HTML_TABLE_ROW_ELEMENT;
				break;

			case TABLEROW_CELLS:
				ele_type = HTML_TABLE_CELL_ELEMENT;
				break;

			case MAP_AREAS:
				ele_type = HTML_AREA_ELEMENT;
				break;

			case SELECT_OPTIONS:
				ele_type = HTML_OPTION_ELEMENT;
				break;

			case WIN_FRAMES:
			{
				*rval = JSVAL_NULL;
			  #if (WEBC_SUPPORT_FRAMES)
				HTMLNthOfTypeFinder finder(HTML_FRAME_ELEMENT, index);
				pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_ELEMENT_DEFAULT);
				if (pElem)
				{
					HTMLFrame *pFrame = (HTMLFrame *) pElem;
					if (pFrame->FrameDocument() && pFrame->FrameDocument()->GetJSMgr())
					{
						*rval = OBJECT_TO_JSVAL(pFrame->FrameDocument()->GetJSMgr()->GetGlobalObject());
					}
				}
			  #endif // WEBC_SUPPORT_FRAMES
				return JS_TRUE;
			}

			case ELEMENT_NODES:
			{
				HTMLNthOfAnyTypeFinder finder(index);
				pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_NODES_DEFAULT);
				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}
				return JS_TRUE;
			}

			case DOCUMENT_FORMS:
			{
				HTMLElementTypeFinder formFinder(HTML_FORM_ELEMENT);
				HTMLNthElementFinder nthFormFinder(&formFinder, index);

				pElem = pDoc->FindElement(&nthFormFinder);

				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}
				return JS_TRUE;
			}

            case DOCUMENT_IDS:
			{
				HTMLNthOfAnyTypeFinder finder(index);
				pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_ELEMENT_DEFAULT);
				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}
				return JS_TRUE;
			}

			case DOCUMENT_ALL:
			{
				HTMLNthOfAnyTypeFinder finder(index);
				pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_ELEMENT_DEFAULT);
				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}
				return JS_TRUE;
			}

			case ALL_BY_NAME:
			{
				//get the nth item with name...
				HTMLNthByNameFinder finder(pColl->nameOfAll, index);
				pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_ELEMENT_DEFAULT);

				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}

				return JS_TRUE;
			}

			case ALL_TAGS_BY_TAGNAME:
			{
				//get the nth item with the specified tag name...
				HTMLTagType hType = HTML_ParseTagType(pColl->nameOfAll, webc_strlen(pColl->nameOfAll));
				HTMLElementType eType = TagToHTMLElementType[hType];
				HTMLNthOfTypeFinder finder(eType, index);
				pElem = pColl->pTop->FindElement(&finder, 1, WEBC_FALSE);

				if (pElem)
				{
					*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
				}
				else
				{
					*rval = JSVAL_NULL;
				}

				return JS_TRUE;
			}

			case FORM_INPUTS:
			{
				//for this type of collection, the top will always be of type form
				HTMLForm *form = (HTMLForm *)pColl->pTop;
				if (form)
				{
					pElem = jutils_GetNthOfObjectList(form->GetFieldVector(),
					                                  index,
					                                  _matchInput,
					                                  0);

					if (pElem)
					{
						*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
					}
					else
					{
						*rval = JSVAL_NULL;
					}

					return JS_TRUE;
				}
				break;
			}

			case DOCUMENT_STYLESHEETS:
			{
#if (WEBC_SUPPORT_STYLE_SHEETS)
				//GMP this needs to be revisited if CSS is changed to have more than 1 style sheet
				*rval = OBJECT_TO_JSVAL(pDoc->GetCSSContext()->GetJSObject());
#else
				*rval = JSVAL_NULL;
#endif
				return JS_TRUE;
			}

			case SSHEET_RULES:
			{
#if (WEBC_SUPPORT_STYLE_SHEETS)
				/*int i = 0;
				CSSDocumentContext *pCSSCx = pDoc->GetCSSContext();
				if (pCSSCx)
				{
					vector_iterator pvi[1];
					CSSPropertyDescriptor *pCSSPD = pCSSCx->EnumFirstProperty(pvi);
					while(pCSSPD)
					{
						if ( i == index)
						{
							*rval = OBJECT_TO_JSVAL(pCSSPD->GetJSObject());
							return JS_TRUE;
						}
						i++;
						pCSSPD = pCSSCx->EnumNextProperty(pvi);
					}
				}*/
#endif // (WEBC_SUPPORT_STYLE_SHEETS)
				return JS_TRUE;
			}

			case RADIO_BUTTONS:
			{
				HTMLRadioButton *pRadio = (HTMLRadioButton*)pColl->pTop;
				while (index > 0)
				{
					index--;
					pRadio = (pRadio->mpGroupNext != pColl->pTop)
						? pRadio->mpGroupNext : 0;
				}

				if (pRadio)
				{
					*rval = OBJECT_TO_JSVAL(pRadio->CreateJSObject());
					return JS_TRUE;
				}
			}
			break;

		}//end switch

		if (ele_type != HTML_ELEMENT_NONE)
		{
			HTMLNthOfTypeFinder finder(ele_type, index);
			pElem = pColl->pTop->FindElement(&finder,1, INCLUDE_SELF_ELEMENT_DEFAULT);
		}

		if (pElem)
		{
			*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
		}
		else
		{
			*rval = JSVAL_NULL;
		}

		return JS_TRUE;
	}//end if
	else if (argc > 0 && JSVAL_IS_STRING(argv[0]))
	{
		//MSIE allows for the item method to take a srting that corresponds to the name
		//therefore we call namedItem instead
		return jhtml_collection_namedItem(cx, obj, argc, argv, rval);
	}
	*rval = JSVAL_NULL;
	return JS_TRUE;
}
Пример #27
0
void HTMLScript::Update(WEBC_PFBYTE o, WEBC_PFBYTE data)
{
#if (WEBC_SUPPORT_JSCRIPT)
HTMLDocument *pDoc = GetDocument();
WebcJSDocumentContext *jsMgr = (pDoc)? pDoc->GetJSMgr() : 0;

	if (mpScript || !jsMgr)
	{
		return;
	}

	WEBC_NEW_VERBOSE(mpScript, WebcJSScript(jsMgr, jsMgr->GetGlobalObject()),"WebcJSDocumentContext");

	if (mpScript)
	{
		if (Src())
		{
			LoadScript *pJob;
			if (pDoc)
			{
				HTMLBrowser *pBrowser = pDoc->GetBrowser();
				if (pBrowser)
				{
					WebcCharset charset = (mCharset == WEBC_CHARSET_UNKNOWN)? pDoc->GetCharset() : mCharset;
					WEBC_NEW_VERBOSE(pJob, LoadScript(this, pDoc, charset),"LoadScript");
					if (pJob)
					{
						pBrowser->ProcessLoadJob(pJob, pJob->GetURL(), pDoc->BaseURL(), pDoc, WEBC_TRUE /* urgent */);
					}
					webc_free_string_copy(mpSrc, __FILE__, __LINE__);
					mpSrc = 0;
				}
			}
		}
		else // compile the contents of this tag as the script to execute
		{
			HTMLElement *pChild = mpFirstChild;
			WEBC_CHAR* pStr;
			long iLen;
			for (; pChild != WEBC_NULL; pChild = pChild->mpNext)
			{
				if (pChild->Type() == HTML_STRING_ELEMENT)
				{
					pStr = ((HTMLString*)(pChild))->GetString();
					iLen = webc_strlen(pStr);
					if (mpScript->Write(pStr, iLen) < iLen)
					{
						mpScript->Destroy();
						mpScript = 0;
						break;
					}
				}
			}

			if (mpScript)
			{
				mpScript->Compile();
			}

			DeleteChildren();
		}
	}

#endif
}
Пример #28
0
void setJSHTMLDocumentVlinkColor(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLDocument* castedThis = static_cast<JSHTMLDocument*>(thisObject);
    HTMLDocument* imp = static_cast<HTMLDocument*>(castedThis->impl());
    imp->setVlinkColor(valueToStringWithNullCheck(exec, value));
}
Пример #29
0
static JSBool jwindow_dialog(JSContext *cx, JSObject *obj,uintN argc, jsval *argv, jsval *rval, int which_dialogue)
{
	WebcJSDocumentContext *jsmgr = (WebcJSDocumentContext *) jhutil_GetPrivate(cx, obj);
	HTMLDocument *pDoc = (jsmgr)? jsmgr->GetDocument() : 0;

	if (argc < 1)
        return(JS_FALSE);

    char *prompt_str = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
// << EDIT 20080120 - Needs work

	// Clone the graphics abstraction layer function pointers so we know who to call
	HTMLBrowserConfig config, docConfig;
    rtp_memset(&config, 0, sizeof(config));
    rtp_memset(&docConfig, 0, sizeof(docConfig));
	pDoc->GetBrowser()->GetConfig(&docConfig);
	config.graphics = docConfig.graphics;

    switch (which_dialogue) {
        case WHICH_DIALOGUE_ALERT:
            config.WindowConfig.left =   WEBC_SKIN_ALERT_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_ALERT_TOP;
            config.WindowConfig.width =  WEBC_SKIN_ALERT_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_ALERT_HEIGHT;
            break;
        case WHICH_DIALOGUE_PROMPT:
            config.WindowConfig.left =   WEBC_SKIN_PROMPT_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_PROMPT_TOP;
            config.WindowConfig.width =  WEBC_SKIN_PROMPT_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_PROMPT_HEIGHT;
            break;
        case WHICH_DIALOGUE_CONFIRM:
        default:
            config.WindowConfig.left =   WEBC_SKIN_CONFIRM_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_CONFIRM_TOP;
            config.WindowConfig.width =  WEBC_SKIN_CONFIRM_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_CONFIRM_HEIGHT;
            break;
    }
	config.WindowConfig.WindowFlags |= WF_MODAL;

    HBROWSER_HANDLE Browser = webc_CreateBrowser(&config,  WEBC_TRUE,"dialog", "");
    if (Browser)
    {
     HDOC_HANDLE hDoc = webc_BrowserGetDocument(Browser);
	 wcCtx Ctx;
     char buff[128];
	  wcCtxtInit(&Ctx, (wcBROW) Browser, (wcDOC) hDoc);
     /* Experimental */
     wcDocClear(&Ctx, wcFALSE);
     wcDocOpen(&Ctx);


     // Create a link between 'C' and Javascript the Native 'C' function PromptDismiss will
     // be called with the value of the input field.
     webc_JScriptDefineFunction(hDoc, "PromptDismiss", (JSNative) PromptDismiss, 0);
     if (which_dialogue == WHICH_DIALOGUE_ALERT)
     {
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_1);
         WriteDlgLine(&Ctx, prompt_str);
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_3);
     }
     else if (which_dialogue == WHICH_DIALOGUE_CONFIRM)
     {
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_1);
         WriteDlgLine(&Ctx, prompt_str);
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_3);
     }
     else if (which_dialogue == WHICH_DIALOGUE_PROMPT)
     {
         char *default_str = "";
         if (argc > 1)
             default_str = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
         WriteDlgLine(&Ctx, prompt_str);
         rtp_sprintf(&buff[0],WEBC_SKIN_PROMPT_SOURCE_1,default_str);
         WriteDlgLine(&Ctx, &buff[0]);
         WriteDlgLine(&Ctx, WEBC_SKIN_PROMPT_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_PROMPT_SOURCE_3);
     }
     wcDocClose(&Ctx);
     wcDocRefresh(&Ctx);

     /* Go modal here */
  //   HBROWSER_HANDLE Browser = webc_CreateBrowser(&config,  WEBC_TRUE, "");
     HTMLBrowser *pBrowser = (HTMLBrowser *) Browser;
     while (pBrowser->ProcessInputQueue(WEBC_TRUE) >= 0)
     {
         WebString *user_WebString;
         void* privateData = webc_BrowserGetPrivateData(Browser);
         if (privateData)
         {
             user_WebString = (WebString *) privateData;
             if (which_dialogue == WHICH_DIALOGUE_PROMPT)
             {
                 if (user_WebString && user_WebString->getLength())
 			        *rval = STRING_TO_JSVAL(WEBC_JS_NEW_STRING_COPY_Z(cx, user_WebString->getChars()));
                 else
                     *rval = JSVAL_VOID;
             }
             else if (which_dialogue == WHICH_DIALOGUE_ALERT)
                 *rval = JSVAL_VOID;
             else if (which_dialogue == WHICH_DIALOGUE_CONFIRM)
             {
                 if (user_WebString && webc_c_strcmp(user_WebString->getChars(), "OK")==0)
                     *rval = BOOLEAN_TO_JSVAL(JS_TRUE);
                 else
                     *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
             }
             WEBC_DELETE(user_WebString);
             webc_JScriptExecuteSource(hDoc, "window.close();");
             break;
         }
     }
     }
     return jutils_CheckContextState(cx);
}
Пример #30
0
void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr)
{
    const QualifiedName& attrName = attr->name();
    if (attrName == altAttr) {
        if (renderer() && renderer()->isImage())
            static_cast<RenderImage*>(renderer())->updateAltText();
    } else if (attrName == srcAttr)
        m_imageLoader.updateFromElement();
    else if (attrName == widthAttr)
        addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
    else if (attrName == heightAttr)
        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
    else if (attrName == borderAttr) {
        // border="noborder" -> border="0"
        if(attr->value().toInt()) {
            addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value());
            addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
            addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
            addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
        }
    } else if (attrName == vspaceAttr) {
        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
    } else if (attrName == hspaceAttr) {
        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
    } else if (attrName == alignAttr)
        addHTMLAlignment(attr);
    else if (attrName == valignAttr)
        addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
    else if (attrName == usemapAttr) {
        if (attr->value().domString()[0] == '#')
            usemap = attr->value();
        else
            usemap = document()->completeURL(parseURL(attr->value()));
        m_isLink = !attr->isNull();
    } else if (attrName == ismapAttr)
        ismap = true;
    else if (attrName == onabortAttr)
        setHTMLEventListener(abortEvent, attr);
    else if (attrName == onloadAttr)
        setHTMLEventListener(loadEvent, attr);
    else if (attrName == compositeAttr) {
        if (!parseCompositeOperator(attr->value(), m_compositeOperator))
            m_compositeOperator = CompositeSourceOver;
    } else if (attrName == nameAttr) {
        String newNameAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument* doc = static_cast<HTMLDocument*>(document());
            doc->removeNamedItem(oldNameAttr);
            doc->addNamedItem(newNameAttr);
        }
        oldNameAttr = newNameAttr;
    } else if (attr->name() == idAttr) {
        String newIdAttr = attr->value();
        if (inDocument() && document()->isHTMLDocument()) {
            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
            doc->removeDocExtraNamedItem(oldIdAttr);
            doc->addDocExtraNamedItem(newIdAttr);
        }
        oldIdAttr = newIdAttr;
        // also call superclass
        HTMLElement::parseMappedAttribute(attr);
    } else
        HTMLElement::parseMappedAttribute(attr);
}