Skip to content

Commit

Permalink
Cherry-pick 274340@main (a23acff). rdar://122601623
Browse files Browse the repository at this point in the history
    Try to avoid conflicts between ObjC's Protocol and Inspector::Protocol namespace
    https://bugs.webkit.org/show_bug.cgi?id=269040

    Reviewed by Wenson Hsieh and Patrick Angle.

    ObjC has a Protocol type; sometimes with various Unified Sources shuffling we
    end up getting that included in an Inspector file, which also has Inspector::Protocol,
    which it often uses without the Inspector:: namespace being mentioned explicitly,
    via `using namespace Inspector`.

    * Source/WebCore/inspector/CommandLineAPIHost.cpp:
    * Source/WebCore/inspector/InspectorAuditResourcesObject.cpp:
    * Source/WebCore/inspector/InspectorCanvas.cpp:
    * Source/WebCore/inspector/InspectorStyleSheet.cpp:
    * Source/WebCore/inspector/agents/InspectorAnimationAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorCPUProfilerAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorCSSAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorDOMAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorMemoryAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorPageAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp:
    * Source/WebCore/inspector/agents/InspectorWorkerAgent.cpp:
    * Source/WebCore/inspector/agents/WebHeapAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageAuditAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageCanvasAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageConsoleAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageDOMDebuggerAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageHeapAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp:
    * Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp:
    * Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerCanvasAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerDebuggerAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerNetworkAgent.cpp:
    * Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.cpp:
    Avoid this conflict by specifying Inspector:: in all cases.

    * Source/WebCore/platform/graphics/cocoa/IOSurface.h:
    Also remove one common cause of objc/objc.h getting included places,
    by removing it from IOSurface.h (the build still succeeds...).

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

Canonical link: https://commits.webkit.org/272448.702@safari-7618-branch
  • Loading branch information
hortont424 authored and ddkilzer committed Mar 8, 2024
1 parent be630db commit f5ad578
Show file tree
Hide file tree
Showing 37 changed files with 950 additions and 951 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/inspector/CommandLineAPIHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void CommandLineAPIHost::inspect(JSC::JSGlobalObject& lexicalGlobalObject, JSC::
if (!hintsObject)
return;

auto remoteObject = Protocol::BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(objectValue.releaseNonNull());
auto remoteObject = Inspector::Protocol::BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(objectValue.releaseNonNull());
inspectorAgent->inspect(WTFMove(remoteObject), hintsObject.releaseNonNull());
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/inspector/InspectorAuditResourcesObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ExceptionOr<InspectorAuditResourcesObject::ResourceContent> InspectorAuditResour
if (!cachedResource)
return Exception { ExceptionCode::NotFoundError, makeString("Unknown identifier "_s, id) };

Protocol::ErrorString errorString;
Inspector::Protocol::ErrorString errorString;
ResourceContent resourceContent;
InspectorPageAgent::resourceContent(errorString, frame, cachedResource->url(), &resourceContent.data, &resourceContent.base64Encoded);
if (!errorString.isEmpty())
Expand Down
60 changes: 30 additions & 30 deletions Source/WebCore/inspector/InspectorCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,12 @@ void InspectorCanvas::recordAction(String&& name, InspectorCanvasCallTracer::Pro
}

if (!m_frames)
m_frames = JSON::ArrayOf<Protocol::Recording::Frame>::create();
m_frames = JSON::ArrayOf<Inspector::Protocol::Recording::Frame>::create();

if (!m_currentActions) {
m_currentActions = JSON::ArrayOf<JSON::Value>::create();

auto frame = Protocol::Recording::Frame::create()
auto frame = Inspector::Protocol::Recording::Frame::create()
.setActions(*m_currentActions)
.release();

Expand Down Expand Up @@ -773,7 +773,7 @@ void InspectorCanvas::finalizeFrame()
appendActionSnapshotIfNeeded();

if (m_frames && m_frames->length() && !m_currentFrameStartTime.isNaN()) {
auto currentFrame = static_reference_cast<Protocol::Recording::Frame>(m_frames->get(m_frames->length() - 1));
auto currentFrame = static_reference_cast<Inspector::Protocol::Recording::Frame>(m_frames->get(m_frames->length() - 1));
currentFrame->setDuration((MonotonicTime::now() - m_currentFrameStartTime).milliseconds());

m_currentFrameStartTime = MonotonicTime::nan();
Expand All @@ -787,7 +787,7 @@ void InspectorCanvas::markCurrentFrameIncomplete()
if (!m_currentActions || !m_frames || !m_frames->length())
return;

auto currentFrame = static_reference_cast<Protocol::Recording::Frame>(m_frames->get(m_frames->length() - 1));
auto currentFrame = static_reference_cast<Inspector::Protocol::Recording::Frame>(m_frames->get(m_frames->length() - 1));
currentFrame->setIncomplete(true);
}

Expand Down Expand Up @@ -822,12 +822,12 @@ static RefPtr<Inspector::Protocol::Canvas::ContextAttributes> buildObjectForCanv
.release();
switch (attributes.colorSpace) {
case PredefinedColorSpace::SRGB:
contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::SRGB);
contextAttributesPayload->setColorSpace(Inspector::Protocol::Canvas::ColorSpace::SRGB);
break;

#if ENABLE(PREDEFINED_COLOR_SPACE_DISPLAY_P3)
case PredefinedColorSpace::DisplayP3:
contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::DisplayP3);
contextAttributesPayload->setColorSpace(Inspector::Protocol::Canvas::ColorSpace::DisplayP3);
break;
#endif
}
Expand Down Expand Up @@ -875,7 +875,7 @@ static RefPtr<Inspector::Protocol::Canvas::ContextAttributes> buildObjectForCanv
return nullptr;
}

