TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

YouTubePluginReplacement.cpp: YouTube-specific code in WebKit

245 pointsby goranmoominover 2 years ago

12 comments

DaleCurtisover 2 years ago
Chrome has something similar here: <a href="https:&#x2F;&#x2F;source.chromium.org&#x2F;chromium&#x2F;chromium&#x2F;src&#x2F;+&#x2F;main:chrome&#x2F;renderer&#x2F;media&#x2F;flash_embed_rewrite.cc;l=10;drc=82b01954552a812c61cf7bea4709e1ab9ca82e58" rel="nofollow">https:&#x2F;&#x2F;source.chromium.org&#x2F;chromium&#x2F;chromium&#x2F;src&#x2F;+&#x2F;main:chr...</a><p>We accept contributions from other sites (e.g., Vimeo, Dailymotion, etc) who wanted to replace their long tail of in the wild embeds prior to Flash removal.
评论 #32889024 未加载
chrismorganover 2 years ago
I believe this is about allowing this kind of markup (that exists on old web pages that haven’t been updated for a long time) to still work:<p><pre><code> &lt;embed src=&quot;http:&#x2F;&#x2F;www.youtube.com&#x2F;v&#x2F;dQw4w9WgXcQ&quot;&gt;&lt;&#x2F;embed&gt; </code></pre> … by roughly translating it into<p><pre><code> &lt;iframe src=&quot;http:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;dQw4w9WgXcQ&quot;&gt;&lt;&#x2F;iframe&gt; </code></pre> Probably also the &lt;object&gt; equivalent, maybe only that and not &lt;embed&gt;, I’m not sure. I never had a great deal to do with those two tags.<p>I don’t know why it has to be done this way. I’d have thought that without this extra code it’d roughly fall back to being an iframe on the original URL, and then YouTube could just check if it’s in a frame and behave as an embed instead of the main UI. But there’s <i>probably</i> a reason why they’ve all done it this kind of way.
评论 #32891728 未加载
评论 #32890058 未加载
评论 #32889755 未加载
评论 #32890473 未加载
orblivionover 2 years ago
Some people here are complaining that this is a hack, technical debt, etc. I thought the point would be the political one, as it were. YouTube.com gets special treatment in a major web browser, whereas Sal&#x27;s discount video website has to conform to standards like all the other plebs.<p>It&#x27;s an erosion (however minor, by itself) of the idea of an open standard.
评论 #32890641 未加载
评论 #32893685 未加载
评论 #32891255 未加载
evilpieover 2 years ago
Firefox will also rewrite YouTube embeds: <a href="https:&#x2F;&#x2F;searchfox.org&#x2F;mozilla-central&#x2F;rev&#x2F;c6d17806faef8708b6511e9849132463b7ea6c37&#x2F;dom&#x2F;base&#x2F;nsObjectLoadingContent.cpp#846" rel="nofollow">https:&#x2F;&#x2F;searchfox.org&#x2F;mozilla-central&#x2F;rev&#x2F;c6d17806faef8708b6...</a>.<p>Firefox also ships a &quot;system&quot; add-on (<a href="https:&#x2F;&#x2F;github.com&#x2F;mozilla-extensions&#x2F;webcompat-addon" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mozilla-extensions&#x2F;webcompat-addon</a>) that has interventions and user-agent overrides for many websites. See for yourself in Firefox on about:compat.
saagarjhaover 2 years ago
Most platform vendors have this in some form or the other. WebKit has far more here, for example: <a href="https:&#x2F;&#x2F;github.com&#x2F;WebKit&#x2F;WebKit&#x2F;blob&#x2F;main&#x2F;Source&#x2F;WebCore&#x2F;page&#x2F;Quirks.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;WebKit&#x2F;WebKit&#x2F;blob&#x2F;main&#x2F;Source&#x2F;WebCore&#x2F;pa...</a>. These are cool and all for when you want software to keep working, but if you&#x27;re the person writing these, the one thing you should absolutely make sure to do is reach out to the authors of the software you&#x27;re working around to see if they are willing to fix their code. Most of the time they are! But I invariable see code go into the OS&#x2F;browser&#x2F;whatever and engineers bemoaning how they have to work super hard on backcompat, and I&#x27;m like…&quot;ok, but when did you send us a bug?&quot;
shadowgovtover 2 years ago
I&#x27;m not sure if it&#x27;s still there, but for a long time there was a chunk of code in the Mozilla code base that hunted for several browser extensions in Windows every time the browser started up and did some patch up work in the file system to make sure that those extensions could be found in the browser because some older installers would dump them in non-standard places. This was to avoid the issue that if the user had already installed the application with the corresponding extension and it was working in Internet Explorer, it wouldn&#x27;t automatically work in Firefox without this patch up process. And in that case, it wasn&#x27;t the extension that was broken from the user&#x27;s point of view... It was Firefox.<p>Some technologies are so fundamental to the web experience that when they break, the user perceives the browser to be broken, not that technology.
评论 #32889937 未加载
jdmndover 2 years ago
This is interesting. It looks like there was even some discussion of making this behaviour part of the standard, since it&#x27;s implemented by all of the major browsers.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;html&#x2F;issues&#x2F;2390" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;html&#x2F;issues&#x2F;2390</a>
NegativeLatencyover 2 years ago
The video in one of the test cases is Steve Jobs commencement address <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;v&#x2F;UF8uR6Z6KLc" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;v&#x2F;UF8uR6Z6KLc</a>
评论 #32889517 未加载
eimrineover 2 years ago
Could you tell those who are not familiar with WebKit what this code actually does?
评论 #32888558 未加载
danielovichdkover 2 years ago
Most beautiful cpp code I have seen in many years
评论 #32889811 未加载
评论 #32890403 未加载
leeoniyaover 2 years ago
hehe, now let&#x27;s see all the WebKit-specific code in YouTube :D
cushover 2 years ago
Odd that a quarter of the code is parsing the qsps