[HN Gopher] WebKit Quirks.cpp
       ___________________________________________________________________
        
       WebKit Quirks.cpp
        
       Author : Bodacious1445
       Score  : 85 points
       Date   : 2022-10-14 19:16 UTC (3 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | sanxiyn wrote:
       | By the way, this is as old as web. It's ironic to re-read
       | https://dev.opera.com/blog/opera-s-site-patching/ published in
       | 2009, which uses 2022(!) as a stand-in year for far future when
       | hopefully none of this will be required.
        
         | zinekeller wrote:
         | The bitter irony is that it was indeed "solved" - not by HTML5
         | as (the original) Opera dev team implied, but by Chromium being
         | in a ~90% market share.
        
       | squeaky-clean wrote:
       | I've found another webkit quirk in the past which is outside of
       | the Quirks.cpp file, ObjectPrototype.cpp has some special code
       | for the PokerBros app. Looks like it's still there.
       | 
       | https://github.com/WebKit/WebKit/blob/f134a54c03b71e8e3c4da0...
       | 
       | https://github.com/WebKit/WebKit/blob/f134a54c03b71e8e3c4da0...
       | 
       | Also not as disgusting as Quirks.cpp, but I was debugging some
       | video decoding stuff in Chrome this week and found some fun
       | things today, special code to work around various GPU driver
       | bugs.
       | 
       | https://source.chromium.org/chromium/chromium/src/+/main:gpu...
       | 
       | https://source.chromium.org/chromium/chromium/src/+/main:gpu...
       | 
       | And a separate implementation of MSAA for Intel GPUs
       | 
       | https://source.chromium.org/chromium/chromium/src/+/main:gpu...
        
       | acid__ wrote:
       | Huh, how big does your website have to be in order for your bugs
       | to be patched this way?
        
         | perardi wrote:
         | Judging by how many times they show up: Google.
         | 
         | Just kidding. Mostly. Lots of little fiddly text editing
         | patches for Google Docs, which doesn't surprise me. It's, I
         | would assume, the most-used application suite on the web, and
         | there's going to be weird edge cases that pop up around rich
         | text editing that get magnified by the sheer number of users.
         | Including probably inside Apple.
        
         | shadowgovt wrote:
         | Big enough for Apple to believe a critical mass of users will
         | switch to another browser if they don't bend the rules.
        
           | peyton wrote:
           | They want a good experience for people who click around
           | popular sites on demo devices at the Apple Store. You can't
           | switch browser engines on iOS
        
           | alwillis wrote:
           | It's more likely about making sure Safari users have a good
           | or consistent user experience on popular sites.
           | 
           | When you're the default browser on 1.5+ billion devices, it's
           | less about losing a few users here or there.
        
             | shadowgovt wrote:
             | I think that's two ways to say the same thing.
             | 
             | Users can still install Chrome on a Macintosh. Apple's
             | larger concern is probably whether they'll lose _hardware_
             | share if, say, Reddit doesn 't load right on MacBooks
             | (you'd be surprised how many people buy an expensive
             | machine as basically an internet appliance) or, more
             | importantly: iPhones.
        
             | esprehn wrote:
             | It's not just about being the default browser, they're the
             | _only_ browser with no user choice to switch or manually
             | upgrade or downgrade independent of the OS.
        
       | Cyberdog wrote:
       | I was going to post a message trying to shame anyone who works on
       | a site with a URL in this file to fix their damn site...
       | 
       | ...but now, thanks to this file, it may be difficult if not
       | impossible to fix their damn site in a way that doesn't conflict
       | with WebKit's own fixes. :/
        
       | babelfish wrote:
       | This bit was interesting.                 bool
       | Quirks::requiresUserGestureToPauseInPictureInPicture() const
       | {       #if ENABLE(VIDEO_PRESENTATION_MODE)           //
       | Facebook, Twitter, and Reddit will naively pause a <video>
       | element that has scrolled out of the viewport,           //
       | regardless of whether that element is currently in PiP mode.
       | // We should remove the quirk once <rdar://problem/67273166>,
       | <rdar://problem/73369869>, and <rdar://problem/80645747> have
       | been fixed.           if (!needsQuirks())               return
       | false;                if
       | (!m_requiresUserGestureToPauseInPictureInPicture) {
       | auto domain =
       | RegistrableDomain(m_document->topDocument().url()).string();
       | m_requiresUserGestureToPauseInPictureInPicture = domain ==
       | "facebook.com"_s || domain == "twitter.com"_s || domain ==
       | "reddit.com"_s;           }                  return
       | *m_requiresUserGestureToPauseInPictureInPicture;       #else
       | return false;       #endif       }
        
         | peaBerberian wrote:
         | This makes me very jealous!
         | 
         | I'm a developer on a web media player and remember that we had
         | at some point an issue with picture in picture mode: We had a
         | feature that lowered the video bitrate to the minimum when the
         | page that contained the video element was not showing for some
         | amount of time.
         | 
         | That made total sense... until the Picture in Picture mode was
         | added to browsers, where you would see a very-low quality after
         | watching your content in that mode in another page long enough
         | (~1 minute).
         | 
         | The sad thing is that because I was (still am) developing an
         | open-source player and because the API documentation described
         | clearly the aforementioned implementation, I had to deprecate
         | that option and re-create a new one (with a better API
         | documentation, talking more about the intent than the
         | implementation!) instead, which would have the right exceptions
         | for picture in picture mode.
         | 
         | Seeing that part made me remember this anecdote, we should just
         | have asked for quirks :p
        
           | CharlesW wrote:
           | Is the player you're working on public? Does the Picture-in-
           | Picture API do what you need now?
        
         | shadowgovt wrote:
         | The first rule of browser development is "forget the standard,
         | forget consistency... If it's popular and works in other
         | browsers but not yours, your browser is broken."
        
       | lapcat wrote:
       | Interesting that this is posted to HN now, because I recently ran
       | into some YouTube brokenness caused by an old WebKit quirk.
       | 
       | "Site-specific hacks break native video controls in YouTube
       | embeds" https://bugs.webkit.org/show_bug.cgi?id=245612
       | 
       | So many hours spent debugging this...
        
       | sanxiyn wrote:
       | You can check out https://github.com/webcompat/web-
       | bugs/labels/sitepatch-appli... to see current actions.
        
       | dschulz wrote:
       | Interesting bits are to be found under the rug :-)
        
       | webmobdev wrote:
       | > bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenE
       | ditableAreasForHost
       | 
       | > Quirks::shouldSuppressAutocorrectionAndAutocaptializationInHidd
       | enEditableAreas
       | 
       | Even with modern IDE's with autocomplete, I wonder if such long
       | names for variables, methods, classes etc. should be encouraged?
        
         | lapcat wrote:
         | I suspect it's influenced by Objective-C, which tends to have a
         | rather verbose style.
         | 
         | It's an acquired taste.
        
       | pvg wrote:
       | Previous (87 comment) discussion two years ago:
       | 
       | https://news.ycombinator.com/item?id=26165357
        
         | richdougherty wrote:
         | We found a bug last time!
         | 
         | https://bugs.webkit.org/show_bug.cgi?id=222130
        
       | lelandfe wrote:
       | Unrelated to quirks mode:
       | https://en.wikipedia.org/wiki/Quirks_mode
       | 
       | Which even just remembering now gave me some small terror
        
       | adamrezich wrote:
       | did not realize that webkit has the equivalent of site-specific
       | hard-coded stuff like this, or even isGoogleMaps(), it's like
       | nvidia drivers for the web, crazy
        
       | l_f wrote:
       | I love how they name things
       | 
       | shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditable
       | AreasForHost(...)
        
         | kitsunesoba wrote:
         | Can't leave any room for ambiguity!
         | 
         | Apple-style function/method naming may be verbose but at least
         | the names usually have good explanatory value and aren't just
         | meaningless verbosity.
        
           | shadowgovt wrote:
           | And in the 21st century, everybody's using tab to
           | autocomplete that string anyway.
        
             | userbinator wrote:
             | The problem is when you have multiple very long identifiers
             | that differ only in a few characters. When scanning through
             | code, it's much easier to see the difference between a
             | saaainheafh and a saaainheafi than it is a shouldSuppressAu
             | tocorrectionAndAutocaptializationInHiddenEditableAreasForHo
             | st and a shouldSuppressAutocorrectionAndAutocaptializationI
             | nHiddenEditableAreasForInput.
             | 
             | Also, autocomplete doesn't work when you're reading and not
             | writing, or just using a text editor or reading/annotating
             | a printout (yes, I still do that.) IMHO writing code that
             | almost completely relies on special tools to handle it is a
             | bad trend.
        
               | shadowgovt wrote:
               | I'm surprised that I strongly disagree. My eyes glaze
               | right past the difference between the fh and the fi in
               | that example.
               | 
               | They also glaze past the end of the mega-strings, but I
               | usually solve that problem by either actually ctrl-F
               | finding for the string (which will highlight it) or by
               | finding an examplar and selecting it (which will
               | highlight all instances of the same symbol in the
               | languages and IDEs I use).
               | 
               | I'm a firm believer that "code isn't just text" (in fact,
               | most of my frustration with code is tools that treat it
               | so... The set of strings that aren't valid programs is
               | vastly larger than the set that are, so why should I be
               | treating programs as if they're mere strings? It'll lead
               | me to create non-compilable artifacts). So I try to avoid
               | being in situations where the only tools I have to work
               | with to understand code are a text editor or an annotated
               | printout (I don't doubt that's done in places, but I've
               | gone my whole career managing to avoid it so far).
        
               | peyton wrote:
               | This is a large open source project used by billions of
               | people with many contributors. saaainheafh just doesn't
               | cut it.
        
         | userbinator wrote:
         | There's even a typo: captialization
        
         | rcoveson wrote:
         | Suggested names for porting this source file to other
         | languages:
         | 
         | Java:
         | 
         | isShouldSuppressAutocorrectionAndAutocaptializationInHiddenEdit
         | ableAreasForHost
         | 
         | Common Lisp:
         | 
         | suppress-autocorrection-and-autocaptialization-in-hidden-
         | editable-areas-for-host-p
         | 
         | C:
         | 
         | saaainheafh
        
           | dvirsky wrote:
           | In Windows, this is just a getter to a private variable
           | variable called m_pcszwclbShouldSuppressAutocorrectionAndAuto
           | captializationInHiddenEditableAreasForHost
        
           | umanwizard wrote:
           | Many codebases I've worked on:
           | 
           | mungeEditable
        
           | hunter2_ wrote:
           | The dropped "s" and extra "n" is... about right I suppose!
        
       | eatonphil wrote:
       | I noticed this today through Andreas Kling's tweet:
       | https://twitter.com/awesomekling/status/1580993812247158784.
        
       | [deleted]
        
       | sanxiyn wrote:
       | It's somewhat interesting although not surprising that iCloud is
       | there in WebKit quirks even if both WebKit and iCloud are
       | developed by Apple.
        
         | Bytewave81 wrote:
         | At some point, "one" company becomes a set of loosely-related
         | "companies" all tied together by a single name and a chain of
         | bureaucracy.
        
         | olliej wrote:
         | oh, that's magical :D
        
       | howinteresting wrote:
       | Surprised this is hardcoded in C++ and not something that can be
       | pushed as an over the air update.
        
       ___________________________________________________________________
       (page generated 2022-10-14 23:00 UTC)