Ref<Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace)
Ref<Inspector::Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace)
{
auto contextType = [&] {
bool isOffscreen = false;
Expand All @@ -886,39 +886,39 @@ Ref<Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool capture

if (is<CanvasRenderingContext2D>(m_context)) {
ASSERT(!isOffscreen);
return Protocol::Canvas::ContextType::Canvas2D;
return Inspector::Protocol::Canvas::ContextType::Canvas2D;
}
#if ENABLE(OFFSCREEN_CANVAS)
if (is<OffscreenCanvasRenderingContext2D>(m_context)) {
ASSERT(isOffscreen);
return Protocol::Canvas::ContextType::OffscreenCanvas2D;
return Inspector::Protocol::Canvas::ContextType::OffscreenCanvas2D;
}
#endif
if (is<ImageBitmapRenderingContext>(m_context)) {
if (isOffscreen)
return Protocol::Canvas::ContextType::OffscreenBitmapRenderer;
return Protocol::Canvas::ContextType::BitmapRenderer;
return Inspector::Protocol::Canvas::ContextType::OffscreenBitmapRenderer;
return Inspector::Protocol::Canvas::ContextType::BitmapRenderer;
}
#if ENABLE(WEBGL)
if (is<WebGLRenderingContext>(m_context)) {
if (isOffscreen)
return Protocol::Canvas::ContextType::OffscreenWebGL;
return Protocol::Canvas::ContextType::WebGL;
return Inspector::Protocol::Canvas::ContextType::OffscreenWebGL;
return Inspector::Protocol::Canvas::ContextType::WebGL;
}
if (is<WebGL2RenderingContext>(m_context)) {
if (isOffscreen)
return Protocol::Canvas::ContextType::OffscreenWebGL2;
return Protocol::Canvas::ContextType::WebGL2;
return Inspector::Protocol::Canvas::ContextType::OffscreenWebGL2;
return Inspector::Protocol::Canvas::ContextType::WebGL2;
}
#endif

ASSERT_NOT_REACHED();
return Protocol::Canvas::ContextType::Canvas2D;
return Inspector::Protocol::Canvas::ContextType::Canvas2D;
}();

const auto& size = m_context->canvasBase().size();

auto canvas = Protocol::Canvas::Canvas::create()
auto canvas = Inspector::Protocol::Canvas::Canvas::create()
.setCanvasId(m_identifier)
.setContextType(contextType)
.setWidth(size.width())
Expand Down Expand Up @@ -947,7 +947,7 @@ Ref<Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool capture
return canvas;
}

