WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 110263
Add the default video poster if it doesn't exist in video tag
https://bugs.webkit.org/show_bug.cgi?id=110263
Summary
Add the default video poster if it doesn't exist in video tag
michaelbai
Reported
2013-02-19 14:27:44 PST
The Android web view application could provide the default poster for a video that doesn't have the poster attribute. To provide the default poster, the application must set defaultVideoPosterURL setting and return the image in the response of that URL.
Attachments
Patch
(2.63 KB, patch)
2013-02-19 15:06 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(2.65 KB, patch)
2013-02-19 15:09 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(10.20 KB, patch)
2013-02-20 12:25 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(10.38 KB, patch)
2013-02-20 13:48 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(11.44 KB, patch)
2013-02-21 11:19 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(11.81 KB, patch)
2013-02-21 14:02 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(13.12 KB, patch)
2013-02-22 14:29 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(13.21 KB, patch)
2013-02-22 14:57 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(13.25 KB, patch)
2013-02-25 10:05 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(13.33 KB, patch)
2013-02-26 12:00 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(13.48 KB, patch)
2013-02-28 13:25 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(92.48 KB, patch)
2013-03-05 18:10 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(29.36 KB, patch)
2013-03-06 14:15 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(31.25 KB, patch)
2013-03-06 15:51 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(31.88 KB, patch)
2013-03-08 00:19 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(32.06 KB, patch)
2013-03-08 18:03 PST
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(36.92 KB, patch)
2013-03-12 10:53 PDT
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(29.50 KB, patch)
2013-03-13 10:35 PDT
,
michaelbai
no flags
Details
Formatted Diff
Diff
Patch
(29.50 KB, patch)
2013-03-13 13:14 PDT
,
michaelbai
no flags
Details
Formatted Diff
Diff
Show Obsolete
(18)
View All
Add attachment
proposed patch, testcase, etc.
michaelbai
Comment 1
2013-02-19 15:06:07 PST
Created
attachment 189171
[details]
Patch
michaelbai
Comment 2
2013-02-19 15:09:08 PST
Created
attachment 189174
[details]
Patch
Eric Carlson
Comment 3
2013-02-19 16:18:23 PST
Comment on
attachment 189174
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=189174&action=review
> Source/WebCore/ChangeLog:15 > + No new tests, covered by existing tests.
How is this new functionallity covered by existing tests?
michaelbai
Comment 4
2013-02-19 16:24:14 PST
Sorry, I just found out I could write a Layout test to test this feature, I am working on it.
michaelbai
Comment 5
2013-02-20 12:25:11 PST
Created
attachment 189357
[details]
Patch
michaelbai
Comment 6
2013-02-20 13:48:34 PST
Created
attachment 189368
[details]
Patch
Philippe Normand
Comment 7
2013-02-21 02:34:51 PST
GTK build fails because the new symbols are not referenced in Source/autotools/symbols.filter
Eric Carlson
Comment 8
2013-02-21 07:32:10 PST
Comment on
attachment 189368
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=189368&action=review
Marking r- because of the GTK problem.
> LayoutTests/media/video-default-poster.html:17 > + document.getElementById("result-no-poster").innerText = > + poster.value == default_poster ? "PASS" : "FAIL";
Nit: I think the line break + ternary make this more difficult to understand instead of easier.
> LayoutTests/media/video-default-poster.html:20 > + } else { > + document.getElementById("result-no-poster").innerText = "FAIL: poster attribute is null"; > + }
Nit: single line if conditionals don't need braces.
> LayoutTests/media/video-default-poster.html:27 > + if (poster) { > + document.getElementById("result-has-poster").innerText = > + poster.value == "content/abe.png" ? "PASS" : "FAIL: poster was changed"; > + } else { > + document.getElementById("result-has-poster").innerText = "FAIL: poster attribute is null"; > + }
Dittos.
> LayoutTests/media/video-no-default-poster.html:21 > + document.getElementById("result-no-poster").innerText = > + poster ? "FAIL : poster was added." : "PASS"; > + poster = document.getElementById("video-has-poster").getAttributeNode("poster"); > + if (poster) { > + document.getElementById("result-has-poster").innerText = > + poster.value == "content/abe.png" ? "PASS" : "FAIL: poster was changed"; > + } else { > + document.getElementById("result-has-poster").innerText = "FAIL: poster attribute is null"; > + }
Dittos.
michaelbai
Comment 9
2013-02-21 11:19:08 PST
Created
attachment 189562
[details]
Patch
Eric Carlson
Comment 10
2013-02-21 13:27:21 PST
Comment on
attachment 189562
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=189562&action=review
> Source/WebCore/ChangeLog:22 > + (WebCore::HTMLVideoElement::attach): > + * page/Settings.in: > + * testing/InternalSettings.cpp: > + (WebCore::InternalSettings::Backup::Backup): > + (WebCore::InternalSettings::Backup::restoreTo): > + (WebCore::InternalSettings::setDefaultVideoPosterURL): > + (WebCore): > + * testing/InternalSettings.h: > + (Backup): > + (InternalSettings): > + * testing/InternalSettings.idl:
Sorry I didn't notice this before, but it is helpful to have per-method comments about what changed here.
> LayoutTests/media/video-default-poster.html:11 > + var default_poster = "about:blank";
Why use an invalid poster?
> LayoutTests/media/video-default-poster.html:17 > + if (poster) { > + if (poster.value) > + document.getElementById("result-no-poster").innerText = "PASS";
Shouldn't this test the poster value before declaring success?
> ChangeLog:8 > + * Source/autotools/symbols.filter:
Ditto.
michaelbai
Comment 11
2013-02-21 14:02:03 PST
Created
attachment 189596
[details]
Patch
michaelbai
Comment 12
2013-02-21 14:05:21 PST
Comment on
attachment 189562
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=189562&action=review
>> Source/WebCore/ChangeLog:22 >> + * testing/InternalSettings.idl: > > Sorry I didn't notice this before, but it is helpful to have per-method comments about what changed here.
Never mind, Done
>> LayoutTests/media/video-default-poster.html:11 >> + var default_poster = "about:blank"; > > Why use an invalid poster?
I were trying to use content/abe.png, but the test failed because content/abe.png is not a valid URL for KURL's GURL implementation. The default poster URL couldn't be related path in practice, so it shouldn't be an issue.
>> LayoutTests/media/video-default-poster.html:17 >> + document.getElementById("result-no-poster").innerText = "PASS"; > > Shouldn't this test the poster value before declaring success?
Done
>> ChangeLog:8 >> + * Source/autotools/symbols.filter: > > Ditto.
Done
Build Bot
Comment 13
2013-02-22 14:11:08 PST
Comment on
attachment 189596
[details]
Patch
Attachment 189596
[details]
did not pass win-ews (win): Output:
http://queues.webkit.org/results/16722088
Eric Carlson
Comment 14
2013-02-22 14:14:25 PST
(In reply to
comment #13
)
> (From update of
attachment 189596
[details]
) >
Attachment 189596
[details]
did not pass win-ews (win): > Output:
http://queues.webkit.org/results/16722088
10>WebCoreTestSupport.lib(InternalSettings.obj) : error LNK2019: unresolved external symbol "public: __thiscall WebCore::KURL::KURL(enum WebCore::ParsedURLStringTag,class WTF::String const &)" (??0KURL@WebCore@@QAE@W4ParsedURLStringTag@
1@ABVString@WTF@@@Z
) referenced in function "public: void __thiscall WebCore::InternalSettings::Backup::restoreTo(class WebCore::Settings *)" (?restoreTo@Backup@InternalSettings@WebCore@@QAEXPAVSettings@
3@@Z
)
michaelbai
Comment 15
2013-02-22 14:29:54 PST
Created
attachment 189829
[details]
Patch
michaelbai
Comment 16
2013-02-22 14:32:10 PST
This should fix win bot.
Eric Carlson
Comment 17
2013-02-22 14:35:59 PST
(In reply to
comment #16
)
> This should fix win bot.
Looks like you need to rebase the patch: Last 500 characters of output: ebKitExports.def.in.rej patching file Source/autotools/symbols.filter Hunk #1 succeeded at 272 (offset 10 lines). patching file LayoutTests/ChangeLog Hunk #1 succeeded at 1 with fuzz 3. patching file LayoutTests/media/video-default-poster-expected.txt patching file LayoutTests/media/video-default-poster.html patching file LayoutTests/media/video-no-default-poster-expected.txt patching file LayoutTests/media/video-no-default-poster.html patching file ChangeLog Hunk #1 succeeded at 1 with fuzz 3.
michaelbai
Comment 18
2013-02-22 14:57:06 PST
Created
attachment 189839
[details]
Patch
michaelbai
Comment 19
2013-02-22 21:37:32 PST
Why win bot didn't showup?
michaelbai
Comment 20
2013-02-25 10:05:03 PST
Created
attachment 190080
[details]
Patch
michaelbai
Comment 21
2013-02-25 10:06:04 PST
Rebase again.
Darin Adler
Comment 22
2013-02-25 10:20:44 PST
(In reply to
comment #12
)
> >> LayoutTests/media/video-default-poster.html:11 > >> + var default_poster = "about:blank"; > > > > Why use an invalid poster? > > I were trying to use content/abe.png, but the test failed because content/abe.png is not a valid URL for KURL's GURL implementation. > The default poster URL couldn't be related path in practice, so it shouldn't be an issue.
The test can construct an absolute URL for content/abe.png.
michaelbai
Comment 23
2013-02-25 11:51:19 PST
(In reply to
comment #22
)
> (In reply to
comment #12
) > > >> LayoutTests/media/video-default-poster.html:11 > > >> + var default_poster = "about:blank"; > > > > > > Why use an invalid poster? > > > > I were trying to use content/abe.png, but the test failed because content/abe.png is not a valid URL for KURL's GURL implementation. > > The default poster URL couldn't be related path in practice, so it shouldn't be an issue. > > The test can construct an absolute URL for content/abe.png.
Would you like point an example to me, thanks?
michaelbai
Comment 24
2013-02-25 14:56:45 PST
(In reply to
comment #23
)
> (In reply to
comment #22
) > > (In reply to
comment #12
) > > > >> LayoutTests/media/video-default-poster.html:11 > > > >> + var default_poster = "about:blank"; > > > > > > > > Why use an invalid poster? > > > > > > I were trying to use content/abe.png, but the test failed because content/abe.png is not a valid URL for KURL's GURL implementation. > > > The default poster URL couldn't be related path in practice, so it shouldn't be an issue. > > > > The test can construct an absolute URL for content/abe.png. > > Would you like point an example to me, thanks?
I just found out the testcase's URL with window.location, it is the file name itself, like 'video-default-poster.html', so I guess use 'about:blank' is a good way here.
Darin Adler
Comment 25
2013-02-26 09:26:20 PST
(In reply to
comment #24
)
> I just found out the testcase's URL with window.location, it is the file name itself, like 'video-default-poster.html', so I guess use 'about:blank' is a good way here.
Did you try document.URL?
michaelbai
Comment 26
2013-02-26 10:07:00 PST
(In reply to
comment #25
)
> (In reply to
comment #24
) > > I just found out the testcase's URL with window.location, it is the file name itself, like 'video-default-poster.html', so I guess use 'about:blank' is a good way here. > > Did you try document.URL?
It is same, gives file name itself.
Darin Adler
Comment 27
2013-02-26 10:14:02 PST
(In reply to
comment #26
)
> It is same, gives file name itself.
Strange, given the many tests that use document.URL such as fast/loader/external-script-URL-location.html.
Eric Carlson
Comment 28
2013-02-26 10:39:09 PST
(In reply to
comment #26
)
> It is same, gives file name itself.
Something is strange. I modified your test to just log window.location.href: <!DOCTYPE html> <html> <head> <script> if (window.testRunner) { testRunner.dumpAsText(); testRunner.waitUntilDone(); } if (window.internals) { addEventListener("load", function() { alert(window.location.href); testRunner.notifyDone(); }, false); } </script> </head> <body> <pre id="result-no-poster"></pre> <pre id="result-has-poster"></pre> <video id="video-no-poster" src="content/test.mp4" preload="none" /> <video id="video-has-poster" src="content/test.mp4" poster="content/abe.png" preload="none" /> </body> </html> and the result is ALERT: file:///Volumes/User/WebKit/Sources/OpenSource/LayoutTests/media/temp.html
michaelbai
Comment 29
2013-02-26 10:44:20 PST
Would you like me to know how did you run it? I ran the test with the following command, perl Tools/Scripts/run-webkit-tests --chromium --debug LayoutTests/media/video-default-poster.html I think this might be the reason I only got the file name itself.
michaelbai
Comment 30
2013-02-26 10:51:58 PST
(In reply to
comment #27
)
> (In reply to
comment #26
) > > It is same, gives file name itself. > > Strange, given the many tests that use document.URL such as fast/loader/external-script-URL-location.html.
This test also passed when I ran it with perl Tools/Scripts/run-webkit-tests --chromium --debug LayoutTests/fast/loader/external-script-URL-location.html The test passed even the Document.URL doesn't have '/'.
michaelbai
Comment 31
2013-02-26 11:33:33 PST
It seemed that console.log only output the relative path. I will provide another patch.
michaelbai
Comment 32
2013-02-26 12:00:50 PST
Created
attachment 190338
[details]
Patch
michaelbai
Comment 33
2013-02-26 12:01:58 PST
Changed to construct URL in Javascript, PTAL
Eric Carlson
Comment 34
2013-02-26 12:31:32 PST
Comment on
attachment 190338
[details]
Patch Thank you for updating the test!
Darin Adler
Comment 35
2013-02-26 17:58:30 PST
Comment on
attachment 190338
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=190338&action=review
> Source/WebCore/html/HTMLVideoElement.cpp:90 > + setAttribute(posterAttr, defaultVideoPosterURL.string());
I don’t know why I didn’t notice this earlier. This is not the right way to do it! We should do this logic when getting the poster attribute. We shouldn’t actually set the poster attribute on an element. It’s not good to have an element that modifies itself during the attach process -- it could even lead to a security bug.
michaelbai
Comment 36
2013-02-26 20:23:38 PST
(In reply to
comment #35
)
> (From update of
attachment 190338
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=190338&action=review
> > > Source/WebCore/html/HTMLVideoElement.cpp:90 > > + setAttribute(posterAttr, defaultVideoPosterURL.string()); > > I don’t know why I didn’t notice this earlier. This is not the right way to do it! We should do this logic when getting the poster attribute. We shouldn’t actually set the poster attribute on an element. It’s not good to have an element that modifies itself during the attach process -- it could even lead to a security bug.
Would you like me know why there is a security bug here? What the right way to do this?
michaelbai
Comment 37
2013-02-27 07:59:17 PST
Hi Darin, Only Android web view application will enable this feature, beside this there is no API or UI coud access this, the application could do whatever they would like and it is the user's choice to trust the application. It shouldn't have security issue here. In another word, it has no impact to the rest of the world. Thanks
michaelbai
Comment 38
2013-02-28 13:25:43 PST
Created
attachment 190796
[details]
Patch
michaelbai
Comment 39
2013-03-01 08:47:11 PST
ping...
Darin Adler
Comment 40
2013-03-05 11:51:22 PST
(In reply to
comment #37
)
> Only Android web view application will enable this feature, beside this there is no API or UI coud access this, the application could do whatever they would like and it is the user's choice to trust the application. It shouldn't have security issue here.
Your analysis is incorrect. If this Android web view app loads content from the web, the web content could exploit the bug and take advantage of it to run arbitrary code.
michaelbai
Comment 41
2013-03-05 11:55:11 PST
(In reply to
comment #40
)
> (In reply to
comment #37
) > > Only Android web view application will enable this feature, beside this there is no API or UI coud access this, the application could do whatever they would like and it is the user's choice to trust the application. It shouldn't have security issue here. > > Your analysis is incorrect. If this Android web view app loads content from the web, the web content could exploit the bug and take advantage of it to run arbitrary code.
Thanks for reply, I still not quite understand how the security issue could happen? Did you mean load the poster image could run arbitrary code?
Darin Adler
Comment 42
2013-03-05 11:58:31 PST
The correct way to do this is to put this logic into the code that fetches the poster. We should not actually change the poster attribute on the DOM element, instead we should fetch the appropriate poster. The way to do this would be: A) Replace the Element::imageSourceAttributeName function with an Element::imageSourceURL function that returns the imageSourceURL as a const AtomicString&. The body will be the same as before, it will just also include a call to getAttribute. Also will need to revise the four classes that override that function. B) Add a new HTMLVideoElement::posterImageURL function that implements the default poster URL logic. C) Update the four functions that get the poster attribute to handle poster loading and display to call posterImageURL. 1) HTMLVideoElement::imageSourceURL. 2) HTMLVideoElement::setDisplayMode. 3) HTMLVideoElement::updateDisplayState. 4) HTMLMediaElement::getPluginProxyParams. Will need to cast to HTMLVideoElement after checking isVideo. That’s the correct way to fix this.
Darin Adler
Comment 43
2013-03-05 11:59:42 PST
(In reply to
comment #41
)
> Did you mean load the poster image could run arbitrary code?
Setting a poster DOM attribute will allow handlers on the webpage to run arbitrary JavaScript during the attach process. Running arbitrary JavaScript at that time can result in the engine following stale pointers, which is exploitable to run arbitrary code.
michaelbai
Comment 44
2013-03-05 18:10:31 PST
Created
attachment 191627
[details]
Patch
michaelbai
Comment 45
2013-03-05 18:11:50 PST
Comment on
attachment 191627
[details]
Patch Not for review, just want to try
Eric Carlson
Comment 46
2013-03-06 09:47:49 PST
Comment on
attachment 191627
[details]
Patch Drive by comment: I would recommend only removing extraneous white-space in functions where you are also changing code. Removing it as you have here makes it harder to pick out what you have actually changed.
michaelbai
Comment 47
2013-03-06 14:15:32 PST
Created
attachment 191830
[details]
Patch
michaelbai
Comment 48
2013-03-06 14:17:31 PST
I should add new symbols in Source/WebCore/WebCore.order, but don't have corresponding platform, will add them once error appears in bots.
Stephen Chenney
Comment 49
2013-03-06 14:56:08 PST
Comment on
attachment 191830
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=191830&action=review
> Source/WebCore/ChangeLog:16 > +
Nowhere here do you explain why imageSourceAttributeName must be changed to imageSourceURL, which seems to be a signficant outcome of this patch.
michaelbai
Comment 50
2013-03-06 15:03:55 PST
(In reply to
comment #49
)
> (From update of
attachment 191830
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=191830&action=review
> > > Source/WebCore/ChangeLog:16 > > + > > Nowhere here do you explain why imageSourceAttributeName must be changed to imageSourceURL, which seems to be a signficant outcome of this patch.
I followed Darin Adler's suggestion (refer comments 42), actually, the return value from imageSourceAttributeName() ends up with getAttribute(imageSourceAttributeName()), it's exactly same as the default implementation of imageSourceURL() does.
Stephen Chenney
Comment 51
2013-03-06 15:05:50 PST
(In reply to
comment #50
)
> (In reply to
comment #49
) > > (From update of
attachment 191830
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=191830&action=review
> > > > > Source/WebCore/ChangeLog:16 > > > + > > > > Nowhere here do you explain why imageSourceAttributeName must be changed to imageSourceURL, which seems to be a signficant outcome of this patch. > > I followed Darin Adler's suggestion (refer comments 42), actually, the return value from imageSourceAttributeName() ends up with getAttribute(imageSourceAttributeName()), it's exactly same as the default implementation of imageSourceURL() does.
Yes, but I believe the ChangeLog should say something. Probably just repeat Darin's outline of the change.
michaelbai
Comment 52
2013-03-06 15:51:19 PST
Created
attachment 191856
[details]
Patch
michaelbai
Comment 53
2013-03-06 15:52:12 PST
Update ChangeLog, thanks
michaelbai
Comment 54
2013-03-08 00:19:00 PST
Created
attachment 192167
[details]
Patch
Stephen Chenney
Comment 55
2013-03-08 06:37:29 PST
Comment on
attachment 192167
[details]
Patch Looks good to me, but I think Darin should give the final word. I'm ultimately not an expert in this area.
Build Bot
Comment 56
2013-03-08 07:24:07 PST
Comment on
attachment 192167
[details]
Patch
Attachment 192167
[details]
did not pass mac-ews (mac): Output:
http://webkit-commit-queue.appspot.com/results/17007165
New failing tests: editing/selection/selection-modify-crash.html
Darin Adler
Comment 57
2013-03-08 16:30:25 PST
Comment on
attachment 192167
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192167&action=review
Looks OK, but breaks whitespace handling in video element poster URLs. I’m surprised there was no test for this that is broken. Please fix that.
> Source/WebCore/html/HTMLVideoElement.cpp:312 > + const AtomicString& url = imageSourceURL();
It’s a shame to make a virtual function call here. No big deal, but not ideal either.
> Source/WebCore/html/HTMLVideoElement.cpp:315 > + if (url.isEmpty()) > + return KURL(); > + return document()->completeURL(url);
This is missing a call to stripLeadingAndTrailingHTMLSpaces.
michaelbai
Comment 58
2013-03-08 18:03:59 PST
Created
attachment 192318
[details]
Patch
michaelbai
Comment 59
2013-03-08 18:06:15 PST
Comment on
attachment 192167
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192167&action=review
>> Source/WebCore/html/HTMLVideoElement.cpp:315 >> + return document()->completeURL(url); > > This is missing a call to stripLeadingAndTrailingHTMLSpaces.
Done
Darin Adler
Comment 60
2013-03-12 09:36:21 PDT
Comment on
attachment 192318
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192318&action=review
> Source/WebCore/html/HTMLVideoElement.cpp:189 > + const AtomicString& url = getAttribute(posterAttr); > + if (!url.isEmpty()) > + return url;
On reflection, it’s a little strange here to special case only an empty URL without considering whitespace stripping. I could imagine special casing only a null URL, which means we’d only do this when the poster attribute is entirely missing. Or special casing any URL that ends up empty, and therefore is something we won't even try to load.
> Source/WebCore/html/HTMLVideoElement.cpp:316 > + const AtomicString& url = imageSourceURL(); > + if (url.isEmpty()) > + return KURL(); > + return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(url));
This is still wrong. The stripping of needs to be done before the isEmpty check. Just look at the code in getNonEmptyURLAttribute and match its behavior exactly. That’s the problem with copied and pasted code, I guess. Hard to get it right!
> Source/WebCore/html/HTMLVideoElement.h:94 > + AtomicString m_defaultPosterURL;
It’s a little strange to store a copy of this in every video element. There’s no reason we couldn’t fetch it from the document settings when we need it instead of when we create the video element.
michaelbai
Comment 61
2013-03-12 10:53:37 PDT
Created
attachment 192766
[details]
Patch
michaelbai
Comment 62
2013-03-12 10:56:27 PDT
Comment on
attachment 192318
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192318&action=review
>> Source/WebCore/html/HTMLVideoElement.cpp:189 >> + return url; > > On reflection, it’s a little strange here to special case only an empty URL without considering whitespace stripping. I could imagine special casing only a null URL, which means we’d only do this when the poster attribute is entirely missing. Or special casing any URL that ends up empty, and therefore is something we won't even try to load.
Thanks, I striped space for isEmpty() checking, but returned the original value, I think imageSoureURL is supposed to return unstriped value.
>> Source/WebCore/html/HTMLVideoElement.cpp:316 >> + return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(url)); > > This is still wrong. The stripping of needs to be done before the isEmpty check. Just look at the code in getNonEmptyURLAttribute and match its behavior exactly. That’s the problem with copied and pasted code, I guess. Hard to get it right!
Done
>> Source/WebCore/html/HTMLVideoElement.h:94 >> + AtomicString m_defaultPosterURL; > > It’s a little strange to store a copy of this in every video element. There’s no reason we couldn’t fetch it from the document settings when we need it instead of when we create the video element.
The document->settings()->defaultVideoPosterURL() returns value, but imageSourceURL() returns a reference, I didn't find other workaround, so have to hold the value here. :( I just guess the settings doesn't return reference might because the settings could be changed during the page's life cycle.
michaelbai
Comment 63
2013-03-12 10:57:03 PDT
PTAL when you have time
Darin Adler
Comment 64
2013-03-13 09:26:03 PDT
Comment on
attachment 192766
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192766&action=review
review- because the whitespace stripping is still wrong in this patch; I’m guessing you uploaded the wrong one
> Source/WebCore/ChangeLog:37 > + * WebCore.order: Replace imageSourceAttributeName() with imageSourceURL()
This file does not need to be updated. You can just remove this change from your patch.
> Source/WebCore/ChangeLog:39 > + * dom/Element.cpp: Replace imageSourceAttributeName() with imageSourceURL() > + (WebCore::Element::imageSourceURL):
Comments should go on the functions, not the entire file, unless there is no function name.
> Source/WebCore/ChangeLog:41 > + (Element):
Bogus lines like this should just be deleted from the ChangeLog. The script generates them.
> Source/WebCore/myChangeLog:1 > +2013-03-06 Tao Bai <
michaelbai@chromium.org
>
Please don’t land this second change log file!
> Source/WebCore/html/HTMLVideoElement.cpp:189 > + const AtomicString& url = getAttribute(posterAttr); > + if (!url.isEmpty()) > + return url;
As I mentioned in my last patch, it’s not right to check isEmpty here. It would be OK to check isNull, or to check isEmpty after calling stripLeadingAndTrailingHTMLSpaces.
> Source/WebCore/html/HTMLVideoElement.cpp:316 > + const AtomicString& url = imageSourceURL(); > + if (url.isEmpty()) > + return KURL(); > + return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(url));
The stripLeadingAndTrailingHTMLSpaces call needs to be *before* calling isEmpty. Isn’t that why I said review- last time? Did you upload the wrong version of the patch?
> Source/WebCore/html/HTMLVideoElement.h:68 > + KURL posterImageURL();
Should be const.
michaelbai
Comment 65
2013-03-13 10:35:40 PDT
Created
attachment 192945
[details]
Patch
michaelbai
Comment 66
2013-03-13 10:36:25 PDT
Comment on
attachment 192766
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192766&action=review
>> Source/WebCore/ChangeLog:37 >> + * WebCore.order: Replace imageSourceAttributeName() with imageSourceURL() > > This file does not need to be updated. You can just remove this change from your patch.
Done
>> Source/WebCore/ChangeLog:39 >> + (WebCore::Element::imageSourceURL): > > Comments should go on the functions, not the entire file, unless there is no function name.
Done
>> Source/WebCore/ChangeLog:41 >> + (Element): > > Bogus lines like this should just be deleted from the ChangeLog. The script generates them.
Done
>> Source/WebCore/myChangeLog:1 >> +2013-03-06 Tao Bai <
michaelbai@chromium.org
> > > Please don’t land this second change log file!
Sorry, it is my bad, this is just wrong patch
>> Source/WebCore/html/HTMLVideoElement.cpp:189 >> + return url; > > As I mentioned in my last patch, it’s not right to check isEmpty here. It would be OK to check isNull, or to check isEmpty after calling stripLeadingAndTrailingHTMLSpaces.
Sorry for the wrong patch.
>> Source/WebCore/html/HTMLVideoElement.cpp:316 >> + return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(url)); > > The stripLeadingAndTrailingHTMLSpaces call needs to be *before* calling isEmpty. Isn’t that why I said review- last time? Did you upload the wrong version of the patch?
Sorry again.
>> Source/WebCore/html/HTMLVideoElement.h:68 >> + KURL posterImageURL(); > > Should be const.
Done
Darin Adler
Comment 67
2013-03-13 12:58:54 PDT
Comment on
attachment 192945
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192945&action=review
> Source/WebCore/html/HTMLVideoElement.cpp:188 > + if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty())
Some day we may want to replace this by an isAllHTMLSpaces function that does not require copying the string even if the string contains leading or trailing spaces.
> Source/WebCore/html/HTMLVideoElement.h:72 > + const KURL posterImageURL();
The const here before KURL is unneeded and nearly meaningless. It just means that you can’t call non-const member functions on the return value from this function. What I meant when I said that this function should be const is that there should be a const *after* the parentheses, allowing this to be called on a const HTMLVideoElement.
michaelbai
Comment 68
2013-03-13 13:14:50 PDT
Created
attachment 192979
[details]
Patch
michaelbai
Comment 69
2013-03-13 13:15:51 PDT
Comment on
attachment 192945
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192945&action=review
>> Source/WebCore/html/HTMLVideoElement.h:72 >> + const KURL posterImageURL(); > > The const here before KURL is unneeded and nearly meaningless. It just means that you can’t call non-const member functions on the return value from this function. > > What I meant when I said that this function should be const is that there should be a const *after* the parentheses, allowing this to be called on a const HTMLVideoElement.
Done
WebKit Review Bot
Comment 70
2013-03-13 14:19:04 PDT
Comment on
attachment 192979
[details]
Patch Clearing flags on attachment: 192979 Committed
r145750
: <
http://trac.webkit.org/changeset/145750
>
WebKit Review Bot
Comment 71
2013-03-13 14:19:12 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 72
2013-03-13 15:03:09 PDT
Comment on
attachment 192979
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=192979&action=review
> Source/WebCore/html/HTMLVideoElement.cpp:320 > + const AtomicString& url = stripLeadingAndTrailingHTMLSpaces(imageSourceURL());
After this landed, I noticed a mistake here. This should be typed either const String& or String. Using the type "const AtomicString&" means we’ll do an extra hash lookup to make an atomic string, but there is no value to doing that. We need a followup.
michaelbai
Comment 73
2013-03-13 19:23:50 PDT
Will do
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