WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
97644
Attr.ownerDocument should change if its parent's owner did
https://bugs.webkit.org/show_bug.cgi?id=97644
Summary
Attr.ownerDocument should change if its parent's owner did
Hajime Morrita
Reported
2012-09-26 01:28:17 PDT
Currently Attr.ownerDocument doesn't change even if its holding element's owner changed.
Attachments
Patch
(6.71 KB, patch)
2012-09-26 01:31 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch for landing
(5.42 KB, patch)
2013-01-16 18:12 PST
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch for landing
(5.41 KB, patch)
2013-01-16 19:39 PST
,
Hajime Morrita
webkit.review.bot
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Hajime Morrita
Comment 1
2012-09-26 01:31:44 PDT
Created
attachment 165749
[details]
Patch
Alexey Proskuryakov
Comment 2
2012-09-27 11:05:19 PDT
This appears to slow down moving elements just to make a very rare operation correct. Would it be possible to change Attr.ownerDocument implementation instead, so that it would get the owner document from element?
Ryosuke Niwa
Comment 3
2012-09-27 16:27:15 PDT
(In reply to
comment #2
)
> This appears to slow down moving elements just to make a very rare operation correct. Would it be possible to change Attr.ownerDocument implementation instead, so that it would get the owner document from element?
Unfortunately, ownerDocument() is implemented in Node so that doesn't work. On the other hand, I don't expect Attr to exist on most elements so the perf. impact should be minimal.
Ryosuke Niwa
Comment 4
2012-09-27 16:31:04 PDT
Comment on
attachment 165749
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
> Source/WebCore/dom/TreeScopeAdopter.cpp:65 > + Vector<Attr*> attrs;
Do we really need to have a local Vector for this? Attr can only have character data & entities, no?
Hajime Morrita
Comment 5
2012-09-27 18:13:42 PDT
Comment on
attachment 165749
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
>> Source/WebCore/dom/TreeScopeAdopter.cpp:65 >> + Vector<Attr*> attrs; > > Do we really need to have a local Vector for this? Attr can only have character data & entities, no?
It doesn't matter which item Attr can have. This Attr list is owned by Element and getExistingAttrs() grubs it. We could just return AttrList, which is defined locally in ElementAttributeData.cpp. But it looks we want to hide the implementation detail so I'm doing like this.
Hajime Morrita
Comment 6
2012-09-27 18:20:28 PDT
(In reply to
comment #3
)
> (In reply to
comment #2
) > > This appears to slow down moving elements just to make a very rare operation correct. Would it be possible to change Attr.ownerDocument implementation instead, so that it would get the owner document from element? > > Unfortunately, ownerDocument() is implemented in Node so that doesn't work. On the other hand, I don't expect Attr to exist on most elements so the perf. impact should be minimal.
Yeah, good news is that this doesn't happen in many cases. This path is hit only when the node is moved between document (TreeScope in precise.) Moving XHR.responseXML to the host document would be almost only relevant usecase in the real world, whose performance regression, if any, will be hidden behind network latency.
Ryosuke Niwa
Comment 7
2012-09-27 18:51:48 PDT
Comment on
attachment 165749
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
>>> Source/WebCore/dom/TreeScopeAdopter.cpp:65 >>> + Vector<Attr*> attrs; >> >> Do we really need to have a local Vector for this? Attr can only have character data & entities, no? > > It doesn't matter which item Attr can have. This Attr list is owned by Element and getExistingAttrs() grubs it. > We could just return AttrList, which is defined locally in ElementAttributeData.cpp. But it looks we want to hide the implementation detail > so I'm doing like this.
IMO, encapsulation is not a good enough reason to allocate another Vector. We should just retrieve const Vector<RefPtr<Attr> >& instead. anttik or kling might have a strong opinion here.
Ryosuke Niwa
Comment 8
2012-09-27 18:54:05 PDT
Let me phrase it differently. The fact we have a Vector<RefPtr<Attr> > in ElementAttributeData doesn't seem like something we need to hide at the cost of cloning a heap-allocated object.
Andreas Kling
Comment 9
2012-09-27 19:03:26 PDT
(In reply to
comment #7
)
> (From update of
attachment 165749
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
> > >>> Source/WebCore/dom/TreeScopeAdopter.cpp:65 > >>> + Vector<Attr*> attrs; > >> > >> Do we really need to have a local Vector for this? Attr can only have character data & entities, no? > > > > It doesn't matter which item Attr can have. This Attr list is owned by Element and getExistingAttrs() grubs it. > > We could just return AttrList, which is defined locally in ElementAttributeData.cpp. But it looks we want to hide the implementation detail > > so I'm doing like this. > > IMO, encapsulation is not a good enough reason to allocate another Vector. > We should just retrieve const Vector<RefPtr<Attr> >& instead. > anttik or kling might have a strong opinion here.
No strong opinion, though I guess I'd prefer if we can avoid spreading the implementation details of Attr too much. The API is not part of DOM4, and sees very little use on the current web.
Alexey Proskuryakov
Comment 10
2012-09-28 09:36:22 PDT
It may be worth sending a note to webkit-dev to solicit thoughts about performance.
Darin Adler
Comment 11
2013-01-16 13:12:12 PST
Comment on
attachment 165749
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
> Source/WebCore/dom/TreeScopeAdopter.cpp:51 > if (oldDocument && willMoveToNewDocument) > oldDocument->incDOMTreeVersion();
One thing I don’t like about this TreeScopeAdopter factoring (not new to this patch) is that this one call to incDOMTreeVersion is now here in this file. All the others are in core files like Element.cpp yet this one stray one is out here in the “hinterlands”. Yuck.
>>>>> Source/WebCore/dom/TreeScopeAdopter.cpp:65 >>>>> + Vector<Attr*> attrs; >>>> >>>> Do we really need to have a local Vector for this? Attr can only have character data & entities, no? >>> >>> It doesn't matter which item Attr can have. This Attr list is owned by Element and getExistingAttrs() grubs it. >>> We could just return AttrList, which is defined locally in ElementAttributeData.cpp. But it looks we want to hide the implementation detail >>> so I'm doing like this. >> >> IMO, encapsulation is not a good enough reason to allocate another Vector. >> We should just retrieve const Vector<RefPtr<Attr> >& instead. >> anttik or kling might have a strong opinion here. > > No strong opinion, though I guess I'd prefer if we can avoid spreading the implementation details of Attr too much. The API is not part of DOM4, and sees very little use on the current web.
It does seem gratuitous to copy the vector just for a slightly larger theoretical level of encapsulation. I agree with Ryosuke that returning a "const Vector<RefPtr<Attr> >&" from an existingAttrs function would be fine. It exposes implementation detail, but in a harmless way that is easy to change later. If the encapsulation really is an issue, then one way to keep tighter encapsulation without copying would be to expose a function, perhaps a template, that applies a passed-in function object to all attrs, then pass it an an object that does this->moveTreeToNewScope(x). But moving a Node between documents that has some associated Attr should be rare enough that I suppose any of these designs would be OK; the performance should not be critical. I wonder how far we are from being able to remove the Attr feature from our engine? That would be the best solution, by far!
Hajime Morrita
Comment 12
2013-01-16 18:11:09 PST
Comment on
attachment 165749
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=165749&action=review
>>>>>> Source/WebCore/dom/TreeScopeAdopter.cpp:65 >>>>>> + Vector<Attr*> attrs; >>>>> >>>>> Do we really need to have a local Vector for this? Attr can only have character data & entities, no? >>>> >>>> It doesn't matter which item Attr can have. This Attr list is owned by Element and getExistingAttrs() grubs it. >>>> We could just return AttrList, which is defined locally in ElementAttributeData.cpp. But it looks we want to hide the implementation detail >>>> so I'm doing like this. >>> >>> IMO, encapsulation is not a good enough reason to allocate another Vector. >>> We should just retrieve const Vector<RefPtr<Attr> >& instead. >>> anttik or kling might have a strong opinion here. >> >> No strong opinion, though I guess I'd prefer if we can avoid spreading the implementation details of Attr too much. The API is not part of DOM4, and sees very little use on the current web. > > It does seem gratuitous to copy the vector just for a slightly larger theoretical level of encapsulation. I agree with Ryosuke that returning a "const Vector<RefPtr<Attr> >&" from an existingAttrs function would be fine. It exposes implementation detail, but in a harmless way that is easy to change later. > > If the encapsulation really is an issue, then one way to keep tighter encapsulation without copying would be to expose a function, perhaps a template, that applies a passed-in function object to all attrs, then pass it an an object that does this->moveTreeToNewScope(x). > > But moving a Node between documents that has some associated Attr should be rare enough that I suppose any of these designs would be OK; the performance should not be critical. > > I wonder how far we are from being able to remove the Attr feature from our engine? That would be the best solution, by far!
OK, keeping encapsulation here looks overkill. I'll take what Ryosuke is suggesting.
Hajime Morrita
Comment 13
2013-01-16 18:12:21 PST
Created
attachment 183080
[details]
Patch for landing
WebKit Review Bot
Comment 14
2013-01-16 18:42:16 PST
Comment on
attachment 183080
[details]
Patch for landing Rejecting
attachment 183080
[details]
from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 cwd: /mnt/git/webkit-commit-queue Last 500 characters of output: rce/WebKit/chromium/webkit/media/crypto/ppapi/cdm --revision 173055 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' 56>At revision 173055. ________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' ________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' Updating webkit projects from gyp files... Full output:
http://queues.webkit.org/results/15905711
Hajime Morrita
Comment 15
2013-01-16 19:39:14 PST
Created
attachment 183102
[details]
Patch for landing
WebKit Review Bot
Comment 16
2013-01-16 20:15:01 PST
Comment on
attachment 183102
[details]
Patch for landing Rejecting
attachment 183102
[details]
from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 cwd: /mnt/git/webkit-commit-queue Last 500 characters of output: e/WebKit/chromium/third_party/skia/include/core/SkShader.h 50>U /mnt/git/webkit-commit-queue/Source/WebKit/chromium/third_party/skia/include/core/SkTDArray.h 51>Updated to revision 7212. 50>Updated to revision 7212. ________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' ________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' Updating webkit projects from gyp files... Full output:
http://queues.webkit.org/results/15910732
Hajime Morrita
Comment 17
2013-01-16 20:16:41 PST
Hmm. cq looks being in trouble.
Hajime Morrita
Comment 18
2013-01-16 20:24:12 PST
Committed
r139958
: <
http://trac.webkit.org/changeset/139958
>
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