New issue
Advanced search Search tips

Issue 750674 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

platform/bindings/ActiveScriptWrappable.h shouldn't depend on ExecutionContext.

Project Member Reported by yukishiino@chromium.org, Jul 31 2017

Issue description

platform/bindings/ActiveScriptWrappable.h does actually depend on core/dom/ExecutionContext.h and this is a layering violation.  ActiveScriptWrappable.h shouldn't depend on ExecutionContext.h.

The current implementation of ActiveScriptWrappable::IsContextDestroyed is as follows.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindings/ActiveScriptWrappable.h?rcl=38bca25edcd71c1cb99d4d951fc0d6783aeb8a10&l=49
----
  bool IsContextDestroyed() const final {
    const auto* execution_context =
        static_cast<const T*>(this)->GetExecutionContext();
    return !execution_context || execution_context->IsContextDestroyed();
  }
----
Where this inline function implicitly requires the call sites (Foo.h or Foo.cpp) to #include "core/dom/ExecutionContext.h".  This breaks the IWYU (Include What You Use) rule.

(This actually bit me when I tried to change
    #include "core/dom/ExecutionContext.h"
to
    class ExecutionContext;  // forward decl
in MutationObserver.h where we shouldn't need the actual class definition.)

There are many options to fix this issue.
a) Move ActiveScriptWrappable class definition into core/dom/ActiveScriptWrappableAdapter.h for example.  (Then, it would make sense to rename ActiveScriptWrappableBase => ActiveScriptWrappable and ActiveScriptWrappable => ActiveScriptWrappableAdapter.)
b) Remove the definition of IsContextDestroyed() from ActiveScriptWrappable.h.  Let each implementation class directly implement IsContextDestroyed.
c) Move only IsContextDestroyed that needs ExecutionContext to core/dom/.

I personally prefer Option a).

 
I mildly prefer (b) because it's analogous to how how HasPendingActivity works, but don't feel strongly.
Project Member

Comment 2 by bugdroid1@chromium.org, Nov 14 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee

commit ca99a6cfa9a6c2529f74d979d7dd0b3898055cee
Author: Adithya Srinivasan <adithyas@chromium.org>
Date: Tue Nov 14 17:04:26 2017

Move ActiveScriptWrappable into bindings/core

The implementation of IsContextDestroyed creates a dependency to
ExecutionContext. This CL keeps ActiveScriptWrappableBase in
platform/bindings and moves ActiveScriptWrappable to bindings/core.

Bug:  750674 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ic9710f5d209c2a028b1e4393b70a94d9334efb26
Reviewed-on: https://chromium-review.googlesource.com/744802
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516331}
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/bindings/bindings.gni
[add] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/animation/Animation.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/css/FontFace.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/css/MediaQueryList.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/dom/MessagePort.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/dom/MutationObserver.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/fileapi/FileReader.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/html/HTMLImageElement.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/html/HTMLPlugInElement.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/html/forms/HTMLInputElement.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/html/media/HTMLMediaElement.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/mojo/MojoWatcher.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/mojo/test/MojoInterfaceInterceptor.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/streams/UnderlyingSourceBase.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/svg/SVGImageElement.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/timing/PerformanceObserver.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/workers/DedicatedWorker.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/workers/SharedWorker.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/workers/WorkletGlobalScope.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/battery/BatteryManager.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/eventsource/EventSource.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/fetch/Body.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/filesystem/FileWriter.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/imagecapture/ImageCapture.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/indexeddb/IDBDatabase.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/indexeddb/IDBRequest.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/mediasource/MediaSource.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/mediasource/SourceBuffer.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/mediastream/MediaDevices.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/netinfo/NetworkInformation.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/notifications/Notification.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/peerconnection/RTCDataChannel.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/permissions/PermissionStatus.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/presentation/PresentationAvailability.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/presentation/PresentationRequest.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/sensor/Sensor.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/speech/SpeechRecognition.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/webmidi/MIDIAccess.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/webmidi/MIDIPort.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/modules/websockets/DOMWebSocket.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/platform/BUILD.gn
[rename] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/platform/bindings/ActiveScriptWrappableBase.cpp
[rename] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/platform/bindings/ActiveScriptWrappableBase.h
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp
[modify] https://crrev.com/ca99a6cfa9a6c2529f74d979d7dd0b3898055cee/third_party/WebKit/Source/platform/bindings/WrapperTypeInfo.h

Status: Fixed (was: Assigned)

Sign in to add a comment