Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 021be8e5aefd8742e091c6369be13fd745207359
      
https://github.com/WebKit/WebKit/commit/021be8e5aefd8742e091c6369be13fd745207359
  Author: Chris Dumez <[email protected]>
  Date:   2025-12-18 (Thu, 18 Dec 2025)

  Changed paths:
    M Source/WTF/wtf/StdLibExtras.h
    M Source/WebCore/dom/DocumentImmersive.cpp
    M Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h

  Log Message:
  -----------
  WTFMove() is not supposed to compile when a `const` variable is passed in
https://bugs.webkit.org/show_bug.cgi?id=302139

Reviewed by Ryosuke Niwa and Geoffrey Garen.

WTFMove() is not supposed to compile when a `const` variable is passed in,
it the main reason we use `WTFMove()` over `std::move()`. However, this is
currently not working as intended and it is compiling just fine. This can
lead to bugs such as Bug 301998.

Address the issue by no longer extending the `std` namespace since this is
undefined behavior [1]. Instead define `move()` in the WTF
namespace.

Most of the incorrect uses of WTFMove() were addressed in 302773@main already.

Unfortunately, I wasn't able to get the `permissive-move` compiler warnings
to work with our custom move function. It seems the compiler hard-codes the
std::move() name so it doesn't warn with code like this:
```
String foo()
{
    StringBuilder builder;
    String string = builder.toString();
    return WTFMove(string); // Should warn about unnecessary move but doesn't.
}
```
I tried a lot of things but it seems we either use the default `std::move()`
and get the `permissive-move` warnings OR we use our custom move functions
and then we can add static assertions to catch unnecessary moves and moves
of const values that would lead to silent copying.

[1] https://en.cppreference.com/w/cpp/language/extending_std.html

* Source/WTF/wtf/StdLibExtras.h:
(WTF::move):
(std::move): Deleted.
* Source/WebCore/dom/DocumentImmersive.cpp:
(WebCore::DocumentImmersive::requestImmersive):
* Source/WebCore/platform/graphics/coretext/FontCoreText.cpp:
(WebCore::Font::fromIPCData):
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _validateText:inNode:completionHandler:]):
* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::setTextIndicatorFromFrame):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setTextIndicatorFromFrame):
* Source/WebKit/UIProcess/WebPageProxy.h:

Canonical link: https://commits.webkit.org/304711@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to