New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SVG element #13589
Merged
+531
−17
Merged
Support SVG element #13589
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9876020
add SVGElement, SVGGraphicsElement interfaces and SVGSVGElement element
splav 14934a4
add SVG fragment (SpecificFragmentInfo::Svg)
splav a1fd802
add SVG2 draft link to WEBIDL_STANDARDS test-tidy list
splav 1f0b9ab
add empty svg element with sizes test
splav File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -76,21 +76,44 @@ use dom::htmltrackelement::HTMLTrackElement; | ||
| use dom::htmlulistelement::HTMLUListElement; | ||
| use dom::htmlunknownelement::HTMLUnknownElement; | ||
| use dom::htmlvideoelement::HTMLVideoElement; | ||
| use dom::svgsvgelement::SVGSVGElement; | ||
| use string_cache::{Atom, QualName}; | ||
| use util::prefs::PREFS; | ||
|
|
||
| pub fn create_element(name: QualName, | ||
| prefix: Option<Atom>, | ||
| document: &Document, | ||
| creator: ElementCreator) | ||
| fn create_svg_element(name: QualName, | ||
| prefix: Option<DOMString>, | ||
| document: &Document) | ||
| -> Root<Element> { | ||
| // FIXME(ajeffrey): Convert directly from Atom to DOMString. | ||
| assert!(name.ns == ns!(svg)); | ||
|
|
||
| let prefix = prefix.map(|p| DOMString::from(&*p)); | ||
| macro_rules! make( | ||
| ($ctor:ident) => ({ | ||
| let obj = $ctor::new(name.local, prefix, document); | ||
| Root::upcast(obj) | ||
| }); | ||
| ($ctor:ident, $($arg:expr),+) => ({ | ||
| let obj = $ctor::new(name.local, prefix, document, $($arg),+); | ||
| Root::upcast(obj) | ||
| }) | ||
| ); | ||
splav
Author
Contributor
|
||
|
|
||
| if name.ns != ns!(html) { | ||
| if !PREFS.get("dom.svg.enabled").as_boolean().unwrap_or(false) { | ||
| return Element::new(name.local, name.ns, prefix, document); | ||
| } | ||
|
|
||
| match name.local { | ||
| atom!("svg") => make!(SVGSVGElement), | ||
| _ => Element::new(name.local, name.ns, prefix, document), | ||
| } | ||
| } | ||
|
|
||
| fn create_html_element(name: QualName, | ||
| prefix: Option<DOMString>, | ||
| document: &Document, | ||
| creator: ElementCreator) | ||
| -> Root<Element> { | ||
| assert!(name.ns == ns!(html)); | ||
|
|
||
| macro_rules! make( | ||
| ($ctor:ident) => ({ | ||
| let obj = $ctor::new(name.local, prefix, document); | ||
| @@ -249,3 +272,19 @@ pub fn create_element(name: QualName, | ||
| _ => make!(HTMLUnknownElement), | ||
| } | ||
| } | ||
|
|
||
| pub fn create_element(name: QualName, | ||
| prefix: Option<Atom>, | ||
| document: &Document, | ||
| creator: ElementCreator) | ||
| -> Root<Element> { | ||
| // FIXME(ajeffrey): Convert directly from Atom to DOMString. | ||
|
|
||
| let prefix = prefix.map(|p| DOMString::from(&*p)); | ||
|
|
||
| match name.ns { | ||
| ns!(html) => create_html_element(name, prefix, document, creator), | ||
| ns!(svg) => create_svg_element(name, prefix, document), | ||
| _ => Element::new(name.local, name.ns, prefix, document) | ||
| } | ||
| } | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Instead of duplicating the macro, it could be moved outside the function :)