Bug 84413

Summary: Use Vector<Attribute> directly instead of encapsulating it in AttributeVector
Product: WebKit Reporter: Caio Marcelo de Oliveira Filho <cmarcelo>
Component: New BugsAssignee: Caio Marcelo de Oliveira Filho <cmarcelo>
Status: RESOLVED FIXED    
Severity: Normal CC: kling, koivisto, oliver, ossy, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 83440, 84809    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Caio Marcelo de Oliveira Filho
Reported 2012-04-19 19:32:55 PDT
Use a typedef instead of inheriting WTF::Vector for AttributeVector
Attachments
Patch (19.39 KB, patch)
2012-04-19 19:52 PDT, Caio Marcelo de Oliveira Filho
no flags
Patch (8.78 KB, patch)
2012-04-24 09:26 PDT, Caio Marcelo de Oliveira Filho
no flags
Patch (8.48 KB, patch)
2012-04-24 09:51 PDT, Caio Marcelo de Oliveira Filho
no flags
Patch (19.39 KB, patch)
2012-04-24 10:45 PDT, Caio Marcelo de Oliveira Filho
no flags
Patch (19.45 KB, patch)
2012-04-25 10:34 PDT, Caio Marcelo de Oliveira Filho
no flags
Patch for landing (19.43 KB, patch)
2012-04-30 08:45 PDT, Caio Marcelo de Oliveira Filho
no flags
Caio Marcelo de Oliveira Filho
Comment 1 2012-04-19 19:52:23 PDT
Caio Marcelo de Oliveira Filho
Comment 2 2012-04-19 19:54:32 PDT
Antti Koivisto
Comment 3 2012-04-19 20:00:12 PDT
Better wait until more complex bug 83440 lands to minimize disruption.
Caio Marcelo de Oliveira Filho
Comment 4 2012-04-20 09:44:43 PDT
Ack.
Caio Marcelo de Oliveira Filho
Comment 5 2012-04-24 09:26:49 PDT
Andreas Kling
Comment 6 2012-04-24 09:41:46 PDT
Comment on attachment 138577 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138577&action=review Looks good, but let's fix up some things and make it great! > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:579 > - attributes.removeAttribute(nameAttr); > - attributes.removeAttribute(actionAttr); > - attributes.removeAttribute(promptAttr); > + removeAttribute(&attributes, nameAttr); > + removeAttribute(&attributes, actionAttr); > + removeAttribute(&attributes, promptAttr); Since this is the only user of removeAttribute(), we could write it as a loop that does a single pass across the attribute vector instead of 3 passes. > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:583 > - attributes.insertAttribute(Attribute(nameAttr, isindexTag.localName())); > + if (!getAttributeFromVector(&attributes, nameAttr)) > + attributes.append(Attribute(nameAttr, isindexTag.localName())); Given that the nameAttr is always removed just above, you don't need the getAttributeFromVector() check here. > Source/WebCore/html/parser/TextDocumentParser.cpp:64 > - attributes.insertAttribute(Attribute("style", "word-wrap: break-word; white-space: pre-wrap;")); > + attributes.append(Attribute("style", "word-wrap: break-word; white-space: pre-wrap;")); It would be slightly more efficient to pass HTMLNames::styleAttr rather than "style" here.
Antti Koivisto
Comment 7 2012-04-24 09:48:52 PDT
Comment on attachment 138577 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138577&action=review > Source/WebCore/dom/ElementAttributeData.h:39 > +typedef Vector<Attribute> AttributeVector; I think you should get rid of the AttributeVector type completely. Vector<Attribute>is not any harder to write and way less opaque.
Caio Marcelo de Oliveira Filho
Comment 8 2012-04-24 09:51:14 PDT
Caio Marcelo de Oliveira Filho
Comment 9 2012-04-24 10:45:57 PDT
Andreas Kling
Comment 10 2012-04-24 10:51:52 PDT
Comment on attachment 138594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138594&action=review r=me with these fixes: > Source/WebCore/dom/ElementAttributeData.h:39 > +inline Attribute* getAttributeFromVector(const Vector<Attribute>* attributes, const QualifiedName& name) - getAttributeFromVector doesn't sound very WebKit. findAttributeInVector would be slightly better. - The 'attributes' argument could be a const Vector<Attribute>&, that would remove the need for the ASSERT. - Also no need for the inline keyword.
Ryosuke Niwa
Comment 11 2012-04-24 10:54:12 PDT
Comment on attachment 138594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138594&action=review >> Source/WebCore/dom/ElementAttributeData.h:39 >> +inline Attribute* getAttributeFromVector(const Vector<Attribute>* attributes, const QualifiedName& name) > > - getAttributeFromVector doesn't sound very WebKit. findAttributeInVector would be slightly better. > - The 'attributes' argument could be a const Vector<Attribute>&, that would remove the need for the ASSERT. > - Also no need for the inline keyword. Yup, we use "get" prefix iff we have an out argument. > Source/WebCore/dom/ElementAttributeData.h:151 > +inline size_t ElementAttributeData::getAttributeItemIndex(const QualifiedName& name) const Ditto. > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:571 > + if (name.matches(nameAttr) || name.matches(actionAttr) || name.matches(promptAttr)) { > + attributes.remove(i); > + --i; > + } Would it be better to remember the indexes and bulk remove? Modifying a vector while iterating over the vector might be too clever.
Ryosuke Niwa
Comment 12 2012-04-24 11:04:11 PDT
Caio Marcelo de Oliveira Filho
Comment 13 2012-04-24 12:59:38 PDT
Oliver Hunt
Comment 14 2012-04-24 13:18:25 PDT
You appear to have broken the debug build :-( /Volumes/Data/git/WebKit/OpenSource/Source/WebCore/dom/ElementAttributeData.h:41:5: error: invalid argument type 'const Vector<WebCore::Attribute>' to unary expression ASSERT(attributes);
Csaba Osztrogonác
Comment 15 2012-04-24 13:41:59 PDT
Comment on attachment 138594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138594&action=review > Source/WebCore/dom/ElementAttributeData.h:41 > + ASSERT(attributes); Reopen, because it broke the debug build: ../../../../Source/WebCore/dom/ElementAttributeData.h: In function ‘WebCore::Attribute* WebCore::findAttributeInVector(const WTF::Vector<WebCore::Attribute, 0ul>&, const WebCore::QualifiedName&)’: ../../../../Source/WebCore/dom/ElementAttributeData.h:41: error: no match for ‘operator!’ in ‘!attributes’ ../../../../Source/WebCore/dom/ElementAttributeData.h:41: note: candidates are: operator!(bool) <built-in>
Caio Marcelo de Oliveira Filho
Comment 16 2012-04-24 13:46:18 PDT
Sorry folks. This should be fixed in http://trac.webkit.org/changeset/115102
Csaba Osztrogonác
Comment 17 2012-04-24 13:48:07 PDT
(In reply to comment #16) > Sorry folks. This should be fixed in http://trac.webkit.org/changeset/115102 Not problem, but I have to share this with you :)) http://webkitmemes.tumblr.com/post/21640883992/scumbag-good-guy-awesomekling
Andreas Kling
Comment 18 2012-04-24 17:20:43 PDT
Reopening since this is being rolled out. My blind fix stopped the crashing but left html5lib/runner.html with incorrect results.
Darin Adler
Comment 19 2012-04-24 17:51:59 PDT
Comment on attachment 138594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138594&action=review > Source/WebCore/xml/parser/MarkupTokenBase.h:542 > + const QualifiedName name = nameForAttribute(attribute); I think you mean to say: const QualifiedName& name
Caio Marcelo de Oliveira Filho
Comment 20 2012-04-25 10:34:59 PDT
Caio Marcelo de Oliveira Filho
Comment 21 2012-04-30 08:45:26 PDT
Created attachment 139457 [details] Patch for landing
WebKit Review Bot
Comment 22 2012-04-30 09:57:32 PDT
Comment on attachment 139457 [details] Patch for landing Clearing flags on attachment: 139457 Committed r115645: <http://trac.webkit.org/changeset/115645>
WebKit Review Bot
Comment 23 2012-04-30 09:57:40 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.