Ref<Protocol::Recording::Recording> InspectorCanvas::releaseObjectForRecording()
Ref<Inspector::Protocol::Recording::Recording> InspectorCanvas::releaseObjectForRecording()
{
ASSERT(!m_currentActions);
ASSERT(!m_lastRecordedAction);
Expand All @@ -961,30 +961,30 @@ Ref<Protocol::Recording::Recording> InspectorCanvas::releaseObjectForRecording()
isOffscreen = true;
#endif

Protocol::Recording::Type type;
Inspector::Protocol::Recording::Type type;
if (is<CanvasRenderingContext2D>(m_context)) {
ASSERT(!isOffscreen);
type = Protocol::Recording::Type::Canvas2D;
type = Inspector::Protocol::Recording::Type::Canvas2D;
#if ENABLE(OFFSCREEN_CANVAS)
} else if (is<OffscreenCanvasRenderingContext2D>(m_context)) {
ASSERT(isOffscreen);
type = Protocol::Recording::Type::OffscreenCanvas2D;
type = Inspector::Protocol::Recording::Type::OffscreenCanvas2D;
#endif
} else if (is<ImageBitmapRenderingContext>(m_context)) {
type = isOffscreen ? Protocol::Recording::Type::OffscreenCanvasBitmapRenderer : Protocol::Recording::Type::CanvasBitmapRenderer;
type = isOffscreen ? Inspector::Protocol::Recording::Type::OffscreenCanvasBitmapRenderer : Inspector::Protocol::Recording::Type::CanvasBitmapRenderer;
#if ENABLE(WEBGL)
} else if (is<WebGLRenderingContext>(m_context)) {
type = isOffscreen ? Protocol::Recording::Type::OffscreenCanvasWebGL : Protocol::Recording::Type::CanvasWebGL;
type = isOffscreen ? Inspector::Protocol::Recording::Type::OffscreenCanvasWebGL : Inspector::Protocol::Recording::Type::CanvasWebGL;
} else if (is<WebGL2RenderingContext>(m_context)) {
type = isOffscreen ? Protocol::Recording::Type::OffscreenCanvasWebGL2 : Protocol::Recording::Type::CanvasWebGL2;
type = isOffscreen ? Inspector::Protocol::Recording::Type::OffscreenCanvasWebGL2 : Inspector::Protocol::Recording::Type::CanvasWebGL2;
#endif
} else {
ASSERT_NOT_REACHED();
type = Protocol::Recording::Type::Canvas2D;
type = Inspector::Protocol::Recording::Type::Canvas2D;
}

auto recording = Protocol::Recording::Recording::create()
.setVersion(Protocol::Recording::VERSION)
auto recording = Inspector::Protocol::Recording::Recording::create()
.setVersion(Inspector::Protocol::Recording::VERSION)
.setType(type)
.setInitialState(m_initialState.releaseNonNull())
.setData(m_serializedDuplicateData.releaseNonNull())
Expand All @@ -998,7 +998,7 @@ Ref<Protocol::Recording::Recording> InspectorCanvas::releaseObjectForRecording()
return recording;
}

Protocol::ErrorStringOr<String> InspectorCanvas::getContentAsDataURL(CanvasRenderingContext& context)
Inspector::Protocol::ErrorStringOr<String> InspectorCanvas::getContentAsDataURL(CanvasRenderingContext& context)
{
if (context.compositingResultsNeedUpdating())
context.drawBufferToCanvas(CanvasRenderingContext::SurfaceBuffer::DrawingBuffer);
Expand Down Expand Up @@ -1203,11 +1203,11 @@ static Ref<JSON::ArrayOf<double>> buildArrayForAffineTransform(const AffineTrans
return array;
}

Ref<Protocol::Recording::InitialState> InspectorCanvas::buildInitialState()
Ref<Inspector::Protocol::Recording::InitialState> InspectorCanvas::buildInitialState()
{
// FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice

auto initialStatePayload = Protocol::Recording::InitialState::create().release();
auto initialStatePayload = Inspector::Protocol::Recording::InitialState::create().release();

auto attributesPayload = JSON::Object::create();
attributesPayload->setInteger("width"_s, m_context->canvasBase().width());
Expand Down
Loading

0 comments on commit f5ad578

Please sign in to comment.