void SVGSVGElement::parseMappedAttribute(MappedAttribute* attr) { if (!nearestViewportElement()) { // Only handle events if we're the outermost <svg> element if (attr->name() == onunloadAttr) addSVGWindowEventListener(unloadEvent, attr); else if (attr->name() == onabortAttr) addSVGWindowEventListener(abortEvent, attr); else if (attr->name() == onerrorAttr) addSVGWindowEventListener(errorEvent, attr); else if (attr->name() == onresizeAttr) addSVGWindowEventListener(resizeEvent, attr); else if (attr->name() == onscrollAttr) addSVGWindowEventListener(scrollEvent, attr); else if (attr->name() == SVGNames::onzoomAttr) addSVGWindowEventListener(zoomEvent, attr); } if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(this, LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(this, LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(this, LengthModeWidth, attr->value())); addCSSProperty(attr, CSS_PROP_WIDTH, attr->value()); if (width().value() < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value())); addCSSProperty(attr, CSS_PROP_HEIGHT, attr->value()); if (height().value() < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGFitToViewBox::parseMappedAttribute(attr) && renderer()) { static_cast<RenderSVGContainer*>(renderer())->setViewBox(viewBox()); return; } if (SVGZoomAndPan::parseMappedAttribute(attr)) return; SVGStyledLocatableElement::parseMappedAttribute(attr); } }
void WMLBRElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == HTMLNames::clearAttr) { // If the string is empty, then don't add the clear property. // <br clear> and <br clear=""> are just treated like <br> by Gecko, Mac IE, etc. -dwh const AtomicString& value = attr->value(); if (value.isEmpty()) return; if (equalIgnoringCase(value, "all")) addCSSProperty(attr, CSSPropertyClear, "both"); else addCSSProperty(attr, CSSPropertyClear, value); } else WMLElement::parseMappedAttribute(attr); }
void SVGSVGElement::parseMappedAttribute(Attribute* attr) { SVGParsingError parseError = NoError; if (!nearestViewportElement()) { bool setListener = true; // Only handle events if we're the outermost <svg> element if (attr->name() == HTMLNames::onunloadAttr) document()->setWindowAttributeEventListener(eventNames().unloadEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == HTMLNames::onresizeAttr) document()->setWindowAttributeEventListener(eventNames().resizeEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == HTMLNames::onscrollAttr) document()->setWindowAttributeEventListener(eventNames().scrollEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == SVGNames::onzoomAttr) document()->setWindowAttributeEventListener(eventNames().zoomEvent, createAttributeEventListener(document()->frame(), attr)); else setListener = false; if (setListener) return; } if (attr->name() == HTMLNames::onabortAttr) document()->setWindowAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == HTMLNames::onerrorAttr) document()->setWindowAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError)); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError)); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths)); addCSSProperty(attr, CSSPropertyWidth, attr->value()); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths)); addCSSProperty(attr, CSSPropertyHeight, attr->value()); } else if (SVGTests::parseMappedAttribute(attr) || SVGLangSpace::parseMappedAttribute(attr) || SVGExternalResourcesRequired::parseMappedAttribute(attr) || SVGFitToViewBox::parseMappedAttribute(document(), attr) || SVGZoomAndPan::parseMappedAttribute(attr)) { } else SVGStyledLocatableElement::parseMappedAttribute(attr); reportAttributeParsingError(parseError, attr); }
void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute *attr) { const AtomicString& value = attr->value(); if (attr->name() == SVGNames::xAttr) x()->baseVal()->setValueAsString(value.impl()); else if (attr->name() == SVGNames::yAttr) y()->baseVal()->setValueAsString(value.impl()); else if (attr->name() == SVGNames::widthAttr) { width()->baseVal()->setValueAsString(value.impl()); addCSSProperty(attr, CSS_PROP_WIDTH, value); } else if (attr->name() == SVGNames::heightAttr) { height()->baseVal()->setValueAsString(value.impl()); addCSSProperty(attr, CSS_PROP_HEIGHT, value); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr) { // NOTE: Any subclass which overrides parseMappedAttribute for a property handled by // cssPropertyIdForSVGAttributeName will also have to override mapToEntry to disable the default eSVG mapping int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name()); if (propId > 0) { addCSSProperty(attr, propId, attr->value()); setChanged(); return; } // id and class are handled by StyledElement SVGElement::parseMappedAttribute(attr); }
void HTMLElement::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == idAttr || attr->name() == classAttr || attr->name() == styleAttr) return StyledElement::parseMappedAttribute(attr); String indexstring; if (attr->name() == alignAttr) { if (equalIgnoringCase(attr->value(), "middle")) addCSSProperty(attr, CSSPropertyTextAlign, "center"); else addCSSProperty(attr, CSSPropertyTextAlign, attr->value()); } else if (attr->name() == contenteditableAttr) { setContentEditable(attr); } else if (attr->name() == tabindexAttr) { indexstring = getAttribute(tabindexAttr); if (indexstring.length()) { bool parsedOK; int tabindex = indexstring.toIntStrict(&parsedOK); if (parsedOK) // Clamp tabindex to the range of 'short' to match Firefox's behavior. setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max())))); } } else if (attr->name() == langAttr) { // FIXME: Implement } else if (attr->name() == dirAttr) { addCSSProperty(attr, CSSPropertyDirection, attr->value()); addCSSProperty(attr, CSSPropertyUnicodeBidi, hasLocalName(bdoTag) ? CSSValueBidiOverride : CSSValueEmbed); } // standard events else if (attr->name() == onclickAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().clickEvent, attr); } else if (attr->name() == oncontextmenuAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().contextmenuEvent, attr); } else if (attr->name() == ondblclickAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dblclickEvent, attr); } else if (attr->name() == onmousedownAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mousedownEvent, attr); } else if (attr->name() == onmousemoveAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mousemoveEvent, attr); } else if (attr->name() == onmouseoutAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mouseoutEvent, attr); } else if (attr->name() == onmouseoverAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mouseoverEvent, attr); } else if (attr->name() == onmouseupAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mouseupEvent, attr); } else if (attr->name() == onmousewheelAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().mousewheelEvent, attr); } else if (attr->name() == onfocusAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().focusEvent, attr); } else if (attr->name() == onblurAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().blurEvent, attr); } else if (attr->name() == onkeydownAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().keydownEvent, attr); } else if (attr->name() == onkeypressAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().keypressEvent, attr); } else if (attr->name() == onkeyupAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().keyupEvent, attr); } else if (attr->name() == onscrollAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().scrollEvent, attr); } else if (attr->name() == onbeforecutAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().beforecutEvent, attr); } else if (attr->name() == oncutAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().cutEvent, attr); } else if (attr->name() == onbeforecopyAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().beforecopyEvent, attr); } else if (attr->name() == oncopyAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().copyEvent, attr); } else if (attr->name() == onbeforepasteAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().beforepasteEvent, attr); } else if (attr->name() == onpasteAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().pasteEvent, attr); } else if (attr->name() == ondragenterAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragenterEvent, attr); } else if (attr->name() == ondragoverAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragoverEvent, attr); } else if (attr->name() == ondragleaveAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragleaveEvent, attr); } else if (attr->name() == ondropAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dropEvent, attr); } else if (attr->name() == ondragstartAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragstartEvent, attr); } else if (attr->name() == ondragAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragEvent, attr); } else if (attr->name() == ondragendAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().dragendEvent, attr); } else if (attr->name() == onselectstartAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().selectstartEvent, attr); } else if (attr->name() == onsubmitAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().submitEvent, attr); } else if (attr->name() == onerrorAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().errorEvent, attr); } else if (attr->name() == onwebkitanimationstartAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationStartEvent, attr); } else if (attr->name() == onwebkitanimationiterationAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationIterationEvent, attr); } else if (attr->name() == onwebkitanimationendAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationEndEvent, attr); } else if (attr->name() == onwebkittransitionendAttr) { setInlineEventListenerForTypeAndAttribute(eventNames().webkitTransitionEndEvent, attr); } }