WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
23940
Use Document::createElement(const QualifiedName&, bool) when creating a known element inside WebCore
https://bugs.webkit.org/show_bug.cgi?id=23940
Summary
Use Document::createElement(const QualifiedName&, bool) when creating a known...
Julien Chaffraix
Reported
2009-02-12 17:44:30 PST
Patch forthcoming.
Attachments
Proposed changes
(21.34 KB, patch)
2009-02-12 17:51 PST
,
Julien Chaffraix
ap
: review-
Details
Formatted Diff
Diff
Updated version: should solve Alexey's comments
(21.59 KB, patch)
2009-02-18 02:00 PST
,
Julien Chaffraix
ap
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Julien Chaffraix
Comment 1
2009-02-12 17:51:00 PST
Created
attachment 27635
[details]
Proposed changes
Alexey Proskuryakov
Comment 2
2009-02-17 02:46:09 PST
Comment on
attachment 27635
[details]
Proposed changes @@ -969,9 +969,8 @@ void Document::setTitle(const String& ti m_titleElement = 0; else if (!m_titleElement) { if (HTMLElement* headElement = head()) { + m_titleElement = createElement(titleTag, false); ExceptionCode ec = 0; - m_titleElement = createElement("title", ec); I think that this changes the behavior for SVG documents - previously, QualifiedName(nullAtom, "title", nullAtom) was used via createElement(). Is this intentional? Please add a test case for this regardless. - RefPtr<Element> reportElement = doc->createElementNS(HTMLNames::xhtmlNamespaceURI, "parsererror", ec); - reportElement->setAttribute(HTMLNames::styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"); + RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), true); This changes createdByParser from false to true - is it intentional? I don't see how that is correct. Same question elsewhere in error header creation code. - // make the span to hold the tab + // Make the span to hold the tab It's great to fix comments - we also prefer to have periods at the end of full sentences. I like this patch a lot! r- for now, to consider the comments.
Julien Chaffraix
Comment 3
2009-02-17 11:21:04 PST
(In reply to
comment #2
)
> (From update of
attachment 27635
[details]
[review]) > @@ -969,9 +969,8 @@ void Document::setTitle(const String& ti > m_titleElement = 0; > else if (!m_titleElement) { > if (HTMLElement* headElement = head()) { > + m_titleElement = createElement(titleTag, false); > ExceptionCode ec = 0; > - m_titleElement = createElement("title", ec); > > I think that this changes the behavior for SVG documents - previously, > QualifiedName(nullAtom, "title", nullAtom) was used via createElement(). Is > this intentional? Please add a test case for this regardless.
Yes, it is. We are creating a title tag for an HTML document (there is a "if(!HTMLDocument()) ... else" guard above). I can add a test case if you request it in light of my point. As you were pointing out, there will be a change in behaviour for all my createElement(const AtomicString&, ...) -> createElement(const QualifiedName&, bool) changes. I have double-checked all the changes and the only problematic change I see is in DragController - the other changes are (X)HTML-specific. I do not think that creating an element in the null namespace is right either.
> - RefPtr<Element> reportElement = > doc->createElementNS(HTMLNames::xhtmlNamespaceURI, "parsererror", ec); > - reportElement->setAttribute(HTMLNames::styleAttr, "display: block; > white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; > background-color: #fdd; color: black"); > + RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, > "parsererror", xhtmlNamespaceURI), true); > > This changes createdByParser from false to true - is it intentional? I don't > see how that is correct. > > Same question elsewhere in error header creation code. >
This is called from the parser so I have though it was correct to set createdByParser to true. I have no strong feelings about the value given thought.
> - // make the span to hold the tab > + // Make the span to hold the tab > > It's great to fix comments - we also prefer to have periods at the end of full > sentences.
Right, I have missed that.
Alexey Proskuryakov
Comment 4
2009-02-17 11:33:23 PST
(In reply to
comment #3
)
> Yes, it is. We are creating a title tag for an HTML document (there is a > "if(!HTMLDocument()) ... else" guard above). I can add a test case if you > request it in light of my point.
My mistake. I don't think this needs a test case now.
> the only problematic > change I see is in DragController - the other changes are (X)HTML-specific.
I think DragController is fine, too -the results was casted to HTMLAnchorElement* anyway. I wonder if the cast can be avoided altogether by creating the element more directly.
> This is called from the parser so I have though it was correct to set > createdByParser to true. I have no strong feelings about the value given > thought.
Let's change it back then - from my understanding of the code, "createdByParser" is tightly coupled to the parser behavior, which is unlikely to be followed here.
Julien Chaffraix
Comment 5
2009-02-18 01:50:24 PST
> > the only problematic > > change I see is in DragController - the other changes are (X)HTML-specific. > > I think DragController is fine, too -the results was casted to > HTMLAnchorElement* anyway. I wonder if the cast can be avoided altogether by > creating the element more directly.
Right, I have missed the cast. I will make this change too as a short-term enhancement but I feel more and more that such manual creation are bad and will backfire on us someday. We should have the Elements' factories exports a way to create a "default" element using the static names.
> Let's change it back then - from my understanding of the code, > "createdByParser" is tightly coupled to the parser behavior, which is unlikely > to be followed here.
Ok.
Julien Chaffraix
Comment 6
2009-02-18 02:00:35 PST
Created
attachment 27744
[details]
Updated version: should solve Alexey's comments
Alexey Proskuryakov
Comment 7
2009-02-18 03:27:47 PST
Comment on
attachment 27744
[details]
Updated version: should solve Alexey's comments r=me
Julien Chaffraix
Comment 8
2009-02-20 16:17:00 PST
Landed in
r41120
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug