hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 98
values | lang stringclasses 21
values | max_stars_repo_path stringlengths 3 945 | max_stars_repo_name stringlengths 4 118 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count int64 1 368k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 945 | max_issues_repo_name stringlengths 4 118 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count int64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 945 | max_forks_repo_name stringlengths 4 135 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1 1.03M | max_line_length int64 2 1.03M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f57acf59aa0126fed78aaafaba74cf3c06794307 | 32,564 | cpp | C++ | src/CaptureClient/ApiEventProcessorTest.cpp | guruantree/orbit | c59eea66e4dc8313fecef9524850bf58c8ba8c30 | [
"BSD-2-Clause"
] | null | null | null | src/CaptureClient/ApiEventProcessorTest.cpp | guruantree/orbit | c59eea66e4dc8313fecef9524850bf58c8ba8c30 | [
"BSD-2-Clause"
] | null | null | null | src/CaptureClient/ApiEventProcessorTest.cpp | guruantree/orbit | c59eea66e4dc8313fecef9524850bf58c8ba8c30 | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) 2020 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <gmock/gmock.h>
#include <google/protobuf/util/message_differencer.h>
#include <gtest/gtest.h>
#include <algorithm>
#include <vector>
#include "ApiUtils/EncodedString.h"
#include "CaptureClient/ApiEventProcessor.h"
#include "CaptureClient/CaptureEventProcessor.h"
#include "CaptureClient/CaptureListener.h"
#include "OrbitBase/Profiling.h"
#include "OrbitBase/ThreadUtils.h"
#include "capture.pb.h"
namespace orbit_capture_client {
using orbit_client_protos::CallstackInfo;
using orbit_client_protos::TimerInfo;
using google::protobuf::util::MessageDifferencer;
using ::testing::Invoke;
using ::testing::SaveArg;
using orbit_grpc_protos::ApiEvent;
using orbit_grpc_protos::ClientCaptureEvent;
namespace {
class MockCaptureListener : public CaptureListener {
public:
MOCK_METHOD(void, OnCaptureStarted,
(const orbit_grpc_protos::CaptureStarted&, std::optional<std::filesystem::path>,
absl::flat_hash_set<uint64_t>),
(override));
MOCK_METHOD(void, OnCaptureFinished, (const orbit_grpc_protos::CaptureFinished&), (override));
MOCK_METHOD(void, OnTimer, (const TimerInfo&), (override));
MOCK_METHOD(void, OnKeyAndString, (uint64_t /*key*/, std::string), (override));
MOCK_METHOD(void, OnUniqueCallstack, (uint64_t /*callstack_id*/, CallstackInfo /*callstack*/),
(override));
MOCK_METHOD(void, OnCallstackEvent, (orbit_client_protos::CallstackEvent), (override));
MOCK_METHOD(void, OnThreadName, (uint32_t /*thread_id*/, std::string /*thread_name*/),
(override));
MOCK_METHOD(void, OnThreadStateSlice, (orbit_client_protos::ThreadStateSliceInfo), (override));
MOCK_METHOD(void, OnAddressInfo, (orbit_client_protos::LinuxAddressInfo), (override));
MOCK_METHOD(void, OnUniqueTracepointInfo,
(uint64_t /*key*/, orbit_grpc_protos::TracepointInfo /*tracepoint_info*/),
(override));
MOCK_METHOD(void, OnTracepointEvent, (orbit_client_protos::TracepointEventInfo), (override));
MOCK_METHOD(void, OnModuleUpdate,
(uint64_t /*timestamp_ns*/, orbit_grpc_protos::ModuleInfo /*module_info*/),
(override));
MOCK_METHOD(void, OnModulesSnapshot,
(uint64_t /*timestamp_ns*/,
std::vector<orbit_grpc_protos::ModuleInfo> /*module_infos*/),
(override));
MOCK_METHOD(void, OnApiStringEvent, (const orbit_client_protos::ApiStringEvent&), (override));
MOCK_METHOD(void, OnApiTrackValue, (const orbit_client_protos::ApiTrackValue&), (override));
MOCK_METHOD(void, OnWarningEvent, (orbit_grpc_protos::WarningEvent /*warning_event*/),
(override));
MOCK_METHOD(void, OnClockResolutionEvent,
(orbit_grpc_protos::ClockResolutionEvent /*clock_resolution_event*/), (override));
MOCK_METHOD(
void, OnErrorsWithPerfEventOpenEvent,
(orbit_grpc_protos::ErrorsWithPerfEventOpenEvent /*errors_with_perf_event_open_event*/),
(override));
MOCK_METHOD(void, OnErrorEnablingOrbitApiEvent,
(orbit_grpc_protos::ErrorEnablingOrbitApiEvent /*error_enabling_orbit_api_event*/),
(override));
MOCK_METHOD(void, OnErrorEnablingUserSpaceInstrumentationEvent,
(orbit_grpc_protos::ErrorEnablingUserSpaceInstrumentationEvent /*error_event*/),
(override));
MOCK_METHOD(
void, OnWarningInstrumentingWithUserSpaceInstrumentationEvent,
(orbit_grpc_protos::WarningInstrumentingWithUserSpaceInstrumentationEvent /*warning_event*/),
(override));
MOCK_METHOD(void, OnLostPerfRecordsEvent,
(orbit_grpc_protos::LostPerfRecordsEvent /*lost_perf_records_event*/), (override));
MOCK_METHOD(
void, OnOutOfOrderEventsDiscardedEvent,
(orbit_grpc_protos::OutOfOrderEventsDiscardedEvent /*out_of_order_events_discarded_event*/),
(override));
};
class ApiEventProcessorTest : public ::testing::Test {
public:
ApiEventProcessorTest() : api_event_processor_{&capture_listener_} {}
protected:
void SetUp() override {}
void TearDown() override {}
static orbit_grpc_protos::ApiScopeStart CreateStartScope(
const char* name, uint64_t timestamp_ns, int32_t process_id, int32_t thread_id,
uint64_t group_id, uint64_t address_in_function, orbit_api_color color = kOrbitColorAuto) {
orbit_grpc_protos::ApiScopeStart result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
result.set_color_rgba(color);
result.set_group_id(group_id);
result.set_address_in_function(address_in_function);
orbit_api::EncodeString(name, &result);
return result;
}
static orbit_grpc_protos::ApiScopeStop CreateStopScope(uint64_t timestamp_ns, int32_t process_id,
int32_t thread_id) {
orbit_grpc_protos::ApiScopeStop result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
return result;
}
static orbit_grpc_protos::ApiScopeStartAsync CreateStartScopeAsync(
const char* name, uint64_t timestamp_ns, int32_t process_id, int32_t thread_id, uint64_t id,
uint64_t address_in_function, orbit_api_color color = kOrbitColorAuto) {
orbit_grpc_protos::ApiScopeStartAsync result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
result.set_color_rgba(color);
result.set_id(id);
result.set_address_in_function(address_in_function);
orbit_api::EncodeString(name, &result);
return result;
}
static orbit_grpc_protos::ApiScopeStopAsync CreateStopScopeAsync(uint64_t timestamp_ns,
int32_t process_id,
int32_t thread_id, uint64_t id) {
orbit_grpc_protos::ApiScopeStopAsync result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
result.set_id(id);
return result;
}
static orbit_grpc_protos::ApiStringEvent CreateStringEvent(uint64_t timestamp_ns,
int32_t process_id, int32_t thread_id,
uint64_t id, const char* name) {
orbit_grpc_protos::ApiStringEvent result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
result.set_id(id);
orbit_api::EncodeString(name, &result);
return result;
}
static orbit_client_protos::ApiStringEvent CreateClientStringEvent(uint64_t timestamp_ns,
int32_t process_id,
int32_t thread_id, uint64_t id,
const char* name) {
orbit_client_protos::ApiStringEvent result;
result.set_timestamp_ns(timestamp_ns);
result.set_process_id(process_id);
result.set_thread_id(thread_id);
result.set_async_scope_id(id);
result.set_name(name);
return result;
}
template <typename DataType, typename ProtoType>
static ProtoType CreateTrackValue(uint64_t timestamp_ns, int32_t process_id, int32_t thread_id,
const char* name, DataType data) {
ProtoType result;
result.set_timestamp_ns(timestamp_ns);
result.set_pid(process_id);
result.set_tid(thread_id);
result.set_data(data);
orbit_api::EncodeString(name, &result);
return result;
}
template <typename DataType>
static orbit_client_protos::ApiTrackValue CreateClientTrackValue(
uint64_t timestamp_ns, int32_t process_id, int32_t thread_id, const char* name,
void (orbit_client_protos::ApiTrackValue::*set_data)(DataType), DataType data) {
orbit_client_protos::ApiTrackValue result;
result.set_timestamp_ns(timestamp_ns);
result.set_process_id(process_id);
result.set_thread_id(thread_id);
result.set_name(name);
(result.*set_data)(data);
return result;
}
[[deprecated]] static orbit_grpc_protos::ApiEvent CreateApiEventLegacy(
int32_t pid, int32_t tid, uint64_t timestamp_ns, orbit_api::EventType type,
const char* name = nullptr, uint64_t data = 0, orbit_api_color color = kOrbitColorAuto) {
orbit_api::EncodedEvent encoded_event(type, name, data, color);
ApiEvent api_event;
api_event.set_timestamp_ns(timestamp_ns);
api_event.set_pid(pid);
api_event.set_tid(tid);
api_event.set_r0(encoded_event.args[0]);
api_event.set_r1(encoded_event.args[1]);
api_event.set_r2(encoded_event.args[2]);
api_event.set_r3(encoded_event.args[3]);
api_event.set_r4(encoded_event.args[4]);
api_event.set_r5(encoded_event.args[5]);
return api_event;
}
static orbit_client_protos::TimerInfo CreateTimerInfo(uint64_t start, uint64_t end,
int32_t process_id, int32_t thread_id,
const char* name, uint32_t depth,
uint64_t group_id, uint64_t async_scope_id,
uint64_t address_in_function,
TimerInfo::Type type) {
orbit_client_protos::TimerInfo timer;
timer.set_start(start);
timer.set_end(end);
timer.set_process_id(process_id);
timer.set_thread_id(thread_id);
timer.set_api_scope_name(name);
timer.set_type(type);
timer.set_group_id(group_id);
timer.set_api_async_scope_id(async_scope_id);
timer.set_address_in_function(address_in_function);
timer.set_depth(depth);
return timer;
}
MockCaptureListener capture_listener_;
ApiEventProcessor api_event_processor_;
static constexpr int32_t kProcessId = 42;
static constexpr int32_t kThreadId1 = 12;
static constexpr int32_t kThreadId2 = 13;
static constexpr uint64_t kGroupId = 77;
static constexpr uint64_t kId1 = 89;
static constexpr uint64_t kId2 = 99;
static constexpr uint64_t kId3 = 109;
static constexpr uint64_t kAddressInFunction = 111;
};
} // namespace
TEST_F(ApiEventProcessorTest, ScopesFromSameThread) {
auto start_0 =
CreateStartScope("Scope0", 1, kProcessId, kThreadId1, kGroupId, kAddressInFunction);
auto start_1 =
CreateStartScope("Scope1", 2, kProcessId, kThreadId1, kGroupId, kAddressInFunction);
auto start_2 =
CreateStartScope("Scope2", 3, kProcessId, kThreadId1, kGroupId, kAddressInFunction);
auto stop_2 = CreateStopScope(4, kProcessId, kThreadId1);
auto stop_1 = CreateStopScope(5, kProcessId, kThreadId1);
auto stop_0 = CreateStopScope(6, kProcessId, kThreadId1);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiScopeStart(start_0);
api_event_processor_.ProcessApiScopeStart(start_1);
api_event_processor_.ProcessApiScopeStart(start_2);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(3)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiScopeStop(stop_2);
api_event_processor_.ProcessApiScopeStop(stop_1);
api_event_processor_.ProcessApiScopeStop(stop_0);
auto expected_timer_2 = CreateTimerInfo(3, 4, kProcessId, kThreadId1, "Scope2", 2, kGroupId, 0,
kAddressInFunction, TimerInfo::kApiScope);
auto expected_timer_1 = CreateTimerInfo(2, 5, kProcessId, kThreadId1, "Scope1", 1, kGroupId, 0,
kAddressInFunction, TimerInfo::kApiScope);
auto expected_timer_0 = CreateTimerInfo(1, 6, kProcessId, kThreadId1, "Scope0", 0, kGroupId, 0,
kAddressInFunction, TimerInfo::kApiScope);
ASSERT_THAT(actual_timers.size(), 3);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_2, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[2]));
}
TEST_F(ApiEventProcessorTest, ScopesFromDifferentThreads) {
auto start_0 =
CreateStartScope("Scope0", 1, kProcessId, kThreadId1, kGroupId, kAddressInFunction);
auto start_1 =
CreateStartScope("Scope1", 2, kProcessId, kThreadId2, kGroupId, kAddressInFunction);
auto stop_2 = CreateStopScope(4, kProcessId, kThreadId1);
auto stop_1 = CreateStopScope(5, kProcessId, kThreadId2);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiScopeStart(start_0);
api_event_processor_.ProcessApiScopeStart(start_1);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(2)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiScopeStop(stop_2);
api_event_processor_.ProcessApiScopeStop(stop_1);
auto expected_timer_0 = CreateTimerInfo(1, 4, kProcessId, kThreadId1, "Scope0", 0, kGroupId, 0,
kAddressInFunction, TimerInfo::kApiScope);
auto expected_timer_1 = CreateTimerInfo(2, 5, kProcessId, kThreadId2, "Scope1", 0, kGroupId, 0,
kAddressInFunction, TimerInfo::kApiScope);
ASSERT_THAT(actual_timers.size(), 2);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
}
TEST_F(ApiEventProcessorTest, AsyncScopes) {
auto start_0 =
CreateStartScopeAsync("AsyncScope0", 1, kProcessId, kThreadId1, kId1, kAddressInFunction);
auto start_1 =
CreateStartScopeAsync("AsyncScope1", 2, kProcessId, kThreadId1, kId2, kAddressInFunction);
auto start_2 =
CreateStartScopeAsync("AsyncScope2", 3, kProcessId, kThreadId1, kId3, kAddressInFunction);
auto stop_2 = CreateStopScopeAsync(4, kProcessId, kThreadId1, kId3);
auto stop_1 = CreateStopScopeAsync(5, kProcessId, kThreadId1, kId2);
auto stop_0 = CreateStopScopeAsync(6, kProcessId, kThreadId1, kId1);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiScopeStartAsync(start_0);
api_event_processor_.ProcessApiScopeStartAsync(start_1);
api_event_processor_.ProcessApiScopeStartAsync(start_2);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(3)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiScopeStopAsync(stop_2);
api_event_processor_.ProcessApiScopeStopAsync(stop_1);
api_event_processor_.ProcessApiScopeStopAsync(stop_0);
auto expected_timer_2 = CreateTimerInfo(3, 4, kProcessId, kThreadId1, "AsyncScope2", 0, 0, kId3,
kAddressInFunction, TimerInfo::kApiScopeAsync);
auto expected_timer_1 = CreateTimerInfo(2, 5, kProcessId, kThreadId1, "AsyncScope1", 0, 0, kId2,
kAddressInFunction, TimerInfo::kApiScopeAsync);
auto expected_timer_0 = CreateTimerInfo(1, 6, kProcessId, kThreadId1, "AsyncScope0", 0, 0, kId1,
kAddressInFunction, TimerInfo::kApiScopeAsync);
ASSERT_THAT(actual_timers.size(), 3);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_2, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[2]));
}
TEST_F(ApiEventProcessorTest, StringEvent) {
auto string_event = CreateStringEvent(1, kProcessId, kThreadId1, kId1, "Some string for this id");
auto expected_string_event =
CreateClientStringEvent(1, kProcessId, kThreadId1, kId1, "Some string for this id");
orbit_client_protos::ApiStringEvent actual_string_event;
EXPECT_CALL(capture_listener_, OnApiStringEvent)
.Times(1)
.WillOnce(SaveArg<0>(&actual_string_event));
api_event_processor_.ProcessApiStringEvent(string_event);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_string_event, actual_string_event));
}
TEST_F(ApiEventProcessorTest, TrackDouble) {
auto track_double = CreateTrackValue<double, orbit_grpc_protos::ApiTrackDouble>(
1, kProcessId, kThreadId1, "Some name", 3.14);
auto expected_track_value =
CreateClientTrackValue<double>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_double, 3.14);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackDouble(track_double);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackFloat) {
auto track_float = CreateTrackValue<float, orbit_grpc_protos::ApiTrackFloat>(
1, kProcessId, kThreadId1, "Some name", 3.14f);
auto expected_track_value =
CreateClientTrackValue<float>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_float, 3.14f);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackFloat(track_float);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackInt) {
auto track_int = CreateTrackValue<int32_t, orbit_grpc_protos::ApiTrackInt>(
1, kProcessId, kThreadId1, "Some name", 3);
auto expected_track_value = CreateClientTrackValue<int32_t>(
1, kProcessId, kThreadId1, "Some name", &orbit_client_protos::ApiTrackValue::set_data_int, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackInt(track_int);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackInt64) {
auto track_int64 = CreateTrackValue<int64_t, orbit_grpc_protos::ApiTrackInt64>(
1, kProcessId, kThreadId1, "Some name", 3);
auto expected_track_value =
CreateClientTrackValue<int64_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_int64, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackInt64(track_int64);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackUint) {
auto track_uint = CreateTrackValue<uint32_t, orbit_grpc_protos::ApiTrackUint>(
1, kProcessId, kThreadId1, "Some name", 3);
auto expected_track_value =
CreateClientTrackValue<uint32_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_uint, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackUint(track_uint);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackUint64) {
auto track_uint64 = CreateTrackValue<uint64_t, orbit_grpc_protos::ApiTrackUint64>(
1, kProcessId, kThreadId1, "Some name", 3);
auto expected_track_value =
CreateClientTrackValue<uint64_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_uint64, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiTrackUint64(track_uint64);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, ScopesFromSameThreadLegacy) {
ApiEvent start_0 =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kScopeStart, "Scope0");
ApiEvent start_1 =
CreateApiEventLegacy(kProcessId, kThreadId1, 2, orbit_api::EventType::kScopeStart, "Scope1");
ApiEvent start_2 =
CreateApiEventLegacy(kProcessId, kThreadId1, 3, orbit_api::EventType::kScopeStart, "Scope2");
ApiEvent stop_2 =
CreateApiEventLegacy(kProcessId, kThreadId1, 4, orbit_api::EventType::kScopeStop);
ApiEvent stop_1 =
CreateApiEventLegacy(kProcessId, kThreadId1, 5, orbit_api::EventType::kScopeStop);
ApiEvent stop_0 =
CreateApiEventLegacy(kProcessId, kThreadId1, 6, orbit_api::EventType::kScopeStop);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiEventLegacy(start_0);
api_event_processor_.ProcessApiEventLegacy(start_1);
api_event_processor_.ProcessApiEventLegacy(start_2);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(3)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiEventLegacy(stop_2);
api_event_processor_.ProcessApiEventLegacy(stop_1);
api_event_processor_.ProcessApiEventLegacy(stop_0);
auto expected_timer_2 =
CreateTimerInfo(3, 4, kProcessId, kThreadId1, "Scope2", 2, 0, 0, 0, TimerInfo::kApiScope);
auto expected_timer_1 =
CreateTimerInfo(2, 5, kProcessId, kThreadId1, "Scope1", 1, 0, 0, 0, TimerInfo::kApiScope);
auto expected_timer_0 =
CreateTimerInfo(1, 6, kProcessId, kThreadId1, "Scope0", 0, 0, 0, 0, TimerInfo::kApiScope);
ASSERT_THAT(actual_timers.size(), 3);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_2, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[2]));
}
TEST_F(ApiEventProcessorTest, ScopesFromDifferentThreadsLegacy) {
auto start_0 =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kScopeStart, "Scope0");
auto start_1 =
CreateApiEventLegacy(kProcessId, kThreadId2, 2, orbit_api::EventType::kScopeStart, "Scope1");
auto stop_0 = CreateApiEventLegacy(kProcessId, kThreadId1, 4, orbit_api::EventType::kScopeStop);
auto stop_1 = CreateApiEventLegacy(kProcessId, kThreadId2, 5, orbit_api::EventType::kScopeStop);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiEventLegacy(start_0);
api_event_processor_.ProcessApiEventLegacy(start_1);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(2)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiEventLegacy(stop_0);
api_event_processor_.ProcessApiEventLegacy(stop_1);
auto expected_timer_0 =
CreateTimerInfo(1, 4, kProcessId, kThreadId1, "Scope0", 0, 0, 0, 0, TimerInfo::kApiScope);
auto expected_timer_1 =
CreateTimerInfo(2, 5, kProcessId, kThreadId2, "Scope1", 0, 0, 0, 0, TimerInfo::kApiScope);
ASSERT_THAT(actual_timers.size(), 2);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
}
TEST_F(ApiEventProcessorTest, AsyncScopesLegacy) {
auto start_0 = CreateApiEventLegacy(kProcessId, kThreadId1, 1,
orbit_api::EventType::kScopeStartAsync, "AsyncScope0", kId1);
auto start_1 = CreateApiEventLegacy(kProcessId, kThreadId1, 2,
orbit_api::EventType::kScopeStartAsync, "AsyncScope1", kId2);
auto start_2 = CreateApiEventLegacy(kProcessId, kThreadId1, 3,
orbit_api::EventType::kScopeStartAsync, "AsyncScope2", kId3);
auto stop_2 = CreateApiEventLegacy(kProcessId, kThreadId1, 4,
orbit_api::EventType::kScopeStopAsync, nullptr, kId3);
auto stop_1 = CreateApiEventLegacy(kProcessId, kThreadId1, 5,
orbit_api::EventType::kScopeStopAsync, nullptr, kId2);
auto stop_0 = CreateApiEventLegacy(kProcessId, kThreadId1, 6,
orbit_api::EventType::kScopeStopAsync, nullptr, kId1);
EXPECT_CALL(capture_listener_, OnTimer).Times(0);
api_event_processor_.ProcessApiEventLegacy(start_0);
api_event_processor_.ProcessApiEventLegacy(start_1);
api_event_processor_.ProcessApiEventLegacy(start_2);
::testing::Mock::VerifyAndClearExpectations(&capture_listener_);
std::vector<orbit_client_protos::TimerInfo> actual_timers;
EXPECT_CALL(capture_listener_, OnTimer)
.Times(3)
.WillRepeatedly(
Invoke([&actual_timers](const TimerInfo& timer) { actual_timers.push_back(timer); }));
api_event_processor_.ProcessApiEventLegacy(stop_2);
api_event_processor_.ProcessApiEventLegacy(stop_1);
api_event_processor_.ProcessApiEventLegacy(stop_0);
auto expected_timer_2 = CreateTimerInfo(3, 4, kProcessId, kThreadId1, "AsyncScope2", 0, 0, kId3,
0, TimerInfo::kApiScopeAsync);
auto expected_timer_1 = CreateTimerInfo(2, 5, kProcessId, kThreadId1, "AsyncScope1", 0, 0, kId2,
0, TimerInfo::kApiScopeAsync);
auto expected_timer_0 = CreateTimerInfo(1, 6, kProcessId, kThreadId1, "AsyncScope0", 0, 0, kId1,
0, TimerInfo::kApiScopeAsync);
ASSERT_THAT(actual_timers.size(), 3);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_2, actual_timers[0]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_1, actual_timers[1]));
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_timer_0, actual_timers[2]));
}
TEST_F(ApiEventProcessorTest, StringEventLegacy) {
auto string_event = CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kString,
"Some string for this id", kId1);
auto expected_string_event =
CreateClientStringEvent(1, kProcessId, kThreadId1, kId1, "Some string for this id");
orbit_client_protos::ApiStringEvent actual_string_event;
EXPECT_CALL(capture_listener_, OnApiStringEvent)
.Times(1)
.WillOnce(SaveArg<0>(&actual_string_event));
api_event_processor_.ProcessApiEventLegacy(string_event);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_string_event, actual_string_event));
}
TEST_F(ApiEventProcessorTest, TrackDoubleLegacy) {
auto track_double =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackDouble,
"Some name", orbit_api::Encode<uint64_t>(3.14));
auto expected_track_value =
CreateClientTrackValue<double>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_double, 3.14);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_double);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackFloatLegacy) {
auto track_float =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackFloat,
"Some name", orbit_api::Encode<uint64_t>(3.14f));
auto expected_track_value =
CreateClientTrackValue<float>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_float, 3.14f);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_float);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackIntLegacy) {
auto track_int = CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackInt,
"Some name", orbit_api::Encode<uint64_t>(3));
auto expected_track_value = CreateClientTrackValue<int32_t>(
1, kProcessId, kThreadId1, "Some name", &orbit_client_protos::ApiTrackValue::set_data_int, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_int);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackInt64Legacy) {
auto track_int64 =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackInt64,
"Some name", orbit_api::Encode<uint64_t>(3));
auto expected_track_value =
CreateClientTrackValue<int64_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_int64, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_int64);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackUintLegacy) {
auto track_uint =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackUint, "Some name",
orbit_api::Encode<uint64_t>(3));
auto expected_track_value =
CreateClientTrackValue<uint32_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_uint, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_uint);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
TEST_F(ApiEventProcessorTest, TrackUint64Legacy) {
auto track_uint64 =
CreateApiEventLegacy(kProcessId, kThreadId1, 1, orbit_api::EventType::kTrackUint64,
"Some name", orbit_api::Encode<uint64_t>(3));
auto expected_track_value =
CreateClientTrackValue<uint64_t>(1, kProcessId, kThreadId1, "Some name",
&orbit_client_protos::ApiTrackValue::set_data_uint64, 3);
orbit_client_protos::ApiTrackValue actual_track_value;
EXPECT_CALL(capture_listener_, OnApiTrackValue)
.Times(1)
.WillOnce(SaveArg<0>(&actual_track_value));
api_event_processor_.ProcessApiEventLegacy(track_uint64);
EXPECT_TRUE(MessageDifferencer::Equivalent(expected_track_value, actual_track_value));
}
} // namespace orbit_capture_client
| 42.678899 | 100 | 0.722239 |
04d40f9e787b564f642642ee7994d11a5d03a4e8 | 9,674 | java | Java | springboot/springboot-jdbc-druid/src/main/java/com/example/springbootdruid/config/MultiDataSourceRegister.java | offline7LY/demo | c6b8f21a305a5e5f21730549eff3056026acba69 | [
"Apache-2.0"
] | null | null | null | springboot/springboot-jdbc-druid/src/main/java/com/example/springbootdruid/config/MultiDataSourceRegister.java | offline7LY/demo | c6b8f21a305a5e5f21730549eff3056026acba69 | [
"Apache-2.0"
] | null | null | null | springboot/springboot-jdbc-druid/src/main/java/com/example/springbootdruid/config/MultiDataSourceRegister.java | offline7LY/demo | c6b8f21a305a5e5f21730549eff3056026acba69 | [
"Apache-2.0"
] | null | null | null | package com.example.springbootdruid.config;
import com.alibaba.druid.filter.Filter;
import com.alibaba.druid.pool.DruidDataSource;
import com.example.springbootdruid.filter.DispatchPartitionFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
import org.springframework.boot.context.properties.source.ConfigurationPropertyNameAliases;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Title: MultiDataSourceRegister
* @Package com/example/springbootdruid/config/MultiDataSourceRegister.java
* @Description: 多数据源支持, 自定义方式注入到spring容器中, 使用时根据key动态使用
* {@see org.springframework.boot.jdbc.DataSourceBuilder}
*
* <dependency>
* <groupId>com.baomidou</groupId>
* <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
* <version>3.3.1</version>
* </dependency>
* 上述pom开源处理1主多从, 可以参考
* @author zhaozhiwei
* @date 2021/7/5 下午9:35
* @version V1.0
*/
public class MultiDataSourceRegister implements EnvironmentAware, ImportBeanDefinitionRegistrar {
private static final Logger logger = LoggerFactory.getLogger(MultiDataSourceRegister.class);
//别名
private final static ConfigurationPropertyNameAliases aliases = new ConfigurationPropertyNameAliases();
static {
//由于部分数据源配置不同,所以在此处添加别名,避免切换数据源出现某些参数无法注入的情况
aliases.addAliases("url", new String[]{"jdbc-url"});
aliases.addAliases("username", new String[]{"user"});
}
/**
* 配置上下文(也可以理解为配置文件的获取工具)
*/
private Environment evn;
/**
* 数据源列表
*/
private Map<String, DataSource> customDataSources;
/**
* 参数绑定工具
*/
private Binder binder;
private boolean isSuportJTA() {
boolean suportJta = binder.bind("spring.datasource.jta", Boolean.class).get();
return suportJta;
}
/**
* ImportBeanDefinitionRegistrar接口的实现方法,通过该方法可以按照自己的方式注册bean
*
* @param annotationMetadata
* @param beanDefinitionRegistry
* {@see com.lx.demo.config.DataSourceConfigDynamic#dataSource}
*/
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
logger.info("注册默认数据源开始");
if (!binder.bind("spring.datasource", Map.class).isBound()) {
return;
}
//获取所有数据源配置
Map config, properties, defaultConfig, atomikosConfig = null;
defaultConfig = binder.bind("spring.datasource", Map.class).get();
defaultConfig.put("type", "com.alibaba.druid.pool.DruidDataSource");
customDataSources = new HashMap<>();
//默认配置
properties = defaultConfig;
//默认数据源类型
String typeStr = (String) properties.get("type");
String defaultTargetKey = "default";
//获取数据源类型
Class<? extends DataSource> clazz = getDataSourceType(typeStr);
//绑定默认数据源参数
DataSource consumerDatasource, defaultDatasource = bind(clazz, properties);
addFilters(defaultDatasource);
boolean openMulti = binder.bind("spring.datasource.openmulti", Boolean.class).get();
logger.info("注册默认数据源{}成功",defaultTargetKey);
if(openMulti && binder.bind("spring.datasource.multi", Map.class).isBound()) {
//获取其他数据源配置
List<Map> configs = binder.bind("spring.datasource.multi", Bindable.listOf(Map.class)).get();
//遍历生成其他数据源
for (Map map : configs) {
config = map;
//获取extend字段,未定义或为true则为继承状态
if ((boolean) config.getOrDefault("extend", Boolean.TRUE)) {
//继承默认数据源配置
properties = new HashMap(defaultConfig);
//添加数据源参数
properties.putAll(config);
} else {
//不继承默认配置
properties = config;
}
//绑定参数
if (properties.containsKey("type")) {
Class<? extends DataSource> clazz1 = getDataSourceType((String) properties.get("type"));
consumerDatasource = bind(clazz1, properties);
} else {
consumerDatasource = bind(clazz, properties);
}
// 获取数据源的key,以便通过该key可以定位到数据源
String key = properties.get("key").toString();
//获取数据源的key,以便通过该key可以定位到数据源
addFilters(consumerDatasource);
customDataSources.put(key, consumerDatasource);
logger.info("注册数据源{}成功", key);
}
}
//bean定义类
GenericBeanDefinition define = new GenericBeanDefinition();
//设置bean的类型,此处MultiDataSource是继承AbstractRoutingDataSource的实现类
define.setBeanClass(MultiDataSource.class);
//需要注入的参数,类似spring配置文件中的<property/>
MutablePropertyValues mpv = define.getPropertyValues();
//添加默认数据源,避免key不存在的情况没有数据源可用
mpv.add("defaultTargetDataSource", defaultDatasource);
//添加其他数据源, 可以增加多个从数据源, 利用反射直接塞到父类
// com.example.springbootdruid.config.MultiDataSource
// |
// |
// \/
//org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
mpv.add("targetDataSources", customDataSources);
//将该bean注册为datasource,不使用springboot自动生成的datasource
beanDefinitionRegistry.registerBeanDefinition("datasource", define);
// BeanDefinitionRegistry registry = ((BeanDefinitionRegistry) ((DefaultListableBeanFactory) beanDefinitionRegistry).getParentBeanFactory());
// registry.registerBeanDefinition("datasource", define);
logger.info("注册数据源成功,一共注册{}个数据源", customDataSources.keySet().size() + 1);
}
/**
* 通过字符串获取数据源class对象
*
* @param typeStr
* @return
*/
private Class<? extends DataSource> getDataSourceType(String typeStr) {
Class<? extends DataSource> type;
try {
//字符串不为空则通过反射获取class对象
if (StringUtils.hasLength(typeStr)) {
type = (Class<? extends DataSource>) Class.forName(typeStr);
} else {
//默认为hikariCP数据源,与springboot默认数据源保持一致
type = DruidDataSource.class;
}
return type;
} catch (Exception e) {
//无法通过反射获取class对象的情况则抛出异常,该情况一般是写错了,所以此次抛出一个runtimeexception
throw new IllegalArgumentException("can not resolve class with type: " + typeStr);
}
}
/**
* 绑定参数,以下三个方法都是参考DataSourceBuilder的bind方法实现的,目的是尽量保证我们自己添加的数据源构造过程与springboot保持一致
*
* @param result
* @param properties
*/
private void bind(DataSource result, Map properties) {
ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
Binder binder = new Binder(new ConfigurationPropertySource[]{source.withAliases(aliases)});
//将参数绑定到对象
binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(result));
}
private <T extends DataSource> T bind(Class<T> clazz, Map properties) {
ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
Binder binder = new Binder(new ConfigurationPropertySource[]{source.withAliases(aliases)});
//通过类型绑定参数并获得实例对象
return binder.bind(ConfigurationPropertyName.EMPTY, Bindable.of(clazz)).get();
}
/**
* @param clazz
* @param sourcePath 参数路径,对应配置文件中的值,如: spring.datasource
* @param <T>
* @return
*/
private <T extends DataSource> T bind(Class<T> clazz, String sourcePath) {
Map properties = binder.bind(sourcePath, Map.class).get();
return bind(clazz, properties);
}
private void addFilters(DataSource dataSource) {
if (dataSource instanceof DruidDataSource) {
DruidDataSource druidDataSource = (DruidDataSource) dataSource;
List<Filter> filters = new ArrayList<Filter>();
// if(DbTypeUtil.DB_TYPE_POLARDB.equals(DbTypeUtil.getPhysicsDbType())) {
// 增加数据源过滤器,处理特殊业务
filters.add(new DispatchPartitionFilter());
// }
druidDataSource.setProxyFilters(filters);
try {
druidDataSource.addFilters("config");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* EnvironmentAware接口的实现方法,通过aware的方式注入,此处是environment对象
*
* @param environment
*/
@Override
public void setEnvironment(Environment environment) {
this.evn = environment;
//绑定配置器
binder = Binder.get(evn);
}
}
| 38.851406 | 148 | 0.657329 |
e8e8b8176423c6bd8c7379484511cbc12b862f8a | 3,568 | hpp | C++ | include/defs.hpp | Josh-MB/Information-Theory-Potts-Model | 74e4c61d2f1bdbc345431fb1d4bade2b5b08f055 | [
"MIT"
] | null | null | null | include/defs.hpp | Josh-MB/Information-Theory-Potts-Model | 74e4c61d2f1bdbc345431fb1d4bade2b5b08f055 | [
"MIT"
] | null | null | null | include/defs.hpp | Josh-MB/Information-Theory-Potts-Model | 74e4c61d2f1bdbc345431fb1d4bade2b5b08f055 | [
"MIT"
] | null | null | null | #pragma once
#include <random>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
#include <numeric>
using u8 = char;
//Set to 5 since we are only using the 5-state model
u8 constexpr numStates = 5;
int constexpr CURRENT_DOS_FILE_VER = 3;
int constexpr CURRENT_GTE_FILE_VER = 4;
int constexpr numNeighbourhoods = 9; // Used for aggregating neighbours in GTE reduced
int constexpr numSiteEnergy = 5; // Number of possible energy values for a given site (-4, -3, -2, -1, 0)
constexpr int neighbour_sites = 4;
using Hist = std::vector<size_t>;
//Helper macros for wrapping lattice coordinates
inline size_t wrap_minus(size_t u, size_t L1) {return (u == 0) ? L1 : u - 1; }; // -1 with lattice wrap
inline size_t wrap_plus(size_t u, size_t L1) {return (u == L1) ? 0 : u + 1; }; // +1 with lattice wrap
//Helper functions for accumulating and clearing histograms
template <class T>
inline void clear_and_resize_vec(std::vector<T> & v) {auto sz = v.size(); v.clear(); v.resize(sz, 0); };
inline void acc_hist(Hist& source, Hist& dest) {std::transform(source.begin(), source.end(), dest.begin(), dest.begin(), std::plus<size_t>()); };
inline void acc_thread_hists(std::vector<Hist>& threadHists, Hist& dest) {
for (auto& v : threadHists) {
std::transform(v.begin(), v.end(), dest.begin(), dest.begin(), std::plus<size_t>());
clear_and_resize_vec(v);
}
}
inline int sgn(int const val) {
return (0 < val) - (val < 0);
}
inline int make_idx(int const x, const int y, const int L) {
return y * L + x;
}
// Wraps x in boundaries of L. i.e returns
// 0 if x == L, L-1 if x==-1 or x otherwise
inline int wrap(int const x, int const L) {
return x + ((x == L)*-L) + ((x == -1)*L);
}
//Works out the wrapped difference
inline int unwrap(int const x, int const L) {
if(x == L - 1)
return -1;
else if(x == 1 - L)
return 1;
else
return x;
}
//Helpers for write data to binary file
#define BIN_WRITE(var, type, num, file) if(fwrite(&var, sizeof(type), num, file) != num) {PEEXIT("write failed");}
#define BIN_WRITE_PTR(var, type, num, file) if(fwrite(var, sizeof(type), num, file) != num) {PEEXIT("write failed");}
#define BIN_READ(var, type, num, file) if(fread(&var, sizeof(type), num, file) != num) {PEEXIT("read failed");}
#define BIN_READ_PTR(var, type, num, file) if(fread(var, sizeof(type), num, file) != num) {PEEXIT("read failed");}
#define CHECK_VAL(var, expected, flag) if(var != expected) { std::cout << "vars not equal " << #var << ":" << var << ", " << #expected << ":" << expected << "\n"; flag = false;}
struct DoSFile {
int fileVersion{ -1 };
size_t L{ 0 };
size_t U{ 0 };
size_t seed{ 0 };
u8 numStates{ 0 };
double factor{ 0.0 };
size_t iteration{ 0 };
// logG with all elements where count=0 is removed
std::vector<double> logG_compressed;
std::vector<double> logG;
Hist hist;
std::vector<size_t> indices;
std::vector<u8> lattice;
};
void read_dos_file(char const*const dosFile, std::vector<double> &g, std::vector<int> &e, size_t& dosL);
// Read DoS data from file. If rand_engine is not nullptr, will update with the saved state
DoSFile read_dos_file(char const* const dosFile, std::mt19937_64* rand_engine = nullptr);
template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v) {
// initialize original index locations
std::vector<size_t> idx(v.size());
std::iota(idx.begin(), idx.end(), 0);
// sort indexes based on comparing values in v
std::sort(idx.begin(), idx.end(),
[&v](size_t i1, size_t i2) {return v[i1] > v[i2]; });
return idx;
} | 34.307692 | 177 | 0.672926 |
e90135a4209fc885d81c6e8f8663d6765a727fdc | 1,148 | cpp | C++ | data_structures/Stack/C++/StackUsingArrays.cpp | JD235/algorithms | 71346a498720dc3da064b3e61de0b369cf7eb76a | [
"MIT"
] | 44 | 2017-12-11T11:13:07.000Z | 2022-03-15T02:59:43.000Z | data_structures/Stack/C++/StackUsingArrays.cpp | JD235/algorithms | 71346a498720dc3da064b3e61de0b369cf7eb76a | [
"MIT"
] | 23 | 2018-10-06T06:17:21.000Z | 2021-03-08T17:13:53.000Z | data_structures/Stack/C++/StackUsingArrays.cpp | JD235/algorithms | 71346a498720dc3da064b3e61de0b369cf7eb76a | [
"MIT"
] | 113 | 2017-12-12T06:46:04.000Z | 2021-11-15T17:33:11.000Z | #include <iostream>
using namespace std;
#define MAX 10000
// defined a class stack
class Stack {
//top variable which represents the top of the stack
int top;
public:
//declared an array of MAX size to store the elements of the stack
int arr[MAX];
//top is intialised to -1 when stack is created
Stack() {
top = -1;
}
// function to push elements into the stack
bool push(int num) {
//maximum size of the stack
if (top >= MAX) {
cout << "Stack OverFlow" << endl;
return false;
}
else {
arr[++top] = num;
cout << num << " is pushed into the stack" << endl;
return true;
}
}
bool pop() {
//minimum size of the stack
if (top <= -1) {
cout << "Stack UnderFlow";
return false;
}
else {
int x = arr[top--];
cout << x << " is popped out of the stack" << endl;
return true;
}
}
bool isEmpty() {
//checking if stack is empty or not.
if (top <= -1) {
return true;
}
else return false;
}
};
int main() {
Stack s;
if (s.isEmpty()) cout << "Stack is empty" << endl;
s.push(10);
s.push(20);
if (!s.isEmpty()) cout << "Stack is not empty" << endl;
s.pop();
s.pop();
return 0;
} | 20.140351 | 67 | 0.599303 |
16e9e12eabd44d38000c7b19985d90a8f69a6cc3 | 996 | kt | Kotlin | src/main/kotlin/org/monsim/api/accounting/CashAccounter.kt | jimdmorgan/monsim | 0c97854234c874a6e5fa4b649ec0ca7719d77c21 | [
"MIT"
] | null | null | null | src/main/kotlin/org/monsim/api/accounting/CashAccounter.kt | jimdmorgan/monsim | 0c97854234c874a6e5fa4b649ec0ca7719d77c21 | [
"MIT"
] | null | null | null | src/main/kotlin/org/monsim/api/accounting/CashAccounter.kt | jimdmorgan/monsim | 0c97854234c874a6e5fa4b649ec0ca7719d77c21 | [
"MIT"
] | null | null | null | package org.monsim.api.accounting
import org.monsim.bean.Bill
import org.monsim.bean.domain.Game
interface CashAccounter {
/**
* Applies a bill (which contains a debitor, a creditor, and an amount).
* All the debitor's available cash is immediately taken and given to the creditor.
* So if the bill is for $200 and the debtor's available cash is $50, and the creditor's current cash is $1000,
* then the creditor's new cash is set to $1050, the debtor's cash is set to $-150.
*
* As the debtor acquires more cash (say by mortgaging property), the cash is immediately turned over to the creditor.
* So let's say the debtor gets $40 by mortgaging a property, then the debtor's new cash is -$110, and then creditor's cash
* becomes $1090.
*
* The bank never goes into debt, so if the debtor is the bank, then the bill is always paid in full and the creditor
* receives the full amount.
*/
fun applyBill(bill: Bill, game: Game)
} | 45.272727 | 127 | 0.696787 |
ab05f1fbca6c18565888a8ce36ab8844361c03d7 | 2,939 | cs | C# | src/AdventOfCode/Puzzles/Y2015/Day12.cs | martincostello/adventofcode | 380af433b11b6fdbe6c6b998fd24e72e33a9210f | [
"Apache-2.0"
] | 5 | 2015-12-01T14:13:32.000Z | 2022-03-25T13:14:44.000Z | src/AdventOfCode/Puzzles/Y2015/Day12.cs | martincostello/adventofcode | 380af433b11b6fdbe6c6b998fd24e72e33a9210f | [
"Apache-2.0"
] | 35 | 2016-11-03T12:58:42.000Z | 2022-03-28T06:14:36.000Z | src/AdventOfCode/Puzzles/Y2015/Day12.cs | martincostello/adventofcode | 380af433b11b6fdbe6c6b998fd24e72e33a9210f | [
"Apache-2.0"
] | null | null | null | // Copyright (c) Martin Costello, 2015. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
using System.Text.Json;
namespace MartinCostello.AdventOfCode.Puzzles.Y2015;
/// <summary>
/// A class representing the puzzle for <c>https://adventofcode.com/2015/day/12</c>. This class cannot be inherited.
/// </summary>
[Puzzle(2015, 12, "JSAbacusFramework.io", RequiresData = true)]
public sealed class Day12 : Puzzle
{
/// <summary>
/// Gets the sum of the integers in the JSON document.
/// </summary>
internal long Sum { get; private set; }
/// <summary>
/// Sums the integer values in the specified JSON element, ignoring any values from
/// child elements that contain the specified string value, if specified.
/// </summary>
/// <param name="element">The JSON element.</param>
/// <param name="valueToIgnore">The elements to ignore if they contain this value.</param>
/// <returns>The sum of the elements in <paramref name="element"/>.</returns>
internal static long SumIntegerValues(JsonElement element, string valueToIgnore)
{
long sum = 0;
if (element.ValueKind == JsonValueKind.Number)
{
sum = element.GetInt64();
}
else if (element.ValueKind == JsonValueKind.Array)
{
foreach (JsonElement child in element.EnumerateArray())
{
sum += SumIntegerValues(child, valueToIgnore);
}
}
else if (element.ValueKind == JsonValueKind.Object)
{
foreach (JsonProperty child in element.EnumerateObject())
{
if (child.Value.ValueKind == JsonValueKind.String &&
child.Value.GetString() == valueToIgnore)
{
return 0;
}
sum += SumIntegerValues(child.Value, valueToIgnore);
}
}
return sum;
}
/// <inheritdoc />
protected override async Task<PuzzleResult> SolveCoreAsync(string[] args, CancellationToken cancellationToken)
{
Stream resource = Resource ?? ReadResource();
try
{
using var document = await JsonDocument.ParseAsync(resource, cancellationToken: cancellationToken);
string keyToIgnore = args.Length > 0 ? args[0] : string.Empty;
Sum = SumIntegerValues(document.RootElement, keyToIgnore);
if (Verbose)
{
Logger.WriteLine("The sum of the integers in the JSON document is {0:N0}.", Sum);
}
}
finally
{
if (Resource is null)
{
await resource.DisposeAsync();
}
}
return PuzzleResult.Create(Sum);
}
}
| 34.174419 | 117 | 0.576046 |
33319c7108f2f54f95e8dca0a5199386d7358140 | 2,760 | py | Python | cfgs/config.py | Pandinosaurus/yolo2-pytorch | f046769ea157e6d57579c67dcef62fdd3b71111e | [
"MIT"
] | 1,663 | 2017-02-25T02:09:58.000Z | 2022-03-31T07:18:30.000Z | cfgs/config.py | Guroto/yolo2-pytorch | 17056ca69f097a07884135d9031c53d4ef217a6a | [
"MIT"
] | 115 | 2017-03-04T12:26:49.000Z | 2022-01-06T04:02:44.000Z | cfgs/config.py | Guroto/yolo2-pytorch | 17056ca69f097a07884135d9031c53d4ef217a6a | [
"MIT"
] | 492 | 2017-02-28T20:09:14.000Z | 2022-03-18T21:25:10.000Z | import os
from .config_voc import * # noqa
from .exps.darknet19_exp1 import * # noqa
def mkdir(path, max_depth=3):
parent, child = os.path.split(path)
if not os.path.exists(parent) and max_depth > 1:
mkdir(parent, max_depth-1)
if not os.path.exists(path):
os.mkdir(path)
# input and output size
############################
multi_scale_inp_size = [np.array([320, 320], dtype=np.int),
np.array([352, 352], dtype=np.int),
np.array([384, 384], dtype=np.int),
np.array([416, 416], dtype=np.int),
np.array([448, 448], dtype=np.int),
np.array([480, 480], dtype=np.int),
np.array([512, 512], dtype=np.int),
np.array([544, 544], dtype=np.int),
np.array([576, 576], dtype=np.int),
# np.array([608, 608], dtype=np.int),
] # w, h
multi_scale_out_size = [multi_scale_inp_size[0] / 32,
multi_scale_inp_size[1] / 32,
multi_scale_inp_size[2] / 32,
multi_scale_inp_size[3] / 32,
multi_scale_inp_size[4] / 32,
multi_scale_inp_size[5] / 32,
multi_scale_inp_size[6] / 32,
multi_scale_inp_size[7] / 32,
multi_scale_inp_size[8] / 32,
# multi_scale_inp_size[9] / 32,
] # w, h
inp_size = np.array([416, 416], dtype=np.int) # w, h
out_size = inp_size / 32
# for display
############################
def _to_color(indx, base):
""" return (b, r, g) tuple"""
base2 = base * base
b = 2 - indx / base2
r = 2 - (indx % base2) / base
g = 2 - (indx % base2) % base
return b * 127, r * 127, g * 127
base = int(np.ceil(pow(num_classes, 1. / 3)))
colors = [_to_color(x, base) for x in range(num_classes)]
# detection config
############################
thresh = 0.3
# dir config
############################
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
DATA_DIR = os.path.join(ROOT_DIR, 'data')
MODEL_DIR = os.path.join(ROOT_DIR, 'models')
TRAIN_DIR = os.path.join(MODEL_DIR, 'training')
TEST_DIR = os.path.join(MODEL_DIR, 'testing')
trained_model = os.path.join(MODEL_DIR, h5_fname)
pretrained_model = os.path.join(MODEL_DIR, pretrained_fname)
train_output_dir = os.path.join(TRAIN_DIR, exp_name)
test_output_dir = os.path.join(TEST_DIR, imdb_test, h5_fname)
mkdir(train_output_dir, max_depth=3)
mkdir(test_output_dir, max_depth=4)
rand_seed = 1024
use_tensorboard = True
log_interval = 50
disp_interval = 10
| 33.253012 | 73 | 0.537681 |
d2606496c1dbb6e49b167cb3861ce264ec93d3db | 2,211 | php | PHP | _src/Chapter 07/1625OS_09_Code/student-portal/controllers/students.php | paullewallencom/php-978-1-7839-8162-5 | abf288978f803ab913775df7841a883e2986a604 | [
"Apache-2.0"
] | null | null | null | _src/Chapter 07/1625OS_09_Code/student-portal/controllers/students.php | paullewallencom/php-978-1-7839-8162-5 | abf288978f803ab913775df7841a883e2986a604 | [
"Apache-2.0"
] | null | null | null | _src/Chapter 07/1625OS_09_Code/student-portal/controllers/students.php | paullewallencom/php-978-1-7839-8162-5 | abf288978f803ab913775df7841a883e2986a604 | [
"Apache-2.0"
] | null | null | null | <?php
class Students extends Base_Controller{
public function __construct(){
parent::__construct();
$this->loadModel("students");
}
public function add(){
if(isset($_POST['submit'])){
unset($_POST['submit']);
$this->view->id = $this->model->addStudent($_POST);
}
$this->view->render('students/add');
}
public function get($id=null){
$this->logger->info("get action been requested");
$this->view->message = isset($_GET['message']) ? $_GET['message'] : '';
if(isset($_GET['message']) && $_GET['message']=='importSuccess'){
$this->view->message = 'Import is successful';
}
$student_data = $this->cache->get('student_data');
if(!$student_data){
$student_data = $this->model->getStudents();
$this->cache->set('student_data', $student_data);
}
$this->view->student_data = $student_data;
$this->view->render('students/get');
}
public function import(){
if(isset($_POST['submit'])){
if($_FILES['file']['error']==0){
if (($handle = fopen($_FILES['file']['tmp_name'], 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
$student['first_name'] = $data[0];
$student['last_name'] = $data[1];
$student['address'] = $data[2];
$student['city'] = $data[3];
$student['state'] = $data[4];
$student['zip_code'] = $data[5];
$student['username'] = $data[6];
$student['password'] = $data[7];
$this->model->addStudent($student);
}
}
header('Location:'.BASE_URL.'students/get?message=importSuccess');
}
}
}
public function export(){
$data = $this->model->getStudents();
$handle = fopen(ROOT_DIR.'/assets/files/students.csv', 'w+');
foreach ($data as $student) {
fputcsv($handle, array($student['student_id'], $student['first_name'], $student['last_name'],$student['address'],$student['city'],$student['state']));
}
fclose($handle);
header('Content-Disposition: attachment; filename="students.csv"');
header('Content-Type:application/csv');
readfile(ROOT_DIR.'/assets/files/students.csv');
error_log('Students.csv has been successfully exported');
//$this->logger->info("Students.csv has been successfully exported");
}
}
?>
| 27.987342 | 153 | 0.616915 |
fba7f8102a1445834f68c97fa58dc30d92c9a126 | 10,541 | java | Java | distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java | AlexOreshkevich/orientdb | 1db47be6f1780e5d00db1883c80e489f5991bd33 | [
"Apache-2.0"
] | 1 | 2016-07-18T21:23:06.000Z | 2016-07-18T21:23:06.000Z | distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java | e-d/orientdb | ae492591dcb2a962ed0728ff788bb97fb8526216 | [
"Apache-2.0"
] | null | null | null | distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java | e-d/orientdb | ae492591dcb2a962ed0728ff788bb97fb8526216 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2015 OrientDB LTD (info--at--orientdb.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.orientechnologies.orient.server.distributed.scenariotest;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.server.distributed.ODistributedConfiguration;
import com.orientechnologies.orient.server.distributed.ServerRun;
import com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Timer;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* It checks the consistency in the cluster with the following scenario:
* - 3 server (quorum=1)
* - deadlock on server3
* - record r1 inserted on server1
* - record r1 (version x) is present in full replica on all the servers
* - client c1 (connected to server1) updates r1 with the value v1, meanwhile client c2 (connected to server2) updates r1 with value v2
* - end of deadlock on server3
* - check consistency on the nodes:
* - r1 has the same value on all the servers
* - r1 has version x+1 on all the servers
*/
public class WWConflictAndNodeInDeadlockScenarioTest extends UpdateConflictFixTaskScenarioTest {
protected Timer timer = new Timer(true);
volatile int serverStarted = 0;
volatile boolean backupInProgress = false;
private volatile boolean server3inDeadlock = false;
@Ignore
@Test
public void test() throws Exception {
maxRetries = 10;
init(SERVERS);
prepare(false);
// execute writes only on server3
executeWritesOnServers.addAll(serverInstance);
execute();
}
@Override
public void executeTest() throws Exception {
/*
* Test with quorum = 1
*/
banner("Test with quorum = 1");
ODatabaseDocumentTx dbServer1 = poolFactory.get(getDatabaseURL(serverInstance.get(0)), "admin", "admin").acquire();
ODatabaseDocumentTx dbServer2 = poolFactory.get(getDatabaseURL(serverInstance.get(1)), "admin", "admin").acquire();
ODatabaseDocumentTx dbServer3 = poolFactory.get(getDatabaseURL(serverInstance.get(2)), "admin", "admin").acquire();
// changing configuration: writeQuorum=1, autoDeploy=false
System.out.print("\nChanging configuration (writeQuorum=1, autoDeploy=false)...");
ODocument cfg = null;
ServerRun server = serverInstance.get(2);
OHazelcastPlugin manager = (OHazelcastPlugin) server.getServerInstance().getDistributedManager();
ODistributedConfiguration databaseConfiguration = manager.getDatabaseConfiguration("distributed-inserttxha");
cfg = databaseConfiguration.serialize();
cfg.field("writeQuorum", 1);
cfg.field("failureAvailableNodesLessQuorum", true);
cfg.field("version", (Integer) cfg.field("version") + 1);
manager.updateCachedDatabaseConfiguration("distributed-inserttxha", cfg, true, true);
System.out.println("\nConfiguration updated.");
// deadlock on server3
this.server3inDeadlock = true;
Thread.sleep(200); // waiting for deadlock
// inserting record r1 and checking consistency on server1 and server2
System.out.print("Inserting record r1 and checking consistency...");
ODocument r1onServer1 = new ODocument("Person").fields("id", "R001", "firstName", "Han", "lastName", "Solo");
r1onServer1.save();
Thread.sleep(200);
ODocument r1onServer2 = retrieveRecord(getDatabaseURL(serverInstance.get(1)), "R001");
assertEquals(r1onServer1.field("@version"), r1onServer2.field("@version"));
assertEquals(r1onServer1.field("id"), r1onServer2.field("id"));
assertEquals(r1onServer1.field("firstName"), r1onServer2.field("firstName"));
assertEquals(r1onServer1.field("lastName"), r1onServer2.field("lastName"));
System.out.println("\tDone.");
// initial version of the record r1
int initialVersion = r1onServer1.field("@version");
// creating and executing two clients c1 and c2 (updating r1)
System.out.print("Building client c1 and client c2...");
List<Callable<Void>> clients = new LinkedList<Callable<Void>>();
clients.add(new ClientWriter(getDatabaseURL(serverInstance.get(0)), "R001", "Luke", "Skywalker"));
clients.add(new ClientWriter(getDatabaseURL(serverInstance.get(1)), "R001", "Darth", "Vader"));
System.out.println("\tDone.");
ExecutorService executor = Executors.newCachedThreadPool();
System.out.println("Concurrent update:");
List<Future<Void>> futures = executor.invokeAll(clients);
try {
for (Future f : futures) {
f.get();
}
assertTrue("Concurrent update NOT detected!", false);
} catch (Exception e) {
e.printStackTrace();
assertTrue(true);
System.out.println("Concurrent update detected!");
}
// wait for propagation
Thread.sleep(500);
// end of deadlock on server3
this.server3inDeadlock = false;
Thread.sleep(1000); // waiting for sync of server3
// check consistency
r1onServer1 = retrieveRecord(getDatabaseURL(serverInstance.get(0)), "R001");
r1onServer2 = retrieveRecord(getDatabaseURL(serverInstance.get(1)), "R001");
ODocument r1onServer3 = retrieveRecord(getDatabaseURL(serverInstance.get(2)), "R001");
ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1);
r1onServer1.reload();
ODatabaseRecordThreadLocal.INSTANCE.set(dbServer2);
r1onServer2.reload();
ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3);
r1onServer3.reload();
if( (r1onServer1.field("firstName").equals("Luke") && r1onServer1.field("lastName").equals("Skywalker")) ||
r1onServer1.field("firstName").equals("Darth") && r1onServer1.field("lastName").equals("Vader")) {
assertTrue("The record has been updated by a client!", true);
}
else {
assertTrue("The record has not been updated by any client!", false);
}
System.out.printf("Checking consistency among servers...");
assertEquals(r1onServer1.field("@version"), r1onServer2.field("@version"));
assertEquals(r1onServer1.field("id"), r1onServer2.field("id"));
assertEquals(r1onServer1.field("firstName"), r1onServer2.field("firstName"));
assertEquals(r1onServer1.field("lastName"), r1onServer2.field("lastName"));
assertEquals(r1onServer2.field("@version"), r1onServer3.field("@version"));
assertEquals(r1onServer2.field("id"), r1onServer3.field("id"));
assertEquals(r1onServer2.field("firstName"), r1onServer3.field("firstName"));
assertEquals(r1onServer2.field("lastName"), r1onServer3.field("lastName"));
System.out.println("The records are consistent in the cluster.");
// final version of the record r1
System.out.print("Checking versioning...");
int finalVersion = r1onServer1.field("@version");
assertEquals(finalVersion, initialVersion +1);
System.out.println("\tDone.");
}
@Override
protected void onServerStarted(ServerRun server) {
super.onServerStarted(server);
if (serverStarted++ == (2)) {
startQueueMonitorTask();
startCountMonitorTask("Person");
// BACKUP LAST SERVER, RUN ASYNCHRONOUSLY
new Thread(new Runnable() {
@Override
public void run() {
try {
// CRASH LAST SERVER try {
executeWhen(new Callable<Boolean>() {
// CONDITION
@Override
public Boolean call() throws Exception {
return server3inDeadlock;
}
}, // ACTION
new Callable() {
@Override
public Object call() throws Exception {
banner("STARTING BACKUP SERVER " + (2));
OrientGraphFactory factory = new OrientGraphFactory(
"plocal:target/server2/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
backupInProgress = true;
File file = null;
try {
file = File.createTempFile("orientdb_test_backup", ".zip");
if (file.exists())
Assert.assertTrue(file.delete());
g.getRawGraph().backup(new FileOutputStream(file), null, new Callable<Object>() {
@Override
public Object call() throws Exception {
// SIMULATE LONG BACKUP UNTIL SPECIFIED BY VARIABLE 'server3inDeadlock'
while (server3inDeadlock) {
Thread.sleep(1000);
}
return null;
}
}, null, 9, 1000000);
} catch (IOException e) {
e.printStackTrace();
} finally {
banner("COMPLETED BACKUP SERVER " + (2));
backupInProgress = false;
g.shutdown();
if (file != null)
file.delete();
}
return null;
}
});
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Error on execution flow");
}
}
}).start();
}
}
}
| 38.753676 | 135 | 0.653828 |
0455c0504245a29d97beaba836e65f2498ffcf86 | 10,862 | java | Java | app/src/main/java/com/converter/MainActivity.java | jose-barata/android-currency-converter | 3a7f02a5739d29a9f12d1e864c4483ce5521c16d | [
"MIT"
] | null | null | null | app/src/main/java/com/converter/MainActivity.java | jose-barata/android-currency-converter | 3a7f02a5739d29a9f12d1e864c4483ce5521c16d | [
"MIT"
] | null | null | null | app/src/main/java/com/converter/MainActivity.java | jose-barata/android-currency-converter | 3a7f02a5739d29a9f12d1e864c4483ce5521c16d | [
"MIT"
] | null | null | null | package com.converter;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
private String API_URL = "http://data.fixer.io/api/latest?access_key=< ! Insert fixer api access key here ! >=1&symbols=EUR,GBP,HKD,NZD,AUD";
private TextView updatedInfo;
private EditText editEUR;
private EditText editGBP;
private EditText editHKD;
private EditText editNZD;
private EditText editAUD;
private float rateEUR;
private float rateGBP;
private float rateHKD;
private float rateNZD;
private float rateAUD;
private final DecimalFormat decimalFormat = new DecimalFormat("##.00");
private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences mPrefs = MainActivity.this.getSharedPreferences("theme", Context.MODE_PRIVATE);
setTheme(mPrefs.getInt("theme", android.R.style.Theme_Material_Light_NoActionBar));
setContentView(R.layout.activity_main);
updatedInfo = (TextView) findViewById(R.id.updatedInfo);
editEUR = (EditText) findViewById(R.id.editEUR);
editGBP = (EditText) findViewById(R.id.editGBP);
editHKD = (EditText) findViewById(R.id.editHKD);
editNZD = (EditText) findViewById(R.id.editNZD);
editAUD = (EditText) findViewById(R.id.editAUD);
editEUR.requestFocus();
initRates();
initButtons();
}
private void initRates() {
SharedPreferences mPrefs = MainActivity.this.getSharedPreferences("rateEUR", Context.MODE_PRIVATE);
rateEUR = mPrefs.getFloat("rateEUR", 1f);
mPrefs = MainActivity.this.getSharedPreferences("rateGBP", Context.MODE_PRIVATE);
rateGBP = mPrefs.getFloat("rateGBP", 1f);
mPrefs = MainActivity.this.getSharedPreferences("rateHKD", Context.MODE_PRIVATE);
rateHKD = mPrefs.getFloat("rateHKD", 1f);
mPrefs = MainActivity.this.getSharedPreferences("rateNZD", Context.MODE_PRIVATE);
rateNZD = mPrefs.getFloat("rateNZD", 1f);
mPrefs = MainActivity.this.getSharedPreferences("rateAUD", Context.MODE_PRIVATE);
rateAUD = mPrefs.getFloat("rateAUD", 1f);
}
private void initButtons() {
View.OnClickListener clearButtonListener = new View.OnClickListener() {
public void onClick(View v) {
clearAllInputs();
}
};
findViewById(R.id.btnClearEUR).setOnClickListener(clearButtonListener);
findViewById(R.id.btnClearGBP).setOnClickListener(clearButtonListener);
findViewById(R.id.btnClearHKD).setOnClickListener(clearButtonListener);
findViewById(R.id.btnClearNZD).setOnClickListener(clearButtonListener);
findViewById(R.id.btnClearAUD).setOnClickListener(clearButtonListener);
findViewById(R.id.btnOkEUR).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
float eurInputValue = Float.parseFloat(editEUR.getText().toString());
editGBP.setText(decimalFormat.format(eurInputValue * rateGBP / rateEUR));
editHKD.setText(decimalFormat.format(eurInputValue * rateHKD / rateEUR));
editNZD.setText(decimalFormat.format(eurInputValue * rateNZD / rateEUR));
editAUD.setText(decimalFormat.format(eurInputValue * rateAUD / rateEUR));
}
});
findViewById(R.id.btnOkGBP).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
float gbpInputValue = Float.parseFloat(editGBP.getText().toString());
editEUR.setText(decimalFormat.format(gbpInputValue * rateEUR / rateGBP));
editHKD.setText(decimalFormat.format(gbpInputValue * rateHKD / rateGBP));
editNZD.setText(decimalFormat.format(gbpInputValue * rateNZD / rateGBP));
editAUD.setText(decimalFormat.format(gbpInputValue * rateAUD / rateGBP));
}
});
findViewById(R.id.btnOkHKD).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
float hkdInputValue = Float.parseFloat(editHKD.getText().toString());
editEUR.setText(decimalFormat.format(hkdInputValue * rateEUR / rateHKD));
editGBP.setText(decimalFormat.format(hkdInputValue * rateGBP / rateHKD));
editNZD.setText(decimalFormat.format(hkdInputValue * rateNZD / rateHKD));
editAUD.setText(decimalFormat.format(hkdInputValue * rateAUD / rateHKD));
}
});
findViewById(R.id.btnOkNZD).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
float nzdInputValue = Float.parseFloat(editNZD.getText().toString());
editEUR.setText(decimalFormat.format(nzdInputValue * rateEUR / rateNZD));
editGBP.setText(decimalFormat.format(nzdInputValue * rateGBP / rateNZD));
editHKD.setText(decimalFormat.format(nzdInputValue * rateHKD / rateNZD));
editAUD.setText(decimalFormat.format(nzdInputValue * rateAUD / rateNZD));
}
});
findViewById(R.id.btnOkAUD).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
float audInputValue = Float.parseFloat(editAUD.getText().toString());
editEUR.setText(decimalFormat.format(audInputValue * rateEUR / rateAUD));
editGBP.setText(decimalFormat.format(audInputValue * rateGBP / rateAUD));
editHKD.setText(decimalFormat.format(audInputValue * rateHKD / rateAUD));
editNZD.setText(decimalFormat.format(audInputValue * rateNZD / rateAUD));
}
});
findViewById(R.id.btnUpdateRates).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
updateRates();
}
});
findViewById(R.id.btnTheme).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SharedPreferences mPrefs = MainActivity.this.getSharedPreferences("theme", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mPrefs.edit();
int theme = mPrefs.getInt("theme", android.R.style.Theme_Material_Light_NoActionBar);
switch (theme) {
case android.R.style.Theme_Material_Light_NoActionBar:
editor.putInt("theme", android.R.style.Theme_Material_NoActionBar);
break;
case android.R.style.Theme_Material_NoActionBar:
editor.putInt("theme", android.R.style.Theme_Material_Light_NoActionBar);
break;
}
if (editor.commit()) {
recreate();
}
}
});
}
private void updateRates() {
String url = API_URL;
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
if (response.has("rates")) {
JSONObject rates = response.getJSONObject("rates");
rateEUR = (float) rates.getDouble("EUR");
rateGBP = (float) rates.getDouble("GBP");
rateHKD = (float) rates.getDouble("HKD");
rateNZD = (float) rates.getDouble("NZD");
rateAUD = (float) rates.getDouble("AUD");
SharedPreferences mPrefs = MainActivity.this.getSharedPreferences("rateEUR", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putFloat("rateEUR", rateEUR);
editor.commit();
mPrefs = MainActivity.this.getSharedPreferences("rateGBP", Context.MODE_PRIVATE);
editor = mPrefs.edit();
editor.putFloat("rateGBP", rateGBP);
editor.commit();
mPrefs = MainActivity.this.getSharedPreferences("rateHKD", Context.MODE_PRIVATE);
editor = mPrefs.edit();
editor.putFloat("rateHKD", rateHKD);
editor.commit();
mPrefs = MainActivity.this.getSharedPreferences("rateNZD", Context.MODE_PRIVATE);
editor = mPrefs.edit();
editor.putFloat("rateNZD", rateNZD);
editor.commit();
mPrefs = MainActivity.this.getSharedPreferences("rateAUD", Context.MODE_PRIVATE);
editor = mPrefs.edit();
editor.putFloat("rateAUD", rateAUD);
editor.commit();
}
} catch (JSONException exception) {
updatedInfo.setText("Unable to get rates: " + exception.getMessage());
}
updatedInfo.setText("Updated at " + simpleDateFormat.format(new Date()));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
updatedInfo.setText("Unable to get rates: " + error.getMessage());
}
});
RequestQueueSingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
}
private void clearAllInputs() {
editEUR.setText("0");
editGBP.setText("0");
editHKD.setText("0");
editNZD.setText("0");
editAUD.setText("0");
}
}
| 46.221277 | 145 | 0.59989 |
24dd918c3947df0f644e99044e4981da7bc4ef58 | 4,316 | dart | Dart | lib/src/pinch_zoom_image.dart | Paulabn/pinch_zoom_image_last | a4d24aa60eb9bd65c822f655cd4cd8ebd7d48c00 | [
"ISC"
] | null | null | null | lib/src/pinch_zoom_image.dart | Paulabn/pinch_zoom_image_last | a4d24aa60eb9bd65c822f655cd4cd8ebd7d48c00 | [
"ISC"
] | null | null | null | lib/src/pinch_zoom_image.dart | Paulabn/pinch_zoom_image_last | a4d24aa60eb9bd65c822f655cd4cd8ebd7d48c00 | [
"ISC"
] | 1 | 2022-03-18T16:57:18.000Z | 2022-03-18T16:57:18.000Z | import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pinch_zoom_image_last/src/pinch_zoom_overlay_image.dart';
class PinchZoomImage extends StatefulWidget {
final Widget image;
final Color zoomedBackgroundColor;
final bool hideStatusBarWhileZooming;
final Function? onZoomStart;
final Function? onZoomEnd;
PinchZoomImage({
required this.image,
this.zoomedBackgroundColor = Colors.transparent,
this.hideStatusBarWhileZooming = false,
this.onZoomStart,
this.onZoomEnd,
});
@override
_PinchZoomImageState createState() => _PinchZoomImageState();
}
class _PinchZoomImageState extends State<PinchZoomImage> {
static const channel = const MethodChannel('pinch_zoom_image');
OverlayEntry? overlayEntry;
Offset? scaleStartPosition;
Offset? origin;
int numPointers = 0;
bool zooming = false;
bool reversing = false;
GlobalKey<PinchZoomOverlayImageState> overlayKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Listener(
onPointerDown: (_) => numPointers++,
onPointerUp: (_) => numPointers--,
onPointerCancel: (_) => numPointers = 0,
child: RawGestureDetector(
gestures: {
_AllowMultipleGestureRecognizer: GestureRecognizerFactoryWithHandlers<
_AllowMultipleGestureRecognizer>(
() => _AllowMultipleGestureRecognizer(), //constructor
(_AllowMultipleGestureRecognizer instance) {
//initializer
instance.onStart = _handleScaleStart;
instance.onUpdate = _handleScaleUpdate;
instance.onEnd = _handleScaleEnd;
},
)
},
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
Opacity(
opacity: zooming ? 0.0 : 1.0,
child: widget.image,
),
Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
bottom: 0.0,
child: Container(
color:
zooming ? widget.zoomedBackgroundColor : Colors.transparent,
),
),
],
),
),
);
}
void _handleScaleStart(ScaleStartDetails details) {
//print("Handle scale start => pointers : $numPointers");
if (overlayEntry != null || reversing || numPointers < 2) return;
setState(() {
zooming = true;
});
if (widget.hideStatusBarWhileZooming) channel.invokeMethod('hideStatusBar');
if (widget.onZoomStart != null) widget.onZoomStart!();
OverlayState overlayState = Overlay.of(context)!;
double width = context.size!.width;
double height = context.size!.height;
origin = (context.findRenderObject() as RenderBox)
.localToGlobal(Offset(0.0, 0.0));
scaleStartPosition = details.focalPoint;
overlayEntry = OverlayEntry(
maintainState: true,
builder: (BuildContext context) {
return PinchZoomOverlayImage(
key: overlayKey,
height: height,
width: width,
origin: origin!,
image: widget.image,
);
},
);
overlayState.insert(overlayEntry!);
}
void _handleScaleUpdate(ScaleUpdateDetails details) {
//print("Handle scale UPDATE => pointers : $numPointers");
if (reversing || numPointers < 2) return;
overlayKey.currentState
?.updatePosition(origin! - (scaleStartPosition! - details.focalPoint));
if (details.scale >= 1.0)
overlayKey.currentState?.updateScale(details.scale);
}
void _handleScaleEnd(ScaleEndDetails details) async {
//print("Handle scale END");
if (reversing || !zooming) return;
reversing = true;
if (widget.hideStatusBarWhileZooming) channel.invokeMethod('showStatusBar');
if (widget.onZoomEnd != null) widget.onZoomEnd!();
await overlayKey.currentState?.reverse();
overlayEntry?.remove();
overlayEntry = null;
origin = null;
scaleStartPosition = null;
reversing = false;
setState(() {
zooming = false;
});
}
}
class _AllowMultipleGestureRecognizer extends ScaleGestureRecognizer {
@override
void rejectGesture(int pointer) {
acceptGesture(pointer);
}
}
| 30.609929 | 80 | 0.641566 |
9d1ca7475c5535816e797eaeee55c4bae4e2e8b1 | 21,473 | html | HTML | src/tab.html | thanhtungweb/dashboard-master | 60bba115bcb2a57b21bf200b3db67eddd0159ead | [
"MIT"
] | 1 | 2021-01-21T08:15:53.000Z | 2021-01-21T08:15:53.000Z | src/tab.html | thanhtungweb/ttweb-dashboard-master | 60bba115bcb2a57b21bf200b3db67eddd0159ead | [
"MIT"
] | null | null | null | src/tab.html | thanhtungweb/ttweb-dashboard-master | 60bba115bcb2a57b21bf200b3db67eddd0159ead | [
"MIT"
] | null | null | null | ---
layout: default
title: "Buttons - TTWeb Admin Dashboard Template"
parent: "components"
sub_parent: "components"
activePage: "tab"
plugins: []
---
<div class="breadcrumb-wrapper">
<h1>Tab</h1>
{% include breadcrumb.htm %}
</div>
<!-- First Row -->
<div class="row">
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Default Tabs </h2>
</div>
<div class="card-body">
<p class="mb-5">Takes the basic nav and adds the <code>.nav-tabs</code> class to generate a tabbed interface. Use them to create tabbable regions with our tab <a href="http://getbootstrap.com/docs/4.1/components/navs/#javascript-behavior"
target="_blank">JavaScript plugin.</a></p>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="javascript:void(0)">Disabled</a>
</li>
</ul>
<div class="tab-content" id="myTabContent1">
<div class="tab-pane pt-3 fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Pill Tabs </h2>
</div>
<div class="card-body">
<p class="mb-5">Take that same HTML, but use <code>.nav-pills</code> instead: Read Bootstrap Documention <a href="http://getbootstrap.com/docs/4.1/components/navs/#javascript-behavior"
target="_blank">more details.</a></p>
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home"
aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile"
aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact" role="tab" aria-controls="pills-contact"
aria-selected="false">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="javascript:void(0)">Disabled</a>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Tabs with Icon</h2>
</div>
<div class="card-body">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="icon-home-tab" data-toggle="tab" href="#icon-home" role="tab" aria-controls="icon-home" aria-selected="true">
<i class="mdi mdi-star mr-1"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="icon-profile-tab" data-toggle="tab" href="#icon-profile" role="tab" aria-controls="icon-profile"
aria-selected="false">
<i class="mdi mdi-account mr-1"></i> Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="icon-contact-tab" data-toggle="tab" href="#icon-contact" role="tab" aria-controls="icon-contact"
aria-selected="false">
<i class="mdi mdi-phone mr-1"></i> Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent2">
<div class="tab-pane pt-3 fade show active" id="icon-home" role="tabpanel" aria-labelledby="icon-home-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="icon-profile" role="tabpanel" aria-labelledby="icon-profile-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="icon-contact" role="tabpanel" aria-labelledby="icon-contact-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Pill Tabs with Icon </h2>
</div>
<div class="card-body">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="ipills-home-tab" data-toggle="pill" href="#ipills-home" role="tab" aria-controls="ipills-home"
aria-selected="true">
<i class="mdi mdi-star mr-1"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="ipills-profile-tab" data-toggle="pill" href="#ipills-profile" role="tab" aria-controls="ipills-profile"
aria-selected="false">
<i class="mdi mdi-account mr-1"></i> Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="ipills-contact-tab" data-toggle="pill" href="#ipills-contact" role="tab" aria-controls="ipills-contact"
aria-selected="false">
<i class="mdi mdi-phone mr-1"></i> Contact</a>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="ipills-home" role="tabpanel" aria-labelledby="ipills-home-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="ipills-profile" role="tabpanel" aria-labelledby="ipills-profile-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="ipills-contact" role="tabpanel" aria-labelledby="ipills-contact-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Custom List Tabs</h2>
</div>
<div class="card-body">
<ul class="nav nav-tabs nav-style-border pl-0 justify-content-between justify-content-xl-start" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home2-tab" data-toggle="tab" href="#home2" role="tab" aria-controls="home2" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile2-tab" data-toggle="tab" href="#profile2" role="tab" aria-controls="profile2" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact2-tab" data-toggle="tab" href="#contact2" role="tab" aria-controls="contact2" aria-selected="false">Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent3">
<div class="tab-pane pt-3 fade show active" id="home2" role="tabpanel" aria-labelledby="home2-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="profile2" role="tabpanel" aria-labelledby="profile2-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="contact2" role="tabpanel" aria-labelledby="contact2-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Custom List Tabs</h2>
</div>
<div class="card-body">
<ul class="nav nav-pills nav-justified nav-style-fill" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home3-tab" data-toggle="tab" href="#home3" role="tab" aria-controls="home3" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile3-tab" data-toggle="tab" href="#profile3" role="tab" aria-controls="profile3" aria-selected="false">Profile</a>
</li>
</ul>
<div class="tab-content" id="myTabContent4">
<div class="tab-pane pt-3 fade show active" id="home3" role="tabpanel" aria-labelledby="home3-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane pt-3 fade" id="profile3" role="tabpanel" aria-labelledby="profile3-tab">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Vertical Tabs</h2>
</div>
<div class="card-body">
<div class="row ">
<div class="col-sm-4">
<ul class="nav nav-tabs nav-stacked flex-column">
<li class="nav-item">
<a href="#vtab1" class="nav-link active" data-toggle="tab" aria-expanded="true">
<i class="mdi mdi-home"></i> Home</a>
</li>
<li class="nav-item">
<a href="#vtab2" class="nav-link" data-toggle="tab" aria-expanded="false">
<i class="mdi mdi-account"></i> Profile</a>
</li>
<li class="nav-item">
<a href="#vtab3" class="nav-link" data-toggle="tab">
<i class="mdi mdi-phone"></i> Contact</a>
</li>
</ul>
</div>
<div class="tab-content col-sm-8 ">
<div class="tab-pane fade active show" id="vtab1" aria-expanded="true">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="vtab2" aria-expanded="false">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="vtab3" aria-expanded="false">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card card-default">
<div class="card-header card-header-border-bottom">
<h2>Vertical Fill Tabs</h2>
</div>
<div class="card-body">
<div class="row ">
<div class="col-sm-4">
<ul class="nav nav-pills nav-stacked flex-column">
<li class="nav-item">
<a href="#vtab4" class="nav-link active" data-toggle="tab" aria-expanded="true">
<i class="mr-1 fa fa-home"></i> Home</a>
</li>
<li class="nav-item">
<a href="#vtab5" class="nav-link" data-toggle="tab" aria-expanded="false">
<i class="mr-1 fa fa-user"></i> Profile</a>
</li>
<li class="nav-item">
<a href="#vtab6" class="nav-link" data-toggle="tab">
<i class="mr-1 fa fa-phone"></i> Contact</a>
</li>
</ul>
</div>
<div class="tab-content col-sm-8 ">
<div class="tab-pane fade active show" id="vtab4" aria-expanded="true">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="vtab5" aria-expanded="false">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
<div class="tab-pane fade" id="vtab6" aria-expanded="false">
Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
| 61.881844 | 249 | 0.611792 |
92e39dffbed6e009a4b5eaed4ea6f7e826156b3b | 3,780 | c | C | cmds/copy.c | gerard5/plo | d9d621d6ea6a166c88aebc7a815f9a2e5598eb2d | [
"BSD-3-Clause"
] | null | null | null | cmds/copy.c | gerard5/plo | d9d621d6ea6a166c88aebc7a815f9a2e5598eb2d | [
"BSD-3-Clause"
] | 44 | 2020-08-30T12:07:00.000Z | 2022-03-24T18:10:58.000Z | cmds/copy.c | gerard5/plo | d9d621d6ea6a166c88aebc7a815f9a2e5598eb2d | [
"BSD-3-Clause"
] | 12 | 2019-01-10T20:10:27.000Z | 2022-02-01T21:57:08.000Z | /*
* Phoenix-RTOS
*
* Operating system loader
*
* Copy data between devices
*
* Copyright 2021 Phoenix Systems
* Author: Hubert Buczynski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#include "cmd.h"
#include <hal/hal.h>
#include <lib/lib.h>
#include <phfs/phfs.h>
static void cmd_copyInfo(void)
{
lib_printf("copies data between devices, usage:\n");
lib_printf("%17s%s", "", "copy <src dev> <file/offs size> <dst dev> <file/offs size>");
}
static ssize_t cmd_cpphfs2phfs(handler_t srcHandler, addr_t srcAddr, size_t srcSz, handler_t dstHandler, addr_t dstAddr, size_t dstSz)
{
ssize_t res;
u8 buff[SIZE_MSG_BUFF];
size_t chunk, rsz = 0, wsz = 0;
/* Size is not defined, copy the whole file */
if (srcSz == 0 && dstSz == 0)
srcSz = -1;
/* Size is defined, use smaller one to copy piece of memory */
else if (srcSz != 0 && dstSz != 0)
srcSz = (srcSz < dstSz) ? srcSz : dstSz;
/* One of the size is not defined, use the defined one */
else
srcSz = (srcSz > dstSz) ? srcSz : dstSz;
do {
chunk = ((srcSz - rsz) > sizeof(buff)) ? sizeof(buff) : (srcSz - rsz);
if ((res = phfs_read(srcHandler, srcAddr + rsz, buff, chunk)) < 0) {
log_error("\nCan't read data\n");
return res;
}
rsz += res;
chunk = res;
while (chunk) {
if ((res = phfs_write(dstHandler, dstAddr + wsz, buff, chunk)) < 0) {
log_error("\nCan't write data to address: 0x%x\n", dstAddr + wsz);
return res;
}
chunk -= res;
wsz += res;
}
} while ((srcSz - rsz) > 0 && res > 0);
return wsz;
}
static int cmd_parseDev(handler_t *h, addr_t *offs, size_t *sz, unsigned int argc, char *argv[], unsigned int *argvID, const char **file)
{
int res;
const char *alias;
char *endptr;
if (h == NULL || offs == NULL || sz == NULL || argv == NULL || argvID == NULL)
return -EINVAL;
alias = argv[(*argvID)++];
if (*argvID >= argc) {
log_error("\n%s: Wrong argument count", argv[0]);
return -EINVAL;
}
*offs = lib_strtoul(argv[*argvID], &endptr, 0);
/* Open device using alias to file */
if (*endptr) {
*offs = 0;
*sz = 0;
*file = argv[*argvID];
if ((res = phfs_open(alias, argv[*argvID], 0, h)) < 0) {
log_error("\nCan't open file '%s' on %s", argv[*argvID], alias);
return res;
}
(*argvID)++;
}
/* Open device using direct access to memory */
else {
*sz = lib_strtoul(argv[++(*argvID)], &endptr, 0);
*file = NULL;
if (*endptr) {
log_error("\nWrong size value: %s, for %s with offs 0x%x", argv[(*argvID)], alias, *offs);
return -EINVAL;
}
if ((res = phfs_open(alias, NULL, 0, h)) < 0) {
log_error("\nCan't open file '%s' with offset 0x%x", alias, *offs);
return res;
}
}
return EOK;
}
static int cmd_copy(int argc, char *argv[])
{
size_t sz[2];
ssize_t res;
addr_t offs[2];
handler_t h[2];
const char *file[2];
unsigned int argvID = 1;
/* Parse all comand's arguments */
if (argc < 5) {
log_error("\n%s: Wrong argument count", argv[0]);
return -EINVAL;
}
if ((res = cmd_parseDev(&h[0], &offs[0], &sz[0], argc, argv, &argvID, &file[0])) < 0)
return res;
if ((res = cmd_parseDev(&h[1], &offs[1], &sz[1], argc, argv, &argvID, &file[1])) < 0)
return res;
/* Copy data between devices */
log_info("\nCopying data, please wait...");
res = cmd_cpphfs2phfs(h[0], offs[0], sz[0], h[1], offs[1], sz[1]);
phfs_close(h[0]);
phfs_close(h[1]);
if (res < 0) {
log_error("\nCopying failed");
return res;
}
log_info("\nFinished copying");
if ((res = phfs_regFile((file[1] == NULL) ? file[0] : file[1], offs[1], res)) < 0)
return res;
return EOK;
}
__attribute__((constructor)) static void cmd_copyReg(void)
{
const static cmd_t app_cmd = { .name = "copy", .run = cmd_copy, .info = cmd_copyInfo };
cmd_reg(&app_cmd);
}
| 22.771084 | 137 | 0.607672 |
7097f1417e87d6b42a00c914eaca5b8499e9fa0f | 287 | dart | Dart | lib/app_widget.dart | WashingtonlGarcia/flutter-nasa-clean-arch | 85468f2464db2b255549ccc6a8c88ff3684c1e8b | [
"MIT"
] | null | null | null | lib/app_widget.dart | WashingtonlGarcia/flutter-nasa-clean-arch | 85468f2464db2b255549ccc6a8c88ff3684c1e8b | [
"MIT"
] | null | null | null | lib/app_widget.dart | WashingtonlGarcia/flutter-nasa-clean-arch | 85468f2464db2b255549ccc6a8c88ff3684c1e8b | [
"MIT"
] | null | null | null | import 'package:flutter/material.dart';
import 'features/presenter/pages/home/home_page.dart';
class AppWidget extends StatelessWidget {
const AppWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(home: HomePage());
}
}
| 23.916667 | 54 | 0.735192 |
6e29e97cd9e672090ef8a81e7f431990533fdfef | 6,567 | html | HTML | contact.html | someshwarmale/epic6 | 2a2af01bbb9fd9da94d6c109aaa6dd30f0a354ca | [
"CC-BY-3.0"
] | null | null | null | contact.html | someshwarmale/epic6 | 2a2af01bbb9fd9da94d6c109aaa6dd30f0a354ca | [
"CC-BY-3.0"
] | 1 | 2020-01-19T17:31:59.000Z | 2020-01-19T17:32:07.000Z | contact.html | someshwarmale/epic6 | 2a2af01bbb9fd9da94d6c109aaa6dd30f0a354ca | [
"CC-BY-3.0"
] | 1 | 2020-01-18T14:14:49.000Z | 2020-01-18T14:14:49.000Z | <!DOCTYPE html>
<html>
<head>
<title>Nature Lovers Pune</title>
<meta name=viewport content="width=device-width, initial-scale=1">
<meta http-equiv=Cache-control content=public>
<meta http-equiv=Content-Type content="text/html; charset=utf-8" />
<meta http-equiv=Cache-Control content="no-cache" />
<meta http-equiv=Cache-Control content="max-age=120" />
<meta http-equiv=Content-Disposition content="inline; filename=spreadsheet.xls" />
<meta http-equiv=Content-Type content="application/xhtml+xml;charset=UTF-8" />
<meta http-equiv=X-UA-Compatible content="IE=8" />
<meta http-equiv=X-UA-Compatible content="IE=edge" />
<meta name=keywords content="epic, the epic show india, epic show india, epic show, epic 2019, nature lovers, nature lovers pune, NGO, helping people, disability, disaled" />
<script type=application/x-javascript>
addEventListener("load", function() {
setTimeout(hideURLbar, 0)
}, false);
function hideURLbar() {
window.scrollTo(0, 1)
}
</script>
<link href=css/bootstrap.css rel=stylesheet type=text/css />
<link href=css/style.css rel=stylesheet type=text/css />
<script src=js/jquery.min.js></script>
<script type=text/javascript src=js/move-top.js></script>
<script type=text/javascript src=js/easing.js></script>
<script type=text/javascript>
jQuery(document).ready(function(a) {
a(".scroll").click(function(b) {
b.preventDefault();
a("html,body").animate({
scrollTop: a(this.hash).offset().top
}, 1000)
})
});
</script>
<link rel=stylesheet type=text/css href=https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css>
<link rel=stylesheet type=text/css href=https://www.w3schools.com/w3css/4/w3.css>
</head>
<body>
<div class=head id=home>
<div class=container>
<div class=head-top>
<div class="col-md-6 h-left">
<p></p>
</div>
<div class="col-md-6 h-right">
<ul>
<li><a href=https://www.facebook.com/epicshowindia/><i class="fa fa-facebook" style=font-size:24px;color:white></i></a>
</li>
<li><a href="https://twitter.com/FoundationEpic?s=08"><i class="fa fa-twitter" style=font-size:24px;color:white></i></a></li>
<li><a href=https://www.youtube.com/channel/UCYGC3V8JQK_bmyUpwVBeHzw><i class="fa fa-youtube" style=font-size:24px;color:white></i></a></li>
<li><a href="https://www.instagram.com/epicshowindia/?utm_source=ig_profile_share&igshid=132f9k8fbr5ta"><i class="fa fa-instagram" style=font-size:24px;color:white></i></a></li>
<li><a href="https://www.linkedin.com/in/epic-foundation-949368199"><i class="fa fa-linkedin" style=font-size:24px;color:white></i></a></li>
</ul>
</div>
<div class=clearfix></div>
</div>
</div>
</div>
<div class=header>
<div class=container>
<div class=header-main>
<div class=logo>
<a href=index.html><h1>CONTACT US</h1></a>
</div>
<div class=head-right>
<div class=top-nav>
<span class=menu><img src=images/nav-icon.png alt> </span>
<ul>
<li><a href=index.html><span class="glyphicon glyphicon-home"></span>Home</a></li>
<li><a href=about.html><span class="glyphicon glyphicon-info-sign"></span>About EPiC</a></li>
<li><a href=typo.html><span class="glyphicon glyphicon-certificate"></span>What we do.</a></li>
<li><a href=about2.html><span class="glyphicon glyphicon-tree-deciduous"></span>Nature lovers</a></li>
<li><a href=gallery.html><span class="glyphicon glyphicon-picture"></span>Gallery</a></li>
<li><a href=https://goo.gl/forms/jdyEWYqh0JxntQjb2><span class="glyphicon glyphicon-tags"></span>Passes</a></li>
<li><a href=contact.html class=active><span class="glyphicon glyphicon-envelope"></span>Contact</a></li>
<div class=clearfix> </div>
</ul>
<script>
$("span.menu").click(function() {
$(".top-nav ul").slideToggle(500, function() {})
});
</script>
</div>
</div>
<div class=clearfix> </div>
</div>
</div>
</div>
<div class=contact>
<div class=container>
<div class="contact-top heading">
<h2>Contact Us</h2>
</div>
</div>
</div>
<div class=address>
<div class=container>
<div class=address-top>
<div class="col-md-4 add-left">
<span class="glyphicon glyphicon-map-marker" aria-hidden=true></span>
<p>
<label>Address.</label>
Kanchan Galli,Law College Road, Pune-411004</p>
</div>
<div class="col-md-4 add-left">
<span class="glyphicon glyphicon-earphone" aria-hidden=true></span>
<p>+91 9529749773
<br>+91 9765926339</p>
</div>
<div class="col-md-4 add-left">
<span class="glyphicon glyphicon-envelope" aria-hidden=true></span>
<p><a href=mailto:epicfoundationpune@gmail.com>epicfoundationpune@gmail.com</a>
<br><a href=mailto:epicshowindia@gmail.com>epicshowindia@gmail.com</a></p>
</div>
<div class=clearfix></div>
</div>
</div>
</div>
<div class=footer>
<div class=container>
<div class=footer-top>
<a href=index.html><h3>EPIC FOUNDATION, PUNE</h3></a>
<p>© 2018 EPIC FOUNDATION PUNE. All Rights Reserved </p>
<a href=#home class=scroll><img src=images/top-arrow.png alt /></a>
</div>
</div>
</div>
</body>
</html> | 48.286765 | 201 | 0.525049 |
6b1d821b32de014ded3506133421d22ca405554c | 995 | kt | Kotlin | rpglib/src/main/kotlin/com/naosim/rpglib/model/script/MessageScriptLooper.kt | naosim/RPGSample | a26dd7ff3da98dd82eabbff50bd2098974743655 | [
"MIT"
] | null | null | null | rpglib/src/main/kotlin/com/naosim/rpglib/model/script/MessageScriptLooper.kt | naosim/RPGSample | a26dd7ff3da98dd82eabbff50bd2098974743655 | [
"MIT"
] | null | null | null | rpglib/src/main/kotlin/com/naosim/rpglib/model/script/MessageScriptLooper.kt | naosim/RPGSample | a26dd7ff3da98dd82eabbff50bd2098974743655 | [
"MIT"
] | null | null | null | package com.naosim.rpglib.model.script
import com.naosim.rpglib.model.viewmodel.MessageViewModel
import com.naosim.rpglib.model.viewmodel.OnNextListener
class MessageScriptLooper(
val messageViewModel: MessageViewModel,
val scriptSet: ScriptSet
): OnNextListener {
var count = 0;
fun start() {
next()
}
fun next() {
if(count >= scriptSet.messageScriptList.size) {
messageViewModel.dismiss()
scriptSet.onEnd.invoke()
return
}
val script = scriptSet.messageScriptList.get(count)
if(script is SimpleMessageScript) {
messageViewModel.clear()
messageViewModel.appendText(script.message, { waitNext() })
}
count++
}
var isWaitingNext = false;
fun waitNext() {
isWaitingNext = true;
}
override fun onNext() {
if(!isWaitingNext) {
return
}
next()
isWaitingNext = false
}
} | 23.139535 | 71 | 0.59799 |
4c2400a1d759e29fce86f13fd8d047d577eb5f06 | 320 | php | PHP | tests/Unit/DisabledExposeGlobalFieldsInGraphQLSchemaFixtureQueryExecutionGraphQLServerTest.php | getpop/graphql | 5eb9468dcc809ce8481e00df03ec7c52611352c0 | [
"MIT"
] | 2 | 2020-01-11T06:32:47.000Z | 2020-01-21T10:06:16.000Z | tests/Unit/DisabledExposeGlobalFieldsInGraphQLSchemaFixtureQueryExecutionGraphQLServerTest.php | getpop/graphql | 5eb9468dcc809ce8481e00df03ec7c52611352c0 | [
"MIT"
] | null | null | null | tests/Unit/DisabledExposeGlobalFieldsInGraphQLSchemaFixtureQueryExecutionGraphQLServerTest.php | getpop/graphql | 5eb9468dcc809ce8481e00df03ec7c52611352c0 | [
"MIT"
] | 1 | 2020-03-30T14:59:34.000Z | 2020-03-30T14:59:34.000Z | <?php
declare(strict_types=1);
namespace GraphQLByPoP\GraphQLServer\Unit;
class DisabledExposeGlobalFieldsInGraphQLSchemaFixtureQueryExecutionGraphQLServerTest extends AbstractExposeGlobalFieldsInGraphQLSchemaFixtureQueryExecutionGraphQLServerTest
{
use DisabledFixtureQueryExecutionGraphQLServerTestCaseTrait;
}
| 29.090909 | 173 | 0.903125 |
4711a36b5c0960661cae1523777f4a9bc3346a4e | 1,047 | swift | Swift | MobileUI/UIFont.swift | velvetroom/Waverley | e600ce75f7d037a1124c16c03c75ee307c09a7cd | [
"MIT"
] | null | null | null | MobileUI/UIFont.swift | velvetroom/Waverley | e600ce75f7d037a1124c16c03c75ee307c09a7cd | [
"MIT"
] | null | null | null | MobileUI/UIFont.swift | velvetroom/Waverley | e600ce75f7d037a1124c16c03c75ee307c09a7cd | [
"MIT"
] | null | null | null | import UIKit
extension UIFont {
class func editorLight(_ size:CGFloat) -> UIFont { return UIFont(name:"SourceCodeRoman-Light", size:size)! }
class func editorBold(_ size:CGFloat) -> UIFont { return UIFont(name:"SourceCodeRoman-Bold", size:size)! }
class func printLight(_ size:CGFloat) -> UIFont { return .systemFont(ofSize:size, weight:.light) }
class func printBold(_ size:CGFloat) -> UIFont { return .systemFont(ofSize:size, weight:.bold) }
class func printLightItalic(_ size:CGFloat) -> UIFont {
return UIFont(descriptor:UIFontDescriptor(name:UIFont.systemFont(ofSize:size, weight:.light).familyName,
size:size).withSymbolicTraits(.traitItalic)!, size:size)
}
class func printBoldItalic(_ size:CGFloat) -> UIFont {
return UIFont(descriptor:UIFontDescriptor(name:UIFont.systemFont(ofSize:size, weight:.bold).familyName,
size:size).withSymbolicTraits([.traitItalic, .traitBold])!, size:size)
}
}
| 61.588235 | 120 | 0.663801 |
801b3390ef55fea96111970bab6bffea28033e30 | 677 | dart | Dart | packages/flame/lib/src/experimental/world.dart | anderlli0053/flame | fa2eabad65e06d09128439be4adfe435e12ac168 | [
"MIT"
] | null | null | null | packages/flame/lib/src/experimental/world.dart | anderlli0053/flame | fa2eabad65e06d09128439be4adfe435e12ac168 | [
"MIT"
] | null | null | null | packages/flame/lib/src/experimental/world.dart | anderlli0053/flame | fa2eabad65e06d09128439be4adfe435e12ac168 | [
"MIT"
] | null | null | null | import 'dart:ui';
import 'package:meta/meta.dart';
import '../components/component.dart';
import 'camera_component.dart';
/// The root component for all game world elements.
///
/// The primary feature of this component is that it disables regular rendering,
/// and allows itself to be rendered through a [CameraComponent] only. The
/// updates proceed through the world tree normally.
class World extends Component {
@override
void renderTree(Canvas canvas) {}
/// Internal rendering method invoked by the [CameraComponent].
@internal
void renderFromCamera(Canvas canvas) {
assert(CameraComponent.currentCamera != null);
super.renderTree(canvas);
}
}
| 28.208333 | 80 | 0.741507 |
11f312671a7e5d095f97486955df6cde9e072a66 | 531 | cpp | C++ | 01_decisions/dna_hamming.cpp | acc-cosc-1337-spring-2019/midterm-spring-2019-artgonzalezacc | 00393b43a56224709ef5d98a7c41dfe7e6aa385e | [
"MIT"
] | null | null | null | 01_decisions/dna_hamming.cpp | acc-cosc-1337-spring-2019/midterm-spring-2019-artgonzalezacc | 00393b43a56224709ef5d98a7c41dfe7e6aa385e | [
"MIT"
] | null | null | null | 01_decisions/dna_hamming.cpp | acc-cosc-1337-spring-2019/midterm-spring-2019-artgonzalezacc | 00393b43a56224709ef5d98a7c41dfe7e6aa385e | [
"MIT"
] | null | null | null | /*
Write code for value-return function get_dna_hamming_distance with two const string
reference parameters that returns an int.
Problem
Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are
colored red. Given two strings s and t of equal length, the Hamming distance between
s and t, denoted dH(s,t), is the number ofcorresponding symbols that differ in s and t.
Sample for function call
int distance = get_dna_hamming_distance("GAGCCTACTAACGGGAT", "CATCGTAATGACGGCCT");
distance will be 7
*/ | 35.4 | 87 | 0.798493 |
b2efa45aafbdbf20dc2a3beb6bb3e66667896bb3 | 414 | py | Python | DNN_Experiments/MaskRCNN/convert.py | wmjpillow/FlameDetectionAPP | c3761c9e15adccbd084b17cd6b6f63c561c7f856 | [
"MIT"
] | 2 | 2019-12-28T21:46:18.000Z | 2020-01-10T03:41:03.000Z | DNN_Experiments/MaskRCNN/convert.py | wmjpillow/FlameDetectionAPP | c3761c9e15adccbd084b17cd6b6f63c561c7f856 | [
"MIT"
] | 10 | 2019-12-28T21:31:19.000Z | 2020-04-12T20:01:58.000Z | DNN_Experiments/MaskRCNN/convert.py | wmjpillow/FlameDetectionAPP | c3761c9e15adccbd084b17cd6b6f63c561c7f856 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# convert jpg tp png
from glob import glob
import cv2
pngs = glob('./*.jpg')
for j in pngs:
img = cv2.imread(j)
cv2.imwrite(j[:-3] + 'png', img)
# delete jpg files
import glob
import os
dir = "/Users/wangmeijie/ALLImportantProjects/FlameDetectionAPP/Models/MaskRCNN/02_26_2020/Mask_RCNN/dataset/train"
for jpgpath in glob.iglob(os.path.join(dir, '*.jpg')):
os.remove(jpgpath) | 21.789474 | 115 | 0.707729 |
39df36c8feaf4a550c561665ced173847db30517 | 3,017 | java | Java | src/main/java/com/tuin/business/service/mapping/EntidadrolServiceMapper.java | appecapps/tuinstrflt | c525c491c84cc496e02c01967e40463dd0be5672 | [
"MIT"
] | null | null | null | src/main/java/com/tuin/business/service/mapping/EntidadrolServiceMapper.java | appecapps/tuinstrflt | c525c491c84cc496e02c01967e40463dd0be5672 | [
"MIT"
] | null | null | null | src/main/java/com/tuin/business/service/mapping/EntidadrolServiceMapper.java | appecapps/tuinstrflt | c525c491c84cc496e02c01967e40463dd0be5672 | [
"MIT"
] | null | null | null | /*
* Created on 28 ago 2017 ( Time 17:51:15 )
* Generated by Telosys Tools Generator ( version 2.1.1 )
*/
package com.tuin.business.service.mapping;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.stereotype.Component;
import com.tuin.bean.Entidadrol;
import com.tuin.bean.jpa.EntidadrolEntity;
import com.tuin.bean.jpa.RolEntity;
import com.tuin.bean.jpa.EntidadEntity;
/**
* Mapping between entity beans and display beans.
*/
@Component
public class EntidadrolServiceMapper extends AbstractServiceMapper {
/**
* ModelMapper : bean to bean mapping library.
*/
private ModelMapper modelMapper;
/**
* Constructor.
*/
public EntidadrolServiceMapper() {
modelMapper = new ModelMapper();
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
}
/**
* Mapping from 'EntidadrolEntity' to 'Entidadrol'
* @param entidadrolEntity
*/
public Entidadrol mapEntidadrolEntityToEntidadrol(EntidadrolEntity entidadrolEntity) {
if(entidadrolEntity == null) {
return null;
}
//--- Generic mapping
Entidadrol entidadrol = map(entidadrolEntity, Entidadrol.class);
//--- Link mapping ( link to Rol )
if(entidadrolEntity.getRol() != null) {
entidadrol.setRolid(entidadrolEntity.getRol().getId());
}
//--- Link mapping ( link to Entidad )
if(entidadrolEntity.getEntidad() != null) {
entidadrol.setEntidadid(entidadrolEntity.getEntidad().getId());
}
return entidadrol;
}
/**
* Mapping from 'Entidadrol' to 'EntidadrolEntity'
* @param entidadrol
* @param entidadrolEntity
*/
public void mapEntidadrolToEntidadrolEntity(Entidadrol entidadrol, EntidadrolEntity entidadrolEntity) {
if(entidadrol == null) {
return;
}
//--- Generic mapping
map(entidadrol, entidadrolEntity);
//--- Link mapping ( link : entidadrol )
if( hasLinkToRol(entidadrol) ) {
RolEntity rol1 = new RolEntity();
rol1.setId( entidadrol.getRolid() );
entidadrolEntity.setRol( rol1 );
} else {
entidadrolEntity.setRol( null );
}
//--- Link mapping ( link : entidadrol )
if( hasLinkToEntidad(entidadrol) ) {
EntidadEntity entidad2 = new EntidadEntity();
entidad2.setId( entidadrol.getEntidadid() );
entidadrolEntity.setEntidad( entidad2 );
} else {
entidadrolEntity.setEntidad( null );
}
}
/**
* Verify that Rol id is valid.
* @param Rol Rol
* @return boolean
*/
private boolean hasLinkToRol(Entidadrol entidadrol) {
if(entidadrol.getRolid() != null) {
return true;
}
return false;
}
/**
* Verify that Entidad id is valid.
* @param Entidad Entidad
* @return boolean
*/
private boolean hasLinkToEntidad(Entidadrol entidadrol) {
if(entidadrol.getEntidadid() != null) {
return true;
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
protected ModelMapper getModelMapper() {
return modelMapper;
}
protected void setModelMapper(ModelMapper modelMapper) {
this.modelMapper = modelMapper;
}
} | 23.944444 | 104 | 0.709645 |
6b4302e516ea526056902ab28e913ad155bc8bee | 1,769 | html | HTML | doc/device-modeling-guidelines/topic21.html | qiyancos/Simics-3.0.31 | 9bd52d5abad023ee87a37306382a338abf7885f1 | [
"BSD-4-Clause",
"FSFAP"
] | 1 | 2020-06-15T10:41:18.000Z | 2020-06-15T10:41:18.000Z | doc/device-modeling-guidelines/topic21.html | qiyancos/Simics-3.0.31 | 9bd52d5abad023ee87a37306382a338abf7885f1 | [
"BSD-4-Clause",
"FSFAP"
] | null | null | null | doc/device-modeling-guidelines/topic21.html | qiyancos/Simics-3.0.31 | 9bd52d5abad023ee87a37306382a338abf7885f1 | [
"BSD-4-Clause",
"FSFAP"
] | 3 | 2020-08-10T10:25:02.000Z | 2021-09-12T01:12:09.000Z | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Device Model Style</title>
<style>@import url(style.css);</style>
</head>
<body class="jdocu_main">
<script type="text/javascript">
parent.frames['toc'].d.openTo(35, true);
</script>
<a name="label63"></a><p class="jdocu_navbarp"><span class="jdocu_navbar">VIRTUTECH CONFIDENTIAL <a class="jdocu" href="topic20.html">Previous</a> - <a class="jdocu" href="topic20.html">Up</a> - <a class="jdocu" href="topic22.html">Next</a></span></p>
<h3 class="jdocu">9.1 Device Model Style</h3 class="jdocu">
<a name="label64"></a>
<p>
The user interface of a Simics module consists of three parts: its
attributes, its interfaces, and the commands it adds to the Simics
command-line interface. You should try to make the user interface of
your model similar in style to that of existing Simics models.
<p>
Every model should have an <b><a name="label65">info</a></b> command, giving
static information about the device, and a
<b><a name="label66">status</a></b> command, that gives dynamic information.
See the <em>Simics Programming Guide</em> for more information.
<p>
Look at the interfaces of similar devices to see what other commands
may be useful, and try to use the same names for similar commands and
parameters. Use existing API functionality where appropriate, rather
than inventing your own.
<p>
<p class="jdocu_navbarp"><span class="jdocu_navbar">VIRTUTECH CONFIDENTIAL <a class="jdocu" href="topic20.html">Previous</a> - <a class="jdocu" href="topic20.html">Up</a> - <a class="jdocu" href="topic22.html">Next</a></span></p>
</body>
</html>
| 46.552632 | 274 | 0.705483 |
fb2a32c6fc72141acc58c07f568023620ba873be | 340 | go | Go | 6_Control_Flow/5_if_statments/main.go | BarSnir/Golang-Studies | 1efe13573c54486acd64edd5a033636443d3a269 | [
"MIT"
] | null | null | null | 6_Control_Flow/5_if_statments/main.go | BarSnir/Golang-Studies | 1efe13573c54486acd64edd5a033636443d3a269 | [
"MIT"
] | null | null | null | 6_Control_Flow/5_if_statments/main.go | BarSnir/Golang-Studies | 1efe13573c54486acd64edd5a033636443d3a269 | [
"MIT"
] | null | null | null | package main
import (
"fmt"
)
func main() {
if true {
fmt.Println("True-A")
}
if false {
fmt.Println("True-B")
}
if !true {
fmt.Println("True-C")
}
if !false {
fmt.Println("True-D")
}
if !(2 == 2) {
fmt.Println("True-E")
}
if !(2 != 2) {
fmt.Println("True-F")
}
if x := 2; x == 2 {
fmt.Println("True-G")
}
}
| 10.967742 | 23 | 0.508824 |
c5e59ff2ddeb04d50bce666dd4f035bfa3d56a6f | 7,844 | cc | C++ | Code/Components/Services/ingest/current/apps/tMSSink.cc | steve-ord/askapsoft | 21b9df1b393b973ec312591efad7ee2b8c974811 | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | 1 | 2020-06-18T08:37:43.000Z | 2020-06-18T08:37:43.000Z | Code/Components/Services/ingest/current/apps/tMSSink.cc | ATNF/askapsoft | d839c052d5c62ad8a511e58cd4b6548491a6006f | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | Code/Components/Services/ingest/current/apps/tMSSink.cc | ATNF/askapsoft | d839c052d5c62ad8a511e58cd4b6548491a6006f | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | /// @file tMSSink.cc
/// @details
/// This application runs MSSink task with mock up data. This is handy
/// for performance testing.
///
/// @copyright (c) 2010 CSIRO
/// Australia Telescope National Facility (ATNF)
/// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
/// PO Box 76, Epping NSW 1710, Australia
/// atnf-enquiries@csiro.au
///
/// This file is part of the ASKAP software distribution.
///
/// The ASKAP software distribution is free software: you can redistribute it
/// and/or modify it under the terms of the GNU General Public License as
/// published by the Free Software Foundation; either version 2 of the License,
/// or (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// @author Max Voronkov <maxim.voronkov@csiro.au>
// System includes
#include <iostream>
#include <iomanip>
#include <string>
// Include package level header file
#include "askap_cpingest.h"
// casa
#include "casacore/casa/OS/Timer.h"
// ASKAPsoft includes
#include "cpcommon/ParallelCPApplication.h"
#include "askap/AskapLogging.h"
#include "askap/AskapError.h"
#include "boost/shared_ptr.hpp"
#include "cpcommon/VisDatagram.h"
// Local package includes
#include "monitoring/MonitoringSingleton.h"
#include "ingestpipeline/mssink/MSSink.h"
#include "ingestpipeline/sourcetask/VisConverterADE.h"
#include "configuration/Configuration.h" // Includes all configuration attributes too
#include "cpcommon/VisChunk.h"
// I am not very happy to have MPI includes here, we may abstract this interaction
// eventually. This task is specific for the parallel case, so there is no reason to
// hide MPI for now.
#include <mpi.h>
// Using
using namespace askap;
using namespace askap::cp;
using namespace askap::cp::ingest;
ASKAP_LOGGER(logger, "tMSSink");
class MSSinkTestApp : public askap::cp::common::ParallelCPApplication
{
public:
virtual void run() {
//ASKAPCHECK(!isStandAlone() && numProcs() > 1, "This test application is specific to parallel multi-rank case and can't be used in stand-alone mode");
int count = config().getInt32("count", 10);
ASKAPCHECK(count > 0, "Expect positive number of timestamps to receive, you have = "<<count);
uint32_t expectedCount = static_cast<uint32_t>(count);
const bool doSync = numProcs() > 1 ? config().getBool("syncranks", false) : false;
if (doSync) {
ASKAPLOG_INFO_STR(logger, "Ranks will be synchronised and same timestamps will be written on all ranks for all cycles");
}
Configuration cfg(config(), rank(), numProcs());
// setup monitoring, if necessary
if (!cfg.monitoringConfig().registryHost().empty()) {
MonitoringSingleton::init(cfg);
}
// a number of generic monitoring points just in case they're useful
// This code is similar to what ingest is doing, but pass altered string
// for SoftwareVersion, this will help to identify tMSSink as opposed to
// normal ingest
MonitoringSingleton::update<int32_t>("NumberOfRanks",cfg.nprocs());
MonitoringSingleton::update<int32_t>("ReceiverId",cfg.receiverId());
MonitoringSingleton::update<int32_t>("nReceivers",cfg.nReceivingProcs());
MonitoringSingleton::update<std::string>("NodeName",cfg.nodeName());
const std::string versionStr = getAskapPackageVersion_cpingest();
const size_t pos = versionStr.find("ingest; ");
if (pos != std::string::npos) {
ASKAPDEBUGASSERT(versionStr.size() >= pos + 8);
MonitoringSingleton::update<std::string>("SoftwareVersion","tMSSink; " + versionStr.substr(pos+8));
} else {
MonitoringSingleton::update<std::string>("SoftwareVersion","tMSSink; " + versionStr);
}
ASKAPLOG_INFO_STR(logger, "Setting up mock up data structure for rank="<<rank());
VisConverter<VisDatagramADE> conv(config(), cfg);
const CorrelatorMode &corrMode = cfg.lookupCorrelatorMode("standard");
conv.initVisChunk(4976749386006000ul, corrMode);
const float corrInterval = static_cast<float>(corrMode.interval()) / 1e6; // in seconds
boost::shared_ptr<common::VisChunk> chunk = conv.visChunk();
ASKAPASSERT(chunk);
// populate beam offsets from static configuration
cfg.feed().fillMatrix(chunk->beamOffsets());
//
// unflag samples to avoid possible confusion due to large reported number of flagged visibilities
chunk->flag().set(false);
casa::Timer timer;
float processingTime = 0.;
float totalSyncTime = 0.;
size_t actualCount = 0;
ASKAPLOG_INFO_STR(logger, "Initialising MSSink constructor for rank="<<rank());
timer.mark();
MSSink sink(config(), cfg);
const float initTime = timer.real();
ASKAPLOG_INFO_STR(logger, "MSSink initialisation time: "<<initTime<<" seconds");
ASKAPLOG_INFO_STR(logger, "Running the test for rank="<<rank());
for (uint32_t count = 0; count < expectedCount; ++count) {
timer.mark();
if (doSync) {
ASKAPDEBUGASSERT(numProcs() > 1);
double timeRecvBuf[2];
if (rank() == 0) {
timeRecvBuf[0] = chunk->time().getDay();
timeRecvBuf[1] = chunk->time().getDayFraction();
}
const int response = MPI_Bcast(timeRecvBuf, 2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
ASKAPCHECK(response == MPI_SUCCESS, "Error gathering times, response from MPI_Bcast = "<<response);
if (rank() != 0) {
const casa::MVEpoch receivedTime(timeRecvBuf[0], timeRecvBuf[1]);
chunk->time() = receivedTime;
}
}
const float syncTime = timer.real();
totalSyncTime += syncTime;
//uncomment this to trigger FEED table update every cycle (with junk values)
//chunk->beamOffsets().set(float(count)/180.*casa::C::pi);
ASKAPLOG_INFO_STR(logger, "Received "<<count + 1<<" integration(s) for rank="<<rank());
timer.mark();
sink.process(chunk);
const float runTime = timer.real();
ASKAPLOG_INFO_STR(logger, " - mssink took "<<runTime<<" seconds");
processingTime += runTime;
++actualCount;
if (rank() == 0 || !doSync) {
chunk->time() += casa::Quantity(corrInterval > 0 ? corrInterval : 5.,"s");
if (runTime + syncTime < corrInterval) {
sleep(corrInterval - runTime - syncTime);
} else {
if (corrInterval > 0) {
ASKAPLOG_INFO_STR(logger, "Not keeping up! interval = "<<corrInterval<<" seconds, but needed "<<runTime+syncTime<<" seconds this cycle");
}
}
}
}
if (actualCount > 0) {
ASKAPLOG_INFO_STR(logger, "Average running time per cycle: "<<processingTime / actualCount<<
" seconds, "<<actualCount<<" iteratons averaged");
if (doSync) {
ASKAPLOG_INFO_STR(logger, "Average synchronisation time per cycle: "<<totalSyncTime / actualCount<<
" seconds, "<<actualCount<<" iteratons averaged");
}
}
}
private:
};
int main(int argc, char *argv[])
{
MSSinkTestApp app;
return app.main(argc, argv);
}
| 41.723404 | 160 | 0.645589 |
e8ec845a92cf55d2d913198734d9f2f9a641e12b | 3,322 | cpp | C++ | graph-source-code/231-E/4312917.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | graph-source-code/231-E/4312917.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | graph-source-code/231-E/4312917.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | //Language: GNU C++0x
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <cassert>
#ifdef LOCAL
#define ATHFILE(f) freopen(f ".in", "r", stdin), freopen(f ".my", "w", stdout)
#else
#define ATHFILE(f)
#endif
#define DEBUGT(t) if (_t == t) _asm int 3
typedef long long LL;
typedef long double LD;
inline int RD() { int x; scanf("%d", &x); return x; }
inline char RDA() { char ch; while ((ch = getchar()) && !isalpha(ch)); return ch; }
#define Rush for (int tests = RD(), _t = 1; _t <= tests; ++_t)
#define ZMV(x, v) memset((x), (v), sizeof(x))
#define ZM(x) memset((x), 0, sizeof(x))
#define SZ(v) (int)(v.size())
#define ALL(v) v.begin(), v.end()
const int maxint = 0x7f7f7f7f;
const int mod = 1000000007;
const double eps = 1e-10, pi = acos(-1.0);
using namespace std;
const int maxn = 100001;
int n, m, dfn[maxn], low[maxn], ind, color, block[maxn], size[maxn];
vector<int> edge[maxn], tree[maxn];
stack<int> sk;
void tarjan(int u, int pa = -1) {
int v;
dfn[u] = low[u] = ++ind;
sk.push(u);
for (auto it = edge[u].begin(); it != edge[u].end(); ++it) {
v = *it;
if (v == pa) continue;
if (!dfn[v]) {
tarjan(v, u);
low[u] = min(low[u], low[v]);
} else low[u] = min(low[u], dfn[v]);
}
if (dfn[u] == low[u]) {
++color;
do {
v = sk.top();
block[v] = color; ++size[color];
sk.pop();
} while (u != v);
}
}
const int logn = 26;
int parent[maxn], lca[logn][maxn], depth[maxn], cnt[maxn];
void dfs(int u, int pa = -1) {
cnt[u] = (pa == -1 ? 0 : cnt[pa]) + (size[u] > 1 ? 1 : 0);
for (auto it = tree[u].begin(); it != tree[u].end(); ++it) {
if (*it != pa) {
parent[*it] = u;
depth[*it] = depth[u] + 1;
dfs(*it, u);
}
}
}
void initLCA(int n) {
dfs(1);
for (int i = 1; i <= n; ++i) lca[0][i] = parent[i];
for (int j = 1; j < logn; ++j) {
for (int i = 1; i <= n; ++i) {
lca[j][i] = lca[j - 1][lca[j - 1][i]];
}
}
}
int LCA(int x, int y) {
if (depth[x] < depth[y]) swap(x, y);
for (int i = logn - 1; i >= 0; --i) {
if (depth[x] - (1 << i) >= depth[y]) x = lca[i][x];
}
if (x == y) return x;
for (int i = logn - 1; i >= 0; --i) {
if (lca[i][x] != lca[i][y]) {
x = lca[i][x], y = lca[i][y];
}
}
return lca[0][x];
}
int two[maxn];
int main() {
two[0] = 1;
for (int i = 1; i < maxn; ++i) two[i] = two[i - 1] * 2 % mod;
n = RD(); m = RD();
while (m--) {
int u = RD(), v = RD();
edge[u].push_back(v);
edge[v].push_back(u);
}
tarjan(1);
for (int i = 1; i <= n; ++i) {
for (auto it = edge[i].begin(); it != edge[i].end(); ++it) {
int j = *it;
if (block[i] != block[j]) tree[block[i]].push_back(block[j]);
}
}
for (int i = 1; i <= color; ++i) {
sort(ALL(tree[i]));
tree[i].erase(unique(ALL(tree[i])), tree[i].end());
}
initLCA(color);
int q = RD();
while (q--) {
int u = RD(), v = RD(), l;
u = block[u], v = block[v];
l = LCA(u, v);
int ans = cnt[u] + cnt[v] - 2 * cnt[l];
if (size[l] > 1) ++ans;
printf("%d\n", two[ans]);
}
return 0;
}
| 23.394366 | 84 | 0.504515 |
cb334e4a93cfc4a6a369f8923f70704b66f315f4 | 2,325 | go | Go | day02/day02.go | jaredpar/advent2021 | bcbb3eb1817c3018ffe87457b643d8a04b10db63 | [
"MIT"
] | 3 | 2021-12-01T16:16:07.000Z | 2021-12-07T20:48:10.000Z | day02/day02.go | jaredpar/advent2021 | bcbb3eb1817c3018ffe87457b643d8a04b10db63 | [
"MIT"
] | null | null | null | day02/day02.go | jaredpar/advent2021 | bcbb3eb1817c3018ffe87457b643d8a04b10db63 | [
"MIT"
] | null | null | null | package day02
import (
"embed"
"errors"
"fmt"
"strconv"
"strings"
"advent2021.com/util"
)
//go:embed *.txt
var f embed.FS
type direction int
type movement struct {
direction direction
value int
}
const (
DirectionUp direction = iota
DirectionDown
DirectionForward
)
func parseDirection(value string) (direction, error) {
switch value {
case "up":
return DirectionUp, nil
case "down":
return DirectionDown, nil
case "forward":
return DirectionForward, nil
default:
return DirectionUp, nil
}
}
func readMovements(fileName string) ([]movement, error) {
lines, err := util.ReadLines(f, fileName)
if err != nil {
return nil, err
}
movements := make([]movement, len(lines))
for _, line := range lines {
parts := strings.Split(line, " ")
if len(parts) != 2 {
message := fmt.Sprintf("Input misformed: %s", line)
return nil, errors.New(message)
}
direction, err := parseDirection(parts[0])
if err != nil {
message := fmt.Sprintf("Invalid direction: %s", parts[0])
return nil, errors.New(message)
}
value, err := strconv.Atoi(parts[1])
if err != nil {
return nil, err
}
movement := movement{direction: direction, value: value}
movements = append(movements, movement)
}
return movements, nil
}
func calcPosition(fileName string) int {
movements, err := readMovements(fileName)
if err != nil {
panic(err)
}
position := 0
depth := 0
for _, movement := range movements {
switch movement.direction {
case DirectionUp:
depth -= movement.value
case DirectionDown:
depth += movement.value
case DirectionForward:
position += movement.value
default:
panic("bad enum")
}
}
return position * depth
}
func calcPositionWithAim(fileName string) (position int, depth int, aim int) {
movements, err := readMovements(fileName)
if err != nil {
panic(err)
}
for _, movement := range movements {
switch movement.direction {
case DirectionUp:
aim -= movement.value
case DirectionDown:
aim += movement.value
case DirectionForward:
position += movement.value
depth += aim * movement.value
default:
panic("bad enum")
}
}
return
}
func CalcPart1() int {
return calcPosition("input.txt")
}
func CalcPart2() int {
position, depth, _ := calcPositionWithAim("input.txt")
return position * depth
}
| 18.023256 | 78 | 0.677419 |
99529731b7c5ea57a6e044a76c8d116fcce3588a | 1,663 | h | C | include/ssmis.h | rgrumbine/mmablib | 107ba1b1026c3cfed97346233c9a76d3d170d544 | [
"Apache-2.0"
] | null | null | null | include/ssmis.h | rgrumbine/mmablib | 107ba1b1026c3cfed97346233c9a76d3d170d544 | [
"Apache-2.0"
] | null | null | null | include/ssmis.h | rgrumbine/mmablib | 107ba1b1026c3cfed97346233c9a76d3d170d544 | [
"Apache-2.0"
] | null | null | null | #ifndef SSMIS_INCLUDE
#define SSMIS_INCLUDE
/* Robert Grumbine 2008 -- present */
/* Set up data types/classes as appropriate for the AVHRR instruments on */
/* NOAA-17, 18, and METOP-A */
/* Translate to AMSR-suitable 10 April 2009 */
/* Translate to SSMI-S 15 October 2010 */
/* Frequencies are . 19.35, 22.235, 37, 91.655, 150 GHz */
/* horizontal, then vertical, polarization except 22 and 150 which */
/* are H only */
/* Note that we are ignoring the sounding channels */
typedef struct {
float tmbr; /* to 0.01 K, note no channel number or latinfo
here. Simpler system */
} ssmisu_spots;
typedef struct {
short int satid;
short int year;
unsigned char month, day, hour, minute, second;
double clat, clon;
ssmisu_spots obs[8];
} ssmisupt;
/* Note that these indices refer to the ssmisupt, rather than the */
/* ice spot values I'll be using later */
#define SSMIS_T150H 0
#define SSMIS_T19H 1
#define SSMIS_T19V 2
#define SSMIS_T22V 3
#define SSMIS_T37H 4
#define SSMIS_T37V 5
#define SSMIS_T92V 6
#define SSMIS_T92H 7
/* RG: Look this up -- currently copying ssmi value */
#ifndef SSMIS_MAX_LATITUDE
#define SSMIS_MAX_LATITUDE 88.5
#endif
#define NSPOTS 1000
/* Structures which relate to bufr decoding */
typedef struct {
ssmisupt full[NSPOTS];
} scan_points;
extern int process_bufr(ssmisupt *b);
extern int check_bufr(ssmisupt *b);
extern void zero_bufr(ssmisupt *b);
#endif
| 27.716667 | 75 | 0.61816 |
90a57025bf40b479c7e55d79d9c1170e8f6187ac | 2,705 | swift | Swift | Tests/LeetcodeTests/UnitTests/Cases/API Calls/Favorite List/DeleteFavoriteListTest.swift | yaroslav-zhurakovskiy/LeetcodeSwift | a5c0ad38513641dc954961ca05bf6f273957928a | [
"MIT"
] | null | null | null | Tests/LeetcodeTests/UnitTests/Cases/API Calls/Favorite List/DeleteFavoriteListTest.swift | yaroslav-zhurakovskiy/LeetcodeSwift | a5c0ad38513641dc954961ca05bf6f273957928a | [
"MIT"
] | null | null | null | Tests/LeetcodeTests/UnitTests/Cases/API Calls/Favorite List/DeleteFavoriteListTest.swift | yaroslav-zhurakovskiy/LeetcodeSwift | a5c0ad38513641dc954961ca05bf6f273957928a | [
"MIT"
] | null | null | null | //
// Created by Yaroslav Zhurakovskiy
// Copyright © 2019-2020 Yaroslav Zhurakovskiy. All rights reserved.
//
import XCTest
@testable import Leetcode
import Foundation
class DeleteFavoriteListTests: LeetcodeTestCase {
func testStatus204() throws {
try urlSessionSpy.setSuccessResult(bodyStub: .empty, statusCode: 204)
var result: Result<Void, Error>!
leetcode.deleteFavoriteList(byHashID: .any) { result = $0 }
assertCorrectRequest(usingID: .any)
XCTAssertNotNil(result)
assertSuccess(result)
}
func testStatusNot204() {
let data = Data.test
let response = HTTPURLResponse(statusCode: 1_000)
urlSessionSpy.setResult(.success((data: data, response: response)))
var result: Result<Void, Error>!
leetcode.deleteFavoriteList(byHashID: .any) { result = $0 }
assertCorrectRequest(usingID: .any)
XCTAssertNotNil(result)
assertFailure(result)
let error = retreiveError(fromResult: result, as: LeetcodeHTTPError.self)
XCTAssertTrue(error.response === response)
XCTAssertEqual(error.responseBody, data)
}
func testFailure() {
let testError = TestError.shared
urlSessionSpy.setFailureResult(error: testError)
var result: Result<Void, Error>!
leetcode.deleteFavoriteList(byHashID: .any) { result = $0 }
assertCorrectRequest(usingID: .any)
XCTAssertNotNil(result)
assertFailure(result)
let error = retreiveError(fromResult: result, as: TestError.self)
XCTAssertTrue(error === testError)
}
private func assertCorrectRequest(usingID id: String, line: UInt = #line) {
XCTAssertEqual(urlSessionSpy.requests.count, 1, line: line)
let request = urlSessionSpy.requests[0]
assertURL(of: request, isEqualToLeetcodePath: "/list/api/\(id)", line: line)
assertMethod(of: request, isEqualTo: "DELETE", line: line)
assertOrigin(of: request, isEqualToLeetcodePath: "/list/", line: line)
assertReferer(of: request, isEqualToLeetcodePath: "/list/", line: line)
}
}
extension Int {
static var any: Int { return 0 }
}
extension Data {
static var test: Data {
return "*TEST-DATA*".data(using: .utf8)!
}
}
extension String {
static var any: String {
return "ANY"
}
}
extension HTTPURLResponse {
convenience init(statusCode: Int, file: String = #file) {
self.init(
url: URL(fileURLWithPath: file),
statusCode: statusCode,
httpVersion: nil,
headerFields: nil
)!
}
}
| 30.738636 | 84 | 0.636969 |
eabbcfb9bc0799c1e3ebdbf3e932324e53a019cf | 2,936 | sql | SQL | Dump20171218.sql | Tuch1312/Rubrica | 4fe2c28a1cace8058a9a23e12eca295a52b5e86c | [
"MIT"
] | null | null | null | Dump20171218.sql | Tuch1312/Rubrica | 4fe2c28a1cace8058a9a23e12eca295a52b5e86c | [
"MIT"
] | null | null | null | Dump20171218.sql | Tuch1312/Rubrica | 4fe2c28a1cace8058a9a23e12eca295a52b5e86c | [
"MIT"
] | null | null | null | CREATE DATABASE IF NOT EXISTS `contattiDB` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `contattiDB`;
-- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64)
--
-- Host: localhost Database: contattiDB
-- ------------------------------------------------------
-- Server version 5.5.5-10.1.28-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `contatti`
--
DROP TABLE IF EXISTS `contatti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contatti` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(45) DEFAULT NULL,
`cognome` varchar(45) DEFAULT NULL,
`mail` varchar(45) DEFAULT NULL,
`numeroTelefono` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `contatti`
--
LOCK TABLES `contatti` WRITE;
/*!40000 ALTER TABLE `contatti` DISABLE KEYS */;
INSERT INTO `contatti` VALUES (2,'arcibaldo','nuzzolo','arci@mail','131213124'),(3,'luca','gialli','gialli.l@mail.com','8882933521'),(4,'francesco','blu','francesco@mail.com','7543785748'),(5,'franco','rosa','francorosa@mail.com','8475834744'),(6,'giovanni','rossi','giovarssi@libero.it','0342342344'),(8,'lucia','due','luica@mail','0432959434'),(9,'beatrice','tre','beatrice@mail','4458345458'),(10,'christian','quattro','chri@mail','4584357834'),(12,'amhed','abdhulla','amhedmail','4548579454'),(13,'abdul','jamali','abdul@mail','4647848376'),(14,'gabriele','bonzi','mail@lele','72632763256'),(16,'mattia','acab','acab@mail','37376376376'),(17,'matta','null','null','4343434343'),(18,'mattia','acab','acab@mail','6374377');
/*!40000 ALTER TABLE `contatti` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping events for database 'contattiDB'
--
--
-- Dumping routines for database 'contattiDB'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-12-18 14:30:27
| 45.169231 | 725 | 0.702316 |
3171232ffc67b6cbdd4ea632a320bdc786e9b9b1 | 908 | sql | SQL | CSharp DB Fundamentals MSSQL/TableRelations/TableRelations/05.OnlineStoreDatabase.sql | MiroslavKisov/Software-University | 4bf99b6c66c7eedfb682ce398224382a5ebf02a3 | [
"MIT"
] | null | null | null | CSharp DB Fundamentals MSSQL/TableRelations/TableRelations/05.OnlineStoreDatabase.sql | MiroslavKisov/Software-University | 4bf99b6c66c7eedfb682ce398224382a5ebf02a3 | [
"MIT"
] | null | null | null | CSharp DB Fundamentals MSSQL/TableRelations/TableRelations/05.OnlineStoreDatabase.sql | MiroslavKisov/Software-University | 4bf99b6c66c7eedfb682ce398224382a5ebf02a3 | [
"MIT"
] | null | null | null | USE TableRelations
--START
CREATE TABLE Cities(
CityID INT PRIMARY KEY NOT NULL,
Name NVARCHAR(50) NOT NULL
)
CREATE TABLE Customers(
CustomerID INT PRIMARY KEY NOT NULL,
Name NVARCHAR(50) NOT NULL,
Birthday DATE NOT NULL,
CityID INT FOREIGN KEY REFERENCES Cities(CityID)
)
CREATE TABLE Orders(
OrderID INT PRIMARY KEY NOT NULL,
CustomerID INT FOREIGN KEY REFERENCES Customers(CustomerID)
)
CREATE TABLE ItemTypes(
ItemTypeID INT PRIMARY KEY NOT NULL,
Name NVARCHAR(50)
)
CREATE TABLE Items(
ItemID INT PRIMARY KEY NOT NULL,
Name NVARCHAR(50) NOT NULL,
ItemTypeID INT FOREIGN KEY REFERENCES ItemTypes(ItemTypeID)
)
CREATE TABLE OrderItems(
OrderID INT,
ItemID INT,
CONSTRAINT PK_OrderID_ItemID
PRIMARY KEY (OrderID, ItemID),
CONSTRAINT FK_OrderID
FOREIGN KEY (OrderID)
REFERENCES Orders(OrderID),
CONSTRAINT FK_ItemID
FOREIGN KEY (ItemID)
REFERENCES Items(ItemID)
)
| 15.929825 | 60 | 0.768722 |
72fa23c5f19443593be5271a6e7844ed8c834567 | 383 | html | HTML | changes/index.html | wikimatze/padrinorb-website | 296c359e21f8889058a1fb4b33da0005f7e2b0fa | [
"Apache-2.0"
] | null | null | null | changes/index.html | wikimatze/padrinorb-website | 296c359e21f8889058a1fb4b33da0005f7e2b0fa | [
"Apache-2.0"
] | null | null | null | changes/index.html | wikimatze/padrinorb-website | 296c359e21f8889058a1fb4b33da0005f7e2b0fa | [
"Apache-2.0"
] | null | null | null | ---
layout: page
title: Changes
text: The changelog for Padrino.
---
{% capture current %}Changes{% endcapture %}
{% include header_navigation.html %}
{% include headline.html %}
<div class="container">
<div class="row">
<div class="col-lg-12">
{% capture changes %}{% include changes.md %}{% endcapture %}
{{ changes | markdownify }}
</div>
</div>
</div>
| 19.15 | 67 | 0.616188 |
1280d6f73340c6e5a7b6858447253cf37bf4faee | 172 | h | C | system/include/stdio.h | Qs315490/QuickSwift_OS | b14ab9a78cf8c0397f7c04cdd0d8da2b15cf12d3 | [
"Apache-2.0"
] | null | null | null | system/include/stdio.h | Qs315490/QuickSwift_OS | b14ab9a78cf8c0397f7c04cdd0d8da2b15cf12d3 | [
"Apache-2.0"
] | null | null | null | system/include/stdio.h | Qs315490/QuickSwift_OS | b14ab9a78cf8c0397f7c04cdd0d8da2b15cf12d3 | [
"Apache-2.0"
] | null | null | null | //
// Created by Qs315490 on 2021/2/9.
//
#ifndef QUICKSWIFTOS_STDIO_H
#define QUICKSWIFTOS_STDIO_H
//控制台标准输出
int printf(const char*,...);
#endif //QUICKSWIFTOS_STDIO_H
| 14.333333 | 35 | 0.738372 |
291f735f51e01122ff3f1ba4fe0ace6dc03366e5 | 3,552 | py | Python | cli_stats/clean_stats/team_standings_clean.py | timoudas/premier_league_api | 2b850466ed1c910ee901c68e660706d55f53df61 | [
"MIT"
] | 2 | 2020-02-13T12:30:47.000Z | 2020-03-21T16:32:47.000Z | cli_stats/clean_stats/team_standings_clean.py | timoudas/premier_league_api | 2b850466ed1c910ee901c68e660706d55f53df61 | [
"MIT"
] | 2 | 2021-04-06T18:27:57.000Z | 2021-06-02T03:51:47.000Z | cli_stats/clean_stats/team_standings_clean.py | timoudas/premier_league_api | 2b850466ed1c910ee901c68e660706d55f53df61 | [
"MIT"
] | null | null | null | from .load_files import deep_get
from .load_files import load_team_standings
def read_team_standings_stats(data):
info_all = []
try:
for d in data:
stats_temp = {}
comp = d['season']
standing = d['standing']
team = d['team']
for fixtures in standing:
if fixtures:
player_fixtures = fixtures['fixtures']
stats_temp = \
{'team' : deep_get(team, 'name'),
'team_id' : deep_get(team, 'club.id'),
'team_shortName' : deep_get(team, 'club.shortName'),
'competition' : deep_get(comp, 'competition.description'),
'competition_abbr' : deep_get(comp, 'competition.abbreviation'),
'competition_id' : deep_get(comp, 'competition.id'),
'seasonLabel': deep_get(d, 'season.label'),
'seasonId': deep_get(d, 'season.id'),
'fixtures' : [],
'played' : fixtures['played'],
'points' : fixtures['points'],
'position' : fixtures['position']}
for fixture in player_fixtures:
fixture_temp = {}
fixture_temp = \
{'home_team' : fixture['teams'][0]['team']['name'],
'home_team_id' : fixture['teams'][0]['team']['club']['id'],
'home_team_shortName' : fixture['teams'][0]['team']['shortName'],
'home_team_score' : fixture['teams'][0]['score'],
'away_team' : fixture['teams'][1]['team']['name'],
'away_team_id' : fixture['teams'][1]['team']['club']['id'],
'away_team_shortName' : fixture['teams'][1]['team']['shortName'],
'away_team_score' : fixture['teams'][1]['score'],
'ground' : fixture['ground']['name'],
'grounds_id' : fixture['ground']['id'],
'city' : fixture['ground']['city'],
'fixtureType' : fixture['fixtureType'],
'extraTime' : fixture['extraTime'],
'shootout' : fixture['shootout'],
'f_id' : fixture['id'],
'clock_label' : fixture['clock']['label'],
'clock_secs' : fixture['clock']['secs'],
'gameweekId': fixture['gameweek']['id'],
'gameweek': fixture['gameweek']['gameweek'],
'kickoffLabel': fixture['kickoff']['label'],
'kickoffMillis': fixture['kickoff']['millis']
}
stats_temp.update({
'gameweek': fixture['gameweek']['gameweek'],
'gameweekId': fixture['gameweek']['id'],
})
stats_temp['fixtures'].append(fixture_temp)
info_all.append(stats_temp)
except KeyError as e:
pass
return info_all
def team_standings(league, year):
"""Returns team standings"""
stats = read_team_standings_stats(load_team_standings(league, year))
return stats | 48 | 93 | 0.434685 |
d09fe97cd439196c55be776fefabdba2c0126615 | 2,957 | css | CSS | main/style.css | okanuregen/University-Database-System | 5204243e835d80ef225a466a8a6daa853ed71303 | [
"MIT"
] | 1 | 2021-06-16T16:21:55.000Z | 2021-06-16T16:21:55.000Z | main/style.css | ozdemirmrtcn/University-Database-System | 018b445b70189d6e2ddec2a4af4c47f077259cc2 | [
"MIT"
] | 1 | 2020-06-14T11:56:46.000Z | 2020-06-14T14:46:16.000Z | main/style.css | ozdemirmrtcn/University-Database-System | 018b445b70189d6e2ddec2a4af4c47f077259cc2 | [
"MIT"
] | 1 | 2021-06-16T16:05:01.000Z | 2021-06-16T16:05:01.000Z | * {
padding: 0;
margin: 0;
}
a {
text-decoration: none;
font-style: none;
color: black;
}
.d-block {
display: block;
}
.d-none {
display: none;
}
.inline-block {
display: inline-block;
}
.ml-3 {
margin-left: 3rem;
}
.mr-3 {
margin-right: 3rem;
}
.mr-5 {
margin-right: 5rem;
}
.upper-case {
text-transform: uppercase;
}
.text-capitalize {
text-transform: capitalize;
}
.text-success {
color: #5cb85c;
}
.text-danger {
color: #d9534f;
}
.text-sm {
font-size: 0.8rem;
}
.f-left {
float: left;
}
.f-right {
float: right;
}
.warning {
background-color: #ff9501;
margin: 5px;
border-radius: 15px;
padding-left: 18px;
padding-top: 25px;
padding-bottom: 25px;
font-size: 20px;
}
/*Nav Bar*/
nav {
display: block;
background: #d8ddff;
padding: 20px 15px;
padding-left: 80px;
}
nav span {
display: inline-block;
font-size: 1.2rem;
text-transform: uppercase;
padding-right: 20px;
}
nav span:nth-child(1) {
font-size: 2rem;
text-transform: uppercase;
padding-right: 20px;
}
nav span a {
transition: all 0.4s;
}
nav span a:hover {
font-size: 1.4rem;
color: #1f2fad;
}
.container {
width: 98%;
margin: 20px;
margin-right: auto;
margin-left: auto;
}
/*Form*/
.lesson-form {
padding-bottom: 5px;
margin-left: 50px;
}
.select-lesson {
border-radius: 3px;
padding: 10px;
padding-right: 15px;
}
.show-hours {
padding-left: 50px;
padding-right: 50px;
}
/*Table*/
.table-box {
margin-bottom: 40px;
padding: 10px;
}
.table-name {
display: block;
font-size: 1.5rem;
font-family: 'Nanum Gothic', sans-serif;
color: #1f2fad;
margin-bottom: 10px;
}
table {
max-width: 800px;
border-radius: 8px;
}
table tr:first-child {
background: #6c79e0;
color: aliceblue;
}
table tr:first-child:hover {
background: #6c79e0;
color: aliceblue;
}
th {
padding-right: 20px;
padding-left: 20px;
padding-bottom: 18px;
padding-top: 18px;
font-weight: 100;
}
th:first-child {
border-top-left-radius: 8px;
}
th:last-child {
border-top-right-radius: 8px;
}
td {
border-bottom: 1px solid #f2f2f2;
text-align: center;
padding: 10px;
}
tr:hover {
background-color: #f2f2f2;
}
.see-more {
cursor: pointer;
width: 80px;
padding: 12px 0px;
color: white;
border-radius: 5px;
border: 1px solid #6c79e0;
background-color: #6c79e0;
transition: background 0.3s;
}
.see-more:hover {
border: 1px solid #6c79e0;
background-color: transparent;
color: #6c79e0;
}
/* Short-Table*/
.table {
margin-left: 10px;
}
.short-table tr td {
border-radius: 5px;
text-align: left;
background-color: white;
color: black;
padding: 20px 10px;
}
.short-table td:nth-child(odd) {
background: #6c79e0;
color: aliceblue;
}
| 13.200893 | 44 | 0.597565 |
cce14ade27c79ab79d52d32e33f444bedd14e567 | 134 | sql | SQL | oci-test/tests/oci_mysql_configuration/test-list-query.sql | turbot/steampipe-plugin-oci | cd534d4992835eb1c756ea93d54ed1a653f7874a | [
"Apache-2.0"
] | 14 | 2021-04-08T08:15:06.000Z | 2022-03-23T16:07:49.000Z | oci-test/tests/oci_mysql_configuration/test-list-query.sql | turbot/steampipe-plugin-oci | cd534d4992835eb1c756ea93d54ed1a653f7874a | [
"Apache-2.0"
] | 235 | 2021-04-02T14:39:36.000Z | 2022-03-30T12:44:35.000Z | oci-test/tests/oci_mysql_configuration/test-list-query.sql | turbot/steampipe-plugin-oci | cd534d4992835eb1c756ea93d54ed1a653f7874a | [
"Apache-2.0"
] | null | null | null | select display_name, id, lifecycle_state, shape_name, type
from oci.oci_mysql_configuration
where display_name = '{{ resourceName }}'; | 44.666667 | 58 | 0.80597 |
46c3ef2dac5054473dc70529e961310452e59091 | 4,609 | cs | C# | Assets/Scripts/Managers/NetworkManager.cs | tarikisildar/Judgement-Day | 0e124be81fa33238471cde3519b8feb27e677afd | [
"MIT"
] | 4 | 2021-06-09T14:23:11.000Z | 2021-06-13T17:31:07.000Z | Assets/Scripts/Managers/NetworkManager.cs | alperenaydas/Judgement-Day | 0e124be81fa33238471cde3519b8feb27e677afd | [
"MIT"
] | null | null | null | Assets/Scripts/Managers/NetworkManager.cs | alperenaydas/Judgement-Day | 0e124be81fa33238471cde3519b8feb27e677afd | [
"MIT"
] | 1 | 2021-06-09T14:30:26.000Z | 2021-06-09T14:30:26.000Z | using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using Managers;
using Photon.Pun.UtilityScripts;
using UI;
public class NetworkManager : MonoBehaviourPunCallbacks
{
public static bool gameReady = false;
public static List<GameObject> players = new List<GameObject>();
private SearchRoomPopup searchRoomPopup;
void Start()
{
if(PlayerPrefs.HasKey(Constants.UserNameKey))
{
SetUpName();
}
searchRoomPopup = CanvasManager.Instance.GetPopUpCanvas().GetSearchRoomPopUp();
}
public static void FindRoom()
{
if(PhotonNetwork.IsConnected)
{
ExitGames.Client.Photon.Hashtable customPropreties = new ExitGames.Client.Photon.Hashtable();
customPropreties["Map"] = PlayerPrefs.GetInt(Constants.MapKey, 0);
PhotonNetwork.JoinRandomRoom(customPropreties,0);
}
else
{
PhotonNetwork.GameVersion = Constants.GameVersion;
PhotonNetwork.ConnectUsingSettings();
}
}
public static void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
}
public static void Connect()
{
PhotonNetwork.GameVersion = Constants.GameVersion;
PhotonNetwork.ConnectUsingSettings();
}
public void SetUpName()
{
if(!PlayerPrefs.HasKey(Constants.UserNameKey)) { return; }
string playerName = PlayerPrefs.GetString(Constants.UserNameKey);
PhotonNetwork.NickName = playerName;
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected to master server.");
CanvasManager.Instance.GetPopUpCanvas().HideConnectingPopUp();
}
public override void OnDisconnected(DisconnectCause cause)
{
Debug.Log($"Disconnected from server. Photon log: {cause}");
CanvasManager.Instance.ShowPopUpCanvas();
CanvasManager.Instance.GetPopUpCanvas().ShowConnectingPopUp();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("No room found, creating a new room.");
searchRoomPopup.WaitingPlayers();
searchRoomPopup.SetUserNames();
// PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = (byte)Constants.MaxPlayersPerRoom });
ExitGames.Client.Photon.Hashtable customPropreties = new ExitGames.Client.Photon.Hashtable();
customPropreties["Map"] = PlayerPrefs.GetInt(Constants.MapKey, 0);
RoomOptions roomOptions = new RoomOptions() {CustomRoomProperties = customPropreties, IsVisible = true, IsOpen = true, MaxPlayers = (byte)Constants.MaxPlayersPerRoom};
roomOptions.CustomRoomPropertiesForLobby = new string[]
{
"Map",
};
PhotonNetwork.CreateRoom("Room" + Random.Range(0, 1000), roomOptions);
}
public override void OnJoinedRoom()
{
Debug.Log("Client successfully joined a room.");
searchRoomPopup.WaitingPlayers();
searchRoomPopup.SetUserNames();
int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
if(playerCount != Constants.MaxPlayersPerRoom)
{
Debug.Log("Waiting for opponents.");
}
else
{
Debug.Log("Match is ready to begin.");
gameReady = true;
StartGame();
}
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
searchRoomPopup.SetUserNames();
if(PhotonNetwork.CurrentRoom.PlayerCount == Constants.MaxPlayersPerRoom)
{
PhotonNetwork.CurrentRoom.IsOpen = false;
Debug.Log("Match is ready to begin.");
gameReady = true;
StartGame();
}
}
public override void OnPlayerLeftRoom(Player otherPlayer)
{
base.OnPlayerLeftRoom(otherPlayer);
searchRoomPopup.SetUserNames();
}
public static void Disconnect()
{
PhotonNetwork.DestroyAll();
PhotonNetwork.LeaveRoom();
PhotonNetwork.Disconnect();
}
void StartGame()
{
searchRoomPopup.Starting();
StartCoroutine(CountDown());
}
IEnumerator CountDown()
{
Debug.Log("3");
yield return new WaitForSeconds(1f);
Debug.Log("2");
yield return new WaitForSeconds(1f);
Debug.Log("1");
yield return new WaitForSeconds(1f);
CanvasManager.Instance.GetPopUpCanvas().HideSearchRoomPopUp();
GameManager.Instance.StartGame();
}
}
| 28.276074 | 175 | 0.641571 |
9bd341c857c8370e20c5b1dd9ce243af93eb9eb8 | 2,906 | js | JavaScript | src/mixins/pdf-utils.js | BAG-ERA/covid-n-go | 6a04da6634c88585a77d9a41d6cef036b0fa7149 | [
"MIT"
] | null | null | null | src/mixins/pdf-utils.js | BAG-ERA/covid-n-go | 6a04da6634c88585a77d9a41d6cef036b0fa7149 | [
"MIT"
] | null | null | null | src/mixins/pdf-utils.js | BAG-ERA/covid-n-go | 6a04da6634c88585a77d9a41d6cef036b0fa7149 | [
"MIT"
] | null | null | null | /* eslint-disable no-alert */
import { PDFDocument, StandardFonts } from 'pdf-lib';
const ys = {
travail: 488,
achats: 417,
sante: 370,
famille: 350,
handicap: 315,
sport_animaux: 294,
convocation: 208,
missions: 178,
enfants: 157,
};
function getIdealFontSize(font, text, maxWidth, minSize, defaultSize) {
let currentSize = defaultSize;
let textWidth = font.widthOfTextAtSize(text, defaultSize);
while (textWidth > maxWidth && currentSize > minSize) {
// eslint-disable-next-line no-plusplus
textWidth = font.widthOfTextAtSize(text, --currentSize);
}
return textWidth > maxWidth ? null : currentSize;
}
async function generatePdf(profile, reasons, pdfBase, qrcode, qrdata) {
const {
lastname,
firstname,
birthday,
placeofbirth,
address,
zipcode,
city,
} = profile;
const existingPdfBytes = await fetch(pdfBase).then((res) => res.arrayBuffer());
const pdfDoc = await PDFDocument.load(existingPdfBytes);
// set pdf metadata
pdfDoc.setTitle('COVID-19 - Déclaration de déplacement');
pdfDoc.setSubject('Attestation de déplacement dérogatoire');
pdfDoc.setKeywords([
'covid19',
'covid-19',
'attestation',
'déclaration',
'déplacement',
'officielle',
'gouvernement',
]);
pdfDoc.setProducer('DNUM/SDIT');
pdfDoc.setCreator('');
pdfDoc.setAuthor("Ministère de l'intérieur");
const page1 = pdfDoc.getPages()[0];
const font = await pdfDoc.embedFont(StandardFonts.Helvetica);
const drawText = (text, x, y, size = 11) => {
page1.drawText(text, {
x, y, size, font,
});
};
drawText(`${firstname} ${lastname}`, 107, 657);
drawText(birthday, 107, 627);
drawText(placeofbirth, 240, 627);
drawText(`${address} ${zipcode} ${city}`, 124, 596);
reasons.forEach((reason) => {
drawText('x', 59, ys[reason], 18);
});
let locationSize = getIdealFontSize(font, city, 83, 7, 11);
if (!locationSize) {
alert(
'Le nom de la ville risque de ne pas être affiché correctement en raison de sa longueur. '
+ 'Essayez d\'utiliser des abréviations ("Saint" en "St." par exemple) quand cela est possible.',
);
locationSize = 7;
}
drawText(profile.city, 93, 122, locationSize);
drawText(`${profile.datesortie}`, 76, 92, 11);
drawText(`${profile.heuresortie}`, 246, 92, 11);
// Date création
drawText('Date de création:', 479, 120, 6);
drawText(qrdata[0], 470, 124, 6);
const qrImage = await pdfDoc.embedPng(qrcode);
page1.drawImage(qrImage, {
x: page1.getWidth() - 133,
y: 38,
width: 105,
height: 105,
});
pdfDoc.addPage();
const page2 = pdfDoc.getPages()[1];
page2.drawImage(qrImage, {
x: 50,
y: page2.getHeight() - 390,
width: 300,
height: 300,
});
const pdfBytes = await pdfDoc.save();
return new Blob([pdfBytes], { type: 'application/pdf' });
}
export default generatePdf;
| 25.051724 | 105 | 0.652443 |
3d871f80e3643e72e78f5d4ace29f729c144cc50 | 683 | rs | Rust | zinc-bytecode/src/instructions/memory/load_sequence_global.rs | sunny-g/zinc | 302a9ea570ba34e980fdeb313426e7c404c1cf4e | [
"MIT"
] | null | null | null | zinc-bytecode/src/instructions/memory/load_sequence_global.rs | sunny-g/zinc | 302a9ea570ba34e980fdeb313426e7c404c1cf4e | [
"MIT"
] | 4 | 2021-03-01T18:58:06.000Z | 2021-09-28T13:14:13.000Z | zinc-bytecode/src/instructions/memory/load_sequence_global.rs | ingzkp/zinc | 1f03631c7136f37e7d59379b7d1e606ef0563f31 | [
"MIT"
] | null | null | null | use crate::{Instruction, InstructionInfo};
use serde_derive::{Deserialize, Serialize};
/// Loads several values from data stack and pushes them onto evaluation stack.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct LoadSequenceGlobal {
pub address: usize,
pub len: usize,
}
impl LoadSequenceGlobal {
pub fn new(address: usize, len: usize) -> Self {
Self { address, len }
}
}
impl InstructionInfo for LoadSequenceGlobal {
fn to_assembly(&self) -> String {
format!("load_array_global {} {}", self.address, self.len)
}
fn wrap(&self) -> Instruction {
Instruction::LoadSequenceGlobal((*self).clone())
}
}
| 26.269231 | 79 | 0.674963 |
f0614ad5a01fc0ee5d8e001a482a5e25e09fde22 | 419 | ps1 | PowerShell | examples/hyperflex/Remove-IntersightHyperflexSoftwareDistributionComponent.ps1 | CiscoDevNet/intersight-powershell | 01e565eab5586e4bc4b9eecde73067e1c3497e6c | [
"Apache-2.0"
] | 6 | 2021-03-24T15:21:12.000Z | 2022-02-22T09:47:16.000Z | examples/hyperflex/Remove-IntersightHyperflexSoftwareDistributionComponent.ps1 | CiscoDevNet/intersight-powershell | 01e565eab5586e4bc4b9eecde73067e1c3497e6c | [
"Apache-2.0"
] | 18 | 2020-08-27T20:54:38.000Z | 2022-03-31T05:53:57.000Z | examples/hyperflex/Remove-IntersightHyperflexSoftwareDistributionComponent.ps1 | CiscoDevNet/intersight-powershell | 01e565eab5586e4bc4b9eecde73067e1c3497e6c | [
"Apache-2.0"
] | 3 | 2020-07-07T14:59:28.000Z | 2021-03-27T14:41:50.000Z |
#Get the HyperflexSoftwareDistributionComponent to delete
$HyperflexSoftwareDistributionComponent = Remove-IntersightHyperflexSoftwareDistributionComponent -Name HyperflexSoftwareDistributionComponentName
$HyperflexSoftwareDistributionComponent | Remove-IntersightHyperflexSoftwareDistributionComponent
#Remove the server profile by Moid.
Remove-IntersightHyperflexSoftwareDistributionComponent -Moid 123bc2222287wee
| 52.375 | 146 | 0.914081 |
6c930784dd361663d8ecd5fb8f6dbb3103e181a0 | 633 | go | Go | demo_test/channel_test03.go | Vicky-w/go_base_test | 8a8ca54d4af391b9ed9df7dc8595f44fa92ee419 | [
"Apache-2.0"
] | null | null | null | demo_test/channel_test03.go | Vicky-w/go_base_test | 8a8ca54d4af391b9ed9df7dc8595f44fa92ee419 | [
"Apache-2.0"
] | null | null | null | demo_test/channel_test03.go | Vicky-w/go_base_test | 8a8ca54d4af391b9ed9df7dc8595f44fa92ee419 | [
"Apache-2.0"
] | null | null | null | package main
import (
"fmt"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//c:=make(chan bool)
//for i :=0 ; i<10 ; i++{
// go Go(c,i)
//}
//<- c
c := make(chan bool, 10)
for i := 0; i < 10; i++ {
go Go(c, i)
}
for i := 0; i < 10; i++ {
v := <-c
fmt.Println(v)
}
}
//func Go(c chan bool, index int) {
// a := 1
// for i := 0; i < 10000000; i++ {
// a += i
// }
// fmt.Println(index, a)
// if index == 9 { 多CUP不能使用尾部index来判断
// c <- true
// }
//
//}
func Go(c chan bool, index int) { //只保证了输出数量 不保证顺序
a := 1
for i := 0; i < 10000000; i++ {
a += i
}
fmt.Println(index, a)
c <- true
}
| 14.066667 | 50 | 0.491311 |
16d911eca7460b341174dd68a4f083ca7edea59b | 128 | ts | TypeScript | apps/concord/src/validation/IValidator.ts | vassourita/agree | 31760114c3407f7ab0fbd2364605c48d1a5187d9 | [
"MIT"
] | 14 | 2020-08-18T23:29:48.000Z | 2022-02-06T04:04:47.000Z | apps/concord/src/validation/IValidator.ts | vassourita/agree | 31760114c3407f7ab0fbd2364605c48d1a5187d9 | [
"MIT"
] | 10 | 2021-05-05T00:48:02.000Z | 2022-02-27T16:38:45.000Z | apps/concord/src/validation/IValidator.ts | vassourita/agree | 31760114c3407f7ab0fbd2364605c48d1a5187d9 | [
"MIT"
] | 1 | 2021-12-10T03:03:23.000Z | 2021-12-10T03:03:23.000Z | import { ValidationError } from 'yup'
export interface IValidator<T> {
validate(input: T): Promise<null | ValidationError>
}
| 21.333333 | 53 | 0.734375 |
b4c6639a4ae41f7b16b64cd8783ccf5ca5ffce87 | 186 | sql | SQL | evo-X-Scriptdev2/sql/Updates/0.0.4/r1463_mangos.sql | Gigelf-evo-X/evo-X | d0e68294d8cacfc7fb3aed5572f51d09a47136b9 | [
"OpenSSL"
] | 1 | 2019-01-19T06:35:40.000Z | 2019-01-19T06:35:40.000Z | src/bindings/Scriptdev2/sql/Updates/0.0.4/r1463_mangos.sql | mfooo/wow | 3e5fad4cfdf0fd1c0a2fd7c9844e6f140a1bb32d | [
"OpenSSL"
] | null | null | null | src/bindings/Scriptdev2/sql/Updates/0.0.4/r1463_mangos.sql | mfooo/wow | 3e5fad4cfdf0fd1c0a2fd7c9844e6f140a1bb32d | [
"OpenSSL"
] | null | null | null | DELETE FROM areatrigger_scripts WHERE entry=5140;
INSERT INTO areatrigger_scripts VALUES (5140,'at_svala_intro');
UPDATE instance_template SET script='instance_pinnacle' WHERE map=575;
| 37.2 | 70 | 0.83871 |
a37c9a41c4a46cead9d857e81da0143ffebd7e33 | 29,680 | dart | Dart | lib/src/page/form_feedback/flutter_feedback_plugin_page.dart | nusanet/flutter-feedback-plugin | 8887f4f992fbcb1fe8bef097b65600be1b08ae4e | [
"MIT"
] | 1 | 2021-04-21T03:27:29.000Z | 2021-04-21T03:27:29.000Z | lib/src/page/form_feedback/flutter_feedback_plugin_page.dart | nusanet/flutter-feedback-plugin | 8887f4f992fbcb1fe8bef097b65600be1b08ae4e | [
"MIT"
] | null | null | null | lib/src/page/form_feedback/flutter_feedback_plugin_page.dart | nusanet/flutter-feedback-plugin | 8887f4f992fbcb1fe8bef097b65600be1b08ae4e | [
"MIT"
] | null | null | null | import 'dart:io';
import 'package:coderjava_image_editor_pro/coderjava_image_editor_pro.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feedback/localization/en_message.dart';
import 'package:flutter_feedback/localization/id_message.dart';
import 'package:flutter_feedback/localization/lookup_message.dart';
import 'package:flutter_feedback/src/data/model/device_logs/device_logs.dart';
import 'package:flutter_feedback/src/widget/widget_dialog.dart';
import 'package:flutter_feedback/src/widget/widget_edit_device_logs.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart';
import '../preview_image/flutter_feedback_preview_image_page.dart';
/// Listener untuk menampilkan loading atau tidak
final _valueListenableLoading = ValueNotifier<bool>(false);
/// Warna primary dari identitas app Anda
late Color _colorPrimary;
/// Callback function ketika respon kode dari API adalah 401
Function()? _onDialog401Showing;
/// Localization untuk bahasa yang digunakan di halaman ini
late LookupMessage _locale;
/// Alias function ketika button `SEND` ditekan
typedef _OnSubmitFeedback = void Function(
List<String> listScreenshots,
String category,
String description,
DeviceLogs deviceLogs,
);
/// Halaman ini berfungsi untuk menampilkan form feedback.
class FormFeedbackController {
void submitFeedback() {
_valueListenableLoading.value = true;
}
/// Action ketika gagal kirim feedback
void failureFeedback(BuildContext context, String errorMessage) {
_valueListenableLoading.value = false;
if (errorMessage.contains('401')) {
_showDialog401(context);
return;
}
_showSnackBar(context, errorMessage);
}
/// Action ketika berhasil kirim feedback
void successFeedback(BuildContext context) {
_valueListenableLoading.value = false;
_showDialogSuccess(context);
}
}
class FlutterFeedbackPluginPage extends StatefulWidget {
/// Hasil file screenshot
final File fileScreenshot;
/// Callback ketika button `SEND` ditekan
final _OnSubmitFeedback onSubmitFeedback;
/// Email user yang sedang login
final String email;
/// Nilai version name dari app
final String appVersion;
/// Warna primary dari identitas app Anda.
final Color colorPrimary;
/// Warna secondary dari identitas app Anda.
final Color colorSecondary;
/// Warna dari widget [AppBar]. Nilai default-nya [Colors.blue]
final Color colorAppBar;
/// Warna dari tulisan didalam widget [AppBar]. Nilai default-nya adalah [Colors.grey.shade700]
final Color? colorTitleAppBar;
/// Function yang dijalankan ketika respon kode dari API 401.
final Function()? onDialog401Showing;
/// Bahasa yang dipakai di halaman ini. Untuk saat ini support `en` dan `id`.
final String locale;
FlutterFeedbackPluginPage({
required this.fileScreenshot,
required this.onSubmitFeedback,
required this.email,
required this.appVersion,
this.colorPrimary = Colors.blue,
this.colorSecondary = Colors.white,
this.colorAppBar = Colors.blue,
this.colorTitleAppBar,
this.onDialog401Showing,
this.locale = 'en',
}) {
_colorPrimary = this.colorPrimary;
_onDialog401Showing = this.onDialog401Showing;
}
@override
_FlutterFeedbackPluginPageState createState() => _FlutterFeedbackPluginPageState();
}
class _FlutterFeedbackPluginPageState extends State<FlutterFeedbackPluginPage> {
final formState = GlobalKey<FormState>();
final controllerFeedback = TextEditingController();
final listAttachments = <String>[];
var indexSelectedCategory = -1;
var selectedCategory = '';
var paddingBottom = 0.0;
var paddingTop = 0.0;
var heightScreen = 0.0;
var platform = '';
var osVersion = '';
var brand = '';
var isCheckEmail = true;
var isCheckAppVersion = true;
var isCheckPlatform = true;
var isCheckOsVersion = true;
var isCheckBrand = true;
@override
void initState() {
listAttachments.add(widget.fileScreenshot.path);
listAttachments.add('');
_initLocale();
WidgetsBinding.instance?.addPostFrameCallback((_) async {
final deviceInfoPlugin = DeviceInfoPlugin();
if (Platform.isAndroid) {
final androidInfo = await deviceInfoPlugin.androidInfo;
platform = 'Android';
osVersion = androidInfo.version.sdkInt.toString();
brand = (androidInfo.brand ?? '') + ' ' + (androidInfo.model ?? '');
if (brand.trim().isEmpty) {
brand = '-';
}
} else if (Platform.isIOS) {
final iosInfo = await deviceInfoPlugin.iosInfo;
platform = 'IOS';
osVersion = iosInfo.systemVersion ?? '-';
brand = (iosInfo.model ?? '-') + ' (' + (iosInfo.name ?? '-') + ')';
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
final mediaQueryData = MediaQuery.of(context);
paddingBottom = mediaQueryData.padding.bottom;
paddingTop = mediaQueryData.padding.top;
heightScreen = mediaQueryData.size.height;
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
_locale.feedback(),
style: TextStyle(
color: widget.colorTitleAppBar ?? Colors.grey[700],
),
),
backgroundColor: widget.colorAppBar,
iconTheme: IconThemeData(color: widget.colorTitleAppBar ?? Colors.grey[700]),
),
body: Stack(
children: [
_buildWidgetForm(),
_buildWidgetLoading(),
],
),
);
}
Widget _buildWidgetForm() {
return Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(
16,
16,
16,
paddingBottom > 0 ? paddingBottom : 16,
),
child: Column(
children: [
Expanded(
child: ListView(
padding: EdgeInsets.zero,
children: [
Text(
_locale.weWouldLikeYourFeedback(),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
Text(
_locale.whatIsYourOpinionOfThisPage(),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
width: double.infinity,
height: 128,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: listAttachments.length,
itemBuilder: (context, index) {
final pathImage = listAttachments[index];
return pathImage.isEmpty
? Padding(
padding: const EdgeInsets.all(8),
child: GestureDetector(
onTap: () async {
final pickedImageGallery = await ImagePicker().pickImage(
source: ImageSource.gallery,
imageQuality: 30,
);
if (pickedImageGallery != null) {
listAttachments.removeLast();
listAttachments.add(pickedImageGallery.path);
listAttachments.add('');
if (listAttachments.length > 3) {
listAttachments.removeLast();
}
setState(() {});
}
},
child: Center(
child: DottedBorder(
color: Colors.grey,
child: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
),
child: Center(
child: Icon(
Icons.add,
color: Colors.grey,
size: 24,
),
),
),
),
),
),
)
: Stack(
children: [
Padding(
padding: const EdgeInsets.all(8),
child: GestureDetector(
onTap: () {
_doTapImage(index, pathImage);
},
child: Container(
height: 128,
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
),
borderRadius: BorderRadius.circular(8),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.file(
File(pathImage),
),
),
),
),
),
Positioned(
top: 2,
right: 2,
child: GestureDetector(
onTap: () async {
_doTapImage(index, pathImage);
},
child: Container(
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
),
),
padding: const EdgeInsets.all(4),
child: Icon(
Icons.edit,
color: Colors.white,
size: 10,
),
),
),
),
],
);
},
),
),
SizedBox(height: 8),
InkWell(
onTap: () async {
var editDeviceLogs = await showModalBottomSheet<DeviceLogs>(
context: context,
enableDrag: false,
isDismissible: false,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
builder: (context) {
return WidgetEditDeviceLogs(
locale: _locale,
paddingBottom: paddingBottom,
deviceLogs: DeviceLogs(
email: widget.email,
isCheckEmail: isCheckEmail,
appVersion: widget.appVersion,
isCheckAppVersion: isCheckAppVersion,
platform: platform,
isCheckPlatform: isCheckPlatform,
osVersion: osVersion,
isCheckOsVersion: isCheckOsVersion,
brand: brand,
isCheckBrand: isCheckBrand,
),
colorPrimary: widget.colorPrimary,
);
});
if (editDeviceLogs != null) {
setState(() {
isCheckEmail = editDeviceLogs.isCheckEmail;
isCheckAppVersion = editDeviceLogs.isCheckAppVersion;
isCheckPlatform = editDeviceLogs.isCheckPlatform;
isCheckOsVersion = editDeviceLogs.isCheckOsVersion;
isCheckBrand = editDeviceLogs.isCheckBrand;
});
}
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
),
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
width: double.infinity,
padding: const EdgeInsets.all(8),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
_locale.deviceLogs(),
style: Theme.of(context).textTheme.subtitle2,
),
Text(
_setDataDeviceLogs(),
style: Theme.of(context).textTheme.bodyText2?.copyWith(
color: Colors.grey,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
Text(
_locale.edit(),
style: Theme.of(context).textTheme.bodyText2?.copyWith(
color: widget.colorPrimary,
),
),
],
),
),
Icon(
FontAwesomeIcons.fileAlt,
color: Colors.grey[700],
),
],
),
),
),
SizedBox(height: 16),
Text(
_locale.pleaseSelectYourFeedbackCategoryBelow(),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
Wrap(
alignment: WrapAlignment.center,
spacing: 8,
runSpacing: 8,
children: [
_buildWidgetChoiceChip(_locale.suggestion()),
_buildWidgetChoiceChip(_locale.appreciation()),
_buildWidgetChoiceChip(_locale.complain()),
],
),
SizedBox(height: 8),
Text(
_locale.pleaseLeaveYourFeedback(),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
Form(
key: formState,
child: TextFormField(
controller: controllerFeedback,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
hintText: _locale.typeMessageHere(),
isDense: true,
),
maxLines: 3,
keyboardType: TextInputType.text,
validator: (value) {
return value == null || value.isEmpty ? _locale.enterYourFeedback() : null;
},
),
),
],
),
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
if (listAttachments.length == 1 && listAttachments.first.isEmpty) {
_showSnackBar(context, _locale.pleaseUploadScreenshot());
return;
} else if (selectedCategory.isEmpty) {
_showSnackBar(context, _locale.pleaseSelectFeedbackCategory());
return;
} else if (formState.currentState!.validate()) {
widget.onSubmitFeedback.call(
listAttachments,
selectedCategory,
controllerFeedback.text.trim(),
DeviceLogs(
email: widget.email,
isCheckEmail: isCheckEmail,
appVersion: widget.appVersion,
isCheckAppVersion: isCheckAppVersion,
platform: platform,
isCheckPlatform: isCheckPlatform,
osVersion: osVersion,
isCheckOsVersion: isCheckOsVersion,
brand: brand,
isCheckBrand: isCheckBrand,
),
);
}
},
style: ElevatedButton.styleFrom(
primary: widget.colorPrimary,
onPrimary: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(4),
),
),
),
child: Text(
_locale.send().toUpperCase(),
style: TextStyle(
color: Colors.white,
),
),
),
),
],
),
);
}
String _setDataDeviceLogs() {
final listDeviceLogs = <String>[];
var strDeviceLogs = '';
if (isCheckEmail) {
listDeviceLogs.add(_locale.email());
}
if (isCheckAppVersion) {
listDeviceLogs.add(_locale.appVersion());
}
if (isCheckPlatform) {
listDeviceLogs.add(_locale.platform());
}
if (isCheckOsVersion) {
listDeviceLogs.add(_locale.osVersion());
}
if (isCheckBrand) {
listDeviceLogs.add(_locale.brand());
}
if (listDeviceLogs.isEmpty) {
strDeviceLogs = _locale.noLogData();
return strDeviceLogs;
} else if (listDeviceLogs.length == 1) {
strDeviceLogs = listDeviceLogs.first;
return strDeviceLogs;
} else if (listDeviceLogs.length == 2) {
strDeviceLogs = listDeviceLogs.join(' ' + _locale.and() + ' ');
return strDeviceLogs;
}
listDeviceLogs.insert(listDeviceLogs.length - 1, _locale.and());
strDeviceLogs = listDeviceLogs.join(', ').replaceAll(_locale.and() + ',', _locale.and());
return strDeviceLogs;
}
void _doTapImage(int index, String pathImage) async {
var actionAttachment;
if (Platform.isIOS) {
actionAttachment = await showCupertinoModalPopup<String>(
context: context,
builder: (context) {
return CupertinoActionSheet(
actions: [
CupertinoActionSheetAction(
child: Text(
_locale.viewScreenshot(),
style: TextStyle(color: Colors.blue),
),
onPressed: () => Navigator.pop(context, 'view'),
),
CupertinoActionSheetAction(
child: Text(
_locale.editScreenshot(),
style: TextStyle(color: Colors.blue),
),
onPressed: () => Navigator.pop(context, 'edit'),
),
CupertinoActionSheetAction(
child: Text(
_locale.deleteScreenshot(),
style: TextStyle(color: Colors.red),
),
isDestructiveAction: true,
onPressed: () => Navigator.pop(context, 'delete'),
),
],
);
});
} else {
actionAttachment = await showModalBottomSheet<String>(
context: context,
enableDrag: false,
builder: (context) {
return _buildWidgetMenuActionAttachment(pathImage);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
);
}
if (actionAttachment != null) {
if (actionAttachment == 'edit') {
_doEditImage(index);
} else if (actionAttachment == 'delete') {
listAttachments.removeAt(index);
if (listAttachments.last.isNotEmpty) {
listAttachments.add('');
}
setState(() {});
} else if (actionAttachment == 'view') {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FlutterFeedbackPreviewImagePage(pathImage),
),
);
}
}
}
Widget _buildWidgetLoading() {
return ValueListenableBuilder(
valueListenable: _valueListenableLoading,
builder: (BuildContext context, bool isLoading, Widget? child) {
if (isLoading) {
return Container(
width: double.infinity,
height: double.infinity,
color: Colors.black.withOpacity(0.5),
child: Center(
child: Platform.isIOS
? Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
CupertinoActivityIndicator(),
SizedBox(height: 8),
Text(
_locale.loading(),
textAlign: TextAlign.center,
),
],
),
)
: CircularProgressIndicator(),
),
);
} else {
return Container();
}
},
);
}
Widget _buildWidgetMenuActionAttachment(String pathImage) {
return Padding(
padding: EdgeInsets.only(
top: 8,
bottom: paddingBottom > 0 ? paddingBottom : 8,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 24,
height: 2,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(999),
),
),
SizedBox(height: 8),
Text(
_locale.screenshots(),
style: Theme.of(context).textTheme.subtitle2,
),
ListTile(
leading: Icon(
Icons.photo,
color: Colors.grey[700],
),
title: Text(_locale.viewScreenshot()),
onTap: () {
Navigator.pop(context, 'view');
},
),
ListTile(
leading: Icon(
Icons.brush,
color: Colors.grey[700],
),
title: Text(_locale.editScreenshot()),
onTap: () {
Navigator.pop(context, 'edit');
},
),
ListTile(
leading: Icon(
Icons.delete,
color: Colors.grey[700],
),
title: Text(_locale.deleteScreenshot()),
onTap: () {
Navigator.pop(context, 'delete');
},
),
],
),
);
}
Widget _buildWidgetChoiceChip(String label) {
final isSelected = label == selectedCategory;
return ChoiceChip(
label: Text(label),
labelStyle: Theme.of(context).textTheme.bodyText2?.copyWith(
color: isSelected ? widget.colorPrimary : Colors.grey,
),
selected: isSelected,
onSelected: (_) => setState(() => selectedCategory = label),
backgroundColor: Colors.white,
selectedColor: Colors.white,
shape: StadiumBorder(
side: BorderSide(
color: isSelected ? widget.colorPrimary : Colors.grey,
),
),
);
}
void _doEditImage(int index) async {
final resultEditImage = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CoderJavaImageEditorPro(
appBarColor: Colors.black87,
bottomBarColor: Colors.black87,
defaultPathImage: listAttachments[index],
isShowingChooseImage: false,
isShowingFlip: false,
isShowingRotate: false,
isShowingBlur: false,
isShowingFilter: false,
isShowingEmoji: false,
),
),
) as File?;
if (resultEditImage != null) {
setState(() => listAttachments[index] = resultEditImage.path);
}
}
void _initLocale() {
if (widget.locale.toLowerCase() == 'en') {
_locale = EnMessage();
} else if (widget.locale.toLowerCase() == 'id') {
_locale = IdMessage();
} else {
_locale = EnMessage();
}
}
}
void _showDialog401(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return WidgetDialog(
title: _locale.info(),
content: _locale.refreshTokenExpired(),
actionsAlertDialog: <Widget>[
TextButton(
child: Text(
_locale.login().toUpperCase(),
style: Theme.of(context).textTheme.button?.copyWith(color: _colorPrimary),
),
onPressed: () async {
if (_onDialog401Showing != null) {
_onDialog401Showing?.call();
}
},
),
],
actionsCupertinoDialog: <Widget>[
CupertinoDialogAction(
child: Text(
_locale.login(),
),
isDefaultAction: true,
onPressed: () async {
if (_onDialog401Showing != null) {
_onDialog401Showing?.call();
}
},
),
],
);
},
);
}
void _showSnackBar(BuildContext context, String text) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(text),
),
);
}
void _showDialogSuccess(BuildContext context) async {
final result = await showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return WidgetDialog(
title: _locale.info(),
content: _locale.thankYouForTheFeedback(),
actionsAlertDialog: [
TextButton(
child: Text(_locale.ok().toUpperCase()),
onPressed: () => Navigator.pop(context, true),
),
],
actionsCupertinoDialog: [
CupertinoDialogAction(
child: Text(_locale.ok()),
onPressed: () => Navigator.pop(context, true),
),
],
);
});
if (result != null) {
Navigator.pop(context);
}
}
| 35.417661 | 97 | 0.461253 |
456ff497e49a3514afa7ca15d4a75fa810fbcd78 | 738 | sql | SQL | sql/dim_sneakers/extract.sql | gagejustins/snql-airflow | 4b59c9da6fcd5ab8b926d4777c60138c8700edc5 | [
"Apache-2.0"
] | null | null | null | sql/dim_sneakers/extract.sql | gagejustins/snql-airflow | 4b59c9da6fcd5ab8b926d4777c60138c8700edc5 | [
"Apache-2.0"
] | 1 | 2019-10-10T16:41:43.000Z | 2019-10-10T16:41:43.000Z | sql/dim_sneakers/extract.sql | gagejustins/snql-airflow | 4b59c9da6fcd5ab8b926d4777c60138c8700edc5 | [
"Apache-2.0"
] | null | null | null | with events as (
select
sneaker_id,
sum(case when event_type = 'wear' then 1 else 0 end) as count_wears,
sum(case when event_type = 'clean' then 1 else 0 end) as count_cleans,
sum(case when event_type = 'walk' then 1 else 0 end) as count_walks
from sneaker_events
group by 1
)
select
s.id as sneaker_id,
s.sneaker_name,
s.color,
s.created_at,
case when coalesce(s.sold_at, s.trashed_at, s.given_at) is null then TRUE else FALSE end as is_owned,
s.sold_at,
s.trashed_at,
s.given_at,
m.manufacturer_name,
m.collaborator_name,
e.count_wears,
e.count_cleans,
e.count_walks,
DATE('{{ ds }}') as updated_at
from sneakers s
left join manufacturers m on s.manufacturer_id = m.id
left join events e on s.id = e.sneaker_id | 27.333333 | 102 | 0.739837 |
88355dc0c5df2d72434488289a7829c0fd1b4f9b | 49,752 | cpp | C++ | system/mp/test/mptest.cpp | lucasmauro/HPCC-Platform | 6df37c79a97bfb02f068c44d2635ffffc5b090c0 | [
"Apache-2.0"
] | null | null | null | system/mp/test/mptest.cpp | lucasmauro/HPCC-Platform | 6df37c79a97bfb02f068c44d2635ffffc5b090c0 | [
"Apache-2.0"
] | null | null | null | system/mp/test/mptest.cpp | lucasmauro/HPCC-Platform | 6df37c79a97bfb02f068c44d2635ffffc5b090c0 | [
"Apache-2.0"
] | 1 | 2019-10-26T22:05:26.000Z | 2019-10-26T22:05:26.000Z |
// CSocketSelectThread error 10038
#include <platform.h>
#include <jlib.hpp>
#include <jthread.hpp>
#include <jmisc.hpp>
#include <jcrc.hpp>
#include <mpbase.hpp>
#include <mpcomm.hpp>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define MPPORT 8888
//#define GPF
#define TEST_AlltoAll "AlltoAll"
#define TEST_STREAM "Stream"
#define TEST_MULTI "Multi"
#define TEST_RING "Ring"
#define TEST_RANK "PrintRank"
#define TEST_SELFSEND "SelfSend"
#define TEST_SINGLE_SEND "SingleSend"
#define TEST_RIGHT_SHIFT "RightShift"
#define TEST_RECV_FROM_ANY "RecvFromAny"
#define TEST_SEND_TO_ALL "SendToAll"
#define TEST_MULTI_MT "MTMultiSendRecv"
#define TEST_NXN "NxN"
// #define aWhile 100000
#define aWhile 10
class CSectionTimer
{
HiresTimer hrt[1000];
unsigned tids[1000];
const char *name;
static CriticalSection findsect;
double total;
double max;
unsigned count;
unsigned idx()
{
CriticalBlock block(findsect);
unsigned tid = (unsigned)(memsize_t)GetCurrentThreadId();
unsigned i;
for (i=0;i<999;i++)
{
if (tids[i]==tid)
break;
if (tids[i]==0)
{
tids[i] = tid;
break;
}
}
return i;
}
public:
CSectionTimer(const char *_name)
{
name = (const char *)strdup(_name);
total = 0;
max = 0;
memset(tids,0,sizeof(tids));
count = 0;
}
~CSectionTimer()
{
free((void *)name);
}
void begin()
{
hrt[idx()].reset();
}
void end()
{
double v = hrt[idx()].get();
total += v;
if (max<v)
max = v;
count++;
}
void print()
{
if (count)
PROGLOG("TIME: %s(%u): max=%.6f, avg=%.6f, tot=%.6f",name,count,max,(double)total/count,total);
}
};
CriticalSection CSectionTimer::findsect;
class TimedBlock
{
CSectionTimer &stim;
public:
TimedBlock(CSectionTimer &_stim) : stim(_stim) { stim.begin(); }
~TimedBlock() { stim.end(); }
};
class TimedCriticalBlock
{
CriticalSection &crit;
public:
TimedCriticalBlock(CriticalSection &c,CSectionTimer &stim)
: crit(c)
{
TimedBlock block(stim); crit.enter();
}
~TimedCriticalBlock() { crit.leave(); }
};
static CSectionTimer STsend("send");
static CSectionTimer STrecv("recv");
//#define NITER 100
#define NITER 40
#define BLOCKSIZE (0x100000*10)
//#define BLOCKSIZE (0x1000*10)
#define WRITEDELAY 100
#define READDELAY 5000
void StreamTest(IGroup *group,ICommunicator *comm)
{
CMessageBuffer mb;
for (unsigned i=0;i<NITER;i++)
{
if (group->rank() == 1)
{
mb.clear();
StringBuffer header;
header.append("Test Block #").append(i);
mb.append(header.str()).reserve(BLOCKSIZE-mb.length());
PROGLOG("MPTEST: StreamTest sending '%s' length %u",header.str(),mb.length());
{
TimedBlock block(STsend);
comm->send(mb,0,MPTAG_TEST,MP_ASYNC_SEND);
}
PROGLOG("MPTEST: StreamTest sent");
//Sleep(WRITEDELAY);
}
else if (group->rank() == 0)
{
rank_t r;
comm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
StringAttr str;
PROGLOG("MPTEST: StreamTest receiving");
{
TimedBlock block(STrecv);
mb.read(str);
}
PROGLOG("MPTEST: StreamTest received(%u) '%s' length %u",r,str.get(),mb.length());
}
else
{
PROGLOG("MPTEST: StreamTest skipping extra rank %u", group->rank());
break;
}
}
comm->barrier();
STsend.print();
STrecv.print();
}
void Test1(IGroup *group,ICommunicator *comm)
{
PROGLOG("test1");
CMessageBuffer mb;
if (group->rank()==0)
{
mb.append("Hello - Test1");
comm->send(mb,1,MPTAG_TEST);
}
else if (group->rank()==1)
{
rank_t r;
comm->recv(mb,0,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("(1) Received '%s' from rank %u",str.get(),r);
}
comm->barrier();
}
void Test2(IGroup *group,ICommunicator *comm)
{
PROGLOG("test2");
CMessageBuffer mb;
if (group->rank()==0)
{
mb.append("Hello - Test2");
comm->send(mb,RANK_ALL,MPTAG_TEST);
}
else if (group->rank()==1)
{
#ifdef GPF
PROGLOG("GPFING");
Sleep(aWhile);
byte *p = NULL; *p = 1;
#endif
rank_t r;
comm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("(2) Received '%s' from rank %u",str.get(),r);
}
comm->barrier();
}
void Test3(IGroup *group,ICommunicator *comm)
{
PROGLOG("test3");
CMessageBuffer mb;
if (group->rank()==0)
{
mb.append("Hello - Test3");
comm->send(mb,1,MPTAG_TEST);
}
else if (group->rank()==1)
{
rank_t r;
comm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("(3) Received '%s' from rank %u",str.get(),r);
}
comm->barrier();
}
void Test4(IGroup *group,ICommunicator *comm)
{
PROGLOG("test4");
CMessageBuffer mb;
if (group->rank()==0)
{
INode *singlenode=&group->queryNode(1);
IGroup *singlegroup = createIGroup(1,&singlenode);
ICommunicator * singlecomm = createCommunicator(singlegroup);
mb.append("Hello - Test4");
singlecomm->send(mb,0,MPTAG_TEST);
singlecomm->Release();
singlegroup->Release();
}
else if (group->rank()==1)
{
rank_t r;
comm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("(4) Received '%s' from rank %u",str.get(),r);
}
comm->barrier();
}
void Test5(IGroup *group,ICommunicator *comm)
{
PROGLOG("test5");
rank_t rank = group->rank();
INode *singlenode=&group->queryNode(1);
IGroup *singlegroup = createIGroup(1,&singlenode);
ICommunicator * singlecomm = createCommunicator(singlegroup);
CMessageBuffer mb;
if (rank==0) {
mb.append("Hello - Test5");
singlecomm->send(mb,0,MPTAG_TEST);
}
else if (rank==1)
{
rank_t r;
singlecomm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("(5) Received '%s' from rank %u (unknown)",str.get(),r);
}
comm->barrier();
singlecomm->Release();
singlegroup->Release();
}
void Test6(IGroup *group,ICommunicator *comm)
{
PROGLOG("test6");
//DebugBreak();
CMessageBuffer mb;
StringAttr str;
if (group->rank()==1)
{
mb.append("Test");
bool cancelled = comm->sendRecv(mb,0,MPTAG_TEST);
StringAttr str;
mb.read(str);
StringBuffer url;
PROGLOG("(6) Received '%s' from %s",str.get(),mb.getSender().getUrlStr(url).str());
}
else if (group->rank()==0)
{
rank_t r;
comm->recv(mb,RANK_ALL,MPTAG_TEST,&r);
mb.read(str);
PROGLOG("(6) - str = <%s>", str.get());
assertex(strcmp(str.get(),"Test")==0);
mb.clear();
mb.append("Hello - Test6");
printf("crash now!");
Sleep(1);
comm->reply(mb);
}
comm->barrier();
}
void Test7(IGroup *group,ICommunicator *comm)
{
PROGLOG("test7");
CMessageBuffer mb;
if (group->rank()==0)
{
mb.append("Hello - Test7");
mb.reserve(150*1024);
comm->send(mb,1,MPTAG_TEST);
}
else if (group->rank()==1)
{
rank_t r;
comm->recv(mb,(mptag_t) TAG_ALL,MPTAG_TEST,&r);
StringAttr str;
mb.read(str);
PROGLOG("Received '%s' from rank %u",str.get(),r);
}
comm->barrier();
}
// #define MAXBUFFERSIZE 0x100000
#define MAXBUFFERSIZE 0x10000
struct CRandomBuffer
{
size32_t size;
char buffer[MAXBUFFERSIZE];
unsigned crc;
void fill()
{
size = getRandom()%MAXBUFFERSIZE;
// size = 100000;
if (size)
{
char c = (char)getRandom();
#if 0
for (unsigned i=0;i<size;i++)
{
buffer[i] = c;
c += (c*16);
c += 113;
}
#endif
for (unsigned i=0;i<size;i++)
{
buffer[i] = 'a' + i%26;
}
}
crc = crc32(&buffer[0],size,0);
}
bool check()
{
int errs = 50;
if (crc!=crc32(buffer,size,0))
{
PROGLOG("**** Error: CRC check failed");
PROGLOG("size = %u",size);
char c = buffer[0];
for (unsigned i=1;i<size;i++)
{
c += (c*16);
c += 113;
if (buffer[i] != c)
{
PROGLOG("Failed at %u, expected %02x found %02x %02x %02x %02x %02x %02x %02x %02x",i,(int)(byte)c,(int)(byte)buffer[i],(int)(byte)buffer[i+1],(int)(byte)buffer[i+2],(int)(byte)buffer[i+3],(int)(byte)buffer[i+4],(int)(byte)buffer[i+5],(int)(byte)buffer[i+6],(int)(byte)buffer[i+7]);
if (errs--==0)
break;
}
}
return false;
}
return true;
}
void serialize(MemoryBuffer &mb)
{
// PROGLOG("1serialize: size = %u, length = %u", size, mb.length());
mb.append(size).append(size,buffer).append(crc);
// PROGLOG("2serialize: size = %u, length = %u", size, mb.length());
}
void deserialize(MemoryBuffer &mb)
{
// PROGLOG("1de-serialize: size = %u, length = %u", size, mb.length());
mb.read(size);
// PROGLOG("2de-serialize: size = %u, length = %u", size, mb.length());
mb.read(size,buffer).read(crc);
}
};
void printtrc(char c)
{
static CriticalSection crit;
CriticalBlock block(crit);
printf("%c",c);
}
// #define N 100
#define N 20
void MultiTest(ICommunicator *_comm)
{
class Server: public Thread
{
public:
Owned<ICommunicator> comm;
Server(ICommunicator *_comm) { comm.set(_comm); }
int run()
{
unsigned n=(comm->queryGroup().ordinality()-1)*N;
CMessageBuffer mb;
CRandomBuffer *buff = new CRandomBuffer();
PROGLOG("MPTEST: MultiTest server started, myrank = %u", comm->queryGroup().rank());
try
{
while(n--)
{
mb.clear();
rank_t rr;
if (!comm->recv(mb,RANK_ALL,MPTAG_TEST,&rr))
break;
PROGLOG("MPTEST: MultiTest server Received from %u, len = %u",rr, mb.length());
StringBuffer str;
comm->queryGroup().queryNode(rr).endpoint().getUrlStr(str);
// PROGLOG("MPTEST: MultiTest server Received from %s",str.str());
buff->deserialize(mb);
#ifdef DO_CRC_CHECK
if (!buff->check())
PROGLOG("MPTEST: MultiTest server Received from %s",str.str());
#endif
mb.clear().append(buff->crc);
int delay = getRandom() % 20;
Sleep(delay);
comm->reply(mb);
}
}
catch (IException *e)
{
pexception("Server Exception",e);
e->Release();
}
comm->barrier();
PROGLOG("MPTEST: MultiTest server stopped");
delete buff;
return 0;
}
} server(_comm);
Owned<ICommunicator> comm;
comm.set(_comm);
server.start();
CMessageBuffer mb;
CRandomBuffer *buff = new CRandomBuffer();
unsigned nr = comm->queryGroup().ordinality();
unsigned n=(nr-1)*N;
rank_t r = comm->queryGroup().rank();
rank_t *targets = new rank_t[n];
rank_t *t = targets;
rank_t i;
for (i=0;i<nr;i++)
if (i!=r)
for (unsigned j=0;j<N;j++)
*(t++) = i;
unsigned k=n;
while (k>1)
{
i = getRandom()%k; // NB n is correct here
k--;
unsigned t = targets[i];
targets[i] = targets[k];
targets[k] = t;
}
PROGLOG("MPTEST: Multitest client started, myrank = %u", comm->queryGroup().rank());
try {
while (n--)
{
buff->fill();
buff->serialize(mb.clear());
#if 0
StringBuffer str;
comm->queryGroup().queryNode(targets[n]).endpoint().getUrlStr(str);
PROGLOG("MPTEST: Multitest client Sending to %s, length=%u",str.str(), mb.length());
#endif
PROGLOG("MPTEST: Multitest client Sending to %u, length=%u", targets[n], mb.length());
if (!comm->sendRecv(mb,targets[n],MPTAG_TEST))
break;
// Sleep((n+1)*2000);
// PROGLOG("MPTEST: Multitest client Sent to %s",str.str());
unsigned crc;
mb.read(crc);
assertex(crc==buff->crc);
}
}
catch (IException *e)
{
pexception("Client Exception",e);
e->Release();
}
PROGLOG("MPTEST: MultiTest client finished");
server.join();
delete [] targets;
delete buff;
}
void MPRing(IGroup *group, ICommunicator *mpicomm, unsigned iters=0)
{
CMessageBuffer smb;
CMessageBuffer rmb;
rank_t myrank = group->rank();
rank_t numranks = group->ordinality();
if (numranks < 2)
throw MakeStringException(-1, "MPTEST: MPRing Error, numranks (%u) must be > 1", numranks);
if (iters == 0)
iters = 1000;
unsigned pintvl = iters/10;
if (pintvl < 1)
pintvl = 1;
PROGLOG("MPTEST: MPRing myrank=%u numranks=%u iters=%u", myrank, numranks, iters);
unsigned next = myrank;
unsigned prev = myrank;
unsigned k = 0;
do
{
next = (next+1) % numranks;
prev = prev > 0 ? prev-1 : numranks-1;
// skip self
if ( (next == prev) && (next == myrank) )
continue;
smb.clear();
smb.append(k);
if ((k%pintvl) == 0)
PROGLOG("MPTEST: MPRing %u send to rank %u", myrank, next);
bool oksend = mpicomm->send(smb, next, MPTAG_TEST);
if (!oksend)
throw MakeStringException(-1, "MPTEST: MPRing %u send() to rank %u failed", myrank, next);
rmb.clear();
if ((k%pintvl) == 0)
PROGLOG("MPTEST: MPRing %u recv from rank %u", myrank, prev);
bool okrecv = mpicomm->recv(rmb, prev, MPTAG_TEST);
if (!okrecv)
throw MakeStringException(-1, "MPTEST: MPRing %u recv() from rank %u failed", myrank, prev);
rmb.read(k);
k++;
if ((k%pintvl) == 0)
PROGLOG("MPTEST: MPRing %u iteration %u complete", myrank, k);
if (k == iters)
break;
}
while (true);
PROGLOG("MPTEST: MPRing complete");
mpicomm->barrier();
}
#define MSGLEN 1048576
void MPAlltoAll(IGroup *group, ICommunicator *mpicomm, size32_t buffsize=0, unsigned iters=0)
{
rank_t myrank = group->rank();
rank_t numranks = group->ordinality();
if (numranks < 2)
throw MakeStringException(-1, "MPAlltoAll: MPRing Error, numranks (%u) must be > 1", numranks);
if (buffsize == 0)
buffsize = MSGLEN;
if (iters == 0)
iters = 1000;
PROGLOG("MPTEST: MPAlltoAll myrank=%u numranks=%u buffsize=%u iters=%u", myrank, numranks, buffsize, iters);
// ---------
class Sender : public Thread
{
public:
Linked<ICommunicator> mpicomm;
rank_t numranks;
rank_t myrank;
size32_t buffsize;
unsigned iters;
Sender(ICommunicator *_mpicomm, rank_t _numranks, rank_t _myrank, size32_t _buffsize, unsigned _iters) : mpicomm(_mpicomm), numranks(_numranks), myrank(_myrank), buffsize(_buffsize), iters(_iters)
{
}
int run()
{
PROGLOG("MPTEST: MPAlltoAll sender started, myrank = %u", myrank);
int pintvl = iters/10;
if (pintvl < 1)
pintvl = 1;
CMessageBuffer smb;
smb.appendBytes('a', buffsize);
for (unsigned k=1;k<=iters;k++)
{
bool oksend = mpicomm->send(smb, RANK_ALL_OTHER, MPTAG_TEST);
if (!oksend)
throw MakeStringException(-1, "MPTEST: MPAlltoAll %u send() failed", myrank);
if ((k%pintvl) == 0)
PROGLOG("MPTEST: MPAlltoAll sender %u iteration %u complete", myrank, k);
}
mpicomm->barrier();
PROGLOG("MPTEST: MPAlltoAll sender stopped");
return 0;
}
} sender(mpicomm, numranks, myrank, buffsize, iters);
unsigned startTime = msTick();
sender.start();
// ---------
PROGLOG("MPTEST: MPAlltoAll receiver started, myrank = %u", myrank);
int pintvl = iters/10;
if (pintvl < 1)
pintvl = 1;
CMessageBuffer rmb(buffsize);
for (unsigned k=1;k<=iters;k++)
{
for (rank_t i=1;i<numranks;i++)
{
// rmb.clear();
bool okrecv = mpicomm->recv(rmb, RANK_ALL, MPTAG_TEST);
if (!okrecv)
throw MakeStringException(-1, "MPTEST: MPAlltoAll %u recv() failed", myrank);
if (i==1 && (k%pintvl) == 0)
PROGLOG("MPTEST: MPAlltoAll receiver rank %u iteration %u complete", myrank, k);
}
}
mpicomm->barrier();
PROGLOG("MPTEST: MPAlltoAll receiver finished");
// ---------
sender.join();
unsigned endTime = msTick();
double msgRateMB = (2.0*(double)buffsize*(double)iters*(double)(numranks-1)) / ((endTime-startTime)*1000.0);
PROGLOG("MPTEST: MPAlltoAll complete %g MB/s", msgRateMB);
return;
}
void MPTest2(IGroup *group, ICommunicator *mpicomm)
{
rank_t myrank = group->rank();
rank_t numranks = group->ordinality();
PROGLOG("MPTEST: MPTest2: myrank=%u numranks=%u", myrank, numranks);
mpicomm->barrier();
return;
}
void testIPnodeHash()
{
setNodeCaching(true);
class casyncfor: public CAsyncFor
{
public:
casyncfor()
{
}
void Do(unsigned i)
{
StringBuffer ips;
ips.appendf("%d.%d.%d.%d",i/256,1,2,getRandom()%10);
SocketEndpoint ep(ips.str());
try {
Owned<INode> node = createINode(ep);
}
catch (IException *e)
{
EXCLOG(e,"failed");
}
}
} afor;
afor.For(100000,10);
}
//-----------Utility classes and global variables---------------//
CriticalSection sendCriticalSec;
CriticalSection recvCriticalSec;
CriticalSection validateCriticalSec;
bool* validate;
int getNextCount(CriticalSection §, int &count)
{
CriticalBlock block(sect);
if (count)
return count--;
else
return 0;
}
//validate that numbers from 1 to maxCounter are received only once
void setValidate(int i, int maxCounter)
{
CriticalBlock block(validateCriticalSec);
assertex(i>0);
assertex(i<=maxCounter);
assertex(validate[i-1] == false);
validate[i-1] = true;
}
//-------------------------------------------------------------//
/**
* Test sending a message to its self
*/
void MPSelfSend(ICommunicator *mpcomm)
{
CMessageBuffer mb;
int sendMessage = 1234;
int receivedMessage;
rank_t myrank = mpcomm->getGroup()->rank();
mb.append(sendMessage);
mpcomm->send(mb, myrank, MPTAG_TEST);
mb.clear();
mpcomm->recv(mb, myrank, MPTAG_TEST);
mb.read(receivedMessage);
assertex(sendMessage == receivedMessage);
PROGLOG("MPTEST: %s: Message sent from %d to %d", TEST_SELFSEND, myrank, myrank);
}
/**
* Test sending message to next (wrap-around) processor
*/
void MPRightShift(ICommunicator* comm)
{
IGroup* group = comm->getGroup();
rank_t p = group->ordinality();
rank_t rank = group->rank();
rank_t source_rank = (rank - 1 + p) % p;
rank_t destination_rank = (rank + 1) % p;
CMessageBuffer sendMsg;
sendMsg.append(rank);
comm->send(sendMsg, destination_rank, MPTAG_TEST);
CMessageBuffer recvMsg;
int received_msg;
comm->recv(recvMsg, source_rank, MPTAG_TEST);
recvMsg.read(received_msg);
assertex(source_rank == received_msg);
PROGLOG("Message received from node %d to node %d.", source_rank, rank);
}
/**
* Test receiving message from an unknown node
*/
void MPReceiveFromAny(ICommunicator* comm)
{
IGroup* group = comm->getGroup();
rank_t nodeRank = group->rank();
rank_t p = group->ordinality();
rank_t rank = group->rank();
rank_t destinationRank = (p-1);
double expectedValue = 1234.0;
PROGLOG("nodeRank=%u", nodeRank);
if (rank == nodeRank)
{
CMessageBuffer sendMsg;
sendMsg.append(expectedValue);
comm->send(sendMsg, destinationRank, MPTAG_TEST);
PROGLOG("Message sent by node %d to node %d.", rank, destinationRank);
}
if (rank == destinationRank)
{
CMessageBuffer recvMsg;
bool success = comm->recv(recvMsg, RANK_ALL, MPTAG_TEST);
assertex(success);
double receivedValue;
recvMsg.read(receivedValue);
PROGLOG("rank=%u, nodeRank=%u", comm->getGroup()->rank(recvMsg.getSender()), nodeRank);
assertex(nodeRank == comm->getGroup()->rank(recvMsg.getSender()));
assertex(expectedValue == receivedValue);
PROGLOG("Message successfully received from node %d to node %d.", comm->getGroup()->rank(recvMsg.getSender()), rank);
}
}
/**
* Test one node sending a message to all nodes
*/
void MPSendToAll(ICommunicator* comm)
{
IGroup* group = comm->getGroup();
rank_t nodeRank = group->rank();
rank_t p = group->ordinality();
rank_t rank = group->rank();
double expectedValue = 1234.0;
double receivedValue;
if (rank == nodeRank)
{
CMessageBuffer sendMsg;
sendMsg.append(expectedValue);
comm->send(sendMsg, RANK_ALL, MPTAG_TEST);
}
CMessageBuffer recvMsg;
comm->recv(recvMsg, nodeRank, MPTAG_TEST, NULL);
recvMsg.read(receivedValue);
assertex(expectedValue == receivedValue);
PROGLOG("Message received from node %d to node %d.", nodeRank, rank);
}
/**
* Test multiple threads calling send and recv functions
*/
void MPMultiMTSendRecv(ICommunicator* comm, int counter)
{
assertex(comm->getGroup()->ordinality()>1);
counter = (counter? counter: 100);
int SEND_THREADS, RECV_THREADS;
SEND_THREADS = RECV_THREADS = 8;
rank_t rank = comm->getGroup()->rank();
// nodes ranked 0 and 1 will be conducting this test
if (rank<2)
{
validate = new bool[counter];
for(int i=0; i<counter; i++) validate[i] = false;
class SWorker: public Thread
{
private:
ICommunicator* comm;
int* counter;
public:
SWorker(ICommunicator* _comm, int* _counter):comm(_comm), counter(_counter){}
int run()
{
IGroup *group = comm->getGroup();
rank_t p = group->ordinality();
rank_t rank = group->rank();
rank_t destination_rank = 1 - rank;
CMessageBuffer sendMsg;
int served = 0;
while(true)
{
sendMsg.clear();
int v = getNextCount(sendCriticalSec, *counter);
if (v > 0)
{
sendMsg.append(v);
comm->send(sendMsg, destination_rank, MPTAG_TEST);
served++;
}
else
{
break;
}
}
PROGLOG("This thread sent %d", served);
return 0;
}
};
class RWorker: public Thread
{
private:
ICommunicator* comm;
int* counter;
int maxCounter;
public:
RWorker(ICommunicator* _comm, int* _counter):comm(_comm), counter(_counter), maxCounter(*_counter){}
int run()
{
IGroup *group = comm->getGroup();
rank_t p = group->ordinality();
rank_t rank = group->rank();
rank_t source_rank = 1 - rank;
int served = 0;
CMessageBuffer recvMsg;
int received_msg;
while (*counter)
{
recvMsg.clear();
if (comm->recv(recvMsg, source_rank, MPTAG_TEST, NULL, 100))
{
recvMsg.read(received_msg);
setValidate(received_msg, maxCounter);
getNextCount(recvCriticalSec, *counter);
served++;
}
}
PROGLOG("This thread received %d", served);
return 0;
}
};
std::vector<Thread*> workers;
int s_counter, r_counter;
s_counter = r_counter = counter;
PROGLOG("counter=%d", counter);
for(int i=0;i<SEND_THREADS; i++)
{
workers.push_back(new SWorker(comm, &s_counter));
}
for(int i=0;i<RECV_THREADS; i++)
{
workers.push_back(new RWorker(comm, &r_counter));
}
for(int i=0;i<workers.size(); i++)
{
workers[i]->start();
}
for(int i=0;i<workers.size(); i++)
{
workers[i]->join();
}
for(int i=0;i<workers.size(); i++)
{
delete workers[i];
}
assertex(s_counter == 0);
assertex(r_counter == 0);
PROGLOG("Rank %d sent %d messages", rank, (counter-s_counter));
PROGLOG("Rank %d received %d messages", rank, (counter-r_counter));
delete [] validate;
}
comm->barrier();
}
void MPNxN(ICommunicator *comm, unsigned numStreams, size32_t perStreamMBSize, size32_t msgSize, bool async)
{
// defaults
if (0 == numStreams)
numStreams = 8;
if (0 == perStreamMBSize)
perStreamMBSize = 100;
if (0 == msgSize)
msgSize = 1024*1024;
unsigned grpSize = comm->queryGroup().ordinality();
rank_t myRank = comm->queryGroup().rank();
PROGLOG("MPNxN: myrank=%u, numStreams=%u, perStreamMBSize=%u, msgSize(bytes)=%u", myRank=(unsigned)myRank, numStreams, perStreamMBSize, msgSize);
class CSendStream : public CInterfaceOf<IInterface>, implements IThreaded
{
CThreaded threaded;
ICommunicator *comm = nullptr;
rank_t myRank;
unsigned grpSize;
mptag_t mpTag, replyTag;
unsigned __int64 totalSendSize;
size32_t msgSize;
StringBuffer resultMsg;
bool passed = false;
std::vector<rank_t> tgtRanks;
StringBuffer tgtRanksStr;
bool async = false;
// used if async
class CAckThread : implements IThreaded
{
CThreaded threaded;
CSendStream &owner;
mptag_t mpTag;
CriticalSection cs;
Owned<IException> exception;
std::vector<std::queue<unsigned>> expectedHashes;
unsigned getNextExpectedHash(unsigned sender)
{
std::queue<unsigned> &queue = expectedHashes[sender];
CriticalBlock b(cs);
assertex(queue.size());
unsigned hash = queue.front();
expectedHashes[sender].pop();
return hash;
}
public:
CAckThread(CSendStream &_owner, mptag_t _mpTag) : owner(_owner), mpTag(_mpTag), threaded("CAckThread", this)
{
expectedHashes.resize(owner.grpSize);
}
void addHash(unsigned tgt, unsigned hash)
{
CriticalBlock b(cs);
expectedHashes[tgt].push(hash);
}
void start() { threaded.start(); }
void join()
{
threaded.join();
if (exception)
throw exception.getClear();
}
// IThredaed
virtual void threadmain() override
{
try
{
CMessageBuffer msg;
rank_t sender;
unsigned finalAcks = 0;
while (true)
{
unsigned receivedHash;
if (!owner.receiveAck(msg, sender, receivedHash)) // empty message indicates end by client
{
finalAcks++;
if (finalAcks == owner.grpSize)
break; // all done
}
else
{
unsigned expectedHash = getNextExpectedHash(sender);
owner.verifyAck(receivedHash, expectedHash);
}
}
}
catch (IException *e)
{
exception.setown(e);
}
}
} ackThread;
unsigned fillData(void *data, size32_t sz, unsigned hash)
{
byte *pData = (byte *)data;
do
{
if (sz<sizeof(hash))
{
memset(pData, 0, sz);
break;
}
hash = hashc((unsigned char *)&hash, sizeof(hash), hash);
memcpy(pData, &hash, sizeof(hash));
sz -= sizeof(hash);
pData += sizeof(hash);
}
while (true);
return hash;
}
bool receiveAck(CMessageBuffer &msg, rank_t &sender, unsigned &ack)
{
while (!comm->recv(msg, RANK_ALL, replyTag, &sender, 60000))
WARNLOG("Waiting for receive ack");
if (0 == msg.length())
return false; // final empty message indicated complete
if (std::find(tgtRanks.begin(), tgtRanks.end(), sender) == tgtRanks.end())
throwStringExceptionV(0, "Received reply from rank(%u) this stream did not send to", (unsigned)sender);
msg.read(ack);
msg.clear();
return true;
}
void verifyAck(unsigned receivedHash, unsigned expectedHash)
{
if (receivedHash != expectedHash)
throwStringExceptionV(0, "Checksums mismatch: %u sent vs %u received", expectedHash, receivedHash);
}
public:
CSendStream(ICommunicator *_comm, rank_t _myRank, unsigned _grpSize, mptag_t _mpTag, unsigned __int64 _totalSendSize, size32_t _msgSize, bool _async)
: threaded("CSendStream", this), comm(_comm), myRank(_myRank), grpSize(_grpSize), mpTag(_mpTag), totalSendSize(_totalSendSize), msgSize(_msgSize), ackThread(*this, _mpTag), async(_async)
{
if (1 == grpSize) // group only contains self, so target self
tgtRanks.push_back(0);
else
{
unsigned pc=25; // %
// add 'pc'% targets, starting from myRank+1
unsigned num = grpSize*pc/100;
if (0 == num)
num = 1;
unsigned step = grpSize / num;
unsigned t = myRank+1;
if (t == grpSize)
t = 0;
while (true)
{
tgtRanks.push_back(t);
--num;
if (0 == num)
break;
t += step;
if (t >= grpSize)
t -= grpSize;
}
}
auto iter = tgtRanks.begin();
while (true)
{
tgtRanksStr.append(*iter);
iter++;
if (iter == tgtRanks.end())
break;
tgtRanksStr.append(",");
}
replyTag = createReplyTag();
if (async)
ackThread.start();
threaded.start();
}
~CSendStream()
{
threaded.join();
}
bool waitResult(StringBuffer &resultMessage)
{
threaded.join();
return passed;
}
const char *queryTgtRanks() { return tgtRanksStr; }
virtual void threadmain() override
{
passed = false;
try
{
CMessageBuffer msg, recvMsg;
msg.setReplyTag(replyTag);
void *data = msg.reserveTruncate(msgSize);
unsigned hash = (unsigned)mpTag;
VStringBuffer logMsg("NxN: mpTag=%u, dstRank(s) [%s]", (unsigned)mpTag, tgtRanksStr.str());
PROGLOG("%s", logMsg.str());
unsigned __int64 remaining = totalSendSize;
CCycleTimer timer;
while (true)
{
size32_t sz;
if (remaining >= msgSize)
{
sz = msgSize;
remaining -= msgSize;
}
else
{
sz = remaining;
msg.setLength(sz);
remaining = 0;
}
hash = fillData(data, sz, hash);
for (rank_t t: tgtRanks)
{
if (async)
ackThread.addHash(t, hash);
if (!comm->send(msg, t, mpTag))
throwUnexpected();
}
if (!async)
{
rank_t sender;
for (int t: tgtRanks)
{
rank_t sender;
unsigned receivedHash;
assertex(receiveAck(recvMsg, sender, receivedHash));
verifyAck(hash, receivedHash);
}
}
if (!remaining)
break;
}
msg.clear();
// send blank msg to all to signal end to receivers.
if (!comm->send(msg, RANK_ALL, mpTag))
throwUnexpected();
if (async)
ackThread.join();
else
{
rank_t sender;
for (unsigned r=0; r<grpSize; r++)
{
while (!comm->recv(msg, r, replyTag, &sender, 60000))
WARNLOG("Waiting for final ack");
assertex(sender == r);
assertex(0 == msg.length());
}
}
float ms = timer.elapsedMs();
float mbPerSec = (totalSendSize/ms*1000)/0x100000;
PROGLOG("Stream stats: time taken = %.2f seconds, total sent=%u MB, throughput = %.2f MB/s", ms/1000, (unsigned)(totalSendSize/0x100000), mbPerSec);
}
catch (IException *e)
{
e->errorMessage(resultMsg);
EXCLOG(e, "FAIL");
e->Release();
return;
}
passed = true;
}
};
class CRecvServer : public CInterfaceOf<IInterface>, implements IThreaded
{
CThreaded threaded;
ICommunicator *comm;
rank_t myRank;
unsigned grpSize;
mptag_t mpTag;
unsigned numStreams;
unsigned checkData(MemoryBuffer &mb, unsigned hash)
{
size32_t len = mb.remaining();
const byte *p = (const byte *)mb.readDirect(len);
while (len >= sizeof(hash))
{
hash = hashc((unsigned char *)&hash, sizeof(hash), hash);
if (0 != memcmp(p, &hash, sizeof(hash)))
return 0;
p += sizeof(hash);
len -= sizeof(hash);
}
return hash;
}
public:
CRecvServer(ICommunicator *_comm, rank_t _myRank, unsigned _grpSize, mptag_t _mpTag, unsigned _numStreams)
: threaded("CSendStream", this), comm(_comm), myRank(_myRank), grpSize(_grpSize), mpTag(_mpTag), numStreams(_numStreams)
{
threaded.start();
}
~CRecvServer()
{
threaded.join();
}
void join()
{
threaded.join();
}
void stop()
{
comm->cancel(RANK_ALL, mpTag);
join();
}
virtual void threadmain() override
{
unsigned __int64 szRecvd = 0;
std::vector<rank_t> endReplyTags;
try
{
unsigned hash = (unsigned)mpTag;
unsigned clients = grpSize;
endReplyTags.resize(clients);
CMessageBuffer msg;
do
{
rank_t sender;
while (!comm->recv(msg, RANK_ALL, mpTag, &sender, 60000))
PROGLOG("Waiting for data on %u", (unsigned)mpTag);
if (!msg.length())
{
/* each client sends a zero length buffer when done.
* When all received, receiver can stop, and replies to indicate finished.
*
*/
endReplyTags[(unsigned)sender] = msg.getReplyTag();
--clients;
if (0 == clients)
{
for (unsigned r=0; r<endReplyTags.size(); r++)
{
if (!comm->send(msg, r, (mptag_t)endReplyTags[r]))
throwUnexpected();
}
break;
}
}
else
{
szRecvd += msg.length();
// read 1st hash, then use to calculate and check incoming data.
msg.read(hash);
hash = checkData(msg, hash);
msg.clear();
msg.append(hash); // this should match what client calculated presend.
if (!comm->reply(msg))
throwUnexpected();
}
}
while (true);
}
catch (IException *e)
{
EXCLOG(e, "CRecvServer");
e->Release();
}
PROGLOG("NxN:Receiver[tag=%u] szRecvd=%" I64F "u finished", (unsigned)mpTag, szRecvd);
}
};
mptag_t mpTag = (mptag_t)0x20000;
std::vector<Owned<CRecvServer>> receivers;
std::vector<Owned<CSendStream>> senders;
for (unsigned s=0; s<numStreams; s++)
{
receivers.push_back(new CRecvServer(comm, myRank, grpSize, mpTag, numStreams));
senders.push_back(new CSendStream(comm, myRank, grpSize, mpTag, ((unsigned __int64)perStreamMBSize)*0x100000, msgSize, async));
mpTag = (mptag_t)((unsigned)mpTag+1);
}
bool allSuccess = true;
for (unsigned senderN=0; senderN<senders.size(); senderN++)
{
const auto &sender = senders[senderN];
StringBuffer resultMsg;
bool res = sender->waitResult(resultMsg);
VStringBuffer logMsg("Stream[%u] from rank %u -> rank(s) [%s] result: ", senderN, (unsigned)myRank, sender->queryTgtRanks());
if (res)
logMsg.append("PASSED");
else
{
logMsg.append("FAILED - ").append(resultMsg.str());
allSuccess = false;
}
PROGLOG("%s", logMsg.str());
}
for (const auto &receiver: receivers)
{
if (allSuccess)
receiver->join();
else
receiver->stop();
}
}
// various test use some of these configurable parameters
static size32_t buffsize = 0;
static unsigned numiters = 0;
static unsigned numStreams = 0;
static unsigned perStreamMBSize = 0;
static bool async = false;
void runTest(const char *caption, const char *testname, IGroup* group, ICommunicator* comm)
{
if (group->rank()==0)
{
printf("\n\n");
PROGLOG("%s %s", caption, testname);
PROGLOG("========================");
}
comm->barrier();
if (strieq(testname, TEST_STREAM))
StreamTest(group, comm);
else if (strieq(testname, TEST_MULTI))
MultiTest(comm);
else if (strieq(testname, TEST_RING))
MPRing(group, comm, numiters);
else if (strieq(testname, TEST_AlltoAll))
MPAlltoAll(group, comm, buffsize, numiters);
else if (strieq(testname, TEST_RANK))
MPTest2(group, comm);
else if (strieq(testname, TEST_SELFSEND))
MPSelfSend(comm);
else if (strieq(testname, TEST_SINGLE_SEND))
Test1(group, comm);
else if (strieq(testname, TEST_RIGHT_SHIFT))
MPRightShift(comm);
else if (strieq(testname, TEST_RECV_FROM_ANY))
MPReceiveFromAny(comm);
else if (strieq(testname, TEST_SEND_TO_ALL))
MPSendToAll(comm);
else if (strieq(testname, TEST_MULTI_MT))
MPMultiMTSendRecv(comm, numiters);
else if (strieq(testname, TEST_NXN))
MPNxN(comm, numStreams, perStreamMBSize, buffsize, async);
else
PROGLOG("MPTEST: Error, invalid testname specified (-t %s)", testname);
comm->barrier();
}
bool createNodeList(IArrayOf<INode> &nodes, const char* hostfile, int my_port, rank_t max_ranks) {
unsigned i = 1;
char hoststr[256] = { "" };
FILE* fp = fopen(hostfile, "r");
if (fp == NULL)
{
PROGLOG("MPTest: Error, cannot open hostfile <%s>", hostfile);
return false;
}
char line[256] = { "" };
while (fgets(line, 255, fp) != NULL)
{
if ((max_ranks > 0) && ((i - 1) >= max_ranks))
break;
int srtn = sscanf(line, "%s", hoststr);
if (srtn == 1 && line[0] != '#') {
INode* newNode = createINode(hoststr, my_port);
nodes.append(*newNode);
i++;
}
}
fclose(fp);
return true;
}
void printHelp(char* executableName)
{
printf("\nMPTEST: Usage: %s <myport> [-f <hostfile> [-t <testname> -b <buffsize> -i <iters> -r <rank> -n <numprocs> -d] | <ip:port> <ip:port>] [-mpi] [-mp]\n\n",executableName);
std::vector<std::string> tests = { TEST_RANK, TEST_SELFSEND, TEST_MULTI,
TEST_STREAM, TEST_RING, TEST_AlltoAll, TEST_SINGLE_SEND,
TEST_RIGHT_SHIFT, TEST_RECV_FROM_ANY, TEST_SEND_TO_ALL,
TEST_MULTI_MT, TEST_NXN };
printf("\t <testname>");
for (auto &testName: tests)
printf("\t%s\n\t\t", testName.c_str());
printf("\n");
}
int main(int argc, char* argv[])
{
int mpi_debug = 0;
const char * testname = "";
rank_t max_ranks = 0;
unsigned startupDelay = 0;
InitModuleObjects();
EnableSEHtoExceptionMapping();
// startMPServer(9123);
// testIPnodeHash();
// stopMPServer();
// return 0;
/* mp hostfile format:
* -------------------
* <IP0>:port0
* <IP1>:port1
* <IP2>:port2
* ...
*
* run script:
* -----------
* # NOTE: because mptest will stop if its cmdline port and native IP do not match
* # corresponding entry in hostfile - the same cmdline can be repeated on all hosts ...
* mptest port0 -f hostfile [-t testname] [-b buffsize] [-i iters] [-n numprocs] [-d] &
* mptest port1 -f hostfile ... &
* ...
* [wait]
*
* Test names (-t):
* -----------
* MPRing (default)
* StreamTest
* MultiTest
* MPAlltoAll
* MPTest2
* MPNxN [-b <msgSiz>] [-s <numStreams>] [-m <perStreamMBSize>] [-a]
*
* Options: (available with -f hostfile arg)
* --------
* -b buffsize (bytes) for MPAlltoAll and MPNxN tests
* -i iterations for MPRing and MPAlltoAll tests
* -n numprocs for when wanting to test a subset of ranks from hostfile/script
* -d for some additional debug output
* -s number of streams for MPNxN test
* -m total MB's to send per stream for MPNxN test
* -a async for NxN test
*/
int argSize = argc;
char** argL = argv;
if (argSize<3)
{
printHelp(argv[0]);
return 0;
}
try
{
EnableSEHtoExceptionMapping();
StringBuffer lf;
rank_t tot_ranks = 0;
int my_port = atoi(argv[1]);
char logfile[256] = { "" };
sprintf(logfile,"mptest-%d.log",my_port);
openLogFile(lf, logfile);
IArrayOf<INode> nodes;
const char * hostfile = nullptr;
if (argSize > 3)
{
if (strcmp(argL[2], "-f") == 0)
hostfile = argL[3];
}
if (hostfile)
{
int j = 4;
while (j < argSize)
{
if (streq(argL[j], "-t"))
{
if ((j+1) < argSize)
{
testname = argL[j+1];
j++;
}
}
else if (streq(argL[j], "-d"))
{
mpi_debug++;
}
else if (streq(argL[j], "-b"))
{
if ((j+1) < argSize)
{
buffsize = atoi(argL[j+1]);
j++;
}
}
else if (streq(argL[j], "-i"))
{
if ((j+1) < argSize)
{
numiters = atoi(argL[j+1]);
j++;
}
}
else if ( streq(argL[j], "-n") || streq(argL[j], "-np") )
{
if ((j+1) < argSize)
{
max_ranks = atoi(argL[j+1]);
j++;
}
}
else if (streq(argv[j], "-s"))
{
if ((j+1) < argc)
{
numStreams = atoi(argv[j+1]);
j++;
}
}
else if (streq(argv[j], "-m"))
{
if ((j+1) < argc)
{
perStreamMBSize = atoi(argv[j+1]);
j++;
}
}
else if (streq(argv[j], "-a"))
async = true;
else if (streq(argv[j], "-delay"))
{
if ((j+1) < argc)
{
startupDelay = atoi(argv[j+1]);
j++;
}
}
j++;
}
if (!createNodeList(nodes, hostfile, my_port, max_ranks))
return 1;
}
else
{
unsigned i = 1;
while (i+1 < argSize)
{
PROGLOG("MPTEST: adding node %u, port = <%s>", i-1, argL[i+1]);
INode *newNode = createINode(argL[i+1], my_port);
nodes.append(*newNode);
i++;
}
}
tot_ranks = nodes.length();
if (startupDelay)
{
PROGLOG("Pausing for startupDelay = %u second(s)", startupDelay);
MilliSleep(startupDelay * 1000);
PROGLOG("Resuming");
}
Owned<IGroup> group = createIGroup(tot_ranks, nodes.getArray());
// stop if not meant for this host ...
IpAddress myIp;
GetHostIp(myIp);
SocketEndpoint myEp(my_port, myIp);
bool die = true;
for (rank_t k=0;k<tot_ranks;k++)
{
if (nodes.item(k).endpoint().equals(myEp))
die = false;
}
if (die)
return 0;
PROGLOG("MPTEST: Starting, port = %d tot ranks = %u", my_port, tot_ranks);
startMPServer(my_port);
if (mpi_debug)
{
for (rank_t k=0;k<tot_ranks;k++)
{
StringBuffer urlStr;
nodes.item(k).endpoint().getUrlStr(urlStr);
PROGLOG("MPTEST: adding node %u, %s", k, urlStr.str());
}
}
Owned<ICommunicator> comm = createCommunicator(group);
runTest("MPTEST: Running MP Test:", testname, group, comm);
stopMPServer();
}
catch (IException *e)
{
pexception("Exception",e);
e->Release();
}
PROGLOG("MPTEST: bye");
return 0;
}
| 29.077732 | 302 | 0.497086 |
867b91089c5e8aa3d5c05895f0beafc5161bae0f | 531 | asm | Assembly | oeis/245/A245245.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/245/A245245.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/245/A245245.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A245245: a(n) = C(3*n^2, n^2).
; Submitted by Christian Krause
; 1,3,495,4686825,2254848913647,52588547141148893628,58152371703925106867047535565,3012179439602547459232394950891834843500,7255167425905233148164780983569428433097979870294255,808718755397067598640202627155266231883064669446721506930287016061,4158251463258564744783383526326405580280466005743648708663033657304756328324008620,983944431992885247886528744781914765780055310889986542226990820250469418230392153367541438162630800
pow $0,2
mov $1,$0
mul $0,3
bin $0,$1
| 59 | 426 | 0.892655 |
9bc302866ef6107af4908ea1eea850153c1214ef | 2,435 | swift | Swift | Sample/buttonSample/ViewController.swift | sun54907/IconButtonView | 968b9b917e9cffa9005298d95a938d5cf90ee43f | [
"MIT"
] | 4 | 2017-11-28T10:35:43.000Z | 2018-06-20T13:41:08.000Z | Sample/buttonSample/ViewController.swift | umikawa-k/IconButtonView | 968b9b917e9cffa9005298d95a938d5cf90ee43f | [
"MIT"
] | null | null | null | Sample/buttonSample/ViewController.swift | umikawa-k/IconButtonView | 968b9b917e9cffa9005298d95a938d5cf90ee43f | [
"MIT"
] | null | null | null | //
// ViewController.swift
// buttonSample
//
// Created by kazuya umikawa on 2017/12/03.
// Copyright © 2017年 sun54907. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .center
stackView.distribution = .equalCentering
self.view.addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.backgroundColor = UIColor.init(white: 0.3, alpha: 0.5)
if #available(iOS 11.0, *) {
stackView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor).isActive = true
stackView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true
stackView.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor).isActive = true
stackView.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor).isActive = true
} else {
stackView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
stackView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
stackView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true
stackView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true
}
let iconButtonView = IconButtonView.create(data: .init(title: "クリック"), style: .medium(.wrapContent), colorType: .primary)
stackView.addArrangedSubview(iconButtonView)
let iconButtonView2 = IconButtonView.create(data: .init(title: "クリック", leftImage: #imageLiteral(resourceName: "camera")), style: .large(.wrapContent), colorType: .secondary)
stackView.addArrangedSubview(iconButtonView2)
let iconButtonView3 = IconButtonView.create(data: .init(title: "クリック", leftImage: #imageLiteral(resourceName: "camera"), rightImage: #imageLiteral(resourceName: "mail")), style: .large(.wrapContent), colorType: .primaryBorder)
stackView.addArrangedSubview(iconButtonView3)
let iconButtonView4 = IconButtonView.create(data: .init(title: "クリック"), style: .small(.wrapContent), colorType: .normal)
stackView.addArrangedSubview(iconButtonView4)
}
}
| 48.7 | 234 | 0.712936 |
64faaa8f7c76722664556a2d424e842a27c0294c | 1,410 | java | Java | src/main/java/cn/edu/hust/engine/api/Field.java | xinyuyu/javap-web | 0d999070fba9b96a289860e9aa540ab8fbc7fb1a | [
"MIT"
] | null | null | null | src/main/java/cn/edu/hust/engine/api/Field.java | xinyuyu/javap-web | 0d999070fba9b96a289860e9aa540ab8fbc7fb1a | [
"MIT"
] | null | null | null | src/main/java/cn/edu/hust/engine/api/Field.java | xinyuyu/javap-web | 0d999070fba9b96a289860e9aa540ab8fbc7fb1a | [
"MIT"
] | null | null | null | /*
* 定义ClassFile的Field类
*
* 1.public String getAccessFlags(): 字符串格式的access_flags
* 2.public String getFieldSignature(): 字段签名
*
* Copyright (c) 2014.2.21, All rights reserved.
*/
package cn.edu.hust.engine.api;
import java.util.Map;
/**
* field_info {
* u2 access_flags;
* u2 name_index;
* u2 descriptor_index;
* u2 attributes_count;
* attribute_info attributes[attributes_count];
* }
*/
public class Field extends FieldBase {
public Field( byte[] data, int[] pool, int offset) {
super(data, pool, offset);
}
/**
* @return 字符串格式的access_flags
*/
public String getAccessFlags() {
return ClassFile.getAccessFlagSet(access_flags, Flags.fieldAccessFlags);
}
/**
* @return 字段签名(访问信息 类型 名字 = 值)
*/
public String getFieldSignature() {
String descriptor = getDescriptor();
String fieldSignature = getAccessFlags() + " " + descriptor + " " + getName();
Map<String, Attribute> attributeMap = getAttributeMap();
if (attributeMap.containsKey("ConstantValue")) {
ConstantValue constantValue = (ConstantValue)attributeMap.get("ConstantValue");
String v = constantValue.getConstantValue();
if (descriptor.equals("char"))
v = "'" + (char)Short.parseShort(v) + "'";
else if (descriptor.equals("boolean")) {
if (v.equals("1"))
v = "true";
else {
v = "false";
}
}
fieldSignature += " = " + v;
}
return fieldSignature + ";";
}
} | 24.310345 | 82 | 0.660284 |
e73064789317534ef829e06807429a8ccced2a83 | 113 | js | JavaScript | src/index.js | gvergnaud/evolui | c99a83e18ae9f76ac8ae731e8c8d243d733b9611 | [
"MIT"
] | 45 | 2018-02-11T19:28:43.000Z | 2021-02-02T09:22:27.000Z | src/index.js | gvergnaud/evolui | c99a83e18ae9f76ac8ae731e8c8d243d733b9611 | [
"MIT"
] | null | null | null | src/index.js | gvergnaud/evolui | c99a83e18ae9f76ac8ae731e8c8d243d733b9611 | [
"MIT"
] | 2 | 2018-02-14T17:58:13.000Z | 2021-01-12T22:13:47.000Z | import { html, render } from './html'
import { text } from './text'
export default html
export { text, render }
| 18.833333 | 37 | 0.663717 |
0a616f844b98fdf6eae57dceddc690a65d111f80 | 389 | sql | SQL | database/schema/dbDROP.sql | kanalumaddela/ub-course-registration | 483dd2cb88afb34225311b87d056262ddfa46210 | [
"MIT"
] | null | null | null | database/schema/dbDROP.sql | kanalumaddela/ub-course-registration | 483dd2cb88afb34225311b87d056262ddfa46210 | [
"MIT"
] | null | null | null | database/schema/dbDROP.sql | kanalumaddela/ub-course-registration | 483dd2cb88afb34225311b87d056262ddfa46210 | [
"MIT"
] | null | null | null | DROP TABLE IF EXISTS locations;
DROP TABLE IF EXISTS student_registrations;
DROP TABLE IF EXISTS department_advisors;
DROP TABLE IF EXISTS messages;
DROP TABLE IF EXISTS course_section_schedules;
DROP TABLE IF EXISTS course_sections;
DROP TABLE IF EXISTS catalogs;
DROP TABLE IF EXISTS courses;
DROP TABLE IF EXISTS departments;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS buildings;
| 32.416667 | 46 | 0.830334 |
98823baf7c469c90a391dd5a038d32e12dfdb902 | 2,648 | kt | Kotlin | test/leetcode/WordSearch.kt | andrej-dyck/coding-challenges | da395484b3d483fbf5eaae9f30064672ad014f0d | [
"MIT"
] | null | null | null | test/leetcode/WordSearch.kt | andrej-dyck/coding-challenges | da395484b3d483fbf5eaae9f30064672ad014f0d | [
"MIT"
] | null | null | null | test/leetcode/WordSearch.kt | andrej-dyck/coding-challenges | da395484b3d483fbf5eaae9f30064672ad014f0d | [
"MIT"
] | null | null | null | package leetcode
import lib.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.*
import org.junit.jupiter.params.*
import org.junit.jupiter.params.converter.*
import org.junit.jupiter.params.provider.*
/**
* https://leetcode.com/problems/word-search/
*
* 79. Word Search
* [Medium]
*
* Given an m x n board and a word, find if the word exists in the grid.
*
* The word can be constructed from letters of sequentially adjacent cells,
* where "adjacent" cells are horizontally or vertically neighboring.
* The same letter cell may not be used more than once.
*
* Constraints:
* - m == board.length
* - n = board[i].length
* - 1 <= m, n <= 200
* - 1 <= word.length <= 10^3
* - board and word consists only of lowercase and uppercase English letters.
*/
typealias Board = Array<String>
typealias Coordinates = Sequence<XY>
typealias Path = Coordinates
fun findWordsOnBoard(board: Board, words: List<String>) =
words.filter { boardContainsWord(board, it) }
fun boardContainsWord(board: Board, word: String) = board.findPath(word).any() // for leetcode
fun Board.findPath(word: String, xys: Coordinates = xys(), path: Path = emptySequence()): Path =
if (word.isEmpty()) path
else xys
.filter { word.first() == maybeValue(it) && it !in path }
.map { findPath(word.drop(1), it.neighbors(), path + it) }
.find { it.any() }
.orEmpty()
private fun Board.xys() =
asSequence().flatMapIndexed { y, r -> r.mapIndexed { x, _ -> XY(x, y) } }
private fun Board.maybeValue(xy: XY) = getOrNull(xy.y)?.getOrNull(xy.x)
data class XY(val x: Int, val y: Int) {
fun neighbors() = sequenceOf(right(), down(), up(), left())
fun up() = copy(y = y - 1)
fun right() = copy(x = x + 1)
fun down() = copy(y = y + 1)
fun left() = copy(x = x - 1)
}
/**
* Unit tests
*/
class WordsInsideARectangleTest {
@ParameterizedTest
@CsvSource(
"[KOTE, NULE, AFIN]; [Kotlin, fun, file, line, null]; [KOTLIN, FUN, FILE, LINE]",
"[ABCE, SFCS, ADEE]; [ABCCED, SEE, ABCB]; [ABCCED, SEE]", // ABCB can only be found by visiting a cell twice
delimiter = ';'
)
fun `finds words on board by finding a path of adjacent cells starting anywhere`(
@ConvertWith(StringArrayArg::class) board: Array<String>,
@ConvertWith(StringArrayArg::class) words: Array<String>,
@ConvertWith(StringArrayArg::class) expectedWords: Array<String>
) {
assertThat(
findWordsOnBoard(board, words.map { it.uppercase() })
).containsExactlyElementsOf(
expectedWords.toList()
)
}
} | 31.903614 | 116 | 0.645015 |
290a1776184d8caeef4900f9245b7dc90371ba58 | 736 | py | Python | plotly/validators/choropleth/_marker.py | faezs/plotly.py | 6009b5b9c746e5d2a2849ad255a4eb234b551ed7 | [
"MIT"
] | 1 | 2018-07-16T01:51:47.000Z | 2018-07-16T01:51:47.000Z | plotly/validators/choropleth/_marker.py | faezs/plotly.py | 6009b5b9c746e5d2a2849ad255a4eb234b551ed7 | [
"MIT"
] | null | null | null | plotly/validators/choropleth/_marker.py | faezs/plotly.py | 6009b5b9c746e5d2a2849ad255a4eb234b551ed7 | [
"MIT"
] | 1 | 2019-02-18T04:12:56.000Z | 2019-02-18T04:12:56.000Z | import _plotly_utils.basevalidators
class MarkerValidator(_plotly_utils.basevalidators.CompoundValidator):
def __init__(
self, plotly_name='marker', parent_name='choropleth', **kwargs
):
super(MarkerValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_class_str='Marker',
data_docs="""
line
plotly.graph_objs.choropleth.marker.Line
instance or dict with compatible properties
opacity
Sets the opacity of the locations.
opacitysrc
Sets the source reference on plot.ly for
opacity .""",
**kwargs
)
| 30.666667 | 70 | 0.584239 |
5083ed123705edf4aa4d7ccc1f6babef7e2848a4 | 300 | html | HTML | AngularApp/projects/app-service-diagnostics/src/app/availability/detector-view/detectors/page-operations-detector/page-operations-detector.component.html | khaled-zayed/Azure-AppServices-Diagnostics-Portal | eef71d4ae91ccb38b51cb33183d22c50c9bfb051 | [
"MIT"
] | 40 | 2018-10-14T15:13:04.000Z | 2022-03-25T02:27:28.000Z | AngularApp/projects/app-service-diagnostics/src/app/availability/detector-view/detectors/page-operations-detector/page-operations-detector.component.html | khaled-zayed/Azure-AppServices-Diagnostics-Portal | eef71d4ae91ccb38b51cb33183d22c50c9bfb051 | [
"MIT"
] | 232 | 2018-03-26T17:27:03.000Z | 2022-03-20T03:32:05.000Z | AngularApp/projects/app-service-diagnostics/src/app/availability/detector-view/detectors/page-operations-detector/page-operations-detector.component.html | khaled-zayed/Azure-AppServices-Diagnostics-Portal | eef71d4ae91ccb38b51cb33183d22c50c9bfb051 | [
"MIT"
] | 45 | 2018-10-30T10:57:49.000Z | 2022-01-17T17:38:44.000Z | <metric-graph
[metricSets]="detectorMetrics"
[title]="detectorMetricsTitle"
[chartType]="metricsChartType"
[description]="detectorMetricsDescription"
[yAxisLabel]="detectorMetricsYAxisLabel">
</metric-graph>
<br/>
<feedback-form [source]='getDetectorName()'></feedback-form> | 30 | 60 | 0.72 |
3693bb953b7464502da0cf120263724e82ba9c7a | 2,407 | rs | Rust | src/server.rs | jiricodes/rust_http_server | af709a5c816586edf5fa3f002f09799411f64c49 | [
"MIT"
] | null | null | null | src/server.rs | jiricodes/rust_http_server | af709a5c816586edf5fa3f002f09799411f64c49 | [
"MIT"
] | null | null | null | src/server.rs | jiricodes/rust_http_server | af709a5c816586edf5fa3f002f09799411f64c49 | [
"MIT"
] | null | null | null | //! Main server struct and loop
use crate::http::{ParseError, Request, Response, StatusCode};
use std::convert::TryFrom;
use std::io::Read;
use std::net::TcpListener;
/// Trait to handle requests
pub trait Handler {
fn handle_request(&mut self, request: &Request) -> Response;
fn handle_bad_request(&mut self, e: &ParseError) -> Response {
println!("Failed to convert the request: {}", e);
Response::new(
StatusCode::BadRequest,
Some("<h1>404 Bad Request</h1>".to_string()),
)
}
}
pub struct Server {
address: String,
}
impl Server {
pub fn new(address: String) -> Server {
Server { address }
}
// takes ownership since we want to be dealocated upon exit
pub fn run(self, mut handler: impl Handler) {
let listener: TcpListener = TcpListener::bind(&self.address).unwrap();
println!("Listening at {}", self.address);
loop {
match listener.accept() {
Ok((mut stream, address)) => {
println!("Connection established with {}", address);
let mut buffer: [u8; 4096] = [0; 4096];
match stream.read(&mut buffer) {
Ok(size) => {
println!("Read {} bytes:", size);
// println!("{}", String::from_utf8_lossy(&buffer));
let response = match Request::try_from(&buffer as &[u8]) {
Ok(request) => handler.handle_request(&request),
Err(e) => handler.handle_bad_request(&e),
};
if let Err(e) = response.send(&mut stream) {
println!("Failed to send response: {}", e);
}
}
Err(e) => println!("Failed to read from connection: {}", e),
}
}
Err(e) => {
println!("Failed to establish a connection: {}", e);
}
}
// let result = listener.accept();
// if result.is_err() {
// println!("Experienced connection error. Continuing.");
// continue ;
// }
// let (stream, socket_address) = result.unwrap();
}
}
}
| 35.925373 | 86 | 0.472788 |
a55a3fb9207b90c45bb11ccdfc3323576c16fcf7 | 1,641 | dart | Dart | lib/animations/basic_animations/hero_anim.dart | SumitShukla007/Flutter_Material_Design | d30b12cb69c23631e991acc40ae1c591d8cbd669 | [
"Apache-2.0"
] | 20 | 2020-10-03T11:13:11.000Z | 2022-02-10T05:38:10.000Z | lib/animations/basic_animations/hero_anim.dart | SumitShukla007/Flutter_Material_Design | d30b12cb69c23631e991acc40ae1c591d8cbd669 | [
"Apache-2.0"
] | null | null | null | lib/animations/basic_animations/hero_anim.dart | SumitShukla007/Flutter_Material_Design | d30b12cb69c23631e991acc40ae1c591d8cbd669 | [
"Apache-2.0"
] | 3 | 2021-06-07T13:48:17.000Z | 2021-12-18T13:21:26.000Z | import 'package:flutter/material.dart';
class HeroAnimScreen extends StatefulWidget {
@override
_HeroAnimScreenState createState() => _HeroAnimScreenState();
}
class _HeroAnimScreenState extends State<HeroAnimScreen> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Hero Page1"),
),
body: Page1(),
),
);
}
}
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.push(
context,
PageRouteBuilder(
transitionDuration: Duration(seconds: 1),
pageBuilder: (_, __, ___) => Page2(),
),
),
child: Align(
alignment: Alignment.topCenter,
child: Hero(
tag: "profile_img",
child: Container(
child: Image.asset(
"images/img.webp",
width: 150.0,
height: 150.0,
),
),
),
),
);
}
}
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Hero Page2"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Hero(
tag: 'profile_img',
child: Container(
width: double.infinity,
height: 300.0,
child: Image.asset(
"images/img.webp",
),
),
),
),
),
);
}
}
| 21.88 | 63 | 0.520414 |
96d06ac64fd20beb6d4581027b7e50bc68b85c7b | 776 | cpp | C++ | BosekiAudioFilter/BosekiAudioFilter.cpp | totoki-kei/MyAviutlFilter | 6fcb6279319e933580a8a17aca6e6aabd1324055 | [
"MIT"
] | null | null | null | BosekiAudioFilter/BosekiAudioFilter.cpp | totoki-kei/MyAviutlFilter | 6fcb6279319e933580a8a17aca6e6aabd1324055 | [
"MIT"
] | null | null | null | BosekiAudioFilter/BosekiAudioFilter.cpp | totoki-kei/MyAviutlFilter | 6fcb6279319e933580a8a17aca6e6aabd1324055 | [
"MIT"
] | null | null | null | // BosekiSoundFilter.cpp : DLL アプリケーション用にエクスポートされる関数を定義します。
//
#include "stdafx.h"
#include "AudioMultiplier.h"
#include "AudioPosition.h"
#include "AudioWave.h"
#include "AudioReverse.h"
#include "AudioTest.h"
//---------------------------------------------------------------------
// フィルタ構造体のポインタを渡す関数
//---------------------------------------------------------------------
EXTERN_C FILTER_DLL** cdecl GetFilterTableList(void)
{
//must terminate with nullptr
//http://qiita.com/yumetodo/items/4d972da03b3be788fcda
static FILTER_DLL* pluginlist[] = {
&AudioMultiplier::FilterDeclaration,
&AudioPosition::FilterDeclaration,
&AudioReverse::FilterDeclaration,
&AudioWave::FilterDeclaration,
&AudioTest::FilterDeclaration,
nullptr,
};
return pluginlist;
} | 25.032258 | 71 | 0.625 |
4ab52631035fa1dae7aff56680377bd9a7041374 | 436 | cs | C# | Server/Generators/DungeonSharp-master/DungeonSharp/Room.cs | LeifBloomquist/MultiRogueLike | f3a2afea40dcfa36423975de5b913146701abfe7 | [
"MIT"
] | 21 | 2018-03-19T02:07:41.000Z | 2022-02-12T20:13:21.000Z | Server/Generators/DungeonSharp-master/DungeonSharp/Room.cs | LeifBloomquist/MultiRogueLike | f3a2afea40dcfa36423975de5b913146701abfe7 | [
"MIT"
] | 2 | 2020-10-30T15:45:35.000Z | 2020-10-30T20:34:52.000Z | Server/Generators/DungeonSharp-master/DungeonSharp/Room.cs | LeifBloomquist/MultiRogueLike | f3a2afea40dcfa36423975de5b913146701abfe7 | [
"MIT"
] | 3 | 2019-09-29T20:28:02.000Z | 2020-10-01T03:53:51.000Z | using System.Collections.Generic;
namespace DungeonSharp
{
internal class Room : IRoom
{
public int X;
public int Y;
public int Width;
public int Height;
public IEnumerable<Coordinate> GetFloorTiles()
{
for (int y = 0; y < Height; y++)
for (int x = 0; x < Width; x++)
yield return new Coordinate(X + x, Y + y);
}
}
}
| 21.8 | 62 | 0.504587 |
2ff7a93afe25442c660521081f5105f3417092f3 | 1,768 | rs | Rust | src/http.rs | dev-launchers/interactive-bot | cd00d9ee7a63af71bf4dea0be3211c4cfc2cd7c5 | [
"Apache-2.0",
"MIT"
] | null | null | null | src/http.rs | dev-launchers/interactive-bot | cd00d9ee7a63af71bf4dea0be3211c4cfc2cd7c5 | [
"Apache-2.0",
"MIT"
] | null | null | null | src/http.rs | dev-launchers/interactive-bot | cd00d9ee7a63af71bf4dea0be3211c4cfc2cd7c5 | [
"Apache-2.0",
"MIT"
] | null | null | null | use super::error::Error;
use serde::Serialize;
use std::collections::HashMap;
use wasm_bindgen::{JsCast, JsValue};
use wasm_bindgen_futures::JsFuture;
use web_sys::{RequestInit, Response};
pub struct Request<T: ?Sized>
where
T: Serialize,
{
pub url: String,
pub method: Method,
pub headers: HashMap<String, String>,
pub body: T,
}
pub enum Method {
GET,
POST,
PUT,
DELETE,
}
impl Method {
pub fn as_str(&self) -> &str {
match self {
Method::GET => "GET",
Method::POST => "POST",
Method::PUT => "PUT",
Method::DELETE => "DELETE",
}
}
}
pub async fn send<T>(req: Request<T>) -> Result<Response, Error>
where
T: Serialize,
{
let mut opts = RequestInit::new();
let method = req.method;
opts.method(method.as_str());
match method {
Method::GET | Method::DELETE => {}
Method::POST | Method::PUT => {
// Equivalent to JSON.stringify in JS
let body = JsValue::from_str(&serde_json::to_string(&req.body)?);
opts.body(Some(&body));
}
};
let request = web_sys::Request::new_with_str_and_init(&req.url, &opts)?;
for (k, v) in req.headers.iter() {
request.headers().set(k, v)?;
}
let window = worker_global_scope().ok_or(Error::NoWindow)?;
// `resp_value` is a JS `Response` object.
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;
let resp: Response = resp_value.dyn_into()?;
Ok(resp)
}
// Returns global execution context of a service worker
fn worker_global_scope() -> Option<web_sys::ServiceWorkerGlobalScope> {
js_sys::global()
.dyn_into::<web_sys::ServiceWorkerGlobalScope>()
.ok()
}
| 23.891892 | 80 | 0.60181 |
32d295ce6f3819e00a8091c4d688f5a560081816 | 956 | cql | SQL | cassandra-based/scripts/02-aggregate-functions.cql | hsmak/sql-analytics-sandbox | db3349d8ec20e5d4c966f9cddd0131e5df62950b | [
"MIT"
] | null | null | null | cassandra-based/scripts/02-aggregate-functions.cql | hsmak/sql-analytics-sandbox | db3349d8ec20e5d4c966f9cddd0131e5df62950b | [
"MIT"
] | null | null | null | cassandra-based/scripts/02-aggregate-functions.cql | hsmak/sql-analytics-sandbox | db3349d8ec20e5d4c966f9cddd0131e5df62950b | [
"MIT"
] | null | null | null | -- ############################################ --
-- -- Create a Keyspace --
DROP KEYSPACE if exists KSOfHusain;
CREATE KEYSPACE if not exists KSOfHusain WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
USE KSOfHusain;
--
DROP TABLE IF EXISTS reversed_user_status_updates;
CREATE TABLE reversed_user_status_updates
(
username text,
id timeuuid,
body text,
PRIMARY KEY (username, id)
) WITH CLUSTERING ORDER BY (id DESC);
INSERT INTO reversed_user_status_updates(username, id, body) VALUES ('alice', NOW(), 'Reversed status 1');
INSERT INTO reversed_user_status_updates(username, id, body) VALUES ('alice', NOW(), 'Reversed status 2');
INSERT INTO reversed_user_status_updates(username, id, body) VALUES ('alice', NOW(), 'Reversed status 3');
SELECT * FROM reversed_user_status_updates WHERE username = 'alice';
SELECT * FROM reversed_user_status_updates WHERE username = 'alice' ORDER BY id ASC;
--
| 36.769231 | 114 | 0.705021 |
49bb95a3454d4067566cd6562ff6884ad69f7a5d | 359 | asm | Assembly | programs/oeis/037/A037667.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/037/A037667.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/037/A037667.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A037667: Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 3,2,0.
; 3,14,56,227,910,3640,14563,58254,233016,932067,3728270,14913080,59652323,238609294,954437176,3817748707,15270994830,61083979320,244335917283,977343669134,3909374676536,15637498706147,62549994824590
mov $1,4
pow $1,$0
mul $1,32
div $1,9
mov $0,$1
| 39.888889 | 199 | 0.791086 |
8c8c7cbb8dc3c827eb1963cdcaa1f854f30fc45a | 176 | swift | Swift | Pod/Classes/ViewModel/BViewModel.swift | ApterKingRepo/Verify-B | eeafcba91defacc09f73d5fc19923e0242feb2f4 | [
"MIT"
] | null | null | null | Pod/Classes/ViewModel/BViewModel.swift | ApterKingRepo/Verify-B | eeafcba91defacc09f73d5fc19923e0242feb2f4 | [
"MIT"
] | null | null | null | Pod/Classes/ViewModel/BViewModel.swift | ApterKingRepo/Verify-B | eeafcba91defacc09f73d5fc19923e0242feb2f4 | [
"MIT"
] | null | null | null | //
// BViewModel.swift
// Example
//
// Created by wangcong on 22/05/2017.
// Copyright © 2017 cdsf. All rights reserved.
//
import UIKit
class BViewModel: NSObject {
}
| 12.571429 | 47 | 0.664773 |
0b4623dab1603f85bb3ff230be87bd3549b4bccb | 1,493 | dart | Dart | lib/components/home/home_tasks.dart | mba-78aoj-grupo3/todo_app | 261ad79bba52495324346f49fee479f4f1e5390c | [
"MIT"
] | null | null | null | lib/components/home/home_tasks.dart | mba-78aoj-grupo3/todo_app | 261ad79bba52495324346f49fee479f4f1e5390c | [
"MIT"
] | null | null | null | lib/components/home/home_tasks.dart | mba-78aoj-grupo3/todo_app | 261ad79bba52495324346f49fee479f4f1e5390c | [
"MIT"
] | null | null | null | import 'package:flutter/material.dart';
import '../../components/task_item.dart';
import '../../database/entities/task.dart';
import '../../resources/spacings.dart';
import '../../resources/strings.dart';
class HomeTasks extends StatelessWidget {
const HomeTasks(this.todayTasks, this.onChanged);
final List<Task> todayTasks;
final Function(bool value, Task task) onChanged;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: Spacings.x3),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Strings.todayTaskSection,
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold),
),
const SizedBox(height: Spacings.x3),
Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: todayTasks.length,
itemBuilder: (context, index) {
return Card(
child: TaskItem(
completed: todayTasks[index].isComplete,
title: todayTasks[index].description,
onChanged: (value) => onChanged(value, todayTasks[index]),
),
);
}),
),
const SizedBox(height: Spacings.x20),
],
),
);
}
}
| 31.104167 | 80 | 0.54789 |
28ef47ef61225e6b6e2c34388b2b234a3577daac | 3,974 | hpp | C++ | ReactNativeFrontend/ios/Pods/boost/boost/atomic/detail/wait_ops_freebsd_umtx.hpp | Harshitha91/Tmdb-react-native-node | e06e3f25a7ee6946ef07a1f524fdf62e48424293 | [
"Apache-2.0"
] | 2,728 | 2015-01-01T10:06:45.000Z | 2022-03-30T18:12:58.000Z | ReactNativeFrontend/ios/Pods/boost/boost/atomic/detail/wait_ops_freebsd_umtx.hpp | Harshitha91/Tmdb-react-native-node | e06e3f25a7ee6946ef07a1f524fdf62e48424293 | [
"Apache-2.0"
] | 1,192 | 2015-01-01T06:03:19.000Z | 2022-03-31T09:14:36.000Z | ReactNativeFrontend/ios/Pods/boost/boost/atomic/detail/wait_ops_freebsd_umtx.hpp | Harshitha91/Tmdb-react-native-node | e06e3f25a7ee6946ef07a1f524fdf62e48424293 | [
"Apache-2.0"
] | 334 | 2015-01-08T20:47:03.000Z | 2022-02-18T07:07:01.000Z | /*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2020 Andrey Semashev
*/
/*!
* \file atomic/detail/wait_ops_freebsd_umtx.hpp
*
* This header contains implementation of the waiting/notifying atomic operations based on FreeBSD _umtx_op syscall.
* https://www.freebsd.org/cgi/man.cgi?query=_umtx_op&apropos=0&sektion=2&manpath=FreeBSD+11-current&format=html
*/
#ifndef BOOST_ATOMIC_DETAIL_WAIT_OPS_FREEBSD_UMTX_HPP_INCLUDED_
#define BOOST_ATOMIC_DETAIL_WAIT_OPS_FREEBSD_UMTX_HPP_INCLUDED_
#include <sys/types.h>
#include <sys/umtx.h>
#include <cstddef>
#include <boost/memory_order.hpp>
#include <boost/atomic/detail/config.hpp>
#include <boost/atomic/detail/int_sizes.hpp>
#include <boost/atomic/detail/wait_operations_fwd.hpp>
#include <boost/atomic/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
namespace atomics {
namespace detail {
#if defined(UMTX_OP_WAIT_UINT) || defined(UMTX_OP_WAIT)
template< typename Base >
struct wait_operations_freebsd_umtx_common :
public Base
{
typedef Base base_type;
typedef typename base_type::storage_type storage_type;
static BOOST_CONSTEXPR_OR_CONST bool always_has_native_wait_notify = true;
static BOOST_FORCEINLINE bool has_native_wait_notify(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
static BOOST_FORCEINLINE void notify_one(storage_type volatile& storage) BOOST_NOEXCEPT
{
::_umtx_op(const_cast< storage_type* >(&storage), UMTX_OP_WAKE, 1u, NULL, NULL);
}
static BOOST_FORCEINLINE void notify_all(storage_type volatile& storage) BOOST_NOEXCEPT
{
::_umtx_op(const_cast< storage_type* >(&storage), UMTX_OP_WAKE, (~static_cast< unsigned int >(0u)) >> 1, NULL, NULL);
}
};
#endif // defined(UMTX_OP_WAIT_UINT) || defined(UMTX_OP_WAIT)
// UMTX_OP_WAIT_UINT only appeared in FreeBSD 8.0
#if defined(UMTX_OP_WAIT_UINT) && BOOST_ATOMIC_DETAIL_SIZEOF_INT < BOOST_ATOMIC_DETAIL_SIZEOF_LONG
template< typename Base, bool Interprocess >
struct wait_operations< Base, sizeof(unsigned int), true, Interprocess > :
public wait_operations_freebsd_umtx_common< Base >
{
typedef wait_operations_freebsd_umtx_common< Base > base_type;
typedef typename base_type::storage_type storage_type;
static BOOST_FORCEINLINE storage_type wait(storage_type const volatile& storage, storage_type old_val, memory_order order) BOOST_NOEXCEPT
{
storage_type new_val = base_type::load(storage, order);
while (new_val == old_val)
{
::_umtx_op(const_cast< storage_type* >(&storage), UMTX_OP_WAIT_UINT, old_val, NULL, NULL);
new_val = base_type::load(storage, order);
}
return new_val;
}
};
#endif // defined(UMTX_OP_WAIT_UINT) && BOOST_ATOMIC_DETAIL_SIZEOF_INT < BOOST_ATOMIC_DETAIL_SIZEOF_LONG
#if defined(UMTX_OP_WAIT)
template< typename Base, bool Interprocess >
struct wait_operations< Base, sizeof(unsigned long), true, Interprocess > :
public wait_operations_freebsd_umtx_common< Base >
{
typedef wait_operations_freebsd_umtx_common< Base > base_type;
typedef typename base_type::storage_type storage_type;
static BOOST_FORCEINLINE storage_type wait(storage_type const volatile& storage, storage_type old_val, memory_order order) BOOST_NOEXCEPT
{
storage_type new_val = base_type::load(storage, order);
while (new_val == old_val)
{
::_umtx_op(const_cast< storage_type* >(&storage), UMTX_OP_WAIT, old_val, NULL, NULL);
new_val = base_type::load(storage, order);
}
return new_val;
}
};
#endif // defined(UMTX_OP_WAIT)
} // namespace detail
} // namespace atomics
} // namespace boost
#include <boost/atomic/detail/footer.hpp>
#endif // BOOST_ATOMIC_DETAIL_WAIT_OPS_FREEBSD_UMTX_HPP_INCLUDED_
| 33.116667 | 141 | 0.747609 |
b6a0a1bdef656835f5bf187d18122cae0616f81d | 699 | asm | Assembly | oeis/221/A221172.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/221/A221172.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/221/A221172.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A221172: a(0)=-2, a(1)=3; thereafter a(n) = 2*a(n-1) + a(n-2).
; Submitted by Jamie Morken(s3)
; -2,3,4,11,26,63,152,367,886,2139,5164,12467,30098,72663,175424,423511,1022446,2468403,5959252,14386907,34733066,83853039,202439144,488731327,1179901798,2848534923,6876971644,16602478211,40081928066,96766334343,233614596752,563995527847,1361605652446,3287206832739,7936019317924,19159245468587,46254510255098,111668265978783,269591042212664,650850350404111,1571291743020886,3793433836445883,9158159415912652,22109752668271187,53377664752455026,128865082173181239,311107829098817504,751080740370816247
mov $1,7
mov $3,-2
lpb $0
sub $0,1
add $1,$3
mov $2,$3
add $3,$1
mov $1,$2
lpe
mov $0,$3
| 46.6 | 501 | 0.792561 |
313bdd80ca7ddccb5515d11d34f25085ea0a7978 | 335 | kt | Kotlin | mylibrary/src/main/java/com/esp/library/utilities/data/applicants/addapplication/ESP_LIB_ResponseFileUploadDAO.kt | ahsanm155/ESP_LIBRARY | 11d17817eb75077ac97309509d20fe5adae1bc43 | [
"MIT"
] | null | null | null | mylibrary/src/main/java/com/esp/library/utilities/data/applicants/addapplication/ESP_LIB_ResponseFileUploadDAO.kt | ahsanm155/ESP_LIBRARY | 11d17817eb75077ac97309509d20fe5adae1bc43 | [
"MIT"
] | null | null | null | mylibrary/src/main/java/com/esp/library/utilities/data/applicants/addapplication/ESP_LIB_ResponseFileUploadDAO.kt | ahsanm155/ESP_LIBRARY | 11d17817eb75077ac97309509d20fe5adae1bc43 | [
"MIT"
] | null | null | null | package utilities.data.applicants.addapplication
import java.io.Serializable
import utilities.data.ESP_LIB_Base
class ESP_LIB_ResponseFileUploadDAO : ESP_LIB_Base(), Serializable {
var fileId: String? = null
var downloadUrl: String? = null
companion object {
var BUNDLE_KEY = "ResponseFileUploadDAO"
}
}
| 18.611111 | 68 | 0.743284 |
83dd06e9d6c4c457c67ce05c374d38bde0e45685 | 1,122 | java | Java | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/levelgen/heightproviders/HeightProvider.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/levelgen/heightproviders/HeightProvider.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/levelgen/heightproviders/HeightProvider.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | package net.minecraft.world.level.levelgen.heightproviders;
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import java.util.Random;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.WorldGenerationContext;
public abstract class HeightProvider {
private static final Codec<Either<VerticalAnchor, HeightProvider>> CONSTANT_OR_DISPATCH_CODEC = Codec.either(VerticalAnchor.CODEC, Registry.HEIGHT_PROVIDER_TYPES.byNameCodec().dispatch(HeightProvider::getType, HeightProviderType::codec));
public static final Codec<HeightProvider> CODEC = CONSTANT_OR_DISPATCH_CODEC.xmap((p_161974_) -> {
return p_161974_.map(ConstantHeight::of, (p_161980_) -> {
return p_161980_;
});
}, (p_161976_) -> {
return p_161976_.getType() == HeightProviderType.CONSTANT ? Either.left(((ConstantHeight)p_161976_).getValue()) : Either.right(p_161976_);
});
public abstract int sample(Random pRandom, WorldGenerationContext pContext);
public abstract HeightProviderType<?> getType();
} | 48.782609 | 241 | 0.78164 |
188994e28f3655193d84b02d6976103d13f2f344 | 2,280 | ps1 | PowerShell | TMF/internal/functions/validate/Validate-UserSet.ps1 | verasbr/tenant-management-framework | 7d511cd7c5ff4528f5562874ab378cc6c449a4ef | [
"MIT"
] | 12 | 2021-09-17T15:20:21.000Z | 2022-03-29T13:15:36.000Z | TMF/internal/functions/validate/Validate-UserSet.ps1 | verasbr/tenant-management-framework | 7d511cd7c5ff4528f5562874ab378cc6c449a4ef | [
"MIT"
] | 6 | 2022-03-07T07:47:07.000Z | 2022-03-17T10:37:29.000Z | TMF/internal/functions/validate/Validate-UserSet.ps1 | verasbr/tenant-management-framework | 7d511cd7c5ff4528f5562874ab378cc6c449a4ef | [
"MIT"
] | 3 | 2022-03-07T07:48:38.000Z | 2022-03-17T12:23:43.000Z | function Validate-UserSet
{
<#
.SYNOPSIS
Validates the properties of a userSet complex type
.PARAMETER reference
The id, displayName, userPrincipalName or mailNickname of the referenced resource.
#>
[CmdletBinding()]
Param (
[Parameter(ParameterSetName = "Default")]
[string] $reference,
[ValidateSet("singleUser", "groupMembers", "connectedOrganizationMembers", "requestorManager", "internalSponsors", "externalSponsors")]
[string] $type = "singleUser",
[bool] $isBackup = $false,
[Parameter(Mandatory = $true, ParameterSetName = "RequestorManager")]
[int] $managerLevel,
[System.Management.Automation.PSCmdlet]
$Cmdlet = $PSCmdlet
)
begin
{
if ($managerLevel) {
$type = "requestorManager"
}
}
process
{
if (Test-PSFFunctionInterrupt) { return }
$userSetObject = [PSCustomObject]@{
type = $type
isBackup = $isBackup
}
Add-Member -InputObject $userSetObject -MemberType NoteProperty -Name "@odata.type" -Value ("#microsoft.graph.{0}" -f $type)
if ($type -in @("singleUser", "groupMembers", "connectedOrganizationMembers")) {
Add-Member -InputObject $userSetObject -MemberType NoteProperty -Name reference -Value $reference
Add-Member -InputObject $userSetObject -MemberType ScriptMethod -Name getId -Value {
switch ($this.type) {
"singleUser" {
Resolve-User -InputReference $this.reference -SearchInDesiredConfiguration -Cmdlet $PSCmdlet
}
"groupMembers" {
Resolve-Group -InputReference $this.reference -SearchInDesiredConfiguration -Cmdlet $PSCmdlet
}
"connectedOrganizationMembers" {
Resolve-ConnectedOrganization -InputReference $this.reference -SearchInDesiredConfiguration -Cmdlet $PSCmdlet
}
}
}
}
if ($type -eq "requestorManager") {
Add-Member -InputObject $userSetObject -MemberType NoteProperty -Name managerLevel -Value $managerLevel
}
Add-Member -InputObject $userSetObject -MemberType ScriptMethod -Name prepareBody -Value {
$hashtable = @{
isBackup = $this.isBackup
"@odata.type" = $this."@odata.type"
}
if ($this.getId) {$hashtable["id"] = $this.getId()}
if ($this.managerLevel) {$hashtable["managerLevel"] = $this.managerLevel}
return $hashtable
}
}
end
{
$userSetObject
}
}
| 30.4 | 137 | 0.700877 |
ec17a569874c96b78196ada75c0f5cb2fe1996eb | 117 | dart | Dart | lib/src/utils/cli.data.dart | victoreronmosele/coverde | 1b04d806af05ad9e6a2878bb7a02b533d186b037 | [
"MIT"
] | 17 | 2021-09-25T21:50:01.000Z | 2022-03-24T11:06:12.000Z | lib/src/utils/cli.data.dart | victoreronmosele/coverde | 1b04d806af05ad9e6a2878bb7a02b533d186b037 | [
"MIT"
] | 10 | 2021-10-01T00:17:07.000Z | 2022-03-11T07:41:41.000Z | lib/src/utils/cli.data.dart | victoreronmosele/coverde | 1b04d806af05ad9e6a2878bb7a02b533d186b037 | [
"MIT"
] | 2 | 2021-11-25T15:00:16.000Z | 2022-02-04T21:03:34.000Z | /// The `coverde` CLI name.
const cliName = 'coverde';
/// The `coverde` CLI version.
const cliVersion = '0.1.0+1';
| 19.5 | 30 | 0.641026 |
681eb87d4124ceaa3d7330b21805688823508cd4 | 2,743 | cc | C++ | history/dirhistory/src/v2/tsdata_xdr.cc | nahratzah/monsoon_plus_plus | 789082078f1d474d38056518f66613ed1319181b | [
"BSD-2-Clause"
] | 1 | 2018-03-06T11:15:40.000Z | 2018-03-06T11:15:40.000Z | history/dirhistory/src/v2/tsdata_xdr.cc | nahratzah/monsoon_plus_plus | 789082078f1d474d38056518f66613ed1319181b | [
"BSD-2-Clause"
] | null | null | null | history/dirhistory/src/v2/tsdata_xdr.cc | nahratzah/monsoon_plus_plus | 789082078f1d474d38056518f66613ed1319181b | [
"BSD-2-Clause"
] | null | null | null | #include "tsdata_xdr.h"
#include "xdr_primitives.h"
#include "record_array.h"
#include "tsdata.h"
#include <stack>
#include <tuple>
namespace monsoon::history::v2 {
auto decode(const cache_search_type<dictionary, tsdata_xdr>& cst, dictionary::allocator_type alloc)
-> std::shared_ptr<dictionary> {
auto result = std::allocate_shared<dictionary>(alloc, alloc);
const encdec_ctx& ctx = cst.parent()->get_ctx();
// Build stack of segments.
std::stack<file_segment_ptr> ptrs;
for (std::shared_ptr<const tsdata_xdr> tsd = cst.parent();
tsd != nullptr;
tsd = tsd->get_predecessor()) {
if (tsd->dict_ != file_segment_ptr())
ptrs.push(tsd->dict_);
}
// Decode update for each segment.
while (!ptrs.empty()) {
auto xdr = ctx.new_reader(ptrs.top(), dictionary::is_compressed);
ptrs.pop();
result->decode_update(xdr);
if (!xdr.at_end()) throw dirhistory_exception("xdr data remaining");
xdr.close();
}
return result;
}
tsdata_xdr::tsdata_xdr(std::shared_ptr<tsdata_v2> parent, allocator_type alloc)
: typed_dynamics<dynamics>(parent),
ctx_(parent->get_ctx())
{}
tsdata_xdr::tsdata_xdr(std::shared_ptr<tsdata_xdr> parent, allocator_type alloc)
: typed_dynamics<dynamics>(parent),
ctx_(parent->get_ctx())
{}
tsdata_xdr::~tsdata_xdr() noexcept {}
auto tsdata_xdr::get_dictionary() const
-> std::shared_ptr<const dictionary> {
tsdata_xdr*const parent = dynamic_cast<tsdata_xdr*>(&this->parent());
if (parent != nullptr) return parent->get_dictionary();
return get_dynamics_cache<dictionary>(shared_from_this(), dict_);
}
auto tsdata_xdr::get_dictionary()
-> std::shared_ptr<dictionary> {
tsdata_xdr*const parent = dynamic_cast<tsdata_xdr*>(&this->parent());
if (parent != nullptr) return parent->get_dictionary();
return get_dynamics_cache<dictionary>(shared_from_this(), dict_);
}
auto tsdata_xdr::get_predecessor() const
-> std::shared_ptr<const tsdata_xdr> {
return const_cast<tsdata_xdr&>(*this).get_predecessor();
}
auto tsdata_xdr::get() const
-> std::shared_ptr<const record_array> {
return get_dynamics_cache<record_array>(shared_from_this(), records_);
}
auto tsdata_xdr::get_predecessor()
-> std::shared_ptr<tsdata_xdr> {
if (pred_ == file_segment_ptr()) return nullptr;
return get_dynamics_cache<tsdata_xdr>(std::const_pointer_cast<tsdata_xdr>(shared_from_this()), pred_);
}
auto tsdata_xdr::decode(xdr::xdr_istream& in)
-> void {
ts_ = decode_timestamp(in);
pred_ = in.get_optional(&file_segment_ptr::from_xdr).value_or(file_segment_ptr());
dict_ = in.get_optional(&file_segment_ptr::from_xdr).value_or(file_segment_ptr());
records_.decode(in);
std::ignore = in.get_uint32(); // reserved_
}
} /* namespace monsoon::history::v2 */
| 29.494624 | 104 | 0.725118 |
0c997c75e6f8130a6ad00cdbe08dc81152f2e474 | 1,074 | lua | Lua | day02/main.lua | michaeladler/aoc-2020 | 9027cb3c9f89a2af7a3acd41791dc2dbf021211b | [
"Apache-2.0"
] | null | null | null | day02/main.lua | michaeladler/aoc-2020 | 9027cb3c9f89a2af7a3acd41791dc2dbf021211b | [
"Apache-2.0"
] | null | null | null | day02/main.lua | michaeladler/aoc-2020 | 9027cb3c9f89a2af7a3acd41791dc2dbf021211b | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env luajit
require("io")
require("bit")
local function is_valid(min, max, letter, pw)
local matches = 0
for i = 1, #pw do
local c = pw:sub(i, i)
if c == letter then
matches = matches + 1
end
end
return tonumber(min) <= matches and matches <= tonumber(max)
end
local bxor = bit.bxor
local function is_valid2(min, max, letter, pw)
local found_min = 0
if pw:sub(min, min) == letter then
found_min = 1
end
local found_max = 0
if pw:sub(max, max) == letter then
found_max = 1
end
return bxor(found_min, found_max) == 1
end
local f = io.open("input.txt", "r")
local valid_counts = 0
local valid_counts2 = 0
for line in f:lines() do
local min, max, letter, pw = string.match(line, "([%d]*).([%d]*)[%s*]([%a]*):[%s]*([%a]*)")
if is_valid(min, max, letter, pw) then
valid_counts = valid_counts + 1
end
if is_valid2(min, max, letter, pw) then
valid_counts2 = valid_counts2 + 1
end
end
f:close()
print("Part 1", valid_counts)
print("Part 2:", valid_counts2)
assert(valid_counts == 582, "part1")
assert(valid_counts2 == 729, "part2")
| 21.058824 | 92 | 0.660149 |
562192d9d984042b7ebde4729d812a9b6f2aa069 | 277 | go | Go | msngr/freedesktop/freedesktop_linux_test.go | colt3k/utils | 8fe59a6315a0797a3ee6addb6cc96ea66582b614 | [
"MIT"
] | 3 | 2020-10-07T23:29:33.000Z | 2021-09-13T08:10:16.000Z | msngr/freedesktop/freedesktop_linux_test.go | colt3k/utils | 8fe59a6315a0797a3ee6addb6cc96ea66582b614 | [
"MIT"
] | null | null | null | msngr/freedesktop/freedesktop_linux_test.go | colt3k/utils | 8fe59a6315a0797a3ee6addb6cc96ea66582b614 | [
"MIT"
] | null | null | null | package freedesktop
func Test() {
title := "title"
message := "message"
n := &freedesktop.Notification{
Summary: title,
Body: message,
ExpireTimeout: 500,
AppIcon: "utilities-terminal",
}
if err := n.Send(); err != nil {
t.Error(err)
}
}
| 16.294118 | 38 | 0.584838 |
a144d6a7cfd2eb518524d1c0fb249315f5a84b3b | 2,113 | swift | Swift | ExposureTests/Authentication/SessionTokenSpec.swift | EricssonBroadcastServices/iOSClientExposure | 7adb5e9e0030c566617321c47ff85086260f0e05 | [
"Apache-2.0"
] | null | null | null | ExposureTests/Authentication/SessionTokenSpec.swift | EricssonBroadcastServices/iOSClientExposure | 7adb5e9e0030c566617321c47ff85086260f0e05 | [
"Apache-2.0"
] | 3 | 2018-03-09T06:22:25.000Z | 2021-05-25T14:47:06.000Z | ExposureTests/Authentication/SessionTokenSpec.swift | EricssonBroadcastServices/iOSClientExposure | 7adb5e9e0030c566617321c47ff85086260f0e05 | [
"Apache-2.0"
] | 2 | 2018-03-07T20:49:55.000Z | 2019-02-07T08:14:13.000Z | //
// SessionTokenSpec.swift
// Exposure
//
// Created by Fredrik Sjöberg on 2017-04-24.
// Copyright © 2017 emp. All rights reserved.
//
import Quick
import Nimble
@testable import Exposure
class SessionTokenSpec: QuickSpec {
override func spec() {
super.spec()
describe("AuthorizationHeaders") {
it("should produce authorization headers") {
let token = SessionToken(value: "TOKEN")
let header = token.authorizationHeader
let value:String? = header["Authorization"]
expect(value).toNot(beNil())
expect(value!).to(equal("Bearer "+"TOKEN"))
}
it("Should not init with nil value") {
expect(SessionToken(value: nil)).to(beNil())
let optionalValue: String? = "TEST"
expect(SessionToken(value: optionalValue)).toNot(beNil())
}
it("Should be equatable with matching tokens") {
expect(SessionToken(value: "TEST") == SessionToken(value: "TEST")).to(beTrue())
}
context("Components") {
let validFormat = SessionToken(value: "crm|accountId|userId|hello|1000|2000|false|something|other")
it("Should contain 9 components") {
expect(validFormat.hasValidFormat).to(beTrue())
}
it("should parse components") {
expect(validFormat.crmToken).to(equal("crm"))
expect(validFormat.accountId).to(equal("accountId"))
expect(validFormat.userId).to(equal("userId"))
let aquired: TimeInterval = 1000
let expiration: TimeInterval = 2000
expect(validFormat.acquired).to(equal(aquired))
expect(validFormat.expiration).to(equal(expiration))
expect(validFormat.isAnonymous).to(equal(false))
}
}
}
}
}
| 35.216667 | 115 | 0.523426 |
7534581dc73b824f13d29828b5dca7e476006f60 | 1,846 | cs | C# | EmpowerData/EntityModels/DIA_AppraisalAppointment.cs | HaloImageEngine/EmpowerClaim-hotfix-1.25.1 | 91db2d24682518f3e4a45d2fb3dd123968a8663c | [
"Apache-2.0"
] | null | null | null | EmpowerData/EntityModels/DIA_AppraisalAppointment.cs | HaloImageEngine/EmpowerClaim-hotfix-1.25.1 | 91db2d24682518f3e4a45d2fb3dd123968a8663c | [
"Apache-2.0"
] | null | null | null | EmpowerData/EntityModels/DIA_AppraisalAppointment.cs | HaloImageEngine/EmpowerClaim-hotfix-1.25.1 | 91db2d24682518f3e4a45d2fb3dd123968a8663c | [
"Apache-2.0"
] | null | null | null | using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EmpowerData.EntityModels
{
public partial class DIA_AppraisalAppointment
{
[Key]
public int AppraisalAppointmentSysID { get; set; }
public DateTime SysDate { get; set; }
[Required]
[StringLength(50)]
public string Subject { get; set; }
[Required]
[StringLength(250)]
public string Body { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDayEvent { get; set; }
[StringLength(50)]
public string TimeZoneString { get; set; }
public int? TimeMarkerID { get; set; }
public int? CategoryID { get; set; }
public int EnteredByID { get; set; }
public int? AssignedToID { get; set; }
public int? AppraisalID { get; set; }
public int? ResourceID { get; set; }
public int? ClaimantID { get; set; }
public int? LocationID { get; set; }
public int? ContactID { get; set; }
[StringLength(100)]
public string ContactName { get; set; }
[StringLength(20)]
public string ContactPhone { get; set; }
public int ClaimID { get; set; }
[Required]
[StringLength(10)]
public string ClaimNo { get; set; }
public int Importance { get; set; }
public int SqlResourceID { get; set; }
public int LastUpdatedByID { get; set; }
public DateTime LastUpdatedDate { get; set; }
[Column(TypeName = "timestamp")]
[MaxLength(8)]
[Timestamp]
public byte[] RecordVersion { get; set; }
public virtual CMS_Appraisals Appraisal { get; set; }
}
}
| 23.974026 | 61 | 0.586132 |
93bb252e8bccbc25f53451f447137c6e3bb9a9dd | 83,724 | html | HTML | library/www.baldurbjarnason.com/notes/ebook-widget-semantics/index.html | extratone/extratone | a18e3ac94527626f27dd5447257c9785b7f5d167 | [
"MIT"
] | 2 | 2021-06-09T20:03:11.000Z | 2021-09-18T21:34:18.000Z | library/www.baldurbjarnason.com/notes/ebook-widget-semantics/index.html | extratone/extratone | a18e3ac94527626f27dd5447257c9785b7f5d167 | [
"MIT"
] | 497 | 2020-11-23T12:22:45.000Z | 2022-01-17T02:03:22.000Z | library/www.baldurbjarnason.com/notes/ebook-widget-semantics/index.html | extratone/extratone | a18e3ac94527626f27dd5447257c9785b7f5d167 | [
"MIT"
] | null | null | null | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>The semantics of ebook widgets – Baldur Bjarnason</title>
<meta
name="description"
content="
Over the past few days I’ve had several interesting conversations on ebooks, interactivity, widgets, standardisation, and other issues that have cropped up as a result of Apple forking the ePub3 format.
"
/>
<meta name="image" content="">
<meta itemprop="name" content="The semantics of ebook widgets" />
<meta
itemprop="description"
content="
Over the past few days I’ve had several interesting conversations on ebooks, interactivity, widgets, standardisation, and other issues that have cropped up as a result of Apple forking the ePub3 format.
"
/>
<meta itemprop="image" content="">
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="The semantics of ebook widgets" />
<meta
name="twitter:description"
content="
Over the past few days I’ve had several interesting conversations on ebooks, interactivity, widgets, standardisation, and other issues that have cropped up as a result of Apple forking the ePub3 format.
"
/>
<meta name="og:title" content="The semantics of ebook widgets" />
<meta
name="og:description"
content="
Over the past few days I’ve had several interesting conversations on ebooks, interactivity, widgets, standardisation, and other issues that have cropped up as a result of Apple forking the ePub3 format.
"
/>
<meta name="og:url" content="https://www.baldurbjarnason.com/notes/ebook-widget-semantics/" />
<meta name="og:site_name" content="Baldur Bjarnason" />
<meta name="og:type" content="article" />
<meta name="article:author" content="https://www.baldurbjarnason.com/" />
<meta name="author" content="Baldur Bjarnason" />
<meta name="article:tag" content="" />
<link href="https://www.baldurbjarnason.com/fonts/literata/literata.css" rel="stylesheet" />
<link rel="stylesheet" href="https://www.baldurbjarnason.com/styles/main.min.3a98d38583d9a7fb72c3343ba33af9ea82872d943b7705b3fc07a60f39c06415.css" />
<link href="https://www.baldurbjarnason.com/stylesheets/syntax.css" rel="stylesheet" />
<link href="../../feed.xml" rel="alternate"
type="application/rss+xml" title="All posts for Baldur Bjarnason" /> <link
href="../../index.xml" rel="feed" type="application/rss+xml"
title="All posts for Baldur Bjarnason" />
<link href="https://micro.blog/baldur" rel="me" />
</head>
<body class="page">
<nav class="Top" aria-label="Site navigation">
<ul>
<li><a href="../../../baldurbjarnason.com/index.html#archive">Writing</a></li>
<li><a href="https://www.baldurbjarnason.com/work/2021">Work</a></li>
<li><a href="../../../notes.baldurbjarnason.com/index.html">Notes</a></li>
<li><a href="https://github.com/baldurbjarnason">GitHub</a></li>
<li><a href="mailto:baldur.bjarnason@gmail.com">Email</a></li>
</ul>
</nav>
<header class="header">
<div class="Description">
<div class="Title"><a href="../../../baldurbjarnason.com/index.html">Baldur Bjarnason</a></div>
<p>
<em>
… web developer, writer, and consultant based in Hveragerði,
Iceland.
</em>
</p>
<p>
I write about web dev, interactive media, digital publishing, and
product development.
</p>
<p>
<a href="https://www.baldurbjarnason.com/work/2021">I’m available for consulting and hire</a>.
</p>
</div>
</header>
<main>
<div class="FrontBody">
<header id="start">
<aside class="Date">
<time datetime="2012-02-04T00:00:00Z"
>4 February 2012</time
>
</aside>
<h1>The semantics of ebook widgets</h1>
<div class="Tags">
</div>
</header>
<article class="post">
<p>Most of them have been people making very good points that have forced me to clarify my thoughts and reconsider some of my ideas.</p>
<p>One such conversation was the following email exchange with <a href="http://grantsutherland.net/">Grant Sutherland</a> (posted with his permission).</p>
<p>We didn’t quite manage to convince each other, but I think we each made a pretty good case for our respective approaches for the discussion to be useful and educational to others, no matter which side you take.</p>
<p>Both of our respective principles and approaches to developing more interactive ebooks are, I think, much healthier than the one-sided and opaque approach Apple has decided to take.</p>
<hr />
<p><em>From Grant:</em></p>
<blockquote>
<p>Hi Baldur,</p>
<p>I’m a writer, currently published by Macmillan.</p>
<p>I’ve been interested in the development of ebooks for some while, and have been enjoying your posts.</p>
<p>( I wrote something last year along similar lines, probably out of date).
<a href="http://grantsutherland.net/essays/traditional_publishing_is_a_burning_platform.html">Traditional Publishing is a Burning Platform</a></p>
<p>In relation to your recent exchange with Joseph Pearson, I agree with you both about the widgets being authored declaratively (with bindings).</p>
<p>However I strongly disagree that microformats are the appropriate solution for books (however useful they might be on the web). The ‘vocabularies’ extension in epub3 allows for any numbers of xml dialects to be dropped into the basic xhtml5. Why not use them? They’ve already been developed rigorously (e.g. ChemML, KML) and something like TEI seems to me ideally suited as a basis for interactivity/enhancement in a variety of non-fiction ebooks. Microformats are meant to evolve towards useful common standards; but in this case, the common standards already exist. </p>
<p>Why reinvent the wheel?</p>
<p>Anyway, just a thought.</p>
<p>Regards, Grant</p>
<p><a href="https://www.baldurbjarnason.com/notes/ebook-widget-semantics/%C2%A0http://grantsutherland.net/"> http://grantsutherland.net</a></p>
</blockquote>
<hr />
<p><em>To which I replied:</em></p>
<p>That’s a valid point and it’s one I debated a lot when I was an academic studying and authoring interactive projects. Generally speaking, only a minority thought it was a good idea to reuse these vocabularies because they simple weren’t designed for our purposes (creating interactive texts). I was a part of that minority in favour of reuse. I changed my mind as soon as I gained more practical experience in authoring interactive projects.</p>
<p>There’s only one, widely accepted, open format that suits our purposes: HTML+CSS+JS. There hasn’t been a need to create a new format for interactive hypertexts (which is what we are talking about, since text is a subset of hypertext) because we already have one. The problem arises when we remove JS from that equation; we need simple methods of getting back some of the interactive functionality we’ve lost. None of the other pre-existing formats suit our purposes because we’ve just given up on the only one that does.(^1)</p>
<p>So, short answer: Because it’s not reinventing the wheel. Not really.</p>
<p>Most of those XML formats, like TEI, are both specialised and largely focus on meaning (that is, preserving a fidelity of the information it carries). But when you are creating an interactive project you need to explicitly declare your intent: this is how this element is supposed to behave. Using existing XML formats for this purpose can get extremely complex and awkward because it’s not what they were designed to do. Relying on a reading system to infer a behaviour based on semantics is an extremely limited way to author interactive ebooks.</p>
<p>(TEI is also bloody complicated.)</p>
<p>Microformats is a term that Joseph Pearson brought up and I’m not quite sure I agree with it being applicable in this circumstance, because microformats generally describe semantics and meaning and not behaviour and intent.</p>
<p>A simple OBJECT tag, configured by linking to something like a json file using the PARAM tag, is much easier to author than any of these pre-existing XML formats, and has the added benefit of being both explicit in terms of the behaviour that’s desired, and flexible in terms of how the reading system wants to implement it. It’s also something that’s very easy to implement in almost any programming language. None of these apply to a complex XML vocabulary, even if it really did what we need it to do. </p>
<p>A small set of simple but flexible widgets (behavioural objects) is very much outside the remit of any of the preexisting formats.</p>
<p>The only exception I can think of are SVG+SMIL which could cover a lot of bases but even that is still quite complicated both to author and implement (which is why support is so sparse and buggy, even among web browsers).</p>
<p>And even then SVG+SMIL doesn’t cover some of the basic behaviours we need.</p>
<p>I’d love to have it, though.</p>
<p>For authored interactivity we either need javascript (to implement and attach behaviour to semantic elements) or we need simple but configurable objects. Any other solution is too complex to author and implement, or simply doesn’t solve our problem.</p>
<p>For the record, I don’t think the iBooks widgets cover exactly our needs either. They are a starting point.</p>
<p>So, that’s my reasoning. I hope it makes some sort of sense :-)</p>
<p>best,
baldur</p>
<p><em>The footnote:</em></p>
<p>(^1): There are very good reasons for abandoning javascript in the context of ebooks. The biggest reason is security. An ebook is a much more persistent object than a web page. Turning an ebook into a fully-fledged javascript app platform opens readers up to exactly the same security issues as any other app platform, viruses, trojans, worms, etc. etc. It’s understandable that many ebook platform vendors might want to avoid that. In many cases javascript support may simply present substantial and expensive problems that are very hard to solve.</p>
<p>Consider for example iBooks, the only epub platform that supports javascript: It is buggy as hell and updates regularly break working code. It breaks away from established web behaviours in subtle and not so subtle ways that is complex to tackle. And it crashes. A lot. Especially when you are on an iPad 1.</p>
<hr />
<p>Addendum. I do miss proper javascript support in ebooks. It has the merit of years of development and testing and phenomenal mindshare. But, I think it’s clear at this point that cross-platform javascript is a non-starter in the ebook realm. If that’s the case, we need to start thinking about alternatives.</p>
<hr />
<p><em>From Grant:</em></p>
<blockquote>
<p>Hi Baldur,</p>
<p>Thanks for the thoughtful reply. I take your well-made points.</p>
<p>I think your key statement is this one:</p>
<p>For authored interactivity we either (a) need javascript to implement and attach behaviour to semantic elements or we need (b) simple but configurable objects. Any other solution is too complex to author and implement, or simply doesn’t solve our problem.</p>
<p>My own belief is that certain classes of texts are well-suited to solution (a), whereas others - and I would guess that among these are the type of interactive texts you’re working on - are more suited to solution (b).</p>
<p>As an example of a text of type (a), take any classic history. By impregnating the text at appropriate points with the various <code><bio></code>,<code><time></code> and <code><geo></code> related tags of the TEI, a work like ‘Decline and Fall…’ could be gently enhanced by the reading system with a sidebarred timeline, map and bio reference. The primary purpose of this type of enhancement (and, in my view, probably the only useful kind of enhancement possible in this type of work) is navigational. It is clearly not a hugely ambitious aim, but it has the inestimable advantage, over the many ‘snake-oil’ type’enhancements we’ve lately seen, of actually being useful. Because this is the kind of text I tend to read, my view is admittedly skewed toward this solution. </p>
<p>(In a way, the Kindle’s X-Ray facility is something like this, but prone to error because it’s using text-mining to make the semantic enhancements. And it’s ugly.)</p>
<p>As to texts of type (b), I think you are absolutely right.</p>
<p>There is obviously a massive problem here with the stability of this type of book. And I think the lessons to be learned about ‘maintainability’ will be learned from the past experiences and current best-practices of programmers.</p>
<p>The big lesson I see is that ‘unstable’ is the natural state in this world. I’m reminded of the old joke in biology: ‘We biologists have a special word for obects in a stable state - dead.’</p>
<p>Publishers want ‘stable’, but I don’t think they’re ever going to get it in this area. The best they can hope for to manage the ‘instability’ of these books in a commercially viable manner.</p>
<p>My own guess is that books will come to exist on a (lumpy) spectrum of stability that looks something like this:</p>
<ol>
<li>Plain-text, stored on clay tablets (the first, and still the best for longevity)</li>
<li>Plain-text, stored on paper</li>
<li>Plain-text semantically enhanced, stored on computers. Behaviors (if any) determined by reading system.</li>
<li>Plain-text semantically+programmaticaly enhanced, stored on computers. Behaviours (if any) determined by some combination of reading system and program embedded in text.</li>
</ol>
<p>With regard to your remarks about the widgetization of behaviours, I agree that SVG+SMIL is the only sane long-term answer. In the meantime, here are a couple of links that might interest you (if you’re not aware of them already):</p>
<p><a href="http://www.simile-widgets.org/">http://www.simile-widgets.org/</a></p>
<p><a href="http://lively-kernel.org/">http://lively-kernel.org</a></p>
<p>Simile uses json to populate a set of predetermined html/css/javascript widgets.
Lively-kernel is less straightforward, and more buggy. It’s widgets are primarily customizable javascript objects. But if you look here:</p>
<p><a href="http://lively-kernel.org/repository/webwerkstatt/documentation/HowConnectWorks.xhtml">http://lively-kernel.org/repository/webwerkstatt/documentation/HowConnectWorks.xhtml</a></p>
<p>you’ll see that they use a similar mechanism to that <code><object></code> PARAM technique that you’re suggesting (but in their case from one highly configurable javascript object to another, rather than from json to html.</p>
<p>Hope some of this is of some use to you.</p>
<p>Regards, Grant</p>
</blockquote>
<hr />
<p><em>And me:</em></p>
<p>I’d like to start off by saying that I generally agree with you, in an ideal world semantic text combined with authored javascript would be the ideal solution for creating interactive texts. The only point I’d make is that in this circumstance the programmer becomes a co-author of the text (interactivity is an act of authorship) but those who can work in this context that embrace this and partner with a skilled programmer will end up creating remarkable things.</p>
<p>There is a subset of interactive patterns that can’t be tied into semantics since the behaviour is the primary carrier of meaning (understanding is derived form the actions the reader takes). In this case you have to author a non-semantic widget into the text. Texts full of this behaviour lend themselves to solution (b), as you call it. They are also, in my opinion, generally only appropriate to non-fiction; like you I’m skeptical of the benefits of ‘enhancing’ narrative text.</p>
<p>Then there’s the issue of supporting true interactive narratives, creating a platform that can support hypertext and non-linear stories.</p>
<p>In either case, creating these texts hasn’t been that much of a problem because we have had a tool at hand: Javascript.</p>
<p>The problem is that javascript in ebooks is looking like a non-starter at the moment. The only major platform that implements it is iBooks and even there support is buggy enough to make development substantially more difficult than developing a scripted web site. I think it’s pretty much a certainty at this point, based on the discussions and debates I’ve witnessed and participated in, that javascript won’t be universally supported in ebooks like it is on the web. </p>
<p>Which, really, is the origin of my conundrum.</p>
<p>On the stability of these texts:</p>
<p>Very true, and it’s a problem I and other academics who were researching and teaching in this field ten years ago have had to tackle again and again, and, believe it or not, what we have now is much better than it was.</p>
<p>Most of the interactive works I studied ten years ago and I cited in my research are unplayable now. Hypercard projects, Director-authored CD-ROMs, old flash files, and plain old executable programs, many of the big, influential, texts are now hard to access, locked in a dead platform (Mac Classic). So, this has been a subject of debate for decades now. There was a lot of worrying and scaremongering about the issue at the time, but it ended up not being as much of an issue as people expected.</p>
<p>Of course, some works have been lost. It’s hard to find and play a Voyager Expanded Book today. But the solution was articulated by Mark Bernstein (of Eastgate Systems, publisher of hypertext, maker of tools, etc.): The only thing that preserves works is interest. </p>
<p>When there is interest, someone will make sure that the work is available and accessible (see, for example the conversion and update of the “If Monks Had Macs” CD-ROM).</p>
<p>When there isn’t interest, no amount of open formats or standardisation will save the work from oblivion. </p>
<p>Of course, there are exceptions such as the rights situation with many of the Voyager Expanded Books, but that kind of legal bind won’t be solved by any amount of standardisation.</p>
<p>And, as I wrote, we’re in a much better place now than we were then. We have an open standard, ePub, which, even with books published on the Kindle, will remain an archival and authoring format.</p>
<p>Extending that format with a set of documented, standardised (even if just a de facto standard) objects will not threaten their archivability in any way, provided we do it in a sensible manner.</p>
<p>Which brings me to Apple’s new iBooks 2.0 format. That format runs the risk of instability and obsolescence. It’s undocumented, intentionally incompatible with the standard, extends it in odd ways. It’s a very problematic approach to creating interactive texts.</p>
<p>With javascript ruled out, we need to establish a path forward in ebook interactivity that isn’t dominated by the proprietary and exclusionary path Apple is taking. The only way I see of doing that is describing a set of simple, but configurable, interactive objects that can be combined and used to create fairly rich works.</p>
<p>Both the Simile Widgets and Lively Kernel are similar to what I think we need, but not quite. (In either case, projects like these are ruled out by the fact that javascript is a non-starter on many ebook platforms.) The Simile Widgets are a little bit too specialised and complex. Lively Kernel is too tightly integrated with javascript both conceptually and in implementation.</p>
<p>I think the next step for me would be to write up a description of the forms of interactivity I think are needed for ebooks (there are a few basic actions that can be combined to create 90% of what authors of interactive works need) followed by a list of widgets, with suggested format extensions, that would implement those forms of interactivity.</p>
<p>I wouldn’t be surprised if, with a little bit of thought, those of us who want this can come up with conventions that are closer to the semantic ideal than the hodgepodge of opaque data that Apple is using.</p>
<p>I think, for example, that epub:type can be put to effective use. One approach would be to create a vocabulary of interactivity for epub:type which might give us the best of both worlds—if we assume that an interactive act has meaning in and of itself, that is.</p>
<p>The analogy would be ‘footnote’, which is a name of a print design feature that has attained an added meaning derived from its common use. If we define a epub:type vocabulary for commonly used interactive design features, especially those that have attained some added meaning from repeated practice, then I think we would have something that is sustainable, usable, and would satisfy the qualms of most.</p>
<p>I’ve really enjoyed this exchange. :-) Would you mind if I posted this conversation on my website? I won’t do it if you’d rather I didn’t, but I think a lot of people would find it interesting to see an exchange that presented both sides equally like this.</p>
<p>best, baldur</p>
<hr />
<p>References:</p>
<ul>
<li><a href="http://idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-content-type-attribute">epub:type in the ePub3 specification</a></li>
<li><a href="http://idpf.org/epub/vocab/structure/">EPUB 3 Structural Semantics Vocabulary</a></li>
<li><a href="../the-ibooks-textbook-format/index.html">The iBooks 2.0 textbook format</a></li>
<li><a href="../the-ibooks-builtin-widgets/index.html">The iBooks 2.0 built-in widgets</a></li>
<li><a href="../the-pros-and-cons-of-iBooks-2/index.html">The pros and cons of the iBooks 2.0 textbook format</a></li>
<li><a href="http://blog.booki.sh/blog/post/a-favour-from-goliath/">A favour from Goliath: How Apple does ebook widgets right</a></li>
<li><a href="../widgets-javascript/index.html">iBooks widgets – to javascript or not to javascript</a></li>
</ul>
<footer>
<div class="FooterNav">
<p class="left">
<a href="https://www.baldurbjarnason.com/notes/widgets-javascript/"
><svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path d="M19 12H6M12 5l-7 7 7 7" />
</svg>
iBooks widgets – to javascript or not to javascript</a
>
</p>
<p class="right">
<a href="https://www.baldurbjarnason.com/notes/epub-widgets-and-windows/"
>ePub windows and widgets – a proposal
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path d="M5 12h13M12 5l7 7-7 7" /></svg></a
>
</p>
</div>
<form
action="https://app.convertkit.com/forms/1092832/subscriptions"
class="seva-form formkit-form"
method="post"
data-sv-form="1092832"
data-uid="17fe25197d"
data-format="inline"
data-version="5"
data-options='{"settings":{"after_subscribe":{"action":"message","redirect_url":"","success_message":"Success! Now check your email to confirm your subscription."},"return_visitor":{"action":"hide","custom_content":""},"recaptcha":{"enabled":false}},"version":5}'
min-width="400 500 600 700 800"
>
<div class="formkit-header" data-element="header">
<h2>Join my Newsletter</h2>
</div>
<p>
Do you ever wonder why a newly released open source project matters? Why it
doesn't? How new or old standards or specifications affect your work? Why
the web, tech, and publishing are the way they are?
</p>
<p>
This is an unapologetically political newsletter about tech, the web, and
publishing—with context.
</p>
<p>
Because, to decide whether to use a piece of software, web standard, or open
source project, you need to know
<em><strong>why</strong></em> it‘s interesting, not just
<em><strong>that</strong></em> it‘s interesting.
</p>
<p
data-element="fields"
data-stacked="false"
class="seva-fields formkit-fields"
>
<label for="email_address" class="visually-hidden"
>Your email address</label
>
<input
class="formkit-input"
name="email_address"
id="email_address"
placeholder="example@example.com"
required=""
type="email"
/>
<button data-element="submit" class="formkit-submit formkit-submit">
<span>Subscribe</span>
</button>
</p>
<p class="formkit-guarantee" data-element="guarantee">
I won't send you spam. Unsubscribe at any time.
</p>
</form>
</footer>
</article>
</div>
<h2 id="archive">Writing</h2>
<ul class="FrontArchive">
<li>
<a href="../../2021/ways-of-reading/index.html"
>Ways of reading without the influence of community</a
>
<span class="Date">6 July 2021</span>
</li>
<li>
<a href="../../2021/the-oss-bubble-and-the-blogging-bubble/index.html"
>The Open-Source Software bubble that is and the blogging bubble that was</a
>
<span class="Date">11 May 2021</span>
</li>
<li>
<a href="../../2021/you-are-what-you-do/index.html"
>You are what you do, not what you say or write</a
>
<span class="Date">4 May 2021</span>
</li>
<li>
<a href="../../2021/the-curious-case-of-the-crashing-conic-gradient/index.html"
>The Curious Case Of The Crashing Conic Gradient And How I Used A Technique I Learned In The 90s To Fix It</a
>
<span class="Date">28 April 2021</span>
</li>
<li>
<a href="../../2021/100-things-every-web-developer-should-know/index.html"
>136 facts every web dev should know before they burn out and turn to landscape painting or nude modelling</a
>
<span class="Date">21 April 2021</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/work/2021/"
>I’m available for work</a
>
<span class="Date">20 April 2021</span>
</li>
<li>
<a href="../../2021/which-kind-of-web-developer-are-you/index.html"
>Which type of novelty-seeking web developer are you?</a
>
<span class="Date">31 March 2021</span>
</li>
<li>
<a href="../../every-day-a-fair-warning/index.html"
>Every Day; a Fair Warning (You Should Read These Articles)</a
>
<span class="Date">3 March 2020</span>
</li>
<li>
<a href="../../2020/weeknote-3/index.html"
>Weeknote 3 - Resistance and the dull blade</a
>
<span class="Date">10 February 2020</span>
</li>
<li>
<a href="../../2020/weeknote-2/index.html"
>Weeknote 2 (2020) - News, Bad News, and Star Wars</a
>
<span class="Date">2 February 2020</span>
</li>
<li>
<a href="../../2020/weeknote-1/index.html"
>Weeknote 1 (2020) - Ending the hiatus</a
>
<span class="Date">26 January 2020</span>
</li>
<li>
<a href="../../the-ed-tech-conundrum/index.html"
>The Ed Tech Conundrum</a
>
<span class="Date">2 January 2020</span>
</li>
<li>
<a href="../../past-present-future-web/index.html"
>Thinking about the past, present, and future of web development</a
>
<span class="Date">1 January 2020</span>
</li>
<li>
<a href="../../the-weakened-web/index.html"
>The Web Falls Apart</a
>
<span class="Date">3 November 2019</span>
</li>
<li>
<a href="../../weeknote-19/index.html"
>Weeknote 19 ─ blog redesign and changes at work</a
>
<span class="Date">27 October 2019</span>
</li>
<li>
<a href="../../life-and-lemonades/index.html"
>When life hands you lemonades, sit down and contemplate the meaning of life</a
>
<span class="Date">10 September 2019</span>
</li>
<li>
<a href="../../weeknote-18/index.html"
>Weeknote 18 - Uncertainty and Discomfort</a
>
<span class="Date">11 August 2019</span>
</li>
<li>
<a href="../../weeknote-17/index.html"
>Web Dev: The Red Queen Wire Mommy of Modern Tech</a
>
<span class="Date">6 August 2019</span>
</li>
<li>
<a href="../../weeknote-16/index.html"
>Weeknote 16 – Vacation</a
>
<span class="Date">29 July 2019</span>
</li>
<li>
<a href="../../weeknote-15/index.html"
>Weeknote 15 - Counting Down the Days</a
>
<span class="Date">1 July 2019</span>
</li>
<li>
<a href="../../weeknote-14/index.html"
>Weeknote 14 - Shadows and DOMs</a
>
<span class="Date">25 June 2019</span>
</li>
<li>
<a href="../../weeknote-13/index.html"
>Weeknote 13 - The weight of deadlines</a
>
<span class="Date">16 June 2019</span>
</li>
<li>
<a href="../../webby-things-1/index.html"
>That Web Dev Thing Where Everybody Says Something Clever Involving Toast</a
>
<span class="Date">15 June 2019</span>
</li>
<li>
<a href="../../swiftui-macos-privacy-web/index.html"
>SwiftUI, Privacy, macOS, and the Web</a
>
<span class="Date">9 June 2019</span>
</li>
<li>
<a href="../../weeknote-12/index.html"
>Weeknote 12 - The genres of web media</a
>
<span class="Date">5 June 2019</span>
</li>
<li>
<a href="../../the-aesthetics-of-concentration/index.html"
>The Aesthetics of Concentration</a
>
<span class="Date">3 June 2019</span>
</li>
<li>
<a href="../../weeknote-11/index.html"
>Weeknote 11 - do I have focus?</a
>
<span class="Date">29 May 2019</span>
</li>
<li>
<a href="../../weeknote-10/index.html"
>Weeknote 10 - A clear view and more reading</a
>
<span class="Date">20 May 2019</span>
</li>
<li>
<a href="../../2019/05/12/weeknote-9-being-contemplative-finishing-a-photo-project/index.html"
>Weeknote 9 - Being contemplative, finishing a photo project</a
>
<span class="Date">12 May 2019</span>
</li>
<li>
<a href="../../2019/05/05/weeknote-8-moving-endgame-and-more-musings-on-colour/index.html"
>Weeknote 8 – Moving, Endgame, and more musings on colour</a
>
<span class="Date">5 May 2019</span>
</li>
<li>
<a href="../../2019/04/29/weeknote-7-story-length-and-that-thing-about-colour/index.html"
>Weeknote 7 - Story length and that thing about colour</a
>
<span class="Date">29 April 2019</span>
</li>
<li>
<a href="../../2019/04/22/weeknote-6-star-trek-rest-and-spring-finally-arrives/index.html"
>Weeknote 6 – Star Trek, rest and spring finally arrives</a
>
<span class="Date">22 April 2019</span>
</li>
<li>
<a href="../../2019/04/14/weeknote-5-stuff-comics-superheroes-and-other-nonsense/index.html"
>Weeknote 5 – Stuff, comics, superheroes, and other nonsense</a
>
<span class="Date">14 April 2019</span>
</li>
<li>
<a href="../../2019/04/07/weeknote-4-tv-week-with-the-expanse/index.html"
>Weeknote 4 – TV week with The Expanse</a
>
<span class="Date">7 April 2019</span>
</li>
<li>
<a href="../../2019/03/31/weeknote-3-mvps-fatigue-and-emotional-crutches/index.html"
>Weeknote 3 — MVPs, fatigue, and emotional crutches</a
>
<span class="Date">31 March 2019</span>
</li>
<li>
<a href="../../2019/03/24/weeknote-2-web-development-mistakes-mary-sues-and-icy-spring/index.html"
>Weeknote 2 - Web Development Mistakes, Mary Sues, and Icy Spring</a
>
<span class="Date">24 March 2019</span>
</li>
<li>
<a href="../../2019/03/18/weeknote-1/index.html"
>Weeknote 1</a
>
<span class="Date">18 March 2019</span>
</li>
<li>
<a href="../../2019/02/12/hitchcock-and-the-author-construct/index.html"
>Hitchcock and the author construct</a
>
<span class="Date">12 February 2019</span>
</li>
<li>
<a href="../../2018/11/03/seams-stitches-and-the-decline-of-the-mac/index.html"
>Seams, Stitches, And The Decline Of The Mac</a
>
<span class="Date">3 November 2018</span>
</li>
<li>
<a href="../../2018/09/03/neither-paper-nor-digital-does-active-reading-well/index.html"
>Neither Paper Nor Digital Does Active Reading Well</a
>
<span class="Date">3 September 2018</span>
</li>
<li>
<a href="../../2018/01/07/leftover-thoughts-from-2017/index.html"
>Leftover Thoughts From 2017</a
>
<span class="Date">7 January 2018</span>
</li>
<li>
<a href="../under-engineering-websites/index.html"
>Over-engineering is under-engineering</a
>
<span class="Date">25 November 2017</span>
</li>
<li>
<a href="../the-process-is-the-thing/index.html"
>The process is the thing</a
>
<span class="Date">23 March 2017</span>
</li>
<li>
<a href="../vonbedon-notes-on-a-project/index.html"
>Von Be Don: A few notes on a recent digital publishing project in Iceland</a
>
<span class="Date">19 February 2017</span>
</li>
<li>
<a href="../why-drm-is-a-problem-for-the-w3c/index.html"
>W3C and EME: it isn't about preventing DRM but saving the W3C</a
>
<span class="Date">14 February 2017</span>
</li>
<li>
<a href="../for-the-want-of-an-indirect-pointer/index.html"
>Unpopular opinion: dismissing indirect pointers is a mistake</a
>
<span class="Date">4 February 2017</span>
</li>
<li>
<a href="../feels-like-poison/index.html"
>Anger feels like poison</a
>
<span class="Date">24 January 2017</span>
</li>
<li>
<a href="../is-js-more-fragile/index.html"
>Is JavaScript more fragile?</a
>
<span class="Date">7 December 2016</span>
</li>
<li>
<a href="../progressive-enhancement-debate/index.html"
>Debating Progressive Enhancement</a
>
<span class="Date">5 December 2016</span>
</li>
<li>
<a href="../the-less-pro-apple/index.html"
>The downside of believing in Apple</a
>
<span class="Date">1 November 2016</span>
</li>
<li>
<a href="../icelandic-politics-primer/index.html"
>A short primer on Icelandic politics on the day of the 2016 election</a
>
<span class="Date">29 October 2016</span>
</li>
<li>
<a href="../web-media-tragedy/index.html"
>The Tragedy/Farce of the Open Web according to journalists</a
>
<span class="Date">18 October 2016</span>
</li>
<li>
<a href="../debating-web-development/index.html"
>Notes on debating for the web development community</a
>
<span class="Date">17 October 2016</span>
</li>
<li>
<a href="../addendum-on-coupling-and-commodification/index.html"
>Addendum on loose coupling and the iOS App Store</a
>
<span class="Date">11 October 2016</span>
</li>
<li>
<a href="../idle-sunday-thoughts-on-modularity/index.html"
>Idle thoughts on modularity and loose coupling in digital media</a
>
<span class="Date">9 October 2016</span>
</li>
<li>
<a href="../when-fear-is-rational/index.html"
>When fear is rational</a
>
<span class="Date">24 June 2016</span>
</li>
<li>
<a href="../once-upon-a-time-there-was-word/index.html"
>Once upon a time, I couldn't imagine a better word processor than Word</a
>
<span class="Date">7 June 2016</span>
</li>
<li>
<a href="../a-thought-to-consider/index.html"
>A thought to consider</a
>
<span class="Date">24 May 2016</span>
</li>
<li>
<a href="../thoughts-on-standardisation/index.html"
>A few thoughts on standardisation, W3C, and the IDPF</a
>
<span class="Date">16 May 2016</span>
</li>
<li>
<a href="../zero-marginal-cost/index.html"
>Filling in the gaps – the dynamics of zero marginal cost</a
>
<span class="Date">21 April 2016</span>
</li>
<li>
<a href="../choosing-a-host/index.html"
>Which CMS/blog system would you choose?</a
>
<span class="Date">12 April 2016</span>
</li>
<li>
<a href="../some-notes-on-security/index.html"
>A few simplified points on web and document security</a
>
<span class="Date">30 March 2016</span>
</li>
<li>
<a href="../judge-the-work/index.html"
>Judge the work</a
>
<span class="Date">21 January 2016</span>
</li>
<li>
<a href="../why-did-paul-graham/index.html"
>Why did Paul Graham argue against equality?</a
>
<span class="Date">13 January 2016</span>
</li>
<li>
<a href="../purpose-joy-capability/index.html"
>Purpose, Joy, Capability</a
>
<span class="Date">4 January 2016</span>
</li>
<li>
<a href="../fix-the-app-store/index.html"
>You can't fix the App Store, so here's how you fix it</a
>
<span class="Date">20 November 2015</span>
</li>
<li>
<a href="../twitter-troubles/index.html"
>Why I am worried about Twitter and why you should be too</a
>
<span class="Date">4 November 2015</span>
</li>
<li>
<a href="../the-crossroads/index.html"
>The crossroads or the wilderness</a
>
<span class="Date">23 October 2015</span>
</li>
<li>
<a href="../people-problems/index.html"
>You can't solve people problems with software</a
>
<span class="Date">28 September 2015</span>
</li>
<li>
<a href="../ad-blockers/index.html"
>The discussion about ad blocking is very dumb (but not in the way you think)</a
>
<span class="Date">18 September 2015</span>
</li>
<li>
<a href="../this-is-a-podcast/index.html"
>This is not a book, but it is a podcast</a
>
<span class="Date">10 September 2015</span>
</li>
<li>
<a href="../a-week-of-this-is-not-a-book/index.html"
>A week of 'This is not a book'</a
>
<span class="Date">7 September 2015</span>
</li>
<li>
<a href="../launching-thisisnotabook/index.html"
>Launching "This is not a book" – what it is and why you should be interested</a
>
<span class="Date">1 September 2015</span>
</li>
<li>
<a href="../my-kingdom-for-a-new-bookstore/index.html"
>My kingdom for a new bookstore</a
>
<span class="Date">28 August 2015</span>
</li>
<li>
<a href="../modern-software-sucks/index.html"
>Modern software sucks</a
>
<span class="Date">26 August 2015</span>
</li>
<li>
<a href="../the-cost-benefit/index.html"
>The cost versus benefits of disorganised programming power</a
>
<span class="Date">25 August 2015</span>
</li>
<li>
<a href="../OSS-and-money/index.html"
>Who benefits the most from Open Source Software?</a
>
<span class="Date">25 August 2015</span>
</li>
<li>
<a href="../sex-apocalypse/index.html"
>Sex Apocalypse Later</a
>
<span class="Date">24 August 2015</span>
</li>
<li>
<a href="../that-amazon-thing/index.html"
>Random thoughts on work and that Amazon thing</a
>
<span class="Date">23 August 2015</span>
</li>
<li>
<a href="../bookmarks-great-caper/index.html"
>Bookmarks – UI flaws and other great capers</a
>
<span class="Date">14 August 2015</span>
</li>
<li>
<a href="../bookmarks-ad-blockers-again/index.html"
>Bookmarks – learnable programming</a
>
<span class="Date">13 August 2015</span>
</li>
<li>
<a href="../bookmarks-midweek-blues/index.html"
>Bookmarks – More money for open-source</a
>
<span class="Date">12 August 2015</span>
</li>
<li>
<a href="../bookmarks-leaving-bosses/index.html"
>Bookmarks – Leaving bosses</a
>
<span class="Date">11 August 2015</span>
</li>
<li>
<a href="../bookmarks-getting-better/index.html"
>Bookmarks – Promoting other people's work</a
>
<span class="Date">10 August 2015</span>
</li>
<li>
<a href="../bookmarks-thingamabob/index.html"
>Bookmarks – What Would Kamala Khan Do?</a
>
<span class="Date">7 August 2015</span>
</li>
<li>
<a href="../trickle-down-golden-goose/index.html"
>Bookmarks – Trickle down golden geese</a
>
<span class="Date">6 August 2015</span>
</li>
<li>
<a href="../hateviews/index.html"
>Bookmarks – Hateviews are us</a
>
<span class="Date">5 August 2015</span>
</li>
<li>
<a href="../bookmarks-milk-it/index.html"
>Bookmarks – Milk it</a
>
<span class="Date">4 August 2015</span>
</li>
<li>
<a href="../iterating-the-web-away/index.html"
>Iterating the web away: <br>losing the next generation</a
>
<span class="Date">4 August 2015</span>
</li>
<li>
<a href="../bookmarks-paying-attention/index.html"
>Bookmarks – You haven't been paying attention</a
>
<span class="Date">3 August 2015</span>
</li>
<li>
<a href="../bookmarks-stop-the-web/index.html"
>Bookmarks – It's a note card world, we just live in it</a
>
<span class="Date">31 July 2015</span>
</li>
<li>
<a href="../bookmarks-sucky-websites/index.html"
>Bookmarks – Just call it Smylfeste</a
>
<span class="Date">30 July 2015</span>
</li>
<li>
<a href="../bookmarks-that-one-is-an-idiot/index.html"
>Bookmarks – That one is shaped like an idiot</a
>
<span class="Date">29 July 2015</span>
</li>
<li>
<a href="../blogger-nostalgia/index.html"
>Blogger nostalgia</a
>
<span class="Date">28 July 2015</span>
</li>
<li>
<a href="../bookmarks-make-it-simpler/index.html"
>Bookmarks – Make it simpler</a
>
<span class="Date">28 July 2015</span>
</li>
<li>
<a href="../bookmarks-javascript-cry/index.html"
>Wet streets cause rain and criminal responsibility</a
>
<span class="Date">27 July 2015</span>
</li>
<li>
<a href="../bookmark-5/index.html"
>Tweet bookmarks galore</a
>
<span class="Date">26 July 2015</span>
</li>
<li>
<a href="../bookmarks-4/index.html"
>Random links that catch my fancy, part four of ∞</a
>
<span class="Date">23 July 2015</span>
</li>
<li>
<a href="../bookmarks-3/index.html"
>Random links that catch my fancy, part three of ∞</a
>
<span class="Date">22 July 2015</span>
</li>
<li>
<a href="../mythic-dimension-of-sexuality/index.html"
>Mythic visions of sexuality</a
>
<span class="Date">21 July 2015</span>
</li>
<li>
<a href="../bookmarks-2/index.html"
>Random links that catch my fancy, part two of ∞</a
>
<span class="Date">21 July 2015</span>
</li>
<li>
<a href="../bookmarks/index.html"
>Random links that catch my fancy, part one of ∞</a
>
<span class="Date">20 July 2015</span>
</li>
<li>
<a href="../modularisation-exercise/index.html"
>An exercise for the reader in integration and modularity</a
>
<span class="Date">17 July 2015</span>
</li>
<li>
<a href="../how-to-read-baldur/index.html"
>How to read my nonsense</a
>
<span class="Date">17 July 2015</span>
</li>
<li>
<a href="../decentralised-or-disorganised/index.html"
>Is it distributed or just a disorganised hierarchy?</a
>
<span class="Date">10 July 2015</span>
</li>
<li>
<a href="../the-robust-web/index.html"
>On the vaunted robustness of the web</a
>
<span class="Date">10 July 2015</span>
</li>
<li>
<a href="../the-rules-have-changed-for-rss/index.html"
>The rules of the game have changed for RSS</a
>
<span class="Date">10 July 2015</span>
</li>
<li>
<a href="../web-app-developer-lament/index.html"
>The web app developer's lament</a
>
<span class="Date">6 July 2015</span>
</li>
<li>
<a href="../paradigm-shift/index.html"
>Other people write about digital media</a
>
<span class="Date">25 June 2015</span>
</li>
<li>
<a href="../media-changes/index.html"
>The plural of 'Medium' is clearly 'clusterfuck'</a
>
<span class="Date">25 June 2015</span>
</li>
<li>
<a href="../burnout/index.html"
>Burnout</a
>
<span class="Date">24 June 2015</span>
</li>
<li>
<a href="../our-working-files/index.html"
>The files Steven Pressfield works with</a
>
<span class="Date">24 June 2015</span>
</li>
<li>
<a href="../ios9-content-blocking/index.html"
>iOS 9 content blocking extensions are not a mobile advertising armageddon</a
>
<span class="Date">14 June 2015</span>
</li>
<li>
<a href="../writing-the-other/index.html"
><em>Writing the Other</em>: <br>a book that's useful to all writers</a
>
<span class="Date">3 June 2015</span>
</li>
<li>
<a href="../wwdc-predictions/index.html"
>Should I make a WWDC prediction? <br>Yes, let's</a
>
<span class="Date">3 June 2015</span>
</li>
<li>
<a href="../grim-meathook-present-2/index.html"
>Grim Meathook Present #2</a
>
<span class="Date">2 June 2015</span>
</li>
<li>
<a href="../software-quality/index.html"
>Other people discuss software quality (spoiler: it sucks)</a
>
<span class="Date">2 June 2015</span>
</li>
<li>
<a href="../startup-fallacy/index.html"
>Other people talk about startups and entrepreneurship</a
>
<span class="Date">2 June 2015</span>
</li>
<li>
<a href="../quick-thoughts-big-problems/index.html"
>A few quick links and thoughts on big web problems</a
>
<span class="Date">29 May 2015</span>
</li>
<li>
<a href="../femininity-heroism/index.html"
>I really want the Supergirl TV show to be fun</a
>
<span class="Date">25 May 2015</span>
</li>
<li>
<a href="../grim-meathook-present/index.html"
>Our Grim Meathook Present</a
>
<span class="Date">25 May 2015</span>
</li>
<li>
<a href="../new-age-of-html/index.html"
>The new age of HTML:<br> the web is being torn apart</a
>
<span class="Date">20 May 2015</span>
</li>
<li>
<a href="../her-movie-his-name/index.html"
>Her movie, his name;<br> Mad Max: Fury Road</a
>
<span class="Date">19 May 2015</span>
</li>
<li>
<a href="../we-are-a-violent-species/index.html"
>We are a violent species</a
>
<span class="Date">19 May 2015</span>
</li>
<li>
<a href="../toxic-environments/index.html"
>Toxic environments: <br> inequality in tech is a symptom of something worse</a
>
<span class="Date">18 May 2015</span>
</li>
<li>
<a href="../../2015/05/16/where-i-write-about-facebooks-instant-articles/index.html"
>Where I write about Facebook's Instant Articles</a
>
<span class="Date">16 May 2015</span>
</li>
<li>
<a href="../media-websites-vs-facebook/index.html"
>Facebook and the media: <br>united, they attack the web</a
>
<span class="Date">15 May 2015</span>
</li>
<li>
<a href="../decision-cycles/index.html"
>Speeding up decision cycles with rules and heuristics</a
>
<span class="Date">14 May 2015</span>
</li>
<li>
<a href="../a-you-are-here-5/index.html"
>You are here #5: <br>UX, design, and CSS as a parasite</a
>
<span class="Date">14 May 2015</span>
</li>
<li>
<a href="../you-are-here-4/index.html"
>You are here #4: <br>an epic journey through app dev and male bodies</a
>
<span class="Date">13 May 2015</span>
</li>
<li>
<a href="../you-are-here-3/index.html"
>You are here #3: <br>the glorious wonders of online reading await you</a
>
<span class="Date">12 May 2015</span>
</li>
<li>
<a href="../18-39-16/index.html"
>2015-05-11-18-39-16</a
>
<span class="Date">11 May 2015</span>
</li>
<li>
<a href="../you-are-here-2/index.html"
>You are here #2: <br>an artisanal curation of reading material</a
>
<span class="Date">11 May 2015</span>
</li>
<li>
<a href="../you-are-here-1/index.html"
>You are here #1: <br>a selection of fine links and tweets for your pleasure</a
>
<span class="Date">10 May 2015</span>
</li>
<li>
<a href="../00-59-18/index.html"
>2015-05-07-00-59-18</a
>
<span class="Date">7 May 2015</span>
</li>
<li>
<a href="../../2015/05/04/four-publishing-related-thoughts-on-a-friday-afternoon/index.html"
>Five publishing-related thoughts on a Friday afternoon</a
>
<span class="Date">4 May 2015</span>
</li>
<li>
<a href="../../2015/05/04/why-should-people-read-more-books/index.html"
>Why should people read more books?</a
>
<span class="Date">4 May 2015</span>
</li>
<li>
<a href="../../2015/05/04/how-is-taxing-ebooks-as-print-books-supposed-to-work/index.html"
>How is taxing ebooks as print books supposed to work?</a
>
<span class="Date">4 May 2015</span>
</li>
<li>
<a href="../../2015/03/04/kathy-sierras-badass-making-users-awesome-the-book-you-all-should-read/index.html"
>Kathy Sierra's Badass: Making Users Awesome – the book you all should read</a
>
<span class="Date">4 March 2015</span>
</li>
<li>
<a href="../../2015/03/01/idle-sunday-thoughts-about-web-trends/index.html"
>Idle Sunday thoughts about web trends</a
>
<span class="Date">1 March 2015</span>
</li>
<li>
<a href="../../2015/03/01/repetition-only-works-in-fiction/index.html"
>Repetition only works in fiction</a
>
<span class="Date">1 March 2015</span>
</li>
<li>
<a href="../../2015/03/01/the-web-has-covered-the-basicse2808a-e2808athats-why-itll-get-harder-from-now/index.html"
>The web has covered the basics — that’s why it’ll get harder from now</a
>
<span class="Date">1 March 2015</span>
</li>
<li>
<a href="../../2015/01/09/a-draft-of-a-chapter-of-some-thoughts-on-things/index.html"
>A draft of a chapter of some thoughts on things.</a
>
<span class="Date">9 January 2015</span>
</li>
<li>
<a href="../../2014/12/31/taking-stock-of-2013-and-2014/index.html"
>Taking stock of 2013 and 2014</a
>
<span class="Date">31 December 2014</span>
</li>
<li>
<a href="../../2014/12/17/the-weather-of-course/index.html"
>The weather, of course</a
>
<span class="Date">17 December 2014</span>
</li>
<li>
<a href="../../2014/12/03/publishing-business-ideas-are-a-dime-a-dozen/index.html"
>Publishing business ideas are a dime a dozen</a
>
<span class="Date">3 December 2014</span>
</li>
<li>
<a href="../../2014/11/25/eu-vat-changes-shift-the-digital-landscape/index.html"
>EU VAT changes shift the digital landscape</a
>
<span class="Date">25 November 2014</span>
</li>
<li>
<a href="../../2014/11/25/money-is-a-poor-measure-of-value/index.html"
>Money is a poor measure of value</a
>
<span class="Date">25 November 2014</span>
</li>
<li>
<a href="../../2014/11/13/on-conference/index.html"
>On conferences</a
>
<span class="Date">13 November 2014</span>
</li>
<li>
<a href="../../2014/11/12/crushed-by-multinationals/index.html"
>Crushed by multinationals</a
>
<span class="Date">12 November 2014</span>
</li>
<li>
<a href="../../2014/11/07/software-as-a-strategy-prefabricated-publishers/index.html"
>Software as a strategy: prefabricated publishers</a
>
<span class="Date">7 November 2014</span>
</li>
<li>
<a href="../../2014/11/06/software-as-strategy-in-the-ebook-world/index.html"
>Software as strategy in the ebook world</a
>
<span class="Date">6 November 2014</span>
</li>
<li>
<a href="../../2014/11/05/the-five-types-of-unpublished-books/index.html"
>The five types of unpublished books</a
>
<span class="Date">5 November 2014</span>
</li>
<li>
<a href="../../2014/11/04/four-hundred-words-from-anita-elberses-book-blockbusters/index.html"
>Four hundred words from Anita Elberse's book "Blockbusters"</a
>
<span class="Date">4 November 2014</span>
</li>
<li>
<a href="../../2014/11/04/the-splintered-author/index.html"
>The splintered author</a
>
<span class="Date">4 November 2014</span>
</li>
<li>
<a href="../../2014/11/03/there-is-no-war-between-amazon-and-traditional-publishing/index.html"
>There is no war between Amazon and Traditional Publishing</a
>
<span class="Date">3 November 2014</span>
</li>
<li>
<a href="../../2014/10/10/ebooks-suck-for-learning/index.html"
>Ebooks suck for learning</a
>
<span class="Date">10 October 2014</span>
</li>
<li>
<a href="../../2014/09/09/the-poisoning-of-social-media-a-reading-list/index.html"
>The Poisoning of Social Media: A Reading List</a
>
<span class="Date">9 September 2014</span>
</li>
<li>
<a href="../../2014/08/10/wobbly-amazon/index.html"
>Wobbly Amazon</a
>
<span class="Date">10 August 2014</span>
</li>
<li>
<a href="../../2014/07/24/this-weeks-must-read-post/index.html"
>This week's must-read post</a
>
<span class="Date">24 July 2014</span>
</li>
<li>
<a href="../../2014/07/10/friends-dont-let-their-friends-become-authors/index.html"
>Friends don’t let their friends become authors</a
>
<span class="Date">10 July 2014</span>
</li>
<li>
<a href="../../2014/07/04/both-at-the-same-time/index.html"
>Both at the same time</a
>
<span class="Date">4 July 2014</span>
</li>
<li>
<a href="../../2014/04/15/so-i-had-to-make-an-ebook-cover/index.html"
>So I had to make an ebook cover...</a
>
<span class="Date">15 April 2014</span>
</li>
<li>
<a href="../../2014/03/31/so-long-readmill-and-thanks-for-all-the-fish/index.html"
>So long, Readmill, and thanks for all the fish</a
>
<span class="Date">31 March 2014</span>
</li>
<li>
<a href="../../2014/03/24/what-ebook-production-problems-are-self-publishers-facing/index.html"
>What ebook production problems are self-publishers facing?</a
>
<span class="Date">24 March 2014</span>
</li>
<li>
<a href="../../2014/03/13/many-stories-many-truths/index.html"
>Many stories, many truths</a
>
<span class="Date">13 March 2014</span>
</li>
<li>
<a href="../../2014/02/28/problem-statements-for-digital-publishing-research/index.html"
>Problem statements for digital publishing research</a
>
<span class="Date">28 February 2014</span>
</li>
<li>
<a href="../../2014/02/21/to-do-to-do/index.html"
>To do, to do</a
>
<span class="Date">21 February 2014</span>
</li>
<li>
<a href="../../2014/02/20/ibooks-author-tempts-you-with-bling/index.html"
>iBooks Author tempts you with bling</a
>
<span class="Date">20 February 2014</span>
</li>
<li>
<a href="../../2014/02/19/microsoft-word-is-a-liability/index.html"
>Microsoft Word is a liability</a
>
<span class="Date">19 February 2014</span>
</li>
<li>
<a href="../../2014/02/18/the-print-design-mentality/index.html"
>The print design mentality</a
>
<span class="Date">18 February 2014</span>
</li>
<li>
<a href="../../2014/02/12/book-contracts/index.html"
>Book contracts</a
>
<span class="Date">12 February 2014</span>
</li>
<li>
<a href="../../2014/02/05/intermission-sorting-through-the-banal/index.html"
>Intermission: sorting through the banal</a
>
<span class="Date">5 February 2014</span>
</li>
<li>
<a href="../../2014/01/30/how-to-create-value-with-a-new-thing/index.html"
>How to create value with a new thing</a
>
<span class="Date">30 January 2014</span>
</li>
<li>
<a href="../../2014/01/29/html-is-too-complex/index.html"
>HTML is too complex</a
>
<span class="Date">29 January 2014</span>
</li>
<li>
<a href="../../2014/01/28/the-ebook-as-an-api/index.html"
>The ebook as an API</a
>
<span class="Date">28 January 2014</span>
</li>
<li>
<a href="../../2014/01/27/my-last-word-on-drm/index.html"
>My last word on DRM</a
>
<span class="Date">27 January 2014</span>
</li>
<li>
<a href="../../2014/01/23/except-except-except/index.html"
>Except, except, except</a
>
<span class="Date">23 January 2014</span>
</li>
<li>
<a href="../../2014/01/22/a-thought-exercise/index.html"
>A thought exercise</a
>
<span class="Date">22 January 2014</span>
</li>
<li>
<a href="../../2014/01/21/losing-faith-in-yourself/index.html"
>Losing faith in yourself</a
>
<span class="Date">21 January 2014</span>
</li>
<li>
<a href="../../2014/01/20/changing-your-readership-mix/index.html"
>Changing your readership mix</a
>
<span class="Date">20 January 2014</span>
</li>
<li>
<a href="../../2014/01/18/sex-education-readers-and-futures-what-works-what-doesnt/index.html"
>Sex, education, readers, and futures: what works, what doesn't</a
>
<span class="Date">18 January 2014</span>
</li>
<li>
<a href="../../2014/01/17/the-various-types-of-readers/index.html"
>The various types of readers</a
>
<span class="Date">17 January 2014</span>
</li>
<li>
<a href="../../2014/01/16/the-unevenly-distributed-ebook-future/index.html"
>The unevenly distributed ebook future</a
>
<span class="Date">16 January 2014</span>
</li>
<li>
<a href="../../2014/01/15/sex-violence-and-stilbrot/index.html"
>Sex, violence, and stílbrot</a
>
<span class="Date">15 January 2014</span>
</li>
<li>
<a href="../../2014/01/14/recipe-for-pundit-response-to-hugh-howeys-suggestions/index.html"
>Recipe for pundit response to Hugh Howey’s suggestions</a
>
<span class="Date">14 January 2014</span>
</li>
<li>
<a href="../../2014/01/13/bling-it-up-for-education/index.html"
>Bling it up for education</a
>
<span class="Date">13 January 2014</span>
</li>
<li>
<a href="../../2014/01/09/blogging-has-trained-me-to-assume-youre-stupid/index.html"
>Blogging has trained me to assume you’re stupid</a
>
<span class="Date">9 January 2014</span>
</li>
<li>
<a href="../../2014/01/08/ergodic-literature/index.html"
>Ergodic literature</a
>
<span class="Date">8 January 2014</span>
</li>
<li>
<a href="../../2014/01/07/what-i-thought-i-wanted-versus-what-i-really-wanted/index.html"
>What I thought I wanted versus what I really wanted</a
>
<span class="Date">7 January 2014</span>
</li>
<li>
<a href="../../2014/01/06/the-mistake-of-enhancing-novels/index.html"
>The mistake of 'enhancing' novels</a
>
<span class="Date">6 January 2014</span>
</li>
<li>
<a href="../../2014/01/04/pessimistic-ramblings-and-other-fun-links-week-overview-further-reading/index.html"
>Pessimistic ramblings and other fun links (week overview + further reading)</a
>
<span class="Date">4 January 2014</span>
</li>
<li>
<a href="../../2014/01/03/stumbling-into-publishing/index.html"
>Stumbling into publishing</a
>
<span class="Date">3 January 2014</span>
</li>
<li>
<a href="../../2014/01/02/the-publishing-industrys-new-product-categories/index.html"
>The publishing industry's new product categories</a
>
<span class="Date">2 January 2014</span>
</li>
<li>
<a href="../../2014/01/01/the-last-two-knights-and-necromancers-stories/index.html"
>The last two Knights and Necromancers stories</a
>
<span class="Date">1 January 2014</span>
</li>
<li>
<a href="../../2013/12/31/random-loosely-connected-thoughts-on-the-future/index.html"
>Random, loosely connected, thoughts on the future</a
>
<span class="Date">31 December 2013</span>
</li>
<li>
<a href="../../2013/12/29/old-photos-posted-without-context-reykjavik-cats/index.html"
>Old photos posted without context: Reykjavík Cats</a
>
<span class="Date">29 December 2013</span>
</li>
<li>
<a href="../../2013/12/22/old-photos-posted-without-context-sweep-after-use/index.html"
>Old photos posted without context: Sweep After Use</a
>
<span class="Date">22 December 2013</span>
</li>
<li>
<a href="../../2013/12/20/the-checklist-ibooks-image-handling/index.html"
>The Checklist: fix iBooks image handling</a
>
<span class="Date">20 December 2013</span>
</li>
<li>
<a href="../../2013/12/17/great-text-transcends-nothing/index.html"
>Great text transcends nothing</a
>
<span class="Date">17 December 2013</span>
</li>
<li>
<a href="../../2013/10/17/quarantine-all-ebooks/index.html"
>Quarantine all ebooks</a
>
<span class="Date">17 October 2013</span>
</li>
<li>
<a href="../../2013/10/17/the-self-publishers-perspective-of-the-ebook-market/index.html"
>The self-publisher's perspective of the ebook market</a
>
<span class="Date">17 October 2013</span>
</li>
<li>
<a href="../../2013/10/10/light-evening-trauma/index.html"
>Light evening trauma</a
>
<span class="Date">10 October 2013</span>
</li>
<li>
<a href="../../2013/10/02/just-say-no-to-ebook-css-and-js/index.html"
>Just say no to ebook CSS and JS</a
>
<span class="Date">2 October 2013</span>
</li>
<li>
<a href="../../2013/09/17/the-google-wave-heuristic/index.html"
>The Google Wave Heuristic</a
>
<span class="Date">17 September 2013</span>
</li>
<li>
<a href="../../2013/09/12/amazons-biggest-ally-is-apple/index.html"
>Amazon's biggest ally is Apple</a
>
<span class="Date">12 September 2013</span>
</li>
<li>
<a href="../../2013/08/26/readmill-versus-kindle-readmill-is-worth-the-hassle/index.html"
>Readmill versus Kindle – Readmill is worth the hassle</a
>
<span class="Date">26 August 2013</span>
</li>
<li>
<a href="../../2013/08/19/proprietary-ebook-formats-versus-drm/index.html"
>Proprietary ebook formats versus DRM</a
>
<span class="Date">19 August 2013</span>
</li>
<li>
<a href="../../2013/08/16/publishing-has-catered-to-dumb-for-a-long-while/index.html"
>Publishing has catered to dumb for a long while</a
>
<span class="Date">16 August 2013</span>
</li>
<li>
<a href="../../2013/08/14/computers-are-both-too-difficult-and-people-are-computer-illiterate/index.html"
>Computers are too difficult and people are computer illiterate</a
>
<span class="Date">14 August 2013</span>
</li>
<li>
<a href="../../2013/08/12/why-disruption-goes-unchecked/index.html"
>Why disruption goes unchecked</a
>
<span class="Date">12 August 2013</span>
</li>
<li>
<a href="../../2013/08/09/make-ebooks-worth-it/index.html"
>Make ebooks worth it</a
>
<span class="Date">9 August 2013</span>
</li>
<li>
<a href="../../2013/08/08/ebooks-and-cognitive-mapping/index.html"
>Ebooks and cognitive mapping</a
>
<span class="Date">8 August 2013</span>
</li>
<li>
<a href="../../2013/08/07/ebook-silos-update/index.html"
>Ebook silos, update</a
>
<span class="Date">7 August 2013</span>
</li>
<li>
<a href="../../2013/08/06/ebook-silos-and-missed-opportunities/index.html"
>Ebook silos and missed opportunities</a
>
<span class="Date">6 August 2013</span>
</li>
<li>
<a href="../../2013/08/05/technology-is-not-inherently-good/index.html"
>Technology is not inherently good</a
>
<span class="Date">5 August 2013</span>
</li>
<li>
<a href="../../2013/07/29/administrative-note-on-baldurbjarnason-com-and-feeds/index.html"
>Administrative note on baldurbjarnason.com and feeds</a
>
<span class="Date">29 July 2013</span>
</li>
<li>
<a href="../../2013/07/29/posted-without-comment/index.html"
>Posted without comment</a
>
<span class="Date">29 July 2013</span>
</li>
<li>
<a href="../../2013/07/24/the-inefficiencies-of-joy/index.html"
>The inefficiencies of joy</a
>
<span class="Date">24 July 2013</span>
</li>
<li>
<a href="../../2013/07/23/winner-takes-all-versus-the-matthew-effect/index.html"
>Winner takes all versus the Matthew effect</a
>
<span class="Date">23 July 2013</span>
</li>
<li>
<a href="../../2013/07/22/what-you-people-read-on-my-websites/index.html"
>What you people read (on my websites)</a
>
<span class="Date">22 July 2013</span>
</li>
<li>
<a href="../../2013/07/19/tolerating-the-heat-noticing-the-water/index.html"
>Tolerating the heat, noticing the water</a
>
<span class="Date">19 July 2013</span>
</li>
<li>
<a href="../../2013/07/18/if-the-kindle-fails-so-will-ebooks/index.html"
>If the Kindle fails so will ebooks</a
>
<span class="Date">18 July 2013</span>
</li>
<li>
<a href="../../2013/07/16/followup-to-this-ebook-is-a-lemon/index.html"
>Followup to 'this ebook is a lemon'</a
>
<span class="Date">16 July 2013</span>
</li>
<li>
<a href="../../2013/07/12/this-ebook-is-a-lemon/index.html"
>This ebook is a lemon</a
>
<span class="Date">12 July 2013</span>
</li>
<li>
<a href="../../2013/07/10/caught-between-madmen-and-mercenaries/index.html"
>Caught between madmen and mercenaries</a
>
<span class="Date">10 July 2013</span>
</li>
<li>
<a href="../../2013/07/03/major-update-to-studio-tendras-oz-project/index.html"
>Major update to Studio Tendra's Oz project</a
>
<span class="Date">3 July 2013</span>
</li>
<li>
<a href="../../2013/07/01/what-are-self-publishings-biggest-pain-points/index.html"
>What are self-publishing's biggest pain points?</a
>
<span class="Date">1 July 2013</span>
</li>
<li>
<a href="../../2013/07/01/intellectual-terrain/index.html"
>Intellectual terrain</a
>
<span class="Date">1 July 2013</span>
</li>
<li>
<a href="../../2013/06/26/good-books-dont-win/index.html"
>Good books don't win</a
>
<span class="Date">26 June 2013</span>
</li>
<li>
<a href="../why-does-it-matter/index.html"
>Why does it matter?</a
>
<span class="Date">10 May 2013</span>
</li>
<li>
<a href="../../2013/05/07/the-oz-reading-club-books-two-and-three/index.html"
>The OZ Reading Club: Books three and four</a
>
<span class="Date">7 May 2013</span>
</li>
<li>
<a href="../the-ebook-innovation/index.html"
>Which kind of innovation?</a
>
<span class="Date">3 May 2013</span>
</li>
<li>
<a href="../books-and-print/index.html"
>Books and Print Showcase</a
>
<span class="Date">2 May 2013</span>
</li>
<li>
<a href="../../2013/04/30/peasants/index.html"
>Peasants</a
>
<span class="Date">30 April 2013</span>
</li>
<li>
<a href="../for-the-love/index.html"
>For the love</a
>
<span class="Date">14 April 2013</span>
</li>
<li>
<a href="../../2013/04/05/the-idiocies-of-young-men/index.html"
>The idiocies of young men</a
>
<span class="Date">5 April 2013</span>
</li>
<li>
<a href="../../2013/04/02/studio-tendras-grand-and-marvelous-oz-reading-club/index.html"
>Studio Tendra's grand and marvellous Oz Reading Club</a
>
<span class="Date">2 April 2013</span>
</li>
<li>
<a href="../../2013/03/29/icelands-crowd-sourced-constitution-is-dead/index.html"
>Iceland’s ‘crowd-sourced’ constitution is dead</a
>
<span class="Date">29 March 2013</span>
</li>
<li>
<a href="../the-bn-fallacy/index.html"
>The B&N fallacy</a
>
<span class="Date">27 February 2013</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/hire-me/"
>Hire me!</a
>
<span class="Date">19 February 2013</span>
</li>
<li>
<a href="../../2013/02/15/a-question-only-you-can-answer/index.html"
>A question only you can answer</a
>
<span class="Date">15 February 2013</span>
</li>
<li>
<a href="../respect-the-reader/index.html"
>Respect the reader</a
>
<span class="Date">6 February 2013</span>
</li>
<li>
<a href="../../2013/02/05/33-observations-on-the-year-2012/index.html"
>33 observations on the year 2012</a
>
<span class="Date">5 February 2013</span>
</li>
<li>
<a href="../../2013/02/04/knights-and-necromancers-new-books-and-megapacks/index.html"
>Knights and Necromancers: new books and megapacks!</a
>
<span class="Date">4 February 2013</span>
</li>
<li>
<a href="../../2013/01/02/the-falcons-shriek/index.html"
>The falcon's shriek</a
>
<span class="Date">2 January 2013</span>
</li>
<li>
<a href="../../2012/12/29/what-is-actually-going-on-in-iceland/index.html"
>What is actually going on in Iceland</a
>
<span class="Date">29 December 2012</span>
</li>
<li>
<a href="../../2012/12/25/merry-christmas/index.html"
>Merry Christmas!</a
>
<span class="Date">25 December 2012</span>
</li>
<li>
<a href="../tag-soup/index.html"
>Tag soup is history</a
>
<span class="Date">21 December 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/schlock/"
>Schlock</a
>
<span class="Date">15 December 2012</span>
</li>
<li>
<a href="../../2012/12/05/strange-definitions-of-nice/index.html"
>Strange definitions of 'nice'</a
>
<span class="Date">5 December 2012</span>
</li>
<li>
<a href="../../2012/12/04/books-of-christmas-past/index.html"
>Books of Christmas Past</a
>
<span class="Date">4 December 2012</span>
</li>
<li>
<a href="../ids-in-css/index.html"
>Using IDs in CSS</a
>
<span class="Date">26 November 2012</span>
</li>
<li>
<a href="../../2012/11/22/design-highlights-from-the-icelandic-book-season/index.html"
>Design highlights from the Icelandic book season</a
>
<span class="Date">22 November 2012</span>
</li>
<li>
<a href="../../2012/11/19/news-updates-and-the-icelandic-book-market/index.html"
>News, updates, and the Icelandic book market</a
>
<span class="Date">19 November 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/standardisation/"
>A response, of sorts</a
>
<span class="Date">15 November 2012</span>
</li>
<li>
<a href="../../2012/11/08/high-tide-and-a-room-of-your-own/index.html"
>High tide and a room of your own</a
>
<span class="Date">8 November 2012</span>
</li>
<li>
<a href="../../2012/11/06/knights-and-necromancers-2-has-been-released/index.html"
>Knights and Necromancers 2 has been released</a
>
<span class="Date">6 November 2012</span>
</li>
<li>
<a href="../../2012/10/30/the-comment-fiction-challenge-post-mortem/index.html"
>The comment-fiction challenge post-mortem</a
>
<span class="Date">30 October 2012</span>
</li>
<li>
<a href="../../2012/10/29/fantasy-collapse-and-a-sense-of-history/index.html"
>Fantasy, Collapse, and a sense of history</a
>
<span class="Date">29 October 2012</span>
</li>
<li>
<a href="../../2012/10/26/two-questions-on-putting-books-on-the-web/index.html"
>Two questions on putting books on the web</a
>
<span class="Date">26 October 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/ibooks-30/"
>iBooks 3.0</a
>
<span class="Date">25 October 2012</span>
</li>
<li>
<a href="../../2012/10/22/perceptions-of-society/index.html"
>Perceptions of society</a
>
<span class="Date">22 October 2012</span>
</li>
<li>
<a href="../../2012/10/19/what-ive-been-up-to/index.html"
>What I've been up to</a
>
<span class="Date">19 October 2012</span>
</li>
<li>
<a href="../../2012/10/01/the-readmill-comment-fiction-challenge/index.html"
>The Readmill comment fiction challenge</a
>
<span class="Date">1 October 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/is-it-safe/"
>Is it safe?</a
>
<span class="Date">27 September 2012</span>
</li>
<li>
<a href="../the-time-work-takes/index.html"
>The time work takes</a
>
<span class="Date">24 September 2012</span>
</li>
<li>
<a href="../../2012/09/21/i-need-your-help/index.html"
>I need your help</a
>
<span class="Date">21 September 2012</span>
</li>
<li>
<a href="../../2012/09/19/designing-the-covers/index.html"
>Designing the covers</a
>
<span class="Date">19 September 2012</span>
</li>
<li>
<a href="../../2012/09/19/free-kindle-version/index.html"
>Free Kindle version</a
>
<span class="Date">19 September 2012</span>
</li>
<li>
<a href="../../2012/09/17/what-is-this/index.html"
>What is this?</a
>
<span class="Date">17 September 2012</span>
</li>
<li>
<a href="../the-stillborn-creature/index.html"
>The stillborn creature</a
>
<span class="Date">1 August 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/epub-javascript-security/"
>EPUB javascript security</a
>
<span class="Date">27 July 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/i-be-writing/"
>I be writing</a
>
<span class="Date">21 July 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/farce/"
>Farce</a
>
<span class="Date">16 July 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/bad-writing/"
>Bad writing</a
>
<span class="Date">19 June 2012</span>
</li>
<li>
<a href="../points-on-drm/index.html"
>A few random points on DRM</a
>
<span class="Date">7 June 2012</span>
</li>
<li>
<a href="../web-and-ebooks/index.html"
>The web and ebooks have little in common</a
>
<span class="Date">7 May 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/end-of-ebook-dev/"
>The end of ebook development</a
>
<span class="Date">26 April 2012</span>
</li>
<li>
<a href="../aftermath/index.html"
>Aftermath – notes on the Amazon post</a
>
<span class="Date">20 April 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/today-is-not-tomorrow/"
>Today is not tomorrow (or, how to beat Amazon)</a
>
<span class="Date">15 April 2012</span>
</li>
<li>
<a href="../bits-and-bobs/index.html"
>Bits, bobs, and anecdata</a
>
<span class="Date">3 April 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/lessons-in-interactivity/"
>Lessons in interactivity</a
>
<span class="Date">29 March 2012</span>
</li>
<li>
<a href="../hierarchies-of-ebook-design/index.html"
>Hierarchies of ebook design</a
>
<span class="Date">20 March 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/treat-ebook-developers-as-developers/"
>It's time to treat ebook developers as developers</a
>
<span class="Date">12 March 2012</span>
</li>
<li>
<a href="../code-does-not-change-minds/index.html"
>Code doesn't change minds</a
>
<span class="Date">7 March 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/amazon-wins/"
>Game over, Amazon wins</a
>
<span class="Date">3 March 2012</span>
</li>
<li>
<a href="../idpf-css-pgt/index.html"
>On CSS Page Templates</a
>
<span class="Date">2 March 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/javascript-in-ebooks/"
>Javascript in ebooks</a
>
<span class="Date">29 February 2012</span>
</li>
<li>
<a href="../explanatory-windows/index.html"
>Explanatory windows</a
>
<span class="Date">20 February 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/readium-and-good-intentions/"
>Readium and other good intentions</a
>
<span class="Date">13 February 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/epub-widgets-and-windows/"
>ePub windows and widgets – a proposal</a
>
<span class="Date">10 February 2012</span>
</li>
<li>
<a href="index.html"
>The semantics of ebook widgets</a
>
<span class="Date">4 February 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/widgets-javascript/"
>iBooks widgets – to javascript or not to javascript</a
>
<span class="Date">1 February 2012</span>
</li>
<li>
<a href="../what-do-we-want-from-the-kindle/index.html"
>What do we want from the Kindle platform?</a
>
<span class="Date">1 February 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/disruptive-crap/"
>Disruptive crap</a
>
<span class="Date">27 January 2012</span>
</li>
<li>
<a href="../elsewhere/index.html"
>Me, elsewhere</a
>
<span class="Date">26 January 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/the-pros-and-cons-of-iBooks-2/"
>The pros and cons of the iBooks 2.0 textbook format</a
>
<span class="Date">21 January 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/the-ibooks-builtin-widgets/"
>The iBooks 2.0 built-in widgets</a
>
<span class="Date">20 January 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/the-ibooks-textbook-format/"
>The iBooks 2.0 textbook format</a
>
<span class="Date">19 January 2012</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/the-publishing-animal/"
>The publishing animal</a
>
<span class="Date">17 January 2012</span>
</li>
<li>
<a href="../A-day-of-innovation-on-the-future-of-the-book/index.html"
>A day of innovation on the future of the book</a
>
<span class="Date">8 December 2011</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/what-a-publisher-does/"
>What a publisher does</a
>
<span class="Date">30 November 2011</span>
</li>
<li>
<a href="../Design-Pseudoscience/index.html"
>Design pseudoscience</a
>
<span class="Date">8 November 2011</span>
</li>
<li>
<a href="../a-tale-of-three-blog-posts/index.html"
>A tale of three blog posts</a
>
<span class="Date">28 October 2011</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/css-and-ebook-design/"
>CSS and ebook design</a
>
<span class="Date">24 October 2011</span>
</li>
<li>
<a href="../the-loss-of-ambient-intimacy/index.html"
>The loss of ambient intimacy</a
>
<span class="Date">15 September 2011</span>
</li>
<li>
<a href="../friday-links-and-reading/index.html"
>Friday links and reading</a
>
<span class="Date">26 August 2011</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/convert-or-engage/"
>Convert or engage</a
>
<span class="Date">4 August 2011</span>
</li>
<li>
<a href="../CSS3-hyphens/index.html"
>CSS3 Hyphens</a
>
<span class="Date">30 July 2011</span>
</li>
<li>
<a href="../just-you-and-the-megacorporation/index.html"
>Just you & Google</a
>
<span class="Date">29 July 2011</span>
</li>
<li>
<a href="../knowledge-is-not-adoption/index.html"
>Knowledge is not adoption</a
>
<span class="Date">24 July 2011</span>
</li>
<li>
<a href="../HTML5-history-api/index.html"
>HTML5 history API</a
>
<span class="Date">23 July 2011</span>
</li>
<li>
<a href="../social-in-the-mind/index.html"
>Your friends, in boxes</a
>
<span class="Date">17 July 2011</span>
</li>
<li>
<a href="../localstorage-and-messaging/index.html"
>Localstorage & messaging in ePub</a
>
<span class="Date">27 January 2011</span>
</li>
<li>
<a href="../javascript-in-epub/index.html"
>Javascript in epub</a
>
<span class="Date">26 January 2011</span>
</li>
<li>
<a href="../an-epub-experiment/index.html"
>An epub experiment</a
>
<span class="Date">25 January 2011</span>
</li>
<li>
<a href="../what-is-an-ebook/index.html"
>What is an ebook?</a
>
<span class="Date">21 December 2010</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/hypotheses-and-testing/"
>Hypotheses and testing</a
>
<span class="Date">25 October 2010</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/identifying-publishing-inn/"
>Identifying publishing innovators</a
>
<span class="Date">7 October 2010</span>
</li>
<li>
<a href="https://www.baldurbjarnason.com/notes/on-quality-in-publishing/"
>On quality in publishing</a
>
<span class="Date">7 October 2010</span>
</li>
<li>
<a href="../An-interesting-discussion/index.html"
>An interesting discussion</a
>
<span class="Date">28 June 2010</span>
</li>
</ul>
</main>
<div class="Bottom"></div>
</body>
</html>
| 31.158913 | 840 | 0.631014 |
7b043d88cc75a0eea7ced95d064130aae5c511f1 | 139 | rb | Ruby | app/models/user.rb | Strycora/phase_two_project | f4633ead03d1f302b6bf132a5e8212ffb38eb7f7 | [
"MIT"
] | null | null | null | app/models/user.rb | Strycora/phase_two_project | f4633ead03d1f302b6bf132a5e8212ffb38eb7f7 | [
"MIT"
] | null | null | null | app/models/user.rb | Strycora/phase_two_project | f4633ead03d1f302b6bf132a5e8212ffb38eb7f7 | [
"MIT"
] | null | null | null | class User < ActiveRecord::Base
has_secure_password
validates :username, presence: true, uniqueness: true
has_many :dragons
end
| 15.444444 | 55 | 0.755396 |
19f5309ef69800382a4e432f5487ae0938fef85b | 4,745 | dart | Dart | lib/screens/bottom_bar/bottom_bar_ui.dart | Volgograd-Power-Engineering-College/vpec | 760ea3771a171799114110eb233c67a5b099b876 | [
"Apache-2.0"
] | null | null | null | lib/screens/bottom_bar/bottom_bar_ui.dart | Volgograd-Power-Engineering-College/vpec | 760ea3771a171799114110eb233c67a5b099b876 | [
"Apache-2.0"
] | 1 | 2021-11-19T19:17:46.000Z | 2021-12-01T17:34:16.000Z | lib/screens/bottom_bar/bottom_bar_ui.dart | ShyroTeam/vpec | bdc1a8c5a6d7438be620da93922b6899f341c818 | [
"Apache-2.0"
] | null | null | null | import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '/utils/icons.dart';
import '../announcements/announcements_screen.dart';
import '../lessons_schedule/lessons_schedule_logic.dart';
import '../lessons_schedule/lessons_schedule_screen.dart';
import '../menu/menu_screen.dart';
import '../news/news_screen.dart';
import '../timetable/timetable_tabs/timetable_tabs_screen.dart';
import 'bottom_bar_logic.dart';
class PageStorageUI extends StatelessWidget {
const PageStorageUI({
Key? key,
}) : super(key: key);
// List of screens for navigation
static List<Widget> pages = [
const NewsScreenProvider(),
const AnnouncementsScreen(),
const TimeTableTabs(),
ChangeNotifierProvider(
create: (_) => LessonsScheduleLogic(),
child: const LessonsScheduleScreen()),
const MenuScreen(),
];
@override
Widget build(BuildContext context) {
return Consumer<BottomBarLogic>(
builder: (context, storage, child) => PageStorage(
child: pages[storage.bottomBarIndex],
bucket: PageStorageBucket(),
),
);
}
}
class BottomBarUI extends StatelessWidget {
const BottomBarUI({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer<BottomBarLogic>(
builder: (context, storage, child) => BottomNavigationBar(
type: BottomNavigationBarType.shifting,
currentIndex: storage.bottomBarIndex,
onTap: (index) {
storage.setIndex(index);
},
items: [
BottomNavigationBarItem(
backgroundColor:
Theme.of(context).bottomNavigationBarTheme.backgroundColor,
icon: const Icon(VpecIconPack.news_outline),
activeIcon: const Icon(VpecIconPack.news),
label: 'События'),
BottomNavigationBarItem(
backgroundColor:
Theme.of(context).bottomNavigationBarTheme.backgroundColor,
icon: const Icon(Icons.notifications_outlined),
activeIcon: const Icon(Icons.notifications),
label: 'Объявления'),
BottomNavigationBarItem(
backgroundColor:
Theme.of(context).bottomNavigationBarTheme.backgroundColor,
icon: const Icon(Icons.schedule_outlined),
activeIcon: const Icon(Icons.watch_later),
label: 'Звонки'),
BottomNavigationBarItem(
backgroundColor:
Theme.of(context).bottomNavigationBarTheme.backgroundColor,
icon: const Icon(Icons.dashboard_outlined),
activeIcon: const Icon(Icons.dashboard),
label: 'Расписание'),
BottomNavigationBarItem(
backgroundColor:
Theme.of(context).bottomNavigationBarTheme.backgroundColor,
icon: const Icon(Icons.menu_outlined),
activeIcon: const Icon(Icons.menu),
label: 'Меню',
),
],
),
);
}
}
class BuildTabletUI extends StatelessWidget {
const BuildTabletUI({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer<BottomBarLogic>(
child: const Expanded(
child: PageStorageUI(),
),
builder: (context, storage, child) => Row(
children: [
NavigationRail(
groupAlignment: -0.9,
selectedIndex: storage.bottomBarIndex,
labelType: NavigationRailLabelType.none,
onDestinationSelected: (value) => storage.setIndex(value),
destinations: const [
NavigationRailDestination(
icon: Icon(VpecIconPack.news_outline),
selectedIcon: Icon(VpecIconPack.news),
label: Text('События'),
),
NavigationRailDestination(
icon: Icon(Icons.notifications_outlined),
selectedIcon: Icon(Icons.notifications),
label: Text('Объявления'),
),
NavigationRailDestination(
icon: Icon(Icons.schedule_outlined),
selectedIcon: Icon(Icons.watch_later),
label: Text('Звонки'),
),
NavigationRailDestination(
icon: Icon(Icons.dashboard_outlined),
selectedIcon: Icon(Icons.dashboard),
label: Text('Расписание'),
),
NavigationRailDestination(
icon: Icon(Icons.menu_outlined),
selectedIcon: Icon(Icons.menu),
label: Text('Меню'),
),
],
),
child!,
],
),
);
}
}
| 33.892857 | 77 | 0.598314 |
800dac400a89147dd194405fcae76a61c4646f0c | 1,727 | java | Java | wallet/vo/TokenVo.java | MonetChain-Project/MonetChain_Android | 6a43ca5b3aae95b71d474d19ba295b538c9e1d87 | [
"MIT"
] | 2 | 2018-05-21T01:39:55.000Z | 2019-03-22T05:48:10.000Z | wallet/vo/TokenVo.java | MonetChain-Project/MonetBlockchain_Android | 6a43ca5b3aae95b71d474d19ba295b538c9e1d87 | [
"MIT"
] | null | null | null | wallet/vo/TokenVo.java | MonetChain-Project/MonetBlockchain_Android | 6a43ca5b3aae95b71d474d19ba295b538c9e1d87 | [
"MIT"
] | null | null | null | package com.lingtuan.firefly.wallet.vo;
import org.json.JSONObject;
/**
* Created on 2018/3/19.
* token info
*/
public class TokenVo {
//token img
private String tokenPic;
//token name
private String tokenName;
//token info
private String tokenInfo;
//token number
private String tokenNumber;
//token price
private String tokenPrice;
//token total price
private String tokenTotalPrice;
//token is checked
private boolean isChecked;
public String getTokenPic() {
return tokenPic;
}
public void setTokenPic(String tokenPic) {
this.tokenPic = tokenPic;
}
public String getTokenName() {
return tokenName;
}
public void setTokenName(String tokenName) {
this.tokenName = tokenName;
}
public String getTokenInfo() {
return tokenInfo;
}
public void setTokenInfo(String tokenInfo) {
this.tokenInfo = tokenInfo;
}
public String getTokenNumber() {
return tokenNumber;
}
public void setTokenNumber(String tokenNumber) {
this.tokenNumber = tokenNumber;
}
public String getTokenPrice() {
return tokenPrice;
}
public void setTokenPrice(String tokenPrice) {
this.tokenPrice = tokenPrice;
}
public String getTokenTotalPrice() {
return tokenTotalPrice;
}
public void setTokenTotalPrice(String tokenTotalPrice) {
this.tokenTotalPrice = tokenTotalPrice;
}
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
public TokenVo parse(JSONObject object){
return this;
}
}
| 19.625 | 60 | 0.639838 |
80bad5790bdfea9252636455df3096302777880d | 1,309 | java | Java | src/main/java/com/oven/demo/common/util/LogUtils.java | 503612012/demo | a6f3bc2173cf9140bc72aad0ee1474c163f2de7a | [
"Apache-2.0"
] | 16 | 2019-04-25T01:28:18.000Z | 2022-02-23T02:00:34.000Z | src/main/java/com/oven/demo/common/util/LogUtils.java | 503612012/demo | a6f3bc2173cf9140bc72aad0ee1474c163f2de7a | [
"Apache-2.0"
] | 3 | 2020-11-03T06:01:39.000Z | 2022-02-09T22:09:21.000Z | src/main/java/com/oven/demo/common/util/LogUtils.java | 503612012/demo | 283b19aaa13344001098a4b112a46cdd55a56307 | [
"Apache-2.0"
] | 4 | 2019-04-25T08:47:16.000Z | 2020-08-25T01:50:32.000Z | package com.oven.demo.common.util;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
/**
* 获取对象属性更改日志
*
* @author Oven
*/
@Slf4j
public class LogUtils {
/**
* 获取对象属性更改日志
*
* @param oldObj 修改前对象
* @param newObj 修改后对象
*/
private static String getChangeInfo(Object oldObj, Object newObj) {
try {
StringBuilder result = new StringBuilder();
Field[] fields = oldObj.getClass().getDeclaredFields();
boolean isChange = false;
for (Field item : fields) {
item.setAccessible(true);
String oldValue = item.get(oldObj).toString();
String newValue = item.get(newObj).toString();
if (oldValue != null && !oldValue.equals(newValue)) {
result.append(item.getName()).append("由[").append(oldValue).append("]改为[").append(newValue).append("]").append(", ");
isChange = true;
}
}
if (isChange) {
String str = result.toString();
return str.substring(0, str.length() - 2);
}
return result.toString();
} catch (Exception e) {
log.error("获取对象属性更改日志异常:", e);
return "";
}
}
}
| 27.851064 | 137 | 0.521772 |
477164c83daac03b2df4ee1705f5d9c968bb277a | 1,744 | lua | Lua | src/IncludedCommands/Fun/play.lua | TheNexusAvenger/Nexus-Admin | 38ae3f128b19af023b3fff137e5bfd695675b310 | [
"MIT"
] | 4 | 2021-04-08T02:10:44.000Z | 2022-03-23T21:34:19.000Z | src/IncludedCommands/Fun/play.lua | TheNexusAvenger/Nexus-Admin | 38ae3f128b19af023b3fff137e5bfd695675b310 | [
"MIT"
] | 4 | 2020-07-22T20:08:43.000Z | 2021-01-06T02:32:01.000Z | src/IncludedCommands/Fun/play.lua | TheNexusAvenger/Nexus-Admin | 38ae3f128b19af023b3fff137e5bfd695675b310 | [
"MIT"
] | 2 | 2020-07-23T10:05:14.000Z | 2021-07-24T21:57:58.000Z | --[[
TheNexusAvenger
Implementation of a command.
--]]
local BaseCommand = require(script.Parent.Parent:WaitForChild("BaseCommand"))
local CommonState = require(script.Parent.Parent:WaitForChild("CommonState"))
local Command = BaseCommand:Extend()
--[[
Creates the command.
--]]
function Command:__new()
self:InitializeSuper("play","FunCommands","Plays music with the given id.")
self.Arguments = {
{
Type = "integer",
Name = "AudioId",
Description = "Audio id to play.",
},
}
--Create the audio.
CommonState.GlobalAudio = Instance.new("Sound")
CommonState.GlobalAudio.Name = "NexusAdmin_GlobalAudio"
CommonState.GlobalAudio.Looped = true
CommonState.GlobalAudio.Parent = self.Workspace
end
--[[
Runs the command.
--]]
function Command:Run(CommandContext,AudioId)
self.super:Run(CommandContext)
--Get the audio information.
local Worked,ProductData = pcall(function()
return self.MarketplaceService:GetProductInfo(AudioId)
end)
if not Worked or not ProductData then
self:SendError("Error loading audio "..AudioId..".")
return
end
--Display a message for playing the audio.
if ProductData.AssetTypeId ~= 3 then
self:SendError(tostring(ProductData.Name.."("..AudioId..") is not an audio."))
return
end
for _,Player in pairs(self.Players:GetPlayers()) do
self.API.Messages:DisplayHint(Player,tostring("Now playing \""..tostring(ProductData.Name).."\" ("..AudioId..")."))
end
--Play the audio.
CommonState.GlobalAudio:Stop()
CommonState.GlobalAudio.SoundId = "rbxassetid://"..AudioId
CommonState.GlobalAudio:Play()
end
return Command | 26.424242 | 123 | 0.668578 |
c5ad3f5dfed692bba7078c372f7ee86c960f72c6 | 1,563 | swift | Swift | Classes/Application.swift | RockerHX/Devices | 9e7f0a69e20171305baf94ca340af1cebfe841d5 | [
"MIT"
] | 112 | 2018-04-03T02:03:51.000Z | 2021-08-30T09:21:45.000Z | Classes/Application.swift | RockerHX/Devices | 9e7f0a69e20171305baf94ca340af1cebfe841d5 | [
"MIT"
] | 1 | 2018-09-29T03:03:17.000Z | 2018-09-30T01:43:03.000Z | Classes/Application.swift | RockerHX/Devices | 9e7f0a69e20171305baf94ca340af1cebfe841d5 | [
"MIT"
] | 2 | 2018-04-09T13:49:20.000Z | 2018-09-26T02:48:30.000Z | //
// Application.swift
// Devices
//
// Created by RockerHX on 2018/4/24.
//
import Foundation
extension Device {
public struct Application {
enum Key: String {
case FirstLanuch = "NotFirstLanuch"
}
// MARK: - Singleton -
public static let shared = Application()
// MARK: - Public Property -
public private(set) var version: String
public private(set) var build: String
public private(set) var name: String
public private(set) var wholeVersion: String
public private(set) var firstLanuch: Bool = true
// MARK: - Initialize Methods -
fileprivate init() {
let infoDictionary = Bundle.main.infoDictionary
version = infoDictionary?["CFBundleShortVersionString"] as! String
build = infoDictionary?["CFBundleVersion"] as! String
if let appName = infoDictionary?["CFBundleDisplayName"] as? String {
name = appName
} else {
name = infoDictionary?["CFBundleName"] as! String
}
wholeVersion = "\(version) (Build \(build))"
let key = Key.FirstLanuch.rawValue
let userDefaults = UserDefaults.standard
let currentVersion = wholeVersion
if let storeVersion = userDefaults.string(forKey: key) {
firstLanuch = (currentVersion != storeVersion)
}
userDefaults.set(currentVersion, forKey: key)
userDefaults.synchronize()
}
}
}
| 28.944444 | 80 | 0.586692 |
d5a9e9282563a60abe74267bd2622cd5c11d95f7 | 2,206 | dart | Dart | lib/misc/AbstractFolderIdWrapper.dart | SaurabhSM/ews | 2614ef691f6d672a94f7898be8a33ad6f4fa088e | [
"MIT"
] | null | null | null | lib/misc/AbstractFolderIdWrapper.dart | SaurabhSM/ews | 2614ef691f6d672a94f7898be8a33ad6f4fa088e | [
"MIT"
] | null | null | null | lib/misc/AbstractFolderIdWrapper.dart | SaurabhSM/ews | 2614ef691f6d672a94f7898be8a33ad6f4fa088e | [
"MIT"
] | null | null | null | /*
* Exchange Web Services Managed API
*
* Copyright (c) Microsoft Corporation
* All rights reserved.
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import 'package:ews/Core/EwsServiceXmlWriter.dart';
import 'package:ews/Core/ServiceObjects/Folders/Folder.dart';
import 'package:ews/Enumerations/ExchangeVersion.dart';
/// <summary>
/// Represents the abstraction of a folder Id.
/// </summary>
abstract class AbstractFolderIdWrapper {
/// <summary>
/// Obtains the Folder object associated with the wrapper.
/// </summary>
/// <returns>The Folder object associated with the wrapper.</returns>
Folder GetFolder() {
return null;
}
/// <summary>
/// Initializes a new instance of AbstractFolderIdWrapper.
/// </summary>
AbstractFolderIdWrapper() {}
/// <summary>
/// Writes the Id encapsulated in the wrapper to XML.
/// </summary>
/// <param name="writer">The writer to write the Id to.</param>
void WriteToXml(EwsServiceXmlWriter writer);
/// <summary>
/// Validates folderId against specified version.
/// </summary>
/// <param name="version">The version.</param>
void Validate(ExchangeVersion version) {}
}
| 37.389831 | 93 | 0.732548 |
e91c4c9e09bf4217ac2cd733a068127ac588eb33 | 280,008 | cpp | C++ | The-Forge/Common_3/Renderer/Vulkan/Vulkan.cpp | Origamijr/The-Forge | bfdd16c8b00a8a0b5c73af2b031a05578900edab | [
"Apache-2.0"
] | null | null | null | The-Forge/Common_3/Renderer/Vulkan/Vulkan.cpp | Origamijr/The-Forge | bfdd16c8b00a8a0b5c73af2b031a05578900edab | [
"Apache-2.0"
] | null | null | null | The-Forge/Common_3/Renderer/Vulkan/Vulkan.cpp | Origamijr/The-Forge | bfdd16c8b00a8a0b5c73af2b031a05578900edab | [
"Apache-2.0"
] | 1 | 2020-03-06T09:53:01.000Z | 2020-03-06T09:53:01.000Z | /*
* Copyright (c) 2018-2020 The Forge Interactive Inc.
*
* This file is part of The-Forge
* (see https://github.com/ConfettiFX/The-Forge).
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifdef VULKAN
#define RENDERER_IMPLEMENTATION
#define VMA_IMPLEMENTATION
/************************************************************************/
// Debugging Macros
/************************************************************************/
// Uncomment this to enable render doc capture support
//#define USE_RENDER_DOC
// Debug Utils Extension is still WIP and does not work with all Validation Layers
// Disable this to use the old debug report and debug marker extensions
// Debug Utils requires the Nightly Build of RenderDoc
//#define USE_DEBUG_UTILS_EXTENSION
/************************************************************************/
/************************************************************************/
#if defined(_WIN32)
// Pull in minimal Windows headers
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
#endif
#if defined(__linux__)
#define stricmp(a, b) strcasecmp(a, b)
#define vsprintf_s vsnprintf
#define strncpy_s strncpy
#endif
#if defined(NX64)
#include "../../../Switch/Common_3/Renderer/Vulkan/NX/NXVulkan.h"
#endif
#include "../IRenderer.h"
#include "../../ThirdParty/OpenSource/EASTL/functional.h"
#include "../../ThirdParty/OpenSource/EASTL/sort.h"
#include "../../ThirdParty/OpenSource/EASTL/string_hash_map.h"
#include "../../OS/Interfaces/ILog.h"
#include "../../ThirdParty/OpenSource/VulkanMemoryAllocator/VulkanMemoryAllocator.h"
#include "../../OS/Core/Atomics.h"
#include "../../OS/Core/GPUConfig.h"
#include "../../ThirdParty/OpenSource/tinyimageformat/tinyimageformat_base.h"
#include "../../ThirdParty/OpenSource/tinyimageformat/tinyimageformat_query.h"
#include "VulkanCapsBuilder.h"
#if defined(VK_USE_DISPATCH_TABLES) && !defined(NX64)
#include "../../../Common_3/ThirdParty/OpenSource/volk/volkForgeExt.h"
#endif
#include "../../OS/Interfaces/IMemory.h"
extern void vk_createShaderReflection(const uint8_t* shaderCode, uint32_t shaderSize, ShaderStage shaderStage, ShaderReflection* pOutReflection);
#ifdef ENABLE_RAYTRACING
extern void addRaytracingPipelineImpl(const RaytracingPipelineDesc*, Pipeline**);
extern void vk_FillRaytracingDescriptorData(const AccelerationStructure* pAccelerationStructure, void* pWriteNV);
#endif
// clang-format off
VkBlendOp gVkBlendOpTranslator[BlendMode::MAX_BLEND_MODES] =
{
VK_BLEND_OP_ADD,
VK_BLEND_OP_SUBTRACT,
VK_BLEND_OP_REVERSE_SUBTRACT,
VK_BLEND_OP_MIN,
VK_BLEND_OP_MAX,
};
VkBlendFactor gVkBlendConstantTranslator[BlendConstant::MAX_BLEND_CONSTANTS] =
{
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ONE,
VK_BLEND_FACTOR_SRC_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
VK_BLEND_FACTOR_DST_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR,
VK_BLEND_FACTOR_SRC_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
VK_BLEND_FACTOR_DST_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
VK_BLEND_FACTOR_SRC_ALPHA_SATURATE,
VK_BLEND_FACTOR_CONSTANT_COLOR,
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
};
VkCompareOp gVkComparisonFuncTranslator[CompareMode::MAX_COMPARE_MODES] =
{
VK_COMPARE_OP_NEVER,
VK_COMPARE_OP_LESS,
VK_COMPARE_OP_EQUAL,
VK_COMPARE_OP_LESS_OR_EQUAL,
VK_COMPARE_OP_GREATER,
VK_COMPARE_OP_NOT_EQUAL,
VK_COMPARE_OP_GREATER_OR_EQUAL,
VK_COMPARE_OP_ALWAYS,
};
VkStencilOp gVkStencilOpTranslator[StencilOp::MAX_STENCIL_OPS] =
{
VK_STENCIL_OP_KEEP,
VK_STENCIL_OP_ZERO,
VK_STENCIL_OP_REPLACE,
VK_STENCIL_OP_INVERT,
VK_STENCIL_OP_INCREMENT_AND_WRAP,
VK_STENCIL_OP_DECREMENT_AND_WRAP,
VK_STENCIL_OP_INCREMENT_AND_CLAMP,
VK_STENCIL_OP_DECREMENT_AND_CLAMP,
};
VkCullModeFlagBits gVkCullModeTranslator[CullMode::MAX_CULL_MODES] =
{
VK_CULL_MODE_NONE,
VK_CULL_MODE_BACK_BIT,
VK_CULL_MODE_FRONT_BIT
};
VkPolygonMode gVkFillModeTranslator[FillMode::MAX_FILL_MODES] =
{
VK_POLYGON_MODE_FILL,
VK_POLYGON_MODE_LINE
};
VkFrontFace gVkFrontFaceTranslator[] =
{
VK_FRONT_FACE_COUNTER_CLOCKWISE,
VK_FRONT_FACE_CLOCKWISE
};
static const VkFormat gVkFormatTranslator[] =
{
VK_FORMAT_UNDEFINED,
VK_FORMAT_R8_UNORM,
VK_FORMAT_R8G8_UNORM,
VK_FORMAT_UNDEFINED, // RGB8 not directly supported
VK_FORMAT_R8G8B8A8_UNORM,
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16G16_UNORM,
VK_FORMAT_UNDEFINED, // RGB16 not directly supported
VK_FORMAT_R16G16B16A16_UNORM,
VK_FORMAT_R8_SNORM,
VK_FORMAT_R8G8_SNORM,
VK_FORMAT_UNDEFINED, // RGB8S not directly supported
VK_FORMAT_R8G8B8A8_SNORM,
VK_FORMAT_R16_SNORM,
VK_FORMAT_R16G16_SNORM,
VK_FORMAT_UNDEFINED, // RGB16S not directly supported
VK_FORMAT_R16G16B16A16_SNORM,
VK_FORMAT_R16_SFLOAT,
VK_FORMAT_R16G16_SFLOAT,
VK_FORMAT_UNDEFINED, // RGB16F not directly supported
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_R32_SFLOAT,
VK_FORMAT_R32G32_SFLOAT,
VK_FORMAT_R32G32B32_SFLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT,
VK_FORMAT_R16_SINT,
VK_FORMAT_R16G16_SINT,
VK_FORMAT_UNDEFINED, // RGB16I not directly supported
VK_FORMAT_R16G16B16A16_SINT,
VK_FORMAT_R32_SINT,
VK_FORMAT_R32G32_SINT,
VK_FORMAT_R32G32B32_SINT,
VK_FORMAT_R32G32B32A32_SINT,
VK_FORMAT_R16_UINT,
VK_FORMAT_R16G16_UINT,
VK_FORMAT_UNDEFINED, // RGB16UI not directly supported
VK_FORMAT_R16G16B16A16_UINT,
VK_FORMAT_R32_UINT,
VK_FORMAT_R32G32_UINT,
VK_FORMAT_R32G32B32_UINT,
VK_FORMAT_R32G32B32A32_UINT,
VK_FORMAT_UNDEFINED, // RGBE8 not directly supported
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
VK_FORMAT_B10G11R11_UFLOAT_PACK32, // order switched in vulkan compared to DX11/12
VK_FORMAT_B5G6R5_UNORM_PACK16,
VK_FORMAT_UNDEFINED, // RGBA4 not directly supported
VK_FORMAT_A2R10G10B10_UNORM_PACK32,// order switched in vulkan compared to DX11/12
// Depth formats
VK_FORMAT_D16_UNORM,
VK_FORMAT_D24_UNORM_S8_UINT,
VK_FORMAT_D24_UNORM_S8_UINT,
VK_FORMAT_D32_SFLOAT,
// DXT formats
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
VK_FORMAT_BC2_UNORM_BLOCK,
VK_FORMAT_BC3_UNORM_BLOCK,
VK_FORMAT_BC4_UNORM_BLOCK,
VK_FORMAT_BC5_UNORM_BLOCK,
// PVR formats
VK_FORMAT_UNDEFINED, // PVR_2BPP = 56,
VK_FORMAT_UNDEFINED, // PVR_2BPPA = 57,
VK_FORMAT_UNDEFINED, // PVR_4BPP = 58,
VK_FORMAT_UNDEFINED, // PVR_4BPPA = 59,
VK_FORMAT_UNDEFINED, // INTZ = 60, // NVidia hack. Supported on all DX10+ HW
// XBox 360 specific fron buffer formats. NOt listed in other renderers. Please, add them when extend this structure.
VK_FORMAT_UNDEFINED, // LE_XRGB8 = 61,
VK_FORMAT_UNDEFINED, // LE_ARGB8 = 62,
VK_FORMAT_UNDEFINED, // LE_X2RGB10 = 63,
VK_FORMAT_UNDEFINED, // LE_A2RGB10 = 64,
// compressed mobile forms
VK_FORMAT_UNDEFINED, // ETC1 = 65, // RGB
VK_FORMAT_UNDEFINED, // ATC = 66, // RGB
VK_FORMAT_UNDEFINED, // ATCA = 67, // RGBA, explicit alpha
VK_FORMAT_UNDEFINED, // ATCI = 68, // RGBA, interpolated alpha
VK_FORMAT_UNDEFINED, // RAWZ = 69, //depth only, Nvidia (requires recombination of data) //FIX IT: PS3 as well?
VK_FORMAT_UNDEFINED, // DF16 = 70, //depth only, Intel/AMD
VK_FORMAT_UNDEFINED, // STENCILONLY = 71, // stencil ony usage
// BC formats
VK_FORMAT_BC1_RGBA_UNORM_BLOCK, // GNF_BC1 = 72,
VK_FORMAT_BC2_UNORM_BLOCK, // GNF_BC2 = 73,
VK_FORMAT_BC3_UNORM_BLOCK, // GNF_BC3 = 74,
VK_FORMAT_BC4_UNORM_BLOCK, // GNF_BC4 = 75,
VK_FORMAT_BC5_UNORM_BLOCK, // GNF_BC5 = 76,
VK_FORMAT_BC6H_UFLOAT_BLOCK, // GNF_BC6HUF = 77,
VK_FORMAT_BC6H_SFLOAT_BLOCK, // GNF_BC6HSF = 78,
VK_FORMAT_BC7_UNORM_BLOCK, // GNF_BC7 = 79,
// Reveser Form
VK_FORMAT_B8G8R8A8_UNORM, // BGRA8 = 80,
// Extend for DXGI
VK_FORMAT_X8_D24_UNORM_PACK32, // X8D24PAX32 = 81,
VK_FORMAT_S8_UINT, // S8 = 82,
VK_FORMAT_D16_UNORM_S8_UINT, // D16S8 = 83,
VK_FORMAT_D32_SFLOAT_S8_UINT, // D32S8 = 84,
// ASTC formats
VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
};
VkAttachmentLoadOp gVkAttachmentLoadOpTranslator[LoadActionType::MAX_LOAD_ACTION] =
{
VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_LOAD_OP_CLEAR,
};
const char* gVkWantedInstanceExtensions[] =
{
VK_KHR_SURFACE_EXTENSION_NAME,
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
#elif defined(VK_USE_PLATFORM_XCB_KHR)
VK_KHR_XCB_SURFACE_EXTENSION_NAME,
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
#elif defined(VK_USE_PLATFORM_GGP)
VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME,
#elif defined(VK_USE_PLATFORM_VI_NN)
VK_NN_VI_SURFACE_EXTENSION_NAME,
#endif
// Debug utils not supported on all devices yet
#ifdef USE_DEBUG_UTILS_EXTENSION
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
#else
VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
#endif
VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
// To legally use HDR formats
VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME,
/************************************************************************/
// VR Extensions
/************************************************************************/
VK_KHR_DISPLAY_EXTENSION_NAME,
VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME,
/************************************************************************/
// Multi GPU Extensions
/************************************************************************/
#if VK_KHR_device_group_creation
VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME,
#endif
#ifndef NX64
/************************************************************************/
// Property querying extensions
/************************************************************************/
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
/************************************************************************/
/************************************************************************/
#endif
};
const char* gVkWantedDeviceExtensions[] =
{
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME,
VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME,
VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME,
VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
#ifdef USE_EXTERNAL_MEMORY_EXTENSIONS
VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME,
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,
VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME,
#endif
#endif
// Debug marker extension in case debug utils is not supported
#ifndef USE_DEBUG_UTILS_EXTENSION
VK_EXT_DEBUG_MARKER_EXTENSION_NAME,
#endif
#if defined(VK_USE_PLATFORM_GGP)
VK_GGP_FRAME_TOKEN_EXTENSION_NAME,
#endif
#if VK_KHR_draw_indirect_count
VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME,
#endif
// Fragment shader interlock extension to be used for ROV type functionality in Vulkan
#if VK_EXT_fragment_shader_interlock
VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME,
#endif
/************************************************************************/
// NVIDIA Specific Extensions
/************************************************************************/
#ifdef USE_NV_EXTENSIONS
VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME,
#endif
/************************************************************************/
// AMD Specific Extensions
/************************************************************************/
VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME,
VK_AMD_SHADER_BALLOT_EXTENSION_NAME,
VK_AMD_GCN_SHADER_EXTENSION_NAME,
/************************************************************************/
// Multi GPU Extensions
/************************************************************************/
#if VK_KHR_device_group
VK_KHR_DEVICE_GROUP_EXTENSION_NAME,
#endif
/************************************************************************/
// Bindless & None Uniform access Extensions
/************************************************************************/
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
/************************************************************************/
// Descriptor Update Template Extension for efficient descriptor set updates
/************************************************************************/
VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME,
/************************************************************************/
// Raytracing
/************************************************************************/
#ifdef ENABLE_RAYTRACING
VK_NV_RAY_TRACING_EXTENSION_NAME,
#endif
/************************************************************************/
/************************************************************************/
};
// clang-format on
#ifdef USE_DEBUG_UTILS_EXTENSION
static bool gDebugUtilsExtension = false;
#endif
static bool gRenderDocLayerEnabled = false;
static bool gDedicatedAllocationExtension = false;
static bool gExternalMemoryExtension = false;
static bool gDrawIndirectCountExtension = false;
static bool gDeviceGroupCreationExtension = false;
static bool gDescriptorIndexingExtension = false;
static bool gAMDDrawIndirectCountExtension = false;
static bool gAMDGCNShaderExtension = false;
static bool gNVRayTracingExtension = false;
static bool gDebugMarkerSupport = false;
#if defined(VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME)
PFN_vkCmdDrawIndirectCountKHR pfnVkCmdDrawIndirectCountKHR = NULL;
PFN_vkCmdDrawIndexedIndirectCountKHR pfnVkCmdDrawIndexedIndirectCountKHR = NULL;
#else
PFN_vkCmdDrawIndirectCountAMD pfnVkCmdDrawIndirectCountKHR = NULL;
PFN_vkCmdDrawIndexedIndirectCountAMD pfnVkCmdDrawIndexedIndirectCountKHR = NULL;
#endif
/************************************************************************/
// IMPLEMENTATION
/************************************************************************/
#if defined(RENDERER_IMPLEMENTATION)
#if !defined(VK_USE_DISPATCH_TABLES)
#ifdef _MSC_VER
#pragma comment(lib, "vulkan-1.lib")
#endif
#endif
#define SAFE_FREE(p_var) \
if (p_var) \
{ \
conf_free((void*)p_var); \
}
#if defined(__cplusplus)
#define DECLARE_ZERO(type, var) type var = {};
#else
#define DECLARE_ZERO(type, var) type var = { 0 };
#endif
// Internal utility functions (may become external one day)
VkSampleCountFlagBits util_to_vk_sample_count(SampleCount sampleCount);
// clang-format off
API_INTERFACE void FORGE_CALLCONV addBuffer(Renderer* pRenderer, const BufferDesc* pDesc, Buffer** pp_buffer);
API_INTERFACE void FORGE_CALLCONV removeBuffer(Renderer* pRenderer, Buffer* pBuffer);
API_INTERFACE void FORGE_CALLCONV addTexture(Renderer* pRenderer, const TextureDesc* pDesc, Texture** ppTexture);
API_INTERFACE void FORGE_CALLCONV removeTexture(Renderer* pRenderer, Texture* pTexture);
API_INTERFACE void FORGE_CALLCONV mapBuffer(Renderer* pRenderer, Buffer* pBuffer, ReadRange* pRange);
API_INTERFACE void FORGE_CALLCONV unmapBuffer(Renderer* pRenderer, Buffer* pBuffer);
API_INTERFACE void FORGE_CALLCONV cmdUpdateBuffer(Cmd* pCmd, Buffer* pBuffer, uint64_t dstOffset, Buffer* pSrcBuffer, uint64_t srcOffset, uint64_t size);
API_INTERFACE void FORGE_CALLCONV cmdUpdateSubresource(Cmd* pCmd, Texture* pTexture, Buffer* pSrcBuffer, SubresourceDataDesc* pSubresourceDesc);
// clang-format on
//+1 for Acceleration Structure because it is not counted by VK_DESCRIPTOR_TYPE_RANGE_SIZE
#define CONF_DESCRIPTOR_TYPE_RANGE_SIZE (VK_DESCRIPTOR_TYPE_RANGE_SIZE + 1)
static uint32_t gDescriptorTypeRangeSize = VK_DESCRIPTOR_TYPE_RANGE_SIZE;
static void removeVirtualTexture(Renderer* pRenderer, VirtualTexture* pTexture);
/************************************************************************/
// DescriptorInfo Heap Structures
/************************************************************************/
/// CPU Visible Heap to store all the resources needing CPU read / write operations - Textures/Buffers/RTV
typedef struct DescriptorPool
{
VkDevice pDevice;
VkDescriptorPool pCurrentPool;
VkDescriptorPoolSize* pPoolSizes;
eastl::vector<VkDescriptorPool> mDescriptorPools;
uint32_t mPoolSizeCount;
uint32_t mNumDescriptorSets;
uint32_t mUsedDescriptorSetCount;
VkDescriptorPoolCreateFlags mFlags;
Mutex* pMutex;
} DescriptorPool;
/************************************************************************/
// Static DescriptorInfo Heap Implementation
/************************************************************************/
static void add_descriptor_pool(
Renderer* pRenderer, uint32_t numDescriptorSets, VkDescriptorPoolCreateFlags flags, VkDescriptorPoolSize* pPoolSizes,
uint32_t numPoolSizes, DescriptorPool** ppPool)
{
DescriptorPool* pPool = (DescriptorPool*)conf_calloc(1, sizeof(*pPool));
pPool->mFlags = flags;
pPool->mNumDescriptorSets = numDescriptorSets;
pPool->mUsedDescriptorSetCount = 0;
pPool->pDevice = pRenderer->pVkDevice;
pPool->pMutex = (Mutex*)conf_calloc(1, sizeof(Mutex));
pPool->pMutex->Init();
pPool->mPoolSizeCount = numPoolSizes;
pPool->pPoolSizes = (VkDescriptorPoolSize*)conf_calloc(numPoolSizes, sizeof(VkDescriptorPoolSize));
for (uint32_t i = 0; i < numPoolSizes; ++i)
pPool->pPoolSizes[i] = pPoolSizes[i];
VkDescriptorPoolCreateInfo poolCreateInfo = {};
poolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
poolCreateInfo.pNext = NULL;
poolCreateInfo.poolSizeCount = numPoolSizes;
poolCreateInfo.pPoolSizes = pPoolSizes;
poolCreateInfo.flags = flags;
poolCreateInfo.maxSets = numDescriptorSets;
VkResult res = vkCreateDescriptorPool(pPool->pDevice, &poolCreateInfo, NULL, &pPool->pCurrentPool);
ASSERT(VK_SUCCESS == res);
pPool->mDescriptorPools.emplace_back(pPool->pCurrentPool);
*ppPool = pPool;
}
static void reset_descriptor_pool(DescriptorPool* pPool)
{
VkResult res = vkResetDescriptorPool(pPool->pDevice, pPool->pCurrentPool, pPool->mFlags);
pPool->mUsedDescriptorSetCount = 0;
ASSERT(VK_SUCCESS == res);
}
static void remove_descriptor_pool(Renderer* pRenderer, DescriptorPool* pPool)
{
for (uint32_t i = 0; i < (uint32_t)pPool->mDescriptorPools.size(); ++i)
vkDestroyDescriptorPool(pRenderer->pVkDevice, pPool->mDescriptorPools[i], NULL);
pPool->mDescriptorPools.~vector();
pPool->pMutex->Destroy();
conf_free(pPool->pMutex);
SAFE_FREE(pPool->pPoolSizes);
SAFE_FREE(pPool);
}
static void consume_descriptor_sets(DescriptorPool* pPool,
const VkDescriptorSetLayout* pLayouts, VkDescriptorSet** pSets, uint32_t numDescriptorSets)
{
// Need a lock since vkAllocateDescriptorSets needs to be externally synchronized
// This is fine since this will only happen during Init time
MutexLock lock(*pPool->pMutex);
DECLARE_ZERO(VkDescriptorSetAllocateInfo, alloc_info);
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
alloc_info.pNext = NULL;
alloc_info.descriptorPool = pPool->pCurrentPool;
alloc_info.descriptorSetCount = numDescriptorSets;
alloc_info.pSetLayouts = pLayouts;
VkResult vk_res = vkAllocateDescriptorSets(pPool->pDevice, &alloc_info, *pSets);
if (VK_SUCCESS != vk_res)
{
VkDescriptorPool pDescriptorPool = VK_NULL_HANDLE;
VkDescriptorPoolCreateInfo poolCreateInfo = {};
poolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
poolCreateInfo.pNext = NULL;
poolCreateInfo.poolSizeCount = pPool->mPoolSizeCount;
poolCreateInfo.pPoolSizes = pPool->pPoolSizes;
poolCreateInfo.flags = pPool->mFlags;
poolCreateInfo.maxSets = pPool->mNumDescriptorSets;
VkResult res = vkCreateDescriptorPool(pPool->pDevice, &poolCreateInfo, NULL, &pDescriptorPool);
ASSERT(VK_SUCCESS == res);
pPool->mDescriptorPools.emplace_back(pDescriptorPool);
pPool->pCurrentPool = pDescriptorPool;
pPool->mUsedDescriptorSetCount = 0;
alloc_info.descriptorPool = pPool->pCurrentPool;
vk_res = vkAllocateDescriptorSets(pPool->pDevice, &alloc_info, *pSets);
}
ASSERT(VK_SUCCESS == vk_res);
pPool->mUsedDescriptorSetCount += numDescriptorSets;
}
/************************************************************************/
/************************************************************************/
VkPipelineBindPoint gPipelineBindPoint[PIPELINE_TYPE_COUNT] =
{
VK_PIPELINE_BIND_POINT_MAX_ENUM,
VK_PIPELINE_BIND_POINT_COMPUTE,
VK_PIPELINE_BIND_POINT_GRAPHICS,
#ifdef ENABLE_RAYTRACING
VK_PIPELINE_BIND_POINT_RAY_TRACING_NV
#endif
};
using DescriptorNameToIndexMap = eastl::string_hash_map<uint32_t>;
union DescriptorUpdateData
{
VkDescriptorImageInfo mImageInfo;
VkDescriptorBufferInfo mBufferInfo;
VkBufferView mBuferView;
};
struct SizeOffset
{
uint32_t mSize;
uint32_t mOffset;
};
/************************************************************************/
// Descriptor Set Structure
/************************************************************************/
typedef struct DescriptorIndexMap
{
eastl::string_hash_map<uint32_t> mMap;
} DescriptorIndexMap;
static const DescriptorInfo* get_descriptor(const RootSignature* pRootSignature, const char* pResName)
{
DescriptorNameToIndexMap::const_iterator it = pRootSignature->pDescriptorNameToIndexMap->mMap.find(pResName);
if (it != pRootSignature->pDescriptorNameToIndexMap->mMap.end())
{
return &pRootSignature->pDescriptors[it->second];
}
else
{
LOGF(LogLevel::eERROR, "Invalid descriptor param (%s)", pResName);
return NULL;
}
}
/************************************************************************/
// Render Pass Implementation
/************************************************************************/
typedef struct RenderPassDesc
{
TinyImageFormat* pColorFormats;
const LoadActionType* pLoadActionsColor;
bool* pSrgbValues;
uint32_t mRenderTargetCount;
SampleCount mSampleCount;
TinyImageFormat mDepthStencilFormat;
LoadActionType mLoadActionDepth;
LoadActionType mLoadActionStencil;
} RenderPassDesc;
typedef struct RenderPass
{
VkRenderPass pRenderPass;
RenderPassDesc mDesc;
} RenderPass;
typedef struct FrameBufferDesc
{
RenderPass* pRenderPass;
RenderTarget** ppRenderTargets;
RenderTarget* pDepthStencil;
uint32_t* pColorArraySlices;
uint32_t* pColorMipSlices;
uint32_t mDepthArraySlice;
uint32_t mDepthMipSlice;
uint32_t mRenderTargetCount;
} FrameBufferDesc;
typedef struct FrameBuffer
{
VkFramebuffer pFramebuffer;
uint32_t mWidth;
uint32_t mHeight;
uint32_t mArraySize;
} FrameBuffer;
static void add_render_pass(Renderer* pRenderer, const RenderPassDesc* pDesc, RenderPass** ppRenderPass)
{
RenderPass* pRenderPass = (RenderPass*)conf_calloc(1, sizeof(*pRenderPass));
pRenderPass->mDesc = *pDesc;
/************************************************************************/
// Add render pass
/************************************************************************/
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
uint32_t colorAttachmentCount = pDesc->mRenderTargetCount;
uint32_t depthAttachmentCount = (pDesc->mDepthStencilFormat != TinyImageFormat_UNDEFINED) ? 1 : 0;
VkAttachmentDescription* attachments = NULL;
VkAttachmentReference* color_attachment_refs = NULL;
VkAttachmentReference* depth_stencil_attachment_ref = NULL;
VkSampleCountFlagBits sample_count = util_to_vk_sample_count(pDesc->mSampleCount);
// Fill out attachment descriptions and references
{
attachments = (VkAttachmentDescription*)conf_calloc(colorAttachmentCount + depthAttachmentCount, sizeof(*attachments));
ASSERT(attachments);
if (colorAttachmentCount > 0)
{
color_attachment_refs = (VkAttachmentReference*)conf_calloc(colorAttachmentCount, sizeof(*color_attachment_refs));
ASSERT(color_attachment_refs);
}
if (depthAttachmentCount > 0)
{
depth_stencil_attachment_ref = (VkAttachmentReference*)conf_calloc(1, sizeof(*depth_stencil_attachment_ref));
ASSERT(depth_stencil_attachment_ref);
}
// Color
for (uint32_t i = 0; i < colorAttachmentCount; ++i)
{
const uint32_t ssidx = i;
// descriptions
attachments[ssidx].flags = 0;
attachments[ssidx].format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->pColorFormats[i]);
attachments[ssidx].samples = sample_count;
attachments[ssidx].loadOp =
pDesc->pLoadActionsColor ? gVkAttachmentLoadOpTranslator[pDesc->pLoadActionsColor[i]] : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments[ssidx].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[ssidx].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments[ssidx].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[ssidx].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachments[ssidx].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
// references
color_attachment_refs[i].attachment = ssidx;
color_attachment_refs[i].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
}
// Depth stencil
if (depthAttachmentCount > 0)
{
uint32_t idx = colorAttachmentCount;
attachments[idx].flags = 0;
attachments[idx].format = (VkFormat) TinyImageFormat_ToVkFormat(pDesc->mDepthStencilFormat);
attachments[idx].samples = sample_count;
attachments[idx].loadOp = gVkAttachmentLoadOpTranslator[pDesc->mLoadActionDepth];
attachments[idx].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[idx].stencilLoadOp = gVkAttachmentLoadOpTranslator[pDesc->mLoadActionStencil];
attachments[idx].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[idx].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
attachments[idx].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
depth_stencil_attachment_ref[0].attachment = idx;
depth_stencil_attachment_ref[0].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
}
DECLARE_ZERO(VkSubpassDescription, subpass);
subpass.flags = 0;
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.inputAttachmentCount = 0;
subpass.pInputAttachments = NULL;
subpass.colorAttachmentCount = colorAttachmentCount;
subpass.pColorAttachments = color_attachment_refs;
subpass.pResolveAttachments = NULL;
subpass.pDepthStencilAttachment = depth_stencil_attachment_ref;
subpass.preserveAttachmentCount = 0;
subpass.pPreserveAttachments = NULL;
uint32_t attachment_count = colorAttachmentCount;
attachment_count += depthAttachmentCount;
DECLARE_ZERO(VkRenderPassCreateInfo, create_info);
create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
create_info.pNext = NULL;
create_info.flags = 0;
create_info.attachmentCount = attachment_count;
create_info.pAttachments = attachments;
create_info.subpassCount = 1;
create_info.pSubpasses = &subpass;
create_info.dependencyCount = 0;
create_info.pDependencies = NULL;
VkResult vk_res = vkCreateRenderPass(pRenderer->pVkDevice, &create_info, NULL, &(pRenderPass->pRenderPass));
ASSERT(VK_SUCCESS == vk_res);
SAFE_FREE(attachments);
SAFE_FREE(color_attachment_refs);
SAFE_FREE(depth_stencil_attachment_ref);
*ppRenderPass = pRenderPass;
}
static void remove_render_pass(Renderer* pRenderer, RenderPass* pRenderPass)
{
vkDestroyRenderPass(pRenderer->pVkDevice, pRenderPass->pRenderPass, NULL);
SAFE_FREE(pRenderPass);
}
static void add_framebuffer(Renderer* pRenderer, const FrameBufferDesc* pDesc, FrameBuffer** ppFrameBuffer)
{
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
FrameBuffer* pFrameBuffer = (FrameBuffer*)conf_calloc(1, sizeof(*pFrameBuffer));
ASSERT(pFrameBuffer);
uint32_t colorAttachmentCount = pDesc->mRenderTargetCount;
uint32_t depthAttachmentCount = (pDesc->pDepthStencil) ? 1 : 0;
if (colorAttachmentCount)
{
pFrameBuffer->mWidth = pDesc->ppRenderTargets[0]->mWidth;
pFrameBuffer->mHeight = pDesc->ppRenderTargets[0]->mHeight;
if (pDesc->pColorArraySlices)
pFrameBuffer->mArraySize = 1;
else
pFrameBuffer->mArraySize = pDesc->ppRenderTargets[0]->mArraySize;
}
else
{
pFrameBuffer->mWidth = pDesc->pDepthStencil->mWidth;
pFrameBuffer->mHeight = pDesc->pDepthStencil->mHeight;
if (pDesc->mDepthArraySlice != -1)
pFrameBuffer->mArraySize = 1;
else
pFrameBuffer->mArraySize = pDesc->pDepthStencil->mArraySize;
}
/************************************************************************/
// Add frame buffer
/************************************************************************/
uint32_t attachment_count = colorAttachmentCount;
attachment_count += depthAttachmentCount;
VkImageView* pImageViews = (VkImageView*)conf_calloc(attachment_count, sizeof(*pImageViews));
ASSERT(pImageViews);
VkImageView* iter_attachments = pImageViews;
// Color
for (uint32_t i = 0; i < pDesc->mRenderTargetCount; ++i)
{
if (!pDesc->pColorMipSlices && !pDesc->pColorArraySlices)
{
*iter_attachments = pDesc->ppRenderTargets[i]->pVkDescriptor;
++iter_attachments;
}
else
{
uint32_t handle = 0;
if (pDesc->pColorMipSlices)
{
if (pDesc->pColorArraySlices)
handle = pDesc->pColorMipSlices[i] * pDesc->ppRenderTargets[i]->mArraySize + pDesc->pColorArraySlices[i];
else
handle = pDesc->pColorMipSlices[i];
}
else if (pDesc->pColorArraySlices)
{
handle = pDesc->pColorArraySlices[i];
}
*iter_attachments = pDesc->ppRenderTargets[i]->pVkSliceDescriptors[handle];
++iter_attachments;
}
}
// Depth/stencil
if (pDesc->pDepthStencil)
{
if (-1 == pDesc->mDepthMipSlice && -1 == pDesc->mDepthArraySlice)
{
*iter_attachments = pDesc->pDepthStencil->pVkDescriptor;
++iter_attachments;
}
else
{
uint32_t handle = 0;
if (pDesc->mDepthMipSlice != -1)
{
if (pDesc->mDepthArraySlice != -1)
handle = pDesc->mDepthMipSlice * pDesc->pDepthStencil->mArraySize + pDesc->mDepthArraySlice;
else
handle = pDesc->mDepthMipSlice;
}
else if (pDesc->mDepthArraySlice != -1)
{
handle = pDesc->mDepthArraySlice;
}
*iter_attachments = pDesc->pDepthStencil->pVkSliceDescriptors[handle];
++iter_attachments;
}
}
DECLARE_ZERO(VkFramebufferCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.renderPass = pDesc->pRenderPass->pRenderPass;
add_info.attachmentCount = attachment_count;
add_info.pAttachments = pImageViews;
add_info.width = pFrameBuffer->mWidth;
add_info.height = pFrameBuffer->mHeight;
add_info.layers = pFrameBuffer->mArraySize;
VkResult vk_res = vkCreateFramebuffer(pRenderer->pVkDevice, &add_info, NULL, &(pFrameBuffer->pFramebuffer));
ASSERT(VK_SUCCESS == vk_res);
SAFE_FREE(pImageViews);
/************************************************************************/
/************************************************************************/
*ppFrameBuffer = pFrameBuffer;
}
static void remove_framebuffer(Renderer* pRenderer, FrameBuffer* pFrameBuffer)
{
ASSERT(pRenderer);
ASSERT(pFrameBuffer);
vkDestroyFramebuffer(pRenderer->pVkDevice, pFrameBuffer->pFramebuffer, NULL);
SAFE_FREE(pFrameBuffer);
}
/************************************************************************/
// Per Thread Render Pass synchronization logic
/************************************************************************/
/// Render-passes are not exposed to the app code since they are not available on all apis
/// This map takes care of hashing a render pass based on the render targets passed to cmdBeginRender
using RenderPassMap = eastl::hash_map<uint64_t, struct RenderPass*>;
using RenderPassMapNode = RenderPassMap::value_type;
using RenderPassMapIt = RenderPassMap::iterator;
using FrameBufferMap = eastl::hash_map<uint64_t, struct FrameBuffer*>;
using FrameBufferMapNode = FrameBufferMap::value_type;
using FrameBufferMapIt = FrameBufferMap::iterator;
// RenderPass map per thread (this will make lookups lock free and we only need a lock when inserting a RenderPass Map for the first time)
eastl::hash_map<ThreadID, RenderPassMap>* gRenderPassMap;
// FrameBuffer map per thread (this will make lookups lock free and we only need a lock when inserting a FrameBuffer map for the first time)
eastl::hash_map<ThreadID, FrameBufferMap>* gFrameBufferMap;
Mutex* pRenderPassMutex;
static RenderPassMap& get_render_pass_map()
{
eastl::hash_map<ThreadID, RenderPassMap>::iterator it = gRenderPassMap->find(Thread::GetCurrentThreadID());
if (it == gRenderPassMap->end())
{
// Only need a lock when creating a new renderpass map for this thread
MutexLock lock(*pRenderPassMutex);
return gRenderPassMap->insert(Thread::GetCurrentThreadID()).first->second;
}
else
{
return it->second;
}
}
static FrameBufferMap& get_frame_buffer_map()
{
eastl::hash_map<ThreadID, FrameBufferMap>::iterator it = gFrameBufferMap->find(Thread::GetCurrentThreadID());
if (it == gFrameBufferMap->end())
{
// Only need a lock when creating a new framebuffer map for this thread
MutexLock lock(*pRenderPassMutex);
return gFrameBufferMap->insert(Thread::GetCurrentThreadID()).first->second;
}
else
{
return it->second;
}
}
/************************************************************************/
// Logging, Validation layer implementation
/************************************************************************/
// Proxy log callback
static void internal_log(LogType type, const char* msg, const char* component)
{
#ifndef NX64
switch (type)
{
case LOG_TYPE_INFO: LOGF(LogLevel::eINFO, "%s ( %s )", component, msg); break;
case LOG_TYPE_WARN: LOGF(LogLevel::eWARNING, "%s ( %s )", component, msg); break;
case LOG_TYPE_DEBUG: LOGF(LogLevel::eDEBUG, "%s ( %s )", component, msg); break;
case LOG_TYPE_ERROR: LOGF(LogLevel::eERROR, "%s ( %s )", component, msg); break;
default: break;
}
#endif
}
#ifdef USE_DEBUG_UTILS_EXTENSION
// Debug callback for Vulkan layers
static VkBool32 VKAPI_PTR internal_debug_report_callback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
{
const char* pLayerPrefix = pCallbackData->pMessageIdName;
const char* pMessage = pCallbackData->pMessage;
int32_t messageCode = pCallbackData->messageIdNumber;
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
{
LOGF(LogLevel::eINFO, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
{
// Code 64 is vkCmdClearAttachments issued before any draws
// We ignore this since we dont use load store actions
// Instead we clear the attachments in the DirectX way
if (messageCode == 64)
return VK_FALSE;
LOGF(LogLevel::eWARNING, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
{
LOGF(LogLevel::eERROR, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
return VK_FALSE;
}
#else
static VKAPI_ATTR VkBool32 VKAPI_CALL internal_debug_report_callback(
VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode,
const char* pLayerPrefix, const char* pMessage, void* pUserData)
{
if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT)
{
LOGF(LogLevel::eINFO, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
{
LOGF(LogLevel::eWARNING, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
else if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)
{
LOGF(LogLevel::eWARNING, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
else if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
{
LOGF(LogLevel::eERROR, "[%s] : %s (%i)", pLayerPrefix, pMessage, messageCode);
}
return VK_FALSE;
}
#endif
/************************************************************************/
/************************************************************************/
static inline VkPipelineColorBlendStateCreateInfo util_to_blend_desc(const BlendStateDesc* pDesc, VkPipelineColorBlendAttachmentState* pAttachments)
{
int blendDescIndex = 0;
#ifdef _DEBUG
for (int i = 0; i < MAX_RENDER_TARGET_ATTACHMENTS; ++i)
{
if (pDesc->mRenderTargetMask & (1 << i))
{
ASSERT(pDesc->mSrcFactors[blendDescIndex] < BlendConstant::MAX_BLEND_CONSTANTS);
ASSERT(pDesc->mDstFactors[blendDescIndex] < BlendConstant::MAX_BLEND_CONSTANTS);
ASSERT(pDesc->mSrcAlphaFactors[blendDescIndex] < BlendConstant::MAX_BLEND_CONSTANTS);
ASSERT(pDesc->mDstAlphaFactors[blendDescIndex] < BlendConstant::MAX_BLEND_CONSTANTS);
ASSERT(pDesc->mBlendModes[blendDescIndex] < BlendMode::MAX_BLEND_MODES);
ASSERT(pDesc->mBlendAlphaModes[blendDescIndex] < BlendMode::MAX_BLEND_MODES);
}
if (pDesc->mIndependentBlend)
++blendDescIndex;
}
blendDescIndex = 0;
#endif
for (int i = 0; i < MAX_RENDER_TARGET_ATTACHMENTS; ++i)
{
if (pDesc->mRenderTargetMask & (1 << i))
{
VkBool32 blendEnable =
(gVkBlendConstantTranslator[pDesc->mSrcFactors[blendDescIndex]] != VK_BLEND_FACTOR_ONE ||
gVkBlendConstantTranslator[pDesc->mDstFactors[blendDescIndex]] != VK_BLEND_FACTOR_ZERO ||
gVkBlendConstantTranslator[pDesc->mSrcAlphaFactors[blendDescIndex]] != VK_BLEND_FACTOR_ONE ||
gVkBlendConstantTranslator[pDesc->mDstAlphaFactors[blendDescIndex]] != VK_BLEND_FACTOR_ZERO);
pAttachments[i].blendEnable = blendEnable;
pAttachments[i].colorWriteMask = pDesc->mMasks[blendDescIndex];
pAttachments[i].srcColorBlendFactor = gVkBlendConstantTranslator[pDesc->mSrcFactors[blendDescIndex]];
pAttachments[i].dstColorBlendFactor = gVkBlendConstantTranslator[pDesc->mDstFactors[blendDescIndex]];
pAttachments[i].colorBlendOp = gVkBlendOpTranslator[pDesc->mBlendModes[blendDescIndex]];
pAttachments[i].srcAlphaBlendFactor = gVkBlendConstantTranslator[pDesc->mSrcAlphaFactors[blendDescIndex]];
pAttachments[i].dstAlphaBlendFactor = gVkBlendConstantTranslator[pDesc->mDstAlphaFactors[blendDescIndex]];
pAttachments[i].alphaBlendOp = gVkBlendOpTranslator[pDesc->mBlendAlphaModes[blendDescIndex]];
}
if (pDesc->mIndependentBlend)
++blendDescIndex;
}
VkPipelineColorBlendStateCreateInfo cb = {};
cb.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
cb.pNext = NULL;
cb.flags = 0;
cb.logicOpEnable = VK_FALSE;
cb.logicOp = VK_LOGIC_OP_CLEAR;
cb.pAttachments = pAttachments;
cb.blendConstants[0] = 0.0f;
cb.blendConstants[1] = 0.0f;
cb.blendConstants[2] = 0.0f;
cb.blendConstants[3] = 0.0f;
return cb;
}
static inline VkPipelineDepthStencilStateCreateInfo util_to_depth_desc(const DepthStateDesc* pDesc)
{
ASSERT(pDesc->mDepthFunc < CompareMode::MAX_COMPARE_MODES);
ASSERT(pDesc->mStencilFrontFunc < CompareMode::MAX_COMPARE_MODES);
ASSERT(pDesc->mStencilFrontFail < StencilOp::MAX_STENCIL_OPS);
ASSERT(pDesc->mDepthFrontFail < StencilOp::MAX_STENCIL_OPS);
ASSERT(pDesc->mStencilFrontPass < StencilOp::MAX_STENCIL_OPS);
ASSERT(pDesc->mStencilBackFunc < CompareMode::MAX_COMPARE_MODES);
ASSERT(pDesc->mStencilBackFail < StencilOp::MAX_STENCIL_OPS);
ASSERT(pDesc->mDepthBackFail < StencilOp::MAX_STENCIL_OPS);
ASSERT(pDesc->mStencilBackPass < StencilOp::MAX_STENCIL_OPS);
VkPipelineDepthStencilStateCreateInfo ds = {};
ds.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
ds.pNext = NULL;
ds.flags = 0;
ds.depthTestEnable = pDesc->mDepthTest ? VK_TRUE : VK_FALSE;
ds.depthWriteEnable = pDesc->mDepthWrite ? VK_TRUE : VK_FALSE;
ds.depthCompareOp = gVkComparisonFuncTranslator[pDesc->mDepthFunc];
ds.depthBoundsTestEnable = VK_FALSE;
ds.stencilTestEnable = pDesc->mStencilTest ? VK_TRUE : VK_FALSE;
ds.front.failOp = gVkStencilOpTranslator[pDesc->mStencilFrontFail];
ds.front.passOp = gVkStencilOpTranslator[pDesc->mStencilFrontPass];
ds.front.depthFailOp = gVkStencilOpTranslator[pDesc->mDepthFrontFail];
ds.front.compareOp = VkCompareOp(pDesc->mStencilFrontFunc);
ds.front.compareMask = pDesc->mStencilReadMask;
ds.front.writeMask = pDesc->mStencilWriteMask;
ds.front.reference = 0;
ds.back.failOp = gVkStencilOpTranslator[pDesc->mStencilBackFail];
ds.back.passOp = gVkStencilOpTranslator[pDesc->mStencilBackPass];
ds.back.depthFailOp = gVkStencilOpTranslator[pDesc->mDepthBackFail];
ds.back.compareOp = gVkComparisonFuncTranslator[pDesc->mStencilBackFunc];
ds.back.compareMask = pDesc->mStencilReadMask;
ds.back.writeMask = pDesc->mStencilWriteMask; // devsh fixed
ds.back.reference = 0;
ds.minDepthBounds = 0;
ds.maxDepthBounds = 1;
return ds;
}
static inline VkPipelineRasterizationStateCreateInfo util_to_rasterizer_desc(const RasterizerStateDesc* pDesc)
{
ASSERT(pDesc->mFillMode < FillMode::MAX_FILL_MODES);
ASSERT(pDesc->mCullMode < CullMode::MAX_CULL_MODES);
ASSERT(pDesc->mFrontFace == FRONT_FACE_CCW || pDesc->mFrontFace == FRONT_FACE_CW);
VkPipelineRasterizationStateCreateInfo rs = {};
rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rs.pNext = NULL;
rs.flags = 0;
rs.depthClampEnable = VK_TRUE;
rs.rasterizerDiscardEnable = VK_FALSE;
rs.polygonMode = gVkFillModeTranslator[pDesc->mFillMode];
rs.cullMode = gVkCullModeTranslator[pDesc->mCullMode];
rs.frontFace = gVkFrontFaceTranslator[pDesc->mFrontFace];
rs.depthBiasEnable = (pDesc->mDepthBias != 0) ? VK_TRUE : VK_FALSE;
rs.depthBiasConstantFactor = float(pDesc->mDepthBias);
rs.depthBiasClamp = 0.0f;
rs.depthBiasSlopeFactor = pDesc->mSlopeScaledDepthBias;
rs.lineWidth = 1;
return rs;
}
/************************************************************************/
// Create default resources to be used a null descriptors in case user does not specify some descriptors
/************************************************************************/
static VkPipelineRasterizationStateCreateInfo gDefaultRasterizerDesc = {};
static VkPipelineDepthStencilStateCreateInfo gDefaultDepthDesc = {};
static VkPipelineColorBlendStateCreateInfo gDefaultBlendDesc = {};
static VkPipelineColorBlendAttachmentState gDefaultBlendAttachments[MAX_RENDER_TARGET_ATTACHMENTS] = {};
typedef struct NullDescriptors
{
Texture* pDefaultTextureSRV[MAX_GPUS][TEXTURE_DIM_COUNT];
Texture* pDefaultTextureUAV[MAX_GPUS][TEXTURE_DIM_COUNT];
Buffer* pDefaultBufferSRV[MAX_GPUS];
Buffer* pDefaultBufferUAV[MAX_GPUS];
Sampler* pDefaultSampler;
} NullDescriptors;
static void add_default_resources(Renderer* pRenderer)
{
pRenderer->pNullDescriptors = (NullDescriptors*)conf_calloc(1, sizeof(NullDescriptors));
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
{
// 1D texture
TextureDesc textureDesc = {};
textureDesc.mNodeIndex = i;
textureDesc.mArraySize = 1;
textureDesc.mDepth = 1;
textureDesc.mFormat = TinyImageFormat_R8G8B8A8_UNORM;
textureDesc.mHeight = 1;
textureDesc.mMipLevels = 1;
textureDesc.mSampleCount = SAMPLE_COUNT_1;
textureDesc.mStartState = RESOURCE_STATE_COMMON;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
textureDesc.mWidth = 1;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_1D]);
textureDesc.mDescriptors = DESCRIPTOR_TYPE_RW_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureUAV[i][TEXTURE_DIM_1D]);
// 1D texture array
textureDesc.mArraySize = 2;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_1D_ARRAY]);
textureDesc.mDescriptors = DESCRIPTOR_TYPE_RW_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureUAV[i][TEXTURE_DIM_1D_ARRAY]);
// 2D texture
textureDesc.mWidth = 2;
textureDesc.mHeight = 2;
textureDesc.mArraySize = 1;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_2D]);
textureDesc.mDescriptors = DESCRIPTOR_TYPE_RW_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureUAV[i][TEXTURE_DIM_2D]);
// 2D MS texture
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
textureDesc.mSampleCount = SAMPLE_COUNT_2;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_2DMS]);
textureDesc.mSampleCount = SAMPLE_COUNT_1;
// 2D texture array
textureDesc.mArraySize = 2;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_2D_ARRAY]);
textureDesc.mDescriptors = DESCRIPTOR_TYPE_RW_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureUAV[i][TEXTURE_DIM_2D_ARRAY]);
// 2D MS texture array
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
textureDesc.mSampleCount = SAMPLE_COUNT_2;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_2DMS_ARRAY]);
textureDesc.mSampleCount = SAMPLE_COUNT_1;
// 3D texture
textureDesc.mDepth = 2;
textureDesc.mArraySize = 1;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_3D]);
textureDesc.mDescriptors = DESCRIPTOR_TYPE_RW_TEXTURE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureUAV[i][TEXTURE_DIM_3D]);
// Cube texture
textureDesc.mWidth = 2;
textureDesc.mHeight = 2;
textureDesc.mDepth = 1;
textureDesc.mArraySize = 6;
textureDesc.mDescriptors = DESCRIPTOR_TYPE_TEXTURE_CUBE;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_CUBE]);
textureDesc.mArraySize = 6 * 2;
addTexture(pRenderer, &textureDesc, &pRenderer->pNullDescriptors->pDefaultTextureSRV[i][TEXTURE_DIM_CUBE_ARRAY]);
BufferDesc bufferDesc = {};
bufferDesc.mNodeIndex = i;
bufferDesc.mDescriptors = DESCRIPTOR_TYPE_BUFFER | DESCRIPTOR_TYPE_UNIFORM_BUFFER;
bufferDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_GPU_ONLY;
bufferDesc.mStartState = RESOURCE_STATE_COMMON;
bufferDesc.mSize = sizeof(uint32_t);
bufferDesc.mFirstElement = 0;
bufferDesc.mElementCount = 1;
bufferDesc.mStructStride = sizeof(uint32_t);
bufferDesc.mFormat = TinyImageFormat_R32_UINT;
addBuffer(pRenderer, &bufferDesc, &pRenderer->pNullDescriptors->pDefaultBufferSRV[i]);
bufferDesc.mDescriptors = DESCRIPTOR_TYPE_RW_BUFFER;
addBuffer(pRenderer, &bufferDesc, &pRenderer->pNullDescriptors->pDefaultBufferUAV[i]);
}
SamplerDesc samplerDesc = {};
samplerDesc.mAddressU = ADDRESS_MODE_CLAMP_TO_BORDER;
samplerDesc.mAddressV = ADDRESS_MODE_CLAMP_TO_BORDER;
samplerDesc.mAddressW = ADDRESS_MODE_CLAMP_TO_BORDER;
addSampler(pRenderer, &samplerDesc, &pRenderer->pNullDescriptors->pDefaultSampler);
BlendStateDesc blendStateDesc = {};
blendStateDesc.mDstAlphaFactors[0] = BC_ZERO;
blendStateDesc.mDstFactors[0] = BC_ZERO;
blendStateDesc.mSrcAlphaFactors[0] = BC_ONE;
blendStateDesc.mSrcFactors[0] = BC_ONE;
blendStateDesc.mMasks[0] = ALL;
blendStateDesc.mRenderTargetMask = BLEND_STATE_TARGET_ALL;
blendStateDesc.mIndependentBlend = false;
gDefaultBlendDesc = util_to_blend_desc(&blendStateDesc, gDefaultBlendAttachments);
DepthStateDesc depthStateDesc = {};
depthStateDesc.mDepthFunc = CMP_LEQUAL;
depthStateDesc.mDepthTest = false;
depthStateDesc.mDepthWrite = false;
depthStateDesc.mStencilBackFunc = CMP_ALWAYS;
depthStateDesc.mStencilFrontFunc = CMP_ALWAYS;
depthStateDesc.mStencilReadMask = 0xFF;
depthStateDesc.mStencilWriteMask = 0xFF;
gDefaultDepthDesc = util_to_depth_desc(&depthStateDesc);
RasterizerStateDesc rasterizerStateDesc = {};
rasterizerStateDesc.mCullMode = CULL_MODE_BACK;
gDefaultRasterizerDesc = util_to_rasterizer_desc(&rasterizerStateDesc);
// Create command buffer to transition resources to the correct state
Queue* graphicsQueue = {};
CmdPool* cmdPool = {};
Cmd* cmd = {};
QueueDesc queueDesc = {};
queueDesc.mType = QUEUE_TYPE_GRAPHICS;
addQueue(pRenderer, &queueDesc, &graphicsQueue);
CmdPoolDesc cmdPoolDesc = {};
cmdPoolDesc.pQueue = graphicsQueue;
cmdPoolDesc.mTransient = true;
addCmdPool(pRenderer, &cmdPoolDesc, &cmdPool);
CmdDesc cmdDesc = {};
cmdDesc.pPool = cmdPool;
addCmd(pRenderer, &cmdDesc, &cmd);
// Transition resources
beginCmd(cmd);
eastl::vector<BufferBarrier> bufferBarriers;
eastl::vector<TextureBarrier> textureBarriers;
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
{
for (uint32_t dim = 0; dim < TEXTURE_DIM_COUNT; ++dim)
{
if (pRenderer->pNullDescriptors->pDefaultTextureSRV[i][dim])
textureBarriers.push_back(TextureBarrier{ pRenderer->pNullDescriptors->pDefaultTextureSRV[i][dim], RESOURCE_STATE_SHADER_RESOURCE });
if (pRenderer->pNullDescriptors->pDefaultTextureUAV[i][dim])
textureBarriers.push_back(TextureBarrier{ pRenderer->pNullDescriptors->pDefaultTextureUAV[i][dim], RESOURCE_STATE_UNORDERED_ACCESS });
}
bufferBarriers.push_back(BufferBarrier{ pRenderer->pNullDescriptors->pDefaultBufferSRV[i], RESOURCE_STATE_SHADER_RESOURCE, false });
bufferBarriers.push_back(BufferBarrier{ pRenderer->pNullDescriptors->pDefaultBufferUAV[i], RESOURCE_STATE_UNORDERED_ACCESS, false });
}
uint32_t bufferBarrierCount = (uint32_t)bufferBarriers.size();
uint32_t textureBarrierCount = (uint32_t)textureBarriers.size();
cmdResourceBarrier(cmd, bufferBarrierCount, bufferBarriers.data(), textureBarrierCount, textureBarriers.data(), 0, NULL);
endCmd(cmd);
QueueSubmitDesc submitDesc = {};
submitDesc.mCmdCount = 1;
submitDesc.ppCmds = &cmd;
queueSubmit(graphicsQueue, &submitDesc);
waitQueueIdle(graphicsQueue);
// Delete command buffer
removeCmd(pRenderer, cmd);
removeCmdPool(pRenderer, cmdPool);
removeQueue(pRenderer, graphicsQueue);
}
static void remove_default_resources(Renderer* pRenderer)
{
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
{
for (uint32_t dim = 0; dim < TEXTURE_DIM_COUNT; ++dim)
{
if (pRenderer->pNullDescriptors->pDefaultTextureSRV[i][dim])
removeTexture(pRenderer, pRenderer->pNullDescriptors->pDefaultTextureSRV[i][dim]);
if (pRenderer->pNullDescriptors->pDefaultTextureUAV[i][dim])
removeTexture(pRenderer, pRenderer->pNullDescriptors->pDefaultTextureUAV[i][dim]);
}
removeBuffer(pRenderer, pRenderer->pNullDescriptors->pDefaultBufferSRV[i]);
removeBuffer(pRenderer, pRenderer->pNullDescriptors->pDefaultBufferUAV[i]);
}
removeSampler(pRenderer, pRenderer->pNullDescriptors->pDefaultSampler);
SAFE_FREE(pRenderer->pNullDescriptors);
}
/************************************************************************/
// Globals
/************************************************************************/
static tfrg_atomic64_t gRenderTargetIds = 1;
/************************************************************************/
// Internal utility functions
/************************************************************************/
VkFilter util_to_vk_filter(FilterType filter)
{
switch (filter)
{
case FILTER_NEAREST: return VK_FILTER_NEAREST;
case FILTER_LINEAR: return VK_FILTER_LINEAR;
default: return VK_FILTER_LINEAR;
}
}
VkSamplerMipmapMode util_to_vk_mip_map_mode(MipMapMode mipMapMode)
{
switch (mipMapMode)
{
case MIPMAP_MODE_NEAREST: return VK_SAMPLER_MIPMAP_MODE_NEAREST;
case MIPMAP_MODE_LINEAR: return VK_SAMPLER_MIPMAP_MODE_LINEAR;
default: ASSERT(false && "Invalid Mip Map Mode"); return VK_SAMPLER_MIPMAP_MODE_MAX_ENUM;
}
}
VkSamplerAddressMode util_to_vk_address_mode(AddressMode addressMode)
{
switch (addressMode)
{
case ADDRESS_MODE_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
case ADDRESS_MODE_REPEAT: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
case ADDRESS_MODE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
case ADDRESS_MODE_CLAMP_TO_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
default: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
}
}
VkShaderStageFlags util_to_vk_shader_stages(ShaderStage shader_stages)
{
VkShaderStageFlags result = 0;
if (SHADER_STAGE_ALL_GRAPHICS == (shader_stages & SHADER_STAGE_ALL_GRAPHICS))
{
result = VK_SHADER_STAGE_ALL_GRAPHICS;
}
else
{
if (SHADER_STAGE_VERT == (shader_stages & SHADER_STAGE_VERT))
{
result |= VK_SHADER_STAGE_VERTEX_BIT;
}
if (SHADER_STAGE_TESC == (shader_stages & SHADER_STAGE_TESC))
{
result |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
}
if (SHADER_STAGE_TESE == (shader_stages & SHADER_STAGE_TESE))
{
result |= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
}
if (SHADER_STAGE_GEOM == (shader_stages & SHADER_STAGE_GEOM))
{
result |= VK_SHADER_STAGE_GEOMETRY_BIT;
}
if (SHADER_STAGE_FRAG == (shader_stages & SHADER_STAGE_FRAG))
{
result |= VK_SHADER_STAGE_FRAGMENT_BIT;
}
if (SHADER_STAGE_COMP == (shader_stages & SHADER_STAGE_COMP))
{
result |= VK_SHADER_STAGE_COMPUTE_BIT;
}
}
return result;
}
VkSampleCountFlagBits util_to_vk_sample_count(SampleCount sampleCount)
{
VkSampleCountFlagBits result = VK_SAMPLE_COUNT_1_BIT;
switch (sampleCount)
{
case SAMPLE_COUNT_1: result = VK_SAMPLE_COUNT_1_BIT; break;
case SAMPLE_COUNT_2: result = VK_SAMPLE_COUNT_2_BIT; break;
case SAMPLE_COUNT_4: result = VK_SAMPLE_COUNT_4_BIT; break;
case SAMPLE_COUNT_8: result = VK_SAMPLE_COUNT_8_BIT; break;
case SAMPLE_COUNT_16: result = VK_SAMPLE_COUNT_16_BIT; break;
}
return result;
}
VkBufferUsageFlags util_to_vk_buffer_usage(DescriptorType usage, bool typed)
{
VkBufferUsageFlags result = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
if (usage & DESCRIPTOR_TYPE_UNIFORM_BUFFER)
{
result |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
}
if (usage & DESCRIPTOR_TYPE_RW_BUFFER)
{
result |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
if (typed)
result |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
}
if (usage & DESCRIPTOR_TYPE_BUFFER)
{
result |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
if (typed)
result |= VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
}
if (usage & DESCRIPTOR_TYPE_INDEX_BUFFER)
{
result |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
}
if (usage & DESCRIPTOR_TYPE_VERTEX_BUFFER)
{
result |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
}
if (usage & DESCRIPTOR_TYPE_INDIRECT_BUFFER)
{
result |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
}
#ifdef ENABLE_RAYTRACING
if (usage & DESCRIPTOR_TYPE_RAY_TRACING)
{
result |= VK_BUFFER_USAGE_RAY_TRACING_BIT_NV;
}
#endif
return result;
}
VkImageUsageFlags util_to_vk_image_usage(DescriptorType usage)
{
VkImageUsageFlags result = 0;
if (DESCRIPTOR_TYPE_TEXTURE == (usage & DESCRIPTOR_TYPE_TEXTURE))
result |= VK_IMAGE_USAGE_SAMPLED_BIT;
if (DESCRIPTOR_TYPE_RW_TEXTURE == (usage & DESCRIPTOR_TYPE_RW_TEXTURE))
result |= VK_IMAGE_USAGE_STORAGE_BIT;
return result;
}
VkAccessFlags util_to_vk_access_flags(ResourceState state)
{
VkAccessFlags ret = 0;
if (state & RESOURCE_STATE_COPY_SOURCE)
{
ret |= VK_ACCESS_TRANSFER_READ_BIT;
}
if (state & RESOURCE_STATE_COPY_DEST)
{
ret |= VK_ACCESS_TRANSFER_WRITE_BIT;
}
if (state & RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER)
{
ret |= VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
}
if (state & RESOURCE_STATE_INDEX_BUFFER)
{
ret |= VK_ACCESS_INDEX_READ_BIT;
}
if (state & RESOURCE_STATE_UNORDERED_ACCESS)
{
ret |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
}
if (state & RESOURCE_STATE_INDIRECT_ARGUMENT)
{
ret |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
}
if (state & RESOURCE_STATE_RENDER_TARGET)
{
ret |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
}
if (state & RESOURCE_STATE_DEPTH_WRITE)
{
ret |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
}
if ((state & RESOURCE_STATE_SHADER_RESOURCE) || (state & RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE))
{
ret |= VK_ACCESS_SHADER_READ_BIT;
}
if (state & RESOURCE_STATE_PRESENT)
{
ret |= VK_ACCESS_MEMORY_READ_BIT;
}
return ret;
}
VkImageLayout util_to_vk_image_layout(ResourceState usage)
{
if (usage & RESOURCE_STATE_COPY_SOURCE)
return VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
if (usage & RESOURCE_STATE_COPY_DEST)
return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
if (usage & RESOURCE_STATE_RENDER_TARGET)
return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
if (usage & RESOURCE_STATE_DEPTH_WRITE)
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
if (usage & RESOURCE_STATE_UNORDERED_ACCESS)
return VK_IMAGE_LAYOUT_GENERAL;
if ((usage & RESOURCE_STATE_SHADER_RESOURCE) || (usage & RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE))
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
if (usage & RESOURCE_STATE_PRESENT)
return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
if (usage == RESOURCE_STATE_COMMON)
return VK_IMAGE_LAYOUT_GENERAL;
return VK_IMAGE_LAYOUT_UNDEFINED;
}
// Determines pipeline stages involved for given accesses
VkPipelineStageFlags util_determine_pipeline_stage_flags(VkAccessFlags accessFlags, QueueType queueType)
{
VkPipelineStageFlags flags = 0;
switch (queueType)
{
case QUEUE_TYPE_GRAPHICS:
{
if ((accessFlags & (VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
if ((accessFlags & (VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT)) != 0)
{
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT;
flags |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
flags |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
flags |= VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT;
flags |= VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT;
flags |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
#ifdef ENABLE_RAYTRACING
flags |= VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV;
#endif
}
if ((accessFlags & VK_ACCESS_INPUT_ATTACHMENT_READ_BIT) != 0)
flags |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
if ((accessFlags & (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
if ((accessFlags & (VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
break;
}
case QUEUE_TYPE_COMPUTE:
{
if ((accessFlags & (VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT)) != 0 ||
(accessFlags & VK_ACCESS_INPUT_ATTACHMENT_READ_BIT) != 0 ||
(accessFlags & (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)) != 0 ||
(accessFlags & (VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT)) != 0)
return VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
if ((accessFlags & (VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
break;
}
case QUEUE_TYPE_TRANSFER:
return VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
default:
break;
}
// Compatible with both compute and graphics queues
if ((accessFlags & VK_ACCESS_INDIRECT_COMMAND_READ_BIT) != 0)
flags |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
if ((accessFlags & (VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
if ((accessFlags & (VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_HOST_BIT;
if (flags == 0)
flags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
return flags;
}
VkImageAspectFlags util_vk_determine_aspect_mask(VkFormat format, bool includeStencilBit)
{
VkImageAspectFlags result = 0;
switch (format)
{
// Depth
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_X8_D24_UNORM_PACK32:
case VK_FORMAT_D32_SFLOAT:
result = VK_IMAGE_ASPECT_DEPTH_BIT;
break;
// Stencil
case VK_FORMAT_S8_UINT:
result = VK_IMAGE_ASPECT_STENCIL_BIT;
break;
// Depth/stencil
case VK_FORMAT_D16_UNORM_S8_UINT:
case VK_FORMAT_D24_UNORM_S8_UINT:
case VK_FORMAT_D32_SFLOAT_S8_UINT:
result = VK_IMAGE_ASPECT_DEPTH_BIT;
if (includeStencilBit) result |= VK_IMAGE_ASPECT_STENCIL_BIT;
break;
// Assume everything else is Color
default: result = VK_IMAGE_ASPECT_COLOR_BIT; break;
}
return result;
}
VkFormatFeatureFlags util_vk_image_usage_to_format_features(VkImageUsageFlags usage)
{
VkFormatFeatureFlags result = (VkFormatFeatureFlags)0;
if (VK_IMAGE_USAGE_SAMPLED_BIT == (usage & VK_IMAGE_USAGE_SAMPLED_BIT))
{
result |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
}
if (VK_IMAGE_USAGE_STORAGE_BIT == (usage & VK_IMAGE_USAGE_STORAGE_BIT))
{
result |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
}
if (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT == (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
{
result |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
}
if (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT == (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
{
result |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
return result;
}
VkQueueFlags util_to_vk_queue_flags(QueueType queueType)
{
switch (queueType)
{
case QUEUE_TYPE_GRAPHICS: return VK_QUEUE_GRAPHICS_BIT;
case QUEUE_TYPE_TRANSFER: return VK_QUEUE_TRANSFER_BIT;
case QUEUE_TYPE_COMPUTE: return VK_QUEUE_COMPUTE_BIT;
default: ASSERT(false && "Invalid Queue Type"); return VK_QUEUE_FLAG_BITS_MAX_ENUM;
}
}
VkDescriptorType util_to_vk_descriptor_type(DescriptorType type)
{
switch (type)
{
case DESCRIPTOR_TYPE_UNDEFINED: ASSERT("Invalid DescriptorInfo Type"); return VK_DESCRIPTOR_TYPE_MAX_ENUM;
case DESCRIPTOR_TYPE_SAMPLER: return VK_DESCRIPTOR_TYPE_SAMPLER;
case DESCRIPTOR_TYPE_TEXTURE: return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
case DESCRIPTOR_TYPE_UNIFORM_BUFFER: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
case DESCRIPTOR_TYPE_RW_TEXTURE: return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
case DESCRIPTOR_TYPE_BUFFER:
case DESCRIPTOR_TYPE_RW_BUFFER: return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
case DESCRIPTOR_TYPE_INPUT_ATTACHMENT: return VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
case DESCRIPTOR_TYPE_TEXEL_BUFFER: return VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
case DESCRIPTOR_TYPE_RW_TEXEL_BUFFER: return VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
#ifdef ENABLE_RAYTRACING
case DESCRIPTOR_TYPE_RAY_TRACING: return VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV;
#endif
default:
ASSERT("Invalid DescriptorInfo Type");
return VK_DESCRIPTOR_TYPE_MAX_ENUM;
break;
}
}
VkShaderStageFlags util_to_vk_shader_stage_flags(ShaderStage stages)
{
VkShaderStageFlags res = 0;
if (stages & SHADER_STAGE_ALL_GRAPHICS)
return VK_SHADER_STAGE_ALL_GRAPHICS;
if (stages & SHADER_STAGE_VERT)
res |= VK_SHADER_STAGE_VERTEX_BIT;
if (stages & SHADER_STAGE_GEOM)
res |= VK_SHADER_STAGE_GEOMETRY_BIT;
if (stages & SHADER_STAGE_TESE)
res |= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
if (stages & SHADER_STAGE_TESC)
res |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
if (stages & SHADER_STAGE_COMP)
res |= VK_SHADER_STAGE_COMPUTE_BIT;
#ifdef ENABLE_RAYTRACING
if (stages & SHADER_STAGE_RAYTRACING)
res |= (
VK_SHADER_STAGE_RAYGEN_BIT_NV |
VK_SHADER_STAGE_ANY_HIT_BIT_NV |
VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV |
VK_SHADER_STAGE_MISS_BIT_NV |
VK_SHADER_STAGE_INTERSECTION_BIT_NV |
VK_SHADER_STAGE_CALLABLE_BIT_NV);
#endif
ASSERT(res != 0);
return res;
}
/************************************************************************/
// Multi GPU Helper Functions
/************************************************************************/
uint32_t util_calculate_shared_device_mask(uint32_t gpuCount) { return (1 << gpuCount) - 1; }
void util_calculate_device_indices(
Renderer* pRenderer, uint32_t nodeIndex, uint32_t* pSharedNodeIndices, uint32_t sharedNodeIndexCount, uint32_t* pIndices)
{
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
pIndices[i] = i;
pIndices[nodeIndex] = nodeIndex;
/************************************************************************/
// Set the node indices which need sharing access to the creation node
// Example: Texture created on GPU0 but GPU1 will need to access it, GPU2 does not care
// pIndices = { 0, 0, 2 }
/************************************************************************/
for (uint32_t i = 0; i < sharedNodeIndexCount; ++i)
pIndices[pSharedNodeIndices[i]] = nodeIndex;
}
/************************************************************************/
// Internal init functions
/************************************************************************/
void CreateInstance(const char* app_name,
const RendererDesc* pDesc,
uint32_t userDefinedInstanceLayerCount,
const char** userDefinedInstanceLayers,
Renderer* pRenderer)
{
// These are the extensions that we have loaded
const char* instanceExtensionCache[MAX_INSTANCE_EXTENSIONS] = {};
uint32_t layerCount = 0;
uint32_t extCount = 0;
vkEnumerateInstanceLayerProperties(&layerCount, NULL);
vkEnumerateInstanceExtensionProperties(NULL, &extCount, NULL);
VkLayerProperties* layers = (VkLayerProperties*)alloca(sizeof(VkLayerProperties) * layerCount);
vkEnumerateInstanceLayerProperties(&layerCount, layers);
VkExtensionProperties* exts = (VkExtensionProperties*)alloca(sizeof(VkExtensionProperties) * extCount);
vkEnumerateInstanceExtensionProperties(NULL, &extCount, exts);
for (uint32_t i = 0; i < layerCount; ++i)
{
internal_log(LOG_TYPE_INFO, layers[i].layerName, "vkinstance-layer");
}
for (uint32_t i = 0; i < extCount; ++i)
{
internal_log(LOG_TYPE_INFO, exts[i].extensionName, "vkinstance-ext");
}
DECLARE_ZERO(VkApplicationInfo, app_info);
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pNext = NULL;
app_info.pApplicationName = app_name;
app_info.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
app_info.pEngineName = "TheForge";
app_info.engineVersion = VK_MAKE_VERSION(1, 0, 0);
app_info.apiVersion = VK_API_VERSION_1_1;
VkResult vk_res = VK_RESULT_MAX_ENUM;
eastl::vector<const char*> layerTemp = eastl::vector<const char*>(userDefinedInstanceLayerCount);
memcpy(layerTemp.data(), userDefinedInstanceLayers, layerTemp.size() * sizeof(char*));
// Instance
{
// check to see if the layers are present
for (uint32_t i = 0; i < (uint32_t)layerTemp.size(); ++i)
{
bool layerFound = false;
for (uint32_t j = 0; j < layerCount; ++j)
{
if (strcmp(userDefinedInstanceLayers[i], layers[j].layerName) == 0)
{
layerFound = true;
break;
}
}
if (layerFound == false)
{
internal_log(LOG_TYPE_WARN, userDefinedInstanceLayers[i], "vkinstance-layer-missing");
// deleate layer and get new index
i = (uint32_t)(
layerTemp.erase(layerTemp.begin() + i) - layerTemp.begin());
}
}
uint32_t extension_count = 0;
const uint32_t initialCount = sizeof(gVkWantedInstanceExtensions) / sizeof(gVkWantedInstanceExtensions[0]);
const uint32_t userRequestedCount = (uint32_t)pDesc->mInstanceExtensionCount;
eastl::vector<const char*> wantedInstanceExtensions(initialCount + userRequestedCount);
for (uint32_t i = 0; i < initialCount; ++i)
{
wantedInstanceExtensions[i] = gVkWantedInstanceExtensions[i];
}
for (uint32_t i = 0; i < userRequestedCount; ++i)
{
wantedInstanceExtensions[initialCount + i] = pDesc->ppInstanceExtensions[i];
}
const uint32_t wanted_extension_count = (uint32_t)wantedInstanceExtensions.size();
// Layer extensions
for (uint32_t i = 0; i < layerTemp.size(); ++i)
{
const char* layer_name = layerTemp[i];
uint32_t count = 0;
vkEnumerateInstanceExtensionProperties(layer_name, &count, NULL);
VkExtensionProperties* properties = (VkExtensionProperties*)conf_calloc(count, sizeof(*properties));
ASSERT(properties != NULL);
vkEnumerateInstanceExtensionProperties(layer_name, &count, properties);
for (uint32_t j = 0; j < count; ++j)
{
for (uint32_t k = 0; k < wanted_extension_count; ++k)
{
if (strcmp(wantedInstanceExtensions[k], properties[j].extensionName) == 0)
{
if (strcmp(wantedInstanceExtensions[k], VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME) == 0)
gDeviceGroupCreationExtension = true;
#ifdef USE_DEBUG_UTILS_EXTENSION
if (strcmp(wantedInstanceExtensions[k], VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0)
gDebugUtilsExtension = true;
#endif
instanceExtensionCache[extension_count++] = wantedInstanceExtensions[k];
// clear wanted extenstion so we dont load it more then once
wantedInstanceExtensions[k] = "";
break;
}
}
}
SAFE_FREE((void*)properties);
}
// Standalone extensions
{
const char* layer_name = NULL;
uint32_t count = 0;
vkEnumerateInstanceExtensionProperties(layer_name, &count, NULL);
if (count > 0)
{
VkExtensionProperties* properties = (VkExtensionProperties*)conf_calloc(count, sizeof(*properties));
ASSERT(properties != NULL);
vkEnumerateInstanceExtensionProperties(layer_name, &count, properties);
for (uint32_t j = 0; j < count; ++j)
{
for (uint32_t k = 0; k < wanted_extension_count; ++k)
{
if (strcmp(wantedInstanceExtensions[k], properties[j].extensionName) == 0)
{
instanceExtensionCache[extension_count++] = wantedInstanceExtensions[k];
// clear wanted extenstion so we dont load it more then once
//gVkWantedInstanceExtensions[k] = "";
if (strcmp(wantedInstanceExtensions[k], VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME) == 0)
gDeviceGroupCreationExtension = true;
#ifdef USE_DEBUG_UTILS_EXTENSION
if (strcmp(wantedInstanceExtensions[k], VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0)
gDebugUtilsExtension = true;
#endif
break;
}
}
}
SAFE_FREE((void*)properties);
}
}
#if VK_HEADER_VERSION >= 108
VkValidationFeaturesEXT validationFeaturesExt = { VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT };
VkValidationFeatureEnableEXT enabledValidationFeatures[] =
{
VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,
};
if (pDesc->mEnableGPUBasedValidation)
{
validationFeaturesExt.enabledValidationFeatureCount = 1;
validationFeaturesExt.pEnabledValidationFeatures = enabledValidationFeatures;
}
#endif
// Add more extensions here
DECLARE_ZERO(VkInstanceCreateInfo, create_info);
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
#if VK_HEADER_VERSION >= 108
create_info.pNext = &validationFeaturesExt;
#endif
create_info.flags = 0;
create_info.pApplicationInfo = &app_info;
create_info.enabledLayerCount = (uint32_t)layerTemp.size();
create_info.ppEnabledLayerNames = layerTemp.data();
create_info.enabledExtensionCount = extension_count;
create_info.ppEnabledExtensionNames = instanceExtensionCache;
vk_res = vkCreateInstance(&create_info, NULL, &(pRenderer->pVkInstance));
ASSERT(VK_SUCCESS == vk_res);
}
#if defined(NX64)
loadExtensionsNX(pRenderer->pVkInstance);
#else
// Load Vulkan instance functions
volkLoadInstance(pRenderer->pVkInstance);
#endif
// Debug
{
#ifdef USE_DEBUG_UTILS_EXTENSION
if (gDebugUtilsExtension)
{
VkDebugUtilsMessengerCreateInfoEXT create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
create_info.pfnUserCallback = internal_debug_report_callback;
create_info.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
create_info.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
create_info.flags = 0;
create_info.pUserData = NULL;
VkResult res = vkCreateDebugUtilsMessengerEXT(pRenderer->pVkInstance, &create_info, NULL, &(pRenderer->pVkDebugUtilsMessenger));
if (VK_SUCCESS != res)
{
internal_log(
LOG_TYPE_ERROR, "vkCreateDebugUtilsMessengerEXT failed - disabling Vulkan debug callbacks",
"internal_vk_init_instance");
}
}
#else
DECLARE_ZERO(VkDebugReportCallbackCreateInfoEXT, create_info);
create_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
create_info.pNext = NULL;
create_info.pfnCallback = internal_debug_report_callback;
create_info.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT |
#if defined(NX64) || defined(__ANDROID__)
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | // Performance warnings are not very vaild on desktop
#endif
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_DEBUG_BIT_EXT/* | VK_DEBUG_REPORT_INFORMATION_BIT_EXT*/;
VkResult res = vkCreateDebugReportCallbackEXT(pRenderer->pVkInstance, &create_info, NULL, &(pRenderer->pVkDebugReport));
if (VK_SUCCESS != res)
{
internal_log(
LOG_TYPE_ERROR, "vkCreateDebugReportCallbackEXT failed - disabling Vulkan debug callbacks", "internal_vk_init_instance");
}
#endif
}
}
static void RemoveInstance(Renderer* pRenderer)
{
ASSERT(VK_NULL_HANDLE != pRenderer->pVkInstance);
#ifdef USE_DEBUG_UTILS_EXTENSION
if (pRenderer->pVkDebugUtilsMessenger)
{
vkDestroyDebugUtilsMessengerEXT(pRenderer->pVkInstance, pRenderer->pVkDebugUtilsMessenger, NULL);
pRenderer->pVkDebugUtilsMessenger = NULL;
}
#else
if (pRenderer->pVkDebugReport)
{
vkDestroyDebugReportCallbackEXT(pRenderer->pVkInstance, pRenderer->pVkDebugReport, NULL);
pRenderer->pVkDebugReport = NULL;
}
#endif
vkDestroyInstance(pRenderer->pVkInstance, NULL);
}
static void AddDevice(const RendererDesc* pDesc, Renderer* pRenderer)
{
ASSERT(VK_NULL_HANDLE != pRenderer->pVkInstance);
// These are the extensions that we have loaded
const char* deviceExtensionCache[MAX_DEVICE_EXTENSIONS] = {};
VkResult vk_res = VK_RESULT_MAX_ENUM;
#if VK_KHR_device_group_creation
VkDeviceGroupDeviceCreateInfoKHR deviceGroupInfo = { VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR };
eastl::vector<VkPhysicalDeviceGroupPropertiesKHR> props;
pRenderer->mLinkedNodeCount = 1;
if (pRenderer->mGpuMode == GPU_MODE_LINKED && gDeviceGroupCreationExtension)
{
// (not shown) fill out devCreateInfo as usual.
uint32_t deviceGroupCount = 0;
// Query the number of device groups
vkEnumeratePhysicalDeviceGroupsKHR(pRenderer->pVkInstance, &deviceGroupCount, NULL);
// Allocate and initialize structures to query the device groups
props.resize(deviceGroupCount);
for (uint32_t i = 0; i < deviceGroupCount; ++i)
{
props[i].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR;
props[i].pNext = NULL;
}
vk_res = vkEnumeratePhysicalDeviceGroupsKHR(pRenderer->pVkInstance, &deviceGroupCount, props.data());
ASSERT(VK_SUCCESS == vk_res);
// If the first device group has more than one physical device. create
// a logical device using all of the physical devices.
for (uint32_t i = 0; i < deviceGroupCount; ++i)
{
if (props[i].physicalDeviceCount > 1)
{
deviceGroupInfo.physicalDeviceCount = props[i].physicalDeviceCount;
deviceGroupInfo.pPhysicalDevices = props[i].physicalDevices;
pRenderer->mLinkedNodeCount = deviceGroupInfo.physicalDeviceCount;
break;
}
}
}
#endif
if (pRenderer->mLinkedNodeCount < 2)
{
pRenderer->mGpuMode = GPU_MODE_SINGLE;
}
uint32_t gpuCount = 0;
VkPhysicalDevice gpus[MAX_GPUS] = {};
VkPhysicalDeviceProperties2 gpuProperties[MAX_GPUS] = {};
VkPhysicalDeviceMemoryProperties gpuMemoryProperties[MAX_GPUS] = {};
VkPhysicalDeviceFeatures2KHR gpuFeatures[MAX_GPUS] = {};
VkQueueFamilyProperties* queueFamilyProperties[MAX_GPUS] = {};
uint32_t queueFamilyPropertyCount[MAX_GPUS] = {};
vk_res = vkEnumeratePhysicalDevices(pRenderer->pVkInstance, &gpuCount, NULL);
ASSERT(VK_SUCCESS == vk_res);
ASSERT(gpuCount);
gpuCount = min<uint32_t>(MAX_GPUS, gpuCount);
vk_res = vkEnumeratePhysicalDevices(pRenderer->pVkInstance, &gpuCount, gpus);
ASSERT(VK_SUCCESS == vk_res);
/************************************************************************/
// Select discrete gpus first
// If we have multiple discrete gpus prefer with bigger VRAM size
// To find VRAM in Vulkan, loop through all the heaps and find if the
// heap has the DEVICE_LOCAL_BIT flag set
/************************************************************************/
auto isDeviceBetter = [&gpuProperties, &gpuMemoryProperties](uint32_t testIndex, uint32_t refIndex)->bool
{
const VkPhysicalDeviceProperties& testProps = gpuProperties[testIndex].properties;
const VkPhysicalDeviceProperties& refProps = gpuProperties[refIndex].properties;
if (testProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU && refProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
{
return true;
}
if (testProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU && refProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{
return false;
}
//compare by preset if both gpu's are of same type (integrated vs discrete)
if (testProps.vendorID == refProps.vendorID && testProps.deviceID == refProps.deviceID)
{
const VkPhysicalDeviceMemoryProperties& testMemoryProps = gpuMemoryProperties[testIndex];
const VkPhysicalDeviceMemoryProperties& refMemoryProps = gpuMemoryProperties[refIndex];
//if presets are the same then sort by vram size
VkDeviceSize totalTestVram = 0;
VkDeviceSize totalRefVram = 0;
for (uint32_t i = 0; i < testMemoryProps.memoryHeapCount; ++i)
{
if (VK_MEMORY_HEAP_DEVICE_LOCAL_BIT & testMemoryProps.memoryHeaps[i].flags)
totalTestVram += testMemoryProps.memoryHeaps[i].size;
}
for (uint32_t i = 0; i < refMemoryProps.memoryHeapCount; ++i)
{
if (VK_MEMORY_HEAP_DEVICE_LOCAL_BIT & refMemoryProps.memoryHeaps[i].flags)
totalRefVram += refMemoryProps.memoryHeaps[i].size;
}
return totalTestVram >= totalRefVram;
}
return false;
};
uint32_t gpuIndex = UINT32_MAX;
GPUSettings gpuSettings[MAX_GPUS] = {};
for (uint32_t i = 0; i < gpuCount; ++i)
{
// Get memory properties
vkGetPhysicalDeviceMemoryProperties(gpus[i], &gpuMemoryProperties[i]);
// Get features
gpuFeatures[i].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
#if VK_EXT_fragment_shader_interlock
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragmentShaderInterlockFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT };
gpuFeatures[i].pNext = &fragmentShaderInterlockFeatures;
#endif
vkGetPhysicalDeviceFeatures2KHR(gpus[i], &gpuFeatures[i]);
// Get device properties
VkPhysicalDeviceSubgroupProperties subgroupProperties = {};
subgroupProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
subgroupProperties.pNext = NULL;
gpuProperties[i].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
gpuProperties[i].pNext = &subgroupProperties;
vkGetPhysicalDeviceProperties2(gpus[i], &gpuProperties[i]);
// Get queue family properties
vkGetPhysicalDeviceQueueFamilyProperties(gpus[i], &queueFamilyPropertyCount[i], NULL);
queueFamilyProperties[i] = (VkQueueFamilyProperties*)conf_calloc(queueFamilyPropertyCount[i], sizeof(VkQueueFamilyProperties));
vkGetPhysicalDeviceQueueFamilyProperties(gpus[i], &queueFamilyPropertyCount[i], queueFamilyProperties[i]);
gpuSettings[i].mUniformBufferAlignment =
(uint32_t)gpuProperties[i].properties.limits.minUniformBufferOffsetAlignment;
gpuSettings[i].mUploadBufferTextureAlignment =
16; // TODO: (uint32_t)pRenderer->mVkGpuProperties[i].properties.limits.optimalBufferCopyOffsetAlignment;
gpuSettings[i].mUploadBufferTextureRowAlignment =
1; // TODO: (uint32_t)pRenderer->mVkGpuProperties[i].properties.limits.optimalBufferCopyRowPitchAlignment;
gpuSettings[i].mMaxVertexInputBindings = gpuProperties[i].properties.limits.maxVertexInputBindings;
gpuSettings[i].mMultiDrawIndirect = gpuProperties[i].properties.limits.maxDrawIndirectCount > 1;
gpuSettings[i].mWaveLaneCount = subgroupProperties.subgroupSize;
#if VK_EXT_fragment_shader_interlock
gpuSettings[i].mROVsSupported = (bool)fragmentShaderInterlockFeatures.fragmentShaderPixelInterlock;
#endif
//save vendor and model Id as string
sprintf(gpuSettings[i].mGpuVendorPreset.mModelId, "%#x", gpuProperties[i].properties.deviceID);
sprintf(gpuSettings[i].mGpuVendorPreset.mVendorId, "%#x", gpuProperties[i].properties.vendorID);
strncpy(
gpuSettings[i].mGpuVendorPreset.mGpuName, gpuProperties[i].properties.deviceName,
MAX_GPU_VENDOR_STRING_LENGTH);
//TODO: Fix once vulkan adds support for revision ID
strncpy(gpuSettings[i].mGpuVendorPreset.mRevisionId, "0x00", MAX_GPU_VENDOR_STRING_LENGTH);
gpuSettings[i].mGpuVendorPreset.mPresetLevel = getGPUPresetLevel(
gpuSettings[i].mGpuVendorPreset.mVendorId, gpuSettings[i].mGpuVendorPreset.mModelId,
gpuSettings[i].mGpuVendorPreset.mRevisionId);
LOGF(LogLevel::eINFO, "GPU[%i] detected. Vendor ID: %x, Model ID: %x, Preset: %s, GPU Name: %s", i,
gpuSettings[i].mGpuVendorPreset.mVendorId,
gpuSettings[i].mGpuVendorPreset.mModelId,
presetLevelToString(gpuSettings[i].mGpuVendorPreset.mPresetLevel),
gpuSettings[i].mGpuVendorPreset.mGpuName);
// Check that gpu supports at least graphics
if (gpuIndex == UINT32_MAX || isDeviceBetter(i, gpuIndex))
{
uint32_t count = queueFamilyPropertyCount[i];
VkQueueFamilyProperties* properties = queueFamilyProperties[i];
//select if graphics queue is available
for (uint32_t j = 0; j < count; j++)
{
//get graphics queue family
if (properties[j].queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
gpuIndex = i;
break;
}
}
}
}
#if defined(AUTOMATED_TESTING) && defined(ACTIVE_TESTING_GPU)
// Overwrite gpuIndex for automatic testing
GPUVendorPreset activeTestingPreset;
bool activeTestingGpu = getActiveGpuConfig(activeTestingPreset);
if (activeTestingGpu)
{
for (uint32_t i = 0; i < pRenderer->mNumOfGPUs; i++)
{
VkPhysicalDeviceProperties& props = gpuProperties[i].properties;
char deviceId[MAX_GPU_VENDOR_STRING_LENGTH];
sprintf(deviceId, "%#x", props.deviceID);
char vendorId[MAX_GPU_VENDOR_STRING_LENGTH];
sprintf(vendorId, "%#x", props.vendorID);
if (strcmp(vendorId, activeTestingPreset.mVendorId) == 0 && strcmp(deviceId, activeTestingPreset.mModelId)==0)
{
gpuIndex = i;
break;
}
}
}
#endif
// If we don't own the instance or device, then we need to set the gpuIndex to the correct physical device
#if defined(VK_USE_DISPATCH_TABLES)
gpuIndex = UINT32_MAX;
for (uint32_t i = 0; i < gpuCount; i++)
{
if (gpus[i] == pRenderer->pVkActiveGPU)
{
gpuIndex = i;
}
}
#endif
ASSERT(gpuIndex != UINT32_MAX);
pRenderer->pVkActiveGPU = gpus[gpuIndex];
pRenderer->pVkActiveGPUProperties = (VkPhysicalDeviceProperties2*)conf_malloc(sizeof(VkPhysicalDeviceProperties2));
pRenderer->pActiveGpuSettings = (GPUSettings*)conf_malloc(sizeof(GPUSettings));
*pRenderer->pVkActiveGPUProperties = gpuProperties[gpuIndex];
*pRenderer->pActiveGpuSettings = gpuSettings[gpuIndex];
ASSERT(VK_NULL_HANDLE != pRenderer->pVkActiveGPU);
LOGF(LogLevel::eINFO, "GPU[%d] is selected as default GPU", gpuIndex);
LOGF(LogLevel::eINFO, "Name of selected gpu: %s", pRenderer->pActiveGpuSettings->mGpuVendorPreset.mGpuName);
LOGF(LogLevel::eINFO, "Vendor id of selected gpu: %s", pRenderer->pActiveGpuSettings->mGpuVendorPreset.mVendorId);
LOGF(LogLevel::eINFO, "Model id of selected gpu: %s", pRenderer->pActiveGpuSettings->mGpuVendorPreset.mModelId);
LOGF(LogLevel::eINFO, "Preset of selected gpu: %s", presetLevelToString(pRenderer->pActiveGpuSettings->mGpuVendorPreset.mPresetLevel));
uint32_t layerCount = 0;
uint32_t extCount = 0;
vkEnumerateDeviceLayerProperties(pRenderer->pVkActiveGPU, &layerCount, NULL);
vkEnumerateDeviceExtensionProperties(pRenderer->pVkActiveGPU, NULL, &extCount, NULL);
VkLayerProperties* layers = (VkLayerProperties*)alloca(sizeof(VkLayerProperties) * layerCount);
vkEnumerateDeviceLayerProperties(pRenderer->pVkActiveGPU, &layerCount, layers);
VkExtensionProperties* exts = (VkExtensionProperties*)alloca(sizeof(VkExtensionProperties) * extCount);
vkEnumerateDeviceExtensionProperties(pRenderer->pVkActiveGPU, NULL, &extCount, exts);
for (uint32_t i = 0; i < layerCount; ++i)
{
internal_log(LOG_TYPE_INFO, layers[i].layerName, "vkdevice-layer");
if (strcmp(layers[i].layerName, "VK_LAYER_RENDERDOC_Capture") == 0)
gRenderDocLayerEnabled = true;
}
for (uint32_t i = 0; i < extCount; ++i)
{
internal_log(LOG_TYPE_INFO, exts[i].extensionName, "vkdevice-ext");
}
uint32_t extension_count = 0;
bool dedicatedAllocationExtension = false;
bool memoryReq2Extension = false;
bool externalMemoryExtension = false;
#if defined(VK_USE_PLATFORM_WIN32_KHR)
bool externalMemoryWin32Extension = false;
#endif
// Standalone extensions
{
const char* layer_name = NULL;
uint32_t initialCount = sizeof(gVkWantedDeviceExtensions) / sizeof(gVkWantedDeviceExtensions[0]);
const uint32_t userRequestedCount = (uint32_t)pDesc->mDeviceExtensionCount;
eastl::vector<const char*> wantedDeviceExtensions(initialCount + userRequestedCount);
for (uint32_t i = 0; i < initialCount; ++i)
{
wantedDeviceExtensions[i] = gVkWantedDeviceExtensions[i];
}
for (uint32_t i = 0; i < userRequestedCount; ++i)
{
wantedDeviceExtensions[initialCount + i] = pDesc->ppDeviceExtensions[i];
}
const uint32_t wanted_extension_count = (uint32_t)wantedDeviceExtensions.size();
uint32_t count = 0;
vkEnumerateDeviceExtensionProperties(pRenderer->pVkActiveGPU, layer_name, &count, NULL);
if (count > 0)
{
VkExtensionProperties* properties = (VkExtensionProperties*)conf_calloc(count, sizeof(*properties));
ASSERT(properties != NULL);
vkEnumerateDeviceExtensionProperties(pRenderer->pVkActiveGPU, layer_name, &count, properties);
for (uint32_t j = 0; j < count; ++j)
{
for (uint32_t k = 0; k < wanted_extension_count; ++k)
{
if (strcmp(wantedDeviceExtensions[k], properties[j].extensionName) == 0)
{
deviceExtensionCache[extension_count++] = wantedDeviceExtensions[k];
#ifndef USE_DEBUG_UTILS_EXTENSION
if (strcmp(wantedDeviceExtensions[k], VK_EXT_DEBUG_MARKER_EXTENSION_NAME) == 0)
gDebugMarkerSupport = true;
#endif
if (strcmp(wantedDeviceExtensions[k], VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME) == 0)
dedicatedAllocationExtension = true;
if (strcmp(wantedDeviceExtensions[k], VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME) == 0)
memoryReq2Extension = true;
if (strcmp(wantedDeviceExtensions[k], VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME) == 0)
externalMemoryExtension = true;
#if defined(VK_USE_PLATFORM_WIN32_KHR)
if (strcmp(wantedDeviceExtensions[k], VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME) == 0)
externalMemoryWin32Extension = true;
#endif
#ifdef VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME
if (strcmp(wantedDeviceExtensions[k], VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME) == 0)
gDrawIndirectCountExtension = true;
#endif
if (strcmp(wantedDeviceExtensions[k], VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME) == 0)
gAMDDrawIndirectCountExtension = true;
if (strcmp(wantedDeviceExtensions[k], VK_AMD_GCN_SHADER_EXTENSION_NAME) == 0)
gAMDGCNShaderExtension = true;
if (strcmp(wantedDeviceExtensions[k], VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) == 0)
gDescriptorIndexingExtension = true;
#ifdef VK_NV_RAY_TRACING_SPEC_VERSION
if (strcmp(wantedDeviceExtensions[k], VK_NV_RAY_TRACING_EXTENSION_NAME) == 0)
{
pRenderer->mRaytracingExtension = 1;
gNVRayTracingExtension = true;
gDescriptorTypeRangeSize = CONF_DESCRIPTOR_TYPE_RANGE_SIZE;
}
#endif
break;
}
}
}
SAFE_FREE((void*)properties);
}
}
#if !defined(VK_USE_DISPATCH_TABLES)
// Add more extensions here
#if VK_EXT_fragment_shader_interlock
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragmentShaderInterlockFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT };
VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptorIndexingFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT, &fragmentShaderInterlockFeatures };
#else
VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptorIndexingFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT };
#endif // VK_EXT_fragment_shader_interlock
VkPhysicalDeviceFeatures2KHR gpuFeatures2 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR };
gpuFeatures2.pNext = &descriptorIndexingFeatures;
#ifndef NX64
vkGetPhysicalDeviceFeatures2KHR(pRenderer->pVkActiveGPU, &gpuFeatures2);
#else
vkGetPhysicalDeviceFeatures2(pRenderer->pVkActiveGPU, &gpuFeatures2);
#endif
// need a queue_priorite for each queue in the queue family we create
uint32_t queueFamiliesCount = queueFamilyPropertyCount[gpuIndex];
VkQueueFamilyProperties* queueFamiliesProperties = queueFamilyProperties[gpuIndex];
eastl::vector<eastl::vector<float> > queue_priorities(queueFamiliesCount);
uint32_t queue_create_infos_count = 0;
DECLARE_ZERO(VkDeviceQueueCreateInfo, queue_create_infos[4]);
//create all queue families with maximum amount of queues
for (uint32_t i = 0; i < queueFamiliesCount; i++)
{
uint32_t queueCount = queueFamiliesProperties[i].queueCount;
if (queueCount > 0)
{
queue_create_infos[queue_create_infos_count].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queue_create_infos[queue_create_infos_count].pNext = NULL;
queue_create_infos[queue_create_infos_count].flags = 0;
queue_create_infos[queue_create_infos_count].queueFamilyIndex = i;
queue_create_infos[queue_create_infos_count].queueCount = queueCount;
queue_priorities[i].resize(queueCount);
memset(queue_priorities[i].data(), 1, queue_priorities[i].size() * sizeof(float));
queue_create_infos[queue_create_infos_count].pQueuePriorities = queue_priorities[i].data();
queue_create_infos_count++;
}
}
DECLARE_ZERO(VkDeviceCreateInfo, create_info);
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
create_info.pNext = &gpuFeatures2;
create_info.flags = 0;
create_info.queueCreateInfoCount = queue_create_infos_count;
create_info.pQueueCreateInfos = queue_create_infos;
create_info.enabledLayerCount = 0;
create_info.ppEnabledLayerNames = NULL;
create_info.enabledExtensionCount = extension_count;
create_info.ppEnabledExtensionNames = deviceExtensionCache;
create_info.pEnabledFeatures = NULL;
/************************************************************************/
// Add Device Group Extension if requested and available
/************************************************************************/
#if VK_KHR_device_group_creation
if (pRenderer->mGpuMode == GPU_MODE_LINKED)
{
create_info.pNext = &deviceGroupInfo;
}
#endif
vk_res = vkCreateDevice(pRenderer->pVkActiveGPU, &create_info, NULL, &(pRenderer->pVkDevice));
ASSERT(VK_SUCCESS == vk_res);
#if !defined(NX64)
// Load Vulkan device functions to bypass loader
volkLoadDevice(pRenderer->pVkDevice);
#endif
queue_priorities.clear();
#endif
gDedicatedAllocationExtension = dedicatedAllocationExtension && memoryReq2Extension;
#if defined(VK_USE_PLATFORM_WIN32_KHR)
gExternalMemoryExtension = externalMemoryExtension && externalMemoryWin32Extension;
#endif
if (gDedicatedAllocationExtension)
{
LOGF(LogLevel::eINFO, "Successfully loaded Dedicated Allocation extension");
}
if (gExternalMemoryExtension)
{
LOGF(LogLevel::eINFO, "Successfully loaded External Memory extension");
}
#ifdef VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME
if (gDrawIndirectCountExtension)
{
pfnVkCmdDrawIndirectCountKHR = vkCmdDrawIndirectCountKHR;
pfnVkCmdDrawIndexedIndirectCountKHR = vkCmdDrawIndexedIndirectCountKHR;
LOGF(LogLevel::eINFO, "Successfully loaded Draw Indirect extension");
}
else if (gAMDDrawIndirectCountExtension)
#endif
{
pfnVkCmdDrawIndirectCountKHR = vkCmdDrawIndirectCountAMD;
pfnVkCmdDrawIndexedIndirectCountKHR = vkCmdDrawIndexedIndirectCountAMD;
LOGF(LogLevel::eINFO, "Successfully loaded AMD Draw Indirect extension");
}
if (gAMDGCNShaderExtension)
{
LOGF(LogLevel::eINFO, "Successfully loaded AMD GCN Shader extension");
}
if (gDescriptorIndexingExtension)
{
LOGF(LogLevel::eINFO, "Successfully loaded Descriptor Indexing extension");
}
if (gNVRayTracingExtension)
{
LOGF(LogLevel::eINFO, "Successfully loaded Nvidia Ray Tracing extension");
}
#ifdef USE_DEBUG_UTILS_EXTENSION
gDebugMarkerSupport = (&vkCmdBeginDebugUtilsLabelEXT) && (&vkCmdEndDebugUtilsLabelEXT) && (&vkCmdInsertDebugUtilsLabelEXT) && (&vkSetDebugUtilsObjectNameEXT);
#endif
for (uint32_t i = 0; i < gpuCount; ++i)
SAFE_FREE(queueFamilyProperties[i]);
utils_caps_builder(pRenderer);
}
static void RemoveDevice(Renderer* pRenderer)
{
vkDestroyDevice(pRenderer->pVkDevice, NULL);
SAFE_FREE(pRenderer->pActiveGpuSettings);
SAFE_FREE(pRenderer->pVkActiveGPUProperties);
}
VkDeviceMemory get_vk_device_memory(Renderer* pRenderer, Buffer* pBuffer)
{
VmaAllocationInfo allocInfo = {};
vmaGetAllocationInfo(pRenderer->pVmaAllocator, pBuffer->pVkAllocation, &allocInfo);
return allocInfo.deviceMemory;
}
uint64_t get_vk_device_memory_offset(Renderer* pRenderer, Buffer* pBuffer)
{
VmaAllocationInfo allocInfo = {};
vmaGetAllocationInfo(pRenderer->pVmaAllocator, pBuffer->pVkAllocation, &allocInfo);
return (uint64_t)allocInfo.offset;
}
/************************************************************************/
// Renderer Init Remove
/************************************************************************/
void initRenderer(const char* appName, const RendererDesc* pDesc, Renderer** ppRenderer)
{
ASSERT(appName);
ASSERT(pDesc);
ASSERT(ppRenderer);
Renderer* pRenderer = (Renderer*)conf_calloc(1, sizeof(Renderer));
ASSERT(pRenderer);
pRenderer->mGpuMode = pDesc->mGpuMode;
pRenderer->mShaderTarget = pDesc->mShaderTarget;
pRenderer->mEnableGpuBasedValidation = pDesc->mEnableGPUBasedValidation;
pRenderer->mApi = RENDERER_API_VULKAN;
pRenderer->pName = (char*)conf_calloc(strlen(appName) + 1, sizeof(char));
memcpy(pRenderer->pName, appName, strlen(appName));
// Initialize the Vulkan internal bits
{
#if defined(VK_USE_DISPATCH_TABLES)
VkResult vkRes = volkInitializeWithDispatchTables(pRenderer);
if (vkRes != VK_SUCCESS)
{
LOGF(LogLevel::eERROR, "Failed to initialize Vulkan");
return;
}
#else
const char** instanceLayers = (const char**)alloca((2 + pDesc->mInstanceLayerCount) * sizeof(char*));
uint32_t instanceLayerCount = 0;
#if defined(_DEBUG)
// this turns on all validation layers
instanceLayers[instanceLayerCount++] = "VK_LAYER_LUNARG_standard_validation";
#endif
// this turns on render doc layer for gpu capture
#ifdef USE_RENDER_DOC
instanceLayers[instanceLayerCount++] = "VK_LAYER_RENDERDOC_Capture";
#endif
// Add user specified instance layers for instance creation
for (uint32_t i = 0; i < (uint32_t)pDesc->mInstanceLayerCount; ++i)
instanceLayers[instanceLayerCount++] = pDesc->ppInstanceLayers[i];
#if !defined(NX64)
VkResult vkRes = volkInitialize();
if (vkRes != VK_SUCCESS)
{
LOGF(LogLevel::eERROR, "Failed to initialize Vulkan");
return;
}
#endif
CreateInstance(appName, pDesc, instanceLayerCount, instanceLayers, pRenderer);
#endif
AddDevice(pDesc, pRenderer);
//anything below LOW preset is not supported and we will exit
if (pRenderer->pActiveGpuSettings->mGpuVendorPreset.mPresetLevel < GPU_PRESET_LOW)
{
//have the condition in the assert as well so its cleared when the assert message box appears
ASSERT(pRenderer->pActiveGpuSettings->mGpuVendorPreset.mPresetLevel >= GPU_PRESET_LOW);
SAFE_FREE(pRenderer->pName);
//remove device and any memory we allocated in just above as this is the first function called
//when initializing the forge
#if !defined(VK_USE_DISPATCH_TABLES)
RemoveDevice(pRenderer);
RemoveInstance(pRenderer);
SAFE_FREE(pRenderer);
LOGF(LogLevel::eERROR, "Selected GPU has an Office Preset in gpu.cfg.");
LOGF(LogLevel::eERROR, "Office preset is not supported by The Forge.");
#endif
//return NULL pRenderer so that client can gracefully handle exit
//This is better than exiting from here in case client has allocated memory or has fallbacks
*pRenderer = {};
return;
}
/************************************************************************/
// Memory allocator
/************************************************************************/
VmaAllocatorCreateInfo createInfo = { 0 };
createInfo.device = pRenderer->pVkDevice;
createInfo.physicalDevice = pRenderer->pVkActiveGPU;
// Render Doc Capture currently does not support use of this extension
if (gDedicatedAllocationExtension && !gRenderDocLayerEnabled)
{
createInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
}
VmaVulkanFunctions vulkanFunctions = {};
vulkanFunctions.vkAllocateMemory = vkAllocateMemory;
vulkanFunctions.vkBindBufferMemory = vkBindBufferMemory;
vulkanFunctions.vkBindImageMemory = vkBindImageMemory;
vulkanFunctions.vkCreateBuffer = vkCreateBuffer;
vulkanFunctions.vkCreateImage = vkCreateImage;
vulkanFunctions.vkDestroyBuffer = vkDestroyBuffer;
vulkanFunctions.vkDestroyImage = vkDestroyImage;
vulkanFunctions.vkFreeMemory = vkFreeMemory;
vulkanFunctions.vkGetBufferMemoryRequirements = vkGetBufferMemoryRequirements;
vulkanFunctions.vkGetBufferMemoryRequirements2KHR = vkGetBufferMemoryRequirements2KHR;
vulkanFunctions.vkGetImageMemoryRequirements = vkGetImageMemoryRequirements;
vulkanFunctions.vkGetImageMemoryRequirements2KHR = vkGetImageMemoryRequirements2KHR;
vulkanFunctions.vkGetPhysicalDeviceMemoryProperties = vkGetPhysicalDeviceMemoryProperties;
vulkanFunctions.vkGetPhysicalDeviceProperties = vkGetPhysicalDeviceProperties;
vulkanFunctions.vkMapMemory = vkMapMemory;
vulkanFunctions.vkUnmapMemory = vkUnmapMemory;
vulkanFunctions.vkFlushMappedMemoryRanges = vkFlushMappedMemoryRanges;
vulkanFunctions.vkInvalidateMappedMemoryRanges = vkInvalidateMappedMemoryRanges;
vulkanFunctions.vkCmdCopyBuffer = vkCmdCopyBuffer;
createInfo.pVulkanFunctions = &vulkanFunctions;
vmaCreateAllocator(&createInfo, &pRenderer->pVmaAllocator);
}
VkDescriptorPoolSize descriptorPoolSizes[CONF_DESCRIPTOR_TYPE_RANGE_SIZE] =
{
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1024 },
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 },
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 8192 },
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1024 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1024 },
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1024 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 8192 },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1024 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1024 },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1 },
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1 },
};
#ifdef VK_NV_RAY_TRACING_SPEC_VERSION
if (gNVRayTracingExtension)
{
descriptorPoolSizes[CONF_DESCRIPTOR_TYPE_RANGE_SIZE - 1] = { VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, 1024 };
}
#endif
add_descriptor_pool(pRenderer, 8192, (VkDescriptorPoolCreateFlags)0, descriptorPoolSizes, gDescriptorTypeRangeSize, &pRenderer->pDescriptorPool);
pRenderPassMutex = (Mutex*)conf_calloc(1, sizeof(Mutex));
pRenderPassMutex->Init();
gRenderPassMap = conf_placement_new<eastl::hash_map<ThreadID, RenderPassMap> >(conf_malloc(sizeof(*gRenderPassMap)));
gFrameBufferMap = conf_placement_new<eastl::hash_map<ThreadID, FrameBufferMap> >(conf_malloc(sizeof(*gFrameBufferMap)));
VkPhysicalDeviceFeatures2KHR gpuFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR };
vkGetPhysicalDeviceFeatures2KHR(pRenderer->pVkActiveGPU, &gpuFeatures);
// Set shader macro based on runtime information
static char descriptorIndexingMacroBuffer[2] = {};
static char textureArrayDynamicIndexingMacroBuffer[2] = {};
sprintf(descriptorIndexingMacroBuffer, "%u", (uint32_t)(gDescriptorIndexingExtension));
sprintf(textureArrayDynamicIndexingMacroBuffer, "%u", (uint32_t)(gpuFeatures.features.shaderSampledImageArrayDynamicIndexing));
static ShaderMacro rendererShaderDefines[] =
{
{ "VK_EXT_DESCRIPTOR_INDEXING_ENABLED", descriptorIndexingMacroBuffer },
{ "VK_FEATURE_TEXTURE_ARRAY_DYNAMIC_INDEXING_ENABLED", textureArrayDynamicIndexingMacroBuffer },
// Descriptor set indices
{ "UPDATE_FREQ_NONE", "set = 0" },
{ "UPDATE_FREQ_PER_FRAME", "set = 1" },
{ "UPDATE_FREQ_PER_BATCH", "set = 2" },
{ "UPDATE_FREQ_PER_DRAW", "set = 3" },
};
pRenderer->mBuiltinShaderDefinesCount = sizeof(rendererShaderDefines) / sizeof(rendererShaderDefines[0]);
pRenderer->pBuiltinShaderDefines = rendererShaderDefines;
const uint32_t maxQueueFlag = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT | VK_QUEUE_PROTECTED_BIT;
pRenderer->pUsedQueueCount = (uint32_t**)conf_malloc(pRenderer->mLinkedNodeCount * sizeof(uint32_t*));
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
pRenderer->pUsedQueueCount[i] = (uint32_t*)conf_calloc(maxQueueFlag, sizeof(uint32_t));
add_default_resources(pRenderer);
// Renderer is good!
*ppRenderer = pRenderer;
}
void removeRenderer(Renderer* pRenderer)
{
ASSERT(pRenderer);
remove_default_resources(pRenderer);
remove_descriptor_pool(pRenderer, pRenderer->pDescriptorPool);
// Remove the renderpasses
for (eastl::hash_map<ThreadID, RenderPassMap>::value_type& t : *gRenderPassMap)
for (RenderPassMapNode& it : t.second)
remove_render_pass(pRenderer, it.second);
for (eastl::hash_map<ThreadID, FrameBufferMap>::value_type& t : *gFrameBufferMap)
for (FrameBufferMapNode& it : t.second)
remove_framebuffer(pRenderer, it.second);
// Destroy the Vulkan bits
vmaDestroyAllocator(pRenderer->pVmaAllocator);
#if defined(VK_USE_DISPATCH_TABLES)
#else
RemoveDevice(pRenderer);
RemoveInstance(pRenderer);
#endif
pRenderPassMutex->Destroy();
gRenderPassMap->clear(true);
gFrameBufferMap->clear(true);
SAFE_FREE(pRenderPassMutex);
SAFE_FREE(gRenderPassMap);
SAFE_FREE(gFrameBufferMap);
for (uint32_t i = 0; i < pRenderer->mLinkedNodeCount; ++i)
SAFE_FREE(pRenderer->pUsedQueueCount[i]);
// Free all the renderer components!
SAFE_FREE(pRenderer->pUsedQueueCount);
SAFE_FREE(pRenderer->pCapBits);
SAFE_FREE(pRenderer->pName);
SAFE_FREE(pRenderer);
}
/************************************************************************/
// Resource Creation Functions
/************************************************************************/
void addFence(Renderer* pRenderer, Fence** ppFence)
{
ASSERT(pRenderer);
ASSERT(ppFence);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
Fence* pFence = (Fence*)conf_calloc(1, sizeof(Fence));
ASSERT(pFence);
DECLARE_ZERO(VkFenceCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
VkResult vk_res = vkCreateFence(pRenderer->pVkDevice, &add_info, NULL, &(pFence->pVkFence));
ASSERT(VK_SUCCESS == vk_res);
pFence->mSubmitted = false;
*ppFence = pFence;
}
void removeFence(Renderer* pRenderer, Fence* pFence)
{
ASSERT(pRenderer);
ASSERT(pFence);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pFence->pVkFence);
vkDestroyFence(pRenderer->pVkDevice, pFence->pVkFence, NULL);
SAFE_FREE(pFence);
}
void addSemaphore(Renderer* pRenderer, Semaphore** ppSemaphore)
{
ASSERT(pRenderer);
ASSERT(ppSemaphore);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
Semaphore* pSemaphore = (Semaphore*)conf_calloc(1, sizeof(Semaphore));
ASSERT(pSemaphore);
DECLARE_ZERO(VkSemaphoreCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
VkResult vk_res = vkCreateSemaphore(pRenderer->pVkDevice, &add_info, NULL, &(pSemaphore->pVkSemaphore));
ASSERT(VK_SUCCESS == vk_res);
// Set signal inital state.
pSemaphore->mSignaled = false;
*ppSemaphore = pSemaphore;
}
void removeSemaphore(Renderer* pRenderer, Semaphore* pSemaphore)
{
ASSERT(pRenderer);
ASSERT(pSemaphore);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pSemaphore->pVkSemaphore);
vkDestroySemaphore(pRenderer->pVkDevice, pSemaphore->pVkSemaphore, NULL);
SAFE_FREE(pSemaphore);
}
void addQueue(Renderer* pRenderer, QueueDesc* pDesc, Queue** ppQueue)
{
ASSERT(pDesc != NULL);
uint32_t queueFamilyIndex = -1;
VkQueueFlags requiredFlags = util_to_vk_queue_flags(pDesc->mType);
uint32_t queueIndex = -1;
bool found = false;
const uint32_t nodeIndex = pDesc->mNodeIndex;
// Get queue family properties
uint32_t queueFamilyPropertyCount = 0;
VkQueueFamilyProperties* queueFamilyProperties = NULL;
vkGetPhysicalDeviceQueueFamilyProperties(pRenderer->pVkActiveGPU, &queueFamilyPropertyCount, NULL);
queueFamilyProperties = (VkQueueFamilyProperties*)alloca(queueFamilyPropertyCount * sizeof(VkQueueFamilyProperties));
vkGetPhysicalDeviceQueueFamilyProperties(pRenderer->pVkActiveGPU, &queueFamilyPropertyCount, queueFamilyProperties);
// Try to find a dedicated queue of this type
for (uint32_t index = 0; index < queueFamilyPropertyCount; ++index)
{
VkQueueFlags queueFlags = queueFamilyProperties[index].queueFlags;
if ((queueFlags & requiredFlags) && ((queueFlags & ~requiredFlags) == 0) &&
pRenderer->pUsedQueueCount[nodeIndex][queueFlags] < queueFamilyProperties[index].queueCount)
{
found = true;
queueFamilyIndex = index;
queueIndex = pRenderer->pUsedQueueCount[nodeIndex][queueFlags];
break;
}
}
// If hardware doesn't provide a dedicated queue try to find a non-dedicated one
if (!found)
{
for (uint32_t index = 0; index < queueFamilyPropertyCount; ++index)
{
VkQueueFlags queueFlags = queueFamilyProperties[index].queueFlags;
if ((queueFlags & requiredFlags) &&
pRenderer->pUsedQueueCount[nodeIndex][queueFlags] < queueFamilyProperties[index].queueCount)
{
found = true;
queueFamilyIndex = index;
queueIndex = pRenderer->pUsedQueueCount[nodeIndex][queueFlags];
break;
}
}
}
if (!found)
{
found = true;
queueFamilyIndex = 0;
queueIndex = 0;
LOGF(LogLevel::eWARNING, "Could not find queue of type %u. Using default queue", (uint32_t)pDesc->mType);
}
if (found)
{
VkQueueFamilyProperties& queueProps = queueFamilyProperties[queueFamilyIndex];
Queue* pQueue = (Queue*)conf_calloc(1, sizeof(Queue));
ASSERT(pQueue);
pQueue->mVkQueueFamilyIndex = queueFamilyIndex;
pQueue->mNodeIndex = pDesc->mNodeIndex;
pQueue->mType = pDesc->mType;
pQueue->mVkQueueIndex = queueIndex;
pQueue->mGpuMode = pRenderer->mGpuMode;
pQueue->mTimestampPeriod = pRenderer->pVkActiveGPUProperties->properties.limits.timestampPeriod;
pQueue->mFlags = queueFamilyProperties[pQueue->mVkQueueFamilyIndex].queueFlags;
pQueue->mUploadGranularity = { queueProps.minImageTransferGranularity.width, queueProps.minImageTransferGranularity.height,
queueProps.minImageTransferGranularity.depth };
//get queue handle
vkGetDeviceQueue(
pRenderer->pVkDevice, pQueue->mVkQueueFamilyIndex, pQueue->mVkQueueIndex, &(pQueue->pVkQueue));
ASSERT(VK_NULL_HANDLE != pQueue->pVkQueue);
++pRenderer->pUsedQueueCount[nodeIndex][queueProps.queueFlags];
*ppQueue = pQueue;
}
else
{
LOGF(LogLevel::eERROR, "Cannot create queue of type (%u)", pDesc->mType);
}
}
void removeQueue(Renderer* pRenderer, Queue* pQueue)
{
ASSERT(pQueue != NULL);
const uint32_t nodeIndex = pQueue->mNodeIndex;
VkQueueFlags queueFlags = pQueue->mFlags;
--pRenderer->pUsedQueueCount[nodeIndex][queueFlags];
SAFE_FREE(pQueue);
}
void addCmdPool(Renderer* pRenderer, const CmdPoolDesc* pDesc, CmdPool** ppCmdPool)
{
ASSERT(pRenderer);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(ppCmdPool);
CmdPool* pCmdPool = (CmdPool*)conf_calloc(1, sizeof(CmdPool));
ASSERT(pCmdPool);
pCmdPool->pQueue = pDesc->pQueue;
DECLARE_ZERO(VkCommandPoolCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
add_info.queueFamilyIndex = pDesc->pQueue->mVkQueueFamilyIndex;
if (pDesc->mTransient)
{
add_info.flags |= VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
}
VkResult vk_res = vkCreateCommandPool(pRenderer->pVkDevice, &add_info, NULL, &(pCmdPool->pVkCmdPool));
ASSERT(VK_SUCCESS == vk_res);
*ppCmdPool = pCmdPool;
}
void removeCmdPool(Renderer* pRenderer, CmdPool* pCmdPool)
{
ASSERT(pRenderer);
ASSERT(pCmdPool);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pCmdPool->pVkCmdPool);
vkDestroyCommandPool(pRenderer->pVkDevice, pCmdPool->pVkCmdPool, NULL);
SAFE_FREE(pCmdPool);
}
void addCmd(Renderer* pRenderer, const CmdDesc* pDesc, Cmd** ppCmd)
{
ASSERT(pRenderer);
ASSERT(VK_NULL_HANDLE != pDesc->pPool);
ASSERT(ppCmd);
Cmd* pCmd = (Cmd*)conf_calloc(1, sizeof(Cmd));
ASSERT(pCmd);
pCmd->pRenderer = pRenderer;
pCmd->pQueue = pDesc->pPool->pQueue;
pCmd->pCmdPool = pDesc->pPool;
pCmd->mType = pDesc->pPool->pQueue->mType;
pCmd->mNodeIndex = pDesc->pPool->pQueue->mNodeIndex;
DECLARE_ZERO(VkCommandBufferAllocateInfo, alloc_info);
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
alloc_info.pNext = NULL;
alloc_info.commandPool = pDesc->pPool->pVkCmdPool;
alloc_info.level = pDesc->mSecondary ? VK_COMMAND_BUFFER_LEVEL_SECONDARY : VK_COMMAND_BUFFER_LEVEL_PRIMARY;
alloc_info.commandBufferCount = 1;
VkResult vk_res = vkAllocateCommandBuffers(pRenderer->pVkDevice, &alloc_info, &(pCmd->pVkCmdBuf));
ASSERT(VK_SUCCESS == vk_res);
*ppCmd = pCmd;
}
void removeCmd(Renderer* pRenderer, Cmd* pCmd)
{
ASSERT(pRenderer);
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
vkFreeCommandBuffers(pRenderer->pVkDevice, pCmd->pCmdPool->pVkCmdPool, 1, &(pCmd->pVkCmdBuf));
SAFE_FREE(pCmd);
}
void addCmd_n(Renderer* pRenderer, const CmdDesc* pDesc, uint32_t cmdCount, Cmd*** pppCmd)
{
//verify that ***cmd is valid
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(cmdCount);
ASSERT(pppCmd);
Cmd** ppCmds = (Cmd**)conf_calloc(cmdCount, sizeof(Cmd*));
ASSERT(ppCmds);
//add n new cmds to given pool
for (uint32_t i = 0; i < cmdCount; ++i)
{
::addCmd(pRenderer, pDesc, &ppCmds[i]);
}
*pppCmd = ppCmds;
}
void removeCmd_n(Renderer* pRenderer, uint32_t cmdCount, Cmd** ppCmds)
{
//verify that given command list is valid
ASSERT(ppCmds);
//remove every given cmd in array
for (uint32_t i = 0; i < cmdCount; ++i)
{
removeCmd(pRenderer, ppCmds[i]);
}
SAFE_FREE(ppCmds);
}
void toggleVSync(Renderer* pRenderer, SwapChain** ppSwapChain)
{
SwapChain* pSwapChain = *ppSwapChain;
Queue queue = {};
queue.mVkQueueFamilyIndex = pSwapChain->mPresentQueueFamilyIndex;
Queue* queues[] = { &queue };
SwapChainDesc desc = *pSwapChain->pDesc;
desc.mEnableVsync = !desc.mEnableVsync;
desc.mPresentQueueCount = 1;
desc.ppPresentQueues = queues;
//toggle vsync on or off
//for Vulkan we need to remove the SwapChain and recreate it with correct vsync option
removeSwapChain(pRenderer, pSwapChain);
addSwapChain(pRenderer, &desc, ppSwapChain);
}
void addSwapChain(Renderer* pRenderer, const SwapChainDesc* pDesc, SwapChain** ppSwapChain)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppSwapChain);
ASSERT(pDesc->mImageCount <= MAX_SWAPCHAIN_IMAGES);
SwapChain* pSwapChain = (SwapChain*)conf_calloc(1, sizeof(SwapChain) + pDesc->mImageCount * sizeof(RenderTarget*) + sizeof(SwapChainDesc));
pSwapChain->ppRenderTargets = (RenderTarget**)(pSwapChain + 1);
pSwapChain->pDesc = (SwapChainDesc*)(pSwapChain->ppRenderTargets + pDesc->mImageCount);
ASSERT(pSwapChain);
/************************************************************************/
// Create surface
/************************************************************************/
ASSERT(VK_NULL_HANDLE != pRenderer->pVkInstance);
VkResult vk_res;
// Create a WSI surface for the window:
#if defined(VK_USE_PLATFORM_WIN32_KHR)
DECLARE_ZERO(VkWin32SurfaceCreateInfoKHR, add_info);
add_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.hinstance = ::GetModuleHandle(NULL);
add_info.hwnd = (HWND)pDesc->mWindowHandle.window;
vk_res = vkCreateWin32SurfaceKHR(pRenderer->pVkInstance, &add_info, NULL, &pSwapChain->pVkSurface);
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
DECLARE_ZERO(VkXlibSurfaceCreateInfoKHR, add_info);
add_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.dpy = pDesc->mWindowHandle.display; //TODO
add_info.window = pDesc->mWindowHandle.window; //TODO
vk_res = vkCreateXlibSurfaceKHR(pRenderer->pVkInstance, &add_info, NULL, &pSwapChain->pVkSurface);
#elif defined(VK_USE_PLATFORM_XCB_KHR)
DECLARE_ZERO(VkXcbSurfaceCreateInfoKHR, add_info);
add_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.connection = pDesc->mWindowHandle.connection; //TODO
add_info.window = pDesc->mWindowHandle.window; //TODO
vk_res = vkCreateXcbSurfaceKHR(pRenderer->pVkInstance, &add_info, NULL, &pSwapChain->pVkSurface);
#elif defined(VK_USE_PLATFORM_IOS_MVK)
// Add IOS support here
#elif defined(VK_USE_PLATFORM_MACOS_MVK)
// Add MacOS support here
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
DECLARE_ZERO(VkAndroidSurfaceCreateInfoKHR, add_info);
add_info.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.window = (ANativeWindow*)pDesc->mWindowHandle.window;
vk_res = vkCreateAndroidSurfaceKHR(pRenderer->pVkInstance, &add_info, NULL, &pSwapChain->pVkSurface);
#elif defined(VK_USE_PLATFORM_GGP)
extern VkResult ggpCreateSurface(VkInstance, VkSurfaceKHR* surface);
vk_res = ggpCreateSurface(pRenderer->pVkInstance, &pSwapChain->pVkSurface);
#elif defined(VK_USE_PLATFORM_VI_NN)
extern VkResult nxCreateSurface(VkInstance, VkSurfaceKHR* surface);
vk_res = nxCreateSurface(pRenderer->pVkInstance, &pSwapChain->pVkSurface);
#else
#error PLATFORM NOT SUPPORTED
#endif
ASSERT(VK_SUCCESS == vk_res);
/************************************************************************/
// Create swap chain
/************************************************************************/
ASSERT(VK_NULL_HANDLE != pRenderer->pVkActiveGPU);
// Image count
if (0 == pDesc->mImageCount)
{
((SwapChainDesc*)pDesc)->mImageCount = 2;
}
DECLARE_ZERO(VkSurfaceCapabilitiesKHR, caps);
vk_res = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pRenderer->pVkActiveGPU, pSwapChain->pVkSurface, &caps);
ASSERT(VK_SUCCESS == vk_res);
if ((caps.maxImageCount > 0) && (pDesc->mImageCount > caps.maxImageCount))
{
((SwapChainDesc*)pDesc)->mImageCount = caps.maxImageCount;
}
// Surface format
// Select a surface format, depending on whether HDR is available.
VkSurfaceFormatKHR hdrSurfaceFormat = { VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_COLOR_SPACE_HDR10_ST2084_EXT };
DECLARE_ZERO(VkSurfaceFormatKHR, surface_format);
surface_format.format = VK_FORMAT_UNDEFINED;
uint32_t surfaceFormatCount = 0;
VkSurfaceFormatKHR* formats = NULL;
// Get surface formats count
vk_res = vkGetPhysicalDeviceSurfaceFormatsKHR(pRenderer->pVkActiveGPU, pSwapChain->pVkSurface, &surfaceFormatCount, NULL);
ASSERT(VK_SUCCESS == vk_res);
// Allocate and get surface formats
formats = (VkSurfaceFormatKHR*)conf_calloc(surfaceFormatCount, sizeof(*formats));
vk_res = vkGetPhysicalDeviceSurfaceFormatsKHR(pRenderer->pVkActiveGPU, pSwapChain->pVkSurface, &surfaceFormatCount, formats);
ASSERT(VK_SUCCESS == vk_res);
if ((1 == surfaceFormatCount) && (VK_FORMAT_UNDEFINED == formats[0].format))
{
surface_format.format = VK_FORMAT_B8G8R8A8_UNORM;
surface_format.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
else
{
VkFormat requested_format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mColorFormat);
VkColorSpaceKHR requested_color_space = requested_format == hdrSurfaceFormat.format ? hdrSurfaceFormat.colorSpace : VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
for (uint32_t i = 0; i < surfaceFormatCount; ++i)
{
if ((requested_format == formats[i].format) && (requested_color_space == formats[i].colorSpace))
{
surface_format.format = requested_format;
surface_format.colorSpace = requested_color_space;
break;
}
}
// Default to VK_FORMAT_B8G8R8A8_UNORM if requested format isn't found
if (VK_FORMAT_UNDEFINED == surface_format.format)
{
surface_format.format = VK_FORMAT_B8G8R8A8_UNORM;
surface_format.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
}
ASSERT(VK_FORMAT_UNDEFINED != surface_format.format);
// Free formats
SAFE_FREE(formats);
// The VK_PRESENT_MODE_FIFO_KHR mode must always be present as per spec
// This mode waits for the vertical blank ("v-sync")
VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
uint32_t swapChainImageCount = 0;
VkPresentModeKHR* modes = NULL;
// Get present mode count
vk_res = vkGetPhysicalDeviceSurfacePresentModesKHR(pRenderer->pVkActiveGPU, pSwapChain->pVkSurface, &swapChainImageCount, NULL);
ASSERT(VK_SUCCESS == vk_res);
// Allocate and get present modes
modes = (VkPresentModeKHR*)alloca(swapChainImageCount * sizeof(*modes));
vk_res = vkGetPhysicalDeviceSurfacePresentModesKHR(pRenderer->pVkActiveGPU, pSwapChain->pVkSurface, &swapChainImageCount, modes);
ASSERT(VK_SUCCESS == vk_res);
const uint32_t preferredModeCount = 4;
VkPresentModeKHR preferredModeList[preferredModeCount] = { VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_RELAXED_KHR, VK_PRESENT_MODE_FIFO_KHR };
uint32_t preferredModeStartIndex = pDesc->mEnableVsync ? 2 : 0;
for (uint32_t j = preferredModeStartIndex; j < preferredModeCount; ++j)
{
VkPresentModeKHR mode = preferredModeList[j];
uint32_t i = 0;
for (; i < swapChainImageCount; ++i)
{
if (modes[i] == mode)
{
break;
}
}
if (i < swapChainImageCount)
{
present_mode = mode;
break;
}
}
// Swapchain
VkExtent2D extent = { 0 };
extent.width = pDesc->mWidth;
extent.height = pDesc->mHeight;
VkSharingMode sharing_mode = VK_SHARING_MODE_EXCLUSIVE;
uint32_t queue_family_index_count = 0;
uint32_t queue_family_indices[2] = { pDesc->ppPresentQueues[0]->mVkQueueFamilyIndex, 0 };
uint32_t presentQueueFamilyIndex = -1;
uint32_t nodeIndex = 0;
// Get queue family properties
uint32_t queueFamilyPropertyCount = 0;
VkQueueFamilyProperties* queueFamilyProperties = NULL;
vkGetPhysicalDeviceQueueFamilyProperties(pRenderer->pVkActiveGPU, &queueFamilyPropertyCount, NULL);
queueFamilyProperties = (VkQueueFamilyProperties*)alloca(queueFamilyPropertyCount * sizeof(VkQueueFamilyProperties));
vkGetPhysicalDeviceQueueFamilyProperties(pRenderer->pVkActiveGPU, &queueFamilyPropertyCount, queueFamilyProperties);
// Check if hardware provides dedicated present queue
if (queueFamilyPropertyCount)
{
for (uint32_t index = 0; index < queueFamilyPropertyCount; ++index)
{
VkBool32 supports_present = VK_FALSE;
VkResult res = vkGetPhysicalDeviceSurfaceSupportKHR(pRenderer->pVkActiveGPU, index, pSwapChain->pVkSurface, &supports_present);
if ((VK_SUCCESS == res) && (VK_TRUE == supports_present) && pDesc->ppPresentQueues[0]->mVkQueueFamilyIndex != index)
{
presentQueueFamilyIndex = index;
break;
}
}
// If there is no dedicated present queue, just find the first available queue which supports present
if (presentQueueFamilyIndex == -1)
{
for (uint32_t index = 0; index < queueFamilyPropertyCount; ++index)
{
VkBool32 supports_present = VK_FALSE;
VkResult res =
vkGetPhysicalDeviceSurfaceSupportKHR(pRenderer->pVkActiveGPU, index, pSwapChain->pVkSurface, &supports_present);
if ((VK_SUCCESS == res) && (VK_TRUE == supports_present))
{
presentQueueFamilyIndex = index;
break;
}
else
{
// No present queue family available. Something goes wrong.
ASSERT(0);
}
}
}
}
// Find if gpu has a dedicated present queue
if (presentQueueFamilyIndex != -1 && queue_family_indices[0] != presentQueueFamilyIndex)
{
queue_family_indices[0] = presentQueueFamilyIndex;
vkGetDeviceQueue(pRenderer->pVkDevice, queue_family_indices[0], 0, &pSwapChain->pPresentQueue);
queue_family_index_count = 1;
pSwapChain->mPresentQueueFamilyIndex = presentQueueFamilyIndex;
}
else
{
pSwapChain->mPresentQueueFamilyIndex = queue_family_indices[0];
pSwapChain->pPresentQueue = VK_NULL_HANDLE;
}
VkSurfaceTransformFlagBitsKHR pre_transform;
// #TODO: Add more if necessary but identity should be enough for now
if (caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
{
pre_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
}
else
{
pre_transform = caps.currentTransform;
}
DECLARE_ZERO(VkSwapchainCreateInfoKHR, swapChainCreateInfo);
swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
swapChainCreateInfo.pNext = NULL;
swapChainCreateInfo.flags = 0;
swapChainCreateInfo.surface = pSwapChain->pVkSurface;
#ifndef VK_USE_PLATFORM_ANDROID_KHR
swapChainCreateInfo.minImageCount = pDesc->mImageCount;
#else
//TODO: thomas Fixme hack
swapChainCreateInfo.minImageCount = caps.minImageCount;
#endif
swapChainCreateInfo.imageFormat = surface_format.format;
swapChainCreateInfo.imageColorSpace = surface_format.colorSpace;
swapChainCreateInfo.imageExtent = extent;
swapChainCreateInfo.imageArrayLayers = 1;
swapChainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
swapChainCreateInfo.imageSharingMode = sharing_mode;
swapChainCreateInfo.queueFamilyIndexCount = queue_family_index_count;
swapChainCreateInfo.pQueueFamilyIndices = queue_family_indices;
swapChainCreateInfo.preTransform = pre_transform;
swapChainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
swapChainCreateInfo.presentMode = present_mode;
swapChainCreateInfo.clipped = VK_TRUE;
swapChainCreateInfo.oldSwapchain = 0;
vk_res = vkCreateSwapchainKHR(pRenderer->pVkDevice, &swapChainCreateInfo, NULL, &(pSwapChain->pSwapChain));
ASSERT(VK_SUCCESS == vk_res);
((SwapChainDesc*)pDesc)->mColorFormat = TinyImageFormat_FromVkFormat((TinyImageFormat_VkFormat)surface_format.format);
// Create rendertargets from swapchain
uint32_t image_count = 0;
vk_res = vkGetSwapchainImagesKHR(pRenderer->pVkDevice, pSwapChain->pSwapChain, &image_count, NULL);
ASSERT(VK_SUCCESS == vk_res);
ASSERT(image_count == pDesc->mImageCount);
VkImage* images = (VkImage*)alloca(image_count * sizeof(VkImage));
vk_res = vkGetSwapchainImagesKHR(pRenderer->pVkDevice, pSwapChain->pSwapChain, &image_count, images);
ASSERT(VK_SUCCESS == vk_res);
RenderTargetDesc descColor = {};
descColor.mWidth = pDesc->mWidth;
descColor.mHeight = pDesc->mHeight;
descColor.mDepth = 1;
descColor.mArraySize = 1;
descColor.mFormat = pDesc->mColorFormat;
descColor.mClearValue = pDesc->mColorClearValue;
descColor.mSampleCount = SAMPLE_COUNT_1;
descColor.mSampleQuality = 0;
// Populate the vk_image field and add the Vulkan texture objects
for (uint32_t i = 0; i < pDesc->mImageCount; ++i)
{
descColor.pNativeHandle = (void*)images[i];
addRenderTarget(pRenderer, &descColor, &pSwapChain->ppRenderTargets[i]);
}
/************************************************************************/
/************************************************************************/
*pSwapChain->pDesc = *pDesc;
pSwapChain->mEnableVsync = pDesc->mEnableVsync;
pSwapChain->mImageCount = pDesc->mImageCount;
*ppSwapChain = pSwapChain;
}
void removeSwapChain(Renderer* pRenderer, SwapChain* pSwapChain)
{
ASSERT(pRenderer);
ASSERT(pSwapChain);
for (uint32_t i = 0; i < pSwapChain->mImageCount; ++i)
{
removeRenderTarget(pRenderer, pSwapChain->ppRenderTargets[i]);
}
vkDestroySwapchainKHR(pRenderer->pVkDevice, pSwapChain->pSwapChain, NULL);
vkDestroySurfaceKHR(pRenderer->pVkInstance, pSwapChain->pVkSurface, NULL);
SAFE_FREE(pSwapChain);
}
void addBuffer(Renderer* pRenderer, const BufferDesc* pDesc, Buffer** ppBuffer)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(pDesc->mSize > 0);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
Buffer* pBuffer = (Buffer*)conf_calloc(1, sizeof(Buffer));
ASSERT(ppBuffer);
uint64_t allocationSize = pDesc->mSize;
// Align the buffer size to multiples of the dynamic uniform buffer minimum size
if (pDesc->mDescriptors & DESCRIPTOR_TYPE_UNIFORM_BUFFER)
{
uint64_t minAlignment = pRenderer->pActiveGpuSettings->mUniformBufferAlignment;
allocationSize = round_up_64(allocationSize, minAlignment);
}
DECLARE_ZERO(VkBufferCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.size = allocationSize;
add_info.usage = util_to_vk_buffer_usage(pDesc->mDescriptors, pDesc->mFormat != TinyImageFormat_UNDEFINED);
add_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
add_info.queueFamilyIndexCount = 0;
add_info.pQueueFamilyIndices = NULL;
// Buffer can be used as dest in a transfer command (Uploading data to a storage buffer, Readback query data)
if (pDesc->mMemoryUsage == RESOURCE_MEMORY_USAGE_GPU_ONLY || pDesc->mMemoryUsage == RESOURCE_MEMORY_USAGE_GPU_TO_CPU)
add_info.usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
const bool linkedMultiGpu = (pRenderer->mGpuMode == GPU_MODE_LINKED && (pDesc->pSharedNodeIndices || pDesc->mNodeIndex));
VmaAllocationCreateInfo vma_mem_reqs = { 0 };
vma_mem_reqs.usage = (VmaMemoryUsage)pDesc->mMemoryUsage;
vma_mem_reqs.flags = 0;
if (pDesc->mFlags & BUFFER_CREATION_FLAG_OWN_MEMORY_BIT)
vma_mem_reqs.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
if (pDesc->mFlags & BUFFER_CREATION_FLAG_PERSISTENT_MAP_BIT)
vma_mem_reqs.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
if (linkedMultiGpu)
vma_mem_reqs.flags |= VMA_ALLOCATION_CREATE_DONT_BIND_BIT;
VmaAllocationInfo alloc_info = {};
VkResult vk_res = (VkResult)vmaCreateBuffer(pRenderer->pVmaAllocator, &add_info, &vma_mem_reqs,
&pBuffer->pVkBuffer, &pBuffer->pVkAllocation, &alloc_info);
ASSERT(VK_SUCCESS == vk_res);
pBuffer->pCpuMappedAddress = alloc_info.pMappedData;
/************************************************************************/
// Buffer to be used on multiple GPUs
/************************************************************************/
if (linkedMultiGpu)
{
VmaAllocationInfo allocInfo = {};
vmaGetAllocationInfo(pRenderer->pVmaAllocator, pBuffer->pVkAllocation, &allocInfo);
/************************************************************************/
// Set all the device indices to the index of the device where we will create the buffer
/************************************************************************/
uint32_t* pIndices = (uint32_t*)alloca(pRenderer->mLinkedNodeCount * sizeof(uint32_t));
util_calculate_device_indices(pRenderer, pDesc->mNodeIndex, pDesc->pSharedNodeIndices, pDesc->mSharedNodeIndexCount, pIndices);
/************************************************************************/
// #TODO : Move this to the Vulkan memory allocator
/************************************************************************/
VkBindBufferMemoryInfoKHR bindInfo = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR };
VkBindBufferMemoryDeviceGroupInfoKHR bindDeviceGroup = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR };
bindDeviceGroup.deviceIndexCount = pRenderer->mLinkedNodeCount;
bindDeviceGroup.pDeviceIndices = pIndices;
bindInfo.buffer = pBuffer->pVkBuffer;
bindInfo.memory = allocInfo.deviceMemory;
bindInfo.memoryOffset = allocInfo.offset;
bindInfo.pNext = &bindDeviceGroup;
vkBindBufferMemory2KHR(pRenderer->pVkDevice, 1, &bindInfo);
/************************************************************************/
/************************************************************************/
}
pBuffer->mCurrentState = RESOURCE_STATE_UNDEFINED;
/************************************************************************/
// Set descriptor data
/************************************************************************/
if ((pDesc->mDescriptors & DESCRIPTOR_TYPE_UNIFORM_BUFFER) || (pDesc->mDescriptors & DESCRIPTOR_TYPE_BUFFER) ||
(pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_BUFFER))
{
if ((pDesc->mDescriptors & DESCRIPTOR_TYPE_BUFFER) || (pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_BUFFER))
{
pBuffer->mOffset = pDesc->mStructStride * pDesc->mFirstElement;
}
}
if (add_info.usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)
{
VkBufferViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, NULL };
viewInfo.buffer = pBuffer->pVkBuffer;
viewInfo.flags = 0;
viewInfo.format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mFormat);
viewInfo.offset = pDesc->mFirstElement * pDesc->mStructStride;
viewInfo.range = pDesc->mElementCount * pDesc->mStructStride;
VkFormatProperties formatProps = {};
vkGetPhysicalDeviceFormatProperties(pRenderer->pVkActiveGPU, viewInfo.format, &formatProps);
if (!(formatProps.bufferFeatures & VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT))
{
LOGF(LogLevel::eWARNING, "Failed to create uniform texel buffer view for format %u", (uint32_t)pDesc->mFormat);
}
else
{
vkCreateBufferView(pRenderer->pVkDevice, &viewInfo, NULL, &pBuffer->pVkUniformTexelView);
}
}
if (add_info.usage & VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)
{
VkBufferViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, NULL };
viewInfo.buffer = pBuffer->pVkBuffer;
viewInfo.flags = 0;
viewInfo.format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mFormat);
viewInfo.offset = pDesc->mFirstElement * pDesc->mStructStride;
viewInfo.range = pDesc->mElementCount * pDesc->mStructStride;
VkFormatProperties formatProps = {};
vkGetPhysicalDeviceFormatProperties(pRenderer->pVkActiveGPU, viewInfo.format, &formatProps);
if (!(formatProps.bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT))
{
LOGF(LogLevel::eWARNING, "Failed to create storage texel buffer view for format %u", (uint32_t)pDesc->mFormat);
}
else
{
vkCreateBufferView(pRenderer->pVkDevice, &viewInfo, NULL, &pBuffer->pVkStorageTexelView);
}
}
if (pDesc->pDebugName)
{
char name[MAX_DEBUG_NAME_LENGTH] = {};
wcstombs(name, pDesc->pDebugName, MAX_DEBUG_NAME_LENGTH);
setBufferName(pRenderer, pBuffer, name);
}
/************************************************************************/
/************************************************************************/
pBuffer->mSize = (uint32_t)pDesc->mSize;
pBuffer->mMemoryUsage = pDesc->mMemoryUsage;
pBuffer->mNodeIndex = pDesc->mNodeIndex;
pBuffer->mStartState = pDesc->mStartState;
pBuffer->mDescriptors = pDesc->mDescriptors;
*ppBuffer = pBuffer;
}
void removeBuffer(Renderer* pRenderer, Buffer* pBuffer)
{
ASSERT(pRenderer);
ASSERT(pBuffer);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pBuffer->pVkBuffer);
if (pBuffer->pVkUniformTexelView)
{
vkDestroyBufferView(pRenderer->pVkDevice, pBuffer->pVkUniformTexelView, NULL);
pBuffer->pVkUniformTexelView = VK_NULL_HANDLE;
}
if (pBuffer->pVkStorageTexelView)
{
vkDestroyBufferView(pRenderer->pVkDevice, pBuffer->pVkStorageTexelView, NULL);
pBuffer->pVkStorageTexelView = VK_NULL_HANDLE;
}
vmaDestroyBuffer(pRenderer->pVmaAllocator, pBuffer->pVkBuffer, pBuffer->pVkAllocation);
SAFE_FREE(pBuffer);
}
void addTexture(Renderer* pRenderer, const TextureDesc* pDesc, Texture** ppTexture)
{
ASSERT(pRenderer);
ASSERT(pDesc && pDesc->mWidth && pDesc->mHeight && (pDesc->mDepth || pDesc->mArraySize));
if (pDesc->mSampleCount > SAMPLE_COUNT_1 && pDesc->mMipLevels > 1)
{
LOGF(LogLevel::eERROR, "Multi-Sampled textures cannot have mip maps");
ASSERT(false);
return;
}
size_t totalSize = sizeof(Texture);
totalSize += (pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_TEXTURE ? (pDesc->mMipLevels * sizeof(VkImageView)) : 0);
Texture* pTexture = (Texture*)conf_calloc(1, totalSize);
ASSERT(pTexture);
if (pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_TEXTURE)
pTexture->pVkUAVDescriptors = (VkImageView*)(pTexture + 1);
if (pDesc->pNativeHandle && !(pDesc->mFlags & TEXTURE_CREATION_FLAG_IMPORT_BIT))
{
pTexture->mOwnsImage = false;
pTexture->pVkImage = (VkImage)pDesc->pNativeHandle;
}
else
{
pTexture->mOwnsImage = true;
}
VkImageUsageFlags additionalFlags = 0;
if (pDesc->mStartState & RESOURCE_STATE_RENDER_TARGET)
additionalFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
else if (pDesc->mStartState & RESOURCE_STATE_DEPTH_WRITE)
additionalFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
VkImageType image_type = VK_IMAGE_TYPE_MAX_ENUM;
if (pDesc->mFlags & TEXTURE_CREATION_FLAG_FORCE_2D)
{
ASSERT(pDesc->mDepth == 1);
image_type = VK_IMAGE_TYPE_2D;
}
else if (pDesc->mFlags & TEXTURE_CREATION_FLAG_FORCE_3D)
{
image_type = VK_IMAGE_TYPE_3D;
}
else
{
if (pDesc->mDepth > 1)
image_type = VK_IMAGE_TYPE_3D;
else if (pDesc->mHeight > 1)
image_type = VK_IMAGE_TYPE_2D;
else
image_type = VK_IMAGE_TYPE_1D;
}
DescriptorType descriptors = pDesc->mDescriptors;
bool cubemapRequired = (DESCRIPTOR_TYPE_TEXTURE_CUBE == (descriptors & DESCRIPTOR_TYPE_TEXTURE_CUBE));
bool arrayRequired = false;
if (VK_NULL_HANDLE == pTexture->pVkImage)
{
DECLARE_ZERO(VkImageCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.imageType = image_type;
add_info.format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mFormat);
add_info.extent.width = pDesc->mWidth;
add_info.extent.height = pDesc->mHeight;
add_info.extent.depth = pDesc->mDepth;
add_info.mipLevels = pDesc->mMipLevels;
add_info.arrayLayers = pDesc->mArraySize;
add_info.samples = util_to_vk_sample_count(pDesc->mSampleCount);
add_info.tiling = (0 != pDesc->mHostVisible) ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
add_info.usage = util_to_vk_image_usage(descriptors);
add_info.usage |= additionalFlags;
add_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
add_info.queueFamilyIndexCount = 0;
add_info.pQueueFamilyIndices = NULL;
add_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (cubemapRequired)
add_info.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
if (arrayRequired)
add_info.flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR;
if (VK_IMAGE_USAGE_SAMPLED_BIT & add_info.usage)
{
// Make it easy to copy to and from textures
add_info.usage |= (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT);
}
ASSERT(pRenderer->pCapBits->canShaderReadFrom[pDesc->mFormat] && "GPU shader can't' read from this format");
// TODO Deano move hostvisible flag to capbits structure
// Verify that GPU supports this format
DECLARE_ZERO(VkFormatProperties, format_props);
vkGetPhysicalDeviceFormatProperties(pRenderer->pVkActiveGPU, add_info.format, &format_props);
VkFormatFeatureFlags format_features = util_vk_image_usage_to_format_features(add_info.usage);
if (pDesc->mHostVisible)
{
VkFormatFeatureFlags flags = format_props.linearTilingFeatures & format_features;
ASSERT((0 != flags) && "Format is not supported for host visible images");
}
else
{
VkFormatFeatureFlags flags = format_props.optimalTilingFeatures & format_features;
ASSERT((0 != flags) && "Format is not supported for GPU local images (i.e. not host visible images)");
}
const bool linkedMultiGpu = (pRenderer->mGpuMode == GPU_MODE_LINKED) && (pDesc->pSharedNodeIndices || pDesc->mNodeIndex);
VmaAllocationCreateInfo mem_reqs = { 0 };
if (pDesc->mFlags & TEXTURE_CREATION_FLAG_OWN_MEMORY_BIT)
mem_reqs.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
if (linkedMultiGpu)
mem_reqs.flags |= VMA_ALLOCATION_CREATE_DONT_BIND_BIT;
mem_reqs.usage = (VmaMemoryUsage)VMA_MEMORY_USAGE_GPU_ONLY;
VkExternalMemoryImageCreateInfoKHR externalInfo = { VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR, NULL };
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VkImportMemoryWin32HandleInfoKHR importInfo = { VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR, NULL };
#endif
VkExportMemoryAllocateInfoKHR exportMemoryInfo = { VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR, NULL };
if (gExternalMemoryExtension && pDesc->mFlags & TEXTURE_CREATION_FLAG_IMPORT_BIT)
{
add_info.pNext = &externalInfo;
#if defined(VK_USE_PLATFORM_WIN32_KHR)
struct ImportHandleInfo
{
void* pHandle;
VkExternalMemoryHandleTypeFlagBitsKHR mHandleType;
};
ImportHandleInfo* pHandleInfo = (ImportHandleInfo*)pDesc->pNativeHandle;
importInfo.handle = pHandleInfo->pHandle;
importInfo.handleType = pHandleInfo->mHandleType;
externalInfo.handleTypes = pHandleInfo->mHandleType;
mem_reqs.pUserData = &importInfo;
// Allocate external (importable / exportable) memory as dedicated memory to avoid adding unnecessary complexity to the Vulkan Memory Allocator
mem_reqs.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
#endif
}
else if (gExternalMemoryExtension && pDesc->mFlags & TEXTURE_CREATION_FLAG_EXPORT_BIT)
{
#if defined(VK_USE_PLATFORM_WIN32_KHR)
exportMemoryInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR;
#endif
mem_reqs.pUserData = &exportMemoryInfo;
// Allocate external (importable / exportable) memory as dedicated memory to avoid adding unnecessary complexity to the Vulkan Memory Allocator
mem_reqs.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
}
VmaAllocationInfo alloc_info = {};
VkResult vk_res = (VkResult)vmaCreateImage(pRenderer->pVmaAllocator, &add_info, &mem_reqs,
&pTexture->pVkImage, &pTexture->pVkAllocation, &alloc_info);
ASSERT(VK_SUCCESS == vk_res);
/************************************************************************/
// Texture to be used on multiple GPUs
/************************************************************************/
if (linkedMultiGpu)
{
VmaAllocationInfo allocInfo = {};
vmaGetAllocationInfo(pRenderer->pVmaAllocator, pTexture->pVkAllocation, &allocInfo);
/************************************************************************/
// Set all the device indices to the index of the device where we will create the texture
/************************************************************************/
uint32_t* pIndices = (uint32_t*)alloca(pRenderer->mLinkedNodeCount * sizeof(uint32_t));
util_calculate_device_indices(pRenderer, pDesc->mNodeIndex, pDesc->pSharedNodeIndices, pDesc->mSharedNodeIndexCount, pIndices);
/************************************************************************/
// #TODO : Move this to the Vulkan memory allocator
/************************************************************************/
VkBindImageMemoryInfoKHR bindInfo = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR };
VkBindImageMemoryDeviceGroupInfoKHR bindDeviceGroup = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR };
bindDeviceGroup.deviceIndexCount = pRenderer->mLinkedNodeCount;
bindDeviceGroup.pDeviceIndices = pIndices;
bindInfo.image = pTexture->pVkImage;
bindInfo.memory = allocInfo.deviceMemory;
bindInfo.memoryOffset = allocInfo.offset;
bindInfo.pNext = &bindDeviceGroup;
vkBindImageMemory2KHR(pRenderer->pVkDevice, 1, &bindInfo);
/************************************************************************/
/************************************************************************/
}
pTexture->mCurrentState = RESOURCE_STATE_UNDEFINED;
}
/************************************************************************/
// Create image view
/************************************************************************/
VkImageViewType view_type = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
switch (image_type)
{
case VK_IMAGE_TYPE_1D: view_type = pDesc->mArraySize > 1 ? VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D; break;
case VK_IMAGE_TYPE_2D:
if (cubemapRequired)
view_type = (pDesc->mArraySize > 6) ? VK_IMAGE_VIEW_TYPE_CUBE_ARRAY : VK_IMAGE_VIEW_TYPE_CUBE;
else
view_type = pDesc->mArraySize > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D;
break;
case VK_IMAGE_TYPE_3D:
if (pDesc->mArraySize > 1)
{
LOGF(LogLevel::eERROR, "Cannot support 3D Texture Array in Vulkan");
ASSERT(false);
}
view_type = VK_IMAGE_VIEW_TYPE_3D;
break;
default: ASSERT(false && "Image Format not supported!"); break;
}
ASSERT(view_type != VK_IMAGE_VIEW_TYPE_MAX_ENUM && "Invalid Image View");
VkImageViewCreateInfo srvDesc = {};
// SRV
srvDesc.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
srvDesc.pNext = NULL;
srvDesc.flags = 0;
srvDesc.image = pTexture->pVkImage;
srvDesc.viewType = view_type;
srvDesc.format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mFormat);
srvDesc.components.r = VK_COMPONENT_SWIZZLE_R;
srvDesc.components.g = VK_COMPONENT_SWIZZLE_G;
srvDesc.components.b = VK_COMPONENT_SWIZZLE_B;
srvDesc.components.a = VK_COMPONENT_SWIZZLE_A;
srvDesc.subresourceRange.aspectMask = util_vk_determine_aspect_mask(srvDesc.format, false);
srvDesc.subresourceRange.baseMipLevel = 0;
srvDesc.subresourceRange.levelCount = pDesc->mMipLevels;
srvDesc.subresourceRange.baseArrayLayer = 0;
srvDesc.subresourceRange.layerCount = pDesc->mArraySize;
pTexture->mAspectMask = util_vk_determine_aspect_mask(srvDesc.format, true);
if (descriptors & DESCRIPTOR_TYPE_TEXTURE)
{
VkResult vk_res = vkCreateImageView(pRenderer->pVkDevice, &srvDesc, NULL, &pTexture->pVkSRVDescriptor);
ASSERT(VK_SUCCESS == vk_res);
}
// SRV stencil
if ((TinyImageFormat_HasStencil(pDesc->mFormat))
&& (descriptors & DESCRIPTOR_TYPE_TEXTURE))
{
srvDesc.subresourceRange.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT;
VkResult vk_res = vkCreateImageView(pRenderer->pVkDevice, &srvDesc, NULL, &pTexture->pVkSRVStencilDescriptor);
ASSERT(VK_SUCCESS == vk_res);
}
// UAV
if (descriptors & DESCRIPTOR_TYPE_RW_TEXTURE)
{
VkImageViewCreateInfo uavDesc = srvDesc;
// #NOTE : We dont support imageCube, imageCubeArray for consistency with other APIs
// All cubemaps will be used as image2DArray for Image Load / Store ops
if (uavDesc.viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY || uavDesc.viewType == VK_IMAGE_VIEW_TYPE_CUBE)
uavDesc.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
uavDesc.subresourceRange.levelCount = 1;
for (uint32_t i = 0; i < pDesc->mMipLevels; ++i)
{
uavDesc.subresourceRange.baseMipLevel = i;
VkResult vk_res = vkCreateImageView(pRenderer->pVkDevice, &uavDesc, NULL, &pTexture->pVkUAVDescriptors[i]);
ASSERT(VK_SUCCESS == vk_res);
}
}
/************************************************************************/
/************************************************************************/
pTexture->mNodeIndex = pDesc->mNodeIndex;
pTexture->mStartState = pDesc->mStartState;
pTexture->mWidth = pDesc->mWidth;
pTexture->mHeight = pDesc->mHeight;
pTexture->mDepth = pDesc->mDepth;
pTexture->mMipLevels = pDesc->mMipLevels;
pTexture->mUav = pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_TEXTURE;
if (pDesc->pDebugName)
{
char name[MAX_DEBUG_NAME_LENGTH] = {};
wcstombs(name, pDesc->pDebugName, MAX_DEBUG_NAME_LENGTH);
setTextureName(pRenderer, pTexture, name);
}
*ppTexture = pTexture;
}
void removeTexture(Renderer* pRenderer, Texture* pTexture)
{
ASSERT(pRenderer);
ASSERT(pTexture);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pTexture->pVkImage);
if (pTexture->mOwnsImage)
vmaDestroyImage(pRenderer->pVmaAllocator, pTexture->pVkImage, pTexture->pVkAllocation);
if (VK_NULL_HANDLE != pTexture->pVkSRVDescriptor)
vkDestroyImageView(pRenderer->pVkDevice, pTexture->pVkSRVDescriptor, NULL);
if (VK_NULL_HANDLE != pTexture->pVkSRVStencilDescriptor)
vkDestroyImageView(pRenderer->pVkDevice, pTexture->pVkSRVStencilDescriptor, NULL);
if (pTexture->pVkUAVDescriptors)
{
for (uint32_t i = 0; i < pTexture->mMipLevels; ++i)
{
vkDestroyImageView(pRenderer->pVkDevice, pTexture->pVkUAVDescriptors[i], NULL);
}
}
if (pTexture->pSvt)
{
removeVirtualTexture(pRenderer, pTexture->pSvt);
}
SAFE_FREE(pTexture);
}
void addRenderTarget(Renderer* pRenderer, const RenderTargetDesc* pDesc, RenderTarget** ppRenderTarget)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppRenderTarget);
bool const isDepth = TinyImageFormat_IsDepthOnly(pDesc->mFormat) ||
TinyImageFormat_IsDepthAndStencil(pDesc->mFormat);
ASSERT(!((isDepth) && (pDesc->mDescriptors & DESCRIPTOR_TYPE_RW_TEXTURE)) && "Cannot use depth stencil as UAV");
((RenderTargetDesc*)pDesc)->mMipLevels = max(1U, pDesc->mMipLevels);
uint32_t depthOrArraySize = pDesc->mArraySize * pDesc->mDepth;
uint32_t numRTVs = pDesc->mMipLevels;
if ((pDesc->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_ARRAY_SLICES) ||
(pDesc->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_DEPTH_SLICES))
numRTVs *= depthOrArraySize;
size_t totalSize = sizeof(RenderTarget);
totalSize += numRTVs * sizeof(VkImageView);
RenderTarget* pRenderTarget = (RenderTarget*)conf_calloc(1, totalSize);
ASSERT(pRenderTarget);
pRenderTarget->pVkSliceDescriptors = (VkImageView*)(pRenderTarget + 1);
// Monotonically increasing thread safe id generation
pRenderTarget->mId = tfrg_atomic64_add_relaxed(&gRenderTargetIds, 1);
TextureDesc textureDesc = {};
textureDesc.mArraySize = pDesc->mArraySize;
textureDesc.mClearValue = pDesc->mClearValue;
textureDesc.mDepth = pDesc->mDepth;
textureDesc.mFlags = pDesc->mFlags;
textureDesc.mFormat = pDesc->mFormat;
textureDesc.mHeight = pDesc->mHeight;
textureDesc.mHostVisible = false;
textureDesc.mMipLevels = pDesc->mMipLevels;
textureDesc.mSampleCount = pDesc->mSampleCount;
textureDesc.mSampleQuality = pDesc->mSampleQuality;
textureDesc.mWidth = pDesc->mWidth;
textureDesc.pNativeHandle = pDesc->pNativeHandle;
textureDesc.mNodeIndex = pDesc->mNodeIndex;
textureDesc.pSharedNodeIndices = pDesc->pSharedNodeIndices;
textureDesc.mSharedNodeIndexCount = pDesc->mSharedNodeIndexCount;
if (!isDepth)
textureDesc.mStartState |= RESOURCE_STATE_RENDER_TARGET;
else
textureDesc.mStartState |= RESOURCE_STATE_DEPTH_WRITE;
// Set this by default to be able to sample the rendertarget in shader
textureDesc.mDescriptors = pDesc->mDescriptors;
// Create SRV by default for a render target
textureDesc.mDescriptors |= DESCRIPTOR_TYPE_TEXTURE;
if (isDepth)
{
// Make sure depth/stencil format is supported - fall back to VK_FORMAT_D16_UNORM if not
VkFormat vk_depth_stencil_format = (VkFormat) TinyImageFormat_ToVkFormat(pDesc->mFormat);
if (VK_FORMAT_UNDEFINED != vk_depth_stencil_format)
{
DECLARE_ZERO(VkImageFormatProperties, properties);
VkResult vk_res = vkGetPhysicalDeviceImageFormatProperties(
pRenderer->pVkActiveGPU, vk_depth_stencil_format, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, &properties);
// Fall back to something that's guaranteed to work
if (VK_SUCCESS != vk_res)
{
textureDesc.mFormat = TinyImageFormat_D16_UNORM;
LOGF(LogLevel::eWARNING, "Depth stencil format (%u) not supported. Falling back to D16 format", pDesc->mFormat);
}
}
}
addTexture(pRenderer, &textureDesc, &pRenderTarget->pTexture);
VkImageViewType viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
if (pDesc->mDepth > 1)
viewType = VK_IMAGE_VIEW_TYPE_3D;
else if (pDesc->mHeight > 1)
viewType = pDesc->mArraySize > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D;
else
viewType = pDesc->mArraySize > 1 ? VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D;
VkImageViewCreateInfo rtvDesc = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, NULL };
rtvDesc.flags = 0;
rtvDesc.image = pRenderTarget->pTexture->pVkImage;
rtvDesc.viewType = viewType;
rtvDesc.format = (VkFormat)TinyImageFormat_ToVkFormat(pDesc->mFormat);
rtvDesc.components.r = VK_COMPONENT_SWIZZLE_R;
rtvDesc.components.g = VK_COMPONENT_SWIZZLE_G;
rtvDesc.components.b = VK_COMPONENT_SWIZZLE_B;
rtvDesc.components.a = VK_COMPONENT_SWIZZLE_A;
rtvDesc.subresourceRange.aspectMask = util_vk_determine_aspect_mask(rtvDesc.format, true);
rtvDesc.subresourceRange.baseMipLevel = 0;
rtvDesc.subresourceRange.levelCount = 1;
rtvDesc.subresourceRange.baseArrayLayer = 0;
rtvDesc.subresourceRange.layerCount = depthOrArraySize;
if (VK_IMAGE_VIEW_TYPE_3D == viewType)
rtvDesc.subresourceRange.layerCount = 1;
vkCreateImageView(pRenderer->pVkDevice, &rtvDesc, NULL, &pRenderTarget->pVkDescriptor);
for (uint32_t i = 0; i < pDesc->mMipLevels; ++i)
{
rtvDesc.subresourceRange.baseMipLevel = i;
if ((pDesc->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_ARRAY_SLICES) ||
(pDesc->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_DEPTH_SLICES))
{
for (uint32_t j = 0; j < depthOrArraySize; ++j)
{
rtvDesc.subresourceRange.layerCount = 1;
rtvDesc.subresourceRange.baseArrayLayer = j;
VkResult vkRes =
vkCreateImageView(pRenderer->pVkDevice, &rtvDesc, NULL, &pRenderTarget->pVkSliceDescriptors[i * depthOrArraySize + j]);
ASSERT(VK_SUCCESS == vkRes);
}
}
else
{
VkResult vkRes = vkCreateImageView(pRenderer->pVkDevice, &rtvDesc, NULL, &pRenderTarget->pVkSliceDescriptors[i]);
ASSERT(VK_SUCCESS == vkRes);
}
}
pRenderTarget->mWidth = pDesc->mWidth;
pRenderTarget->mHeight = pDesc->mHeight;
pRenderTarget->mArraySize = pDesc->mArraySize;
pRenderTarget->mDepth = pDesc->mDepth;
pRenderTarget->mMipLevels = pDesc->mMipLevels;
pRenderTarget->mSampleCount = pDesc->mSampleCount;
pRenderTarget->mSampleQuality = pDesc->mSampleQuality;
pRenderTarget->mFormat = pDesc->mFormat;
pRenderTarget->mClearValue = pDesc->mClearValue;
*ppRenderTarget = pRenderTarget;
}
void removeRenderTarget(Renderer* pRenderer, RenderTarget* pRenderTarget)
{
::removeTexture(pRenderer, pRenderTarget->pTexture);
vkDestroyImageView(pRenderer->pVkDevice, pRenderTarget->pVkDescriptor, NULL);
const uint32_t depthOrArraySize = pRenderTarget->mArraySize * pRenderTarget->mDepth;
if ((pRenderTarget->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_ARRAY_SLICES) ||
(pRenderTarget->mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_DEPTH_SLICES))
{
for (uint32_t i = 0; i < pRenderTarget->mMipLevels; ++i)
for (uint32_t j = 0; j < depthOrArraySize; ++j)
vkDestroyImageView(pRenderer->pVkDevice, pRenderTarget->pVkSliceDescriptors[i * depthOrArraySize + j], NULL);
}
else
{
for (uint32_t i = 0; i < pRenderTarget->mMipLevels; ++i)
vkDestroyImageView(pRenderer->pVkDevice, pRenderTarget->pVkSliceDescriptors[i], NULL);
}
SAFE_FREE(pRenderTarget);
}
void addSampler(Renderer* pRenderer, const SamplerDesc* pDesc, Sampler** ppSampler)
{
ASSERT(pRenderer);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(pDesc->mCompareFunc < MAX_COMPARE_MODES);
ASSERT(ppSampler);
Sampler* pSampler = (Sampler*)conf_calloc(1, sizeof(Sampler));
ASSERT(pSampler);
DECLARE_ZERO(VkSamplerCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.magFilter = util_to_vk_filter(pDesc->mMagFilter);
add_info.minFilter = util_to_vk_filter(pDesc->mMinFilter);
add_info.mipmapMode = util_to_vk_mip_map_mode(pDesc->mMipMapMode);
add_info.addressModeU = util_to_vk_address_mode(pDesc->mAddressU);
add_info.addressModeV = util_to_vk_address_mode(pDesc->mAddressV);
add_info.addressModeW = util_to_vk_address_mode(pDesc->mAddressW);
add_info.mipLodBias = pDesc->mMipLodBias;
add_info.anisotropyEnable = (pDesc->mMaxAnisotropy > 0.0f)? VK_TRUE : VK_FALSE;
add_info.maxAnisotropy = pDesc->mMaxAnisotropy;
add_info.compareEnable = (gVkComparisonFuncTranslator[pDesc->mCompareFunc] != VK_COMPARE_OP_NEVER) ? VK_TRUE : VK_FALSE;
add_info.compareOp = gVkComparisonFuncTranslator[pDesc->mCompareFunc];
add_info.minLod = 0.0f;
add_info.maxLod = ((pDesc->mMipMapMode == MIPMAP_MODE_LINEAR) ? FLT_MAX : 0.0f);
add_info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
add_info.unnormalizedCoordinates = VK_FALSE;
VkResult vk_res = vkCreateSampler(pRenderer->pVkDevice, &add_info, NULL, &(pSampler->pVkSampler));
ASSERT(VK_SUCCESS == vk_res);
*ppSampler = pSampler;
}
void removeSampler(Renderer* pRenderer, Sampler* pSampler)
{
ASSERT(pRenderer);
ASSERT(pSampler);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pSampler->pVkSampler);
vkDestroySampler(pRenderer->pVkDevice, pSampler->pVkSampler, NULL);
SAFE_FREE(pSampler);
}
/************************************************************************/
// Buffer Functions
/************************************************************************/
void mapBuffer(Renderer* pRenderer, Buffer* pBuffer, ReadRange* pRange)
{
ASSERT(pBuffer->mMemoryUsage != RESOURCE_MEMORY_USAGE_GPU_ONLY && "Trying to map non-cpu accessible resource");
VkResult vk_res = vmaMapMemory(pRenderer->pVmaAllocator, pBuffer->pVkAllocation, &pBuffer->pCpuMappedAddress);
ASSERT(vk_res == VK_SUCCESS);
if (pRange)
{
pBuffer->pCpuMappedAddress = ((uint8_t*)pBuffer->pCpuMappedAddress + pRange->mOffset);
}
}
void unmapBuffer(Renderer* pRenderer, Buffer* pBuffer)
{
ASSERT(pBuffer->mMemoryUsage != RESOURCE_MEMORY_USAGE_GPU_ONLY && "Trying to unmap non-cpu accessible resource");
vmaUnmapMemory(pRenderer->pVmaAllocator, pBuffer->pVkAllocation);
pBuffer->pCpuMappedAddress = NULL;
}
/************************************************************************/
// Descriptor Set Functions
/************************************************************************/
void addDescriptorSet(Renderer* pRenderer, const DescriptorSetDesc* pDesc, DescriptorSet** ppDescriptorSet)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppDescriptorSet);
const RootSignature* pRootSignature = pDesc->pRootSignature;
const DescriptorUpdateFrequency updateFreq = pDesc->mUpdateFrequency;
const uint32_t nodeIndex = pDesc->mNodeIndex;
const uint32_t descriptorCount = pRootSignature->mVkCumulativeDescriptorCounts[updateFreq];
const uint32_t dynamicOffsetCount = pRootSignature->mVkDynamicDescriptorCounts[updateFreq];
uint32_t totalSize = sizeof(DescriptorSet);
if (VK_NULL_HANDLE != pRootSignature->mVkDescriptorSetLayouts[updateFreq])
{
totalSize += pDesc->mMaxSets * sizeof(VkDescriptorSet);
totalSize += pDesc->mMaxSets * sizeof(DescriptorUpdateData*);
totalSize += pDesc->mMaxSets * descriptorCount * sizeof(DescriptorUpdateData);
}
if (dynamicOffsetCount)
{
ASSERT(1 == dynamicOffsetCount);
totalSize += pDesc->mMaxSets * sizeof(SizeOffset);
}
DescriptorSet* pDescriptorSet = (DescriptorSet*)conf_calloc(1, totalSize);
pDescriptorSet->pRootSignature = pRootSignature;
pDescriptorSet->mUpdateFrequency = updateFreq;
pDescriptorSet->mDynamicOffsetCount = dynamicOffsetCount;
pDescriptorSet->mNodeIndex = nodeIndex;
pDescriptorSet->mMaxSets = pDesc->mMaxSets;
uint8_t* pMem = (uint8_t*)(pDescriptorSet + 1);
pDescriptorSet->pHandles = (VkDescriptorSet*)pMem;
if (VK_NULL_HANDLE != pRootSignature->mVkDescriptorSetLayouts[updateFreq])
{
pMem += pDesc->mMaxSets * sizeof(VkDescriptorSet);
pDescriptorSet->ppUpdateData = (DescriptorUpdateData**)pMem;
pMem += pDesc->mMaxSets * sizeof(DescriptorUpdateData*);
VkDescriptorSetLayout* pLayouts = (VkDescriptorSetLayout*)alloca(pDesc->mMaxSets * sizeof(VkDescriptorSetLayout));
VkDescriptorSet** pHandles = (VkDescriptorSet**)alloca(pDesc->mMaxSets * sizeof(VkDescriptorSet*));
for (uint32_t i = 0; i < pDesc->mMaxSets; ++i)
{
pLayouts[i] = pRootSignature->mVkDescriptorSetLayouts[updateFreq];
pHandles[i] = &pDescriptorSet->pHandles[i];
pDescriptorSet->ppUpdateData[i] = (DescriptorUpdateData*)pMem;
pMem += descriptorCount * sizeof(DescriptorUpdateData);
memcpy(pDescriptorSet->ppUpdateData[i], pRootSignature->pUpdateTemplateData[updateFreq][pDescriptorSet->mNodeIndex], descriptorCount * sizeof(DescriptorUpdateData));
}
consume_descriptor_sets(pRenderer->pDescriptorPool, pLayouts, pHandles, pDesc->mMaxSets);
}
else
{
LOGF(LogLevel::eERROR, "NULL Descriptor Set Layout for update frequency %u. Cannot allocate descriptor set", (uint32_t)updateFreq);
ASSERT(false && "NULL Descriptor Set Layout for update frequency. Cannot allocate descriptor set");
}
if (pDescriptorSet->mDynamicOffsetCount)
{
ASSERT(1 == pDescriptorSet->mDynamicOffsetCount);
pDescriptorSet->pDynamicSizeOffsets = (SizeOffset*)pMem;
pMem += pDescriptorSet->mMaxSets * sizeof(SizeOffset);
}
*ppDescriptorSet = pDescriptorSet;
}
void removeDescriptorSet(Renderer* pRenderer, DescriptorSet* pDescriptorSet)
{
ASSERT(pRenderer);
ASSERT(pDescriptorSet);
SAFE_FREE(pDescriptorSet);
}
void updateDescriptorSet(Renderer* pRenderer, uint32_t index, DescriptorSet* pDescriptorSet, uint32_t count, const DescriptorData* pParams)
{
#ifdef _DEBUG
#define VALIDATE_DESCRIPTOR(descriptor,...) \
if (!(descriptor)) \
{ \
eastl::string msg = __FUNCTION__ + eastl::string(" : ") + eastl::string().sprintf(__VA_ARGS__); \
LOGF(LogLevel::eERROR, msg.c_str()); \
_FailedAssert(__FILE__, __LINE__, msg.c_str()); \
continue; \
}
#else
#define VALIDATE_DESCRIPTOR(descriptor,...)
#endif
ASSERT(pRenderer);
ASSERT(pDescriptorSet);
ASSERT(pDescriptorSet->pHandles);
ASSERT(index < pDescriptorSet->mMaxSets);
const RootSignature* pRootSignature = pDescriptorSet->pRootSignature;
DescriptorUpdateFrequency updateFreq = (DescriptorUpdateFrequency)pDescriptorSet->mUpdateFrequency;
DescriptorUpdateData* pUpdateData = pDescriptorSet->ppUpdateData[index];
bool update = false;
#ifdef ENABLE_RAYTRACING
VkWriteDescriptorSet* raytracingWrites = NULL;
VkWriteDescriptorSetAccelerationStructureNV* raytracingWritesNV = NULL;
uint32_t raytracingWriteCount = 0;
if (pRootSignature->mVkRaytracingDescriptorCounts[updateFreq])
{
raytracingWrites = (VkWriteDescriptorSet*)alloca(pRootSignature->mVkRaytracingDescriptorCounts[updateFreq] * sizeof(VkWriteDescriptorSet));
raytracingWritesNV = (VkWriteDescriptorSetAccelerationStructureNV*)alloca(pRootSignature->mVkRaytracingDescriptorCounts[updateFreq] * sizeof(VkWriteDescriptorSetAccelerationStructureNV));
}
#endif
for (uint32_t i = 0; i < count; ++i)
{
const DescriptorData* pParam = pParams + i;
uint32_t paramIndex = pParam->mIndex;
VALIDATE_DESCRIPTOR(pParam->pName || (paramIndex != -1), "DescriptorData has NULL name and invalid index");
const DescriptorInfo* pDesc = (paramIndex != -1) ? (pRootSignature->pDescriptors + paramIndex) : get_descriptor(pRootSignature, pParam->pName);
if (paramIndex != -1)
{
VALIDATE_DESCRIPTOR(pDesc, "Invalid descriptor with param index (%u)", paramIndex);
}
else
{
VALIDATE_DESCRIPTOR(pDesc, "Invalid descriptor with param name (%s)", pParam->pName);
}
const DescriptorType type = (DescriptorType)pDesc->mType;
const uint32_t arrayCount = max(1U, pParam->mCount);
VALIDATE_DESCRIPTOR(pDesc->mUpdateFrequency == updateFreq,
"Descriptor (%s) - Mismatching update frequency and set index", pDesc->pName);
switch (type)
{
case DESCRIPTOR_TYPE_SAMPLER:
{
// Index is invalid when descriptor is a static sampler
VALIDATE_DESCRIPTOR(pDesc->mIndexInParent != -1,
"Trying to update a static sampler (%s). All static samplers must be set in addRootSignature and cannot be updated later",
pDesc->pName);
VALIDATE_DESCRIPTOR(pParam->ppSamplers, "NULL Sampler (%s)", pDesc->pName);
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppSamplers[arr], "NULL Sampler (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo = { pParam->ppSamplers[arr]->pVkSampler, VK_NULL_HANDLE };
update = true;
}
break;
}
case DESCRIPTOR_TYPE_TEXTURE:
{
VALIDATE_DESCRIPTOR(pParam->ppTextures, "NULL Texture (%s)", pDesc->pName);
if (!pParam->mBindStencilResource)
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppTextures[arr], "NULL Texture (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo =
{
VK_NULL_HANDLE, // Sampler
pParam->ppTextures[arr]->pVkSRVDescriptor, // Image View
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL // Image Layout
};
update = true;
}
}
else
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppTextures[arr], "NULL Texture (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo =
{
VK_NULL_HANDLE, // Sampler
pParam->ppTextures[arr]->pVkSRVStencilDescriptor, // Image View
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL // Image Layout
};
update = true;
}
}
break;
}
case DESCRIPTOR_TYPE_RW_TEXTURE:
{
VALIDATE_DESCRIPTOR(pParam->ppTextures, "NULL RW Texture (%s)", pDesc->pName);
const uint32_t mipSlice = pParam->mUAVMipSlice;
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppTextures[arr], "NULL RW Texture (%s [%u] )", pDesc->pName, arr);
VALIDATE_DESCRIPTOR(mipSlice < pParam->ppTextures[arr]->mMipLevels, "Descriptor : (%s [%u] ) Mip Slice (%u) exceeds mip levels (%u)",
pDesc->pName, arr, mipSlice, pParam->ppTextures[arr]->mMipLevels);
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo =
{
VK_NULL_HANDLE, // Sampler
pParam->ppTextures[arr]->pVkUAVDescriptors[mipSlice], // Image View
VK_IMAGE_LAYOUT_GENERAL // Image Layout
};
update = true;
}
break;
}
case DESCRIPTOR_TYPE_UNIFORM_BUFFER:
{
if (pDesc->mVkType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers, "NULL Uniform Buffer (%s)", pDesc->pName);
VALIDATE_DESCRIPTOR(pParam->ppBuffers[0], "NULL Uniform Buffer (%s [%u] )", pDesc->pName, 0);
VALIDATE_DESCRIPTOR(arrayCount == 1, "Descriptor (%s) : VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC does not support arrays", pDesc->pName);
VALIDATE_DESCRIPTOR(pParam->pSizes, "Descriptor (%s) : Must provide pSizes for VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC", pDesc->pName);
VALIDATE_DESCRIPTOR(pParam->pSizes[0] > 0, "Descriptor (%s) - pSizes[%u] is zero", pDesc->pName, 0);
VALIDATE_DESCRIPTOR(pParam->pSizes[0] <= pRenderer->pVkActiveGPUProperties->properties.limits.maxUniformBufferRange,
"Descriptor (%s) - pSizes[%u] is %ull which exceeds max size %u", pDesc->pName, 0,
pParam->pSizes[0],
pRenderer->pVkActiveGPUProperties->properties.limits.maxUniformBufferRange);
pDescriptorSet->pDynamicSizeOffsets[index].mOffset = pParam->pOffsets ? (uint32_t)pParam->pOffsets[0] : 0;
pUpdateData[pDesc->mHandleIndex + 0].mBufferInfo =
{
pParam->ppBuffers[0]->pVkBuffer,
pParam->ppBuffers[0]->mOffset,
pParam->pSizes[0]
};
// If this is a different size we have to update the VkDescriptorBufferInfo::range so a call to vkUpdateDescriptorSet is necessary
if (pParam->pSizes[0] != (uint32_t)pDescriptorSet->pDynamicSizeOffsets[index].mSize)
{
pDescriptorSet->pDynamicSizeOffsets[index].mSize = (uint32_t)pParam->pSizes[0];
update = true;
}
break;
}
case DESCRIPTOR_TYPE_BUFFER:
case DESCRIPTOR_TYPE_BUFFER_RAW:
case DESCRIPTOR_TYPE_RW_BUFFER:
case DESCRIPTOR_TYPE_RW_BUFFER_RAW:
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers, "NULL Buffer (%s)", pDesc->pName);
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers[arr], "NULL Buffer (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mBufferInfo =
{
pParam->ppBuffers[arr]->pVkBuffer,
pParam->ppBuffers[arr]->mOffset,
VK_WHOLE_SIZE
};
if (pParam->pOffsets)
{
VALIDATE_DESCRIPTOR(pParam->pSizes, "Descriptor (%s) - pSizes must be provided with pOffsets", pDesc->pName);
VALIDATE_DESCRIPTOR(pParam->pSizes[arr] > 0, "Descriptor (%s) - pSizes[%u] is zero", pDesc->pName, arr);
VALIDATE_DESCRIPTOR(pParam->pSizes[arr] <= pRenderer->pVkActiveGPUProperties->properties.limits.maxUniformBufferRange,
"Descriptor (%s) - pSizes[%u] is %ull which exceeds max size %u", pDesc->pName, arr,
pParam->pSizes[arr],
pRenderer->pVkActiveGPUProperties->properties.limits.maxUniformBufferRange);
pUpdateData[pDesc->mHandleIndex + arr].mBufferInfo.offset = pParam->pOffsets[arr];
pUpdateData[pDesc->mHandleIndex + arr].mBufferInfo.range = pParam->pSizes[arr];
}
update = true;
}
}
break;
}
case DESCRIPTOR_TYPE_TEXEL_BUFFER:
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers, "NULL Texel Buffer (%s)", pDesc->pName);
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers[arr], "NULL Texel Buffer (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mBuferView = pParam->ppBuffers[arr]->pVkUniformTexelView;
update = true;
}
break;
}
case DESCRIPTOR_TYPE_RW_TEXEL_BUFFER:
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers, "NULL RW Texel Buffer (%s)", pDesc->pName);
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppBuffers[arr], "NULL RW Texel Buffer (%s [%u] )", pDesc->pName, arr);
pUpdateData[pDesc->mHandleIndex + arr].mBuferView = pParam->ppBuffers[arr]->pVkStorageTexelView;
update = true;
}
break;
}
#ifdef ENABLE_RAYTRACING
case DESCRIPTOR_TYPE_RAY_TRACING:
{
VALIDATE_DESCRIPTOR(pParam->ppAccelerationStructures, "NULL Acceleration Structure (%s)", pDesc->pName);
for (uint32_t arr = 0; arr < arrayCount; ++arr)
{
VALIDATE_DESCRIPTOR(pParam->ppAccelerationStructures[arr], "Acceleration Structure (%s [%u] )", pDesc->pName, arr);
VkWriteDescriptorSet* pWrite = raytracingWrites + raytracingWriteCount;
VkWriteDescriptorSetAccelerationStructureNV* pWriteNV = raytracingWritesNV + raytracingWriteCount;
pWrite->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
pWrite->pNext = pWriteNV;
pWrite->dstSet = pDescriptorSet->pHandles[index];
pWrite->descriptorCount = 1;
pWrite->descriptorType = (VkDescriptorType)pDesc->mVkType;
pWrite->dstArrayElement = arr;
pWrite->dstBinding = pDesc->mReg;
vk_FillRaytracingDescriptorData(pParam->ppAccelerationStructures[arr], pWriteNV);
++raytracingWriteCount;
}
break;
}
#endif
default:
break;
}
}
// If this was called to just update a dynamic offset skip the update
if (update)
vkUpdateDescriptorSetWithTemplateKHR(pRenderer->pVkDevice, pDescriptorSet->pHandles[index],
pRootSignature->mUpdateTemplates[updateFreq], pUpdateData);
#ifdef ENABLE_RAYTRACING
// Raytracing Update Descriptor Set since it does not support update template
if (raytracingWriteCount)
vkUpdateDescriptorSets(pRenderer->pVkDevice, raytracingWriteCount, raytracingWrites, 0, NULL);
#endif
}
void cmdBindDescriptorSet(Cmd* pCmd, uint32_t index, DescriptorSet* pDescriptorSet)
{
ASSERT(pCmd);
ASSERT(pDescriptorSet);
ASSERT(pDescriptorSet->pHandles);
ASSERT(index < pDescriptorSet->mMaxSets);
const RootSignature* pRootSignature = pDescriptorSet->pRootSignature;
if (pCmd->pBoundPipelineLayout != pRootSignature->pPipelineLayout)
{
pCmd->pBoundPipelineLayout = pRootSignature->pPipelineLayout;
// Vulkan requires to bind all descriptor sets upto the highest set number even if they are empty
// Example: If shader uses only set 2, we still have to bind empty sets for set=0 and set=1
for (uint32_t setIndex = 0; setIndex < DESCRIPTOR_UPDATE_FREQ_COUNT; ++setIndex)
{
if (pRootSignature->mVkEmptyDescriptorSets[setIndex] != VK_NULL_HANDLE)
{
vkCmdBindDescriptorSets(
pCmd->pVkCmdBuf, gPipelineBindPoint[pRootSignature->mPipelineType], pRootSignature->pPipelineLayout, setIndex, 1,
&pRootSignature->mVkEmptyDescriptorSets[setIndex], 0, NULL);
}
}
}
vkCmdBindDescriptorSets(pCmd->pVkCmdBuf, gPipelineBindPoint[pRootSignature->mPipelineType],
pRootSignature->pPipelineLayout, pDescriptorSet->mUpdateFrequency, 1, &pDescriptorSet->pHandles[index],
pDescriptorSet->mDynamicOffsetCount, pDescriptorSet->mDynamicOffsetCount ? &pDescriptorSet->pDynamicSizeOffsets[index].mOffset : NULL);
}
void cmdBindPushConstants(Cmd* pCmd, RootSignature* pRootSignature, const char* pName, const void* pConstants)
{
ASSERT(pCmd);
ASSERT(pConstants);
ASSERT(pRootSignature);
ASSERT(pName);
const DescriptorInfo* pDesc = get_descriptor(pRootSignature, pName);
ASSERT(pDesc);
ASSERT(DESCRIPTOR_TYPE_ROOT_CONSTANT == pDesc->mType);
vkCmdPushConstants(pCmd->pVkCmdBuf, pRootSignature->pPipelineLayout,
pDesc->mVkStages, 0, pDesc->mSize, pConstants);
}
void cmdBindPushConstantsByIndex(Cmd* pCmd, RootSignature* pRootSignature, uint32_t paramIndex, const void* pConstants)
{
ASSERT(pCmd);
ASSERT(pConstants);
ASSERT(pRootSignature);
ASSERT(paramIndex >= 0 && paramIndex < pRootSignature->mDescriptorCount);
const DescriptorInfo* pDesc = pRootSignature->pDescriptors + paramIndex;
ASSERT(pDesc);
ASSERT(DESCRIPTOR_TYPE_ROOT_CONSTANT == pDesc->mType);
vkCmdPushConstants(pCmd->pVkCmdBuf, pRootSignature->pPipelineLayout,
pDesc->mVkStages, 0, pDesc->mSize, pConstants);
}
/************************************************************************/
// Shader Functions
/************************************************************************/
void addShaderBinary(Renderer* pRenderer, const BinaryShaderDesc* pDesc, Shader** ppShaderProgram)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppShaderProgram);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
uint32_t counter = 0;
size_t totalSize = sizeof(Shader);
totalSize += sizeof(PipelineReflection);
for (uint32_t i = 0; i < SHADER_STAGE_COUNT; ++i)
{
ShaderStage stage_mask = (ShaderStage)(1 << i);
if (stage_mask == (pDesc->mStages & stage_mask))
{
const BinaryShaderStageDesc* pStageDesc = nullptr;
switch (stage_mask)
{
case SHADER_STAGE_VERT: totalSize += (strlen(pDesc->mVert.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_TESC: totalSize += (strlen(pDesc->mHull.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_TESE: totalSize += (strlen(pDesc->mDomain.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_GEOM: totalSize += (strlen(pDesc->mGeom.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_FRAG: totalSize += (strlen(pDesc->mFrag.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_COMP: totalSize += (strlen(pDesc->mComp.pEntryPoint) + 1) * sizeof(char); break;
case SHADER_STAGE_RAYTRACING: totalSize += (strlen(pDesc->mComp.pEntryPoint) + 1) * sizeof(char); break;
default: break;
}
++counter;
}
}
totalSize += counter * sizeof(VkShaderModule);
totalSize += counter * sizeof(char*);
Shader* pShaderProgram = (Shader*)conf_calloc(1, totalSize);
pShaderProgram->mStages = pDesc->mStages;
pShaderProgram->pReflection = (PipelineReflection*)(pShaderProgram + 1);
pShaderProgram->pShaderModules = (VkShaderModule*)(pShaderProgram->pReflection + 1);
pShaderProgram->pEntryNames = (char**)(pShaderProgram->pShaderModules + counter);
uint8_t* mem = (uint8_t*)(pShaderProgram->pEntryNames + counter);
counter = 0;
ShaderReflection stageReflections[SHADER_STAGE_COUNT] = {};
for (uint32_t i = 0; i < SHADER_STAGE_COUNT; ++i)
{
ShaderStage stage_mask = (ShaderStage)(1 << i);
if (stage_mask == (pShaderProgram->mStages & stage_mask))
{
DECLARE_ZERO(VkShaderModuleCreateInfo, create_info);
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
create_info.pNext = NULL;
create_info.flags = 0;
const BinaryShaderStageDesc* pStageDesc = nullptr;
switch (stage_mask)
{
case SHADER_STAGE_VERT:
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mVert.pByteCode, (uint32_t)pDesc->mVert.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mVert.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mVert.pByteCode;
pStageDesc = &pDesc->mVert;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
case SHADER_STAGE_TESC:
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mHull.pByteCode, (uint32_t)pDesc->mHull.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mHull.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mHull.pByteCode;
pStageDesc = &pDesc->mHull;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
case SHADER_STAGE_TESE:
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mDomain.pByteCode, (uint32_t)pDesc->mDomain.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mDomain.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mDomain.pByteCode;
pStageDesc = &pDesc->mDomain;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
case SHADER_STAGE_GEOM:
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mGeom.pByteCode, (uint32_t)pDesc->mGeom.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mGeom.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mGeom.pByteCode;
pStageDesc = &pDesc->mGeom;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
case SHADER_STAGE_FRAG:
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mFrag.pByteCode, (uint32_t)pDesc->mFrag.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mFrag.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mFrag.pByteCode;
pStageDesc = &pDesc->mFrag;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
case SHADER_STAGE_COMP:
#ifdef ENABLE_RAYTRACING
case SHADER_STAGE_RAYTRACING:
#endif
{
vk_createShaderReflection(
(const uint8_t*)pDesc->mComp.pByteCode, (uint32_t)pDesc->mComp.mByteCodeSize, stage_mask,
&stageReflections[counter]);
create_info.codeSize = pDesc->mComp.mByteCodeSize;
create_info.pCode = (const uint32_t*)pDesc->mComp.pByteCode;
pStageDesc = &pDesc->mComp;
VkResult vk_res = vkCreateShaderModule(pRenderer->pVkDevice, &create_info, NULL, &(pShaderProgram->pShaderModules[counter]));
ASSERT(VK_SUCCESS == vk_res);
}
break;
default: ASSERT(false && "Shader Stage not supported!"); break;
}
pShaderProgram->pEntryNames[counter] = (char*)mem;
mem += (strlen(pStageDesc->pEntryPoint) + 1) * sizeof(char);
memcpy(pShaderProgram->pEntryNames[counter], pStageDesc->pEntryPoint, strlen(pStageDesc->pEntryPoint));
++counter;
}
}
createPipelineReflection(stageReflections, counter, pShaderProgram->pReflection);
*ppShaderProgram = pShaderProgram;
}
void removeShader(Renderer* pRenderer, Shader* pShaderProgram)
{
ASSERT(pRenderer);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
if (pShaderProgram->mStages & SHADER_STAGE_VERT)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[pShaderProgram->pReflection->mVertexStageIndex], NULL);
}
if (pShaderProgram->mStages & SHADER_STAGE_TESC)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[pShaderProgram->pReflection->mHullStageIndex], NULL);
}
if (pShaderProgram->mStages & SHADER_STAGE_TESE)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[pShaderProgram->pReflection->mDomainStageIndex], NULL);
}
if (pShaderProgram->mStages & SHADER_STAGE_GEOM)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[pShaderProgram->pReflection->mGeometryStageIndex], NULL);
}
if (pShaderProgram->mStages & SHADER_STAGE_FRAG)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[pShaderProgram->pReflection->mPixelStageIndex], NULL);
}
if (pShaderProgram->mStages & SHADER_STAGE_COMP)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[0], NULL);
}
#ifdef ENABLE_RAYTRACING
if (pShaderProgram->mStages & SHADER_STAGE_RAYTRACING)
{
vkDestroyShaderModule(pRenderer->pVkDevice, pShaderProgram->pShaderModules[0], NULL);
}
#endif
destroyPipelineReflection(pShaderProgram->pReflection);
SAFE_FREE(pShaderProgram);
}
/************************************************************************/
// Root Signature Functions
/************************************************************************/
typedef struct UpdateFrequencyLayoutInfo
{
/// Array of all bindings in the descriptor set
eastl::vector<VkDescriptorSetLayoutBinding> mBindings;
/// Array of all descriptors in this descriptor set
eastl::vector<DescriptorInfo*> mDescriptors;
/// Array of all descriptors marked as dynamic in this descriptor set (applicable to DESCRIPTOR_TYPE_UNIFORM_BUFFER)
eastl::vector<DescriptorInfo*> mDynamicDescriptors;
/// Hash map to get index of the descriptor in the root signature
eastl::hash_map<DescriptorInfo*, uint32_t> mDescriptorIndexMap;
} UpdateFrequencyLayoutInfo;
void addRootSignature(Renderer* pRenderer, const RootSignatureDesc* pRootSignatureDesc, RootSignature** ppRootSignature)
{
ASSERT(pRenderer);
ASSERT(pRootSignatureDesc);
ASSERT(ppRootSignature);
eastl::vector<UpdateFrequencyLayoutInfo> layouts(DESCRIPTOR_UPDATE_FREQ_COUNT);
eastl::vector<DescriptorInfo*> pushConstantDescriptors;
eastl::vector<ShaderResource> shaderResources;
eastl::hash_map<eastl::string, Sampler*> staticSamplerMap;
for (uint32_t i = 0; i < pRootSignatureDesc->mStaticSamplerCount; ++i)
{
ASSERT(pRootSignatureDesc->ppStaticSamplers[i]);
staticSamplerMap.insert({ { pRootSignatureDesc->ppStaticSamplerNames[i], pRootSignatureDesc->ppStaticSamplers[i] } });
}
PipelineType pipelineType = PIPELINE_TYPE_UNDEFINED;
DescriptorIndexMap indexMap;
// Collect all unique shader resources in the given shaders
// Resources are parsed by name (two resources named "XYZ" in two shaders will be considered the same resource)
for (uint32_t sh = 0; sh < pRootSignatureDesc->mShaderCount; ++sh)
{
PipelineReflection const* pReflection = pRootSignatureDesc->ppShaders[sh]->pReflection;
if (pReflection->mShaderStages & SHADER_STAGE_COMP)
pipelineType = PIPELINE_TYPE_COMPUTE;
#ifdef ENABLE_RAYTRACING
else if (pReflection->mShaderStages & SHADER_STAGE_RAYTRACING)
pipelineType = PIPELINE_TYPE_RAYTRACING;
#endif
else
pipelineType = PIPELINE_TYPE_GRAPHICS;
for (uint32_t i = 0; i < pReflection->mShaderResourceCount; ++i)
{
ShaderResource const* pRes = &pReflection->pShaderResources[i];
uint32_t setIndex = pRes->set;
if (pRes->type == DESCRIPTOR_TYPE_ROOT_CONSTANT)
setIndex = 0;
eastl::string_hash_map<uint32_t>::iterator it =
indexMap.mMap.find(pRes->name);
if (it == indexMap.mMap.end())
{
decltype(shaderResources)::iterator it = eastl::find(shaderResources.begin(), shaderResources.end(), *pRes,
[](const ShaderResource& a, const ShaderResource& b)
{
return ((a.reg << 16) | (a.set & 0xFFFF)) == ((b.reg << 16) | (b.set & 0xFFFF));
});
if (it == shaderResources.end())
{
indexMap.mMap.insert(pRes->name, (uint32_t)shaderResources.size());
shaderResources.push_back(*pRes);
}
else
{
ASSERT(pRes->type == it->type);
if (pRes->type != it->type)
{
LOGF(LogLevel::eERROR,
"\nFailed to create root signature\n"
"Shared shader resources %s and %s have mismatching types (%u) and (%u). All shader resources "
"sharing the same register and space addRootSignature "
"must have the same type",
pRes->name, it->name, (uint32_t)pRes->type, (uint32_t)it->type);
return;
}
indexMap.mMap.insert(pRes->name,
indexMap.mMap[it->name]);
it->used_stages |= pRes->used_stages;
}
}
else
{
if (shaderResources[it->second].reg != pRes->reg)
{
LOGF( LogLevel::eERROR,
"\nFailed to create root signature\n"
"Shared shader resource %s has mismatching binding. All shader resources "
"shared by multiple shaders specified in addRootSignature "
"must have the same binding and set",
pRes->name);
return;
}
if (shaderResources[it->second].set != pRes->set)
{
LOGF( LogLevel::eERROR,
"\nFailed to create root signature\n"
"Shared shader resource %s has mismatching set. All shader resources "
"shared by multiple shaders specified in addRootSignature "
"must have the same binding and set",
pRes->name);
return;
}
for (ShaderResource& res : shaderResources)
{
if (strcmp(res.name, it->first) == 0)
{
res.used_stages |= pRes->used_stages;
break;
}
}
}
}
}
size_t totalSize = sizeof(RootSignature);
totalSize += shaderResources.size() * sizeof(DescriptorInfo);
totalSize += sizeof(DescriptorIndexMap);
RootSignature* pRootSignature = (RootSignature*)conf_calloc(1, totalSize);
ASSERT(pRootSignature);
pRootSignature->pDescriptors = (DescriptorInfo*)(pRootSignature + 1);
pRootSignature->pDescriptorNameToIndexMap = (DescriptorIndexMap*)(pRootSignature->pDescriptors + shaderResources.size());
ASSERT(pRootSignature->pDescriptorNameToIndexMap);
conf_placement_new<DescriptorIndexMap>(pRootSignature->pDescriptorNameToIndexMap);
if ((uint32_t)shaderResources.size())
{
pRootSignature->mDescriptorCount = (uint32_t)shaderResources.size();
}
pRootSignature->mPipelineType = pipelineType;
pRootSignature->pDescriptorNameToIndexMap->mMap = indexMap.mMap;
// Fill the descriptor array to be stored in the root signature
for (uint32_t i = 0; i < (uint32_t)shaderResources.size(); ++i)
{
DescriptorInfo* pDesc = &pRootSignature->pDescriptors[i];
ShaderResource const* pRes = &shaderResources[i];
uint32_t setIndex = pRes->set;
DescriptorUpdateFrequency updateFreq = (DescriptorUpdateFrequency)setIndex;
// Copy the binding information generated from the shader reflection into the descriptor
pDesc->mReg = pRes->reg;
pDesc->mSize = pRes->size;
pDesc->mType = pRes->type;
pDesc->pName = pRes->name;
pDesc->mDim = pRes->dim;
// If descriptor is not a root constant create a new layout binding for this descriptor and add it to the binding array
if (pDesc->mType != DESCRIPTOR_TYPE_ROOT_CONSTANT)
{
VkDescriptorSetLayoutBinding binding = {};
binding.binding = pRes->reg;
binding.descriptorCount = pDesc->mSize;
binding.descriptorType = util_to_vk_descriptor_type((DescriptorType)pDesc->mType);
eastl::string name = pRes->name;
name.make_lower();
// If a user specified a uniform buffer to be used as a dynamic uniform buffer change its type to VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
// Also log a message for debugging purpose
if (name.find("rootcbv") != eastl::string::npos)
{
if (pDesc->mSize == 1)
{
LOGF(LogLevel::eINFO, "Descriptor (%s) : User specified VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC", pDesc->pName);
binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
}
else
{
LOGF(
LogLevel::eWARNING, "Descriptor (%s) : Cannot use VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC for arrays",
pDesc->pName);
}
}
binding.stageFlags = util_to_vk_shader_stage_flags(pRes->used_stages);
// Store the vulkan related info in the descriptor to avoid constantly calling the util_to_vk mapping functions
pDesc->mVkType = binding.descriptorType;
pDesc->mVkStages = binding.stageFlags;
pDesc->mUpdateFrequency = updateFreq;
if (binding.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)
{
layouts[setIndex].mDynamicDescriptors.emplace_back(pDesc);
}
// Find if the given descriptor is a static sampler
decltype(staticSamplerMap)::iterator it = staticSamplerMap.find(pDesc->pName);
if (it != staticSamplerMap.end())
{
LOGF(LogLevel::eINFO, "Descriptor (%s) : User specified Static Sampler", pDesc->pName);
// Set the index to an invalid value so we can use this later for error checking if user tries to update a static sampler
pDesc->mIndexInParent = -1;
binding.pImmutableSamplers = &it->second->pVkSampler;
}
else
{
layouts[setIndex].mDescriptors.emplace_back(pDesc);
}
layouts[setIndex].mBindings.push_back(binding);
}
// If descriptor is a root constant, add it to the root constant array
else
{
LOGF(LogLevel::eINFO, "Descriptor (%s) : User specified Push Constant", pDesc->pName);
pDesc->mVkStages = util_to_vk_shader_stage_flags(pRes->used_stages);
setIndex = 0;
pushConstantDescriptors.emplace_back(pDesc);
}
layouts[setIndex].mDescriptorIndexMap[pDesc] = i;
}
pRootSignature->mVkPushConstantCount = (uint32_t)pushConstantDescriptors.size();
// Create push constant ranges
for (uint32_t i = 0; i < pRootSignature->mVkPushConstantCount; ++i)
{
DescriptorInfo* pDesc = pushConstantDescriptors[i];
pDesc->mIndexInParent = i;
}
// Create descriptor layouts
// Put most frequently changed params first
for (uint32_t i = (uint32_t)layouts.size(); i-- > 0U;)
{
UpdateFrequencyLayoutInfo& layout = layouts[i];
if (layouts[i].mBindings.size())
{
// sort table by type (CBV/SRV/UAV) by register
eastl::stable_sort(layout.mBindings.begin(), layout.mBindings.end(), [](const VkDescriptorSetLayoutBinding& lhs, const VkDescriptorSetLayoutBinding& rhs) {
return lhs.binding > rhs.binding;
});
eastl::stable_sort(layout.mBindings.begin(), layout.mBindings.end(), [](const VkDescriptorSetLayoutBinding& lhs, const VkDescriptorSetLayoutBinding& rhs) {
return lhs.descriptorType > rhs.descriptorType;
});
}
bool createLayout = layout.mBindings.size() > 0;
// Check if we need to create an empty layout in case there is an empty set between two used sets
// Example: set = 0 is used, set = 2 is used. In this case, set = 1 needs to exist even if it is empty
if (!createLayout && i < layouts.size() - 1)
{
createLayout = pRootSignature->mVkDescriptorSetLayouts[i + 1] != VK_NULL_HANDLE;
}
if (createLayout)
{
VkDescriptorSetLayoutCreateInfo layoutInfo = {};
layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layoutInfo.pNext = NULL;
layoutInfo.bindingCount = (uint32_t)layout.mBindings.size();
layoutInfo.pBindings = layout.mBindings.data();
layoutInfo.flags = 0;
vkCreateDescriptorSetLayout(pRenderer->pVkDevice, &layoutInfo, NULL, &pRootSignature->mVkDescriptorSetLayouts[i]);
}
if (!layouts[i].mBindings.size())
continue;
pRootSignature->mVkDescriptorCounts[i] = (uint32_t)layout.mDescriptors.size();
// Loop through descriptors belonging to this update frequency and increment the cumulative descriptor count
for (uint32_t descIndex = 0; descIndex < (uint32_t)layout.mDescriptors.size(); ++descIndex)
{
DescriptorInfo* pDesc = layout.mDescriptors[descIndex];
pDesc->mIndexInParent = descIndex;
pDesc->mHandleIndex = pRootSignature->mVkCumulativeDescriptorCounts[i];
pRootSignature->mVkCumulativeDescriptorCounts[i] += pDesc->mSize;
}
pRootSignature->mVkDynamicDescriptorCounts[i] = (uint32_t)layout.mDynamicDescriptors.size();
for (uint32_t descIndex = 0; descIndex < pRootSignature->mVkDynamicDescriptorCounts[i]; ++descIndex)
{
DescriptorInfo* pDesc = layout.mDynamicDescriptors[descIndex];
pDesc->mRootDescriptorIndex = descIndex;
}
}
/************************************************************************/
// Pipeline layout
/************************************************************************/
eastl::vector<VkDescriptorSetLayout> descriptorSetLayouts;
eastl::vector<VkPushConstantRange> pushConstants(pRootSignature->mVkPushConstantCount);
for (uint32_t i = 0; i < DESCRIPTOR_UPDATE_FREQ_COUNT; ++i)
if (pRootSignature->mVkDescriptorSetLayouts[i])
descriptorSetLayouts.emplace_back(pRootSignature->mVkDescriptorSetLayouts[i]);
for (uint32_t i = 0; i < pRootSignature->mVkPushConstantCount; ++i)
{
pushConstants[i].offset = 0;
pushConstants[i].size = pushConstantDescriptors[i]->mSize;
pushConstants[i].stageFlags = pushConstantDescriptors[i]->mVkStages;
}
DECLARE_ZERO(VkPipelineLayoutCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.setLayoutCount = (uint32_t)descriptorSetLayouts.size();
add_info.pSetLayouts = descriptorSetLayouts.data();
add_info.pushConstantRangeCount = pRootSignature->mVkPushConstantCount;
add_info.pPushConstantRanges = pushConstants.data();
VkResult vk_res = vkCreatePipelineLayout(pRenderer->pVkDevice, &add_info, NULL, &(pRootSignature->pPipelineLayout));
ASSERT(VK_SUCCESS == vk_res);
/************************************************************************/
// Update templates
/************************************************************************/
for (uint32_t setIndex = 0; setIndex < DESCRIPTOR_UPDATE_FREQ_COUNT; ++setIndex)
{
if (pRootSignature->mVkDescriptorCounts[setIndex])
{
pRootSignature->pUpdateTemplateData[setIndex] = (void**)conf_calloc(pRenderer->mLinkedNodeCount, sizeof(DescriptorUpdateData*));
const UpdateFrequencyLayoutInfo& layout = layouts[setIndex];
VkDescriptorUpdateTemplateEntry* pEntries = (VkDescriptorUpdateTemplateEntry*)alloca(pRootSignature->mVkDescriptorCounts[setIndex] * sizeof(VkDescriptorUpdateTemplateEntry));
uint32_t entryCount = 0;
for (uint32_t nodeIndex = 0; nodeIndex < pRenderer->mLinkedNodeCount; ++nodeIndex)
{
pRootSignature->pUpdateTemplateData[setIndex][nodeIndex] = conf_calloc(pRootSignature->mVkCumulativeDescriptorCounts[setIndex], sizeof(DescriptorUpdateData));
}
// Fill the write descriptors with default values during initialize so the only thing we change in cmdBindDescriptors is the the VkBuffer / VkImageView objects
for (uint32_t i = 0; i < (uint32_t)layout.mDescriptors.size(); ++i)
{
const DescriptorInfo* pDesc = layout.mDescriptors[i];
const uint64_t offset = pDesc->mHandleIndex * sizeof(DescriptorUpdateData);
#ifdef VK_NV_RAY_TRACING_SPEC_VERSION
// Raytracing descriptors dont support update template so we ignore them
if (pDesc->mType == DESCRIPTOR_TYPE_RAY_TRACING)
{
pRootSignature->mVkRaytracingDescriptorCounts[setIndex] += pDesc->mSize;
continue;
}
#endif
pEntries[entryCount].descriptorCount = pDesc->mSize;
pEntries[entryCount].descriptorType = (VkDescriptorType)pDesc->mVkType;
pEntries[entryCount].dstArrayElement = 0;
pEntries[entryCount].dstBinding = pDesc->mReg;
pEntries[entryCount].offset = offset;
pEntries[entryCount].stride = sizeof(DescriptorUpdateData);
for (uint32_t nodeIndex = 0; nodeIndex < pRenderer->mLinkedNodeCount; ++nodeIndex)
{
DescriptorUpdateData* pUpdateData = (DescriptorUpdateData*)pRootSignature->pUpdateTemplateData[setIndex][nodeIndex];
const DescriptorType type = (DescriptorType)pDesc->mType;
const uint32_t arrayCount = pDesc->mSize;
switch (type)
{
case DESCRIPTOR_TYPE_SAMPLER:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo = { pRenderer->pNullDescriptors->pDefaultSampler->pVkSampler, VK_NULL_HANDLE };
break;
}
case DESCRIPTOR_TYPE_TEXTURE:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo = { VK_NULL_HANDLE, pRenderer->pNullDescriptors->pDefaultTextureSRV[nodeIndex][pDesc->mDim]->pVkSRVDescriptor, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL };
break;
}
case DESCRIPTOR_TYPE_RW_TEXTURE:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mImageInfo = { VK_NULL_HANDLE, pRenderer->pNullDescriptors->pDefaultTextureUAV[nodeIndex][pDesc->mDim]->pVkUAVDescriptors[0], VK_IMAGE_LAYOUT_GENERAL };
break;
}
case DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case DESCRIPTOR_TYPE_BUFFER:
case DESCRIPTOR_TYPE_BUFFER_RAW:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mBufferInfo =
{
pRenderer->pNullDescriptors->pDefaultBufferSRV[nodeIndex]->pVkBuffer,
pRenderer->pNullDescriptors->pDefaultBufferSRV[nodeIndex]->mOffset,
VK_WHOLE_SIZE
};
break;
}
case DESCRIPTOR_TYPE_RW_BUFFER:
case DESCRIPTOR_TYPE_RW_BUFFER_RAW:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mBufferInfo =
{
pRenderer->pNullDescriptors->pDefaultBufferUAV[nodeIndex]->pVkBuffer,
pRenderer->pNullDescriptors->pDefaultBufferUAV[nodeIndex]->mOffset,
VK_WHOLE_SIZE
};
break;
}
case DESCRIPTOR_TYPE_TEXEL_BUFFER:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mBuferView = pRenderer->pNullDescriptors->pDefaultBufferSRV[nodeIndex]->pVkUniformTexelView;
break;
}
case DESCRIPTOR_TYPE_RW_TEXEL_BUFFER:
{
for (uint32_t arr = 0; arr < arrayCount; ++arr)
pUpdateData[pDesc->mHandleIndex + arr].mBuferView = pRenderer->pNullDescriptors->pDefaultBufferUAV[nodeIndex]->pVkStorageTexelView;
break;
}
default:
break;
}
}
++entryCount;
}
VkDescriptorUpdateTemplateCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR;
createInfo.pNext = NULL;
createInfo.descriptorSetLayout = pRootSignature->mVkDescriptorSetLayouts[setIndex];
createInfo.descriptorUpdateEntryCount = entryCount;
createInfo.pDescriptorUpdateEntries = pEntries;
createInfo.pipelineBindPoint = gPipelineBindPoint[pRootSignature->mPipelineType];
createInfo.pipelineLayout = pRootSignature->pPipelineLayout;
createInfo.set = setIndex;
createInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR;
VkResult vkRes = vkCreateDescriptorUpdateTemplateKHR(pRenderer->pVkDevice, &createInfo, NULL, &pRootSignature->mUpdateTemplates[setIndex]);
ASSERT(VK_SUCCESS == vkRes);
}
else if (VK_NULL_HANDLE != pRootSignature->mVkDescriptorSetLayouts[setIndex])
{
// Consume empty descriptor sets from empty descriptor set pool
VkDescriptorSet* pSets[] = { &pRootSignature->mVkEmptyDescriptorSets[setIndex] };
consume_descriptor_sets(pRenderer->pDescriptorPool, &pRootSignature->mVkDescriptorSetLayouts[setIndex], pSets, 1);
}
}
*ppRootSignature = pRootSignature;
}
void removeRootSignature(Renderer* pRenderer, RootSignature* pRootSignature)
{
for (uint32_t i = 0; i < DESCRIPTOR_UPDATE_FREQ_COUNT; ++i)
{
vkDestroyDescriptorSetLayout(pRenderer->pVkDevice, pRootSignature->mVkDescriptorSetLayouts[i], NULL);
if (VK_NULL_HANDLE != pRootSignature->mUpdateTemplates[i])
vkDestroyDescriptorUpdateTemplateKHR(pRenderer->pVkDevice, pRootSignature->mUpdateTemplates[i], NULL);
if (pRootSignature->mVkDescriptorCounts[i])
for (uint32_t nodeIndex = 0; nodeIndex < pRenderer->mLinkedNodeCount; ++nodeIndex)
SAFE_FREE(pRootSignature->pUpdateTemplateData[i][nodeIndex]);
SAFE_FREE(pRootSignature->pUpdateTemplateData[i]);
}
// Need delete since the destructor frees allocated memory
pRootSignature->pDescriptorNameToIndexMap->mMap.clear(true);
vkDestroyPipelineLayout(pRenderer->pVkDevice, pRootSignature->pPipelineLayout, NULL);
SAFE_FREE(pRootSignature);
}
/************************************************************************/
// Pipeline State Functions
/************************************************************************/
static void addGraphicsPipelineImpl(Renderer* pRenderer, const GraphicsPipelineDesc* pDesc, Pipeline** ppPipeline)
{
ASSERT(pRenderer);
ASSERT(ppPipeline);
ASSERT(pDesc);
ASSERT(pDesc->pShaderProgram);
ASSERT(pDesc->pRootSignature);
Pipeline* pPipeline = (Pipeline*)conf_calloc(1, sizeof(Pipeline));
ASSERT(pPipeline);
const Shader* pShaderProgram = pDesc->pShaderProgram;
const VertexLayout* pVertexLayout = pDesc->pVertexLayout;
pPipeline->mType = PIPELINE_TYPE_GRAPHICS;
// Create tempporary renderpass for pipeline creation
RenderPassDesc renderPassDesc = { 0 };
RenderPass* pRenderPass = NULL;
renderPassDesc.mRenderTargetCount = pDesc->mRenderTargetCount;
renderPassDesc.pColorFormats = pDesc->pColorFormats;
renderPassDesc.mSampleCount = pDesc->mSampleCount;
renderPassDesc.mDepthStencilFormat = pDesc->mDepthStencilFormat;
add_render_pass(pRenderer, &renderPassDesc, &pRenderPass);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
for (uint32_t i = 0; i < pShaderProgram->pReflection->mStageReflectionCount; ++i)
ASSERT(VK_NULL_HANDLE != pShaderProgram->pShaderModules[i]);
// Pipeline
{
uint32_t stage_count = 0;
DECLARE_ZERO(VkPipelineShaderStageCreateInfo, stages[5]);
for (uint32_t i = 0; i < 5; ++i)
{
ShaderStage stage_mask = (ShaderStage)(1 << i);
if (stage_mask == (pShaderProgram->mStages & stage_mask))
{
stages[stage_count].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stages[stage_count].pNext = NULL;
stages[stage_count].flags = 0;
stages[stage_count].pSpecializationInfo = NULL;
switch (stage_mask)
{
case SHADER_STAGE_VERT:
{
stages[stage_count].pName =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mVertexStageIndex].pEntryPoint;
stages[stage_count].stage = VK_SHADER_STAGE_VERTEX_BIT;
stages[stage_count].module = pShaderProgram->pShaderModules[pShaderProgram->pReflection->mVertexStageIndex];
}
break;
case SHADER_STAGE_TESC:
{
stages[stage_count].pName =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mHullStageIndex].pEntryPoint;
stages[stage_count].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
stages[stage_count].module = pShaderProgram->pShaderModules[pShaderProgram->pReflection->mHullStageIndex];
}
break;
case SHADER_STAGE_TESE:
{
stages[stage_count].pName =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mDomainStageIndex].pEntryPoint;
stages[stage_count].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
stages[stage_count].module = pShaderProgram->pShaderModules[pShaderProgram->pReflection->mDomainStageIndex];
}
break;
case SHADER_STAGE_GEOM:
{
stages[stage_count].pName =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mGeometryStageIndex].pEntryPoint;
stages[stage_count].stage = VK_SHADER_STAGE_GEOMETRY_BIT;
stages[stage_count].module = pShaderProgram->pShaderModules[pShaderProgram->pReflection->mGeometryStageIndex];
}
break;
case SHADER_STAGE_FRAG:
{
stages[stage_count].pName =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mPixelStageIndex].pEntryPoint;
stages[stage_count].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
stages[stage_count].module = pShaderProgram->pShaderModules[pShaderProgram->pReflection->mPixelStageIndex];
}
break;
default: ASSERT(false && "Shader Stage not supported!"); break;
}
++stage_count;
}
}
// Make sure there's a shader
ASSERT(0 != stage_count);
uint32_t input_binding_count = 0;
VkVertexInputBindingDescription input_bindings[MAX_VERTEX_BINDINGS] = { { 0 } };
uint32_t input_attribute_count = 0;
VkVertexInputAttributeDescription input_attributes[MAX_VERTEX_ATTRIBS] = { { 0 } };
// Make sure there's attributes
if (pVertexLayout != NULL)
{
// Ignore everything that's beyond max_vertex_attribs
uint32_t attrib_count = pVertexLayout->mAttribCount > MAX_VERTEX_ATTRIBS ? MAX_VERTEX_ATTRIBS : pVertexLayout->mAttribCount;
uint32_t binding_value = UINT32_MAX;
// Initial values
for (uint32_t i = 0; i < attrib_count; ++i)
{
const VertexAttrib* attrib = &(pVertexLayout->mAttribs[i]);
if (binding_value != attrib->mBinding)
{
binding_value = attrib->mBinding;
++input_binding_count;
}
input_bindings[input_binding_count - 1].binding = binding_value;
if (attrib->mRate == VERTEX_ATTRIB_RATE_INSTANCE)
{
input_bindings[input_binding_count - 1].inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
}
else
{
input_bindings[input_binding_count - 1].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
}
input_bindings[input_binding_count - 1].stride += TinyImageFormat_BitSizeOfBlock(attrib->mFormat) / 8;
input_attributes[input_attribute_count].location = attrib->mLocation;
input_attributes[input_attribute_count].binding = attrib->mBinding;
input_attributes[input_attribute_count].format = (VkFormat)TinyImageFormat_ToVkFormat(attrib->mFormat);
input_attributes[input_attribute_count].offset = attrib->mOffset;
++input_attribute_count;
}
}
DECLARE_ZERO(VkPipelineVertexInputStateCreateInfo, vi);
vi.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vi.pNext = NULL;
vi.flags = 0;
vi.vertexBindingDescriptionCount = input_binding_count;
vi.pVertexBindingDescriptions = input_bindings;
vi.vertexAttributeDescriptionCount = input_attribute_count;
vi.pVertexAttributeDescriptions = input_attributes;
VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
switch (pDesc->mPrimitiveTopo)
{
case PRIMITIVE_TOPO_POINT_LIST: topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; break;
case PRIMITIVE_TOPO_LINE_LIST: topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; break;
case PRIMITIVE_TOPO_LINE_STRIP: topology = VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; break;
case PRIMITIVE_TOPO_TRI_STRIP: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; break;
case PRIMITIVE_TOPO_PATCH_LIST: topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; break;
case PRIMITIVE_TOPO_TRI_LIST: topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; break;
default: ASSERT(false && "Primitive Topo not supported!"); break;
}
DECLARE_ZERO(VkPipelineInputAssemblyStateCreateInfo, ia);
ia.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
ia.pNext = NULL;
ia.flags = 0;
ia.topology = topology;
ia.primitiveRestartEnable = VK_FALSE;
DECLARE_ZERO(VkPipelineTessellationStateCreateInfo, ts);
if ((pShaderProgram->mStages & SHADER_STAGE_TESC) && (pShaderProgram->mStages & SHADER_STAGE_TESE))
{
ts.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
ts.pNext = NULL;
ts.flags = 0;
ts.patchControlPoints =
pShaderProgram->pReflection->mStageReflections[pShaderProgram->pReflection->mHullStageIndex].mNumControlPoint;
}
DECLARE_ZERO(VkPipelineViewportStateCreateInfo, vs);
vs.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
vs.pNext = NULL;
vs.flags = 0;
// we are using dynimic viewports but we must set the count to 1
vs.viewportCount = 1;
vs.pViewports = NULL;
vs.scissorCount = 1;
vs.pScissors = NULL;
DECLARE_ZERO(VkPipelineMultisampleStateCreateInfo, ms);
ms.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
ms.pNext = NULL;
ms.flags = 0;
ms.rasterizationSamples = util_to_vk_sample_count(pDesc->mSampleCount);
ms.sampleShadingEnable = VK_FALSE;
ms.minSampleShading = 0.0f;
ms.pSampleMask = 0;
ms.alphaToCoverageEnable = VK_FALSE;
ms.alphaToOneEnable = VK_FALSE;
DECLARE_ZERO(VkPipelineRasterizationStateCreateInfo, rs);
rs = pDesc->pRasterizerState ? util_to_rasterizer_desc(pDesc->pRasterizerState) : gDefaultRasterizerDesc;
/// TODO: Dont create depth state if no depth stencil bound
DECLARE_ZERO(VkPipelineDepthStencilStateCreateInfo, ds);
ds = pDesc->pDepthState ? util_to_depth_desc(pDesc->pDepthState) : gDefaultDepthDesc;
DECLARE_ZERO(VkPipelineColorBlendStateCreateInfo, cb);
DECLARE_ZERO(VkPipelineColorBlendAttachmentState, cbAtt[MAX_RENDER_TARGET_ATTACHMENTS]);
cb = pDesc->pBlendState ? util_to_blend_desc(pDesc->pBlendState, cbAtt) : gDefaultBlendDesc;
cb.attachmentCount = pDesc->mRenderTargetCount;
DECLARE_ZERO(VkDynamicState, dyn_states[5]);
dyn_states[0] = VK_DYNAMIC_STATE_VIEWPORT;
dyn_states[1] = VK_DYNAMIC_STATE_SCISSOR;
dyn_states[2] = VK_DYNAMIC_STATE_DEPTH_BIAS;
dyn_states[3] = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
dyn_states[4] = VK_DYNAMIC_STATE_DEPTH_BOUNDS;
DECLARE_ZERO(VkPipelineDynamicStateCreateInfo, dy);
dy.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dy.pNext = NULL;
dy.flags = 0;
dy.dynamicStateCount = 5;
dy.pDynamicStates = dyn_states;
DECLARE_ZERO(VkGraphicsPipelineCreateInfo, add_info);
add_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
add_info.pNext = NULL;
add_info.flags = 0;
add_info.stageCount = stage_count;
add_info.pStages = stages;
add_info.pVertexInputState = &vi;
add_info.pInputAssemblyState = &ia;
if ((pShaderProgram->mStages & SHADER_STAGE_TESC) && (pShaderProgram->mStages & SHADER_STAGE_TESE))
add_info.pTessellationState = &ts;
else
add_info.pTessellationState = NULL; // set tessellation state to null if we have no tessellation
add_info.pViewportState = &vs;
add_info.pRasterizationState = &rs;
add_info.pMultisampleState = &ms;
add_info.pDepthStencilState = &ds;
add_info.pColorBlendState = &cb;
add_info.pDynamicState = &dy;
add_info.layout = pDesc->pRootSignature->pPipelineLayout;
add_info.renderPass = pRenderPass->pRenderPass;
add_info.subpass = 0;
add_info.basePipelineHandle = VK_NULL_HANDLE;
add_info.basePipelineIndex = -1;
VkResult vk_res = vkCreateGraphicsPipelines(pRenderer->pVkDevice, VK_NULL_HANDLE, 1, &add_info, NULL, &(pPipeline->pVkPipeline));
ASSERT(VK_SUCCESS == vk_res);
remove_render_pass(pRenderer, pRenderPass);
}
*ppPipeline = pPipeline;
}
static void addComputePipelineImpl(Renderer* pRenderer, const ComputePipelineDesc* pDesc, Pipeline** ppPipeline)
{
ASSERT(pRenderer);
ASSERT(ppPipeline);
ASSERT(pDesc);
ASSERT(pDesc->pShaderProgram);
ASSERT(pDesc->pRootSignature);
ASSERT(pRenderer->pVkDevice != VK_NULL_HANDLE);
ASSERT(pDesc->pShaderProgram->pShaderModules[0] != VK_NULL_HANDLE);
Pipeline* pPipeline = (Pipeline*)conf_calloc(1, sizeof(Pipeline));
ASSERT(pPipeline);
pPipeline->mType = PIPELINE_TYPE_COMPUTE;
// Pipeline
{
DECLARE_ZERO(VkPipelineShaderStageCreateInfo, stage);
stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stage.pNext = NULL;
stage.flags = 0;
stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
stage.module = pDesc->pShaderProgram->pShaderModules[0];
stage.pName = pDesc->pShaderProgram->pReflection->mStageReflections[0].pEntryPoint;
stage.pSpecializationInfo = NULL;
DECLARE_ZERO(VkComputePipelineCreateInfo, create_info);
create_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
create_info.pNext = NULL;
create_info.flags = 0;
create_info.stage = stage;
create_info.layout = pDesc->pRootSignature->pPipelineLayout;
create_info.basePipelineHandle = 0;
create_info.basePipelineIndex = 0;
VkResult vk_res = vkCreateComputePipelines(pRenderer->pVkDevice, VK_NULL_HANDLE, 1, &create_info, NULL, &(pPipeline->pVkPipeline));
ASSERT(VK_SUCCESS == vk_res);
}
*ppPipeline = pPipeline;
}
void addPipeline(Renderer* pRenderer, const PipelineDesc* pDesc, Pipeline** ppPipeline)
{
switch (pDesc->mType)
{
case(PIPELINE_TYPE_COMPUTE):
{
addComputePipelineImpl(pRenderer, &pDesc->mComputeDesc, ppPipeline);
break;
}
case(PIPELINE_TYPE_GRAPHICS):
{
addGraphicsPipelineImpl(pRenderer, &pDesc->mGraphicsDesc, ppPipeline);
break;
}
#ifdef ENABLE_RAYTRACING
case(PIPELINE_TYPE_RAYTRACING):
{
addRaytracingPipelineImpl(&pDesc->mRaytracingDesc, ppPipeline);
break;
}
#endif
default:
{
ASSERT(false);
*ppPipeline = {};
break;
}
}
}
void removePipeline(Renderer* pRenderer, Pipeline* pPipeline)
{
ASSERT(pRenderer);
ASSERT(pPipeline);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pPipeline->pVkPipeline);
#ifdef ENABLE_RAYTRACING
SAFE_FREE(pPipeline->ppShaderStageNames);
#endif
vkDestroyPipeline(pRenderer->pVkDevice, pPipeline->pVkPipeline, NULL);
SAFE_FREE(pPipeline);
}
/************************************************************************/
// Command buffer functions
/************************************************************************/
void beginCmd(Cmd* pCmd)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
// reset buffer to conf_free memory
vkResetCommandBuffer(pCmd->pVkCmdBuf, 0);
DECLARE_ZERO(VkCommandBufferBeginInfo, begin_info);
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
begin_info.pNext = NULL;
begin_info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
begin_info.pInheritanceInfo = NULL;
VkDeviceGroupCommandBufferBeginInfoKHR deviceGroupBeginInfo = { VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR };
deviceGroupBeginInfo.pNext = NULL;
if (pCmd->pRenderer->mGpuMode == GPU_MODE_LINKED)
{
deviceGroupBeginInfo.deviceMask = (1 << pCmd->mNodeIndex);
begin_info.pNext = &deviceGroupBeginInfo;
}
VkResult vk_res = vkBeginCommandBuffer(pCmd->pVkCmdBuf, &begin_info);
ASSERT(VK_SUCCESS == vk_res);
// Reset CPU side data
pCmd->pBoundPipelineLayout = NULL;
}
void endCmd(Cmd* pCmd)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
if (pCmd->pVkActiveRenderPass)
{
vkCmdEndRenderPass(pCmd->pVkCmdBuf);
}
pCmd->pVkActiveRenderPass = VK_NULL_HANDLE;
VkResult vk_res = vkEndCommandBuffer(pCmd->pVkCmdBuf);
ASSERT(VK_SUCCESS == vk_res);
}
void cmdBindRenderTargets(
Cmd* pCmd, uint32_t renderTargetCount, RenderTarget** ppRenderTargets, RenderTarget* pDepthStencil,
const LoadActionsDesc* pLoadActions /* = NULL*/, uint32_t* pColorArraySlices, uint32_t* pColorMipSlices, uint32_t depthArraySlice,
uint32_t depthMipSlice)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
if (pCmd->pVkActiveRenderPass)
{
vkCmdEndRenderPass(pCmd->pVkCmdBuf);
pCmd->pVkActiveRenderPass = VK_NULL_HANDLE;
}
if (!renderTargetCount && !pDepthStencil)
return;
uint64_t renderPassHash = 0;
uint64_t frameBufferHash = 0;
// Generate hash for render pass and frame buffer
// NOTE:
// Render pass does not care about underlying VkImageView. It only cares about the format and sample count of the attachments.
// We hash those two values to generate render pass hash
// Frame buffer is the actual array of all the VkImageViews
// We hash the texture id associated with the render target to generate frame buffer hash
for (uint32_t i = 0; i < renderTargetCount; ++i)
{
uint32_t hashValues[] = {
(uint32_t)ppRenderTargets[i]->mFormat,
(uint32_t)ppRenderTargets[i]->mSampleCount,
pLoadActions ? (uint32_t)pLoadActions->mLoadActionsColor[i] : 0,
};
renderPassHash = eastl::mem_hash<uint32_t>()(hashValues, 3, renderPassHash);
frameBufferHash = eastl::mem_hash<uint64_t>()(&ppRenderTargets[i]->mId, 1, frameBufferHash);
}
if (pDepthStencil)
{
uint32_t hashValues[] = {
(uint32_t)pDepthStencil->mFormat,
(uint32_t)pDepthStencil->mSampleCount,
pLoadActions ? (uint32_t)pLoadActions->mLoadActionDepth : 0,
pLoadActions ? (uint32_t)pLoadActions->mLoadActionStencil : 0,
};
renderPassHash = eastl::mem_hash<uint32_t>()(hashValues, 4, renderPassHash);
frameBufferHash = eastl::mem_hash<uint64_t>()(&pDepthStencil->mId, 1, frameBufferHash);
}
if (pColorArraySlices)
frameBufferHash = eastl::mem_hash<uint32_t>()(pColorArraySlices, renderTargetCount, frameBufferHash);
if (pColorMipSlices)
frameBufferHash = eastl::mem_hash<uint32_t>()(pColorMipSlices, renderTargetCount, frameBufferHash);
if (depthArraySlice != -1)
frameBufferHash = eastl::mem_hash<uint32_t>()(&depthArraySlice, 1, frameBufferHash);
if (depthMipSlice != -1)
frameBufferHash = eastl::mem_hash<uint32_t>()(&depthMipSlice, 1, frameBufferHash);
SampleCount sampleCount = renderTargetCount ? ppRenderTargets[0]->mSampleCount : pDepthStencil->mSampleCount;
RenderPassMap& renderPassMap = get_render_pass_map();
FrameBufferMap& frameBufferMap = get_frame_buffer_map();
const RenderPassMapIt pNode = renderPassMap.find(renderPassHash);
const FrameBufferMapIt pFrameBufferNode = frameBufferMap.find(frameBufferHash);
RenderPass* pRenderPass = NULL;
FrameBuffer* pFrameBuffer = NULL;
// If a render pass of this combination already exists just use it or create a new one
if (pNode != renderPassMap.end())
{
pRenderPass = pNode->second;
}
else
{
TinyImageFormat colorFormats[MAX_RENDER_TARGET_ATTACHMENTS] = {};
TinyImageFormat depthStencilFormat = TinyImageFormat_UNDEFINED;
for (uint32_t i = 0; i < renderTargetCount; ++i)
{
colorFormats[i] = ppRenderTargets[i]->mFormat;
}
if (pDepthStencil)
{
depthStencilFormat = pDepthStencil->mFormat;
}
RenderPassDesc renderPassDesc = {};
renderPassDesc.mRenderTargetCount = renderTargetCount;
renderPassDesc.mSampleCount = sampleCount;
renderPassDesc.pColorFormats = colorFormats;
renderPassDesc.mDepthStencilFormat = depthStencilFormat;
renderPassDesc.pLoadActionsColor = pLoadActions ? pLoadActions->mLoadActionsColor : NULL;
renderPassDesc.mLoadActionDepth = pLoadActions ? pLoadActions->mLoadActionDepth : LOAD_ACTION_DONTCARE;
renderPassDesc.mLoadActionStencil = pLoadActions ? pLoadActions->mLoadActionStencil : LOAD_ACTION_DONTCARE;
add_render_pass(pCmd->pRenderer, &renderPassDesc, &pRenderPass);
// No need of a lock here since this map is per thread
renderPassMap.insert({{ renderPassHash, pRenderPass }});
}
// If a frame buffer of this combination already exists just use it or create a new one
if (pFrameBufferNode != frameBufferMap.end())
{
pFrameBuffer = pFrameBufferNode->second;
}
else
{
FrameBufferDesc desc = { 0 };
desc.mRenderTargetCount = renderTargetCount;
desc.pDepthStencil = pDepthStencil;
desc.ppRenderTargets = ppRenderTargets;
desc.pRenderPass = pRenderPass;
desc.pColorArraySlices = pColorArraySlices;
desc.pColorMipSlices = pColorMipSlices;
desc.mDepthArraySlice = depthArraySlice;
desc.mDepthMipSlice = depthMipSlice;
add_framebuffer(pCmd->pRenderer, &desc, &pFrameBuffer);
// No need of a lock here since this map is per thread
frameBufferMap.insert({{ frameBufferHash, pFrameBuffer }});
}
DECLARE_ZERO(VkRect2D, render_area);
render_area.offset.x = 0;
render_area.offset.y = 0;
render_area.extent.width = pFrameBuffer->mWidth;
render_area.extent.height = pFrameBuffer->mHeight;
uint32_t clearValueCount = renderTargetCount;
VkClearValue clearValues[MAX_RENDER_TARGET_ATTACHMENTS + 1] = {};
if (pLoadActions)
{
for (uint32_t i = 0; i < renderTargetCount; ++i)
{
ClearValue clearValue = pLoadActions->mClearColorValues[i];
clearValues[i].color = {{ clearValue.r, clearValue.g, clearValue.b, clearValue.a }};
}
if (pDepthStencil)
{
clearValues[renderTargetCount].depthStencil = { pLoadActions->mClearDepth.depth, pLoadActions->mClearDepth.stencil };
++clearValueCount;
}
}
DECLARE_ZERO(VkRenderPassBeginInfo, begin_info);
begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
begin_info.pNext = NULL;
begin_info.renderPass = pRenderPass->pRenderPass;
begin_info.framebuffer = pFrameBuffer->pFramebuffer;
begin_info.renderArea = render_area;
begin_info.clearValueCount = clearValueCount;
begin_info.pClearValues = clearValues;
vkCmdBeginRenderPass(pCmd->pVkCmdBuf, &begin_info, VK_SUBPASS_CONTENTS_INLINE);
pCmd->pVkActiveRenderPass = pRenderPass->pRenderPass;
}
void cmdSetViewport(Cmd* pCmd, float x, float y, float width, float height, float minDepth, float maxDepth)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
DECLARE_ZERO(VkViewport, viewport);
viewport.x = x;
viewport.y = y + height;
viewport.width = width;
viewport.height = -height;
viewport.minDepth = minDepth;
viewport.maxDepth = maxDepth;
vkCmdSetViewport(pCmd->pVkCmdBuf, 0, 1, &viewport);
}
void cmdSetScissor(Cmd* pCmd, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
DECLARE_ZERO(VkRect2D, rect);
rect.offset.x = x;
rect.offset.y = y;
rect.extent.width = width;
rect.extent.height = height;
vkCmdSetScissor(pCmd->pVkCmdBuf, 0, 1, &rect);
}
void cmdBindPipeline(Cmd* pCmd, Pipeline* pPipeline)
{
ASSERT(pCmd);
ASSERT(pPipeline);
ASSERT(pCmd->pVkCmdBuf != VK_NULL_HANDLE);
VkPipelineBindPoint pipeline_bind_point = gPipelineBindPoint[pPipeline->mType];
vkCmdBindPipeline(pCmd->pVkCmdBuf, pipeline_bind_point, pPipeline->pVkPipeline);
}
void cmdBindIndexBuffer(Cmd* pCmd, Buffer* pBuffer, uint32_t indexType, uint64_t offset)
{
ASSERT(pCmd);
ASSERT(pBuffer);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
VkIndexType vk_index_type = (INDEX_TYPE_UINT16 == indexType) ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32;
vkCmdBindIndexBuffer(pCmd->pVkCmdBuf, pBuffer->pVkBuffer, offset, vk_index_type);
}
void cmdBindVertexBuffer(Cmd* pCmd, uint32_t bufferCount, Buffer** ppBuffers, const uint32_t* pStrides, const uint64_t* pOffsets)
{
UNREF_PARAM(pStrides);
ASSERT(pCmd);
ASSERT(0 != bufferCount);
ASSERT(ppBuffers);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
ASSERT(pStrides);
const uint32_t max_buffers = pCmd->pRenderer->pVkActiveGPUProperties->properties.limits.maxVertexInputBindings;
uint32_t capped_buffer_count = bufferCount > max_buffers ? max_buffers : bufferCount;
// No upper bound for this, so use 64 for now
ASSERT(capped_buffer_count < 64);
DECLARE_ZERO(VkBuffer, buffers[64]);
DECLARE_ZERO(VkDeviceSize, offsets[64]);
for (uint32_t i = 0; i < capped_buffer_count; ++i)
{
buffers[i] = ppBuffers[i]->pVkBuffer;
offsets[i] = (pOffsets ? pOffsets[i] : 0);
}
vkCmdBindVertexBuffers(pCmd->pVkCmdBuf, 0, capped_buffer_count, buffers, offsets);
}
void cmdDraw(Cmd* pCmd, uint32_t vertex_count, uint32_t first_vertex)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
vkCmdDraw(pCmd->pVkCmdBuf, vertex_count, 1, first_vertex, 0);
}
void cmdDrawInstanced(Cmd* pCmd, uint32_t vertexCount, uint32_t firstVertex, uint32_t instanceCount, uint32_t firstInstance)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
vkCmdDraw(pCmd->pVkCmdBuf, vertexCount, instanceCount, firstVertex, firstInstance);
}
void cmdDrawIndexed(Cmd* pCmd, uint32_t index_count, uint32_t first_index, uint32_t first_vertex)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
vkCmdDrawIndexed(pCmd->pVkCmdBuf, index_count, 1, first_index, first_vertex, 0);
}
void cmdDrawIndexedInstanced(
Cmd* pCmd, uint32_t indexCount, uint32_t firstIndex, uint32_t instanceCount, uint32_t firstInstance, uint32_t firstVertex)
{
ASSERT(pCmd);
ASSERT(VK_NULL_HANDLE != pCmd->pVkCmdBuf);
vkCmdDrawIndexed(pCmd->pVkCmdBuf, indexCount, instanceCount, firstIndex, firstVertex, firstInstance);
}
void cmdDispatch(Cmd* pCmd, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
{
ASSERT(pCmd);
ASSERT(pCmd->pVkCmdBuf != VK_NULL_HANDLE);
vkCmdDispatch(pCmd->pVkCmdBuf, groupCountX, groupCountY, groupCountZ);
}
void cmdResourceBarrier(Cmd* pCmd,
uint32_t numBufferBarriers, BufferBarrier* pBufferBarriers,
uint32_t numTextureBarriers, TextureBarrier* pTextureBarriers,
uint32_t numRtBarriers, RenderTargetBarrier* pRtBarriers)
{
VkImageMemoryBarrier* imageBarriers =
(numTextureBarriers + numRtBarriers) ? (VkImageMemoryBarrier*)alloca((numTextureBarriers + numRtBarriers) * sizeof(VkImageMemoryBarrier)) : NULL;
uint32_t imageBarrierCount = 0;
VkBufferMemoryBarrier* bufferBarriers =
numBufferBarriers ? (VkBufferMemoryBarrier*)alloca(numBufferBarriers * sizeof(VkBufferMemoryBarrier)) : NULL;
uint32_t bufferBarrierCount = 0;
VkAccessFlags srcAccessFlags = 0;
VkAccessFlags dstAccessFlags = 0;
for (uint32_t i = 0; i < numBufferBarriers; ++i)
{
BufferBarrier* pTrans = &pBufferBarriers[i];
Buffer* pBuffer = pTrans->pBuffer;
if (!(pTrans->mNewState & pBuffer->mCurrentState))
{
VkBufferMemoryBarrier* pBufferBarrier = &bufferBarriers[bufferBarrierCount++];
pBufferBarrier->sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
pBufferBarrier->pNext = NULL;
pBufferBarrier->buffer = pBuffer->pVkBuffer;
pBufferBarrier->size = VK_WHOLE_SIZE;
pBufferBarrier->offset = 0;
pBufferBarrier->srcAccessMask = util_to_vk_access_flags((ResourceState)pBuffer->mCurrentState);
pBufferBarrier->dstAccessMask = util_to_vk_access_flags(pTrans->mNewState);
pBufferBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pBufferBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pBuffer->mCurrentState = pTrans->mNewState;
srcAccessFlags |= pBufferBarrier->srcAccessMask;
dstAccessFlags |= pBufferBarrier->dstAccessMask;
}
else if (pTrans->mNewState == RESOURCE_STATE_UNORDERED_ACCESS)
{
VkBufferMemoryBarrier* pBufferBarrier = &bufferBarriers[bufferBarrierCount++];
pBufferBarrier->sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
pBufferBarrier->pNext = NULL;
pBufferBarrier->buffer = pBuffer->pVkBuffer;
pBufferBarrier->size = VK_WHOLE_SIZE;
pBufferBarrier->offset = 0;
pBufferBarrier->srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
pBufferBarrier->dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
pBufferBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pBufferBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
srcAccessFlags |= pBufferBarrier->srcAccessMask;
dstAccessFlags |= pBufferBarrier->dstAccessMask;
}
}
for (uint32_t i = 0; i < numTextureBarriers; ++i)
{
TextureBarrier* pTrans = &pTextureBarriers[i];
Texture* pTexture = pTrans->pTexture;
if (!(pTrans->mNewState & pTexture->mCurrentState))
{
VkImageMemoryBarrier* pImageBarrier = &imageBarriers[imageBarrierCount++];
pImageBarrier->sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
pImageBarrier->pNext = NULL;
pImageBarrier->image = pTexture->pVkImage;
pImageBarrier->subresourceRange.aspectMask = (VkImageAspectFlags)pTexture->mAspectMask;
pImageBarrier->subresourceRange.baseMipLevel = 0;
pImageBarrier->subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
pImageBarrier->subresourceRange.baseArrayLayer = 0;
pImageBarrier->subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
pImageBarrier->srcAccessMask = util_to_vk_access_flags((ResourceState)pTexture->mCurrentState);
pImageBarrier->dstAccessMask = util_to_vk_access_flags(pTrans->mNewState);
pImageBarrier->oldLayout = util_to_vk_image_layout((ResourceState)pTexture->mCurrentState);
pImageBarrier->newLayout = util_to_vk_image_layout(pTrans->mNewState);
pImageBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pImageBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pTexture->mCurrentState = pTrans->mNewState;
srcAccessFlags |= pImageBarrier->srcAccessMask;
dstAccessFlags |= pImageBarrier->dstAccessMask;
}
else if (pTrans->mNewState == RESOURCE_STATE_UNORDERED_ACCESS)
{
VkImageMemoryBarrier* pImageBarrier = &imageBarriers[imageBarrierCount++];
pImageBarrier->sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
pImageBarrier->pNext = NULL;
pImageBarrier->image = pTexture->pVkImage;
pImageBarrier->subresourceRange.aspectMask = (VkImageAspectFlags)pTexture->mAspectMask;
pImageBarrier->subresourceRange.baseMipLevel = 0;
pImageBarrier->subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
pImageBarrier->subresourceRange.baseArrayLayer = 0;
pImageBarrier->subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
pImageBarrier->srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
pImageBarrier->dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
pImageBarrier->oldLayout = VK_IMAGE_LAYOUT_GENERAL;
pImageBarrier->newLayout = VK_IMAGE_LAYOUT_GENERAL;
pImageBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pImageBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
srcAccessFlags |= pImageBarrier->srcAccessMask;
dstAccessFlags |= pImageBarrier->dstAccessMask;
}
}
for (uint32_t i = 0; i < numRtBarriers; ++i)
{
RenderTargetBarrier* pTrans = &pRtBarriers[i];
Texture* pTexture = pTrans->pRenderTarget->pTexture;
if (!(pTrans->mNewState & pTexture->mCurrentState))
{
VkImageMemoryBarrier* pImageBarrier = &imageBarriers[imageBarrierCount++];
pImageBarrier->sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
pImageBarrier->pNext = NULL;
pImageBarrier->image = pTexture->pVkImage;
pImageBarrier->subresourceRange.aspectMask = (VkImageAspectFlags)pTexture->mAspectMask;
pImageBarrier->subresourceRange.baseMipLevel = 0;
pImageBarrier->subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
pImageBarrier->subresourceRange.baseArrayLayer = 0;
pImageBarrier->subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
pImageBarrier->srcAccessMask = util_to_vk_access_flags((ResourceState)pTexture->mCurrentState);
pImageBarrier->dstAccessMask = util_to_vk_access_flags(pTrans->mNewState);
pImageBarrier->oldLayout = util_to_vk_image_layout((ResourceState)pTexture->mCurrentState);
pImageBarrier->newLayout = util_to_vk_image_layout(pTrans->mNewState);
pImageBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pImageBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pTexture->mCurrentState = pTrans->mNewState;
srcAccessFlags |= pImageBarrier->srcAccessMask;
dstAccessFlags |= pImageBarrier->dstAccessMask;
}
else if (pTrans->mNewState == RESOURCE_STATE_UNORDERED_ACCESS)
{
VkImageMemoryBarrier* pImageBarrier = &imageBarriers[imageBarrierCount++];
pImageBarrier->sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
pImageBarrier->pNext = NULL;
pImageBarrier->image = pTexture->pVkImage;
pImageBarrier->subresourceRange.aspectMask = (VkImageAspectFlags)pTexture->mAspectMask;
pImageBarrier->subresourceRange.baseMipLevel = 0;
pImageBarrier->subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
pImageBarrier->subresourceRange.baseArrayLayer = 0;
pImageBarrier->subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
pImageBarrier->srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
pImageBarrier->dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
pImageBarrier->oldLayout = VK_IMAGE_LAYOUT_GENERAL;
pImageBarrier->newLayout = VK_IMAGE_LAYOUT_GENERAL;
pImageBarrier->srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
pImageBarrier->dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
srcAccessFlags |= pImageBarrier->srcAccessMask;
dstAccessFlags |= pImageBarrier->dstAccessMask;
}
}
VkPipelineStageFlags srcStageMask = util_determine_pipeline_stage_flags(srcAccessFlags, (QueueType)pCmd->mType);
VkPipelineStageFlags dstStageMask = util_determine_pipeline_stage_flags(dstAccessFlags, (QueueType)pCmd->mType);
if (bufferBarrierCount || imageBarrierCount)
{
vkCmdPipelineBarrier(
pCmd->pVkCmdBuf, srcStageMask, dstStageMask, 0, 0, NULL, bufferBarrierCount, bufferBarriers, imageBarrierCount,
imageBarriers);
}
}
void cmdUpdateBuffer(Cmd* pCmd, Buffer* pBuffer, uint64_t dstOffset, Buffer* pSrcBuffer, uint64_t srcOffset, uint64_t size)
{
ASSERT(pCmd);
ASSERT(pSrcBuffer);
ASSERT(pSrcBuffer->pVkBuffer);
ASSERT(pBuffer);
ASSERT(pBuffer->pVkBuffer);
ASSERT(srcOffset + size <= pSrcBuffer->mSize);
ASSERT(dstOffset + size <= pBuffer->mSize);
DECLARE_ZERO(VkBufferCopy, region);
region.srcOffset = srcOffset;
region.dstOffset = dstOffset;
region.size = (VkDeviceSize)size;
vkCmdCopyBuffer(pCmd->pVkCmdBuf, pSrcBuffer->pVkBuffer, pBuffer->pVkBuffer, 1, ®ion);
}
void cmdUpdateSubresource(Cmd* pCmd, Texture* pTexture, Buffer* pSrcBuffer, SubresourceDataDesc* pSubresourceDesc)
{
VkBufferImageCopy pCopy;
pCopy.bufferOffset = pSubresourceDesc->mBufferOffset;
pCopy.bufferRowLength = 0;
pCopy.bufferImageHeight = 0;
pCopy.imageSubresource.aspectMask = (VkImageAspectFlags)pTexture->mAspectMask;
pCopy.imageSubresource.mipLevel = pSubresourceDesc->mMipLevel;
pCopy.imageSubresource.baseArrayLayer = pSubresourceDesc->mArrayLayer;
pCopy.imageSubresource.layerCount = 1;
pCopy.imageOffset.x = pSubresourceDesc->mRegion.mXOffset;
pCopy.imageOffset.y = pSubresourceDesc->mRegion.mYOffset;
pCopy.imageOffset.z = pSubresourceDesc->mRegion.mZOffset;
pCopy.imageExtent.width = pSubresourceDesc->mRegion.mWidth;
pCopy.imageExtent.height = pSubresourceDesc->mRegion.mHeight;
pCopy.imageExtent.depth = pSubresourceDesc->mRegion.mDepth;
vkCmdCopyBufferToImage(pCmd->pVkCmdBuf, pSrcBuffer->pVkBuffer, pTexture->pVkImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &pCopy);
}
/************************************************************************/
// Queue Fence Semaphore Functions
/************************************************************************/
void acquireNextImage(Renderer* pRenderer, SwapChain* pSwapChain, Semaphore* pSignalSemaphore, Fence* pFence, uint32_t* pImageIndex)
{
ASSERT(pRenderer);
ASSERT(VK_NULL_HANDLE != pRenderer->pVkDevice);
ASSERT(VK_NULL_HANDLE != pSwapChain->pSwapChain);
ASSERT(pSignalSemaphore || pFence);
VkResult vk_res = {};
if (pFence != NULL)
{
vk_res =
vkAcquireNextImageKHR(pRenderer->pVkDevice, pSwapChain->pSwapChain, UINT64_MAX, VK_NULL_HANDLE, pFence->pVkFence, pImageIndex);
// If swapchain is out of date, let caller know by setting image index to -1
if (vk_res == VK_ERROR_OUT_OF_DATE_KHR)
{
*pImageIndex = -1;
vkResetFences(pRenderer->pVkDevice, 1, &pFence->pVkFence);
pFence->mSubmitted = false;
return;
}
pFence->mSubmitted = true;
}
else
{
vk_res = vkAcquireNextImageKHR(
pRenderer->pVkDevice, pSwapChain->pSwapChain, UINT64_MAX, pSignalSemaphore->pVkSemaphore, VK_NULL_HANDLE, pImageIndex);
// If swapchain is out of date, let caller know by setting image index to -1
if (vk_res == VK_ERROR_OUT_OF_DATE_KHR)
{
*pImageIndex = -1;
pSignalSemaphore->mSignaled = false;
return;
}
ASSERT(VK_SUCCESS == vk_res);
pSignalSemaphore->mSignaled = true;
}
}
void queueSubmit(Queue* pQueue, const QueueSubmitDesc* pDesc)
{
ASSERT(pQueue);
ASSERT(pDesc);
uint32_t cmdCount = pDesc->mCmdCount;
Cmd** ppCmds = pDesc->ppCmds;
Fence* pFence = pDesc->pSignalFence;
uint32_t waitSemaphoreCount = pDesc->mWaitSemaphoreCount;
Semaphore** ppWaitSemaphores = pDesc->ppWaitSemaphores;
uint32_t signalSemaphoreCount = pDesc->mSignalSemaphoreCount;
Semaphore** ppSignalSemaphores = pDesc->ppSignalSemaphores;
ASSERT(cmdCount > 0);
ASSERT(ppCmds);
if (waitSemaphoreCount > 0)
{
ASSERT(ppWaitSemaphores);
}
if (signalSemaphoreCount > 0)
{
ASSERT(ppSignalSemaphores);
}
ASSERT(VK_NULL_HANDLE != pQueue->pVkQueue);
cmdCount = cmdCount > MAX_SUBMIT_CMDS ? MAX_SUBMIT_CMDS : cmdCount;
waitSemaphoreCount = waitSemaphoreCount > MAX_SUBMIT_WAIT_SEMAPHORES ? MAX_SUBMIT_WAIT_SEMAPHORES : waitSemaphoreCount;
signalSemaphoreCount = signalSemaphoreCount > MAX_SUBMIT_SIGNAL_SEMAPHORES ? MAX_SUBMIT_SIGNAL_SEMAPHORES : signalSemaphoreCount;
VkCommandBuffer* cmds = (VkCommandBuffer*)alloca(cmdCount * sizeof(VkCommandBuffer));
for (uint32_t i = 0; i < cmdCount; ++i)
{
cmds[i] = ppCmds[i]->pVkCmdBuf;
}
VkSemaphore* wait_semaphores = waitSemaphoreCount ? (VkSemaphore*)alloca(waitSemaphoreCount * sizeof(VkSemaphore)) : NULL;
VkPipelineStageFlags* wait_masks = (VkPipelineStageFlags*)alloca(waitSemaphoreCount * sizeof(VkPipelineStageFlags));
uint32_t waitCount = 0;
for (uint32_t i = 0; i < waitSemaphoreCount; ++i)
{
if (ppWaitSemaphores[i]->mSignaled)
{
wait_semaphores[waitCount] = ppWaitSemaphores[i]->pVkSemaphore;
wait_masks[waitCount] = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
++waitCount;
ppWaitSemaphores[i]->mSignaled = false;
}
}
VkSemaphore* signal_semaphores = signalSemaphoreCount ? (VkSemaphore*)alloca(signalSemaphoreCount * sizeof(VkSemaphore)) : NULL;
uint32_t signalCount = 0;
for (uint32_t i = 0; i < signalSemaphoreCount; ++i)
{
if (!ppSignalSemaphores[i]->mSignaled)
{
signal_semaphores[signalCount] = ppSignalSemaphores[i]->pVkSemaphore;
ppSignalSemaphores[i]->mCurrentNodeIndex = pQueue->mNodeIndex;
ppSignalSemaphores[signalCount]->mSignaled = true;
++signalCount;
}
}
DECLARE_ZERO(VkSubmitInfo, submit_info);
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submit_info.pNext = NULL;
submit_info.waitSemaphoreCount = waitCount;
submit_info.pWaitSemaphores = wait_semaphores;
submit_info.pWaitDstStageMask = wait_masks;
submit_info.commandBufferCount = cmdCount;
submit_info.pCommandBuffers = cmds;
submit_info.signalSemaphoreCount = signalCount;
submit_info.pSignalSemaphores = signal_semaphores;
VkDeviceGroupSubmitInfo deviceGroupSubmitInfo = { VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHR };
if (pQueue->mGpuMode == GPU_MODE_LINKED)
{
uint32_t* pVkDeviceMasks = NULL;
uint32_t* pSignalIndices = NULL;
uint32_t* pWaitIndices = NULL;
deviceGroupSubmitInfo.pNext = NULL;
deviceGroupSubmitInfo.commandBufferCount = submit_info.commandBufferCount;
deviceGroupSubmitInfo.signalSemaphoreCount = submit_info.signalSemaphoreCount;
deviceGroupSubmitInfo.waitSemaphoreCount = submit_info.waitSemaphoreCount;
pVkDeviceMasks = (uint32_t*)alloca(deviceGroupSubmitInfo.commandBufferCount * sizeof(uint32_t));
pSignalIndices = (uint32_t*)alloca(deviceGroupSubmitInfo.signalSemaphoreCount * sizeof(uint32_t));
pWaitIndices = (uint32_t*)alloca(deviceGroupSubmitInfo.waitSemaphoreCount * sizeof(uint32_t));
for (uint32_t i = 0; i < deviceGroupSubmitInfo.commandBufferCount; ++i)
{
pVkDeviceMasks[i] = (1 << ppCmds[i]->mNodeIndex);
}
for (uint32_t i = 0; i < deviceGroupSubmitInfo.signalSemaphoreCount; ++i)
{
pSignalIndices[i] = pQueue->mNodeIndex;
}
for (uint32_t i = 0; i < deviceGroupSubmitInfo.waitSemaphoreCount; ++i)
{
pWaitIndices[i] = ppWaitSemaphores[i]->mCurrentNodeIndex;
}
deviceGroupSubmitInfo.pCommandBufferDeviceMasks = pVkDeviceMasks;
deviceGroupSubmitInfo.pSignalSemaphoreDeviceIndices = pSignalIndices;
deviceGroupSubmitInfo.pWaitSemaphoreDeviceIndices = pWaitIndices;
submit_info.pNext = &deviceGroupSubmitInfo;
}
VkResult vk_res = vkQueueSubmit(pQueue->pVkQueue, 1, &submit_info, pFence ? pFence->pVkFence : VK_NULL_HANDLE);
ASSERT(VK_SUCCESS == vk_res);
if (pFence)
pFence->mSubmitted = true;
}
void queuePresent(Queue* pQueue, const QueuePresentDesc* pDesc)
{
ASSERT(pQueue);
ASSERT(pDesc);
uint32_t waitSemaphoreCount = pDesc->mWaitSemaphoreCount;
Semaphore** ppWaitSemaphores = pDesc->ppWaitSemaphores;
if (pDesc->pSwapChain)
{
SwapChain* pSwapChain = pDesc->pSwapChain;
ASSERT(pQueue);
if (waitSemaphoreCount > 0)
{
ASSERT(ppWaitSemaphores);
}
ASSERT(VK_NULL_HANDLE != pQueue->pVkQueue);
VkSemaphore* wait_semaphores = waitSemaphoreCount ? (VkSemaphore*)alloca(waitSemaphoreCount * sizeof(VkSemaphore)) : NULL;
waitSemaphoreCount = waitSemaphoreCount > MAX_PRESENT_WAIT_SEMAPHORES ? MAX_PRESENT_WAIT_SEMAPHORES : waitSemaphoreCount;
uint32_t waitCount = 0;
for (uint32_t i = 0; i < waitSemaphoreCount; ++i)
{
if (ppWaitSemaphores[i]->mSignaled)
{
wait_semaphores[waitCount] = ppWaitSemaphores[i]->pVkSemaphore;
ppWaitSemaphores[i]->mSignaled = false;
++waitCount;
}
}
uint32_t presentIndex = pDesc->mIndex;
DECLARE_ZERO(VkPresentInfoKHR, present_info);
present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
present_info.pNext = NULL;
present_info.waitSemaphoreCount = waitCount;
present_info.pWaitSemaphores = wait_semaphores;
present_info.swapchainCount = 1;
present_info.pSwapchains = &(pSwapChain->pSwapChain);
present_info.pImageIndices = &(presentIndex);
present_info.pResults = NULL;
VkResult vk_res = vkQueuePresentKHR(pSwapChain->pPresentQueue ? pSwapChain->pPresentQueue : pQueue->pVkQueue, &present_info);
if (vk_res == VK_ERROR_OUT_OF_DATE_KHR)
{
// TODO : Fix bug where we get this error if window is closed before able to present queue.
}
else
{
ASSERT(VK_SUCCESS == vk_res);
}
}
}
void waitForFences(Renderer* pRenderer, uint32_t fenceCount, Fence** ppFences)
{
ASSERT(pRenderer);
ASSERT(fenceCount);
ASSERT(ppFences);
VkFence* fences = (VkFence*)alloca(fenceCount * sizeof(VkFence));
uint32_t numValidFences = 0;
for (uint32_t i = 0; i < fenceCount; ++i)
{
if (ppFences[i]->mSubmitted)
fences[numValidFences++] = ppFences[i]->pVkFence;
}
if (numValidFences)
{
vkWaitForFences(pRenderer->pVkDevice, numValidFences, fences, VK_TRUE, UINT64_MAX);
vkResetFences(pRenderer->pVkDevice, numValidFences, fences);
}
for (uint32_t i = 0; i < fenceCount; ++i)
ppFences[i]->mSubmitted = false;
}
void waitQueueIdle(Queue* pQueue)
{
vkQueueWaitIdle(pQueue->pVkQueue);
}
void getFenceStatus(Renderer* pRenderer, Fence* pFence, FenceStatus* pFenceStatus)
{
*pFenceStatus = FENCE_STATUS_COMPLETE;
if (pFence->mSubmitted)
{
VkResult vkRes = vkGetFenceStatus(pRenderer->pVkDevice, pFence->pVkFence);
if (vkRes == VK_SUCCESS)
{
vkResetFences(pRenderer->pVkDevice, 1, &pFence->pVkFence);
pFence->mSubmitted = false;
}
*pFenceStatus = vkRes == VK_SUCCESS ? FENCE_STATUS_COMPLETE : FENCE_STATUS_INCOMPLETE;
}
else
{
*pFenceStatus = FENCE_STATUS_NOTSUBMITTED;
}
}
/************************************************************************/
// Utility functions
/************************************************************************/
TinyImageFormat getRecommendedSwapchainFormat(bool hintHDR)
{
//TODO: figure out this properly. BGRA not supported on android
#if !defined(VK_USE_PLATFORM_ANDROID_KHR) && !defined(VK_USE_PLATFORM_VI_NN)
return TinyImageFormat_B8G8R8A8_UNORM;
#else
return TinyImageFormat_R8G8B8A8_UNORM;
#endif
}
/************************************************************************/
// Indirect draw functions
/************************************************************************/
void addIndirectCommandSignature(Renderer* pRenderer, const CommandSignatureDesc* pDesc, CommandSignature** ppCommandSignature)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppCommandSignature);
CommandSignature* pCommandSignature = (CommandSignature*)conf_calloc(1, sizeof(CommandSignature));
ASSERT(pCommandSignature);
for (uint32_t i = 0; i < pDesc->mIndirectArgCount; ++i) // counting for all types;
{
switch (pDesc->pArgDescs[i].mType)
{
case INDIRECT_DRAW:
pCommandSignature->mDrawType = INDIRECT_DRAW;
pCommandSignature->mStride += sizeof(IndirectDrawArguments);
break;
case INDIRECT_DRAW_INDEX:
pCommandSignature->mDrawType = INDIRECT_DRAW_INDEX;
pCommandSignature->mStride += sizeof(IndirectDrawIndexArguments);
break;
case INDIRECT_DISPATCH:
pCommandSignature->mDrawType = INDIRECT_DISPATCH;
pCommandSignature->mStride += sizeof(IndirectDispatchArguments);
break;
default: LOGF(LogLevel::eERROR, "Vulkan runtime only supports IndirectDraw, IndirectDrawIndex and IndirectDispatch at this point"); break;
}
}
pCommandSignature->mStride = round_up(pCommandSignature->mStride, 16);
*ppCommandSignature = pCommandSignature;
}
void removeIndirectCommandSignature(Renderer* pRenderer, CommandSignature* pCommandSignature)
{
pCommandSignature->mStride = 0;
SAFE_FREE(pCommandSignature);
}
void cmdExecuteIndirect(
Cmd* pCmd, CommandSignature* pCommandSignature, uint maxCommandCount, Buffer* pIndirectBuffer, uint64_t bufferOffset,
Buffer* pCounterBuffer, uint64_t counterBufferOffset)
{
if (pCommandSignature->mDrawType == INDIRECT_DRAW)
{
#ifndef NX64
if (pCounterBuffer && pfnVkCmdDrawIndirectCountKHR)
pfnVkCmdDrawIndirectCountKHR(
pCmd->pVkCmdBuf, pIndirectBuffer->pVkBuffer, bufferOffset, pCounterBuffer->pVkBuffer, counterBufferOffset, maxCommandCount,
pCommandSignature->mStride);
else
#endif
vkCmdDrawIndirect(
pCmd->pVkCmdBuf, pIndirectBuffer->pVkBuffer, bufferOffset, maxCommandCount, pCommandSignature->mStride);
}
else if (pCommandSignature->mDrawType == INDIRECT_DRAW_INDEX)
{
#ifndef NX64
if (pCounterBuffer && pfnVkCmdDrawIndexedIndirectCountKHR)
pfnVkCmdDrawIndexedIndirectCountKHR(
pCmd->pVkCmdBuf, pIndirectBuffer->pVkBuffer, bufferOffset, pCounterBuffer->pVkBuffer, counterBufferOffset, maxCommandCount,
pCommandSignature->mStride);
else
#endif
vkCmdDrawIndexedIndirect(
pCmd->pVkCmdBuf, pIndirectBuffer->pVkBuffer, bufferOffset, maxCommandCount, pCommandSignature->mStride);
}
else if (pCommandSignature->mDrawType == INDIRECT_DISPATCH)
{
vkCmdDispatchIndirect(pCmd->pVkCmdBuf, pIndirectBuffer->pVkBuffer, bufferOffset);
}
}
/************************************************************************/
// Query Heap Implementation
/************************************************************************/
VkQueryType util_to_vk_query_type(QueryType type)
{
switch (type)
{
case QUERY_TYPE_TIMESTAMP: return VK_QUERY_TYPE_TIMESTAMP;
case QUERY_TYPE_PIPELINE_STATISTICS: return VK_QUERY_TYPE_PIPELINE_STATISTICS;
case QUERY_TYPE_OCCLUSION: return VK_QUERY_TYPE_OCCLUSION;
default: ASSERT(false && "Invalid query heap type"); return VK_QUERY_TYPE_MAX_ENUM;
}
}
void getTimestampFrequency(Queue* pQueue, double* pFrequency)
{
ASSERT(pQueue);
ASSERT(pFrequency);
// The framework is using ticks per sec as frequency. Vulkan is nano sec per tick.
// Handle the conversion logic here.
*pFrequency = 1.0f / ((double)pQueue->mTimestampPeriod /*ns/tick number of nanoseconds required for a timestamp query to be incremented by 1*/
* 1e-9); // convert to ticks/sec (DX12 standard)
}
void addQueryPool(Renderer* pRenderer, const QueryPoolDesc* pDesc, QueryPool** ppQueryPool)
{
ASSERT(pRenderer);
ASSERT(pDesc);
ASSERT(ppQueryPool);
QueryPool* pQueryPool = (QueryPool*)conf_calloc(1, sizeof(QueryPool));
ASSERT(ppQueryPool);
pQueryPool->mType = util_to_vk_query_type(pDesc->mType);
pQueryPool->mCount = pDesc->mQueryCount;
VkQueryPoolCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
createInfo.pNext = NULL;
createInfo.queryCount = pDesc->mQueryCount;
createInfo.queryType = util_to_vk_query_type(pDesc->mType);
createInfo.flags = 0;
createInfo.pipelineStatistics = 0;
vkCreateQueryPool(pRenderer->pVkDevice, &createInfo, NULL, &pQueryPool->pVkQueryPool);
*ppQueryPool = pQueryPool;
}
void removeQueryPool(Renderer* pRenderer, QueryPool* pQueryPool)
{
ASSERT(pRenderer);
ASSERT(pQueryPool);
vkDestroyQueryPool(pRenderer->pVkDevice, pQueryPool->pVkQueryPool, NULL);
SAFE_FREE(pQueryPool);
}
void cmdResetQueryPool(Cmd* pCmd, QueryPool* pQueryPool, uint32_t startQuery, uint32_t queryCount)
{
vkCmdResetQueryPool(pCmd->pVkCmdBuf, pQueryPool->pVkQueryPool, startQuery, queryCount);
}
void cmdBeginQuery(Cmd* pCmd, QueryPool* pQueryPool, QueryDesc* pQuery)
{
VkQueryType type = pQueryPool->mType;
switch (type)
{
case VK_QUERY_TYPE_TIMESTAMP:
vkCmdWriteTimestamp(pCmd->pVkCmdBuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, pQueryPool->pVkQueryPool, pQuery->mIndex);
break;
case VK_QUERY_TYPE_PIPELINE_STATISTICS: break;
case VK_QUERY_TYPE_OCCLUSION: break;
default: break;
}
}
void cmdEndQuery(Cmd* pCmd, QueryPool* pQueryPool, QueryDesc* pQuery)
{
VkQueryType type = pQueryPool->mType;
switch (type)
{
case VK_QUERY_TYPE_TIMESTAMP:
vkCmdWriteTimestamp(pCmd->pVkCmdBuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, pQueryPool->pVkQueryPool, pQuery->mIndex);
break;
case VK_QUERY_TYPE_PIPELINE_STATISTICS: break;
case VK_QUERY_TYPE_OCCLUSION: break;
default: break;
}
}
void cmdResolveQuery(Cmd* pCmd, QueryPool* pQueryPool, Buffer* pReadbackBuffer, uint32_t startQuery, uint32_t queryCount)
{
vkCmdCopyQueryPoolResults(
pCmd->pVkCmdBuf, pQueryPool->pVkQueryPool, startQuery, queryCount, pReadbackBuffer->pVkBuffer, 0, sizeof(uint64_t),
VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
}
/************************************************************************/
// Memory Stats Implementation
/************************************************************************/
void calculateMemoryStats(Renderer* pRenderer, char** stats) { vmaBuildStatsString(pRenderer->pVmaAllocator, stats, 0); }
void freeMemoryStats(Renderer* pRenderer, char* stats) { vmaFreeStatsString(pRenderer->pVmaAllocator, stats); }
/************************************************************************/
// Debug Marker Implementation
/************************************************************************/
void cmdBeginDebugMarker(Cmd* pCmd, float r, float g, float b, const char* pName)
{
if (gDebugMarkerSupport)
{
#ifdef USE_DEBUG_UTILS_EXTENSION
VkDebugUtilsLabelEXT markerInfo = {};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
markerInfo.color[0] = r;
markerInfo.color[1] = g;
markerInfo.color[2] = b;
markerInfo.color[3] = 1.0f;
markerInfo.pLabelName = pName;
vkCmdBeginDebugUtilsLabelEXT(pCmd->pVkCmdBuf, &markerInfo);
#elif !defined(NX64) || !defined(USE_RENDER_DOC)
VkDebugMarkerMarkerInfoEXT markerInfo = {};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
markerInfo.color[0] = r;
markerInfo.color[1] = g;
markerInfo.color[2] = b;
markerInfo.color[3] = 1.0f;
markerInfo.pMarkerName = pName;
vkCmdDebugMarkerBeginEXT(pCmd->pVkCmdBuf, &markerInfo);
#endif
}
}
void cmdEndDebugMarker(Cmd* pCmd)
{
if (gDebugMarkerSupport)
{
#ifdef USE_DEBUG_UTILS_EXTENSION
vkCmdEndDebugUtilsLabelEXT(pCmd->pVkCmdBuf);
#elif !defined(NX64) || !defined(USE_RENDER_DOC)
vkCmdDebugMarkerEndEXT(pCmd->pVkCmdBuf);
#endif
}
}
void cmdAddDebugMarker(Cmd* pCmd, float r, float g, float b, const char* pName)
{
if (gDebugMarkerSupport)
{
#ifdef USE_DEBUG_UTILS_EXTENSION
VkDebugUtilsLabelEXT markerInfo = {};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
markerInfo.color[0] = r;
markerInfo.color[1] = g;
markerInfo.color[2] = b;
markerInfo.color[3] = 1.0f;
markerInfo.pLabelName = pName;
vkCmdInsertDebugUtilsLabelEXT(pCmd->pVkCmdBuf, &markerInfo);
#else
VkDebugMarkerMarkerInfoEXT markerInfo = {};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
markerInfo.color[0] = r;
markerInfo.color[1] = g;
markerInfo.color[2] = b;
markerInfo.color[3] = 1.0f;
markerInfo.pMarkerName = pName;
vkCmdDebugMarkerInsertEXT(pCmd->pVkCmdBuf, &markerInfo);
#endif
}
}
/************************************************************************/
// Resource Debug Naming Interface
/************************************************************************/
void setBufferName(Renderer* pRenderer, Buffer* pBuffer, const char* pName)
{
ASSERT(pRenderer);
ASSERT(pBuffer);
ASSERT(pName);
if (gDebugMarkerSupport)
{
#ifdef USE_DEBUG_UTILS_EXTENSION
VkDebugUtilsObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_OBJECT_TYPE_BUFFER;
nameInfo.objectHandle = (uint64_t)pBuffer->pVkBuffer;
nameInfo.pObjectName = pName;
vkSetDebugUtilsObjectNameEXT(pRenderer->pVkDevice, &nameInfo);
#else
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT;
nameInfo.object = (uint64_t)pBuffer->pVkBuffer;
nameInfo.pObjectName = pName;
vkDebugMarkerSetObjectNameEXT(pRenderer->pVkDevice, &nameInfo);
#endif
}
}
void setTextureName(Renderer* pRenderer, Texture* pTexture, const char* pName)
{
ASSERT(pRenderer);
ASSERT(pTexture);
ASSERT(pName);
if (gDebugMarkerSupport)
{
#ifdef USE_DEBUG_UTILS_EXTENSION
VkDebugUtilsObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
nameInfo.objectHandle = (uint64_t)pTexture->pVkImage;
nameInfo.pObjectName = pName;
vkSetDebugUtilsObjectNameEXT(pRenderer->pVkDevice, &nameInfo);
#else
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT;
nameInfo.object = (uint64_t)pTexture->pVkImage;
nameInfo.pObjectName = pName;
vkDebugMarkerSetObjectNameEXT(pRenderer->pVkDevice, &nameInfo);
#endif
}
}
uint32_t getMemoryType(uint32_t typeBits, VkPhysicalDeviceMemoryProperties memoryProperties, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr)
{
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++)
{
if ((typeBits & 1) == 1)
{
if ((memoryProperties.memoryTypes[i].propertyFlags & properties) == properties)
{
if (memTypeFound)
{
*memTypeFound = true;
}
return i;
}
}
typeBits >>= 1;
}
if (memTypeFound)
{
*memTypeFound = false;
return 0;
}
else
{
LOGF(LogLevel::eERROR, "Could not find a matching memory type");
ASSERT(0);
return 0;
}
}
/************************************************************************/
// Virtual Texture
/************************************************************************/
void alignedDivision(const VkExtent3D& extent, const VkExtent3D& granularity, VkExtent3D* out)
{
out->width = (extent.width / granularity.width + ((extent.width % granularity.width) ? 1u : 0u));
out->height = (extent.height / granularity.height + ((extent.height % granularity.height) ? 1u : 0u));
out->depth = (extent.depth / granularity.depth + ((extent.depth % granularity.depth) ? 1u : 0u));
}
// Allocate Vulkan memory for the virtual page
bool allocateVirtualPage(Renderer* pRenderer, Texture* pTexture, VirtualTexturePage &virtualPage, uint32_t memoryTypeIndex)
{
if (virtualPage.imageMemoryBind.memory != VK_NULL_HANDLE)
{
//already filled
return false;
};
BufferDesc desc = {};
desc.mDescriptors = DESCRIPTOR_TYPE_RW_BUFFER;
desc.mMemoryUsage = RESOURCE_MEMORY_USAGE_CPU_TO_GPU;
desc.mFlags = BUFFER_CREATION_FLAG_PERSISTENT_MAP_BIT;
desc.mFirstElement = 0;
desc.mElementCount = pTexture->pSvt->mSparseVirtualTexturePageWidth * pTexture->pSvt->mSparseVirtualTexturePageHeight;
desc.mStructStride = sizeof(uint32_t);
desc.mSize = desc.mElementCount * desc.mStructStride;
addBuffer(pRenderer, &desc, &virtualPage.pIntermediateBuffer);
virtualPage.imageMemoryBind = {};
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = virtualPage.size;
allocInfo.memoryTypeIndex = memoryTypeIndex;
VkResult vk_res = (VkResult)vkAllocateMemory(pRenderer->pVkDevice, &allocInfo, nullptr, &virtualPage.imageMemoryBind.memory);
assert(vk_res == VK_SUCCESS);
VkImageSubresource subResource{};
subResource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
subResource.mipLevel = virtualPage.mipLevel;
subResource.arrayLayer = virtualPage.layer;
// Sparse image memory binding
virtualPage.imageMemoryBind.subresource = subResource;
virtualPage.imageMemoryBind.extent = virtualPage.extent;
virtualPage.imageMemoryBind.offset = virtualPage.offset;
return true;
}
// Release Vulkan memory allocated for this page
void releaseVirtualPage(Renderer* pRenderer, VirtualTexturePage &virtualPage, bool removeMemoryBind)
{
//TODO: This should be also removed
if (removeMemoryBind && virtualPage.imageMemoryBind.memory != VK_NULL_HANDLE)
{
vkFreeMemory(pRenderer->pVkDevice, virtualPage.imageMemoryBind.memory, nullptr);
virtualPage.imageMemoryBind.memory = VK_NULL_HANDLE;
}
if (virtualPage.pIntermediateBuffer)
{
removeBuffer(pRenderer, virtualPage.pIntermediateBuffer);
virtualPage.pIntermediateBuffer = NULL;
}
}
VirtualTexturePage* addPage(Renderer* pRenderer, Texture* pTexture, VkOffset3D offset, VkExtent3D extent, const VkDeviceSize size, const uint32_t mipLevel, uint32_t layer)
{
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages;
VirtualTexturePage newPage = {};
newPage.offset = offset;
newPage.extent = extent;
newPage.size = size;
newPage.mipLevel = mipLevel;
newPage.layer = layer;
newPage.index = static_cast<uint32_t>(pPageTable->size());
pPageTable->push_back(newPage);
return &pPageTable->back();
}
// Call before sparse binding to update memory bind list etc.
void updateSparseBindInfo(Texture* pTexture, Queue* pQueue)
{
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages;
eastl::vector<VkSparseImageMemoryBind>* pImageMemory = (eastl::vector<VkSparseImageMemoryBind>*)pTexture->pSvt->pSparseImageMemoryBinds;
eastl::vector<VkSparseMemoryBind>* pOpaqueMemoryBinds = (eastl::vector<VkSparseMemoryBind>*)pTexture->pSvt->pOpaqueMemoryBinds;
// Update list of memory-backed sparse image memory binds
pImageMemory->resize(pPageTable->size());
uint32_t index = 0;
for (int i = 0; i < (int)pPageTable->size(); i++)
{
(*pImageMemory)[index] = (*pPageTable)[i].imageMemoryBind;
index++;
}
// Update sparse bind info
pTexture->pSvt->mBindSparseInfo = {};
pTexture->pSvt->mBindSparseInfo.sType = VK_STRUCTURE_TYPE_BIND_SPARSE_INFO;
// Image memory binds
pTexture->pSvt->mImageMemoryBindInfo = {};
pTexture->pSvt->mImageMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mImageMemoryBindInfo.bindCount = static_cast<uint32_t>(pImageMemory->size());
pTexture->pSvt->mImageMemoryBindInfo.pBinds = pImageMemory->data();
pTexture->pSvt->mBindSparseInfo.imageBindCount = (pTexture->pSvt->mImageMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageBinds = &pTexture->pSvt->mImageMemoryBindInfo;
// Opaque image memory binds (mip tail)
pTexture->pSvt->mOpaqueMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount = static_cast<uint32_t>(pOpaqueMemoryBinds->size());
pTexture->pSvt->mOpaqueMemoryBindInfo.pBinds = pOpaqueMemoryBinds->data();
pTexture->pSvt->mBindSparseInfo.imageOpaqueBindCount = (pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageOpaqueBinds = &pTexture->pSvt->mOpaqueMemoryBindInfo;
}
struct PageCounts
{
uint mAlivePageCount;
uint mRemovePageCount;
};
void releasePage(Cmd* pCmd, Texture* pTexture)
{
Renderer* pRenderer = pCmd->pRenderer;
vkDeviceWaitIdle(pRenderer->pVkDevice);
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages;
uint removePageCount = ((const PageCounts*)pTexture->pSvt->mPageCounts->pCpuMappedAddress)->mRemovePageCount;
if (removePageCount == 0)
return;
eastl::vector<uint32_t> RemovePageTable;
RemovePageTable.resize(removePageCount);
memcpy(RemovePageTable.data(), pTexture->pSvt->mRemovePage->pCpuMappedAddress, sizeof(uint));
for (int i = 0; i < (int)removePageCount; ++i)
{
uint32_t RemoveIndex = RemovePageTable[i];
releaseVirtualPage(pRenderer, (*pPageTable)[RemoveIndex], false);
}
}
// Fill a complete mip level
// Need to get visibility info first then fill them
void fillVirtualTexture(Cmd* pCmd, Texture* pTexture, Fence* pFence)
{
Renderer* pRenderer = pCmd->pRenderer;
TextureBarrier barriers[] = {
{ pTexture, RESOURCE_STATE_COPY_DEST }
};
cmdResourceBarrier(pCmd, 0, NULL, 1, barriers, 0, NULL);
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages;
eastl::vector<VkSparseImageMemoryBind>* pImageMemory = (eastl::vector<VkSparseImageMemoryBind>*)pTexture->pSvt->pSparseImageMemoryBinds;
eastl::vector<VkSparseMemoryBind>* pOpaqueMemoryBinds = (eastl::vector<VkSparseMemoryBind>*)pTexture->pSvt->pOpaqueMemoryBinds;
pImageMemory->set_capacity(0);
uint alivePageCount = ((const PageCounts*)pTexture->pSvt->mPageCounts->pCpuMappedAddress)->mAlivePageCount;
eastl::vector<uint> VisibilityData;
VisibilityData.resize(alivePageCount);
memcpy(VisibilityData.data(), pTexture->pSvt->mAlivePage->pCpuMappedAddress, VisibilityData.size() * sizeof(uint));
for (int i = 0; i < (int)VisibilityData.size(); ++i)
{
uint pageIndex = VisibilityData[i];
VirtualTexturePage* pPage = &(*pPageTable)[pageIndex];
if (allocateVirtualPage(pRenderer, pTexture, *pPage, pTexture->pSvt->mSparseMemoryTypeIndex))
{
void* pData = (void*)((unsigned char*)pTexture->pSvt->mVirtualImageData + (pageIndex * pPage->size));
memcpy(pPage->pIntermediateBuffer->pCpuMappedAddress, pData, pPage->size);
//Copy image to VkImage
VkBufferImageCopy region = {};
region.bufferOffset = 0;
region.bufferRowLength = 0;
region.bufferImageHeight = 0;
region.imageSubresource.mipLevel = pPage->mipLevel;
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.baseArrayLayer = 0;
region.imageSubresource.layerCount = 1;
region.imageOffset = { pPage->offset.x, pPage->offset.y, 0 };
region.imageExtent = { (uint32_t)pTexture->pSvt->mSparseVirtualTexturePageWidth, (uint32_t)pTexture->pSvt->mSparseVirtualTexturePageHeight, 1 };
vkCmdCopyBufferToImage(
pCmd->pVkCmdBuf,
pPage->pIntermediateBuffer->pVkBuffer,
pTexture->pVkImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1,
®ion);
// Update list of memory-backed sparse image memory binds
pImageMemory->push_back(pPage->imageMemoryBind);
}
}
// Update sparse bind info
if (pImageMemory->size() > 0)
{
pTexture->pSvt->mBindSparseInfo = {};
pTexture->pSvt->mBindSparseInfo.sType = VK_STRUCTURE_TYPE_BIND_SPARSE_INFO;
// Image memory binds
pTexture->pSvt->mImageMemoryBindInfo = {};
pTexture->pSvt->mImageMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mImageMemoryBindInfo.bindCount = static_cast<uint32_t>(pImageMemory->size());
pTexture->pSvt->mImageMemoryBindInfo.pBinds = pImageMemory->data();
pTexture->pSvt->mBindSparseInfo.imageBindCount = (pTexture->pSvt->mImageMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageBinds = &pTexture->pSvt->mImageMemoryBindInfo;
// Opaque image memory binds (mip tail)
pTexture->pSvt->mOpaqueMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount = static_cast<uint32_t>(pOpaqueMemoryBinds->size());
pTexture->pSvt->mOpaqueMemoryBindInfo.pBinds = pOpaqueMemoryBinds->data();
pTexture->pSvt->mBindSparseInfo.imageOpaqueBindCount = (pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageOpaqueBinds = &pTexture->pSvt->mOpaqueMemoryBindInfo;
VkResult vk_res = vkQueueBindSparse(pCmd->pQueue->pVkQueue, (uint32_t)1, &pTexture->pSvt->mBindSparseInfo, VK_NULL_HANDLE);
ASSERT(VK_SUCCESS == vk_res);
}
}
// Fill specific mipLevel
void fillVirtualTextureLevel(Cmd* pCmd, Texture* pTexture, uint32_t mipLevel)
{
Renderer* pRenderer = pCmd->pRenderer;
vkDeviceWaitIdle(pRenderer->pVkDevice);
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages;
//Bind data
eastl::vector<VkSparseImageMemoryBind>* pImageMemory = (eastl::vector<VkSparseImageMemoryBind>*)pTexture->pSvt->pSparseImageMemoryBinds;
eastl::vector<VkSparseMemoryBind>* pOpaqueMemoryBinds = (eastl::vector<VkSparseMemoryBind>*)pTexture->pSvt->pOpaqueMemoryBinds;
for (int i = 0; i < (int)pTexture->pSvt->mVirtualPageTotalCount; i++)
{
VirtualTexturePage* pPage = &(*pPageTable)[i];
uint32_t pageIndex = pPage->index;
if ((pPage->mipLevel == mipLevel) && (pPage->imageMemoryBind.memory == VK_NULL_HANDLE))
{
if (allocateVirtualPage(pRenderer, pTexture, *pPage, pTexture->pSvt->mSparseMemoryTypeIndex))
{
void* pData = (void*)((unsigned char*)pTexture->pSvt->mVirtualImageData + (pageIndex * (uint32_t)pPage->size));
//CPU to GPU
memcpy(pPage->pIntermediateBuffer->pCpuMappedAddress, pData, pPage->size);
//Copy image to VkImage
VkBufferImageCopy region = {};
region.bufferOffset = 0;
region.bufferRowLength = 0;
region.bufferImageHeight = 0;
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.mipLevel = mipLevel;
region.imageSubresource.baseArrayLayer = 0;
region.imageSubresource.layerCount = 1;
region.imageOffset = { pPage->offset.x, pPage->offset.y, 0 };
region.imageExtent = { (uint32_t)pTexture->pSvt->mSparseVirtualTexturePageWidth, (uint32_t)pTexture->pSvt->mSparseVirtualTexturePageHeight, 1 };
vkCmdCopyBufferToImage(
pCmd->pVkCmdBuf,
pPage->pIntermediateBuffer->pVkBuffer,
pTexture->pVkImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1,
®ion);
}
// Update list of memory-backed sparse image memory binds
pImageMemory->push_back(pPage->imageMemoryBind);
}
}
// Update sparse bind info
{
pTexture->pSvt->mBindSparseInfo = {};
pTexture->pSvt->mBindSparseInfo.sType = VK_STRUCTURE_TYPE_BIND_SPARSE_INFO;
// Image memory binds
pTexture->pSvt->mImageMemoryBindInfo = {};
pTexture->pSvt->mImageMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mImageMemoryBindInfo.bindCount = static_cast<uint32_t>(pImageMemory->size());
pTexture->pSvt->mImageMemoryBindInfo.pBinds = pImageMemory->data();
pTexture->pSvt->mBindSparseInfo.imageBindCount = (pTexture->pSvt->mImageMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageBinds = &pTexture->pSvt->mImageMemoryBindInfo;
// Opaque image memory binds (mip tail)
pTexture->pSvt->mOpaqueMemoryBindInfo.image = pTexture->pVkImage;
pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount = static_cast<uint32_t>(pOpaqueMemoryBinds->size());
pTexture->pSvt->mOpaqueMemoryBindInfo.pBinds = pOpaqueMemoryBinds->data();
pTexture->pSvt->mBindSparseInfo.imageOpaqueBindCount = (pTexture->pSvt->mOpaqueMemoryBindInfo.bindCount > 0) ? 1 : 0;
pTexture->pSvt->mBindSparseInfo.pImageOpaqueBinds = &pTexture->pSvt->mOpaqueMemoryBindInfo;
VkResult vk_res = vkQueueBindSparse(pCmd->pQueue->pVkQueue, (uint32_t)1, &pTexture->pSvt->mBindSparseInfo, VK_NULL_HANDLE);
ASSERT(VK_SUCCESS == vk_res);
}
}
void addVirtualTexture(Renderer * pRenderer, const TextureDesc * pDesc, Texture** ppTexture, void* pImageData)
{
ASSERT(pRenderer);
Texture* pTexture = (Texture*)conf_calloc(1, sizeof(*pTexture) + sizeof(VirtualTexture));
ASSERT(pTexture);
pTexture->pSvt = (VirtualTexture*)(pTexture + 1);
uint32_t imageSize = 0;
uint32_t mipSize = pDesc->mWidth * pDesc->mHeight * pDesc->mDepth;
while (mipSize > 0)
{
imageSize += mipSize;
mipSize /= 4;
}
pTexture->pSvt->mVirtualImageData = (char*)conf_malloc(imageSize * sizeof(uint32_t));
memcpy(pTexture->pSvt->mVirtualImageData, pImageData, imageSize * sizeof(uint32_t));
// Create command buffer to transition resources to the correct state
Queue* graphicsQueue = NULL;
CmdPool* cmdPool = NULL;
Cmd* cmd = NULL;
QueueDesc queueDesc = {};
queueDesc.mType = QUEUE_TYPE_GRAPHICS;
addQueue(pRenderer, &queueDesc, &graphicsQueue);
CmdPoolDesc cmdPoolDesc = {};
cmdPoolDesc.pQueue = graphicsQueue;
cmdPoolDesc.mTransient = true;
addCmdPool(pRenderer, &cmdPoolDesc, &cmdPool);
CmdDesc cmdDesc = {};
cmdDesc.pPool = cmdPool;
addCmd(pRenderer, &cmdDesc, &cmd);
// Transition resources
beginCmd(cmd);
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
pTexture->mOwnsImage = true;
VkImageCreateInfo add_info = {};
add_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
add_info.flags = VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
add_info.imageType = VK_IMAGE_TYPE_2D;
add_info.format = format;
add_info.extent.width = pDesc->mWidth;
add_info.extent.height = pDesc->mHeight;
add_info.extent.depth = pDesc->mDepth;
add_info.mipLevels = pDesc->mMipLevels;
add_info.arrayLayers = 1;
add_info.samples = VK_SAMPLE_COUNT_1_BIT;
add_info.tiling = VK_IMAGE_TILING_OPTIMAL;
add_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
add_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
add_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
VkResult vk_res = (VkResult)vkCreateImage(pRenderer->pVkDevice, &add_info, nullptr, &pTexture->pVkImage);
assert(vk_res == VK_SUCCESS);
// Get memory requirements
VkMemoryRequirements sparseImageMemoryReqs;
// Sparse image memory requirement counts
vkGetImageMemoryRequirements(pRenderer->pVkDevice, pTexture->pVkImage, &sparseImageMemoryReqs);
// Check requested image size against hardware sparse limit
if (sparseImageMemoryReqs.size > pRenderer->pVkActiveGPUProperties->properties.limits.sparseAddressSpaceSize)
{
LOGF(LogLevel::eERROR, "Requested sparse image size exceeds supportes sparse address space size!");
return;
}
// Get sparse memory requirements
// Count
uint32_t sparseMemoryReqsCount = 32;
eastl::vector<VkSparseImageMemoryRequirements> sparseMemoryReqs(sparseMemoryReqsCount);
vkGetImageSparseMemoryRequirements(pRenderer->pVkDevice, pTexture->pVkImage, &sparseMemoryReqsCount, sparseMemoryReqs.data());
if (sparseMemoryReqsCount == 0)
{
LOGF(LogLevel::eERROR, "No memory requirements for the sparse image!");
return;
}
sparseMemoryReqs.resize(sparseMemoryReqsCount);
// Get actual requirements
vkGetImageSparseMemoryRequirements(pRenderer->pVkDevice, pTexture->pVkImage, &sparseMemoryReqsCount, sparseMemoryReqs.data());
pTexture->pSvt->mSparseVirtualTexturePageWidth = sparseMemoryReqs[0].formatProperties.imageGranularity.width;
pTexture->pSvt->mSparseVirtualTexturePageHeight = sparseMemoryReqs[0].formatProperties.imageGranularity.height;
pTexture->pSvt->mVirtualPageTotalCount = imageSize / (uint32_t)(pTexture->pSvt->mSparseVirtualTexturePageWidth * pTexture->pSvt->mSparseVirtualTexturePageHeight);
uint32_t TiledMiplevel = pDesc->mMipLevels - (uint32_t)log2(min((uint32_t)pTexture->pSvt->mSparseVirtualTexturePageWidth, (uint32_t)pTexture->pSvt->mSparseVirtualTexturePageHeight));
LOGF(LogLevel::eINFO, "Sparse image memory requirements: %d", sparseMemoryReqsCount);
for (int i = 0; i < (int)sparseMemoryReqs.size(); ++i)
{
VkSparseImageMemoryRequirements reqs = sparseMemoryReqs[i];
//todo:multiple reqs
pTexture->pSvt->mMipTailStart = reqs.imageMipTailFirstLod;
}
pTexture->pSvt->mLastFilledMip = pTexture->pSvt->mMipTailStart - 1;
// Get sparse image requirements for the color aspect
VkSparseImageMemoryRequirements sparseMemoryReq;
bool colorAspectFound = false;
for (int i = 0; i < (int)sparseMemoryReqs.size(); ++i)
{
VkSparseImageMemoryRequirements reqs = sparseMemoryReqs[i];
if (reqs.formatProperties.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT)
{
sparseMemoryReq = reqs;
colorAspectFound = true;
break;
}
}
if (!colorAspectFound)
{
LOGF(LogLevel::eERROR, "Could not find sparse image memory requirements for color aspect bit!");
return;
}
VkPhysicalDeviceMemoryProperties memProps = {};
vkGetPhysicalDeviceMemoryProperties(pRenderer->pVkActiveGPU, &memProps);
// todo:
// Calculate number of required sparse memory bindings by alignment
assert((sparseImageMemoryReqs.size % sparseImageMemoryReqs.alignment) == 0);
pTexture->pSvt->mSparseMemoryTypeIndex = getMemoryType(sparseImageMemoryReqs.memoryTypeBits, memProps, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
// Get sparse bindings
uint32_t sparseBindsCount = static_cast<uint32_t>(sparseImageMemoryReqs.size / sparseImageMemoryReqs.alignment);
eastl::vector<VkSparseMemoryBind> sparseMemoryBinds(sparseBindsCount);
// Check if the format has a single mip tail for all layers or one mip tail for each layer
// The mip tail contains all mip levels > sparseMemoryReq.imageMipTailFirstLod
bool singleMipTail = sparseMemoryReq.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT;
pTexture->pSvt->pPages = (eastl::vector<VirtualTexturePage>*)conf_calloc(1, sizeof(eastl::vector<VirtualTexturePage>));
pTexture->pSvt->pSparseImageMemoryBinds = (eastl::vector<VkSparseImageMemoryBind>*)conf_calloc(1, sizeof(eastl::vector<VkSparseImageMemoryBind>));
pTexture->pSvt->pOpaqueMemoryBinds = (eastl::vector<VkSparseMemoryBind>*)conf_calloc(1, sizeof(eastl::vector<VkSparseMemoryBind>));
conf_placement_new<decltype(pTexture->pSvt->pPages)>(pTexture->pSvt->pPages);
conf_placement_new<decltype(pTexture->pSvt->pSparseImageMemoryBinds)>(pTexture->pSvt->pSparseImageMemoryBinds);
conf_placement_new<decltype(pTexture->pSvt->pOpaqueMemoryBinds)>(pTexture->pSvt->pOpaqueMemoryBinds);
eastl::vector<VkSparseMemoryBind>* pOpaqueMemoryBinds = (eastl::vector<VkSparseMemoryBind>*)pTexture->pSvt->pOpaqueMemoryBinds;
// Sparse bindings for each mip level of all layers outside of the mip tail
for (uint32_t layer = 0; layer < 1; layer++)
{
// sparseMemoryReq.imageMipTailFirstLod is the first mip level that's stored inside the mip tail
for (uint32_t mipLevel = 0; mipLevel < TiledMiplevel; mipLevel++)
{
VkExtent3D extent;
extent.width = max(add_info.extent.width >> mipLevel, 1u);
extent.height = max(add_info.extent.height >> mipLevel, 1u);
extent.depth = max(add_info.extent.depth >> mipLevel, 1u);
VkImageSubresource subResource{};
subResource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
subResource.mipLevel = mipLevel;
subResource.arrayLayer = layer;
// Aligned sizes by image granularity
VkExtent3D imageGranularity = sparseMemoryReq.formatProperties.imageGranularity;
VkExtent3D sparseBindCounts = {};
VkExtent3D lastBlockExtent = {};
alignedDivision(extent, imageGranularity, &sparseBindCounts);
lastBlockExtent.width = ((extent.width % imageGranularity.width) ? extent.width % imageGranularity.width : imageGranularity.width);
lastBlockExtent.height = ((extent.height % imageGranularity.height) ? extent.height % imageGranularity.height : imageGranularity.height);
lastBlockExtent.depth = ((extent.depth % imageGranularity.depth) ? extent.depth % imageGranularity.depth : imageGranularity.depth);
// Alllocate memory for some blocks
uint32_t index = 0;
for (uint32_t z = 0; z < sparseBindCounts.depth; z++)
{
for (uint32_t y = 0; y < sparseBindCounts.height; y++)
{
for (uint32_t x = 0; x < sparseBindCounts.width; x++)
{
// Offset
VkOffset3D offset;
offset.x = x * imageGranularity.width;
offset.y = y * imageGranularity.height;
offset.z = z * imageGranularity.depth;
// Size of the page
VkExtent3D extent;
extent.width = (x == sparseBindCounts.width - 1) ? lastBlockExtent.width : imageGranularity.width;
extent.height = (y == sparseBindCounts.height - 1) ? lastBlockExtent.height : imageGranularity.height;
extent.depth = (z == sparseBindCounts.depth - 1) ? lastBlockExtent.depth : imageGranularity.depth;
// Add new virtual page
VirtualTexturePage *newPage = addPage(pRenderer, pTexture, offset, extent, pTexture->pSvt->mSparseVirtualTexturePageWidth * pTexture->pSvt->mSparseVirtualTexturePageHeight * sizeof(uint), mipLevel, layer);
newPage->imageMemoryBind.subresource = subResource;
index++;
}
}
}
}
// Check if format has one mip tail per layer
if ((!singleMipTail) && (sparseMemoryReq.imageMipTailFirstLod < pDesc->mMipLevels))
{
// Allocate memory for the mip tail
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = sparseMemoryReq.imageMipTailSize;
allocInfo.memoryTypeIndex = pTexture->pSvt->mSparseMemoryTypeIndex;
VkDeviceMemory deviceMemory;
vk_res = vkAllocateMemory(pRenderer->pVkDevice, &allocInfo, nullptr, &deviceMemory);
assert(vk_res == VK_SUCCESS);
// (Opaque) sparse memory binding
VkSparseMemoryBind sparseMemoryBind{};
sparseMemoryBind.resourceOffset = sparseMemoryReq.imageMipTailOffset + layer * sparseMemoryReq.imageMipTailStride;
sparseMemoryBind.size = sparseMemoryReq.imageMipTailSize;
sparseMemoryBind.memory = deviceMemory;
pOpaqueMemoryBinds->push_back(sparseMemoryBind);
}
} // end layers and mips
LOGF(LogLevel::eINFO, "Virtual Texture info: Dim %d x %d Pages %d", pDesc->mWidth, pDesc->mHeight, (uint32_t)(((eastl::vector<VirtualTexturePage>*)pTexture->pSvt->pPages)->size()));
// Check if format has one mip tail for all layers
if ((sparseMemoryReq.formatProperties.flags & VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT) && (sparseMemoryReq.imageMipTailFirstLod < pDesc->mMipLevels))
{
// Allocate memory for the mip tail
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = sparseMemoryReq.imageMipTailSize;
allocInfo.memoryTypeIndex = pTexture->pSvt->mSparseMemoryTypeIndex;
VkDeviceMemory deviceMemory;
vk_res = vkAllocateMemory(pRenderer->pVkDevice, &allocInfo, nullptr, &deviceMemory);
assert(vk_res == VK_SUCCESS);
// (Opaque) sparse memory binding
VkSparseMemoryBind sparseMemoryBind{};
sparseMemoryBind.resourceOffset = sparseMemoryReq.imageMipTailOffset;
sparseMemoryBind.size = sparseMemoryReq.imageMipTailSize;
sparseMemoryBind.memory = deviceMemory;
pOpaqueMemoryBinds->push_back(sparseMemoryBind);
}
pTexture->pSvt->mLastFilledMip = pTexture->pSvt->mMipTailStart - 1;
/************************************************************************/
// Create image view
/************************************************************************/
VkImageViewCreateInfo view = {};
view.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
view.image = pTexture->pVkImage;
view.viewType = VK_IMAGE_VIEW_TYPE_2D;
view.format = format;
view.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
view.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
view.subresourceRange.baseMipLevel = 0;
view.subresourceRange.baseArrayLayer = 0;
view.subresourceRange.layerCount = 1;
view.subresourceRange.levelCount = pDesc->mMipLevels;
view.image = pTexture->pVkImage;
pTexture->mAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
vk_res = vkCreateImageView(pRenderer->pVkDevice, &view, NULL, &pTexture->pVkSRVDescriptor);
ASSERT(VK_SUCCESS == vk_res);
eastl::vector<TextureBarrier> textureBarriers;
textureBarriers.push_back(TextureBarrier{ pTexture, RESOURCE_STATE_COPY_DEST });
uint32_t textureBarrierCount = (uint32_t)textureBarriers.size();
cmdResourceBarrier(cmd, 0, NULL, textureBarrierCount, textureBarriers.data(), 0, NULL);
// Fill smallest (non-tail) mip map level
fillVirtualTextureLevel(cmd, pTexture, TiledMiplevel - 1);
endCmd(cmd);
QueueSubmitDesc submitDesc = {};
submitDesc.mCmdCount = 1;
submitDesc.ppCmds = &cmd;
queueSubmit(graphicsQueue, &submitDesc);
waitQueueIdle(graphicsQueue);
// Delete command buffer
removeCmd(pRenderer, cmd);
removeCmdPool(pRenderer, cmdPool);
removeQueue(pRenderer, graphicsQueue);
pTexture->mOwnsImage = true;
pTexture->mNodeIndex = pDesc->mNodeIndex;
pTexture->mStartState = pDesc->mStartState;
pTexture->mMipLevels = pDesc->mMipLevels;
pTexture->mWidth = pDesc->mWidth;
pTexture->mHeight = pDesc->mHeight;
pTexture->mDepth = pDesc->mDepth;
pTexture->mCurrentState = RESOURCE_STATE_UNDEFINED;
*ppTexture = pTexture;
}
void removeVirtualTexture(Renderer* pRenderer, VirtualTexture* pSvt)
{
eastl::vector<VirtualTexturePage>* pPageTable = (eastl::vector<VirtualTexturePage>*)pSvt->pPages;
if (pPageTable)
{
for (int i = 0; i < (int)pPageTable->size(); i++)
{
releaseVirtualPage(pRenderer, (*pPageTable)[i], true);
}
pPageTable->set_capacity(0);
SAFE_FREE(pSvt->pPages);
}
eastl::vector<VkSparseImageMemoryBind>* pImageMemory = (eastl::vector<VkSparseImageMemoryBind>*)pSvt->pSparseImageMemoryBinds;
if (pImageMemory)
{
pImageMemory->set_capacity(0);
SAFE_FREE(pSvt->pSparseImageMemoryBinds);
}
eastl::vector<VkSparseMemoryBind>* pOpaqueMemory = (eastl::vector<VkSparseMemoryBind>*)pSvt->pOpaqueMemoryBinds;
if (pOpaqueMemory)
{
for (int i = 0; i < (int)pOpaqueMemory->size(); i++)
{
vkFreeMemory(pRenderer->pVkDevice, (*pOpaqueMemory)[i].memory, nullptr);
}
pOpaqueMemory->set_capacity(0);
SAFE_FREE(pSvt->pOpaqueMemoryBinds);
}
if (pSvt->mVisibility)
removeBuffer(pRenderer, pSvt->mVisibility);
if (pSvt->mPrevVisibility)
removeBuffer(pRenderer, pSvt->mPrevVisibility);
if (pSvt->mAlivePage)
removeBuffer(pRenderer, pSvt->mAlivePage);
if (pSvt->mRemovePage)
removeBuffer(pRenderer, pSvt->mRemovePage);
if (pSvt->mPageCounts)
removeBuffer(pRenderer, pSvt->mPageCounts);
if (pSvt->mVirtualImageData)
conf_free(pSvt->mVirtualImageData);
}
void cmdUpdateVirtualTexture(Cmd* cmd, Texture* pTexture)
{
if (pTexture->pSvt->mVisibility)
{
releasePage(cmd, pTexture);
fillVirtualTexture(cmd, pTexture, NULL);
}
}
#endif
#if defined(__cplusplus) && defined(ENABLE_RENDERER_RUNTIME_SWITCH)
} // namespace RENDERER_CPP_NAMESPACE
#endif
#if !defined(NX64)
#include "../../../Common_3/ThirdParty/OpenSource/volk/volk.c"
#if defined(VK_USE_DISPATCH_TABLES)
#include "../../../Common_3/ThirdParty/OpenSource/volk/volkForgeExt.c"
#endif
#endif
#endif
| 37.782755 | 211 | 0.740918 |
5deaed3d605ec95b365f13ceacd32f9e2856eca6 | 1,240 | h | C | qprintpreviewdialog_c.h | mariuszmaximus/qt5pas-aarch64-linux-gnu | c60bbcfa5b0d7c4fe18bb21e5f2f424a5b658c1b | [
"Apache-2.0"
] | null | null | null | qprintpreviewdialog_c.h | mariuszmaximus/qt5pas-aarch64-linux-gnu | c60bbcfa5b0d7c4fe18bb21e5f2f424a5b658c1b | [
"Apache-2.0"
] | null | null | null | qprintpreviewdialog_c.h | mariuszmaximus/qt5pas-aarch64-linux-gnu | c60bbcfa5b0d7c4fe18bb21e5f2f424a5b658c1b | [
"Apache-2.0"
] | null | null | null | //******************************************************************************
// Copyright (c) 2005-2013 by Jan Van hijfte
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QPRINTPREVIEWDIALOG_C_H
#define QPRINTPREVIEWDIALOG_C_H
#include <QtPrintSupport>
#include "pascalbind.h"
C_EXPORT QPrintPreviewDialogH QPrintPreviewDialog_Create(QWidgetH parent, unsigned int flags);
C_EXPORT void QPrintPreviewDialog_Destroy(QPrintPreviewDialogH handle);
C_EXPORT QPrintPreviewDialogH QPrintPreviewDialog_Create2(QPrinterH printer, QWidgetH parent, unsigned int flags);
C_EXPORT void QPrintPreviewDialog_open(QPrintPreviewDialogH handle, QObjectH receiver, const char* member);
C_EXPORT QPrinterH QPrintPreviewDialog_printer(QPrintPreviewDialogH handle);
C_EXPORT void QPrintPreviewDialog_setVisible(QPrintPreviewDialogH handle, bool visible);
C_EXPORT void QPrintPreviewDialog_done(QPrintPreviewDialogH handle, int result);
#endif
| 45.925926 | 114 | 0.725806 |
e7561116b9a39f1e33367a14b3d0d228a216c000 | 2,374 | js | JavaScript | Social Media Dashboard/js/index.js | varisha-025/Cool-Front-End-Templates | 723ff036d1b9179b5614456ac6bbea0c2d320ccf | [
"MIT"
] | 90 | 2021-09-12T23:11:36.000Z | 2022-03-31T23:28:01.000Z | Social Media Dashboard/js/index.js | varisha-025/Cool-Front-End-Templates | 723ff036d1b9179b5614456ac6bbea0c2d320ccf | [
"MIT"
] | 367 | 2021-10-01T04:54:35.000Z | 2022-03-31T21:09:28.000Z | Social Media Dashboard/js/index.js | varisha-025/Cool-Front-End-Templates | 723ff036d1b9179b5614456ac6bbea0c2d320ccf | [
"MIT"
] | 196 | 2021-09-30T18:03:10.000Z | 2022-03-31T23:28:06.000Z | AOS.init({
duration: 800
});
function setLightMode() {
document.getElementsByClassName("dark-theme")[0].classList.add("light-theme")
var cardBoxes = document.getElementsByClassName("card-box");
for(var i = 0; i < cardBoxes.length; i++) {
cardBoxes[i].classList.add("card-box-light");
}
var statsBoxes = document.getElementsByClassName("stats-box");
for(var i = 0; i < statsBoxes.length; i++) {
statsBoxes[i].classList.add("stats-box-light");
}
var h1 = document.querySelectorAll("h1");
for(var i = 0; i < h1.length; i++) {
h1[i].classList.add("h1-light");
}
var h3 = document.querySelectorAll("h3");
for(var i = 0; i < h3.length; i++) {
h3[i].classList.add("h3-light");
}
var h4 = document.querySelectorAll("h4");
for(var i = 0; i < h4.length; i++) {
h4[i].classList.add("h4-light");
}
var statsCounts = document.getElementsByClassName("stats-count");
for(var i = 0; i < statsCounts.length; i++) {
statsCounts[i].classList.add("stats-count-light");
}
document.getElementsByClassName("mode-box")[0].classList.add("mode-box-light");
}
function removeLightMode() {
document.getElementsByClassName("dark-theme")[0].classList.remove("light-theme")
var cardBoxes = document.getElementsByClassName("card-box");
for(var i = 0; i < cardBoxes.length; i++) {
cardBoxes[i].classList.remove("card-box-light");
}
var statsBoxes = document.getElementsByClassName("stats-box");
for(var i = 0; i < statsBoxes.length; i++) {
statsBoxes[i].classList.remove("stats-box-light");
}
var h1 = document.querySelectorAll("h1");
for(var i = 0; i < h1.length; i++) {
h1[i].classList.remove("h1-light");
}
var h3 = document.querySelectorAll("h3");
for(var i = 0; i < h3.length; i++) {
h3[i].classList.remove("h3-light");
}
var h4 = document.querySelectorAll("h4");
for(var i = 0; i < h4.length; i++) {
h4[i].classList.remove("h4-light");
}
var statsCounts = document.getElementsByClassName("stats-count");
for(var i = 0; i < statsCounts.length; i++) {
statsCounts[i].classList.remove("stats-count-light");
}
document.getElementsByClassName("mode-box")[0].classList.remove("mode-box-light");
}
var switchInput = document.getElementsByClassName("form-check-input")[0];
switchInput.addEventListener("click" , function(event) {
if(event.target.checked === true) {
removeLightMode();
} else {
setLightMode();
}
}); | 26.977273 | 83 | 0.673968 |
3bc6b4b6243efe1bfe7e30af9159a37a3e1b8ec3 | 867,317 | html | HTML | lists.whatwg.org/pipermail/commit-watchers-whatwg.org/2011/012918.html | zcorpan/whatwg.org | 3374e69f013e5939abc5f3fffaae50bb6eaf0bd3 | [
"CC-BY-4.0"
] | 1 | 2022-02-14T23:44:51.000Z | 2022-02-14T23:44:51.000Z | lists.whatwg.org/pipermail/commit-watchers-whatwg.org/2011/012918.html | Seanpm2001-Google/whatwg.org | 33ad837c0dc53b68865f4a35ccdc1c68dc07fce6 | [
"BSD-3-Clause"
] | 1 | 2021-01-31T11:51:12.000Z | 2021-01-31T11:51:12.000Z | lists.whatwg.org/pipermail/commit-watchers-whatwg.org/2011/012918.html | Seanpm2001-Google/whatwg.org | 33ad837c0dc53b68865f4a35ccdc1c68dc07fce6 | [
"BSD-3-Clause"
] | null | null | null | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [html5] r6050 - [e] (0) make ids more consistent (this might break some links, sorry) Fixing htt [...]
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:commit-watchers%40lists.whatwg.org?Subject=Re%3A%20%5Bhtml5%5D%20r6050%20-%20%5Be%5D%20%280%29%20make%20ids%20more%20consistent%20%28this%20might%20break%0A%09some%20links%2C%20sorry%29%20Fixing%20htt%20%5B...%5D&In-Reply-To=%3C20110503191857.8712011C7C007%40ps20323.dreamhostps.com%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="012916.html">
<LINK REL="Next" HREF="012917.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[html5] r6050 - [e] (0) make ids more consistent (this might break some links, sorry) Fixing htt [...]</H1>
<!--htdig_noindex-->
<B>whatwg at whatwg.org</B>
<A HREF="mailto:commit-watchers%40lists.whatwg.org?Subject=Re%3A%20%5Bhtml5%5D%20r6050%20-%20%5Be%5D%20%280%29%20make%20ids%20more%20consistent%20%28this%20might%20break%0A%09some%20links%2C%20sorry%29%20Fixing%20htt%20%5B...%5D&In-Reply-To=%3C20110503191857.8712011C7C007%40ps20323.dreamhostps.com%3E"
TITLE="[html5] r6050 - [e] (0) make ids more consistent (this might break some links, sorry) Fixing htt [...]">whatwg at whatwg.org
</A><BR>
<I>Tue May 3 12:18:57 PDT 2011</I>
<P><UL>
<LI>Previous message: <A HREF="012916.html">[html5] r6049 - [e] (0) Try to warn implementors about XSLT. Fixing http://www.w3.org/Bugs/Publi [...]
</A></li>
<LI>Next message: <A HREF="012917.html">[html5] r6051 - [e] (0) add a note to clarify interaction with rfc 2388 Fixing http://www.w3.org [...]
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#12918">[ date ]</a>
<a href="thread.html#12918">[ thread ]</a>
<a href="subject.html#12918">[ subject ]</a>
<a href="author.html#12918">[ author ]</a>
</LI>
</UL>
<HR>
<!--/htdig_noindex-->
<!--beginarticle-->
<PRE>Author: ianh
Date: 2011-05-03 12:18:56 -0700 (Tue, 03 May 2011)
New Revision: 6050
Modified:
complete.html
index
source
Log:
[e] (0) make ids more consistent (this might break some links, sorry)
Fixing <A HREF="http://www.w3.org/Bugs/Public/show_bug.cgi?id=9593">http://www.w3.org/Bugs/Public/show_bug.cgi?id=9593</A>
Modified: complete.html
===================================================================
--- complete.html 2011-05-03 01:10:20 UTC (rev 6049)
+++ complete.html 2011-05-03 19:18:56 UTC (rev 6050)
@@ -460,14 +460,14 @@
<ol>
<li><a href=#the-root-element><span class=secno>4.1 </span>The root element</a>
<ol>
- <li><a href=#the-html-element-0><span class=secno>4.1.1 </span>The <code>html</code> element</a></ol></li>
+ <li><a href=#the-html-element><span class=secno>4.1.1 </span>The <code>html</code> element</a></ol></li>
<li><a href=#document-metadata><span class=secno>4.2 </span>Document metadata</a>
<ol>
- <li><a href=#the-head-element-0><span class=secno>4.2.1 </span>The <code>head</code> element</a></li>
- <li><a href=#the-title-element-0><span class=secno>4.2.2 </span>The <code>title</code> element</a></li>
+ <li><a href=#the-head-element><span class=secno>4.2.1 </span>The <code>head</code> element</a></li>
+ <li><a href=#the-title-element><span class=secno>4.2.2 </span>The <code>title</code> element</a></li>
<li><a href=#the-base-element><span class=secno>4.2.3 </span>The <code>base</code> element</a></li>
<li><a href=#the-link-element><span class=secno>4.2.4 </span>The <code>link</code> element</a></li>
- <li><a href=#meta><span class=secno>4.2.5 </span>The <code>meta</code> element</a>
+ <li><a href=#the-meta-element><span class=secno>4.2.5 </span>The <code>meta</code> element</a>
<ol>
<li><a href=#standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</a></li>
<li><a href=#other-metadata-names><span class=secno>4.2.5.2 </span>Other metadata names</a></li>
@@ -478,7 +478,7 @@
<li><a href=#styling><span class=secno>4.2.7 </span>Styling</a></ol></li>
<li><a href=#scripting-1><span class=secno>4.3 </span>Scripting</a>
<ol>
- <li><a href=#script><span class=secno>4.3.1 </span>The <code>script</code> element</a>
+ <li><a href=#the-script-element><span class=secno>4.3.1 </span>The <code>script</code> element</a>
<ol>
<li><a href=#scriptingLanguages><span class=secno>4.3.1.1 </span>Scripting languages</a></li>
<li><a href=#restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span>Restrictions for contents of <code>script</code> elements</a></li>
@@ -492,10 +492,7 @@
<li><a href=#the-nav-element><span class=secno>4.4.3 </span>The <code>nav</code> element</a></li>
<li><a href=#the-article-element><span class=secno>4.4.4 </span>The <code>article</code> element</a></li>
<li><a href=#the-aside-element><span class=secno>4.4.5 </span>The <code>aside</code> element</a></li>
- <li><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <code>h1</code>, <code>h2</code>,
- <code>h3</code>, <code>h4</code>,
- <code>h5</code>, and <code>h6</code>
- elements</a></li>
+ <li><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code> elements</a></li>
<li><a href=#the-hgroup-element><span class=secno>4.4.7 </span>The <code>hgroup</code> element</a></li>
<li><a href=#the-header-element><span class=secno>4.4.8 </span>The <code>header</code> element</a></li>
<li><a href=#the-footer-element><span class=secno>4.4.9 </span>The <code>footer</code> element</a></li>
@@ -579,8 +576,8 @@
<li><a href=#the-embed-element><span class=secno>4.8.3 </span>The <code>embed</code> element</a></li>
<li><a href=#the-object-element><span class=secno>4.8.4 </span>The <code>object</code> element</a></li>
<li><a href=#the-param-element><span class=secno>4.8.5 </span>The <code>param</code> element</a></li>
- <li><a href=#video><span class=secno>4.8.6 </span>The <code>video</code> element</a></li>
- <li><a href=#audio><span class=secno>4.8.7 </span>The <code>audio</code> element</a></li>
+ <li><a href=#the-video-element><span class=secno>4.8.6 </span>The <code>video</code> element</a></li>
+ <li><a href=#the-audio-element><span class=secno>4.8.7 </span>The <code>audio</code> element</a></li>
<li><a href=#the-source-element><span class=secno>4.8.8 </span>The <code>source</code> element</a></li>
<li><a href=#the-track-element><span class=secno>4.8.9 </span>The <code>track</code> element</a></li>
<li><a href=#media-elements><span class=secno>4.8.10 </span>Media elements</a>
@@ -770,8 +767,8 @@
<ol>
<li><a href=#the-details-element><span class=secno>4.11.1 </span>The <code>details</code> element</a></li>
<li><a href=#the-summary-element><span class=secno>4.11.2 </span>The <code>summary</code> element</a></li>
- <li><a href=#the-command><span class=secno>4.11.3 </span>The <code>command</code> element</a></li>
- <li><a href=#menus><span class=secno>4.11.4 </span>The <code>menu</code> element</a>
+ <li><a href=#the-command-element><span class=secno>4.11.3 </span>The <code>command</code> element</a></li>
+ <li><a href=#the-menu-element><span class=secno>4.11.4 </span>The <code>menu</code> element</a>
<ol>
<li><a href=#menus-intro><span class=secno>4.11.4.1 </span>Introduction</a></li>
<li><a href=#building-menus-and-toolbars><span class=secno>4.11.4.2 </span>Building menus and toolbars</a></li>
@@ -1898,9 +1895,9 @@
<p>The <a href=#intro-early-example>markup snippet at the top of
this section</a> would be turned into the following DOM tree:</p>
- <ul class=domTree><li class=t10>DOCTYPE: <code title="">html</code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-title-element-0>title</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-p-element>p</a></code><u
l><li class=t3><code>#text</code>: <span title="">This is a </span><li class=t1><code><a href=#the-a-element>a</a></code> <span class=t2 title=""><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class=t3><code>#text</code>: <span title="">simple</span></ul><li class=t3><code>#text</code>: <span title=""> sample.</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t8><code>#comment</code>: <span title=""> this is a comment </span><li class=t3><code>#text</code>: <span title="">⏎␣⏎</span></ul></ul></ul><p>The <a href=#root-element>root element</a> of this tree is the
- <code><a href=#the-html-element-0>html</a></code> element, which is the element always found at the
- root of HTML documents. It contains two elements, <code><a href=#the-head-element-0>head</a></code>
+ <ul class=domTree><li class=t10>DOCTYPE: <code title="">html</code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-title-element>title</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li
class=t3><code>#text</code>: <span title="">This is a </span><li class=t1><code><a href=#the-a-element>a</a></code> <span class=t2 title=""><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class=t3><code>#text</code>: <span title="">simple</span></ul><li class=t3><code>#text</code>: <span title=""> sample.</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t8><code>#comment</code>: <span title=""> this is a comment </span><li class=t3><code>#text</code>: <span title="">⏎␣⏎</span></ul></ul></ul><p>The <a href=#root-element>root element</a> of this tree is the
+ <code><a href=#the-html-element>html</a></code> element, which is the element always found at the
+ root of HTML documents. It contains two elements, <code><a href=#the-head-element>head</a></code>
and <code><a href=#the-body-element-0>body</a></code>, as well as a text node between them.</p>
<p>There are many more text nodes in the DOM tree than one would
@@ -1909,11 +1906,11 @@
all end up as text nodes in the DOM. However, for historical reasons
not all of the spaces and line breaks in the original markup appear
in the DOM. In particular, all the whitespace before
- <code><a href=#the-head-element-0>head</a></code> start tag ends up being dropped silently, and all
+ <code><a href=#the-head-element>head</a></code> start tag ends up being dropped silently, and all
the whitespace after the <code><a href=#the-body-element-0>body</a></code> end tag ends up placed at
the end of the <code><a href=#the-body-element-0>body</a></code>.</p>
- <p>The <code><a href=#the-head-element-0>head</a></code> element contains a <code><a href=#the-title-element-0>title</a></code>
+ <p>The <code><a href=#the-head-element>head</a></code> element contains a <code><a href=#the-title-element>title</a></code>
element, which itself contains a text node with the text "Sample
page". Similarly, the <code><a href=#the-body-element-0>body</a></code> element contains an
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element, a <code><a href=#the-p-element>p</a></code> element, and a
@@ -1921,14 +1918,14 @@
<hr><p>This DOM tree can be manipulated from scripts in the
page. Scripts (typically in JavaScript) are small programs that can
- be embedded using the <code><a href=#script>script</a></code> element or using
+ be embedded using the <code><a href=#the-script-element>script</a></code> element or using
<a href=#event-handler-content-attributes>event handler content attributes</a>. For example, here is
a form with a script that sets the value of the form's
<code><a href=#the-output-element>output</a></code> element to say "Hello World":</p>
<pre><<a href=#the-form-element>form</a> <a href=#attr-form-name title=attr-form-name>name</a>="main">
Result: <<a href=#the-output-element>output</a> <a href=#attr-fe-name title=attr-fe-name>name</a>="result"></output>
- <<a href=#script>script</a>>
+ <<a href=#the-script-element>script</a>>
<a href=#htmldocument title=HTMLDocument>document</a>.<a href=#dom-document-forms title=dom-document-forms>forms</a>.main.<a href=#dom-form-elements title=dom-form-elements>elements</a>.result.<a href=#dom-output-value title=dom-output-value>value</a> = 'Hello World';
</script>
</form></pre>
@@ -2505,14 +2502,14 @@
encouraging authors to avoid making them, authors can save time in
future efforts.</p>
- <p class=example>For example, a <code><a href=#script>script</a></code> element's
+ <p class=example>For example, a <code><a href=#the-script-element>script</a></code> element's
<code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute causes the
element's contents to be ignored. However, this isn't obvious,
especially if the element's contents appear to be executable
script — which can lead to authors spending a lot of time
trying to debug the inline script without realizing that it is not
executing. To reduce this problem, this specification makes it
- non-conforming to have executable script in a <code><a href=#script>script</a></code>
+ non-conforming to have executable script in a <code><a href=#the-script-element>script</a></code>
element when the <code title=attr-script-src><a href=#attr-script-src>src</a></code>
attribute is present. This means that authors who are validating
their documents are less likely to waste time with this kind of
@@ -2855,7 +2852,7 @@
described in the DOM Core specification. For example, the <code title=dom-cloneNode>cloneNode()</code> and <code title=dom-importNode>importNode()</code> methods of the
<code><a href=#node>Node</a></code> interface both clone nodes, as do a number of
algorithms in this specification. Certain <a href=#html-elements>HTML elements</a>
- (in particular, <code><a href=#the-input-element>input</a></code> and <code><a href=#script>script</a></code>) apply
+ (in particular, <code><a href=#the-input-element>input</a></code> and <code><a href=#the-script-element>script</a></code>) apply
additional requirements on how they are cloned. <a href=#refsDOMCORE>[DOMCORE]</a></p>
@@ -3052,11 +3049,11 @@
specifications.</p>
<p class=example>A conforming XHTML processor would, upon
- finding an XHTML <code><a href=#script>script</a></code> element in an XML document,
+ finding an XHTML <code><a href=#the-script-element>script</a></code> element in an XML document,
execute the script contained in that element. However, if the
element is found within a transformation expressed in XSLT
(assuming the user agent also supports XSLT), then the processor
- would instead treat the <code><a href=#script>script</a></code> element as an opaque
+ would instead treat the <code><a href=#the-script-element>script</a></code> element as an opaque
element that forms part of the transform.</p>
<p>Web browsers that support <a href=#syntax>the HTML syntax</a> must
@@ -3071,7 +3068,7 @@
<p class=note>Unless explicitly stated, specifications that
override the semantics of HTML elements do not override the
requirements on DOM objects representing those elements. For
- example, the <code><a href=#script>script</a></code> element in the example above
+ example, the <code><a href=#the-script-element>script</a></code> element in the example above
would still implement the <code><a href=#htmlscriptelement>HTMLScriptElement</a></code>
interface.</p>
@@ -3533,7 +3530,7 @@
include data on HTML elements that scripts can then look for and
process.</li>
- <li>Authors can use the <code title=meta><a href=#meta><meta name=""
+ <li>Authors can use the <code title=meta><a href=#the-meta-element><meta name=""
content=""></a></code> mechanism to include page-wide metadata by
registering <a href=#concept-meta-extensions title=concept-meta-extensions>extensions to the
predefined set of metadata names</a>.</li>
@@ -3542,7 +3539,7 @@
links with specific meanings by registering <a href=#concept-rel-extensions title=concept-rel-extensions>extensions to the predefined set of
link types</a>. This is also used by Microformats.</li>
- <li>Authors can embed raw data using the <code title=script><a href=#script><script type=""></a></code> mechanism with a custom
+ <li>Authors can embed raw data using the <code title=script><a href=#the-script-element><script type=""></a></code> mechanism with a custom
type, for further handling by inline or server-side scripts.</li>
<li>Authors can create <a href=#plugin title=plugin>plugins</a> and
@@ -7061,7 +7058,7 @@
specification. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p>
- <h4 id=extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code><a href=#meta>meta</a></code> elements</h4>
+ <h4 id=extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code><a href=#the-meta-element>meta</a></code> elements</h4>
<p>The <dfn id=algorithm-for-extracting-an-encoding-from-a-meta-element>algorithm for extracting an encoding from a
<code>meta</code> element</dfn>, given a string <var title="">s</var>, is as follows. It either returns an encoding or
@@ -8980,43 +8977,43 @@
<h4 id=dom-tree-accessors><span class=secno>3.1.4 </span><dfn>DOM tree accessors</dfn></h4>
- <p><dfn id=the-html-element>The <code>html</code> element</dfn> of a document is the
+ <p><dfn id=the-html-element-0>The <code>html</code> element</dfn> of a document is the
document's root element, if there is one and it's an
- <code><a href=#the-html-element-0>html</a></code> element, or null otherwise.</p>
+ <code><a href=#the-html-element>html</a></code> element, or null otherwise.</p>
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-head><a href=#dom-document-head>head</a></code></dt>
<dd>
- <p>Returns <a href=#the-head-element>the <code>head</code> element</a>.</p>
+ <p>Returns <a href=#the-head-element-0>the <code>head</code> element</a>.</p>
</dd>
- </dl><p><dfn id=the-head-element>The <code>head</code> element</dfn> of a document is the
- first <code><a href=#the-head-element-0>head</a></code> element that is a child of <a href=#the-html-element>the
+ </dl><p><dfn id=the-head-element-0>The <code>head</code> element</dfn> of a document is the
+ first <code><a href=#the-head-element>head</a></code> element that is a child of <a href=#the-html-element-0>the
<code>html</code> element</a>, if there is one, or null
otherwise.</p>
<div class=impl>
<p>The <dfn id=dom-document-head title=dom-document-head><code>head</code></dfn>
- attribute, on getting, must return <a href=#the-head-element>the <code>head</code>
- element</a> of the document (a <code><a href=#the-head-element-0>head</a></code> element or
+ attribute, on getting, must return <a href=#the-head-element-0>the <code>head</code>
+ element</a> of the document (a <code><a href=#the-head-element>head</a></code> element or
null).</p>
</div>
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-title><a href=#document.title>title</a></code> [ = <var title="">value</var> ]</dt>
<dd>
- <p>Returns the document's title, as given by <a href=#the-title-element>the
+ <p>Returns the document's title, as given by <a href=#the-title-element-0>the
<code>title</code> element</a>.</p>
<p>Can be set, to update the document's title. If there is no
- <a href=#the-head-element title="the head element"><code>head</code> element</a>,
+ <a href=#the-head-element-0 title="the head element"><code>head</code> element</a>,
the new value is ignored.</p>
<p>In SVG documents, the <code>SVGDocument</code> interface's
<code title=dom-svg-title>title</code> attribute takes
precedence.</p>
</dd>
- </dl><p><dfn id=the-title-element>The <code>title</code> element</dfn> of a document is the
- first <code><a href=#the-title-element-0>title</a></code> element in the document (in tree order), if
+ </dl><p><dfn id=the-title-element-0>The <code>title</code> element</dfn> of a document is the
+ first <code><a href=#the-title-element>title</a></code> element in the document (in tree order), if
there is one, or null otherwise.</p>
<div class=impl>
@@ -9032,8 +9029,8 @@
<li><p>Otherwise, let <var title="">value</var> be a concatenation
of the data of all the child <a href=#text-node title="text node">text
- nodes</a> of <a href=#the-title-element>the <code>title</code> element</a>, in
- <a href=#tree-order>tree order</a>, or the empty string if <a href=#the-title-element>the
+ nodes</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, in
+ <a href=#tree-order>tree order</a>, or the empty string if <a href=#the-title-element-0>the
<code>title</code> element</a> is null.</li>
<li><p>Replace any sequence of one or more consecutive <a href=#space-character title="space character">space characters</a> in <var title="">value</var> with a single U+0020 SPACE character.</li>
@@ -9053,13 +9050,13 @@
<code>SVGDocument</code> interface (if it is readonly, then this
will raise an exception). Stop the algorithm here. <a href=#refsSVG>[SVG]</a></li>
- <li>If <a href=#the-title-element>the <code>title</code> element</a> is null and
- <a href=#the-head-element>the <code>head</code> element</a> is null, then the
+ <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null and
+ <a href=#the-head-element-0>the <code>head</code> element</a> is null, then the
attribute must do nothing. Stop the algorithm here.</li>
- <li>If <a href=#the-title-element>the <code>title</code> element</a> is null, then a
- new <code><a href=#the-title-element-0>title</a></code> element must be created and appended to
- <a href=#the-head-element>the <code>head</code> element</a>. Let <var title="">element</var> be that element. Otherwise, let <var title="">element</var> be <a href=#the-title-element>the <code>title</code>
+ <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null, then a
+ new <code><a href=#the-title-element>title</a></code> element must be created and appended to
+ <a href=#the-head-element-0>the <code>head</code> element</a>. Let <var title="">element</var> be that element. Otherwise, let <var title="">element</var> be <a href=#the-title-element-0>the <code>title</code>
element</a>.</li>
<li>The children of <var title="">element</var> (if any) must all
@@ -9083,7 +9080,7 @@
</dd>
</dl><p><dfn id=the-body-element>The body element</dfn> of a document is the first child of
- <a href=#the-html-element>the <code>html</code> element</a> that is either a
+ <a href=#the-html-element-0>the <code>html</code> element</a> that is either a
<code><a href=#the-body-element-0>body</a></code> element or a <code><a href=#frameset>frameset</a></code> element. If
there is no such element, it is null. <span class=impl>If the body
element is null, then when the specification requires that events be
@@ -9148,7 +9145,7 @@
<dt><var title="">document</var> . <code title=dom-document-scripts><a href=#dom-document-scripts>scripts</a></code></dt>
<dd>
- <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#script>script</a></code> elements in the <code><a href=#document>Document</a></code>.</p>
+ <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-script-element>script</a></code> elements in the <code><a href=#document>Document</a></code>.</p>
</dd>
</dl><div class=impl>
@@ -9183,7 +9180,7 @@
<p>The <dfn id=dom-document-scripts title=dom-document-scripts><code>scripts</code></dfn>
attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the
<code><a href=#document>Document</a></code> node, whose filter matches only
- <code><a href=#script>script</a></code> elements.</p>
+ <code><a href=#the-script-element>script</a></code> elements.</p>
<hr></div>
@@ -9308,7 +9305,7 @@
<p>Each entry in the <a href=#css-id-overrides-list>CSS ID overrides list</a>, while it is
in the list and is either <a href=#in-a-document title="in a Document">in the
<code>Document</code></a> or is an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#video>video</a></code>, or <code><a href=#the-canvas-element>canvas</a></code> element, defines a
+ <code><a href=#the-video-element>video</a></code>, or <code><a href=#the-canvas-element>canvas</a></code> element, defines a
<span>CSS element reference identifier</span> mapping the given name
to the given <code><a href=#element>Element</a></code>. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p>
@@ -9476,7 +9473,7 @@
<dd>
<p>Returns a new <code><a href=#document>Document</a></code>, with a basic DOM already
- constructed with an appropriate <code><a href=#the-title-element-0>title</a></code> element.</p>
+ constructed with an appropriate <code><a href=#the-title-element>title</a></code> element.</p>
</dd>
@@ -9496,20 +9493,20 @@
and empty lists, as appropriate. Append the newly created node to
<var title="">doc</var>.</li>
- <li><p>Create an <code><a href=#the-html-element-0>html</a></code> element, and append it to <var title="">doc</var>.</li>
+ <li><p>Create an <code><a href=#the-html-element>html</a></code> element, and append it to <var title="">doc</var>.</li>
- <li><p>Create a <code><a href=#the-head-element-0>head</a></code> element, and append it to the
- <code><a href=#the-html-element-0>html</a></code> element created in the previous step.</p>
+ <li><p>Create a <code><a href=#the-head-element>head</a></code> element, and append it to the
+ <code><a href=#the-html-element>html</a></code> element created in the previous step.</p>
- <li><p>Create a <code><a href=#the-title-element-0>title</a></code> element, and append it to the
- <code><a href=#the-head-element-0>head</a></code> element created in the previous step.</p>
+ <li><p>Create a <code><a href=#the-title-element>title</a></code> element, and append it to the
+ <code><a href=#the-head-element>head</a></code> element created in the previous step.</p>
<li><p>Create a <code><a href=#text>Text</a></code> node, and set its <code title="">data</code> attribute to the string given by the method's
argument (which could be the empty string). Append it to the
- <code><a href=#the-title-element-0>title</a></code> element created in the previous step.</p>
+ <code><a href=#the-title-element>title</a></code> element created in the previous step.</p>
<li><p>Create a <code><a href=#the-body-element-0>body</a></code> element, and append it to the
- <code><a href=#the-html-element-0>html</a></code> element created in the earlier step.</p>
+ <code><a href=#the-html-element>html</a></code> element created in the earlier step.</p>
<li><p>Return <var title="">doc</var>.</li>
@@ -10330,7 +10327,7 @@
determined and that is either:</p>
<ul class=brief><li>A <code><a href=#the-bdi-element>bdi</a></code> element.
- <li>A <code><a href=#script>script</a></code> element.
+ <li>A <code><a href=#the-script-element>script</a></code> element.
<li>A <code><a href=#the-style-element>style</a></code> element.
<li>An element with a <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute in a defined state.
</ul></li>
@@ -10367,9 +10364,9 @@
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-dir><a href=#dom-dir>dir</a></code> [ = <var title="">value</var> ]</dt>
<dd>
- <p>Returns <a href=#the-html-element>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value, if any.</p>
- <p>Can be set, to either "<code title="">ltr</code>", "<code title="">rtl</code>", or "<code title="">auto</code>" to replace <a href=#the-html-element>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value.</p>
- <p>If there is no <a href=#the-html-element title="the html element"><code>html</code> element</a>, returns the empty string and ignores new values.</p>
+ <p>Returns <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value, if any.</p>
+ <p>Can be set, to either "<code title="">ltr</code>", "<code title="">rtl</code>", or "<code title="">auto</code>" to replace <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value.</p>
+ <p>If there is no <a href=#the-html-element-0 title="the html element"><code>html</code> element</a>, returns the empty string and ignores new values.</p>
</dd>
</dl><div class=impl>
@@ -10381,7 +10378,7 @@
<p>The <dfn id=dom-document-dir title=dom-document-dir><code>dir</code></dfn> IDL
attribute on <code><a href=#htmldocument>HTMLDocument</a></code> objects must
<a href=#reflect>reflect</a> the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content
- attribute of <a href=#the-html-element>the <code>html</code> element</a>, if any,
+ attribute of <a href=#the-html-element-0>the <code>html</code> element</a>, if any,
<a href=#limited-to-only-known-values>limited to only known values</a>. If there is no such
element, then the attribute must return the empty string and do
nothing on setting.</p>
@@ -10912,13 +10909,13 @@
<!-- when updating this also update the category index -->
<ul class="brief category-list"><li><code><a href=#the-base-element>base</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-link-element>link</a></code></li>
- <li><code><a href=#meta>meta</a></code></li>
+ <li><code><a href=#the-meta-element>meta</a></code></li>
<li><code><a href=#the-noscript-element>noscript</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-style-element>style</a></code></li>
- <li><code><a href=#the-title-element-0>title</a></code></li>
+ <li><code><a href=#the-title-element>title</a></code></li>
</ul><p>Elements from other namespaces whose semantics are primarily
metadata-related (e.g. RDF) are also <a href=#metadata-content>metadata
content</a>.</p>
@@ -10964,7 +10961,7 @@
<li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li>
<li><code><a href=#the-article-element>article</a></code></li>
<li><code><a href=#the-aside-element>aside</a></code></li>
- <li><code><a href=#audio>audio</a></code></li>
+ <li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-b-element>b</a></code></li>
<li><code><a href=#the-bdi-element>bdi</a></code></li>
<li><code><a href=#the-bdo-element>bdo</a></code></li>
@@ -10974,7 +10971,7 @@
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-cite-element>cite</a></code></li>
<li><code><a href=#the-code-element>code</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-datalist-element>datalist</a></code></li>
<li><code><a href=#the-del-element>del</a></code></li>
<li><code><a href=#the-details-element>details</a></code></li>
@@ -11010,9 +11007,9 @@
<li><code><a href=#the-map-element>map</a></code></li>
<li><code><a href=#the-mark-element>mark</a></code></li>
<li><code><a href=#math>math</a></code></li>
- <li><code><a href=#menus>menu</a></code></li>
+ <li><code><a href=#the-menu-element>menu</a></code></li>
<!--MD-->
- <li><code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
+ <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
<!--MD-->
<li><code><a href=#the-meter-element>meter</a></code></li>
<li><code><a href=#the-nav-element>nav</a></code></li>
@@ -11027,7 +11024,7 @@
<li><code><a href=#the-ruby-element>ruby</a></code></li>
<li><code><a href=#the-s-element>s</a></code></li>
<li><code><a href=#the-samp-element>samp</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-section-element>section</a></code></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-small-element>small</a></code></li>
@@ -11043,7 +11040,7 @@
<li><code><a href=#the-u-element>u</a></code></li>
<li><code><a href=#the-ul-element>ul</a></code></li>
<li><code><a href=#the-var-element>var</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
<li><code><a href=#the-wbr-element>wbr</a></code></li>
<li><a href=#text-content title="text content">Text</a></li>
</ul><p>As a general rule, elements whose content model allows any
@@ -11105,7 +11102,7 @@
<ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li>
<li><code><a href=#the-abbr-element>abbr</a></code></li>
<li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li>
- <li><code><a href=#audio>audio</a></code></li>
+ <li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-b-element>b</a></code></li>
<li><code><a href=#the-bdi-element>bdi</a></code></li>
<li><code><a href=#the-bdo-element>bdo</a></code></li>
@@ -11114,7 +11111,7 @@
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-cite-element>cite</a></code></li>
<li><code><a href=#the-code-element>code</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-datalist-element>datalist</a></code></li>
<li><code><a href=#the-del-element>del</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li>
<li><code><a href=#the-dfn-element>dfn</a></code></li>
@@ -11135,7 +11132,7 @@
<li><code><a href=#the-mark-element>mark</a></code></li>
<li><code><a href=#math>math</a></code></li>
<!--MD-->
- <li><code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
+ <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
<!--MD-->
<li><code><a href=#the-meter-element>meter</a></code></li>
<li><code><a href=#the-noscript-element>noscript</a></code></li>
@@ -11146,7 +11143,7 @@
<li><code><a href=#the-ruby-element>ruby</a></code></li>
<li><code><a href=#the-s-element>s</a></code></li>
<li><code><a href=#the-samp-element>samp</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-small-element>small</a></code></li>
<li><code><a href=#the-span-element>span</a></code></li>
@@ -11158,7 +11155,7 @@
<li><code><a href=#the-time-element>time</a></code></li>
<li><code><a href=#the-u-element>u</a></code></li>
<li><code><a href=#the-var-element>var</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
<li><code><a href=#the-wbr-element>wbr</a></code></li>
<li><a href=#text-content title="text content">Text</a></li>
</ul><p>As a general rule, elements whose content model allows any
@@ -11190,7 +11187,7 @@
is inserted into the document.</p>
<!-- when updating this also update the category index -->
- <ul class="brief category-list"><li><code><a href=#audio>audio</a></code></li>
+ <ul class="brief category-list"><li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-embed-element>embed</a></code></li>
<li><code><a href=#the-iframe-element>iframe</a></code></li>
@@ -11198,7 +11195,7 @@
<li><code><a href=#math>math</a></code></li>
<li><code><a href=#the-object-element>object</a></code></li>
<li><code><a href=#svg>svg</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
</ul><p>Elements that are from namespaces other than the <a href=#html-namespace-0>HTML
namespace</a> and that convey content but not metadata, are
<a href=#embedded-content>embedded content</a> for the purposes of the content models
@@ -11228,7 +11225,7 @@
<!-- when updating this also update the category index -->
<ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code></li>
- <li><code><a href=#audio>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
+ <li><code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
<li><code><a href=#the-button-element>button</a></code></li>
<li><code><a href=#the-details-element>details</a></code></li>
<li><code><a href=#the-embed-element>embed</a></code></li>
@@ -11237,11 +11234,11 @@
<li><code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state)</li>
<li><code><a href=#the-keygen-element>keygen</a></code></li>
<li><code><a href=#the-label-element>label</a></code></li>
- <li><code><a href=#menus>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state)</li>
+ <li><code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state)</li>
<li><code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section --></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-textarea-element>textarea</a></code></li>
- <li><code><a href=#video>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
+ <li><code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
</ul><p>Certain elements in HTML have an <a href=#activation-behavior>activation
behavior</a>, which means that the user can activate them. This
triggers a sequence of events dependent on the activation mechanism,
@@ -11486,7 +11483,7 @@
<p>Conformance checkers may warn authors of cases where they have
paragraphs that overlap each other (this can happen with
- <code><a href=#the-object-element>object</a></code>, <code><a href=#video>video</a></code>, <code><a href=#audio>audio</a></code>, and
+ <code><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, <code><a href=#the-audio-element>audio</a></code>, and
<code><a href=#the-canvas-element>canvas</a></code> elements, and indirectly through elements in
other namespaces that allow HTML to be further embedded therein,
like <code><a href=#svg>svg</a></code> or <code><a href=#math>math</a></code>).</p> <!-- example below
@@ -11724,7 +11721,7 @@
<td><code title="attr-aria-role-heading">heading</code> role, with the <code title="attr-aria-level">aria-level</code> property set to the element's <span>outline depth</span>
-->
- <tr><td><code><a href=#the-head-element-0>head</a></code> element
+ <tr><td><code><a href=#the-head-element>head</a></code> element
<td>No role
<tr><td><code><a href=#the-hgroup-element>hgroup</a></code> element
@@ -11733,7 +11730,7 @@
<tr><td><code><a href=#the-hr-element>hr</a></code> element
<td><code title=attr-aria-role-separator>separator</code> role
- <tr><td><code><a href=#the-html-element-0>html</a></code> element
+ <tr><td><code><a href=#the-html-element>html</a></code> element
<td>No role
<tr><td><code><a href=#the-img-element>img</a></code> element whose <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value is empty
@@ -11817,16 +11814,16 @@
<tr><td><code><a href=#the-link-element>link</a></code> element that creates a <a href=#hyperlink>hyperlink</a>
<td><code title=attr-aria-role-link>link</code> role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#context-menu-state title="context menu state">context menu</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#context-menu-state title="context menu state">context menu</a> state
<td>No role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menu>menu</code> role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state
<td><code title=attr-aria-role-toolbar>toolbar</code> role
- <tr><td><code><a href=#meta>meta</a></code> element
+ <tr><td><code><a href=#the-meta-element>meta</a></code> element
<td>No role
<tr><td><code><a href=#the-meter-element>meter</a></code> element
@@ -11850,7 +11847,7 @@
<tr><td><code><a href=#the-progress-element>progress</a></code> element
<td><code title=attr-aria-role-progressbar>progressbar</code> role, with, if the progress bar is determinate, the <code title=attr-aria-valuemax>aria-valuemax</code> property set to the maximum value of the progress bar, the <code title=attr-aria-valuemin>aria-valuemin</code> property set to zero, and the <code title=attr-aria-valuenow>aria-valuenow</code> property set to the current value of the progress bar
- <tr><td><code><a href=#script>script</a></code> element
+ <tr><td><code><a href=#the-script-element>script</a></code> element
<td>No role
<tr><td><code><a href=#the-select-element>select</a></code> element with a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute
@@ -11877,16 +11874,16 @@
<tr><td><code><a href=#the-textarea-element>textarea</a></code> element with a <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute
<td>The <code title=title-aria-required>aria-required</code> state set to "true"
- <tr><td><code><a href=#the-title-element-0>title</a></code> element
+ <tr><td><code><a href=#the-title-element>title</a></code> element
<td>No role
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "checkbox", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "checkbox", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "command", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "command", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitem>menuitem</code> role
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "radio", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "radio", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitemradio>menuitemradio</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise
<tr><td>Element that is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>
@@ -11930,7 +11927,7 @@
<td><code title=attr-aria-role-note>note</code> role
<td>Role must be either <code title=attr-aria-role-note>note</code>, <code title=attr-aria-role-complementary>complementary</code>, or <code title=attr-aria-role-search>search</code>
- <tr><td><code><a href=#audio>audio</a></code> element
+ <tr><td><code><a href=#the-audio-element>audio</a></code> element
<td>No role
<td>If specified, role must be <code title=attr-aria-role-application>application</code>
@@ -12044,7 +12041,7 @@
<td><code title=attr-aria-role-list>list</code> role
<td>Role must be either <code title=attr-aria-role-directory>directory</code>, <code title=attr-aria-role-list>list</code>, <code title=attr-aria-role-listbox>listbox</code>, <code title=attr-aria-role-menu>menu</code>, <code title=attr-aria-role-menubar>menubar</code>, <code title=attr-aria-role-tablist>tablist</code>, <code title="attr-aria-role-toolbar ">toolbar</code>, <code title=attr-aria-role-tree>tree</code>
- <tr><td><code><a href=#video>video</a></code> element
+ <tr><td><code><a href=#the-video-element>video</a></code> element
<td>No role
<td>If specified, role must be <code title=attr-aria-role-application>application</code>
@@ -12618,7 +12615,7 @@
<p><code><a href=#document>Document</a></code> objects have an
<dfn id=ignore-destructive-writes-counter>ignore-destructive-writes counter</dfn>, which is used in
- conjunction with the processing of <code><a href=#script>script</a></code> elements to
+ conjunction with the processing of <code><a href=#the-script-element>script</a></code> elements to
prevent external scripts from being able to use <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> to blow away the
document by implicitly calling <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code>. Initially, the
counter must be set to zero.</p>
@@ -12682,12 +12679,12 @@
at a time, processing resulting tokens as they are emitted, and
stopping when the tokenizer reaches the insertion point or when
the processing of the tokenizer is aborted by the tree
- construction stage (this can happen if a <code><a href=#script>script</a></code> end
+ construction stage (this can happen if a <code><a href=#the-script-element>script</a></code> end
tag token is emitted by the tokenizer).
<p class=note>If the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method was
called from script executing inline (i.e. executing because the
- parser parsed a set of <code><a href=#script>script</a></code> tags), then this is a
+ parser parsed a set of <code><a href=#the-script-element>script</a></code> tags), then this is a
<a href=#nestedParsing>reentrant invocation of the
parser</a>.</p>
@@ -13139,7 +13136,7 @@
<h3 id=the-root-element><span class=secno>4.1 </span>The root element</h3>
- <h4 id=the-html-element-0><span class=secno>4.1.1 </span>The <dfn><code>html</code></dfn> element</h4>
+ <h4 id=the-html-element><span class=secno>4.1.1 </span>The <dfn><code>html</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd>None.</dd>
@@ -13147,7 +13144,7 @@
<dd>As the root element of a document.</dd>
<dd>Wherever a subdocument fragment is allowed in a compound document.</dd>
<dt>Content model:</dt>
- <dd>A <code><a href=#the-head-element-0>head</a></code> element followed by a <code><a href=#the-body-element-0>body</a></code> element.</dd>
+ <dd>A <code><a href=#the-head-element>head</a></code> element followed by a <code><a href=#the-body-element-0>body</a></code> element.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dd><code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></dd>
@@ -13155,7 +13152,7 @@
<dd>
<pre class=idl>interface <dfn id=htmlhtmlelement>HTMLHtmlElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre>
</dd>
- </dl><p>The <code><a href=#the-html-element-0>html</a></code> element <a href=#represents>represents</a> the root of
+ </dl><p>The <code><a href=#the-html-element>html</a></code> element <a href=#represents>represents</a> the root of
an HTML document.</p>
<p>The <dfn id=attr-html-manifest title=attr-html-manifest><code>manifest</code></dfn>
@@ -13181,7 +13178,7 @@
<div class=example>
- <p>The <code><a href=#the-html-element-0>html</a></code> element in the following example declares
+ <p>The <code><a href=#the-html-element>html</a></code> element in the following example declares
that the document's language is English.</p>
<pre><!DOCTYPE html>
@@ -13203,27 +13200,27 @@
<h3 id=document-metadata><span class=secno>4.2 </span>Document metadata</h3>
- <h4 id=the-head-element-0><span class=secno>4.2.1 </span>The <dfn><code>head</code></dfn> element</h4>
+ <h4 id=the-head-element><span class=secno>4.2.1 </span>The <dfn><code>head</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>As the first element in an <code><a href=#the-html-element-0>html</a></code> element.</dd>
+ <dd>As the first element in an <code><a href=#the-html-element>html</a></code> element.</dd>
<dt>Content model:</dt>
<dd>If the document is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a> or if title information is available from a higher-level protocol: Zero or more elements of <a href=#metadata-content>metadata content</a>.</dd>
- <dd>Otherwise: One or more elements of <a href=#metadata-content>metadata content</a>, of which exactly one is a <code><a href=#the-title-element-0>title</a></code> element.</dd>
+ <dd>Otherwise: One or more elements of <a href=#metadata-content>metadata content</a>, of which exactly one is a <code><a href=#the-title-element>title</a></code> element.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd>
<pre class=idl>interface <dfn id=htmlheadelement>HTMLHeadElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre>
</dd>
- </dl><p>The <code><a href=#the-head-element-0>head</a></code> element <a href=#represents>represents</a> a
+ </dl><p>The <code><a href=#the-head-element>head</a></code> element <a href=#represents>represents</a> a
collection of metadata for the <code><a href=#document>Document</a></code>.</p>
<div class=example>
- <p>The collection of metadata in a <code><a href=#the-head-element-0>head</a></code> element can be
+ <p>The collection of metadata in a <code><a href=#the-head-element>head</a></code> element can be
large or small. Here is an example of a very short one:</p>
<pre><!doctype html>
@@ -13252,20 +13249,20 @@
</div>
- <p class=note>The <code><a href=#the-title-element-0>title</a></code> element is a required child
+ <p class=note>The <code><a href=#the-title-element>title</a></code> element is a required child
in most situations, but when a higher-level protocol provides title
information, e.g. in the Subject line of an e-mail when HTML is used
- as an e-mail authoring format, the <code><a href=#the-title-element-0>title</a></code> element can be
+ as an e-mail authoring format, the <code><a href=#the-title-element>title</a></code> element can be
omitted.</p>
- <h4 id=the-title-element-0><span class=secno>4.2.2 </span>The <dfn><code>title</code></dfn> element</h4>
+ <h4 id=the-title-element><span class=secno>4.2.2 </span>The <dfn><code>title</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element containing no other <code><a href=#the-title-element-0>title</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-title-element>title</a></code> elements.</dd>
<dt>Content model:</dt>
<dd><a href=#text-content title="text content">Text</a>.</dd>
<dt>Content attributes:</dt>
@@ -13276,7 +13273,7 @@
attribute DOMString <a href=#dom-title-text title=dom-title-text>text</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#the-title-element-0>title</a></code> element <a href=#represents>represents</a> the
+ </dl><p>The <code><a href=#the-title-element>title</a></code> element <a href=#represents>represents</a> the
document's title or name. Authors should use titles that identify
their documents even when they are used out of context, for example
in a user's history or bookmarks, or in search results. The
@@ -13284,7 +13281,7 @@
first heading does not have to stand alone when taken out of
context.</p>
- <p>There must be no more than one <code><a href=#the-title-element-0>title</a></code> element per
+ <p>There must be no more than one <code><a href=#the-title-element>title</a></code> element per
document.</p>
<dl class=domintro><dt><var title="">title</var> . <code title=dom-title-text><a href=#dom-title-text>text</a></code> [ = <var title="">value</var> ]</dt>
@@ -13304,7 +13301,7 @@
<p>The IDL attribute <dfn id=dom-title-text title=dom-title-text><code>text</code></dfn> must return a
concatenation of the contents of all the <a href=#text-node title="text
node">text nodes</a> that are direct children of the
- <code><a href=#the-title-element-0>title</a></code> element (ignoring any other nodes such as
+ <code><a href=#the-title-element>title</a></code> element (ignoring any other nodes such as
comments or elements), in tree order. On setting, it must act the
same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p>
@@ -13338,8 +13335,8 @@
<p>User agents should use the document's title when referring to the
document in their user interface. When the contents of a
- <code><a href=#the-title-element-0>title</a></code> element are used in this way, <a href=#the-directionality>the
- directionality</a> of that <code><a href=#the-title-element-0>title</a></code> element should be
+ <code><a href=#the-title-element>title</a></code> element are used in this way, <a href=#the-directionality>the
+ directionality</a> of that <code><a href=#the-title-element>title</a></code> element should be
used to set the directionality of the document's title in the user
interface.</p>
@@ -13351,7 +13348,7 @@
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element containing no other <code><a href=#the-base-element>base</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-base-element>base</a></code> elements.</dd>
<dt>Content model:</dt>
<dd>Empty.</dd>
<dt>Content attributes:</dt>
@@ -13382,7 +13379,7 @@
<p>A <code><a href=#the-base-element>base</a></code> element, if it has an <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute, must come before any
other elements in the tree that have attributes defined as taking
- <a href=#url title=URL>URLs</a>, except the <code><a href=#the-html-element-0>html</a></code> element
+ <a href=#url title=URL>URLs</a>, except the <code><a href=#the-html-element>html</a></code> element
(its <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute
isn't affected by <code><a href=#the-base-element>base</a></code> elements).</p>
@@ -13452,7 +13449,7 @@
<!--MD-->
<dt>Contexts in which this element can be used:</dt>
<dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd>
- <dd>In a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>In a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<!--MD-->
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
<!--MD-->
@@ -13816,7 +13813,7 @@
- <h4 id=meta><span class=secno>4.2.5 </span>The <dfn><code>meta</code></dfn> element</h4>
+ <h4 id=the-meta-element><span class=secno>4.2.5 </span>The <dfn id=meta><code>meta</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -13825,9 +13822,9 @@
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#phrasing-content>phrasing content</a>.</dd>
<!--MD-->
<dt>Contexts in which this element can be used:</dt>
- <dd>If the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute is present, or if the element's <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element-0>head</a></code> element.</dd>
- <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element-0>head</a></code> element.</dd>
- <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute is present, or if the element's <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<dd>If the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd>
<!--MD-->
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd>
@@ -13849,12 +13846,12 @@
attribute DOMString <a href=#dom-meta-content title=dom-meta-content>content</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#meta>meta</a></code> element <a href=#represents>represents</a> various
+ </dl><p>The <code><a href=#the-meta-element>meta</a></code> element <a href=#represents>represents</a> various
kinds of metadata that cannot be expressed using the
- <code><a href=#the-title-element-0>title</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-link-element>link</a></code>,
- <code><a href=#the-style-element>style</a></code>, and <code><a href=#script>script</a></code> elements.</p>
+ <code><a href=#the-title-element>title</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-link-element>link</a></code>,
+ <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-script-element>script</a></code> elements.</p>
- <p>The <code><a href=#meta>meta</a></code> element can represent document-level
+ <p>The <code><a href=#the-meta-element>meta</a></code> element can represent document-level
metadata with the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>
attribute, pragma directives with the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute, and the
file's <a href=#character-encoding-declaration>character encoding declaration</a> when an HTML
@@ -13878,11 +13875,11 @@
UTF-8 as its encoding).</p>
<p class=note>The <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code>
- attribute on the <code><a href=#meta>meta</a></code> element has no effect in XML
+ attribute on the <code><a href=#the-meta-element>meta</a></code> element has no effect in XML
documents, and is only allowed in order to facilitate migration to
and from XHTML.</p>
- <p>There must not be more than one <code><a href=#meta>meta</a></code> element with a
+ <p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with a
<code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute per
document.</p>
@@ -13892,14 +13889,14 @@
values depend on the exact context, as described in subsequent
sections of this specification.</p>
- <p>If a <code><a href=#meta>meta</a></code> element has a <dfn id=attr-meta-name title=attr-meta-name><code>name</code></dfn> attribute, it sets
+ <p>If a <code><a href=#the-meta-element>meta</a></code> element has a <dfn id=attr-meta-name title=attr-meta-name><code>name</code></dfn> attribute, it sets
document metadata. Document metadata is expressed in terms of
name/value pairs, the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>
- attribute on the <code><a href=#meta>meta</a></code> element giving the name, and the
+ attribute on the <code><a href=#the-meta-element>meta</a></code> element giving the name, and the
<code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute on the same
element giving the value. The name specifies what aspect of metadata
is being set; valid names and the meaning of their values are
- described in the following sections. If a <code><a href=#meta>meta</a></code> element
+ described in the following sections. If a <code><a href=#the-meta-element>meta</a></code> element
has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute,
then the value part of the metadata name/value pair is the empty
string.</p>
@@ -13917,7 +13914,7 @@
<h5 id=standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</h5>
<p>This specification defines a few names for the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute of the
- <code><a href=#meta>meta</a></code> element.</p>
+ <code><a href=#the-meta-element>meta</a></code> element.</p>
<p>Names are case-insensitive<span class=impl>, and must be compared
in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner</span>.</p>
@@ -13927,11 +13924,11 @@
<dd><p>The value must be a short free-form string giving the name
of the Web application that the page represents. If the page is not
a Web application, the <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> metadata name
- must not be used. There must not be more than one <code><a href=#meta>meta</a></code>
+ must not be used. There must not be more than one <code><a href=#the-meta-element>meta</a></code>
element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute
set to the value <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> per
document. <span class=impl>User agents may use the application
- name in UI in preference to the page's <code><a href=#the-title-element-0>title</a></code>, since
+ name in UI in preference to the page's <code><a href=#the-title-element>title</a></code>, since
the title might include status messages and the like relevant to
the status of the page at a particular moment in time instead of
just being the name of the application.</span></dd>
@@ -13946,7 +13943,7 @@
<dd><p>The value must be a free-form string that describes the
page. The value must be appropriate for use in a directory of
pages, e.g. in a search engine. There must not be more than one
- <code><a href=#meta>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-description><a href=#meta-description>description</a></code> per document.</dd>
+ <code><a href=#the-meta-element>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-description><a href=#meta-description>description</a></code> per document.</dd>
<dt><dfn id=meta-generator title=meta-generator><code>generator</code></dfn></dt>
@@ -13959,7 +13956,7 @@
<div class=example>
<p>Here is what a tool called "Frontweaver" could include in its
- output, in the page's <code><a href=#the-head-element-0>head</a></code> element, to identify
+ output, in the page's <code><a href=#the-head-element>head</a></code> element, to identify
itself as the tool used to generate the page:</p>
<pre><meta name=generator content="Frontweaver 8.2"></pre>
@@ -13978,7 +13975,7 @@
<div class=example>
<p>This page about typefaces on British motorways uses a
- <code><a href=#meta>meta</a></code> element to specify some keywords that users
+ <code><a href=#the-meta-element>meta</a></code> element to specify some keywords that users
might use to look for the page:</p>
<pre><!DOCTYPE HTML>
@@ -14008,7 +14005,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose
<code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is
<code title=meta-keywords><a href=#meta-keywords>keywords</a></code>, run the following
substeps:</p>
@@ -14149,14 +14146,14 @@
<p>Metadata names whose values are to be <a href=#url title=URL>URLs</a> must not be proposed or accepted. Links must
be represented using the <code><a href=#the-link-element>link</a></code> element, not the
- <code><a href=#meta>meta</a></code> element.</p>
+ <code><a href=#the-meta-element>meta</a></code> element.</p>
<h5 id=pragma-directives><span class=secno>4.2.5.3 </span>Pragma directives</h5>
<p>When the <dfn id=attr-meta-http-equiv title=attr-meta-http-equiv><code>http-equiv</code></dfn> attribute
- is specified on a <code><a href=#meta>meta</a></code> element, the element is a pragma
+ is specified on a <code><a href=#the-meta-element>meta</a></code> element, the element is a pragma
directive.</p>
<p>The <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>
@@ -14235,7 +14232,7 @@
people expect to have work and what is necessary.
--><div class=impl>
- <p>When a <code><a href=#meta>meta</a></code> element is <a href=#insert-an-element-into-a-document title="insert an
+ <p>When a <code><a href=#the-meta-element>meta</a></code> element is <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into the document</a>, if its
<code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is
present and represents one of the above states, then the user agent
@@ -14256,14 +14253,14 @@
language</dfn>. Until the pragma is successfully processed, there
is no <a href=#pragma-set-default-language>pragma-set default language</a>.</p>
- <ol><li><p>If another <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <ol><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-language title=attr-meta-http-equiv-content-language>Content
Language state</a> has already been successfully processed
(i.e. when it was inserted the user agent processed it and
reached the last step of this list of steps), then abort these
steps.</li>
- <li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14303,7 +14300,7 @@
<a href=#character-encoding-declaration>character encoding declaration</a>. <span class=impl>This state's user agent requirements are all handled
by the parsing section of the specification.</span></p>
- <p>For <code><a href=#meta>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a>, the <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute must have a
value that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for a
@@ -14313,11 +14310,11 @@
the character encoding name of the <a href=#character-encoding-declaration>character encoding
declaration</a>.</p>
- <p>If the document contains a <code><a href=#meta>meta</a></code> element with an
+ <p>If the document contains a <code><a href=#the-meta-element>meta</a></code> element with an
<code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in
the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a>, then the document must not contain a
- <code><a href=#meta>meta</a></code> element with the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute present.</p>
+ <code><a href=#the-meta-element>meta</a></code> element with the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute present.</p>
<p>The <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a> may be used in <a href=#html-documents>HTML
@@ -14335,7 +14332,7 @@
<div class=impl>
- <ol><li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14354,13 +14351,13 @@
<div class=impl>
- <ol><!-- TESTS: <A HREF="http://www.hixie.ch/tests/adhoc/html/meta/refresh/">http://www.hixie.ch/tests/adhoc/html/meta/refresh/</A> --><!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734</A> --><li><p>If another <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <ol><!-- TESTS: <A HREF="http://www.hixie.ch/tests/adhoc/html/meta/refresh/">http://www.hixie.ch/tests/adhoc/html/meta/refresh/</A> --><!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734</A> --><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a>
has already been successfully processed (i.e. when it was
inserted the user agent processed it and reached the last step of
this list of steps), then abort these steps.</li>
- <li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14444,7 +14441,7 @@
(LF), and U+000D CARRIAGE RETURN (CR) characters from <var title="">url</var>.</li>
<li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">url</var> value to an <a href=#absolute-url>absolute URL</a>,
- relative to the <code><a href=#meta>meta</a></code> element. If this fails, abort
+ relative to the <code><a href=#the-meta-element>meta</a></code> element. If this fails, abort
these steps.</li>
<li>
@@ -14455,7 +14452,7 @@
<p>After the refresh has come due (as defined below), if the
user has not canceled the redirect and if the
- <code><a href=#meta>meta</a></code> element's <code><a href=#document>Document</a></code>'s
+ <code><a href=#the-meta-element>meta</a></code> element's <code><a href=#document>Document</a></code>'s
<a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-automatic-features-browsing-context-flag>sandboxed
automatic features browsing context flag</a> set when the
<code><a href=#document>Document</a></code> was created, <a href=#navigate title=navigate>navigate</a><!--DONAV meta refresh--> the
@@ -14474,7 +14471,7 @@
<!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/774">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/774</A> -->
<li>At least <var title="">time</var> seconds have elapsed
- since the <code><a href=#meta>meta</a></code> element was <a href=#insert-an-element-into-a-document title="insert
+ since the <code><a href=#the-meta-element>meta</a></code> element was <a href=#insert-an-element-into-a-document title="insert
an element into a document">inserted into the
<code>Document</code></a>, adjusted to take into account
user or user agent preferences.</li>
@@ -14498,7 +14495,7 @@
</ol></div>
- <p>For <code><a href=#meta>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a>,
the <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute must
have a value consisting either of:</p>
@@ -14521,7 +14518,7 @@
<div class=example>
<p>A news organization's front page could include the following
- markup in the page's <code><a href=#the-head-element-0>head</a></code> element, to ensure that
+ markup in the page's <code><a href=#the-head-element>head</a></code> element, to ensure that
the page automatically reloads from the server every five
minutes:</p>
@@ -14549,7 +14546,7 @@
<p>It is non-conforming. Real HTTP headers should be used instead.</p>
- <ol><li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14563,7 +14560,7 @@
</ol></dd>
- </dl><p>There must not be more than one <code><a href=#meta>meta</a></code> element with
+ </dl><p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with
any particular state in the document at a time.</p>
@@ -14670,8 +14667,8 @@
character encoding used must be an <a href=#ascii-compatible-character-encoding>ASCII-compatible character
encoding</a>, and, in addition, if that encoding isn't US-ASCII
itself, then the encoding must be specified using a
- <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
- <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
+ <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration
state</a>.</p>
@@ -14682,8 +14679,8 @@
<code><a href=#the-iframe-element>iframe</a></code>.)</p>
<p>If an <a href=#html-documents title="HTML documents">HTML document</a> contains
- a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
- <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
+ <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration
state</a>, then the character encoding used must be an
<a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>.</p>
@@ -14748,7 +14745,7 @@
<p>In HTML, to declare that the character encoding is UTF-8, the
author could include the following markup near the top of the
- document (in the <code><a href=#the-head-element-0>head</a></code> element):</p>
+ document (in the <code><a href=#the-head-element>head</a></code> element):</p>
<pre><meta charset="utf-8"></pre>
@@ -14767,7 +14764,7 @@
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: <a href=#flow-content>flow content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: where <a href=#metadata-content>metadata content</a> is expected.</dd>
- <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: where <a href=#flow-content>flow content</a> is expected, but before any other <a href=#flow-content>flow content</a> other than other <code><a href=#the-style-element>style</a></code> elements and <a href=#inter-element-whitespace>inter-element whitespace</a>.</dd>
<dt>Content model:</dt>
<dd>Depends on the value of the <code title=attr-style-type><a href=#attr-style-type>type</a></code> attribute, but must match requirements described in prose below.</dd>
@@ -15148,7 +15145,7 @@
</div>
- <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn> element</h4>
+ <h4 id=the-script-element><span class=secno>4.3.1 </span>The <dfn id=script><code>script</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -15183,7 +15180,7 @@
attribute DOMString <a href=#dom-script-text title=dom-script-text>text</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#script>script</a></code> element allows authors to include dynamic
+ </dl><p>The <code><a href=#the-script-element>script</a></code> element allows authors to include dynamic
script and data blocks in their documents. The element does not
<a href=#represents title=represents>represent</a> content for the user.</p>
@@ -15193,14 +15190,14 @@
is not that described by "<code title="">text/javascript</code>",
then the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must
be present, as described below. Whatever language is used, the
- contents of the <code><a href=#script>script</a></code> element must conform with the
+ contents of the <code><a href=#the-script-element>script</a></code> element must conform with the
requirements of that language's specification.</p>
<p>When used to include data blocks (as opposed to scripts), the
data must be embedded inline, the format of the data must be given
using the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, the
<code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute must not be
- specified, and the contents of the <code><a href=#script>script</a></code> element must
+ specified, and the contents of the <code><a href=#the-script-element>script</a></code> element must
conform to the requirements defined for the format used.</p>
<p>The <dfn id=attr-script-type title=attr-script-type><code>type</code></dfn>
@@ -15253,7 +15250,7 @@
therefore by necessity scattered throughout the specification. The
algorithms below (in this section) describe the core of this
processing, but these algorithms reference and are referenced by the
- parsing rules for <code><a href=#script>script</a></code> <a href=#scriptTag>start</a>
+ parsing rules for <code><a href=#the-script-element>script</a></code> <a href=#scriptTag>start</a>
and <a href=#scriptEndTag>end</a> tags in HTML, <a href=#scriptForeignEndTag>in foreign content</a>, and <a href=#scriptTagXML>in XML</a>, the rules for the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method, the
handling of <a href=#scripting>scripting</a>, etc.</p>
@@ -15270,28 +15267,28 @@
<div class=impl>
- <p>A <code><a href=#script>script</a></code> element has several associated pieces of
+ <p>A <code><a href=#the-script-element>script</a></code> element has several associated pieces of
state.</p>
<p>The first is a flag indicating whether or not the script block
has been <dfn id=already-started>"already started"</dfn>. Initially,
- <code><a href=#script>script</a></code> elements must have this flag unset (script
+ <code><a href=#the-script-element>script</a></code> elements must have this flag unset (script
blocks, when created, are not "already started"). When a
- <code><a href=#script>script</a></code> element is <a href=#concept-clone title=concept-clone>cloned</a>, the "already started" flag, if
+ <code><a href=#the-script-element>script</a></code> element is <a href=#concept-clone title=concept-clone>cloned</a>, the "already started" flag, if
set, must be propagated to the clone when it is created.</p>
<p>The second is a flag indicating whether the element was
- <dfn id=parser-inserted>"parser-inserted"</dfn>. Initially, <code><a href=#script>script</a></code>
+ <dfn id=parser-inserted>"parser-inserted"</dfn>. Initially, <code><a href=#the-script-element>script</a></code>
elements must have this flag unset. It is set by the <a href=#html-parser>HTML
- parser</a> and the <a href=#xml-parser>XML parser</a> on <code><a href=#script>script</a></code>
+ parser</a> and the <a href=#xml-parser>XML parser</a> on <code><a href=#the-script-element>script</a></code>
elements they insert and affects the processing of those
elements.</p>
<p>The third is a flag indicating whether the element will
- <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#script>script</a></code> elements
+ <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#the-script-element>script</a></code> elements
must have this flag set. It is unset by the <a href=#html-parser>HTML parser</a>
- and the <a href=#xml-parser>XML parser</a> on <code><a href=#script>script</a></code> elements they
- insert. In addition, whenever a <code><a href=#script>script</a></code> element whose
+ and the <a href=#xml-parser>XML parser</a> on <code><a href=#the-script-element>script</a></code> elements they
+ insert. In addition, whenever a <code><a href=#the-script-element>script</a></code> element whose
<a href=#force-async>"force-async"</a> flag is set has a <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute added, the
element's <a href=#force-async>"force-async"</a> flag must be unset.</p> <!--
there's no need to unset it when the attribute is removed since you
@@ -15299,7 +15296,7 @@
<p>The fourth is a flag indicating whether or not the script block is
<dfn id=ready-to-be-parser-executed>"ready to be parser-executed"</dfn>. Initially,
- <code><a href=#script>script</a></code> elements must have this flag unset (script
+ <code><a href=#the-script-element>script</a></code> elements must have this flag unset (script
blocks, when created, are not "ready to be parser-executed"). This
flag is used only for elements that are also
<a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
@@ -15310,21 +15307,21 @@
encoding</var></dfn>, and <dfn id="the-script-block's-fallback-character-encoding"><var>the script block's fallback
character encoding</var></dfn>. They are determined when the script
is prepared, based on the attributes on the element at that time,
- and the <code><a href=#document>Document</a></code> of the <code><a href=#script>script</a></code>
+ and the <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code>
element.</p>
- <p>When a <code><a href=#script>script</a></code> element that is not marked as being
+ <p>When a <code><a href=#the-script-element>script</a></code> element that is not marked as being
<a href=#parser-inserted>"parser-inserted"</a> experiences one of the events listed
- in the following list, the user agent must synchronously <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#script>script</a></code>
+ in the following list, the user agent must synchronously <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#the-script-element>script</a></code>
element:</p>
- <ul><li>The <code><a href=#script>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
+ <ul><li>The <code><a href=#the-script-element>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into a document</a>.</li>
- <li>The <code><a href=#script>script</a></code> element is <a href=#in-a-document>in a
+ <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a
<code>Document</code></a> and its child nodes are changed.</li>
- <li>The <code><a href=#script>script</a></code> element is <a href=#in-a-document>in a
+ <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a
<code>Document</code></a> and has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute set where previously
the element had no such attribute.</li>
@@ -15333,7 +15330,7 @@
<ol><li>
- <p>If the <code><a href=#script>script</a></code> element is marked as having
+ <p>If the <code><a href=#the-script-element>script</a></code> element is marked as having
<a href=#already-started>"already started"</a>, then the user agent must abort
these steps at this point. The script is not executed.</p>
@@ -15347,7 +15344,7 @@
<var title="">was-parser-inserted</var> to false.</p>
<p class=note>This is done so that if parser-inserted
- <code><a href=#script>script</a></code> elements fail to run when the parser tries to
+ <code><a href=#the-script-element>script</a></code> elements fail to run when the parser tries to
run them, e.g. because they are empty or specify an unsupported
scripting language, another script can later mutate them and cause
them to run again.</p>
@@ -15363,7 +15360,7 @@
element's <a href=#force-async>"force-async"</a> flag to true.</p>
<p class=note>This is done so that if a parser-inserted
- <code><a href=#script>script</a></code> element fails to run when the parser tries to
+ <code><a href=#the-script-element>script</a></code> element fails to run when the parser tries to
run it, but it is later executed after a script dynamically
updates it, it will execute asynchronously even if the
<code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute isn't
@@ -15393,25 +15390,25 @@
<p>If either:</p>
- <ul class=brief><li>the <code><a href=#script>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute and its value is
+ <ul class=brief><li>the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute and its value is
the empty string, or</li>
- <li>the <code><a href=#script>script</a></code> element has no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute but it has a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute and
+ <li>the <code><a href=#the-script-element>script</a></code> element has no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute but it has a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute and
<em>that</em> attribute's value is the empty string, or</li>
- <li>the <code><a href=#script>script</a></code> element has neither a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute nor a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute, then</li>
+ <li>the <code><a href=#the-script-element>script</a></code> element has neither a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute nor a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute, then</li>
</ul><p>...let <var><a href="#the-script-block's-type">the script block's type</a></var> for this
- <code><a href=#script>script</a></code> element be "<code title="">text/javascript</code>".</p>
+ <code><a href=#the-script-element>script</a></code> element be "<code title="">text/javascript</code>".</p>
- <p>Otherwise, if the <code><a href=#script>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, let <var><a href="#the-script-block's-type">the
- script block's type</a></var> for this <code><a href=#script>script</a></code> element be
+ <p>Otherwise, if the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, let <var><a href="#the-script-block's-type">the
+ script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element be
the value of that attribute with any leading or trailing sequences
of <a href=#space-character title="space character">space characters</a>
removed.</p>
<p>Otherwise, the element has a non-empty <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute; let
- <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#script>script</a></code>
+ <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code>
element be the concatenation of the string "<code title="">text/</code>" followed by the value of the <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute.</p> <!--
user agents already support, e.g., type="text/javascript1.3", so
we don't have to support that separately. -->
@@ -15425,7 +15422,7 @@
<p>If the user agent does not <a href=#support-the-scripting-language>support the scripting
language</a> given by <var><a href="#the-script-block's-type">the script block's type</a></var> for
- this <code><a href=#script>script</a></code> element, then the user agent must abort
+ this <code><a href=#the-script-element>script</a></code> element, then the user agent must abort
these steps at this point. The script is not executed.</p>
</li>
@@ -15460,7 +15457,7 @@
<li id=script-processing-noscript>
<p>If <a href=#concept-n-noscript title=concept-n-noscript>scripting is
- disabled</a> for the <code><a href=#script>script</a></code> element, then the user
+ disabled</a> for the <code><a href=#the-script-element>script</a></code> element, then the user
agent must abort these steps at this point. The script is not
executed.</p>
@@ -15479,7 +15476,7 @@
<li id=script-processing-for>
- <p>If the <code><a href=#script>script</a></code> element has an <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute and a <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute, then run these
+ <p>If the <code><a href=#the-script-element>script</a></code> element has an <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute and a <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute, then run these
substeps:</p>
<ol><li><p>Let <var title="">for</var> be the value of the <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute.</li>
@@ -15501,12 +15498,12 @@
<li id=script-processing-encoding>
- <p>If the <code><a href=#script>script</a></code> element has a <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute, then let
+ <p>If the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute, then let
<var><a href="#the-script-block's-character-encoding">the script block's character encoding</a></var> for this
- <code><a href=#script>script</a></code> element be the encoding given by the <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute.</p>
+ <code><a href=#the-script-element>script</a></code> element be the encoding given by the <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute.</p>
<p>Otherwise, let <var><a href="#the-script-block's-fallback-character-encoding">the script block's fallback character
- encoding</a></var> for this <code><a href=#script>script</a></code> element be the same as
+ encoding</a></var> for this <code><a href=#the-script-element>script</a></code> element be the same as
<a href="#document's-character-encoding" title="document's character encoding">the encoding of the
document itself</a>.</p>
@@ -15606,7 +15603,7 @@
have a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and
the element has been flagged as <a href=#parser-inserted>"parser-inserted"</a>,
and the <code><a href=#document>Document</a></code> of the <a href=#html-parser>HTML parser</a> or
- <a href=#xml-parser>XML parser</a> that created the <code><a href=#script>script</a></code>
+ <a href=#xml-parser>XML parser</a> that created the <code><a href=#the-script-element>script</a></code>
element <a href=#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking
scripts</a></dt>
@@ -15632,7 +15629,7 @@
<p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of
scripts that will execute in order as soon as possible</dfn>
associated with the <code><a href=#document>Document</a></code> of the
- <code><a href=#script>script</a></code> element at the time the <a href=#prepare-a-script>prepare a
+ <code><a href=#the-script-element>script</a></code> element at the time the <a href=#prepare-a-script>prepare a
script</a> algorithm started.</p>
<p>The <a href=#concept-task title=concept-task>task</a> that the
@@ -15668,7 +15665,7 @@
<p>The element must be added to the <dfn id=set-of-scripts-that-will-execute-as-soon-as-possible>set of scripts that
will execute as soon as possible</dfn> of the
- <code><a href=#document>Document</a></code> of the <code><a href=#script>script</a></code> element at the
+ <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code> element at the
time the <a href=#prepare-a-script>prepare a script</a> algorithm started.</p>
<p>The <a href=#concept-task title=concept-task>task</a> that the
@@ -15698,7 +15695,7 @@
<code><a href=#document>Document</a></code> is used by the <code><a href=#document>Document</a></code>'s
parser(s).</p>
- <p class=note>If a <code><a href=#script>script</a></code> element that blocks a
+ <p class=note>If a <code><a href=#the-script-element>script</a></code> element that blocks a
parser gets moved to another <code><a href=#document>Document</a></code> before it would
normally have stopped blocking that parser, it nonetheless continues
blocking that parser until the condition that causes it to be
@@ -15750,7 +15747,7 @@
following steps. For the purposes of these steps, the script is
considered to be from an <i>external file</i> if, while the
<a href=#prepare-a-script>prepare a script</a> algorithm above was running for
- this script, the <code><a href=#script>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>
+ this script, the <code><a href=#the-script-element>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>
<ol><li id=establish-script-block-source>
@@ -15853,7 +15850,7 @@
<dd>
- <p>The child nodes of the <code><a href=#script>script</a></code> element at the
+ <p>The child nodes of the <code><a href=#the-script-element>script</a></code> element at the
time the element's <a href=#already-started>"already started"</a> flag was
last set are the script source.</p>
@@ -15865,7 +15862,7 @@
<p>If the script is from an external file, then increment the
<a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the
- <code><a href=#script>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
+ <code><a href=#the-script-element>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
<code><a href=#document>Document</a></code>.</p>
</li>
@@ -15873,7 +15870,7 @@
<li>
<p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
- script</a> from the <code><a href=#script>script</a></code> element node, using
+ script</a> from the <code><a href=#the-script-element>script</a></code> element node, using
<var><a href="#the-script-block's-source">the script block's source</a></var> and <var><a href="#the-script-block's-type">the script
block's type</a></var>.</p>
@@ -15894,10 +15891,10 @@
<p>If the script is from an external file, <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-load>load</code> at the
- <code><a href=#script>script</a></code> element.</p>
+ <code><a href=#the-script-element>script</a></code> element.</p>
<p>Otherwise, the script is internal; <a href=#queue-a-task>queue a
- task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#script>script</a></code>
+ task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-script-element>script</a></code>
element.</p>
</li>
@@ -15941,20 +15938,20 @@
<p>The IDL attribute <dfn id=dom-script-text title=dom-script-text><code>text</code></dfn> must return a
concatenation of the contents of all the <a href=#text-node title="text
node">text nodes</a> that are direct children of the
- <code><a href=#script>script</a></code> element (ignoring any other nodes such as
+ <code><a href=#the-script-element>script</a></code> element (ignoring any other nodes such as
comments or elements), in tree order. On setting, it must act the
same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p>
</div>
<p class=note>When inserted using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method,
- <code><a href=#script>script</a></code> elements execute (typically synchronously), but
+ <code><a href=#the-script-element>script</a></code> elements execute (typically synchronously), but
when inserted using <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> and <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attributes, they do not
execute at all.</p>
<div class=example>
- <p>In this example, two <code><a href=#script>script</a></code> elements are used. One
+ <p>In this example, two <code><a href=#the-script-element>script</a></code> elements are used. One
embeds an external script, and the other includes some data.</p>
<pre><script src="game-engine.js"></script>
@@ -15978,7 +15975,7 @@
<p>The following sample shows how a script element can be used to
define a function that is then used by other parts of the
- document. It also shows how a <code><a href=#script>script</a></code> element can be
+ document. It also shows how a <code><a href=#the-script-element>script</a></code> element can be
used to invoke script while the document is being parsed, in this
case to initialize the form's output.</p>
@@ -16070,7 +16067,7 @@
<h5 id=restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span><dfn title="script content restrictions">Restrictions for contents of <code>script</code> elements</dfn></h5>
- <p>The <code><a href=#textcontent>textContent</a></code> of a <code><a href=#script>script</a></code> element
+ <p>The <code><a href=#textcontent>textContent</a></code> of a <code><a href=#the-script-element>script</a></code> element
must match the <code title="">script</code> production in the
following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p>
@@ -16112,15 +16109,15 @@
tag-end =/ %x002F ; U+002F SOLIDUS (/)
tag-end =/ %x003E ; U+003E GREATER-THAN SIGN (>)</pre>
- <p>When a <code><a href=#script>script</a></code> element contains <a href=#inline-documentation-for-external-scripts>script
+ <p>When a <code><a href=#the-script-element>script</a></code> element contains <a href=#inline-documentation-for-external-scripts>script
documentation</a>, there are further restrictions on the contents
of the element, as described in the section below.</p>
<h5 id=inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span><dfn title="script documentation">Inline documentation for external scripts</dfn></h5>
- <p>If a <code><a href=#script>script</a></code> element's <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is specified, then the
- contents of the <code><a href=#script>script</a></code> element, if any, must be such
+ <p>If a <code><a href=#the-script-element>script</a></code> element's <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is specified, then the
+ contents of the <code><a href=#the-script-element>script</a></code> element, if any, must be such
that the value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code> IDL
attribute, which is derived from the element's contents, matches the
<code title="">documentation</code> production in the following
@@ -16147,7 +16144,7 @@
element in JavaScript comments.</p>
<p class=note>This requirement is in addition to the earlier
- restrictions on the syntax of contents of <code><a href=#script>script</a></code>
+ restrictions on the syntax of contents of <code><a href=#the-script-element>script</a></code>
elements.</p>
<div class=example>
@@ -16171,12 +16168,12 @@
<div class=impl>
- <h5 id=scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code><a href=#script>script</a></code> elements and XSLT</h5>
+ <h5 id=scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code><a href=#the-script-element>script</a></code> elements and XSLT</h5>
<p><i>This section is non-normative.</i></p>
<p>This specification does not define how XSLT interacts with the
- <code><a href=#script>script</a></code> element (or, indeed, how XSLT processing
+ <code><a href=#the-script-element>script</a></code> element (or, indeed, how XSLT processing
triggers the <a href=#stop-parsing>stop parsing</a> steps, how it interacts with
the <a href=#navigate title=navigate>navigation</a> algorithm, or how it
fits in with the <a href=#event-loop>event loop</a>). However, in the absence
@@ -16185,7 +16182,7 @@
<ul><li><p>When an XSLT transformation program is triggered by an <code title=""><?xml-stylesheet?></code> processing instruction and
the browser implements a direct-to-DOM transformation,
- <code><a href=#script>script</a></code> elements created by the XSLT processor need to
+ <code><a href=#the-script-element>script</a></code> elements created by the XSLT processor need to
be marked <a href=#parser-inserted>"parser-inserted"</a> and run in document order
(modulo scripts marked <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code>
or <code title=attr-script-async><a href=#attr-script-async>async</a></code>), asynchronously
@@ -16194,17 +16191,17 @@
<li><p>The <code title=dom-XSLTProcessor-transformToDocument>XSLTProcessor.transformToDocument()</code>
method adds elements to a <code><a href=#document>Document</a></code> that is not in a
<a href=#browsing-context>browsing context</a>, and, accordingly, any
- <code><a href=#script>script</a></code> elements they create need to have their
+ <code><a href=#the-script-element>script</a></code> elements they create need to have their
<a href=#already-started>"already started"</a> flag set in the <a href=#prepare-a-script>prepare a
script</a> algorithm and never get executed (<a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a>). Such
- <code><a href=#script>script</a></code> elements still need to be marked
+ <code><a href=#the-script-element>script</a></code> elements still need to be marked
<a href=#parser-inserted>"parser-inserted"</a>, though, such that their <code title=dom-script-async><a href=#dom-script-async>async</a></code> IDL attribute will return
false in the absence of an <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute.</li>
<li><p>The <code title=dom-XSLTProcessor-transformToFragment>XSLTProcessor.transformToFragment()</code>
method needs to create a fragment that is equivalent to one built
manually by creating the elements using <code title=dom-document-createElementNS><a href=#dom-document-createelementns>document.createElementNS()</a></code>.
- For instance, it needs to create <code><a href=#script>script</a></code> elements that
+ For instance, it needs to create <code><a href=#the-script-element>script</a></code> elements that
aren't <a href=#parser-inserted>"parser-inserted"</a> and that don't have their
<a href=#already-started>"already started"</a> flag set, so that they will execute
when the fragment is inserted into a document.</li>
@@ -16224,11 +16221,11 @@
<dd><a href=#flow-content>Flow content</a>.</dd>
<dd><a href=#phrasing-content>Phrasing content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element of an <a href=#html-documents title="HTML documents">HTML document</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element of an <a href=#html-documents title="HTML documents">HTML document</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
<dd>Where <a href=#phrasing-content>phrasing content</a> is expected in <a href=#html-documents>HTML documents</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
<dt>Content model:</dt>
- <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, in a <code><a href=#the-head-element-0>head</a></code> element: in any order, zero or more <code><a href=#the-link-element>link</a></code> elements, zero or more <code><a href=#the-style-element>style</a></code> elements, and zero or more <code><a href=#meta>meta</a></code> elements.</dd>
- <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, not in a <code><a href=#the-head-element-0>head</a></code> element: <a href=#transparent>transparent</a>, but there must be no <code><a href=#the-noscript-element>noscript</a></code> element descendants.</dd>
+ <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, in a <code><a href=#the-head-element>head</a></code> element: in any order, zero or more <code><a href=#the-link-element>link</a></code> elements, zero or more <code><a href=#the-style-element>style</a></code> elements, and zero or more <code><a href=#the-meta-element>meta</a></code> elements.</dd>
+ <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, not in a <code><a href=#the-head-element>head</a></code> element: <a href=#transparent>transparent</a>, but there must be no <code><a href=#the-noscript-element>noscript</a></code> element descendants.</dd>
<dd>Otherwise: text that conforms to the requirements given in the prose.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
@@ -16244,14 +16241,14 @@
<p>When used in <a href=#html-documents>HTML documents</a>, the allowed content
model is as follows:</p>
- <dl><dt>In a <code><a href=#the-head-element-0>head</a></code> element, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
+ <dl><dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only
- <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#meta>meta</a></code>
+ <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-meta-element>meta</a></code>
elements.</dd>
- <dt>In a <code><a href=#the-head-element-0>head</a></code> element, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
+ <dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only text,
@@ -16259,10 +16256,10 @@
algorithm</a> <!-- (which disables <script> execution) --> with
the <code><a href=#the-noscript-element>noscript</a></code> element as the <var title="">context</var> element and the text contents as the <var title="">input</var> must result in a list of nodes that consists
only of <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and
- <code><a href=#meta>meta</a></code> elements that would be conforming if they were
+ <code><a href=#the-meta-element>meta</a></code> elements that would be conforming if they were
children of the <code><a href=#the-noscript-element>noscript</a></code> element, and no <a href=#parse-error title="parse error">parse errors</a>.</dd>
- <dt>Outside of <code><a href=#the-head-element-0>head</a></code> elements, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
+ <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element's content model is
@@ -16271,7 +16268,7 @@
element as an ancestor (that is, <code><a href=#the-noscript-element>noscript</a></code> can't be
nested).</dd>
- <dt>Outside of <code><a href=#the-head-element-0>head</a></code> elements, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
+ <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd>
@@ -16279,11 +16276,11 @@
<p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only text,
except that the text must be such that running the following
algorithm results in a conforming document with no
- <code><a href=#the-noscript-element>noscript</a></code> elements and no <code><a href=#script>script</a></code>
+ <code><a href=#the-noscript-element>noscript</a></code> elements and no <code><a href=#the-script-element>script</a></code>
elements, and such that no step in the algorithm causes an
<a href=#html-parser>HTML parser</a> to flag a <a href=#parse-error>parse error</a>:</p>
- <ol><li>Remove every <code><a href=#script>script</a></code> element from the
+ <ol><li>Remove every <code><a href=#the-script-element>script</a></code> element from the
document.</li>
<li>Make a list of every <code><a href=#the-noscript-element>noscript</a></code> element in the
@@ -16419,7 +16416,7 @@
<dl class=element><dt>Categories</dt>
<dd><a href=#sectioning-root>Sectioning root</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>As the second element in an <code><a href=#the-html-element-0>html</a></code> element.</dd>
+ <dd>As the second element in an <code><a href=#the-html-element>html</a></code> element.</dd>
<dt>Content model:</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
<dt>Content attributes:</dt>
@@ -16502,11 +16499,11 @@
body element</a> of a <code><a href=#document>Document</a></code> would first trigger
the <code title=handler-onerror><a href=#handler-onerror>onerror</a></code> <a href=#event-handler-content-attributes>event handler
content attributes</a> of that element, then that of the root
- <code><a href=#the-html-element-0>html</a></code> element, and only <em>then</em> would it trigger
+ <code><a href=#the-html-element>html</a></code> element, and only <em>then</em> would it trigger
the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> <a href=#event-handler-content-attributes title="event handler content attributes">event handler content
attribute</a> on the <code><a href=#the-body-element-0>body</a></code> element. This is because
the event would bubble from the target, to the <code><a href=#the-body-element-0>body</a></code>, to
- the <code><a href=#the-html-element-0>html</a></code>, to the <code><a href=#document>Document</a></code>, to the
+ the <code><a href=#the-html-element>html</a></code>, to the <code><a href=#document>Document</a></code>, to the
<code><a href=#window>Window</a></code>, and the <a href=#event-handlers title="event handlers">event
handler</a> on the <code><a href=#the-body-element-0>body</a></code> is watching the
<code><a href=#window>Window</a></code> not the <code><a href=#the-body-element-0>body</a></code>. A regular event
@@ -17072,10 +17069,7 @@
- <h4 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <dfn><code>h1</code></dfn>, <dfn><code>h2</code></dfn>,
- <dfn><code>h3</code></dfn>, <dfn><code>h4</code></dfn>,
- <dfn><code>h5</code></dfn>, and <dfn><code>h6</code></dfn>
- elements</h4>
+ <h4 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <dfn id=the-h1-element><code>h1</code></dfn>, <dfn id=the-h2-element><code>h2</code></dfn>, <dfn id=the-h3-element><code>h3</code></dfn>, <dfn id=the-h4-element><code>h4</code></dfn>, <dfn id=the-h5-element><code>h5</code></dfn>, and <dfn id=the-h6-element><code>h6</code></dfn> elements</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -18678,7 +18672,7 @@
<dt>Contexts in which this element can be used:</dt>
<dd>Inside <code><a href=#the-ol-element>ol</a></code> elements.</dd>
<dd>Inside <code><a href=#the-ul-element>ul</a></code> elements.</dd>
- <dd>Inside <code><a href=#menus>menu</a></code> elements.</dd>
+ <dd>Inside <code><a href=#the-menu-element>menu</a></code> elements.</dd>
<dt>Content model:</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
<dt>Content attributes:</dt>
@@ -18692,7 +18686,7 @@
</dd>
</dl><p>The <code><a href=#the-li-element>li</a></code> element <a href=#represents>represents</a> a list
item. If its parent element is an <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-ul-element>ul</a></code>,
- or <code><a href=#menus>menu</a></code> element, then the element is an item of the
+ or <code><a href=#the-menu-element>menu</a></code> element, then the element is an item of the
parent element's list, as defined for those elements. Otherwise, the
list item has no defined list-related relationship to any other
<code><a href=#the-li-element>li</a></code> element.</p>
@@ -18765,7 +18759,7 @@
</div>
<p class=note>If the <code><a href=#the-li-element>li</a></code> element is the child of a
- <code><a href=#menus>menu</a></code> element and itself has a child that defines a
+ <code><a href=#the-menu-element>menu</a></code> element and itself has a child that defines a
<a href=#concept-command title=concept-command>command</a>, then the
<code><a href=#the-li-element>li</a></code> element will match the <code title=selector-enabled><a href=#selector-enabled>:enabled</a></code> and <code title=selector-disabled><a href=#selector-disabled>:disabled</a></code> pseudo-classes in the
same way as the first such child element does.</p>
@@ -20581,7 +20575,7 @@
</div>
- <h4 id=the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <dfn><code>sub</code></dfn> and <dfn><code>sup</code></dfn> elements</h4>
+ <h4 id=the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <dfn id=the-sub-element><code>sub</code></dfn> and <dfn id=the-sup-element><code>sup</code></dfn> elements</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -23291,7 +23285,7 @@
who is known to be able to view images.</li>
<!--FORK-->
- <li>The document has a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is an
+ <li>The document has a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is an
<a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=meta-generator><a href=#meta-generator>generator</a></code>". (This case does not
represent a case where the document is conforming, only that the
generator could not determine appropriate alternative text —
@@ -23364,7 +23358,7 @@
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
- <li>The root element, in the form of an <code><a href=#the-html-element-0>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
+ <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
@@ -24092,7 +24086,7 @@
<var title="">input</var> must result in a list of nodes that are
all <a href=#phrasing-content>phrasing content</a>, with no <a href=#parse-error title="parse
error">parse errors</a> having occurred, with no
- <code><a href=#script>script</a></code> elements being anywhere in the list or as
+ <code><a href=#the-script-element>script</a></code> elements being anywhere in the list or as
descendants of elements in the list, and with all the elements in
the list (including their descendants) being themselves
conforming.</p>
@@ -25139,10 +25133,10 @@
<p>The following example shows how a plugin can be used in HTML (in
this case the Flash plugin, to show a video file). Fallback is
provided for users who do not have Flash enabled, in this case
- using the <code><a href=#video>video</a></code> element to show the video for those
- using user agents that support <code><a href=#video>video</a></code>, and finally
+ using the <code><a href=#the-video-element>video</a></code> element to show the video for those
+ using user agents that support <code><a href=#the-video-element>video</a></code>, and finally
providing a link to the video for those who have neither Flash nor
- a <code><a href=#video>video</a></code>-capable browser.</p>
+ a <code><a href=#the-video-element>video</a></code>-capable browser.</p>
<pre><p>Look at my video:
<object type="application/x-shockwave-flash">
@@ -25245,7 +25239,7 @@
</div>
- <h4 id=video><span class=secno>4.8.6 </span>The <dfn><code>video</code></dfn> element</h4>
+ <h4 id=the-video-element><span class=secno>4.8.6 </span>The <dfn id=video><code>video</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -25283,13 +25277,13 @@
attribute DOMString <a href=#dom-video-poster title=dom-video-poster>poster</a>;
};</pre>
</dd>
- </dl><p>A <code><a href=#video>video</a></code> element is used for playing videos or
+ </dl><p>A <code><a href=#the-video-element>video</a></code> element is used for playing videos or
movies, and audio files with captions.</p>
- <p>Content may be provided inside the <code><a href=#video>video</a></code>
+ <p>Content may be provided inside the <code><a href=#the-video-element>video</a></code>
element<span class=impl>. User agents should not show this content
to the user</span>; it is intended for older Web browsers which do
- not support <code><a href=#video>video</a></code>, so that legacy video plugins can be
+ not support <code><a href=#the-video-element>video</a></code>, so that legacy video plugins can be
tried, or to show text to the users of these older browsers informing
them of how to access the video contents.</p>
@@ -25301,7 +25295,7 @@
subtitle tracks, audio description tracks, or sign-language
overlays) into their media streams.</p>
- <p>The <code><a href=#video>video</a></code> element is a <a href=#media-element>media element</a>
+ <p>The <code><a href=#the-video-element>video</a></code> element is a <a href=#media-element>media element</a>
whose <a href=#media-data>media data</a> is ostensibly video data, possibly
with associated audio data.</p>
@@ -25327,7 +25321,7 @@
URL. -->
<ol><li><p>If there is an existing instance of this algorithm running
- for this <code><a href=#video>video</a></code> element, abort that instance of this
+ for this <code><a href=#the-video-element>video</a></code> element, abort that instance of this
algorithm without changing the <a href=#poster-frame>poster frame</a>.</li>
<li><p>If the <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code>
@@ -25362,11 +25356,11 @@
<code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, or <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> but no video
data has yet been obtained at all, or the element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is any
subsequent value but the <a href=#media-resource>media resource</a> does not have a
- video channel), the <code><a href=#video>video</a></code> element
+ video channel), the <code><a href=#the-video-element>video</a></code> element
<a href=#represents>represents</a> either the <a href=#poster-frame>poster frame</a>, or
nothing.</p>
- <p>When a <code><a href=#video>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> and the <a href=#current-playback-position title="current
+ <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> and the <a href=#current-playback-position title="current
playback position">current playback position</a> is the first
frame of video, the element <a href=#represents>represents</a> either the frame
of video corresponding to the <a href=#current-playback-position title="current playback
@@ -25377,7 +25371,7 @@
be preferred over nothing, but the <a href=#poster-frame>poster frame</a> should
not be shown again after a frame of video has been shown.</p>
- <p>When a <code><a href=#video>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> at any other position, and
+ <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> at any other position, and
the <a href=#media-resource>media resource</a> has a video channel, the element
<a href=#represents>represents</a> the frame of video corresponding to the
<a href=#current-playback-position title="current playback position">current playback
@@ -25385,7 +25379,7 @@
video is seeking or buffering), the last frame of the video to have
been rendered.</p>
- <p>When a <code><a href=#video>video</a></code> element whose <a href=#media-resource>media
+ <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media
resource</a> has a video channel is <a href=#potentially-playing>potentially
playing</a>, it <a href=#represents>represents</a> the frame of video at the
continuously increasing <a href=#current-playback-position title="current playback
@@ -25399,7 +25393,7 @@
playback position</a>, at the element's <a href=#effective-media-volume>effective media
volume</a>.</p>
- <p>When a <code><a href=#video>video</a></code> element whose <a href=#media-resource>media
+ <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media
resource</a> has a video channel is neither <a href=#potentially-playing>potentially
playing</a> nor <a href=#dom-media-paused title=dom-media-paused>paused</a>
(e.g. when seeking or stalled), the element <a href=#represents>represents</a>
@@ -25409,7 +25403,7 @@
particular playback position is defined by the video stream's
format.</p>
- <p>The <code><a href=#video>video</a></code> element also <a href=#represents>represents</a> any
+ <p>The <code><a href=#the-video-element>video</a></code> element also <a href=#represents>represents</a> any
<a href=#text-track-cue title="text track cue">text track cues</a> whose
<a href=#text-track-cue-active-flag>text track cue active flag</a> is set and whose
<a href=#text-track>text track</a> is in the <a href=#text-track-showing title="text track
@@ -25460,7 +25454,7 @@
</div>
- <p>The <code><a href=#video>video</a></code> element supports <a href=#dimension-attributes>dimension
+ <p>The <code><a href=#the-video-element>video</a></code> element supports <a href=#dimension-attributes>dimension
attributes</a>.</p>
<div class=impl>
@@ -25479,13 +25473,13 @@
requirement can be implemented by using the <a href=#video-object-fit>style rule suggested in the rendering
section</a>.</p>
- <p>The intrinsic width of a <code><a href=#video>video</a></code> element's playback
+ <p>The intrinsic width of a <code><a href=#the-video-element>video</a></code> element's playback
area is the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic
width</a> of the video resource, if that is available; otherwise
it is the intrinsic width of the <a href=#poster-frame>poster frame</a>, if that
is available; otherwise it is 300 CSS pixels.</p>
- <p>The intrinsic height of a <code><a href=#video>video</a></code> element's playback
+ <p>The intrinsic height of a <code><a href=#the-video-element>video</a></code> element's playback
area is the <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic
height</a> of the video resource, if that is available; otherwise
it is the intrinsic height of the <a href=#poster-frame>poster frame</a>, if that
@@ -25578,7 +25572,7 @@
- <h4 id=audio><span class=secno>4.8.7 </span>The <dfn><code>audio</code></dfn> element</h4>
+ <h4 id=the-audio-element><span class=secno>4.8.7 </span>The <dfn id=audio><code>audio</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -25609,7 +25603,7 @@
NamedConstructor=<a href=#dom-audio-s title=dom-Audio-s>Audio</a>(in DOMString src)]
interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediaelement>HTMLMediaElement</a> {};</pre>
</dd>
- </dl><p>An <code><a href=#audio>audio</a></code> element <a href=#represents>represents</a> a sound or
+ </dl><p>An <code><a href=#the-audio-element>audio</a></code> element <a href=#represents>represents</a> a sound or
audio stream.</p>
<!-- v2 (actually v3) suggestions:
@@ -25629,10 +25623,10 @@
> Support very simple audio codecs, and programmable synthesizers.
-->
- <p>Content may be provided inside the <code><a href=#audio>audio</a></code>
+ <p>Content may be provided inside the <code><a href=#the-audio-element>audio</a></code>
element<span class=impl>. User agents should not show this content
to the user</span>; it is intended for older Web browsers which do
- not support <code><a href=#audio>audio</a></code>, so that legacy audio plugins can be
+ not support <code><a href=#the-audio-element>audio</a></code>, so that legacy audio plugins can be
tried, or to show text to the users of these older browsers informing
them of how to access the audio contents.</p>
@@ -25643,7 +25637,7 @@
embed accessibility aids (such as transcriptions) into their media
streams.</p>
- <p>The <code><a href=#audio>audio</a></code> element is a <a href=#media-element>media element</a>
+ <p>The <code><a href=#the-audio-element>audio</a></code> element is a <a href=#media-element>media element</a>
whose <a href=#media-data>media data</a> is ostensibly audio data.</p>
<p>The <code title=attr-media-src><a href=#attr-media-src>src</a></code>, <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>, <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>,
@@ -25654,12 +25648,12 @@
<div class=impl>
- <p>When an <code><a href=#audio>audio</a></code> element is <a href=#potentially-playing>potentially
+ <p>When an <code><a href=#the-audio-element>audio</a></code> element is <a href=#potentially-playing>potentially
playing</a>, it must have its audio data played synchronized with
the <a href=#current-playback-position>current playback position</a>, at the element's
<a href=#effective-media-volume>effective media volume</a>.</p>
- <p>When an <code><a href=#audio>audio</a></code> element is not <a href=#potentially-playing>potentially
+ <p>When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#potentially-playing>potentially
playing</a>, audio must not play for the element.</p>
</div>
@@ -25668,7 +25662,7 @@
<dd>
- <p>Returns a new <code><a href=#audio>audio</a></code> element, with the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute set to the value
+ <p>Returns a new <code><a href=#the-audio-element>audio</a></code> element, with the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute set to the value
passed in the argument, if applicable.</p>
</dd>
@@ -25679,7 +25673,7 @@
<code><a href=#htmlaudioelement>HTMLAudioElement</a></code> objects (in addition to the factory
methods from DOM Core such as <code title="">createElement()</code>): <dfn id=dom-audio title=dom-Audio><code>Audio()</code></dfn> and <dfn id=dom-audio-s title=dom-Audio-s><code>Audio(<var title="">src</var>)</code></dfn>. When invoked as constructors,
these must return a new <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> object (a new
- <code><a href=#audio>audio</a></code> element). The element must have its <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute set to the
+ <code><a href=#the-audio-element>audio</a></code> element). The element must have its <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute set to the
literal value "<code title=attr-media-preload-auto><a href=#attr-media-preload-auto>auto</a></code>". If the <var title="">src</var> argument is present, the object created must have
its <code title=attr-media-src><a href=#attr-media-src>src</a></code> content attribute set to
the provided value, and the user agent must invoke the object's
@@ -25758,7 +25752,7 @@
<p class=note>Dynamically modifying a <code><a href=#the-source-element>source</a></code> element
and its attribute when the element is already inserted in a
- <code><a href=#video>video</a></code> or <code><a href=#audio>audio</a></code> element will have no
+ <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code> element will have no
effect. To change what is playing, either just use the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute on the <a href=#media-element>media
element</a> directly, or call the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method on the <a href=#media-element>media
element</a> after manipulating the <code><a href=#the-source-element>source</a></code>
@@ -26092,7 +26086,7 @@
<h4 id=media-elements><span class=secno>4.8.10 </span>Media elements</h4>
<p><dfn id=media-element title="media element">Media elements</dfn>
- (<code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code>, in this specification)
+ (<code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code>, in this specification)
implement the following interface:</p>
<pre class=idl>interface <dfn id=htmlmediaelement>HTMLMediaElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
@@ -26214,11 +26208,11 @@
element's <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code>
attribute.</p>
- <p class=note>Both <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code>
+ <p class=note>Both <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code>
elements can be used for both audio and video. The main difference
- between the two is simply that the <code><a href=#audio>audio</a></code> element has no
+ between the two is simply that the <code><a href=#the-audio-element>audio</a></code> element has no
playback area for visual content (such as video or captions),
- whereas the <code><a href=#video>video</a></code> element does.</p>
+ whereas the <code><a href=#the-video-element>video</a></code> element does.</p>
<div class=impl>
@@ -26417,7 +26411,7 @@
agent knows it cannot render</a> or is the type
"<code>application/octet-stream</code>"; it must return "<code title="">probably</code>" if the user agent is confident that the
type represents a <a href=#media-resource>media resource</a> that it can render if
- used in with this <code><a href=#audio>audio</a></code> or <code><a href=#video>video</a></code> element;
+ used in with this <code><a href=#the-audio-element>audio</a></code> or <code><a href=#the-video-element>video</a></code> element;
and it must return "<code title="">maybe</code>" otherwise.
Implementors are encouraged to return "<code title="">maybe</code>"
unless the type can be confidently established as being supported or
@@ -26430,7 +26424,7 @@
<p>This script tests to see if the user agent supports a
(fictional) new format to dynamically decide whether to use a
- <code><a href=#video>video</a></code> element or a plugin:</p>
+ <code><a href=#the-video-element>video</a></code> element or a plugin:</p>
<pre><section id="video">
<p><a href="playing-cats.nfv">Download video</a></p>
@@ -27061,7 +27055,7 @@
</li>
- <li><p>For <code><a href=#video>video</a></code> elements, set the <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code> and <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code>
+ <li><p>For <code><a href=#the-video-element>video</a></code> elements, set the <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code> and <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code>
attributes.</li>
<li>
@@ -27725,7 +27719,7 @@
<dt><dfn id=dom-media-have_metadata title=dom-media-HAVE_METADATA><code>HAVE_METADATA</code></dfn> (numeric value 1)</dt>
<dd>Enough of the resource has been obtained that the duration of
- the resource is available. In the case of a <code><a href=#video>video</a></code>
+ the resource is available. In the case of a <code><a href=#the-video-element>video</a></code>
element, the dimensions of the video are also available. The API
will no longer raise an exception when seeking. No <a href=#media-data>media
data</a> is available for the immediate <a href=#current-playback-position>current playback
@@ -27791,7 +27785,7 @@
<p class=note>Before this task is run, as part of the event
loop mechanism, the rendering will have been updated to resize
- the <code><a href=#video>video</a></code> element if appropriate.</p>
+ the <code><a href=#the-video-element>video</a></code> element if appropriate.</p>
</dd>
@@ -29746,7 +29740,7 @@
<p>In this example, a sign-languge interpreter track from a movie
file is overlaid on the primary video track of that same video file
- using two <code><a href=#video>video</a></code> elements, some CSS, and an implicit
+ using two <code><a href=#the-video-element>video</a></code> elements, some CSS, and an implicit
<code><a href=#mediacontroller>MediaController</a></code>:</p>
<pre><article>
@@ -30986,7 +30980,7 @@
<div class=example>
- <p>In this example, an <code><a href=#audio>audio</a></code> element is used to play a
+ <p>In this example, an <code><a href=#the-audio-element>audio</a></code> element is used to play a
specific sound-effect from a sound file containing many sound
effects. A cue is used to pause the audio, so that it ends exactly
at the end of the clip, even if the browser is busy running some
@@ -33240,7 +33234,7 @@
</ol></div>
<p>The <dfn id=attr-media-muted title=attr-media-muted><code>muted</code></dfn>
- attribute on the <code><a href=#video>video</a></code> element controls the default
+ attribute on the <code><a href=#the-video-element>video</a></code> element controls the default
state of the audio channel of the <a href=#media-resource>media resource</a>,
potentially overriding user preferences.</p>
@@ -33512,7 +33506,7 @@
<h5 id=security-and-privacy-considerations><span class=secno>4.8.10.17 </span>Security and privacy considerations</h5>
<p>The main security and privacy implications of the
- <code><a href=#video>video</a></code> and <code><a href=#audio>audio</a></code> elements come from the
+ <code><a href=#the-video-element>video</a></code> and <code><a href=#the-audio-element>audio</a></code> elements come from the
ability to embed media cross-origin. There are two directions that
threats can flow: from hostile content to a victim page, and from a
hostile page to victim content.</p>
@@ -33526,7 +33520,7 @@
own unrelated <a href=#top-level-browsing-context>top-level browsing context</a>.</p>
<p class=example>For instance, if an SVG animation was embedded in
- a <code><a href=#video>video</a></code> element, the user agent would not give it
+ a <code><a href=#the-video-element>video</a></code> element, the user agent would not give it
access to the DOM of the outer page. From the perspective of scripts
in the SVG resource, the SVG file would appear to be in a lone
top-level browsing context with no parent.</p>
@@ -34811,7 +34805,7 @@
<code title="">repeat</code> is used.</p>
<p>If the first argument isn't an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#video>video</a></code> element, throws a
+ <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#the-video-element>video</a></code> element, throws a
<code><a href=#type_mismatch_err>TYPE_MISMATCH_ERR</a></code> exception. If the image has no
image data, throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception. If
the second argument isn't one of the allowed values, throws a
@@ -36312,7 +36306,7 @@
<p><img alt="The sx and sy parameters give the x and y coordinates of the source rectangle; the sw and sh arguments give the width and height of the source rectangle; the dx and dy give the x and y coordinates of the destination rectangle; and the dw and dh arguments give the width and height of the destination rectangle." height=356 src=<A HREF="http://images.whatwg.org/drawImage.png">http://images.whatwg.org/drawImage.png</A> width=356></p>
<p>If the first argument isn't an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#video>video</a></code> element, throws a
+ <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#the-video-element>video</a></code> element, throws a
<code><a href=#type_mismatch_err>TYPE_MISMATCH_ERR</a></code> exception. If the image has no
image data, throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception. If
the numeric arguments don't make sense (e.g. the destination is a
@@ -37705,7 +37699,7 @@
<p><span class=impl><strong>Author requirements</strong>:</span>
The <dfn id=attr-dim-width title=attr-dim-width><code>width</code></dfn> and <dfn id=attr-dim-height title=attr-dim-height><code>height</code></dfn> attributes on
<code><a href=#the-img-element>img</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>,
- <code><a href=#the-object-element>object</a></code>, <code><a href=#video>video</a></code>, and, when their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state,
+ <code><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, and, when their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state,
<code><a href=#the-input-element>input</a></code> elements may be specified to give the dimensions
of the visual content of the element (the width and height
respectively, relative to the nominal direction of the output
@@ -37752,12 +37746,12 @@
<p>The <dfn id=dom-dim-width title=dom-dim-width><code>width</code></dfn> and <dfn id=dom-dim-height title=dom-dim-height><code>height</code></dfn> IDL attributes on
the <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-object-element>object</a></code>,
- and <code><a href=#video>video</a></code> elements must <a href=#reflect>reflect</a> the
+ and <code><a href=#the-video-element>video</a></code> elements must <a href=#reflect>reflect</a> the
respective content attributes of the same name.</p>
<p class=note>For <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, and
<code><a href=#the-object-element>object</a></code> the IDL attributes are <code>DOMString</code>;
- for <code><a href=#video>video</a></code> the IDL attributes are <code>unsigned
+ for <code><a href=#the-video-element>video</a></code> the IDL attributes are <code>unsigned
long</code>.</p>
</div>
@@ -46539,9 +46533,9 @@
something like <samp>The text you have entered does not match the
required pattern. Birthday</samp>, which is not useful.</p>
- <p>UAs may still show the <code><a href=#the-title-element-0>title</a></code> in non-error situations
+ <p>UAs may still show the <code><a href=#the-title-element>title</a></code> in non-error situations
(for example, as a tooltip when hovering over the control), so
- authors should be careful not to word <code><a href=#the-title-element-0>title</a></code>s as if an
+ authors should be careful not to word <code><a href=#the-title-element>title</a></code>s as if an
error has necessarily occurred.</p>
@@ -51522,7 +51516,7 @@
- <h4 id=the-command><span class=secno>4.11.3 </span>The <dfn><code>command</code></dfn> element</h4>
+ <h4 id=the-command-element><span class=secno>4.11.3 </span>The <dfn id=the-command><code>command</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -51555,11 +51549,11 @@
attribute boolean <span title="dom-command-default">default</span>;-->
};</pre>
</dd>
- </dl><p>The <code><a href=#the-command>command</a></code> element represents a command that the user
+ </dl><p>The <code><a href=#the-command-element>command</a></code> element represents a command that the user
can invoke.</p>
<p>A command can be part of a context menu or toolbar, using the
- <code><a href=#menus>menu</a></code> element, or can be put anywhere else in the page,
+ <code><a href=#the-menu-element>menu</a></code> element, or can be put anywhere else in the page,
to define a keyboard shortcut.</p> <!-- in the future we'll also add
a command="" attribute to refer to a command, which can then be
defined anywhere -->
@@ -51693,7 +51687,7 @@
<dd><p>If the element has a parent, then the UA must walk the list
of child nodes of that parent element, and for each node that is a
- <code><a href=#the-command>command</a></code> element, if that element has a <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attribute whose
+ <code><a href=#the-command-element>command</a></code> element, if that element has a <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attribute whose
value exactly matches the current element's (treating missing <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attributes as if
they were the empty string), and has a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, must remove
that attribute.</p>
@@ -51719,8 +51713,8 @@
</div>
- <p class=note><code><a href=#the-command>command</a></code> elements are not rendered
- unless they <a href=#menus title=menu>form part of a menu</a>.</p>
+ <p class=note><code><a href=#the-command-element>command</a></code> elements are not rendered
+ unless they <a href=#the-menu-element title=menu>form part of a menu</a>.</p>
<div class=example>
@@ -51746,7 +51740,7 @@
- <h4 id=menus><span class=secno>4.11.4 </span>The <dfn><code>menu</code></dfn> element</h4>
+ <h4 id=the-menu-element><span class=secno>4.11.4 </span>The <dfn id=menus><code>menu</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -51766,7 +51760,7 @@
attribute DOMString <a href=#dom-menu-type title=dom-menu-type>type</a>;
attribute DOMString <a href=#dom-menu-label title=dom-menu-label>label</a>;
};</pre>
- </dl><p>The <code><a href=#menus>menu</a></code> element represents a list of commands.</p>
+ </dl><p>The <code><a href=#the-menu-element>menu</a></code> element represents a list of commands.</p>
<!-- v2 idea: <menu> should get an icon, like <command> -->
@@ -51782,16 +51776,16 @@
a list of commands that is neither declaring a context menu nor
defining a toolbar.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#context-menu-state title="context menu state">context menu</a> state, then the
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#context-menu-state title="context menu state">context menu</a> state, then the
element <a href=#represents>represents</a> the commands of a context menu, and
the user can only interact with the commands if that context menu is
activated.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the element
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the element
<a href=#represents>represents</a> a list of active commands that the user can
immediately interact with.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#list-state title="list state">list</a> state, then the element either
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#list-state title="list state">list</a> state, then the element either
<a href=#represents>represents</a> an unordered list of items (each represented
by an <code><a href=#the-li-element>li</a></code> element), each of which represents a command
that the user can perform or activate, or, if the element has no
@@ -51818,7 +51812,7 @@
<p><i>This section is non-normative.</i></p>
- <p>The <code><a href=#menus>menu</a></code> element is used to define context menus and
+ <p>The <code><a href=#the-menu-element>menu</a></code> element is used to define context menus and
toolbars.</p>
<p>For example, the following represents a toolbar with three menu
@@ -51882,7 +51876,7 @@
above, but here the legacy behavior consists of a single
<code><a href=#the-select-element>select</a></code> element with a submit button. The submit button
doesn't appear in the toolbar, because it is not a direct child of
- the <code><a href=#menus>menu</a></code> element or of its <code><a href=#the-li-element>li</a></code>
+ the <code><a href=#the-menu-element>menu</a></code> element or of its <code><a href=#the-li-element>li</a></code>
children.</p>
@@ -51897,7 +51891,7 @@
<ul class=brief><li><a href=#concept-command title=concept-command>Commands</a>, which can be marked as default commands</li>
<li>Separators</li>
<li>Other menus (which allows the list to be nested)</li>
- </ul><p>The list corresponding to a particular <code><a href=#menus>menu</a></code> element
+ </ul><p>The list corresponding to a particular <code><a href=#the-menu-element>menu</a></code> element
is built by iterating over its child nodes. For each child node in
<a href=#tree-order>tree order</a>, the required behavior depends on what the
node is, as follows:</p>
@@ -51933,17 +51927,17 @@
<dd>Iterate over the children of the element.</dd>
- <dt>A <code><a href=#menus>menu</a></code> element with no <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
+ <dt>A <code><a href=#the-menu-element>menu</a></code> element with no <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dt>A <code><a href=#the-select-element>select</a></code> element</dt>
<dd>Append a separator to the menu, then iterate over the children
- of the <code><a href=#menus>menu</a></code> or <code><a href=#the-select-element>select</a></code> element, then
+ of the <code><a href=#the-menu-element>menu</a></code> or <code><a href=#the-select-element>select</a></code> element, then
append another separator.</dd>
<!-- v2: we might want to support <select> in <label> as giving a named submenu -->
- <dt>A <code><a href=#menus>menu</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
+ <dt>A <code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dt>An <code><a href=#the-optgroup-element>optgroup</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dd>Append a submenu to the menu, using the value of the element's
@@ -51978,11 +51972,11 @@
<p>The <dfn id=attr-contextmenu title=attr-contextmenu><code>contextmenu</code></dfn>
attribute gives the element's <a href=#context-menus title="context menus">context
- menu</a>. The value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#menus>menu</a></code> element
+ menu</a>. The value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#the-menu-element>menu</a></code> element
in the DOM. <span class=impl>If the node that would be obtained by
the invoking the <code title=dom-Document-getElementById><a href=#dom-document-getelementbyid>getElementById()</a></code> method
using the attribute's value as the only argument is null or not a
- <code><a href=#menus>menu</a></code> element, then the element has no assigned context
+ <code><a href=#the-menu-element>menu</a></code> element, then the element has no assigned context
menu. Otherwise, the element's assigned context menu is the element
so identified.</span></p>
@@ -52023,13 +52017,13 @@
<p>If the element or one of its ancestors <em>does</em> have a
context menu assigned, then the user agent must <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-show>show</code> at the
- <code><a href=#menus>menu</a></code> element of the context menu of the nearest
+ <code><a href=#the-menu-element>menu</a></code> element of the context menu of the nearest
ancestor (including the element itself) with one assigned.</p>
<!-- v2: include modifier key information -->
<p>The default action of <em>this</em> event is that the user agent
must show a context menu <a href=#building-menus-and-toolbars title="building menus and
- toolbars">built</a> from the <code><a href=#menus>menu</a></code> element.</p>
+ toolbars">built</a> from the <code><a href=#the-menu-element>menu</a></code> element.</p>
<p>The user agent may also provide access to its default context
menu, if any, with the context menu shown. For example, it could
@@ -52083,13 +52077,13 @@
<h5 id=toolbars><span class=secno>4.11.4.4 </span><dfn>Toolbars</dfn></h5>
- <p>When a <code><a href=#menus>menu</a></code> element has a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the user agent
+ <p>When a <code><a href=#the-menu-element>menu</a></code> element has a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the user agent
must <a href=#building-menus-and-toolbars title="building menus and toolbars">build</a> the
- menu for that <code><a href=#menus>menu</a></code> element, and use the result in the
+ menu for that <code><a href=#the-menu-element>menu</a></code> element, and use the result in the
rendering.</p>
<p>The user agent must reflect changes made to the
- <code><a href=#menus>menu</a></code>'s DOM, by immediately <a href=#building-menus-and-toolbars title="building menus
+ <code><a href=#the-menu-element>menu</a></code>'s DOM, by immediately <a href=#building-menus-and-toolbars title="building menus
and toolbars">rebuilding</a> the menu.</p>
</div>
@@ -52289,7 +52283,7 @@
not specify an icon, or if the element does not define a command,
then the attribute must return null. This attribute will be shadowed
by the <code title=dom-command-icon><a href=#dom-command-icon>icon</a></code> IDL attribute on
- <code><a href=#the-command>command</a></code> elements.</p>
+ <code><a href=#the-command-element>command</a></code> elements.</p>
<p>The <dfn id=dom-command-ro-disabled title=dom-command-ro-disabled><code>disabled</code></dfn>
attribute must return true if the command's <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> is that
@@ -52303,7 +52297,7 @@
command is checked, and false if it is that the command is not
checked. If the element does not define a command, the attribute
must return false. This attribute will be shadowed by the <code title="">checked</code> IDL attribute on <code><a href=#the-input-element>input</a></code> and
- <code><a href=#the-command>command</a></code> elements.</p>
+ <code><a href=#the-command-element>command</a></code> elements.</p>
<!--v2COMMAND
<p>The <dfn
@@ -52533,10 +52527,10 @@
<h5 id=using-the-command-element-to-define-a-command><span class=secno>4.11.5.5 </span>Using the <dfn title=command-element><code>command</code></dfn> element to define
a command</h5>
- <p>A <code><a href=#the-command>command</a></code> element <a href=#concept-command title=concept-command>defines a command</a>.</p>
+ <p>A <code><a href=#the-command-element>command</a></code> element <a href=#concept-command title=concept-command>defines a command</a>.</p>
<p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command
- is "radio" if the <code><a href=#the-command>command</a></code>'s <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is
+ is "radio" if the <code><a href=#the-command-element>command</a></code>'s <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is
"<code>radio</code>", "checkbox" if the attribute's value is
"<code>checkbox</code>", and "command" otherwise.</p>
@@ -54518,7 +54512,7 @@
<li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a>, <a href=#image-button-state title=attr-input-type-image>Image Button</a>, <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>, or <a href=#button-state title=attr-input-type-button>Button</a> state</li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li>elements that are <a href=#specially-focusable>specially focusable</a></li>
@@ -54577,10 +54571,10 @@
<li><code><a href=#the-option-element>option</a></code> elements that are not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li><code><a href=#the-li-element>li</a></code> elements that are children of
- <code><a href=#menus>menu</a></code> elements, and that have a child element that
+ <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that
defines a <a href=#concept-command title=concept-command>command</a>, if the
first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet
is false (not disabled)</li>
@@ -54610,10 +54604,10 @@
<li><code><a href=#the-option-element>option</a></code> elements that are <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li><code><a href=#the-li-element>li</a></code> elements that are children of
- <code><a href=#menus>menu</a></code> elements, and that have a child element that
+ <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that
defines a <a href=#concept-command title=concept-command>command</a>, if the
first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet
is true (disabled)</li>
@@ -54642,11 +54636,11 @@
<li><code><a href=#the-option-element>option</a></code> elements whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is
true</li>
- <li><code><a href=#the-command>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state
+ <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state
and that have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code>
attribute</li>
- <li><code><a href=#the-command>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state and that
+ <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state and that
have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code>
attribute</li>
@@ -55621,15 +55615,15 @@
created by the element.</dd>
- <dt>If the element is a <code><a href=#meta>meta</a></code> element</dt>
+ <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt>
<dd><p>The value is the value of the element's <code title=attr-content>content</code> attribute, if any, or the empty
string if there is no such attribute.</dd>
- <dt>If the element is an <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>,
- <code><a href=#the-track-element>track</a></code>, or <code><a href=#video>video</a></code> element</dt>
+ <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt>
<dd><p>The value is the <a href=#absolute-url>absolute URL</a> that results from
<a href=#resolve-a-url title="resolve a url">resolving</a> the value of the
@@ -55671,10 +55665,10 @@
<code><a href=#textcontent>textContent</a></code>.</dd>
</dl><p>The <dfn id=url-property-elements>URL property elements</dfn> are the <code><a href=#the-a-element>a</a></code>,
- <code><a href=#the-area-element>area</a></code>, <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <code><a href=#the-area-element>area</a></code>, <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-link-element>link</a></code>,
<code><a href=#the-object-element>object</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, and
- <code><a href=#video>video</a></code> elements.</p>
+ <code><a href=#the-video-element>video</a></code> elements.</p>
<p>If a property's <a href=#concept-property-value title=concept-property-value>value</a>
is an <a href=#absolute-url>absolute URL</a>, the property must be specified
@@ -55932,15 +55926,15 @@
setting.</p>
- <dt>If the element is a <code><a href=#meta>meta</a></code> element</dt>
+ <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt>
<dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> content
attribute.</dd>
- <dt>If the element is an <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>,
- <code><a href=#the-track-element>track</a></code>, or <code><a href=#video>video</a></code> element</dt>
+ <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt>
<dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title="">src</code> content attribute.</dd>
@@ -57116,10 +57110,10 @@
text string</a> that is <a href="#the-document's-current-address">the document's current
address</a> as the value to <var title="">output</var>.</li>
- <li><p>If <a href=#the-title-element>the <code>title</code> element</a> is not null,
+ <li><p>If <a href=#the-title-element-0>the <code>title</code> element</a> is not null,
<a href=#add-a-vcard-line>add a vCard line</a> with the type "<code title="">NAME</code>" and with the result of <a href=#escaping-the-vcard-text-string>escaping the
vCard text string</a> obtained from the <code><a href=#textcontent>textContent</a></code>
- of <a href=#the-title-element>the <code>title</code> element</a> as the value to <var title="">output</var>.</li>
+ of <a href=#the-title-element-0>the <code>title</code> element</a> as the value to <var title="">output</var>.</li>
<li><p>If <var title="">node</var> has a <a href=#global-identifier>global
identifier</a>, <a href=#add-a-vcard-line>add a vCard line</a> with the type
@@ -58632,12 +58626,12 @@
<ol><li>
- <p>If <a href=#the-title-element>the <code>title</code> element</a> is not null,
+ <p>If <a href=#the-title-element-0>the <code>title</code> element</a> is not null,
then generate the following triple:</p>
<dl class=triple><dt>subject <dd> <a href="#the-document's-current-address">the document's current address</a>
<dt>predicate <dd> <code title=""><A HREF="http://purl.org/dc/terms/title</code">http://purl.org/dc/terms/title</code</A>>
- <dt>object <dd> the concatenation of the data of all the child <a href=#text-node title="text node">text nodes</a> of <a href=#the-title-element>the <code>title</code> element</a>, in <a href=#tree-order>tree order</a>, as a plain literal, with the language information set from the <a href=#language>language</a> of <a href=#the-title-element>the <code>title</code> element</a>, if it is not unknown.
+ <dt>object <dd> the concatenation of the data of all the child <a href=#text-node title="text node">text nodes</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, in <a href=#tree-order>tree order</a>, as a plain literal, with the language information set from the <a href=#language>language</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, if it is not unknown.
</dl></li>
@@ -58692,7 +58686,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element in the <code><a href=#document>Document</a></code>
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element in the <code><a href=#document>Document</a></code>
that has a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and
a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, if the
value of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute
@@ -58702,7 +58696,7 @@
<dl class=triple><dt>subject <dd> <a href="#the-document's-current-address">the document's current address</a>
<dt>predicate <dd> the concatenation of the string "<code title=""><A HREF="http://www.w3.org/1999/xhtml/vocab#</code">http://www.w3.org/1999/xhtml/vocab#</code</A>>" and the value of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, with any characters in the value that are not valid in the <ifragment> production of the IRI syntax being %-escaped <a href=#refsRFC3987>[RFC3987]</a>
<dt>object <dd> the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, as a plain literal, with the language information set from the <a href=#language>language</a> of the element, if it is not unknown
- </dl><p>For each <code><a href=#meta>meta</a></code> element in the <code><a href=#document>Document</a></code>
+ </dl><p>For each <code><a href=#the-meta-element>meta</a></code> element in the <code><a href=#document>Document</a></code>
that has a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and
a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, if the
value of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute is
@@ -59052,7 +59046,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is <code title=meta-author><a href=#meta-author>author</a></code>, run the following substeps:</p>
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is <code title=meta-author><a href=#meta-author>author</a></code>, run the following substeps:</p>
<ol><li><p>Append an <code title="">author</code> element in the
<a href=#atom-namespace>Atom namespace</a> to the root element of <var title="">R</var>.</li>
@@ -59062,7 +59056,7 @@
previous step.</p>
<li><p>Append a text node whose data is the value of the
- <code><a href=#meta>meta</a></code> element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute to the element
+ <code><a href=#the-meta-element>meta</a></code> element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute to the element
created in the previous step.</li>
</ol><!-- could use vCards instead, and get <atom:email> and <atom:uri>
@@ -59145,7 +59139,7 @@
<dd>
<p>Let <var title="">heading content</var> be the descendants of
- <a href=#the-title-element>the <code>title</code> element</a>, if there is one, or
+ <a href=#the-title-element-0>the <code>title</code> element</a>, if there is one, or
an empty list otherwise.</p>
</dd>
@@ -59681,7 +59675,7 @@
whose <a href="#the-document's-address" title="the document's address">address</a> is
<code><a href=#about:blank>about:blank</a></code>, which is marked as being an <a href=#html-documents title="HTML documents">HTML document</a>, and whose <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> is
UTF-8. The <code><a href=#document>Document</a></code> must have a single child
- <code><a href=#the-html-element-0>html</a></code> node, which itself has a single child
+ <code><a href=#the-html-element>html</a></code> node, which itself has a single child
<code><a href=#the-body-element-0>body</a></code> node.</p>
<p class=note>If the <a href=#browsing-context>browsing context</a> is created
@@ -60991,10 +60985,10 @@
origin</a> of a script are determined from another resource,
called the <i>owner</i>:</p>
- <dl class=switch><dt>If a script is in a <code><a href=#script>script</a></code> element</dt>
+ <dl class=switch><dt>If a script is in a <code><a href=#the-script-element>script</a></code> element</dt>
<dd>The owner is the <code><a href=#document>Document</a></code> to which the
- <code><a href=#script>script</a></code> element belongs.</dd>
+ <code><a href=#the-script-element>script</a></code> element belongs.</dd>
<dt>If a script is in an <a href=#event-handler-content-attributes title="event handler content
@@ -61148,7 +61142,7 @@
</dd>
- <dt>For <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code> elements</dt>
+ <dt>For <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements</dt>
<dd>
@@ -61463,7 +61457,7 @@
<p class=note>Titles associated with <a href=#session-history-entry title="session history
entry">session history entries</a> need not have any relation
- with the current <code><a href=#the-title-element-0>title</a></code> of the
+ with the current <code><a href=#the-title-element>title</a></code> of the
<code><a href=#document>Document</a></code>. The title of a <a href=#session-history-entry>session history
entry</a> is intended to explain the state of the document at
that point, so that the user can navigate the document's
@@ -61921,8 +61915,8 @@
<p>Applications might not use the same title for a <a href=#session-history-entry>session
history entry</a> as the value of the document's
- <code><a href=#the-title-element-0>title</a></code> element at that time. For example, here is a
- simple page that shows a block in the <code><a href=#the-title-element-0>title</a></code> element.
+ <code><a href=#the-title-element>title</a></code> element at that time. For example, here is a
+ simple page that shows a block in the <code><a href=#the-title-element>title</a></code> element.
Clearly, when navigating backwards to a previous state the user
does not go back in time, and therefore it would be inappropriate
to put the time in the session history title.</p>
@@ -62800,7 +62794,7 @@
character encoding.</p>
<p>If the root element, as parsed according to the XML
- specifications cited above, is found to be an <code><a href=#the-html-element-0>html</a></code>
+ specifications cited above, is found to be an <code><a href=#the-html-element>html</a></code>
element with an attribute <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> whose value is not the
empty string, then, as soon as the element is <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into the document</a>, the user
@@ -62887,9 +62881,9 @@
before the page has finished parsing, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, e.g. linking to a style sheet or an XBL
- binding, providing script, giving the document a <code><a href=#the-title-element-0>title</a></code>,
+ binding, providing script, giving the document a <code><a href=#the-title-element>title</a></code>,
etc.</p>
<p class=note>In particular, if the user agent supports the <code title="">Format=Flowed</code> feature of RFC 3676 then the user
@@ -62906,9 +62900,9 @@
<p>When an image resource is to be loaded in a <a href=#browsing-context>browsing
context</a>, the user agent should <a href=#create-a-document-object>create a
<code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, append an
- <code><a href=#the-html-element-0>html</a></code> element to the <code><a href=#document>Document</a></code>, append a
- <code><a href=#the-head-element-0>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element to the
- <code><a href=#the-html-element-0>html</a></code> element, append an <code><a href=#the-img-element>img</a></code> to the
+ <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>, append a
+ <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element to the
+ <code><a href=#the-html-element>html</a></code> element, append an <code><a href=#the-img-element>img</a></code> to the
<code><a href=#the-body-element-0>body</a></code> element, and set the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of the <code><a href=#the-img-element>img</a></code>
element to the address of the image.</p>
@@ -62927,10 +62921,10 @@
before the page has finished fully loading, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, or attributes to the <code><a href=#the-img-element>img</a></code>
element, e.g. to link to a style sheet or an XBL binding, to provide
- a script, to give the document a <code><a href=#the-title-element-0>title</a></code>, etc.</p>
+ a script, to give the document a <code><a href=#the-title-element>title</a></code>, etc.</p>
<h4 id=read-plugin><span class=secno>6.5.6 </span><dfn title=navigate-plugin>Page load processing model for content that uses plugins</dfn></h4>
@@ -62939,9 +62933,9 @@
is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent
should <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it
as being an <a href=#html-documents title="HTML documents">HTML document</a>,
- append an <code><a href=#the-html-element-0>html</a></code> element to the <code><a href=#document>Document</a></code>,
- append a <code><a href=#the-head-element-0>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element
- to the <code><a href=#the-html-element-0>html</a></code> element, append an <code><a href=#the-embed-element>embed</a></code> to
+ append an <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>,
+ append a <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element
+ to the <code><a href=#the-html-element>html</a></code> element, append an <code><a href=#the-embed-element>embed</a></code> to
the <code><a href=#the-body-element-0>body</a></code> element, and set the <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute of the
<code><a href=#the-embed-element>embed</a></code> element to the address of the resource.</p>
@@ -62960,10 +62954,10 @@
before the page has finished fully loading, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, or attributes to the <code><a href=#the-embed-element>embed</a></code>
element, e.g. to link to a style sheet or an XBL binding, or to give
- the document a <code><a href=#the-title-element-0>title</a></code>.</p>
+ the document a <code><a href=#the-title-element>title</a></code>.</p>
<p class=note id=sandboxPluginNavigate>If the <a href=#sandboxed-plugins-browsing-context-flag>sandboxed
plugins browsing context flag</a> was set on the <a href=#browsing-context>browsing
@@ -63806,7 +63800,7 @@
<dt><dfn id=concept-appcache-manifest title=concept-appcache-manifest>The manifest</dfn>
<dd><p class=note>This is the resource corresponding to the URL
- that was given in a master entry's <code><a href=#the-html-element-0>html</a></code> element's
+ that was given in a master entry's <code><a href=#the-html-element>html</a></code> element's
<code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute. The
manifest is fetched and processed during the <a href=#application-cache-download-process>application
cache download process</a>. All the <a href=#concept-appcache-master title=concept-appcache-master>master entries</a> have the
@@ -65015,7 +65009,7 @@
entry</a>.</li>
<li><p>As an optimization, if the resource is an HTML or XML file
- whose root element is an <code><a href=#the-html-element-0>html</a></code> element with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value
+ whose root element is an <code><a href=#the-html-element>html</a></code> element with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value
doesn't match the manifest URL of the application cache being
processed, then the user agent should mark the entry as being
<a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>.</p>
@@ -65770,7 +65764,7 @@
run in the context of a document. These mechanisms include, but are
probably not limited to:</p>
- <ul><li>Processing of <code><a href=#script>script</a></code> elements.</li>
+ <ul><li>Processing of <code><a href=#the-script-element>script</a></code> elements.</li>
<li>Processing of inline <code title="javascript
protocol"><a href=#javascript-protocol>javascript:</a></code> URLs (e.g. the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of <code><a href=#the-img-element>img</a></code>
@@ -68802,7 +68796,7 @@
<li><code><a href=#the-textarea-element>textarea</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li>Elements with a <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code>
attribute set, if that would enable the user agent to allow the
@@ -72983,8 +72977,8 @@
receiving streams from remote peers.</li>
<li>Displaying such streams (both the locally-produced ones and the
- remotely-obtained ones) locally using the <code><a href=#video>video</a></code> or
- <code><a href=#audio>audio</a></code> elements.</li>
+ remotely-obtained ones) locally using the <code><a href=#the-video-element>video</a></code> or
+ <code><a href=#the-audio-element>audio</a></code> elements.</li>
<li>Sending arbitrary data to remote peers.</li>
@@ -73535,8 +73529,8 @@
<li><p>Return, and run the remaining steps asynchronously.</li>
<li><p>Generate a file that containing <var title="">data</var> in
- a format supported by the user agent for use in <code><a href=#audio>audio</a></code>
- and <code><a href=#video>video</a></code> elements.</li>
+ a format supported by the user agent for use in <code><a href=#the-audio-element>audio</a></code>
+ and <code><a href=#the-video-element>video</a></code> elements.</li>
<li><p>Let <var title="">blob</var> be a <code>Blob</code> object
representing the contents of the file generated in the previous
@@ -73634,7 +73628,7 @@
<p>For audio and video streams, the data exposed on that stream must
be in a format supported by the user agent for use in
- <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code> elements.</p>
+ <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements.</p>
<p class=bookkeeping>A <dfn id=blob-url>Blob URL</dfn> is the same as what the
File API specification calls a <span>Blob URI</span>, except that
@@ -74086,13 +74080,13 @@
<p>User agents may negotiate any codec and any resolution, bitrate,
or other quality metric. User agents are encouraged to initially
negotiate for the native resolution of the stream. For streams that
- are then rendered (using a <code><a href=#video>video</a></code> element), user agents
+ are then rendered (using a <code><a href=#the-video-element>video</a></code> element), user agents
are encouraged to renegotiate for a resolution that matches the
rendered display size.</p>
<p class=note>Starting with the native resolution means that if
the Web application notifies its peer of the native resolution as it
- starts sending data, and the peer prepares its <code><a href=#video>video</a></code>
+ starts sending data, and the peer prepares its <code><a href=#the-video-element>video</a></code>
element accordingly, there will be no need for a renegotiation once
the stream is flowing.</p>
@@ -75998,8 +75992,8 @@
<p>Let <var title="">language</var> be JavaScript.</p>
- <p class=note>As with <code><a href=#script>script</a></code> elements, the MIME
- type of the script is ignored. Unlike with <code><a href=#script>script</a></code>
+ <p class=note>As with <code><a href=#the-script-element>script</a></code> elements, the MIME
+ type of the script is ignored. Unlike with <code><a href=#the-script-element>script</a></code>
elements, there is no way to override the type. It's always
assumed to be JavaScript.</p>
@@ -79630,7 +79624,7 @@
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
- <li>The root element, in the form of an <code><a href=#the-html-element-0>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
+ <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
@@ -79644,19 +79638,19 @@
<div class=note>
- <p>Space characters before the root <code><a href=#the-html-element-0>html</a></code> element, and
- space characters at the start of the <code><a href=#the-html-element-0>html</a></code> element and
- before the <code><a href=#the-head-element-0>head</a></code> element, will be dropped when the
+ <p>Space characters before the root <code><a href=#the-html-element>html</a></code> element, and
+ space characters at the start of the <code><a href=#the-html-element>html</a></code> element and
+ before the <code><a href=#the-head-element>head</a></code> element, will be dropped when the
document is parsed; space characters <em>after</em> the root
- <code><a href=#the-html-element-0>html</a></code> element will be parsed as if they were at the end
+ <code><a href=#the-html-element>html</a></code> element will be parsed as if they were at the end
of the <code><a href=#the-body-element-0>body</a></code> element. Thus, space characters around the
root element do not round-trip.</p>
<p>It is suggested that newlines be inserted after the DOCTYPE,
after any comments that are before the root element, after the
- <code><a href=#the-html-element-0>html</a></code> element's start tag (if it is not <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>), and after any comments
- that are inside the <code><a href=#the-html-element-0>html</a></code> element but before the
- <code><a href=#the-head-element-0>head</a></code> element.</p>
+ <code><a href=#the-html-element>html</a></code> element's start tag (if it is not <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>), and after any comments
+ that are inside the <code><a href=#the-html-element>html</a></code> element but before the
+ <code><a href=#the-head-element>head</a></code> element.</p>
</div>
@@ -79761,21 +79755,21 @@
<dl><dt><dfn id=void-elements>Void elements</dfn></dt>
<dd><code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-br-element>br</a></code>,
- <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command>command</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
- <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#meta>meta</a></code>,
+ <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>,
<code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>,
<code><a href=#the-wbr-element>wbr</a></code></dd>
<!-- see also other places that say VOIDLIST -->
<dt><dfn id=raw-text-elements>Raw text elements</dfn></dt>
- <dd><code><a href=#script>script</a></code>, <code><a href=#the-style-element>style</a></code></dd> <!-- iframe and
+ <dd><code><a href=#the-script-element>script</a></code>, <code><a href=#the-style-element>style</a></code></dd> <!-- iframe and
noscript don't count as raw text for syntax purposes -->
<dt><dfn id=rcdata-elements>RCDATA elements</dfn></dt>
- <dd><code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-title-element-0>title</a></code></dd>
+ <dd><code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-title-element>title</a></code></dd>
<dt><dfn id=foreign-elements>Foreign elements</dfn></dt>
@@ -80129,34 +80123,34 @@
<p class=note>Omitting an element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> does not mean the element
is not present; it is implied, but it is still there. An HTML
- document always has a root <code><a href=#the-html-element-0>html</a></code> element, even if the
+ document always has a root <code><a href=#the-html-element>html</a></code> element, even if the
string <code title=""><html></code> doesn't appear anywhere in
the markup.</p>
<!-- <html> -->
- <p>An <code><a href=#the-html-element-0>html</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
- first thing inside the <code><a href=#the-html-element-0>html</a></code> element is not a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
+ <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
+ first thing inside the <code><a href=#the-html-element>html</a></code> element is not a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- </html> -->
- <p>An <code><a href=#the-html-element-0>html</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
- tag</a> may be omitted if the <code><a href=#the-html-element-0>html</a></code> element is not
+ <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
+ tag</a> may be omitted if the <code><a href=#the-html-element>html</a></code> element is not
immediately followed by a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- <head> -->
- <p>A <code><a href=#the-head-element-0>head</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
+ <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
element is empty, or if the first thing inside the
- <code><a href=#the-head-element-0>head</a></code> element is an element.</p>
+ <code><a href=#the-head-element>head</a></code> element is an element.</p>
<!-- </head> -->
- <p>A <code><a href=#the-head-element-0>head</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
- tag</a> may be omitted if the <code><a href=#the-head-element-0>head</a></code> element is not
+ <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
+ tag</a> may be omitted if the <code><a href=#the-head-element>head</a></code> element is not
immediately followed by a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- <body> -->
<p>A <code><a href=#the-body-element-0>body</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
element is empty, or if the first thing inside the <code><a href=#the-body-element-0>body</a></code>
element is not a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>, except if the first thing
- inside the <code><a href=#the-body-element-0>body</a></code> element is a <code><a href=#script>script</a></code> or
+ inside the <code><a href=#the-body-element-0>body</a></code> element is a <code><a href=#the-script-element>script</a></code> or
<code><a href=#the-style-element>style</a></code> element. <!-- Note that even if the </head> end
tag is present, the parser makes <style> and <script> elements
between </head> and <body> end up in the <head> instead of implying
@@ -80195,7 +80189,7 @@
<code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-header-element>header</a></code>,
- <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#menus>menu</a></code>,
+ <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-menu-element>menu</a></code>,
<code><a href=#the-nav-element>nav</a></code>, <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-pre-element>pre</a></code>,
<code><a href=#the-section-element>section</a></code>, <code><a href=#the-table-element>table</a></code>, or <code><a href=#the-ul-element>ul</a></code>,
element, or if there is no more content in the parent element and
@@ -81479,7 +81473,7 @@
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" and abort these
steps.</li>
- <li>If <var title="">node</var> is a <code><a href=#the-head-element-0>head</a></code> element,
+ <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element,
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" ("<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"! <em> not "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>"</em>!) and abort
these steps. (<a href=#fragment-case>fragment case</a>)</li> <!-- This is only
here for now in case people think that the spec accidentally
@@ -81501,7 +81495,7 @@
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" and abort
these steps. (<a href=#fragment-case>fragment case</a>)</li>
- <li>If <var title="">node</var> is an <code><a href=#the-html-element-0>html</a></code> element,
+ <li>If <var title="">node</var> is an <code><a href=#the-html-element>html</a></code> element,
then <!--: if the <span><code title="">head</code> element
pointer</span> is null,--> switch the <a href=#insertion-mode>insertion mode</a>
to "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before
@@ -81532,17 +81526,17 @@
<p>The "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before
html</a>" <a href=#insertion-mode>insertion mode</a> creates the
- <code><a href=#the-html-element-0>html</a></code> root element node, which is then added to the
+ <code><a href=#the-html-element>html</a></code> root element node, which is then added to the
stack.</p>
<p>In the <a href=#fragment-case>fragment case</a>, the <a href=#stack-of-open-elements>stack of open
- elements</a> is initialized to contain an <code><a href=#the-html-element-0>html</a></code>
+ elements</a> is initialized to contain an <code><a href=#the-html-element>html</a></code>
element that is created as part of <a href=#html-fragment-parsing-algorithm title="html fragment
parsing algorithm">that algorithm</a>. (The <a href=#fragment-case>fragment
case</a> skips the "<a href=#the-before-html-insertion-mode title="insertion mode: before
html">before html</a>" <a href=#insertion-mode>insertion mode</a>.)</p>
- <p>The <code><a href=#the-html-element-0>html</a></code> node, however it is created, is the topmost
+ <p>The <code><a href=#the-html-element>html</a></code> node, however it is created, is the topmost
node of the stack. It only gets popped off the stack when the parser
<a href=#stop-parsing title="stop parsing">finishes</a>.</p>
@@ -81554,7 +81548,7 @@
one. If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
open elements</a> (<a href=#fragment-case>fragment case</a>), then the
<a href=#current-table>current table</a> is the first element in the <a href=#stack-of-open-elements>stack
- of open elements</a> (the <code><a href=#the-html-element-0>html</a></code> element).</p>
+ of open elements</a> (the <code><a href=#the-html-element>html</a></code> element).</p>
<p>Elements in the stack fall into the following categories:</p>
@@ -81565,28 +81559,28 @@
<code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>,
<code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-br-element>br</a></code>,
<code><a href=#the-button-element>button</a></code>, <code><a href=#the-caption-element>caption</a></code>, <code><a href=#center>center</a></code>,
- <code><a href=#the-col-element>col</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-command>command</a></code>,
+ <code><a href=#the-col-element>col</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-command-element>command</a></code>,
<code><a href=#the-dd-element>dd</a></code>, <code><a href=#the-details-element>details</a></code>, <code><a href=#dir>dir</a></code>,
<code><a href=#the-div-element>div</a></code>, <code><a href=#the-dl-element>dl</a></code>, <code><a href=#the-dt-element>dt</a></code>,
<code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-figcaption-element>figcaption</a></code>,
<code><a href=#the-figure-element>figure</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>,
<code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>,
- <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-head-element-0>head</a></code>, <code><a href=#the-header-element>header</a></code>,
- <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-html-element-0>html</a></code>,
+ <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-head-element>head</a></code>, <code><a href=#the-header-element>header</a></code>,
+ <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <!-- <code>image</code>, (commented out
because this isn't an element that can end up on the stack, so it
doesn't matter) --> <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
<code><a href=#isindex-0>isindex</a></code>, <code><a href=#the-li-element>li</a></code>, <code><a href=#the-link-element>link</a></code>,
- <code><a href=#listing>listing</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#menus>menu</a></code>,
- <code><a href=#meta>meta</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#noembed>noembed</a></code>,
+ <code><a href=#listing>listing</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-menu-element>menu</a></code>,
+ <code><a href=#the-meta-element>meta</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#noembed>noembed</a></code>,
<code><a href=#noframes>noframes</a></code>, <code><a href=#the-noscript-element>noscript</a></code>, <code><a href=#the-object-element>object</a></code>,
<code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-param-element>param</a></code>,
- <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#script>script</a></code>,
+ <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#the-script-element>script</a></code>,
<code><a href=#the-section-element>section</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-style-element>style</a></code>,
<code><a href=#the-summary-element>summary</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>,
<code><a href=#the-td-element>td</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
- <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-title-element-0>title</a></code>,
+ <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-title-element>title</a></code>,
<code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-ul-element>ul</a></code>, <code><a href=#the-wbr-element>wbr</a></code>, and
<code><a href=#xmp>xmp</a></code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code title="">annotation-xml</code>; and SVG's <code title="">foreignObject</code>, <code title="">desc</code>, and
<code title="">title</code>.</dd> <!-- we could actually put
@@ -81623,7 +81617,7 @@
entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to step
2. (This will never fail, since the loop will always terminate in
the previous step if the top of the stack — an
- <code><a href=#the-html-element-0>html</a></code> element — is reached.)</li>
+ <code><a href=#the-html-element>html</a></code> element — is reached.)</li>
</ol><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-scope title="has an element in scope">have an element in scope</dfn> when
it <a href=#has-an-element-in-the-specific-scope>has an element in the specific scope</a> consisting
@@ -81631,7 +81625,7 @@
<ul class=brief><li><code><a href=#the-applet-element>applet</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-caption-element>caption</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
- <li><code><a href=#the-html-element-0>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
+ <li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
<li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-td-element>td</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-th-element>th</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
@@ -81665,7 +81659,7 @@
scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
scope</a> consisting of the following element types:</p>
- <ul class=brief><li><code><a href=#the-html-element-0>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
+ <ul class=brief><li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
<li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
</ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope title="has an element in select scope">have an element in select
scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
@@ -81809,7 +81803,7 @@
pointer</dfn> and the <dfn id=form-element-pointer><code title="">form</code> element
pointer</dfn> are both null.</p>
- <p>Once a <code><a href=#the-head-element-0>head</a></code> element has been parsed (whether
+ <p>Once a <code><a href=#the-head-element>head</a></code> element has been parsed (whether
implicitly or explicitly) the <a href=#head-element-pointer><code title="">head</code>
element pointer</a> gets set to point to this node.</p>
@@ -81828,7 +81822,7 @@
<p class=note>The <a href=#scripting-flag>scripting flag</a> can be enabled even
when the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML fragment
- parsing algorithm</a>, even though <code><a href=#script>script</a></code> elements
+ parsing algorithm</a>, even though <code><a href=#the-script-element>script</a></code> elements
don't execute in that case.</p>
<p>The <dfn id=frameset-ok-flag>frameset-ok flag</dfn> is set to "ok" when the parser is
@@ -81876,7 +81870,7 @@
<a href=#tree-construction>tree construction</a> stage. The tree construction stage
can affect the state of the tokenization stage, and can insert
additional characters into the stream. (For example, the
- <code><a href=#script>script</a></code> element can result in scripts executing and
+ <code><a href=#the-script-element>script</a></code> element can result in scripts executing and
using the <a href=#dynamic-markup-insertion>dynamic markup insertion</a> APIs to insert
characters into the stream being tokenized.)</p>
@@ -84335,7 +84329,7 @@
<p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
open elements</a> (<a href=#fragment-case>fragment case</a>), then the
<i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the <a href=#stack-of-open-elements>stack
- of open elements</a> (the <code><a href=#the-html-element-0>html</a></code> element). Otherwise,
+ of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise,
if there is a <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
elements</a>, but the last <code><a href=#the-table-element>table</a></code> element in the
<a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its parent
@@ -84612,7 +84606,7 @@
<dt>Anything else</dt>
<dd>
- <p>Create an <code><a href=#the-html-element-0>html</a></code> element. Append it to the
+ <p>Create an <code><a href=#the-html-element>html</a></code> element. Append it to the
<code><a href=#document>Document</a></code> object. Put this element in the <a href=#stack-of-open-elements>stack
of open elements</a>.</p>
@@ -84667,7 +84661,7 @@
<p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
<p>Set the <a href=#head-element-pointer><code title="">head</code> element pointer</a>
- to the newly created <code><a href=#the-head-element-0>head</a></code> element.</p>
+ to the newly created <code><a href=#the-head-element>head</a></code> element.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
@@ -84814,7 +84808,7 @@
<li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML
fragment parsing algorithm</a>, then mark the
- <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
<li><p>Append the new element to the <a href=#current-node>current node</a>
@@ -84835,7 +84829,7 @@
<dd>
<p>Pop the <a href=#current-node>current node</a> (which will be the
- <code><a href=#the-head-element-0>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
+ <code><a href=#the-head-element>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>".</p>
@@ -84884,7 +84878,7 @@
<p>Pop the <a href=#current-node>current node</a> (which will be a
<code><a href=#the-noscript-element>noscript</a></code> element) from the <a href=#stack-of-open-elements>stack of open
elements</a>; the new <a href=#current-node>current node</a> will be a
- <code><a href=#the-head-element-0>head</a></code> element.</p>
+ <code><a href=#the-head-element>head</a></code> element.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
@@ -85124,7 +85118,7 @@
<li><p>Pop all the nodes from the bottom of the <a href=#stack-of-open-elements>stack of
open elements</a>, from the <a href=#current-node>current node</a> up to,
- but not including, the root <code><a href=#the-html-element-0>html</a></code> element.</p>
+ but not including, the root <code><a href=#the-html-element>html</a></code> element.</p>
<li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the
token.</li>
@@ -85142,7 +85136,7 @@
<code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a
<code><a href=#the-tfoot-element>tfoot</a></code> element, a <code><a href=#the-th-element>th</a></code> element, a
<code><a href=#the-thead-element>thead</a></code> element, a <code><a href=#the-tr-element>tr</a></code> element, the
- <code><a href=#the-body-element-0>body</a></code> element, or the <code><a href=#the-html-element-0>html</a></code> element, then
+ <code><a href=#the-body-element-0>body</a></code> element, or the <code><a href=#the-html-element>html</a></code> element, then
this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are
fragment cases) -->
@@ -85169,7 +85163,7 @@
<code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
<code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a
<code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element-0>body</a></code> element, or the
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p> <!-- (some of those are fragment cases, e.g. for
<tbody> you'd have hit the first paragraph since the <body>
wouldn't be in scope, unless it was a fragment case) -->
@@ -86297,8 +86291,8 @@
<!-- can't be the fragment case -->
<p><a href=#parse-error>Parse error</a>.</p>
- <p>If the <a href=#current-node>current node</a> is a <code><a href=#script>script</a></code>
- element, mark the <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ <p>If the <a href=#current-node>current node</a> is a <code><a href=#the-script-element>script</a></code>
+ element, mark the <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
started"</a>.</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
@@ -86315,7 +86309,7 @@
<p><a href=#provide-a-stable-state>Provide a stable state</a>.</p>
<p>Let <var title="">script</var> be the <a href=#current-node>current node</a>
- (which will be a <code><a href=#script>script</a></code> element).</p>
+ (which will be a <code><a href=#the-script-element>script</a></code> element).</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
@@ -86595,7 +86589,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -86621,11 +86615,11 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-context>clear the stack
back to a table context</dfn>, it means that the UA must, while
the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>
- element or an <code><a href=#the-html-element-0>html</a></code> element, pop elements from the
+ element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
<a href=#stack-of-open-elements>stack of open elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -86774,7 +86768,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>; ignore the token. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -86793,7 +86787,7 @@
<dt>An end-of-file token</dt>
<dd>
- <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element-0>html</a></code>
+ <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code>
element, then <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -86893,12 +86887,12 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-body-context>clear the stack
back to a table body context</dfn>, it means that the UA must,
while the <a href=#current-node>current node</a> is not a <code><a href=#the-tbody-element>tbody</a></code>,
- <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element-0>html</a></code>
+ <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element>html</a></code>
element, pop elements from the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -86984,11 +86978,11 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-row-context>clear the stack
back to a table row context</dfn>, it means that the UA must,
while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>
- element or an <code><a href=#the-html-element-0>html</a></code> element, pop elements from the
+ element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
<a href=#stack-of-open-elements>stack of open elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -87220,7 +87214,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -87281,7 +87275,7 @@
<dt>A comment token</dt>
<dd>
<p>Append a <code><a href=#comment-0>Comment</a></code> node to the first element in
- the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element-0>html</a></code>
+ the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code>
element), with the <code title="">data</code> attribute set to
the data given in the comment token.</p>
</dd>
@@ -87362,7 +87356,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>; ignore the token. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -87400,7 +87394,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -87777,17 +87771,17 @@
substeps:</p>
<ol><li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the first
- <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ <code><a href=#the-script-element>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
execute when the document has finished parsing</a> has its
<a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag set <em>and</em>
the parser's <code><a href=#document>Document</a></code> <a href=#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that
is blocking scripts</a>.</li>
<li><p><a href=#execute-the-script-block title="execute the script block">Execute</a> the
- first <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ first <code><a href=#the-script-element>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
execute when the document has finished parsing</a>.</li>
- <li><p>Remove the first <code><a href=#script>script</a></code> element from the
+ <li><p>Remove the first <code><a href=#the-script-element>script</a></code> element from the
<a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has
finished parsing</a> (i.e. shift out the first entry in the
list).</li>
@@ -87987,8 +87981,8 @@
<p>The parsing of this markup is straightforward up to the "3". At
this point, the DOM looks like this:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has five elements
- on it: <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-p-element>p</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has five elements
+ on it: <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-p-element>p</a></code>,
<code><a href=#the-b-element>b</a></code>, and <code><a href=#the-i-element>i</a></code>. The <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> just has two: <code><a href=#the-b-element>b</a></code> and
<code><a href=#the-i-element>i</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
@@ -87997,7 +87991,7 @@
invoked. This is a simple case, in that the <var title="">formatting
element</var> is the <code><a href=#the-b-element>b</a></code> element, and there is no
<var title="">furthest block</var>. Thus, the <a href=#stack-of-open-elements>stack of open
- elements</a> ends up with just three elements: <code><a href=#the-html-element-0>html</a></code>,
+ elements</a> ends up with just three elements: <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-body-element-0>body</a></code>, and <code><a href=#the-p-element>p</a></code>, while the <a href=#list-of-active-formatting-elements>list of
active formatting elements</a> has just one: <code><a href=#the-i-element>i</a></code>. The
DOM tree is unmodified at this point.</p>
@@ -88009,7 +88003,7 @@
received, and the "5" text node is inserted, the DOM looks as
follows:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
<p><i>This section is non-normative.</i></p>
@@ -88019,11 +88013,11 @@
<p>Up to the "2" the parsing here is straightforward:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The interesting part is when the end tag token with the tag name
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The interesting part is when the end tag token with the tag name
"b" is parsed.</p>
<p>Before that token is seen, the <a href=#stack-of-open-elements>stack of open
- elements</a> has four elements on it: <code><a href=#the-html-element-0>html</a></code>,
+ elements</a> has four elements on it: <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-b-element>b</a></code>, and <code><a href=#the-p-element>p</a></code>. The
<a href=#list-of-active-formatting-elements>list of active formatting elements</a> just has the one:
<code><a href=#the-b-element>b</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
@@ -88047,18 +88041,18 @@
<p>The <var title="">last node</var> gets appended (moved) to the
<var title="">common ancestor</var>, so that the DOM looks like:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul><p>A new <code><a href=#the-b-element>b</a></code> element is created, and the children of the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul><p>A new <code><a href=#the-b-element>b</a></code> element is created, and the children of the
<code><a href=#the-p-element>p</a></code> element are moved to it:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code></ul></ul></ul><ul class=domTree><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul><p>Finally, the new <code><a href=#the-b-element>b</a></code> element is appended to the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code></ul></ul></ul><ul class=domTree><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul><p>Finally, the new <code><a href=#the-b-element>b</a></code> element is appended to the
<code><a href=#the-p-element>p</a></code> element, so that the DOM looks like:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The <code><a href=#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements>list of
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The <code><a href=#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements>list of
active formatting elements</a> and the <a href=#stack-of-open-elements>stack of open
elements</a>, so that when the "3" is parsed, it is appended to
the <code><a href=#the-p-element>p</a></code> element:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</h5>
<p><i>This section is non-normative.</i></p>
@@ -88073,11 +88067,11 @@
examining the DOM tree as it stands just after the
<code><a href=#the-table-element>table</a></code> element's start tag has been seen:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>...and then immediately after the <code><a href=#the-b-element>b</a></code> element start
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>...and then immediately after the <code><a href=#the-b-element>b</a></code> element start
tag has been seen:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>At this point, the <a href=#stack-of-open-elements>stack of open elements</a> has on it
- the elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>At this point, the <a href=#stack-of-open-elements>stack of open elements</a> has on it
+ the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>,
<code><a href=#the-table-element>table</a></code>, and <code><a href=#the-b-element>b</a></code> (in that order, despite the
resulting DOM tree); the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> just has the <code><a href=#the-b-element>b</a></code> element in it; and the
@@ -88093,8 +88087,8 @@
row</a>" insertion modes, after which the DOM looks as
follows:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
- elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
+ elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
<code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tr-element>tr</a></code>; the <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> still has the <code><a href=#the-b-element>b</a></code> element in
it; and the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intr title="insertion
@@ -88105,13 +88099,13 @@
of active formatting elements</a> (it also switches to the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion
mode</a>).</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul><p>The marker means that when the "aaa" character tokens are seen,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul><p>The marker means that when the "aaa" character tokens are seen,
no <code><a href=#the-b-element>b</a></code> element is created to hold the resulting text
node:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The end tags are handled in a straight-forward manner; after
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The end tags are handled in a straight-forward manner; after
handling them, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
- elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
and <code><a href=#the-tbody-element>tbody</a></code>; the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> still has the <code><a href=#the-b-element>b</a></code> element in it (the
marker having been removed by the "td" end tag token); and the
@@ -88136,8 +88130,8 @@
parent">foster parented</a>, and then the "bbb" text node is
appended to it:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements
- <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements
+ <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
<code><a href=#the-tbody-element>tbody</a></code>, and the new <code><a href=#the-b-element>b</a></code> (again, note that
this doesn't match the resulting tree!); the <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> has the new <code><a href=#the-b-element>b</a></code> element in it;
@@ -88157,7 +88151,7 @@
result in yet another <code><a href=#the-b-element>b</a></code> element being created, this
time after the table:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is bein
g parsed</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is being pa
rsed</h5>
<p><i>This section is non-normative.</i></p>
@@ -88182,16 +88176,16 @@
<p>Up to the first "script" end tag, before the script is parsed,
the result is relatively straightforward:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-div-element>div</a></code> <span class=t2 title=""><code class="attribute name">id</code>="<code class="attribute value"><a href=#the-a-element>a</a></code>"</span><ul><li class=t3><code>#text</code>: <span title="">
- </span><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></ul></ul></ul></ul></ul><p>After the script is parsed, though, the <code><a href=#the-div-element>div</a></code> element
- and its child <code><a href=#script>script</a></code> element are gone:</p>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-div-element>div</a></code> <span class=t2 title=""><code class="attribute name">id</code>="<code class="attribute value"><a href=#the-a-element>a</a></code>"</span><ul><li class=t3><code>#text</code>: <span title="">
+ </span><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></ul></ul></ul></ul></ul><p>After the script is parsed, though, the <code><a href=#the-div-element>div</a></code> element
+ and its child <code><a href=#the-script-element>script</a></code> element are gone:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code></ul></ul><p>They are, at this point, in the <code><a href=#document>Document</a></code> of the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code></ul></ul><p>They are, at this point, in the <code><a href=#document>Document</a></code> of the
aforementioned outer <a href=#browsing-context>browsing context</a>. However, the
<a href=#stack-of-open-elements>stack of open elements</a> <em>still contains the
<code><a href=#the-div-element>div</a></code> element</em>.</p>
- <p>Thus, when the second <code><a href=#script>script</a></code> element is parsed, it
+ <p>Thus, when the second <code><a href=#the-script-element>script</a></code> element is parsed, it
is inserted <em>into the outer <code><a href=#document>Document</a></code>
object</em>.</p>
@@ -88209,9 +88203,9 @@
<p>Once the <code><a href=#the-div-element>div</a></code> element's end tag is parsed, the
<code><a href=#the-div-element>div</a></code> element is popped off the stack, and so the next
- <code><a href=#script>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>
+ <code><a href=#the-script-element>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "<A HREF="http://example.com/inner">http://example.com/inner</A>".</p>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "<A HREF="http://example.com/inner">http://example.com/inner</A>".</p>
<h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>
@@ -88219,7 +88213,7 @@
<p><i>This section is non-normative.</i></p>
<p>Elaborating on the example in the previous section, consider a
- case where a <code><a href=#script>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
+ case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
the external script is being downloaded, the element is moved to
another document.</p>
@@ -88247,7 +88241,7 @@
<p>The resulting DOM tree is as follows:</p>
- <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element-0>html</a></code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 t
itle=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span tit
le="">X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code
><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
+ <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element>html</a></code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title="
"><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">
X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a hr
ef=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
explicit <code><a href=#the-b-element>b</a></code> elements, but in the resulting DOM, up to
three of each kind of formatting element (in this case three
<code><a href=#the-b-element>b</a></code> elements with the class attribute, and two unadorned
@@ -88370,9 +88364,9 @@
<p>If <var title="">current node</var> is an
<code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>,
<code><a href=#bgsound>bgsound</a></code>, <code><a href=#the-br-element>br</a></code>, <code><a href=#the-col-element>col</a></code>,
- <code><a href=#the-command>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#frame>frame</a></code>,
+ <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#frame>frame</a></code>,
<code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
- <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#meta>meta</a></code>,
+ <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>,
<code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code> or
<code><a href=#the-wbr-element>wbr</a></code> element, then continue on to the next child
node at this point.</p> <!-- VOIDLIST superset -->
@@ -88400,7 +88394,7 @@
<dd>
<p>If the parent of <var title="">current node</var> is a
- <code><a href=#the-style-element>style</a></code>, <code><a href=#script>script</a></code>, <code><a href=#xmp>xmp</a></code>,
+ <code><a href=#the-style-element>style</a></code>, <code><a href=#the-script-element>script</a></code>, <code><a href=#xmp>xmp</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#noembed>noembed</a></code>,
<code><a href=#noframes>noframes</a></code>, or <code><a href=#plaintext>plaintext</a></code> element, or
if the parent of <var title="">current node</var> is
@@ -88488,7 +88482,7 @@
literal string "<code title="">--></code>", then when the result
of serializing the element is parsed, the comment will be truncated
at that point and the rest of the comment will be interpreted as
- markup. More examples would be making a <code><a href=#script>script</a></code> element
+ markup. More examples would be making a <code><a href=#the-script-element>script</a></code> element
contain a text node with the text string
"<code></script></code>", or having a <code><a href=#the-p-element>p</a></code> element
that contains a <code><a href=#the-ul-element>ul</a></code> element (as the <code><a href=#the-ul-element>ul</a></code>
@@ -88504,7 +88498,7 @@
"<code></style><script>attack</script></code>" as a font
name, <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> will return
markup that, if parsed in a different context, would contain a
- <code><a href=#script>script</a></code> node, even though no <code><a href=#script>script</a></code> node
+ <code><a href=#the-script-element>script</a></code> node, even though no <code><a href=#the-script-element>script</a></code> node
existed in the original DOM.</p>
</div>
@@ -88580,7 +88574,7 @@
<p>Set the state of the <a href=#html-parser>HTML parser</a>'s
<a href=#tokenization>tokenization</a> stage as follows:</p>
- <dl class=switch><dt>If it is a <code><a href=#the-title-element-0>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
+ <dl class=switch><dt>If it is a <code><a href=#the-title-element>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
element</dt>
<dd>Switch the tokenizer to the <a href=#rcdata-state>RCDATA state</a>.</dd>
@@ -88593,7 +88587,7 @@
<dd>Switch the tokenizer to the <a href=#rawtext-state>RAWTEXT state</a>.</dd>
- <dt>If it is a <code><a href=#script>script</a></code> element</dt>
+ <dt>If it is a <code><a href=#the-script-element>script</a></code> element</dt>
<dd>Switch the tokenizer to the <a href=#script-data-state>script data state</a>.</dd>
@@ -88628,7 +88622,7 @@
<li>
- <p>Let <var title="">root</var> be a new <code><a href=#the-html-element-0>html</a></code> element
+ <p>Let <var title="">root</var> be a new <code><a href=#the-html-element>html</a></code> element
with no attributes.</p>
</li>
@@ -88817,14 +88811,14 @@
handling external subsets. <a href=#refsXML>[XML]</a></p>
<p id=scriptTagXML>When an <a href=#xml-parser>XML parser</a> creates a
- <code><a href=#script>script</a></code> element, it must be marked as being
+ <code><a href=#the-script-element>script</a></code> element, it must be marked as being
<a href=#parser-inserted>"parser-inserted"</a> and its <a href=#force-async>"force-async"</a>
flag must be unset. If the parser was originally created for the
<a href=#xml-fragment-parsing-algorithm>XML fragment parsing algorithm</a>, then the element must
be marked as <a href=#already-started>"already started"</a> also. When the element's
end tag is parsed, the user agent must <a href=#provide-a-stable-state>provide a stable
state</a>, and then <a href=#prepare-a-script title="prepare a script">prepare</a>
- the <code><a href=#script>script</a></code> element. If this causes there to be a
+ the <code><a href=#the-script-element>script</a></code> element. If this causes there to be a
<a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the user agent
must run the following steps:</p>
@@ -90095,7 +90089,7 @@
<h4 id=embedded-content-2><span class=secno>15.3.1 </span>Embedded content</h4>
<p>The <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, and
- <code><a href=#video>video</a></code> elements are expected to be treated as replaced
+ <code><a href=#the-video-element>video</a></code> elements are expected to be treated as replaced
elements.</p>
<p>A <code><a href=#the-canvas-element>canvas</a></code> element that <a href=#represents>represents</a>
@@ -90114,43 +90108,43 @@
element. Other <code><a href=#the-applet-element>applet</a></code> elements are expected to be
treated as ordinary elements in the rendering model.</p>
- <p>The <code><a href=#audio>audio</a></code> element, when it is <a href=#expose-a-user-interface-to-the-user title="expose a
+ <p>The <code><a href=#the-audio-element>audio</a></code> element, when it is <a href=#expose-a-user-interface-to-the-user title="expose a
user interface to the user">exposing a user interface</a>, is
expected to be treated as a replaced element about one line high, as
wide as is necessary to expose the user agent's user interface
- features. When an <code><a href=#audio>audio</a></code> element is not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user
+ features. When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user
interface</a>, the user agent is expected to hide it,
irrespective of CSS rules.</p>
- <p>Whether a <code><a href=#video>video</a></code> element is <a href=#expose-a-user-interface-to-the-user title="expose a
+ <p>Whether a <code><a href=#the-video-element>video</a></code> element is <a href=#expose-a-user-interface-to-the-user title="expose a
user interface to the user">exposing a user interface</a> is not
expected to affect the size of the rendering; controls are expected
to be overlaid with the page content without causing any layout
changes, and are expected to disappear when the user does not need
them.</p>
- <p>When a <code><a href=#video>video</a></code> element represents a poster frame or
+ <p>When a <code><a href=#the-video-element>video</a></code> element represents a poster frame or
frame of video, the poster frame or frame of video is expected to be
rendered at the largest size that maintains the aspect ratio of that
poster frame or frame of video without being taller or wider than
- the <code><a href=#video>video</a></code> element itself, and is expected to be
- centered in the <code><a href=#video>video</a></code> element.</p>
+ the <code><a href=#the-video-element>video</a></code> element itself, and is expected to be
+ centered in the <code><a href=#the-video-element>video</a></code> element.</p>
<p>Any subtitles or captions are expected to be overlayed directly
- on top of their <code><a href=#video>video</a></code> element, as defined by the
+ on top of their <code><a href=#the-video-element>video</a></code> element, as defined by the
relevant rendering rules; for <a href=#webvtt>WebVTT</a>, those are the
<a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a> defined below.</p>
<p>When the user agent starts <a href=#expose-a-user-interface-to-the-user title="expose a user interface
to the user">exposing a user interface</a> for a
- <code><a href=#video>video</a></code> element, the user agent should run the <a href=#rules-for-updating-the-text-track-rendering>rules
- for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in the <code><a href=#video>video</a></code>
+ <code><a href=#the-video-element>video</a></code> element, the user agent should run the <a href=#rules-for-updating-the-text-track-rendering>rules
+ for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in the <code><a href=#the-video-element>video</a></code>
element's <a href=#list-of-text-tracks>list of text tracks</a> that are <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text
track showing by default">showing by default</a> (e.g., for <a href=#text-track title="text track">text tracks</a> based on
<a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of
WebVTT text tracks</a>).</p>
- <p class=note>Resizing <code><a href=#video>video</a></code> and <code><a href=#the-canvas-element>canvas</a></code>
+ <p class=note>Resizing <code><a href=#the-video-element>video</a></code> and <code><a href=#the-canvas-element>canvas</a></code>
elements does not interrupt video playback or clear the canvas.</p>
<hr><p>The following CSS rules are expected to apply:</p>
@@ -90177,7 +90171,7 @@
<p>The <dfn id=rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text
tracks</dfn> render the <a href=#text-track title="text track">text
tracks</a> of a <a href=#media-element>media element</a> (specifically, a
- <code><a href=#video>video</a></code> element), or of another playback mechanism, by
+ <code><a href=#the-video-element>video</a></code> element), or of another playback mechanism, by
applying the steps below. All the <a href=#text-track title="text track">text
tracks</a> that use these rules for a given <a href=#media-element>media
element</a>, or other playback mechanism, are rendered together,
@@ -90190,7 +90184,7 @@
<p>The rules are as follows:</p>
- <ol><li><p>If the <a href=#media-element>media element</a> is an <code><a href=#audio>audio</a></code>
+ <ol><li><p>If the <a href=#media-element>media element</a> is an <code><a href=#the-audio-element>audio</a></code>
element, or is another playback mechanism with no rendering area,
abort these steps. There is nothing to render.</li>
@@ -90803,7 +90797,7 @@
<i>matched element</i>.</p>
<p class=note>If the <i>matched element</i> is not a
- <code><a href=#video>video</a></code> element, the pseudo-elements defined below won't
+ <code><a href=#the-video-element>video</a></code> element, the pseudo-elements defined below won't
have any effect according to this specification.</p>
<p>A CSS user agent that implements the <a href=#text-track title="text
@@ -91153,7 +91147,7 @@
<p id=dimRendering>The <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>
and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes on
<code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>,
- <code><a href=#the-img-element>img</a></code>, <code><a href=#the-object-element>object</a></code> or <code><a href=#video>video</a></code>
+ <code><a href=#the-img-element>img</a></code>, <code><a href=#the-object-element>object</a></code> or <code><a href=#the-video-element>video</a></code>
elements, and <code><a href=#the-input-element>input</a></code> elements with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension
properties</a> 'width' and 'height' on the element
respectively.</p>
@@ -91193,7 +91187,7 @@
<h4 id=toolbars-0><span class=secno>15.3.6 </span>Toolbars</h4>
- <p>When a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is
+ <p>When a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is
expected to be treated as a replaced element with a height about two
lines high and a width derived from the contents of the element.</p>
@@ -91887,7 +91881,7 @@
<h3 id=frames-and-framesets><span class=secno>15.5 </span>Frames and framesets</h3>
- <p>When an <code><a href=#the-html-element-0>html</a></code> element's second child element is a
+ <p>When an <code><a href=#the-html-element>html</a></code> element's second child element is a
<code><a href=#frameset>frameset</a></code> element, the user agent is expected to render
the <code><a href=#frameset>frameset</a></code> element as described below across the
surface of the viewport, instead of applying the usual CSS rendering
@@ -92385,7 +92379,7 @@
instead.</p>
<p>Authors should not specify a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a
- <code><a href=#script>script</a></code> element. If the attribute is present, its value
+ <code><a href=#the-script-element>script</a></code> element. If the attribute is present, its value
must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string
"<code title="">JavaScript</code>" and either the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must be omitted or
its value must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for
@@ -92435,7 +92429,7 @@
<code><a href=#the-img-element>img</a></code> element if its value is the string "<code title="">0</code>".</li>
<li><p>The presence of a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a
- <code><a href=#script>script</a></code> element if its value is an <a href=#ascii-case-insensitive>ASCII
+ <code><a href=#the-script-element>script</a></code> element if its value is an <a href=#ascii-case-insensitive>ASCII
case-insensitive</a> match for the string "<code title="">JavaScript</code>" and if there is no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute or there is and its
value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the
string "<code title="">text/javascript</code>".</li>
@@ -92467,7 +92461,7 @@
<dd><p>Use <code><a href=#the-abbr-element>abbr</a></code> instead.</dd>
<dt><dfn id=bgsound><code>bgsound</code></dfn></dt>
- <dd><p>Use <code><a href=#audio>audio</a></code> instead.</dd>
+ <dd><p>Use <code><a href=#the-audio-element>audio</a></code> instead.</dd>
<dt><dfn id=dir><code>dir</code></dfn></dt>
<dd><p>Use <code><a href=#the-ul-element>ul</a></code> instead.</dd>
@@ -92568,13 +92562,13 @@
attribute is sufficient; the <code title=attr-area-nohref><a href=#attr-area-nohref>nohref</a></code> attribute is
unnecessary. Omit it altogether.</dd>
- <dt><dfn id=attr-head-profile title=attr-head-profile><code>profile</code></dfn> on <code><a href=#the-head-element-0>head</a></code> elements</dt>
- <dd><p>When used for declaring which <code><a href=#meta>meta</a></code> terms are
+ <dt><dfn id=attr-head-profile title=attr-head-profile><code>profile</code></dfn> on <code><a href=#the-head-element>head</a></code> elements</dt>
+ <dd><p>When used for declaring which <code><a href=#the-meta-element>meta</a></code> terms are
used in the document, unnecessary; omit it altogether, and <a href=#concept-meta-extensions title=concept-meta-extensions>register the names</a>.</dd>
<dd><p>When used for triggering specific user agent behaviors: use
a <code><a href=#the-link-element>link</a></code> element instead.</dd>
- <dt><dfn id=attr-html-version title=attr-html-version><code>version</code></dfn> on <code><a href=#the-html-element-0>html</a></code> elements</dt>
+ <dt><dfn id=attr-html-version title=attr-html-version><code>version</code></dfn> on <code><a href=#the-html-element>html</a></code> elements</dt>
<dd><p>Unnecessary. Omit it altogether.</dd>
<dt><dfn id=attr-input-usemap title=attr-input-usemap><code>usemap</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt>
@@ -92594,7 +92588,7 @@
<dt><dfn id=attr-link-target title=attr-link-target><code>target</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt>
<dd><p>Unnecessary. Omit it altogether.</dd>
- <dt><dfn id=attr-meta-scheme title=attr-meta-scheme><code>scheme</code></dfn> on <code><a href=#meta>meta</a></code> elements</dt>
+ <dt><dfn id=attr-meta-scheme title=attr-meta-scheme><code>scheme</code></dfn> on <code><a href=#the-meta-element>meta</a></code> elements</dt>
<dd><p>Use only one scheme per field, or make the scheme declaration part of the value.</dd>
<dt><dfn id=attr-object-archive title=attr-object-archive><code>archive</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
@@ -92616,12 +92610,12 @@
<dd><p>Use the <code title=attr-param-name><a href=#attr-param-name>name</a></code> and <code title=attr-param-value><a href=#attr-param-value>value</a></code> attributes without declaring
value types.</dd>
- <dt><dfn id=attr-script-language title=attr-script-language><code>language</code></dfn> on <code><a href=#script>script</a></code> elements (except as noted in the previous section)</dt>
+ <dt><dfn id=attr-script-language title=attr-script-language><code>language</code></dfn> on <code><a href=#the-script-element>script</a></code> elements (except as noted in the previous section)</dt>
<dd><p>Use the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute
instead.</dd>
- <dt><dfn id=attr-script-event title=attr-script-event><code>event</code></dfn> on <code><a href=#script>script</a></code> elements</dt>
- <dt><dfn id=attr-script-for title=attr-script-for><code>for</code></dfn> on <code><a href=#script>script</a></code> elements</dt>
+ <dt><dfn id=attr-script-event title=attr-script-event><code>event</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt>
+ <dt><dfn id=attr-script-for title=attr-script-for><code>for</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt>
<dd><p>Use DOM Events mechanisms to register event listeners. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></dd>
<dt><dfn id=attr-table-datapagesize title=attr-table-datapagesize><code>datapagesize</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt>
@@ -92689,7 +92683,7 @@
<dt><dfn id=attr-img-vspace title=attr-img-vspace><code>vspace</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt>
<dt><dfn id=attr-legend-align title=attr-legend-align><code>align</code></dfn> on <code><a href=#the-legend-element>legend</a></code> elements</dt>
<dt><dfn id=attr-li-type title=attr-li-type><code>type</code></dfn> on <code><a href=#the-li-element>li</a></code> elements</dt>
- <dt><dfn id=attr-menu-compact title=attr-menu-compact><code>compact</code></dfn> on <code><a href=#menus>menu</a></code> elements</dt>
+ <dt><dfn id=attr-menu-compact title=attr-menu-compact><code>compact</code></dfn> on <code><a href=#the-menu-element>menu</a></code> elements</dt>
<dt><dfn id=attr-object-align title=attr-object-align><code>align</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
<dt><dfn id=attr-object-border title=attr-object-border><code>border</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
<dt><dfn id=attr-object-hspace title=attr-object-hspace><code>hspace</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
@@ -93371,7 +93365,7 @@
<a href=#reflect>reflect</a> the content attribute of the same name.</p>
<hr><p class=note>The <dfn id=dom-head-profile title=dom-head-profile><code>profile</code></dfn> IDL attribute on
- <code><a href=#the-head-element-0>head</a></code> elements (with the <code><a href=#htmlheadelement>HTMLHeadElement</a></code>
+ <code><a href=#the-head-element>head</a></code> elements (with the <code><a href=#htmlheadelement>HTMLHeadElement</a></code>
interface) is intentionally omitted. Unless so required by <a href=#other-applicable-specifications title="other applicable specifications">another applicable
specification</a>, implementations would therefore not support
this attribute. (It is mentioned here as it was defined in a
@@ -93401,7 +93395,7 @@
};</pre>
<p>The <dfn id=dom-html-version title=dom-html-version><code>version</code></dfn> IDL
- attribute of the <code><a href=#the-html-element-0>html</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-html-element>html</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -93517,7 +93511,7 @@
};</pre>
<p>The <dfn id=dom-menu-compact title=dom-menu-compact><code>compact</code></dfn> IDL
- attribute of the <code><a href=#menus>menu</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-menu-element>menu</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -93526,8 +93520,8 @@
};</pre>
<p>User agents may treat the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> content attribute on the
- <code><a href=#meta>meta</a></code> element as an extension of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> content attribute when processing
- a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is one that
+ <code><a href=#the-meta-element>meta</a></code> element as an extension of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> content attribute when processing
+ a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is one that
the user agent recognizes as supporting the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute.</p>
<p>User agents are encouraged to ignore the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute and instead process
@@ -93536,12 +93530,12 @@
<div class=example>
- <p>For example, if the user agent acts on <code><a href=#meta>meta</a></code>
+ <p>For example, if the user agent acts on <code><a href=#the-meta-element>meta</a></code>
elements with <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attributes
having the value "eGMS.subject.keyword", and knows that the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute is used with this
metadata name, then it could take the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute into account,
acting as if it was an extension of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute. Thus the following
- two <code><a href=#meta>meta</a></code> elements could be treated as two elements
+ two <code><a href=#the-meta-element>meta</a></code> elements could be treated as two elements
giving values for two different metadata names, one consisting of a
combination of "eGMS.subject.keyword" and "LGCL", and the other
consisting of a combination of "eGMS.subject.keyword" and
@@ -93560,7 +93554,7 @@
</div>
<p>The <dfn id=dom-meta-scheme title=dom-meta-scheme><code>scheme</code></dfn> IDL
- attribute of the <code><a href=#meta>meta</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-meta-element>meta</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -93645,7 +93639,7 @@
<p>The <dfn id=dom-script-event title=dom-script-event><code>event</code></dfn> and
<dfn id=dom-script-htmlfor title=dom-script-htmlFor><code>htmlFor</code></dfn> IDL
- attributes of the <code><a href=#script>script</a></code> element must return the empty
+ attributes of the <code><a href=#the-script-element>script</a></code> element must return the empty
string on getting, and do nothing on setting.</p>
<hr><pre class=idl>[Supplemental]
@@ -94667,7 +94661,7 @@
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#audio>audio</a></code></th>
+ <tr><th><code><a href=#the-audio-element>audio</a></code></th>
<td>Audio player</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a>;
@@ -94695,7 +94689,7 @@
<tr><th><code><a href=#the-base-element>base</a></code></th>
<td>Base URL and default target <a href=#browsing-context>browsing context</a> for <a href=#attr-hyperlink-target title=attr-hyperlink-target>hyperlinks</a> and <a href=#attr-fs-target title=attr-fs-target>forms</a></td>
<td><a href=#metadata-content title="Metadata content">metadata</a></td>
- <td><code><a href=#the-head-element-0>head</a></code></td>
+ <td><code><a href=#the-head-element>head</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-base-href><a href=#attr-base-href>href</a></code>;
@@ -94730,7 +94724,7 @@
<tr><th><code><a href=#the-body-element-0>body</a></code></th>
<td>Document body</td>
<td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
- <td><code><a href=#the-html-element-0>html</a></code></td>
+ <td><code><a href=#the-html-element>html</a></code></td>
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code>;
@@ -94836,12 +94830,12 @@
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></td>
<td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td>
- <tr><th><code><a href=#the-command>command</a></code></th>
+ <tr><th><code><a href=#the-command-element>command</a></code></th>
<td>Menu command</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
@@ -95006,10 +95000,10 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlheadingelement>HTMLHeadingElement</a></code></td>
- <tr><th><code><a href=#the-head-element-0>head</a></code></th>
+ <tr><th><code><a href=#the-head-element>head</a></code></th>
<td>Container for document metadata</td>
<td>none</td>
- <td><code><a href=#the-html-element-0>html</a></code></td>
+ <td><code><a href=#the-html-element>html</a></code></td>
<td><a href=#metadata-content title="Metadata content">metadata content</a>*</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlheadelement>HTMLHeadElement</a></code></td>
@@ -95037,11 +95031,11 @@
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlhrelement>HTMLHRElement</a></code></td>
- <tr><th><code><a href=#the-html-element-0>html</a></code></th>
+ <tr><th><code><a href=#the-html-element>html</a></code></th>
<td>Root element</td>
<td>none</td>
<td>none*</td>
- <td><code><a href=#the-head-element-0>head</a></code>*;
+ <td><code><a href=#the-head-element>head</a></code>*;
<code><a href=#the-body-element-0>body</a></code>*</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></td>
@@ -95191,7 +95185,7 @@
<tr><th><code><a href=#the-li-element>li</a></code></th>
<td>List item</td>
<td>none</td>
- <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#menus>menu</a></code></td>
+ <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-menu-element>menu</a></code></td>
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-li-value><a href=#attr-li-value>value</a></code>*</td>
@@ -95201,7 +95195,7 @@
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
<td>empty</td>
@@ -95231,7 +95225,7 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#menus>menu</a></code></th>
+ <tr><th><code><a href=#the-menu-element>menu</a></code></th>
<td>Menu of commands</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#interactive-content title="Interactive content">interactive</a>*</td>
@@ -95242,12 +95236,12 @@
<code title=attr-menu-type><a href=#attr-menu-type>type</a></code>;
<code title=attr-menu-label><a href=#attr-menu-label>label</a></code></td>
<td><code><a href=#htmlmenuelement>HTMLMenuElement</a></code></td>
- <tr><th><code><a href=#meta>meta</a></code></th>
+ <tr><th><code><a href=#the-meta-element>meta</a></code></th>
<td>Text metadata</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
<td>empty</td>
@@ -95288,7 +95282,7 @@
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>*;
+ <td><code><a href=#the-head-element>head</a></code>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
<td>varies*</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
@@ -95447,12 +95441,12 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#script>script</a></code></th>
+ <tr><th><code><a href=#the-script-element>script</a></code></th>
<td>Embedded script</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td>script, data, or script documentation*</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
@@ -95501,10 +95495,10 @@
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
<tr><th><code><a href=#the-source-element>source</a></code></th>
- <td>Media source for <code><a href=#video>video</a></code> or <code><a href=#audio>audio</a></code></td>
+ <td>Media source for <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code></td>
<td>none</td>
- <td><code><a href=#video>video</a></code>;
- <code><a href=#audio>audio</a></code></td>
+ <td><code><a href=#the-video-element>video</a></code>;
+ <code><a href=#the-audio-element>audio</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-source-src><a href=#attr-source-src>src</a></code>;
@@ -95531,7 +95525,7 @@
<td>Embedded styling information</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#flow-content title="flow content">flow</a>*</td>
<td>varies*</td>
@@ -95653,10 +95647,10 @@
<code title=attr-time-datetime><a href=#attr-time-datetime>datetime</a></code>;
<code title=attr-time-pubdate><a href=#attr-time-pubdate>pubdate</a></code></td>
<td><code><a href=#htmltimeelement>HTMLTimeElement</a></code></td>
- <tr><th><code><a href=#the-title-element-0>title</a></code></th>
+ <tr><th><code><a href=#the-title-element>title</a></code></th>
<td>Document title</td>
<td><a href=#metadata-content title="Metadata content">metadata</a></td>
- <td><code><a href=#the-head-element-0>head</a></code></td>
+ <td><code><a href=#the-head-element>head</a></code></td>
<td><a href=#text-content title="text content">text</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmltitleelement>HTMLTitleElement</a></code></td>
@@ -95674,8 +95668,8 @@
<tr><th><code><a href=#the-track-element>track</a></code></th>
<td>Timed text track</td>
<td>none</td>
- <td><code><a href=#audio>audio</a></code>;
- <code><a href=#video>video</a></code></td>
+ <td><code><a href=#the-audio-element>audio</a></code>;
+ <code><a href=#the-video-element>video</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-track-default><a href=#attr-track-default>default</a></code>;
@@ -95707,7 +95701,7 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#video>video</a></code></th>
+ <tr><th><code><a href=#the-video-element>video</a></code></th>
<td>Video player</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a>;
@@ -95753,13 +95747,13 @@
<tbody><tr><td> <a href=#metadata-content>Metadata content</a>
<td>
<code><a href=#the-base-element>base</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-link-element>link</a></code>;
- <code><a href=#meta>meta</a></code>;
+ <code><a href=#the-meta-element>meta</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-style-element>style</a></code>;
- <code><a href=#the-title-element-0>title</a></code>
+ <code><a href=#the-title-element>title</a></code>
<td>
—
@@ -95770,7 +95764,7 @@
<code><a href=#the-address-element>address</a></code>;
<code><a href=#the-article-element>article</a></code>;
<code><a href=#the-aside-element>aside</a></code>;
- <code><a href=#audio>audio</a></code>;
+ <code><a href=#the-audio-element>audio</a></code>;
<code><a href=#the-b-element>b</a></code>;
<code><a href=#the-bdi-element>bdi</a></code>;
<code><a href=#the-bdo-element>bdo</a></code>;
@@ -95780,7 +95774,7 @@
<code><a href=#the-canvas-element>canvas</a></code>;
<code><a href=#the-cite-element>cite</a></code>;
<code><a href=#the-code-element>code</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-datalist-element>datalist</a></code>;
<code><a href=#the-del-element>del</a></code>;
<code><a href=#the-details-element>details</a></code>;
@@ -95813,7 +95807,7 @@
<code><a href=#the-map-element>map</a></code>;
<code><a href=#the-mark-element>mark</a></code>;
<code><a href=#math>math</a></code>;
- <code><a href=#menus>menu</a></code>;
+ <code><a href=#the-menu-element>menu</a></code>;
<code><a href=#the-meter-element>meter</a></code>;
<code><a href=#the-nav-element>nav</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>;
@@ -95827,7 +95821,7 @@
<code><a href=#the-ruby-element>ruby</a></code>;
<code><a href=#the-s-element>s</a></code>;
<code><a href=#the-samp-element>samp</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-section-element>section</a></code>;
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-small-element>small</a></code>;
@@ -95842,14 +95836,14 @@
<code><a href=#the-u-element>u</a></code>;
<code><a href=#the-ul-element>ul</a></code>;
<code><a href=#the-var-element>var</a></code>;
- <code><a href=#video>video</a></code>;
+ <code><a href=#the-video-element>video</a></code>;
<code><a href=#the-wbr-element>wbr</a></code>;
<a href=#text-content title="text content">Text</a>
<td>
<code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element);
<!--MD-->
<code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
- <code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
+ <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
<!--MD-->
<code><a href=#the-style-element>style</a></code> (if the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present)
@@ -95877,7 +95871,7 @@
<tr><td> <a href=#phrasing-content>Phrasing content</a>
<td>
<code><a href=#the-abbr-element>abbr</a></code>;
- <code><a href=#audio>audio</a></code>;
+ <code><a href=#the-audio-element>audio</a></code>;
<code><a href=#the-b-element>b</a></code>;
<code><a href=#the-bdi-element>bdi</a></code>;
<code><a href=#the-bdo-element>bdo</a></code>;
@@ -95886,7 +95880,7 @@
<code><a href=#the-canvas-element>canvas</a></code>;
<code><a href=#the-cite-element>cite</a></code>;
<code><a href=#the-code-element>code</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-datalist-element>datalist</a></code>;
<code><a href=#the-dfn-element>dfn</a></code>;
<code><a href=#the-em-element>em</a></code>;
@@ -95909,7 +95903,7 @@
<code><a href=#the-ruby-element>ruby</a></code>;
<code><a href=#the-s-element>s</a></code>;
<code><a href=#the-samp-element>samp</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-small-element>small</a></code>;
<code><a href=#the-span-element>span</a></code>;
@@ -95921,7 +95915,7 @@
<code><a href=#the-time-element>time</a></code>;
<code><a href=#the-u-element>u</a></code>;
<code><a href=#the-var-element>var</a></code>;
- <code><a href=#video>video</a></code>;
+ <code><a href=#the-video-element>video</a></code>;
<code><a href=#the-wbr-element>wbr</a></code>;
<a href=#text-content title="text content">Text</a>
<td>
@@ -95934,13 +95928,13 @@
<!--MD-->
<code><a href=#the-map-element>map</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)<!--
--><!--MD--><!--
- -->; <code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)<!--
+ -->; <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)<!--
--><!--MD--><!--
-->
<tr><td> <a href=#embedded-content>Embedded content</a>
<td>
- <code><a href=#audio>audio</a></code>
+ <code><a href=#the-audio-element>audio</a></code>
<code><a href=#the-canvas-element>canvas</a></code>
<code><a href=#the-embed-element>embed</a></code>
<code><a href=#the-iframe-element>iframe</a></code>
@@ -95948,7 +95942,7 @@
<code><a href=#math>math</a></code>
<code><a href=#the-object-element>object</a></code>
<code><a href=#svg>svg</a></code>
- <code><a href=#video>video</a></code>
+ <code><a href=#the-video-element>video</a></code>
<td>
—
@@ -95964,12 +95958,12 @@
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-textarea-element>textarea</a></code>;
<td>
- <code><a href=#audio>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present);
+ <code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present);
<code><a href=#the-img-element>img</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present);
<code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state);
- <code><a href=#menus>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state);
+ <code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state);
<code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section -->;
- <code><a href=#video>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)
+ <code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)
<tr><td> <a href=#sectioning-root title="sectioning root">Sectioning roots</a>
<td>
@@ -97185,7 +97179,7 @@
<tr><td> <code><a href=#the-aside-element>aside</a></code>
<td> <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#audio>audio</a></code>
+ <tr><td> <code><a href=#the-audio-element>audio</a></code>
<td> <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-b-element>b</a></code>
@@ -97230,7 +97224,7 @@
<tr><td> <code><a href=#the-colgroup-element>colgroup</a></code>
<td> <code><a href=#htmltablecolelement>HTMLTableColElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-command>command</a></code>
+ <tr><td> <code><a href=#the-command-element>command</a></code>
<td> <code><a href=#htmlcommandelement>HTMLCommandElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-datalist-element>datalist</a></code>
@@ -97275,7 +97269,7 @@
<tr><td> <code><a href=#the-form-element>form</a></code>
<td> <code><a href=#htmlformelement>HTMLFormElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-head-element-0>head</a></code>
+ <tr><td> <code><a href=#the-head-element>head</a></code>
<td> <code><a href=#htmlheadelement>HTMLHeadElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>
@@ -97305,7 +97299,7 @@
<tr><td> <code><a href=#the-hr-element>hr</a></code>
<td> <code><a href=#htmlhrelement>HTMLHRElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-html-element-0>html</a></code>
+ <tr><td> <code><a href=#the-html-element>html</a></code>
<td> <code><a href=#htmlhtmlelement>HTMLHtmlElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-i-element>i</a></code>
@@ -97455,7 +97449,7 @@
<tr><td> <code><a href=#the-time-element>time</a></code>
<td> <code><a href=#htmltimeelement>HTMLTimeElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-title-element-0>title</a></code>
+ <tr><td> <code><a href=#the-title-element>title</a></code>
<td> <code><a href=#htmltitleelement>HTMLTitleElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-tr-element>tr</a></code>
@@ -97473,7 +97467,7 @@
<tr><td> <code><a href=#the-var-element>var</a></code>
<td> <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#video>video</a></code>
+ <tr><td> <code><a href=#the-video-element>video</a></code>
<td> <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-wbr-element>wbr</a></code>
Modified: index
===================================================================
--- index 2011-05-03 01:10:20 UTC (rev 6049)
+++ index 2011-05-03 19:18:56 UTC (rev 6050)
@@ -468,14 +468,14 @@
<ol>
<li><a href=#the-root-element><span class=secno>4.1 </span>The root element</a>
<ol>
- <li><a href=#the-html-element-0><span class=secno>4.1.1 </span>The <code>html</code> element</a></ol></li>
+ <li><a href=#the-html-element><span class=secno>4.1.1 </span>The <code>html</code> element</a></ol></li>
<li><a href=#document-metadata><span class=secno>4.2 </span>Document metadata</a>
<ol>
- <li><a href=#the-head-element-0><span class=secno>4.2.1 </span>The <code>head</code> element</a></li>
- <li><a href=#the-title-element-0><span class=secno>4.2.2 </span>The <code>title</code> element</a></li>
+ <li><a href=#the-head-element><span class=secno>4.2.1 </span>The <code>head</code> element</a></li>
+ <li><a href=#the-title-element><span class=secno>4.2.2 </span>The <code>title</code> element</a></li>
<li><a href=#the-base-element><span class=secno>4.2.3 </span>The <code>base</code> element</a></li>
<li><a href=#the-link-element><span class=secno>4.2.4 </span>The <code>link</code> element</a></li>
- <li><a href=#meta><span class=secno>4.2.5 </span>The <code>meta</code> element</a>
+ <li><a href=#the-meta-element><span class=secno>4.2.5 </span>The <code>meta</code> element</a>
<ol>
<li><a href=#standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</a></li>
<li><a href=#other-metadata-names><span class=secno>4.2.5.2 </span>Other metadata names</a></li>
@@ -486,7 +486,7 @@
<li><a href=#styling><span class=secno>4.2.7 </span>Styling</a></ol></li>
<li><a href=#scripting-1><span class=secno>4.3 </span>Scripting</a>
<ol>
- <li><a href=#script><span class=secno>4.3.1 </span>The <code>script</code> element</a>
+ <li><a href=#the-script-element><span class=secno>4.3.1 </span>The <code>script</code> element</a>
<ol>
<li><a href=#scriptingLanguages><span class=secno>4.3.1.1 </span>Scripting languages</a></li>
<li><a href=#restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span>Restrictions for contents of <code>script</code> elements</a></li>
@@ -500,10 +500,7 @@
<li><a href=#the-nav-element><span class=secno>4.4.3 </span>The <code>nav</code> element</a></li>
<li><a href=#the-article-element><span class=secno>4.4.4 </span>The <code>article</code> element</a></li>
<li><a href=#the-aside-element><span class=secno>4.4.5 </span>The <code>aside</code> element</a></li>
- <li><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <code>h1</code>, <code>h2</code>,
- <code>h3</code>, <code>h4</code>,
- <code>h5</code>, and <code>h6</code>
- elements</a></li>
+ <li><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code> elements</a></li>
<li><a href=#the-hgroup-element><span class=secno>4.4.7 </span>The <code>hgroup</code> element</a></li>
<li><a href=#the-header-element><span class=secno>4.4.8 </span>The <code>header</code> element</a></li>
<li><a href=#the-footer-element><span class=secno>4.4.9 </span>The <code>footer</code> element</a></li>
@@ -587,8 +584,8 @@
<li><a href=#the-embed-element><span class=secno>4.8.3 </span>The <code>embed</code> element</a></li>
<li><a href=#the-object-element><span class=secno>4.8.4 </span>The <code>object</code> element</a></li>
<li><a href=#the-param-element><span class=secno>4.8.5 </span>The <code>param</code> element</a></li>
- <li><a href=#video><span class=secno>4.8.6 </span>The <code>video</code> element</a></li>
- <li><a href=#audio><span class=secno>4.8.7 </span>The <code>audio</code> element</a></li>
+ <li><a href=#the-video-element><span class=secno>4.8.6 </span>The <code>video</code> element</a></li>
+ <li><a href=#the-audio-element><span class=secno>4.8.7 </span>The <code>audio</code> element</a></li>
<li><a href=#the-source-element><span class=secno>4.8.8 </span>The <code>source</code> element</a></li>
<li><a href=#the-track-element><span class=secno>4.8.9 </span>The <code>track</code> element</a></li>
<li><a href=#media-elements><span class=secno>4.8.10 </span>Media elements</a>
@@ -778,8 +775,8 @@
<ol>
<li><a href=#the-details-element><span class=secno>4.11.1 </span>The <code>details</code> element</a></li>
<li><a href=#the-summary-element><span class=secno>4.11.2 </span>The <code>summary</code> element</a></li>
- <li><a href=#the-command><span class=secno>4.11.3 </span>The <code>command</code> element</a></li>
- <li><a href=#menus><span class=secno>4.11.4 </span>The <code>menu</code> element</a>
+ <li><a href=#the-command-element><span class=secno>4.11.3 </span>The <code>command</code> element</a></li>
+ <li><a href=#the-menu-element><span class=secno>4.11.4 </span>The <code>menu</code> element</a>
<ol>
<li><a href=#menus-intro><span class=secno>4.11.4.1 </span>Introduction</a></li>
<li><a href=#building-menus-and-toolbars><span class=secno>4.11.4.2 </span>Building menus and toolbars</a></li>
@@ -1923,9 +1920,9 @@
<p>The <a href=#intro-early-example>markup snippet at the top of
this section</a> would be turned into the following DOM tree:</p>
- <ul class=domTree><li class=t10>DOCTYPE: <code title="">html</code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-title-element-0>title</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-p-element>p</a></code><u
l><li class=t3><code>#text</code>: <span title="">This is a </span><li class=t1><code><a href=#the-a-element>a</a></code> <span class=t2 title=""><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class=t3><code>#text</code>: <span title="">simple</span></ul><li class=t3><code>#text</code>: <span title=""> sample.</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t8><code>#comment</code>: <span title=""> this is a comment </span><li class=t3><code>#text</code>: <span title="">⏎␣⏎</span></ul></ul></ul><p>The <a href=#root-element>root element</a> of this tree is the
- <code><a href=#the-html-element-0>html</a></code> element, which is the element always found at the
- root of HTML documents. It contains two elements, <code><a href=#the-head-element-0>head</a></code>
+ <ul class=domTree><li class=t10>DOCTYPE: <code title="">html</code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-title-element>title</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li
class=t3><code>#text</code>: <span title="">This is a </span><li class=t1><code><a href=#the-a-element>a</a></code> <span class=t2 title=""><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class=t3><code>#text</code>: <span title="">simple</span></ul><li class=t3><code>#text</code>: <span title=""> sample.</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t8><code>#comment</code>: <span title=""> this is a comment </span><li class=t3><code>#text</code>: <span title="">⏎␣⏎</span></ul></ul></ul><p>The <a href=#root-element>root element</a> of this tree is the
+ <code><a href=#the-html-element>html</a></code> element, which is the element always found at the
+ root of HTML documents. It contains two elements, <code><a href=#the-head-element>head</a></code>
and <code><a href=#the-body-element-0>body</a></code>, as well as a text node between them.</p>
<p>There are many more text nodes in the DOM tree than one would
@@ -1934,11 +1931,11 @@
all end up as text nodes in the DOM. However, for historical reasons
not all of the spaces and line breaks in the original markup appear
in the DOM. In particular, all the whitespace before
- <code><a href=#the-head-element-0>head</a></code> start tag ends up being dropped silently, and all
+ <code><a href=#the-head-element>head</a></code> start tag ends up being dropped silently, and all
the whitespace after the <code><a href=#the-body-element-0>body</a></code> end tag ends up placed at
the end of the <code><a href=#the-body-element-0>body</a></code>.</p>
- <p>The <code><a href=#the-head-element-0>head</a></code> element contains a <code><a href=#the-title-element-0>title</a></code>
+ <p>The <code><a href=#the-head-element>head</a></code> element contains a <code><a href=#the-title-element>title</a></code>
element, which itself contains a text node with the text "Sample
page". Similarly, the <code><a href=#the-body-element-0>body</a></code> element contains an
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element, a <code><a href=#the-p-element>p</a></code> element, and a
@@ -1946,14 +1943,14 @@
<hr><p>This DOM tree can be manipulated from scripts in the
page. Scripts (typically in JavaScript) are small programs that can
- be embedded using the <code><a href=#script>script</a></code> element or using
+ be embedded using the <code><a href=#the-script-element>script</a></code> element or using
<a href=#event-handler-content-attributes>event handler content attributes</a>. For example, here is
a form with a script that sets the value of the form's
<code><a href=#the-output-element>output</a></code> element to say "Hello World":</p>
<pre><<a href=#the-form-element>form</a> <a href=#attr-form-name title=attr-form-name>name</a>="main">
Result: <<a href=#the-output-element>output</a> <a href=#attr-fe-name title=attr-fe-name>name</a>="result"></output>
- <<a href=#script>script</a>>
+ <<a href=#the-script-element>script</a>>
<a href=#htmldocument title=HTMLDocument>document</a>.<a href=#dom-document-forms title=dom-document-forms>forms</a>.main.<a href=#dom-form-elements title=dom-form-elements>elements</a>.result.<a href=#dom-output-value title=dom-output-value>value</a> = 'Hello World';
</script>
</form></pre>
@@ -2530,14 +2527,14 @@
encouraging authors to avoid making them, authors can save time in
future efforts.</p>
- <p class=example>For example, a <code><a href=#script>script</a></code> element's
+ <p class=example>For example, a <code><a href=#the-script-element>script</a></code> element's
<code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute causes the
element's contents to be ignored. However, this isn't obvious,
especially if the element's contents appear to be executable
script — which can lead to authors spending a lot of time
trying to debug the inline script without realizing that it is not
executing. To reduce this problem, this specification makes it
- non-conforming to have executable script in a <code><a href=#script>script</a></code>
+ non-conforming to have executable script in a <code><a href=#the-script-element>script</a></code>
element when the <code title=attr-script-src><a href=#attr-script-src>src</a></code>
attribute is present. This means that authors who are validating
their documents are less likely to waste time with this kind of
@@ -2880,7 +2877,7 @@
described in the DOM Core specification. For example, the <code title=dom-cloneNode>cloneNode()</code> and <code title=dom-importNode>importNode()</code> methods of the
<code><a href=#node>Node</a></code> interface both clone nodes, as do a number of
algorithms in this specification. Certain <a href=#html-elements>HTML elements</a>
- (in particular, <code><a href=#the-input-element>input</a></code> and <code><a href=#script>script</a></code>) apply
+ (in particular, <code><a href=#the-input-element>input</a></code> and <code><a href=#the-script-element>script</a></code>) apply
additional requirements on how they are cloned. <a href=#refsDOMCORE>[DOMCORE]</a></p>
@@ -3077,11 +3074,11 @@
specifications.</p>
<p class=example>A conforming XHTML processor would, upon
- finding an XHTML <code><a href=#script>script</a></code> element in an XML document,
+ finding an XHTML <code><a href=#the-script-element>script</a></code> element in an XML document,
execute the script contained in that element. However, if the
element is found within a transformation expressed in XSLT
(assuming the user agent also supports XSLT), then the processor
- would instead treat the <code><a href=#script>script</a></code> element as an opaque
+ would instead treat the <code><a href=#the-script-element>script</a></code> element as an opaque
element that forms part of the transform.</p>
<p>Web browsers that support <a href=#syntax>the HTML syntax</a> must
@@ -3096,7 +3093,7 @@
<p class=note>Unless explicitly stated, specifications that
override the semantics of HTML elements do not override the
requirements on DOM objects representing those elements. For
- example, the <code><a href=#script>script</a></code> element in the example above
+ example, the <code><a href=#the-script-element>script</a></code> element in the example above
would still implement the <code><a href=#htmlscriptelement>HTMLScriptElement</a></code>
interface.</p>
@@ -3558,7 +3555,7 @@
include data on HTML elements that scripts can then look for and
process.</li>
- <li>Authors can use the <code title=meta><a href=#meta><meta name=""
+ <li>Authors can use the <code title=meta><a href=#the-meta-element><meta name=""
content=""></a></code> mechanism to include page-wide metadata by
registering <a href=#concept-meta-extensions title=concept-meta-extensions>extensions to the
predefined set of metadata names</a>.</li>
@@ -3567,7 +3564,7 @@
links with specific meanings by registering <a href=#concept-rel-extensions title=concept-rel-extensions>extensions to the predefined set of
link types</a>. This is also used by Microformats.</li>
- <li>Authors can embed raw data using the <code title=script><a href=#script><script type=""></a></code> mechanism with a custom
+ <li>Authors can embed raw data using the <code title=script><a href=#the-script-element><script type=""></a></code> mechanism with a custom
type, for further handling by inline or server-side scripts.</li>
<li>Authors can create <a href=#plugin title=plugin>plugins</a> and
@@ -7086,7 +7083,7 @@
specification. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p>
- <h4 id=extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code><a href=#meta>meta</a></code> elements</h4>
+ <h4 id=extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code><a href=#the-meta-element>meta</a></code> elements</h4>
<p>The <dfn id=algorithm-for-extracting-an-encoding-from-a-meta-element>algorithm for extracting an encoding from a
<code>meta</code> element</dfn>, given a string <var title="">s</var>, is as follows. It either returns an encoding or
@@ -9005,43 +9002,43 @@
<h4 id=dom-tree-accessors><span class=secno>3.1.4 </span><dfn>DOM tree accessors</dfn></h4>
- <p><dfn id=the-html-element>The <code>html</code> element</dfn> of a document is the
+ <p><dfn id=the-html-element-0>The <code>html</code> element</dfn> of a document is the
document's root element, if there is one and it's an
- <code><a href=#the-html-element-0>html</a></code> element, or null otherwise.</p>
+ <code><a href=#the-html-element>html</a></code> element, or null otherwise.</p>
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-head><a href=#dom-document-head>head</a></code></dt>
<dd>
- <p>Returns <a href=#the-head-element>the <code>head</code> element</a>.</p>
+ <p>Returns <a href=#the-head-element-0>the <code>head</code> element</a>.</p>
</dd>
- </dl><p><dfn id=the-head-element>The <code>head</code> element</dfn> of a document is the
- first <code><a href=#the-head-element-0>head</a></code> element that is a child of <a href=#the-html-element>the
+ </dl><p><dfn id=the-head-element-0>The <code>head</code> element</dfn> of a document is the
+ first <code><a href=#the-head-element>head</a></code> element that is a child of <a href=#the-html-element-0>the
<code>html</code> element</a>, if there is one, or null
otherwise.</p>
<div class=impl>
<p>The <dfn id=dom-document-head title=dom-document-head><code>head</code></dfn>
- attribute, on getting, must return <a href=#the-head-element>the <code>head</code>
- element</a> of the document (a <code><a href=#the-head-element-0>head</a></code> element or
+ attribute, on getting, must return <a href=#the-head-element-0>the <code>head</code>
+ element</a> of the document (a <code><a href=#the-head-element>head</a></code> element or
null).</p>
</div>
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-title><a href=#document.title>title</a></code> [ = <var title="">value</var> ]</dt>
<dd>
- <p>Returns the document's title, as given by <a href=#the-title-element>the
+ <p>Returns the document's title, as given by <a href=#the-title-element-0>the
<code>title</code> element</a>.</p>
<p>Can be set, to update the document's title. If there is no
- <a href=#the-head-element title="the head element"><code>head</code> element</a>,
+ <a href=#the-head-element-0 title="the head element"><code>head</code> element</a>,
the new value is ignored.</p>
<p>In SVG documents, the <code>SVGDocument</code> interface's
<code title=dom-svg-title>title</code> attribute takes
precedence.</p>
</dd>
- </dl><p><dfn id=the-title-element>The <code>title</code> element</dfn> of a document is the
- first <code><a href=#the-title-element-0>title</a></code> element in the document (in tree order), if
+ </dl><p><dfn id=the-title-element-0>The <code>title</code> element</dfn> of a document is the
+ first <code><a href=#the-title-element>title</a></code> element in the document (in tree order), if
there is one, or null otherwise.</p>
<div class=impl>
@@ -9057,8 +9054,8 @@
<li><p>Otherwise, let <var title="">value</var> be a concatenation
of the data of all the child <a href=#text-node title="text node">text
- nodes</a> of <a href=#the-title-element>the <code>title</code> element</a>, in
- <a href=#tree-order>tree order</a>, or the empty string if <a href=#the-title-element>the
+ nodes</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, in
+ <a href=#tree-order>tree order</a>, or the empty string if <a href=#the-title-element-0>the
<code>title</code> element</a> is null.</li>
<li><p>Replace any sequence of one or more consecutive <a href=#space-character title="space character">space characters</a> in <var title="">value</var> with a single U+0020 SPACE character.</li>
@@ -9078,13 +9075,13 @@
<code>SVGDocument</code> interface (if it is readonly, then this
will raise an exception). Stop the algorithm here. <a href=#refsSVG>[SVG]</a></li>
- <li>If <a href=#the-title-element>the <code>title</code> element</a> is null and
- <a href=#the-head-element>the <code>head</code> element</a> is null, then the
+ <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null and
+ <a href=#the-head-element-0>the <code>head</code> element</a> is null, then the
attribute must do nothing. Stop the algorithm here.</li>
- <li>If <a href=#the-title-element>the <code>title</code> element</a> is null, then a
- new <code><a href=#the-title-element-0>title</a></code> element must be created and appended to
- <a href=#the-head-element>the <code>head</code> element</a>. Let <var title="">element</var> be that element. Otherwise, let <var title="">element</var> be <a href=#the-title-element>the <code>title</code>
+ <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null, then a
+ new <code><a href=#the-title-element>title</a></code> element must be created and appended to
+ <a href=#the-head-element-0>the <code>head</code> element</a>. Let <var title="">element</var> be that element. Otherwise, let <var title="">element</var> be <a href=#the-title-element-0>the <code>title</code>
element</a>.</li>
<li>The children of <var title="">element</var> (if any) must all
@@ -9108,7 +9105,7 @@
</dd>
</dl><p><dfn id=the-body-element>The body element</dfn> of a document is the first child of
- <a href=#the-html-element>the <code>html</code> element</a> that is either a
+ <a href=#the-html-element-0>the <code>html</code> element</a> that is either a
<code><a href=#the-body-element-0>body</a></code> element or a <code><a href=#frameset>frameset</a></code> element. If
there is no such element, it is null. <span class=impl>If the body
element is null, then when the specification requires that events be
@@ -9173,7 +9170,7 @@
<dt><var title="">document</var> . <code title=dom-document-scripts><a href=#dom-document-scripts>scripts</a></code></dt>
<dd>
- <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#script>script</a></code> elements in the <code><a href=#document>Document</a></code>.</p>
+ <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-script-element>script</a></code> elements in the <code><a href=#document>Document</a></code>.</p>
</dd>
</dl><div class=impl>
@@ -9208,7 +9205,7 @@
<p>The <dfn id=dom-document-scripts title=dom-document-scripts><code>scripts</code></dfn>
attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the
<code><a href=#document>Document</a></code> node, whose filter matches only
- <code><a href=#script>script</a></code> elements.</p>
+ <code><a href=#the-script-element>script</a></code> elements.</p>
<hr></div>
@@ -9333,7 +9330,7 @@
<p>Each entry in the <a href=#css-id-overrides-list>CSS ID overrides list</a>, while it is
in the list and is either <a href=#in-a-document title="in a Document">in the
<code>Document</code></a> or is an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#video>video</a></code>, or <code><a href=#the-canvas-element>canvas</a></code> element, defines a
+ <code><a href=#the-video-element>video</a></code>, or <code><a href=#the-canvas-element>canvas</a></code> element, defines a
<span>CSS element reference identifier</span> mapping the given name
to the given <code><a href=#element>Element</a></code>. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p>
@@ -9501,7 +9498,7 @@
<dd>
<p>Returns a new <code><a href=#document>Document</a></code>, with a basic DOM already
- constructed with an appropriate <code><a href=#the-title-element-0>title</a></code> element.</p>
+ constructed with an appropriate <code><a href=#the-title-element>title</a></code> element.</p>
</dd>
@@ -9521,20 +9518,20 @@
and empty lists, as appropriate. Append the newly created node to
<var title="">doc</var>.</li>
- <li><p>Create an <code><a href=#the-html-element-0>html</a></code> element, and append it to <var title="">doc</var>.</li>
+ <li><p>Create an <code><a href=#the-html-element>html</a></code> element, and append it to <var title="">doc</var>.</li>
- <li><p>Create a <code><a href=#the-head-element-0>head</a></code> element, and append it to the
- <code><a href=#the-html-element-0>html</a></code> element created in the previous step.</p>
+ <li><p>Create a <code><a href=#the-head-element>head</a></code> element, and append it to the
+ <code><a href=#the-html-element>html</a></code> element created in the previous step.</p>
- <li><p>Create a <code><a href=#the-title-element-0>title</a></code> element, and append it to the
- <code><a href=#the-head-element-0>head</a></code> element created in the previous step.</p>
+ <li><p>Create a <code><a href=#the-title-element>title</a></code> element, and append it to the
+ <code><a href=#the-head-element>head</a></code> element created in the previous step.</p>
<li><p>Create a <code><a href=#text>Text</a></code> node, and set its <code title="">data</code> attribute to the string given by the method's
argument (which could be the empty string). Append it to the
- <code><a href=#the-title-element-0>title</a></code> element created in the previous step.</p>
+ <code><a href=#the-title-element>title</a></code> element created in the previous step.</p>
<li><p>Create a <code><a href=#the-body-element-0>body</a></code> element, and append it to the
- <code><a href=#the-html-element-0>html</a></code> element created in the earlier step.</p>
+ <code><a href=#the-html-element>html</a></code> element created in the earlier step.</p>
<li><p>Return <var title="">doc</var>.</li>
@@ -10355,7 +10352,7 @@
determined and that is either:</p>
<ul class=brief><li>A <code><a href=#the-bdi-element>bdi</a></code> element.
- <li>A <code><a href=#script>script</a></code> element.
+ <li>A <code><a href=#the-script-element>script</a></code> element.
<li>A <code><a href=#the-style-element>style</a></code> element.
<li>An element with a <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute in a defined state.
</ul></li>
@@ -10392,9 +10389,9 @@
<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-dir><a href=#dom-dir>dir</a></code> [ = <var title="">value</var> ]</dt>
<dd>
- <p>Returns <a href=#the-html-element>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value, if any.</p>
- <p>Can be set, to either "<code title="">ltr</code>", "<code title="">rtl</code>", or "<code title="">auto</code>" to replace <a href=#the-html-element>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value.</p>
- <p>If there is no <a href=#the-html-element title="the html element"><code>html</code> element</a>, returns the empty string and ignores new values.</p>
+ <p>Returns <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value, if any.</p>
+ <p>Can be set, to either "<code title="">ltr</code>", "<code title="">rtl</code>", or "<code title="">auto</code>" to replace <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value.</p>
+ <p>If there is no <a href=#the-html-element-0 title="the html element"><code>html</code> element</a>, returns the empty string and ignores new values.</p>
</dd>
</dl><div class=impl>
@@ -10406,7 +10403,7 @@
<p>The <dfn id=dom-document-dir title=dom-document-dir><code>dir</code></dfn> IDL
attribute on <code><a href=#htmldocument>HTMLDocument</a></code> objects must
<a href=#reflect>reflect</a> the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content
- attribute of <a href=#the-html-element>the <code>html</code> element</a>, if any,
+ attribute of <a href=#the-html-element-0>the <code>html</code> element</a>, if any,
<a href=#limited-to-only-known-values>limited to only known values</a>. If there is no such
element, then the attribute must return the empty string and do
nothing on setting.</p>
@@ -10937,13 +10934,13 @@
<!-- when updating this also update the category index -->
<ul class="brief category-list"><li><code><a href=#the-base-element>base</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-link-element>link</a></code></li>
- <li><code><a href=#meta>meta</a></code></li>
+ <li><code><a href=#the-meta-element>meta</a></code></li>
<li><code><a href=#the-noscript-element>noscript</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-style-element>style</a></code></li>
- <li><code><a href=#the-title-element-0>title</a></code></li>
+ <li><code><a href=#the-title-element>title</a></code></li>
</ul><p>Elements from other namespaces whose semantics are primarily
metadata-related (e.g. RDF) are also <a href=#metadata-content>metadata
content</a>.</p>
@@ -10989,7 +10986,7 @@
<li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li>
<li><code><a href=#the-article-element>article</a></code></li>
<li><code><a href=#the-aside-element>aside</a></code></li>
- <li><code><a href=#audio>audio</a></code></li>
+ <li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-b-element>b</a></code></li>
<li><code><a href=#the-bdi-element>bdi</a></code></li>
<li><code><a href=#the-bdo-element>bdo</a></code></li>
@@ -10999,7 +10996,7 @@
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-cite-element>cite</a></code></li>
<li><code><a href=#the-code-element>code</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-datalist-element>datalist</a></code></li>
<li><code><a href=#the-del-element>del</a></code></li>
<li><code><a href=#the-details-element>details</a></code></li>
@@ -11035,9 +11032,9 @@
<li><code><a href=#the-map-element>map</a></code></li>
<li><code><a href=#the-mark-element>mark</a></code></li>
<li><code><a href=#math>math</a></code></li>
- <li><code><a href=#menus>menu</a></code></li>
+ <li><code><a href=#the-menu-element>menu</a></code></li>
<!--MD-->
- <li><code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
+ <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
<!--MD-->
<li><code><a href=#the-meter-element>meter</a></code></li>
<li><code><a href=#the-nav-element>nav</a></code></li>
@@ -11052,7 +11049,7 @@
<li><code><a href=#the-ruby-element>ruby</a></code></li>
<li><code><a href=#the-s-element>s</a></code></li>
<li><code><a href=#the-samp-element>samp</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-section-element>section</a></code></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-small-element>small</a></code></li>
@@ -11068,7 +11065,7 @@
<li><code><a href=#the-u-element>u</a></code></li>
<li><code><a href=#the-ul-element>ul</a></code></li>
<li><code><a href=#the-var-element>var</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
<li><code><a href=#the-wbr-element>wbr</a></code></li>
<li><a href=#text-content title="text content">Text</a></li>
</ul><p>As a general rule, elements whose content model allows any
@@ -11130,7 +11127,7 @@
<ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li>
<li><code><a href=#the-abbr-element>abbr</a></code></li>
<li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li>
- <li><code><a href=#audio>audio</a></code></li>
+ <li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-b-element>b</a></code></li>
<li><code><a href=#the-bdi-element>bdi</a></code></li>
<li><code><a href=#the-bdo-element>bdo</a></code></li>
@@ -11139,7 +11136,7 @@
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-cite-element>cite</a></code></li>
<li><code><a href=#the-code-element>code</a></code></li>
- <li><code><a href=#the-command>command</a></code></li>
+ <li><code><a href=#the-command-element>command</a></code></li>
<li><code><a href=#the-datalist-element>datalist</a></code></li>
<li><code><a href=#the-del-element>del</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li>
<li><code><a href=#the-dfn-element>dfn</a></code></li>
@@ -11160,7 +11157,7 @@
<li><code><a href=#the-mark-element>mark</a></code></li>
<li><code><a href=#math>math</a></code></li>
<!--MD-->
- <li><code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
+ <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li>
<!--MD-->
<li><code><a href=#the-meter-element>meter</a></code></li>
<li><code><a href=#the-noscript-element>noscript</a></code></li>
@@ -11171,7 +11168,7 @@
<li><code><a href=#the-ruby-element>ruby</a></code></li>
<li><code><a href=#the-s-element>s</a></code></li>
<li><code><a href=#the-samp-element>samp</a></code></li>
- <li><code><a href=#script>script</a></code></li>
+ <li><code><a href=#the-script-element>script</a></code></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-small-element>small</a></code></li>
<li><code><a href=#the-span-element>span</a></code></li>
@@ -11183,7 +11180,7 @@
<li><code><a href=#the-time-element>time</a></code></li>
<li><code><a href=#the-u-element>u</a></code></li>
<li><code><a href=#the-var-element>var</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
<li><code><a href=#the-wbr-element>wbr</a></code></li>
<li><a href=#text-content title="text content">Text</a></li>
</ul><p>As a general rule, elements whose content model allows any
@@ -11215,7 +11212,7 @@
is inserted into the document.</p>
<!-- when updating this also update the category index -->
- <ul class="brief category-list"><li><code><a href=#audio>audio</a></code></li>
+ <ul class="brief category-list"><li><code><a href=#the-audio-element>audio</a></code></li>
<li><code><a href=#the-canvas-element>canvas</a></code></li>
<li><code><a href=#the-embed-element>embed</a></code></li>
<li><code><a href=#the-iframe-element>iframe</a></code></li>
@@ -11223,7 +11220,7 @@
<li><code><a href=#math>math</a></code></li>
<li><code><a href=#the-object-element>object</a></code></li>
<li><code><a href=#svg>svg</a></code></li>
- <li><code><a href=#video>video</a></code></li>
+ <li><code><a href=#the-video-element>video</a></code></li>
</ul><p>Elements that are from namespaces other than the <a href=#html-namespace-0>HTML
namespace</a> and that convey content but not metadata, are
<a href=#embedded-content>embedded content</a> for the purposes of the content models
@@ -11253,7 +11250,7 @@
<!-- when updating this also update the category index -->
<ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code></li>
- <li><code><a href=#audio>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
+ <li><code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
<li><code><a href=#the-button-element>button</a></code></li>
<li><code><a href=#the-details-element>details</a></code></li>
<li><code><a href=#the-embed-element>embed</a></code></li>
@@ -11262,11 +11259,11 @@
<li><code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state)</li>
<li><code><a href=#the-keygen-element>keygen</a></code></li>
<li><code><a href=#the-label-element>label</a></code></li>
- <li><code><a href=#menus>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state)</li>
+ <li><code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state)</li>
<li><code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section --></li>
<li><code><a href=#the-select-element>select</a></code></li>
<li><code><a href=#the-textarea-element>textarea</a></code></li>
- <li><code><a href=#video>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
+ <li><code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li>
</ul><p>Certain elements in HTML have an <a href=#activation-behavior>activation
behavior</a>, which means that the user can activate them. This
triggers a sequence of events dependent on the activation mechanism,
@@ -11511,7 +11508,7 @@
<p>Conformance checkers may warn authors of cases where they have
paragraphs that overlap each other (this can happen with
- <code><a href=#the-object-element>object</a></code>, <code><a href=#video>video</a></code>, <code><a href=#audio>audio</a></code>, and
+ <code><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, <code><a href=#the-audio-element>audio</a></code>, and
<code><a href=#the-canvas-element>canvas</a></code> elements, and indirectly through elements in
other namespaces that allow HTML to be further embedded therein,
like <code><a href=#svg>svg</a></code> or <code><a href=#math>math</a></code>).</p> <!-- example below
@@ -11749,7 +11746,7 @@
<td><code title="attr-aria-role-heading">heading</code> role, with the <code title="attr-aria-level">aria-level</code> property set to the element's <span>outline depth</span>
-->
- <tr><td><code><a href=#the-head-element-0>head</a></code> element
+ <tr><td><code><a href=#the-head-element>head</a></code> element
<td>No role
<tr><td><code><a href=#the-hgroup-element>hgroup</a></code> element
@@ -11758,7 +11755,7 @@
<tr><td><code><a href=#the-hr-element>hr</a></code> element
<td><code title=attr-aria-role-separator>separator</code> role
- <tr><td><code><a href=#the-html-element-0>html</a></code> element
+ <tr><td><code><a href=#the-html-element>html</a></code> element
<td>No role
<tr><td><code><a href=#the-img-element>img</a></code> element whose <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value is empty
@@ -11842,16 +11839,16 @@
<tr><td><code><a href=#the-link-element>link</a></code> element that creates a <a href=#hyperlink>hyperlink</a>
<td><code title=attr-aria-role-link>link</code> role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#context-menu-state title="context menu state">context menu</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#context-menu-state title="context menu state">context menu</a> state
<td>No role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menu>menu</code> role
- <tr><td><code><a href=#menus>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state
+ <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state
<td><code title=attr-aria-role-toolbar>toolbar</code> role
- <tr><td><code><a href=#meta>meta</a></code> element
+ <tr><td><code><a href=#the-meta-element>meta</a></code> element
<td>No role
<tr><td><code><a href=#the-meter-element>meter</a></code> element
@@ -11875,7 +11872,7 @@
<tr><td><code><a href=#the-progress-element>progress</a></code> element
<td><code title=attr-aria-role-progressbar>progressbar</code> role, with, if the progress bar is determinate, the <code title=attr-aria-valuemax>aria-valuemax</code> property set to the maximum value of the progress bar, the <code title=attr-aria-valuemin>aria-valuemin</code> property set to zero, and the <code title=attr-aria-valuenow>aria-valuenow</code> property set to the current value of the progress bar
- <tr><td><code><a href=#script>script</a></code> element
+ <tr><td><code><a href=#the-script-element>script</a></code> element
<td>No role
<tr><td><code><a href=#the-select-element>select</a></code> element with a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute
@@ -11902,16 +11899,16 @@
<tr><td><code><a href=#the-textarea-element>textarea</a></code> element with a <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute
<td>The <code title=title-aria-required>aria-required</code> state set to "true"
- <tr><td><code><a href=#the-title-element-0>title</a></code> element
+ <tr><td><code><a href=#the-title-element>title</a></code> element
<td>No role
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "checkbox", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "checkbox", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "command", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "command", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitem>menuitem</code> role
- <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "radio", and that is a descendant of a <code><a href=#menus>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
+ <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "radio", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state
<td><code title=attr-aria-role-menuitemradio>menuitemradio</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise
<tr><td>Element that is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>
@@ -11955,7 +11952,7 @@
<td><code title=attr-aria-role-note>note</code> role
<td>Role must be either <code title=attr-aria-role-note>note</code>, <code title=attr-aria-role-complementary>complementary</code>, or <code title=attr-aria-role-search>search</code>
- <tr><td><code><a href=#audio>audio</a></code> element
+ <tr><td><code><a href=#the-audio-element>audio</a></code> element
<td>No role
<td>If specified, role must be <code title=attr-aria-role-application>application</code>
@@ -12069,7 +12066,7 @@
<td><code title=attr-aria-role-list>list</code> role
<td>Role must be either <code title=attr-aria-role-directory>directory</code>, <code title=attr-aria-role-list>list</code>, <code title=attr-aria-role-listbox>listbox</code>, <code title=attr-aria-role-menu>menu</code>, <code title=attr-aria-role-menubar>menubar</code>, <code title=attr-aria-role-tablist>tablist</code>, <code title="attr-aria-role-toolbar ">toolbar</code>, <code title=attr-aria-role-tree>tree</code>
- <tr><td><code><a href=#video>video</a></code> element
+ <tr><td><code><a href=#the-video-element>video</a></code> element
<td>No role
<td>If specified, role must be <code title=attr-aria-role-application>application</code>
@@ -12643,7 +12640,7 @@
<p><code><a href=#document>Document</a></code> objects have an
<dfn id=ignore-destructive-writes-counter>ignore-destructive-writes counter</dfn>, which is used in
- conjunction with the processing of <code><a href=#script>script</a></code> elements to
+ conjunction with the processing of <code><a href=#the-script-element>script</a></code> elements to
prevent external scripts from being able to use <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> to blow away the
document by implicitly calling <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code>. Initially, the
counter must be set to zero.</p>
@@ -12707,12 +12704,12 @@
at a time, processing resulting tokens as they are emitted, and
stopping when the tokenizer reaches the insertion point or when
the processing of the tokenizer is aborted by the tree
- construction stage (this can happen if a <code><a href=#script>script</a></code> end
+ construction stage (this can happen if a <code><a href=#the-script-element>script</a></code> end
tag token is emitted by the tokenizer).
<p class=note>If the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method was
called from script executing inline (i.e. executing because the
- parser parsed a set of <code><a href=#script>script</a></code> tags), then this is a
+ parser parsed a set of <code><a href=#the-script-element>script</a></code> tags), then this is a
<a href=#nestedParsing>reentrant invocation of the
parser</a>.</p>
@@ -13164,7 +13161,7 @@
<h3 id=the-root-element><span class=secno>4.1 </span>The root element</h3>
- <h4 id=the-html-element-0><span class=secno>4.1.1 </span>The <dfn><code>html</code></dfn> element</h4>
+ <h4 id=the-html-element><span class=secno>4.1.1 </span>The <dfn><code>html</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd>None.</dd>
@@ -13172,7 +13169,7 @@
<dd>As the root element of a document.</dd>
<dd>Wherever a subdocument fragment is allowed in a compound document.</dd>
<dt>Content model:</dt>
- <dd>A <code><a href=#the-head-element-0>head</a></code> element followed by a <code><a href=#the-body-element-0>body</a></code> element.</dd>
+ <dd>A <code><a href=#the-head-element>head</a></code> element followed by a <code><a href=#the-body-element-0>body</a></code> element.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dd><code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></dd>
@@ -13180,7 +13177,7 @@
<dd>
<pre class=idl>interface <dfn id=htmlhtmlelement>HTMLHtmlElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre>
</dd>
- </dl><p>The <code><a href=#the-html-element-0>html</a></code> element <a href=#represents>represents</a> the root of
+ </dl><p>The <code><a href=#the-html-element>html</a></code> element <a href=#represents>represents</a> the root of
an HTML document.</p>
<p>The <dfn id=attr-html-manifest title=attr-html-manifest><code>manifest</code></dfn>
@@ -13206,7 +13203,7 @@
<div class=example>
- <p>The <code><a href=#the-html-element-0>html</a></code> element in the following example declares
+ <p>The <code><a href=#the-html-element>html</a></code> element in the following example declares
that the document's language is English.</p>
<pre><!DOCTYPE html>
@@ -13228,27 +13225,27 @@
<h3 id=document-metadata><span class=secno>4.2 </span>Document metadata</h3>
- <h4 id=the-head-element-0><span class=secno>4.2.1 </span>The <dfn><code>head</code></dfn> element</h4>
+ <h4 id=the-head-element><span class=secno>4.2.1 </span>The <dfn><code>head</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>As the first element in an <code><a href=#the-html-element-0>html</a></code> element.</dd>
+ <dd>As the first element in an <code><a href=#the-html-element>html</a></code> element.</dd>
<dt>Content model:</dt>
<dd>If the document is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a> or if title information is available from a higher-level protocol: Zero or more elements of <a href=#metadata-content>metadata content</a>.</dd>
- <dd>Otherwise: One or more elements of <a href=#metadata-content>metadata content</a>, of which exactly one is a <code><a href=#the-title-element-0>title</a></code> element.</dd>
+ <dd>Otherwise: One or more elements of <a href=#metadata-content>metadata content</a>, of which exactly one is a <code><a href=#the-title-element>title</a></code> element.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd>
<pre class=idl>interface <dfn id=htmlheadelement>HTMLHeadElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre>
</dd>
- </dl><p>The <code><a href=#the-head-element-0>head</a></code> element <a href=#represents>represents</a> a
+ </dl><p>The <code><a href=#the-head-element>head</a></code> element <a href=#represents>represents</a> a
collection of metadata for the <code><a href=#document>Document</a></code>.</p>
<div class=example>
- <p>The collection of metadata in a <code><a href=#the-head-element-0>head</a></code> element can be
+ <p>The collection of metadata in a <code><a href=#the-head-element>head</a></code> element can be
large or small. Here is an example of a very short one:</p>
<pre><!doctype html>
@@ -13277,20 +13274,20 @@
</div>
- <p class=note>The <code><a href=#the-title-element-0>title</a></code> element is a required child
+ <p class=note>The <code><a href=#the-title-element>title</a></code> element is a required child
in most situations, but when a higher-level protocol provides title
information, e.g. in the Subject line of an e-mail when HTML is used
- as an e-mail authoring format, the <code><a href=#the-title-element-0>title</a></code> element can be
+ as an e-mail authoring format, the <code><a href=#the-title-element>title</a></code> element can be
omitted.</p>
- <h4 id=the-title-element-0><span class=secno>4.2.2 </span>The <dfn><code>title</code></dfn> element</h4>
+ <h4 id=the-title-element><span class=secno>4.2.2 </span>The <dfn><code>title</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element containing no other <code><a href=#the-title-element-0>title</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-title-element>title</a></code> elements.</dd>
<dt>Content model:</dt>
<dd><a href=#text-content title="text content">Text</a>.</dd>
<dt>Content attributes:</dt>
@@ -13301,7 +13298,7 @@
attribute DOMString <a href=#dom-title-text title=dom-title-text>text</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#the-title-element-0>title</a></code> element <a href=#represents>represents</a> the
+ </dl><p>The <code><a href=#the-title-element>title</a></code> element <a href=#represents>represents</a> the
document's title or name. Authors should use titles that identify
their documents even when they are used out of context, for example
in a user's history or bookmarks, or in search results. The
@@ -13309,7 +13306,7 @@
first heading does not have to stand alone when taken out of
context.</p>
- <p>There must be no more than one <code><a href=#the-title-element-0>title</a></code> element per
+ <p>There must be no more than one <code><a href=#the-title-element>title</a></code> element per
document.</p>
<dl class=domintro><dt><var title="">title</var> . <code title=dom-title-text><a href=#dom-title-text>text</a></code> [ = <var title="">value</var> ]</dt>
@@ -13329,7 +13326,7 @@
<p>The IDL attribute <dfn id=dom-title-text title=dom-title-text><code>text</code></dfn> must return a
concatenation of the contents of all the <a href=#text-node title="text
node">text nodes</a> that are direct children of the
- <code><a href=#the-title-element-0>title</a></code> element (ignoring any other nodes such as
+ <code><a href=#the-title-element>title</a></code> element (ignoring any other nodes such as
comments or elements), in tree order. On setting, it must act the
same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p>
@@ -13363,8 +13360,8 @@
<p>User agents should use the document's title when referring to the
document in their user interface. When the contents of a
- <code><a href=#the-title-element-0>title</a></code> element are used in this way, <a href=#the-directionality>the
- directionality</a> of that <code><a href=#the-title-element-0>title</a></code> element should be
+ <code><a href=#the-title-element>title</a></code> element are used in this way, <a href=#the-directionality>the
+ directionality</a> of that <code><a href=#the-title-element>title</a></code> element should be
used to set the directionality of the document's title in the user
interface.</p>
@@ -13376,7 +13373,7 @@
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element containing no other <code><a href=#the-base-element>base</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-base-element>base</a></code> elements.</dd>
<dt>Content model:</dt>
<dd>Empty.</dd>
<dt>Content attributes:</dt>
@@ -13407,7 +13404,7 @@
<p>A <code><a href=#the-base-element>base</a></code> element, if it has an <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute, must come before any
other elements in the tree that have attributes defined as taking
- <a href=#url title=URL>URLs</a>, except the <code><a href=#the-html-element-0>html</a></code> element
+ <a href=#url title=URL>URLs</a>, except the <code><a href=#the-html-element>html</a></code> element
(its <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute
isn't affected by <code><a href=#the-base-element>base</a></code> elements).</p>
@@ -13477,7 +13474,7 @@
<!--MD-->
<dt>Contexts in which this element can be used:</dt>
<dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd>
- <dd>In a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>In a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<!--MD-->
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
<!--MD-->
@@ -13841,7 +13838,7 @@
- <h4 id=meta><span class=secno>4.2.5 </span>The <dfn><code>meta</code></dfn> element</h4>
+ <h4 id=the-meta-element><span class=secno>4.2.5 </span>The <dfn id=meta><code>meta</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -13850,9 +13847,9 @@
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#phrasing-content>phrasing content</a>.</dd>
<!--MD-->
<dt>Contexts in which this element can be used:</dt>
- <dd>If the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute is present, or if the element's <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element-0>head</a></code> element.</dd>
- <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element-0>head</a></code> element.</dd>
- <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute is present, or if the element's <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd>
+ <dd>If the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is present but not in the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<dd>If the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd>
<!--MD-->
<dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd>
@@ -13874,12 +13871,12 @@
attribute DOMString <a href=#dom-meta-content title=dom-meta-content>content</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#meta>meta</a></code> element <a href=#represents>represents</a> various
+ </dl><p>The <code><a href=#the-meta-element>meta</a></code> element <a href=#represents>represents</a> various
kinds of metadata that cannot be expressed using the
- <code><a href=#the-title-element-0>title</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-link-element>link</a></code>,
- <code><a href=#the-style-element>style</a></code>, and <code><a href=#script>script</a></code> elements.</p>
+ <code><a href=#the-title-element>title</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-link-element>link</a></code>,
+ <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-script-element>script</a></code> elements.</p>
- <p>The <code><a href=#meta>meta</a></code> element can represent document-level
+ <p>The <code><a href=#the-meta-element>meta</a></code> element can represent document-level
metadata with the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>
attribute, pragma directives with the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute, and the
file's <a href=#character-encoding-declaration>character encoding declaration</a> when an HTML
@@ -13903,11 +13900,11 @@
UTF-8 as its encoding).</p>
<p class=note>The <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code>
- attribute on the <code><a href=#meta>meta</a></code> element has no effect in XML
+ attribute on the <code><a href=#the-meta-element>meta</a></code> element has no effect in XML
documents, and is only allowed in order to facilitate migration to
and from XHTML.</p>
- <p>There must not be more than one <code><a href=#meta>meta</a></code> element with a
+ <p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with a
<code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute per
document.</p>
@@ -13917,14 +13914,14 @@
values depend on the exact context, as described in subsequent
sections of this specification.</p>
- <p>If a <code><a href=#meta>meta</a></code> element has a <dfn id=attr-meta-name title=attr-meta-name><code>name</code></dfn> attribute, it sets
+ <p>If a <code><a href=#the-meta-element>meta</a></code> element has a <dfn id=attr-meta-name title=attr-meta-name><code>name</code></dfn> attribute, it sets
document metadata. Document metadata is expressed in terms of
name/value pairs, the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>
- attribute on the <code><a href=#meta>meta</a></code> element giving the name, and the
+ attribute on the <code><a href=#the-meta-element>meta</a></code> element giving the name, and the
<code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute on the same
element giving the value. The name specifies what aspect of metadata
is being set; valid names and the meaning of their values are
- described in the following sections. If a <code><a href=#meta>meta</a></code> element
+ described in the following sections. If a <code><a href=#the-meta-element>meta</a></code> element
has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute,
then the value part of the metadata name/value pair is the empty
string.</p>
@@ -13942,7 +13939,7 @@
<h5 id=standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</h5>
<p>This specification defines a few names for the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute of the
- <code><a href=#meta>meta</a></code> element.</p>
+ <code><a href=#the-meta-element>meta</a></code> element.</p>
<p>Names are case-insensitive<span class=impl>, and must be compared
in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner</span>.</p>
@@ -13952,11 +13949,11 @@
<dd><p>The value must be a short free-form string giving the name
of the Web application that the page represents. If the page is not
a Web application, the <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> metadata name
- must not be used. There must not be more than one <code><a href=#meta>meta</a></code>
+ must not be used. There must not be more than one <code><a href=#the-meta-element>meta</a></code>
element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute
set to the value <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> per
document. <span class=impl>User agents may use the application
- name in UI in preference to the page's <code><a href=#the-title-element-0>title</a></code>, since
+ name in UI in preference to the page's <code><a href=#the-title-element>title</a></code>, since
the title might include status messages and the like relevant to
the status of the page at a particular moment in time instead of
just being the name of the application.</span></dd>
@@ -13971,7 +13968,7 @@
<dd><p>The value must be a free-form string that describes the
page. The value must be appropriate for use in a directory of
pages, e.g. in a search engine. There must not be more than one
- <code><a href=#meta>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-description><a href=#meta-description>description</a></code> per document.</dd>
+ <code><a href=#the-meta-element>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-description><a href=#meta-description>description</a></code> per document.</dd>
<dt><dfn id=meta-generator title=meta-generator><code>generator</code></dfn></dt>
@@ -13984,7 +13981,7 @@
<div class=example>
<p>Here is what a tool called "Frontweaver" could include in its
- output, in the page's <code><a href=#the-head-element-0>head</a></code> element, to identify
+ output, in the page's <code><a href=#the-head-element>head</a></code> element, to identify
itself as the tool used to generate the page:</p>
<pre><meta name=generator content="Frontweaver 8.2"></pre>
@@ -14003,7 +14000,7 @@
<div class=example>
<p>This page about typefaces on British motorways uses a
- <code><a href=#meta>meta</a></code> element to specify some keywords that users
+ <code><a href=#the-meta-element>meta</a></code> element to specify some keywords that users
might use to look for the page:</p>
<pre><!DOCTYPE HTML>
@@ -14033,7 +14030,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose
<code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is
<code title=meta-keywords><a href=#meta-keywords>keywords</a></code>, run the following
substeps:</p>
@@ -14174,14 +14171,14 @@
<p>Metadata names whose values are to be <a href=#url title=URL>URLs</a> must not be proposed or accepted. Links must
be represented using the <code><a href=#the-link-element>link</a></code> element, not the
- <code><a href=#meta>meta</a></code> element.</p>
+ <code><a href=#the-meta-element>meta</a></code> element.</p>
<h5 id=pragma-directives><span class=secno>4.2.5.3 </span>Pragma directives</h5>
<p>When the <dfn id=attr-meta-http-equiv title=attr-meta-http-equiv><code>http-equiv</code></dfn> attribute
- is specified on a <code><a href=#meta>meta</a></code> element, the element is a pragma
+ is specified on a <code><a href=#the-meta-element>meta</a></code> element, the element is a pragma
directive.</p>
<p>The <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>
@@ -14260,7 +14257,7 @@
people expect to have work and what is necessary.
--><div class=impl>
- <p>When a <code><a href=#meta>meta</a></code> element is <a href=#insert-an-element-into-a-document title="insert an
+ <p>When a <code><a href=#the-meta-element>meta</a></code> element is <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into the document</a>, if its
<code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is
present and represents one of the above states, then the user agent
@@ -14281,14 +14278,14 @@
language</dfn>. Until the pragma is successfully processed, there
is no <a href=#pragma-set-default-language>pragma-set default language</a>.</p>
- <ol><li><p>If another <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <ol><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-language title=attr-meta-http-equiv-content-language>Content
Language state</a> has already been successfully processed
(i.e. when it was inserted the user agent processed it and
reached the last step of this list of steps), then abort these
steps.</li>
- <li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14328,7 +14325,7 @@
<a href=#character-encoding-declaration>character encoding declaration</a>. <span class=impl>This state's user agent requirements are all handled
by the parsing section of the specification.</span></p>
- <p>For <code><a href=#meta>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a>, the <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute must have a
value that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for a
@@ -14338,11 +14335,11 @@
the character encoding name of the <a href=#character-encoding-declaration>character encoding
declaration</a>.</p>
- <p>If the document contains a <code><a href=#meta>meta</a></code> element with an
+ <p>If the document contains a <code><a href=#the-meta-element>meta</a></code> element with an
<code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in
the <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a>, then the document must not contain a
- <code><a href=#meta>meta</a></code> element with the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute present.</p>
+ <code><a href=#the-meta-element>meta</a></code> element with the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute present.</p>
<p>The <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding
declaration state</a> may be used in <a href=#html-documents>HTML
@@ -14360,7 +14357,7 @@
<div class=impl>
- <ol><li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14379,13 +14376,13 @@
<div class=impl>
- <ol><!-- TESTS: <A HREF="http://www.hixie.ch/tests/adhoc/html/meta/refresh/">http://www.hixie.ch/tests/adhoc/html/meta/refresh/</A> --><!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734</A> --><li><p>If another <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <ol><!-- TESTS: <A HREF="http://www.hixie.ch/tests/adhoc/html/meta/refresh/">http://www.hixie.ch/tests/adhoc/html/meta/refresh/</A> --><!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734</A> --><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a>
has already been successfully processed (i.e. when it was
inserted the user agent processed it and reached the last step of
this list of steps), then abort these steps.</li>
- <li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14469,7 +14466,7 @@
(LF), and U+000D CARRIAGE RETURN (CR) characters from <var title="">url</var>.</li>
<li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">url</var> value to an <a href=#absolute-url>absolute URL</a>,
- relative to the <code><a href=#meta>meta</a></code> element. If this fails, abort
+ relative to the <code><a href=#the-meta-element>meta</a></code> element. If this fails, abort
these steps.</li>
<li>
@@ -14480,7 +14477,7 @@
<p>After the refresh has come due (as defined below), if the
user has not canceled the redirect and if the
- <code><a href=#meta>meta</a></code> element's <code><a href=#document>Document</a></code>'s
+ <code><a href=#the-meta-element>meta</a></code> element's <code><a href=#document>Document</a></code>'s
<a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-automatic-features-browsing-context-flag>sandboxed
automatic features browsing context flag</a> set when the
<code><a href=#document>Document</a></code> was created, <a href=#navigate title=navigate>navigate</a><!--DONAV meta refresh--> the
@@ -14499,7 +14496,7 @@
<!-- <A HREF="http://software.hixie.ch/utilities/js/live-dom-viewer/saved/774">http://software.hixie.ch/utilities/js/live-dom-viewer/saved/774</A> -->
<li>At least <var title="">time</var> seconds have elapsed
- since the <code><a href=#meta>meta</a></code> element was <a href=#insert-an-element-into-a-document title="insert
+ since the <code><a href=#the-meta-element>meta</a></code> element was <a href=#insert-an-element-into-a-document title="insert
an element into a document">inserted into the
<code>Document</code></a>, adjusted to take into account
user or user agent preferences.</li>
@@ -14523,7 +14520,7 @@
</ol></div>
- <p>For <code><a href=#meta>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a>,
the <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute must
have a value consisting either of:</p>
@@ -14546,7 +14543,7 @@
<div class=example>
<p>A news organization's front page could include the following
- markup in the page's <code><a href=#the-head-element-0>head</a></code> element, to ensure that
+ markup in the page's <code><a href=#the-head-element>head</a></code> element, to ensure that
the page automatically reloads from the server every five
minutes:</p>
@@ -14574,7 +14571,7 @@
<p>It is non-conforming. Real HTTP headers should be used instead.</p>
- <ol><li><p>If the <code><a href=#meta>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
+ <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that
attribute's value is the empty string, then abort these
steps.</li>
@@ -14588,7 +14585,7 @@
</ol></dd>
- </dl><p>There must not be more than one <code><a href=#meta>meta</a></code> element with
+ </dl><p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with
any particular state in the document at a time.</p>
@@ -14695,8 +14692,8 @@
character encoding used must be an <a href=#ascii-compatible-character-encoding>ASCII-compatible character
encoding</a>, and, in addition, if that encoding isn't US-ASCII
itself, then the encoding must be specified using a
- <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
- <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
+ <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration
state</a>.</p>
@@ -14707,8 +14704,8 @@
<code><a href=#the-iframe-element>iframe</a></code>.)</p>
<p>If an <a href=#html-documents title="HTML documents">HTML document</a> contains
- a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
- <code><a href=#meta>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
+ a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a
+ <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the
<a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration
state</a>, then the character encoding used must be an
<a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>.</p>
@@ -14773,7 +14770,7 @@
<p>In HTML, to declare that the character encoding is UTF-8, the
author could include the following markup near the top of the
- document (in the <code><a href=#the-head-element-0>head</a></code> element):</p>
+ document (in the <code><a href=#the-head-element>head</a></code> element):</p>
<pre><meta charset="utf-8"></pre>
@@ -14792,7 +14789,7 @@
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: <a href=#flow-content>flow content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: where <a href=#metadata-content>metadata content</a> is expected.</dd>
- <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element-0>head</a></code> element.</dd>
+ <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd>
<dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: where <a href=#flow-content>flow content</a> is expected, but before any other <a href=#flow-content>flow content</a> other than other <code><a href=#the-style-element>style</a></code> elements and <a href=#inter-element-whitespace>inter-element whitespace</a>.</dd>
<dt>Content model:</dt>
<dd>Depends on the value of the <code title=attr-style-type><a href=#attr-style-type>type</a></code> attribute, but must match requirements described in prose below.</dd>
@@ -15173,7 +15170,7 @@
</div>
- <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn> element</h4>
+ <h4 id=the-script-element><span class=secno>4.3.1 </span>The <dfn id=script><code>script</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -15208,7 +15205,7 @@
attribute DOMString <a href=#dom-script-text title=dom-script-text>text</a>;
};</pre>
</dd>
- </dl><p>The <code><a href=#script>script</a></code> element allows authors to include dynamic
+ </dl><p>The <code><a href=#the-script-element>script</a></code> element allows authors to include dynamic
script and data blocks in their documents. The element does not
<a href=#represents title=represents>represent</a> content for the user.</p>
@@ -15218,14 +15215,14 @@
is not that described by "<code title="">text/javascript</code>",
then the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must
be present, as described below. Whatever language is used, the
- contents of the <code><a href=#script>script</a></code> element must conform with the
+ contents of the <code><a href=#the-script-element>script</a></code> element must conform with the
requirements of that language's specification.</p>
<p>When used to include data blocks (as opposed to scripts), the
data must be embedded inline, the format of the data must be given
using the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, the
<code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute must not be
- specified, and the contents of the <code><a href=#script>script</a></code> element must
+ specified, and the contents of the <code><a href=#the-script-element>script</a></code> element must
conform to the requirements defined for the format used.</p>
<p>The <dfn id=attr-script-type title=attr-script-type><code>type</code></dfn>
@@ -15278,7 +15275,7 @@
therefore by necessity scattered throughout the specification. The
algorithms below (in this section) describe the core of this
processing, but these algorithms reference and are referenced by the
- parsing rules for <code><a href=#script>script</a></code> <a href=#scriptTag>start</a>
+ parsing rules for <code><a href=#the-script-element>script</a></code> <a href=#scriptTag>start</a>
and <a href=#scriptEndTag>end</a> tags in HTML, <a href=#scriptForeignEndTag>in foreign content</a>, and <a href=#scriptTagXML>in XML</a>, the rules for the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method, the
handling of <a href=#scripting>scripting</a>, etc.</p>
@@ -15295,28 +15292,28 @@
<div class=impl>
- <p>A <code><a href=#script>script</a></code> element has several associated pieces of
+ <p>A <code><a href=#the-script-element>script</a></code> element has several associated pieces of
state.</p>
<p>The first is a flag indicating whether or not the script block
has been <dfn id=already-started>"already started"</dfn>. Initially,
- <code><a href=#script>script</a></code> elements must have this flag unset (script
+ <code><a href=#the-script-element>script</a></code> elements must have this flag unset (script
blocks, when created, are not "already started"). When a
- <code><a href=#script>script</a></code> element is <a href=#concept-clone title=concept-clone>cloned</a>, the "already started" flag, if
+ <code><a href=#the-script-element>script</a></code> element is <a href=#concept-clone title=concept-clone>cloned</a>, the "already started" flag, if
set, must be propagated to the clone when it is created.</p>
<p>The second is a flag indicating whether the element was
- <dfn id=parser-inserted>"parser-inserted"</dfn>. Initially, <code><a href=#script>script</a></code>
+ <dfn id=parser-inserted>"parser-inserted"</dfn>. Initially, <code><a href=#the-script-element>script</a></code>
elements must have this flag unset. It is set by the <a href=#html-parser>HTML
- parser</a> and the <a href=#xml-parser>XML parser</a> on <code><a href=#script>script</a></code>
+ parser</a> and the <a href=#xml-parser>XML parser</a> on <code><a href=#the-script-element>script</a></code>
elements they insert and affects the processing of those
elements.</p>
<p>The third is a flag indicating whether the element will
- <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#script>script</a></code> elements
+ <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#the-script-element>script</a></code> elements
must have this flag set. It is unset by the <a href=#html-parser>HTML parser</a>
- and the <a href=#xml-parser>XML parser</a> on <code><a href=#script>script</a></code> elements they
- insert. In addition, whenever a <code><a href=#script>script</a></code> element whose
+ and the <a href=#xml-parser>XML parser</a> on <code><a href=#the-script-element>script</a></code> elements they
+ insert. In addition, whenever a <code><a href=#the-script-element>script</a></code> element whose
<a href=#force-async>"force-async"</a> flag is set has a <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute added, the
element's <a href=#force-async>"force-async"</a> flag must be unset.</p> <!--
there's no need to unset it when the attribute is removed since you
@@ -15324,7 +15321,7 @@
<p>The fourth is a flag indicating whether or not the script block is
<dfn id=ready-to-be-parser-executed>"ready to be parser-executed"</dfn>. Initially,
- <code><a href=#script>script</a></code> elements must have this flag unset (script
+ <code><a href=#the-script-element>script</a></code> elements must have this flag unset (script
blocks, when created, are not "ready to be parser-executed"). This
flag is used only for elements that are also
<a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
@@ -15335,21 +15332,21 @@
encoding</var></dfn>, and <dfn id="the-script-block's-fallback-character-encoding"><var>the script block's fallback
character encoding</var></dfn>. They are determined when the script
is prepared, based on the attributes on the element at that time,
- and the <code><a href=#document>Document</a></code> of the <code><a href=#script>script</a></code>
+ and the <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code>
element.</p>
- <p>When a <code><a href=#script>script</a></code> element that is not marked as being
+ <p>When a <code><a href=#the-script-element>script</a></code> element that is not marked as being
<a href=#parser-inserted>"parser-inserted"</a> experiences one of the events listed
- in the following list, the user agent must synchronously <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#script>script</a></code>
+ in the following list, the user agent must synchronously <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#the-script-element>script</a></code>
element:</p>
- <ul><li>The <code><a href=#script>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
+ <ul><li>The <code><a href=#the-script-element>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into a document</a>.</li>
- <li>The <code><a href=#script>script</a></code> element is <a href=#in-a-document>in a
+ <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a
<code>Document</code></a> and its child nodes are changed.</li>
- <li>The <code><a href=#script>script</a></code> element is <a href=#in-a-document>in a
+ <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a
<code>Document</code></a> and has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute set where previously
the element had no such attribute.</li>
@@ -15358,7 +15355,7 @@
<ol><li>
- <p>If the <code><a href=#script>script</a></code> element is marked as having
+ <p>If the <code><a href=#the-script-element>script</a></code> element is marked as having
<a href=#already-started>"already started"</a>, then the user agent must abort
these steps at this point. The script is not executed.</p>
@@ -15372,7 +15369,7 @@
<var title="">was-parser-inserted</var> to false.</p>
<p class=note>This is done so that if parser-inserted
- <code><a href=#script>script</a></code> elements fail to run when the parser tries to
+ <code><a href=#the-script-element>script</a></code> elements fail to run when the parser tries to
run them, e.g. because they are empty or specify an unsupported
scripting language, another script can later mutate them and cause
them to run again.</p>
@@ -15388,7 +15385,7 @@
element's <a href=#force-async>"force-async"</a> flag to true.</p>
<p class=note>This is done so that if a parser-inserted
- <code><a href=#script>script</a></code> element fails to run when the parser tries to
+ <code><a href=#the-script-element>script</a></code> element fails to run when the parser tries to
run it, but it is later executed after a script dynamically
updates it, it will execute asynchronously even if the
<code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute isn't
@@ -15418,25 +15415,25 @@
<p>If either:</p>
- <ul class=brief><li>the <code><a href=#script>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute and its value is
+ <ul class=brief><li>the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute and its value is
the empty string, or</li>
- <li>the <code><a href=#script>script</a></code> element has no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute but it has a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute and
+ <li>the <code><a href=#the-script-element>script</a></code> element has no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute but it has a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute and
<em>that</em> attribute's value is the empty string, or</li>
- <li>the <code><a href=#script>script</a></code> element has neither a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute nor a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute, then</li>
+ <li>the <code><a href=#the-script-element>script</a></code> element has neither a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute nor a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute, then</li>
</ul><p>...let <var><a href="#the-script-block's-type">the script block's type</a></var> for this
- <code><a href=#script>script</a></code> element be "<code title="">text/javascript</code>".</p>
+ <code><a href=#the-script-element>script</a></code> element be "<code title="">text/javascript</code>".</p>
- <p>Otherwise, if the <code><a href=#script>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, let <var><a href="#the-script-block's-type">the
- script block's type</a></var> for this <code><a href=#script>script</a></code> element be
+ <p>Otherwise, if the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, let <var><a href="#the-script-block's-type">the
+ script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element be
the value of that attribute with any leading or trailing sequences
of <a href=#space-character title="space character">space characters</a>
removed.</p>
<p>Otherwise, the element has a non-empty <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute; let
- <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#script>script</a></code>
+ <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code>
element be the concatenation of the string "<code title="">text/</code>" followed by the value of the <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute.</p> <!--
user agents already support, e.g., type="text/javascript1.3", so
we don't have to support that separately. -->
@@ -15450,7 +15447,7 @@
<p>If the user agent does not <a href=#support-the-scripting-language>support the scripting
language</a> given by <var><a href="#the-script-block's-type">the script block's type</a></var> for
- this <code><a href=#script>script</a></code> element, then the user agent must abort
+ this <code><a href=#the-script-element>script</a></code> element, then the user agent must abort
these steps at this point. The script is not executed.</p>
</li>
@@ -15485,7 +15482,7 @@
<li id=script-processing-noscript>
<p>If <a href=#concept-n-noscript title=concept-n-noscript>scripting is
- disabled</a> for the <code><a href=#script>script</a></code> element, then the user
+ disabled</a> for the <code><a href=#the-script-element>script</a></code> element, then the user
agent must abort these steps at this point. The script is not
executed.</p>
@@ -15504,7 +15501,7 @@
<li id=script-processing-for>
- <p>If the <code><a href=#script>script</a></code> element has an <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute and a <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute, then run these
+ <p>If the <code><a href=#the-script-element>script</a></code> element has an <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute and a <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute, then run these
substeps:</p>
<ol><li><p>Let <var title="">for</var> be the value of the <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute.</li>
@@ -15526,12 +15523,12 @@
<li id=script-processing-encoding>
- <p>If the <code><a href=#script>script</a></code> element has a <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute, then let
+ <p>If the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute, then let
<var><a href="#the-script-block's-character-encoding">the script block's character encoding</a></var> for this
- <code><a href=#script>script</a></code> element be the encoding given by the <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute.</p>
+ <code><a href=#the-script-element>script</a></code> element be the encoding given by the <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute.</p>
<p>Otherwise, let <var><a href="#the-script-block's-fallback-character-encoding">the script block's fallback character
- encoding</a></var> for this <code><a href=#script>script</a></code> element be the same as
+ encoding</a></var> for this <code><a href=#the-script-element>script</a></code> element be the same as
<a href="#document's-character-encoding" title="document's character encoding">the encoding of the
document itself</a>.</p>
@@ -15631,7 +15628,7 @@
have a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and
the element has been flagged as <a href=#parser-inserted>"parser-inserted"</a>,
and the <code><a href=#document>Document</a></code> of the <a href=#html-parser>HTML parser</a> or
- <a href=#xml-parser>XML parser</a> that created the <code><a href=#script>script</a></code>
+ <a href=#xml-parser>XML parser</a> that created the <code><a href=#the-script-element>script</a></code>
element <a href=#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking
scripts</a></dt>
@@ -15657,7 +15654,7 @@
<p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of
scripts that will execute in order as soon as possible</dfn>
associated with the <code><a href=#document>Document</a></code> of the
- <code><a href=#script>script</a></code> element at the time the <a href=#prepare-a-script>prepare a
+ <code><a href=#the-script-element>script</a></code> element at the time the <a href=#prepare-a-script>prepare a
script</a> algorithm started.</p>
<p>The <a href=#concept-task title=concept-task>task</a> that the
@@ -15693,7 +15690,7 @@
<p>The element must be added to the <dfn id=set-of-scripts-that-will-execute-as-soon-as-possible>set of scripts that
will execute as soon as possible</dfn> of the
- <code><a href=#document>Document</a></code> of the <code><a href=#script>script</a></code> element at the
+ <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code> element at the
time the <a href=#prepare-a-script>prepare a script</a> algorithm started.</p>
<p>The <a href=#concept-task title=concept-task>task</a> that the
@@ -15723,7 +15720,7 @@
<code><a href=#document>Document</a></code> is used by the <code><a href=#document>Document</a></code>'s
parser(s).</p>
- <p class=note>If a <code><a href=#script>script</a></code> element that blocks a
+ <p class=note>If a <code><a href=#the-script-element>script</a></code> element that blocks a
parser gets moved to another <code><a href=#document>Document</a></code> before it would
normally have stopped blocking that parser, it nonetheless continues
blocking that parser until the condition that causes it to be
@@ -15775,7 +15772,7 @@
following steps. For the purposes of these steps, the script is
considered to be from an <i>external file</i> if, while the
<a href=#prepare-a-script>prepare a script</a> algorithm above was running for
- this script, the <code><a href=#script>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>
+ this script, the <code><a href=#the-script-element>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p>
<ol><li id=establish-script-block-source>
@@ -15878,7 +15875,7 @@
<dd>
- <p>The child nodes of the <code><a href=#script>script</a></code> element at the
+ <p>The child nodes of the <code><a href=#the-script-element>script</a></code> element at the
time the element's <a href=#already-started>"already started"</a> flag was
last set are the script source.</p>
@@ -15890,7 +15887,7 @@
<p>If the script is from an external file, then increment the
<a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the
- <code><a href=#script>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
+ <code><a href=#the-script-element>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that
<code><a href=#document>Document</a></code>.</p>
</li>
@@ -15898,7 +15895,7 @@
<li>
<p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
- script</a> from the <code><a href=#script>script</a></code> element node, using
+ script</a> from the <code><a href=#the-script-element>script</a></code> element node, using
<var><a href="#the-script-block's-source">the script block's source</a></var> and <var><a href="#the-script-block's-type">the script
block's type</a></var>.</p>
@@ -15919,10 +15916,10 @@
<p>If the script is from an external file, <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-load>load</code> at the
- <code><a href=#script>script</a></code> element.</p>
+ <code><a href=#the-script-element>script</a></code> element.</p>
<p>Otherwise, the script is internal; <a href=#queue-a-task>queue a
- task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#script>script</a></code>
+ task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-script-element>script</a></code>
element.</p>
</li>
@@ -15966,20 +15963,20 @@
<p>The IDL attribute <dfn id=dom-script-text title=dom-script-text><code>text</code></dfn> must return a
concatenation of the contents of all the <a href=#text-node title="text
node">text nodes</a> that are direct children of the
- <code><a href=#script>script</a></code> element (ignoring any other nodes such as
+ <code><a href=#the-script-element>script</a></code> element (ignoring any other nodes such as
comments or elements), in tree order. On setting, it must act the
same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p>
</div>
<p class=note>When inserted using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method,
- <code><a href=#script>script</a></code> elements execute (typically synchronously), but
+ <code><a href=#the-script-element>script</a></code> elements execute (typically synchronously), but
when inserted using <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> and <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attributes, they do not
execute at all.</p>
<div class=example>
- <p>In this example, two <code><a href=#script>script</a></code> elements are used. One
+ <p>In this example, two <code><a href=#the-script-element>script</a></code> elements are used. One
embeds an external script, and the other includes some data.</p>
<pre><script src="game-engine.js"></script>
@@ -16003,7 +16000,7 @@
<p>The following sample shows how a script element can be used to
define a function that is then used by other parts of the
- document. It also shows how a <code><a href=#script>script</a></code> element can be
+ document. It also shows how a <code><a href=#the-script-element>script</a></code> element can be
used to invoke script while the document is being parsed, in this
case to initialize the form's output.</p>
@@ -16095,7 +16092,7 @@
<h5 id=restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span><dfn title="script content restrictions">Restrictions for contents of <code>script</code> elements</dfn></h5>
- <p>The <code><a href=#textcontent>textContent</a></code> of a <code><a href=#script>script</a></code> element
+ <p>The <code><a href=#textcontent>textContent</a></code> of a <code><a href=#the-script-element>script</a></code> element
must match the <code title="">script</code> production in the
following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p>
@@ -16137,15 +16134,15 @@
tag-end =/ %x002F ; U+002F SOLIDUS (/)
tag-end =/ %x003E ; U+003E GREATER-THAN SIGN (>)</pre>
- <p>When a <code><a href=#script>script</a></code> element contains <a href=#inline-documentation-for-external-scripts>script
+ <p>When a <code><a href=#the-script-element>script</a></code> element contains <a href=#inline-documentation-for-external-scripts>script
documentation</a>, there are further restrictions on the contents
of the element, as described in the section below.</p>
<h5 id=inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span><dfn title="script documentation">Inline documentation for external scripts</dfn></h5>
- <p>If a <code><a href=#script>script</a></code> element's <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is specified, then the
- contents of the <code><a href=#script>script</a></code> element, if any, must be such
+ <p>If a <code><a href=#the-script-element>script</a></code> element's <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is specified, then the
+ contents of the <code><a href=#the-script-element>script</a></code> element, if any, must be such
that the value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code> IDL
attribute, which is derived from the element's contents, matches the
<code title="">documentation</code> production in the following
@@ -16172,7 +16169,7 @@
element in JavaScript comments.</p>
<p class=note>This requirement is in addition to the earlier
- restrictions on the syntax of contents of <code><a href=#script>script</a></code>
+ restrictions on the syntax of contents of <code><a href=#the-script-element>script</a></code>
elements.</p>
<div class=example>
@@ -16196,12 +16193,12 @@
<div class=impl>
- <h5 id=scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code><a href=#script>script</a></code> elements and XSLT</h5>
+ <h5 id=scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code><a href=#the-script-element>script</a></code> elements and XSLT</h5>
<p><i>This section is non-normative.</i></p>
<p>This specification does not define how XSLT interacts with the
- <code><a href=#script>script</a></code> element (or, indeed, how XSLT processing
+ <code><a href=#the-script-element>script</a></code> element (or, indeed, how XSLT processing
triggers the <a href=#stop-parsing>stop parsing</a> steps, how it interacts with
the <a href=#navigate title=navigate>navigation</a> algorithm, or how it
fits in with the <a href=#event-loop>event loop</a>). However, in the absence
@@ -16210,7 +16207,7 @@
<ul><li><p>When an XSLT transformation program is triggered by an <code title=""><?xml-stylesheet?></code> processing instruction and
the browser implements a direct-to-DOM transformation,
- <code><a href=#script>script</a></code> elements created by the XSLT processor need to
+ <code><a href=#the-script-element>script</a></code> elements created by the XSLT processor need to
be marked <a href=#parser-inserted>"parser-inserted"</a> and run in document order
(modulo scripts marked <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code>
or <code title=attr-script-async><a href=#attr-script-async>async</a></code>), asynchronously
@@ -16219,17 +16216,17 @@
<li><p>The <code title=dom-XSLTProcessor-transformToDocument>XSLTProcessor.transformToDocument()</code>
method adds elements to a <code><a href=#document>Document</a></code> that is not in a
<a href=#browsing-context>browsing context</a>, and, accordingly, any
- <code><a href=#script>script</a></code> elements they create need to have their
+ <code><a href=#the-script-element>script</a></code> elements they create need to have their
<a href=#already-started>"already started"</a> flag set in the <a href=#prepare-a-script>prepare a
script</a> algorithm and never get executed (<a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a>). Such
- <code><a href=#script>script</a></code> elements still need to be marked
+ <code><a href=#the-script-element>script</a></code> elements still need to be marked
<a href=#parser-inserted>"parser-inserted"</a>, though, such that their <code title=dom-script-async><a href=#dom-script-async>async</a></code> IDL attribute will return
false in the absence of an <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute.</li>
<li><p>The <code title=dom-XSLTProcessor-transformToFragment>XSLTProcessor.transformToFragment()</code>
method needs to create a fragment that is equivalent to one built
manually by creating the elements using <code title=dom-document-createElementNS><a href=#dom-document-createelementns>document.createElementNS()</a></code>.
- For instance, it needs to create <code><a href=#script>script</a></code> elements that
+ For instance, it needs to create <code><a href=#the-script-element>script</a></code> elements that
aren't <a href=#parser-inserted>"parser-inserted"</a> and that don't have their
<a href=#already-started>"already started"</a> flag set, so that they will execute
when the fragment is inserted into a document.</li>
@@ -16249,11 +16246,11 @@
<dd><a href=#flow-content>Flow content</a>.</dd>
<dd><a href=#phrasing-content>Phrasing content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>In a <code><a href=#the-head-element-0>head</a></code> element of an <a href=#html-documents title="HTML documents">HTML document</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
+ <dd>In a <code><a href=#the-head-element>head</a></code> element of an <a href=#html-documents title="HTML documents">HTML document</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
<dd>Where <a href=#phrasing-content>phrasing content</a> is expected in <a href=#html-documents>HTML documents</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd>
<dt>Content model:</dt>
- <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, in a <code><a href=#the-head-element-0>head</a></code> element: in any order, zero or more <code><a href=#the-link-element>link</a></code> elements, zero or more <code><a href=#the-style-element>style</a></code> elements, and zero or more <code><a href=#meta>meta</a></code> elements.</dd>
- <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, not in a <code><a href=#the-head-element-0>head</a></code> element: <a href=#transparent>transparent</a>, but there must be no <code><a href=#the-noscript-element>noscript</a></code> element descendants.</dd>
+ <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, in a <code><a href=#the-head-element>head</a></code> element: in any order, zero or more <code><a href=#the-link-element>link</a></code> elements, zero or more <code><a href=#the-style-element>style</a></code> elements, and zero or more <code><a href=#the-meta-element>meta</a></code> elements.</dd>
+ <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, not in a <code><a href=#the-head-element>head</a></code> element: <a href=#transparent>transparent</a>, but there must be no <code><a href=#the-noscript-element>noscript</a></code> element descendants.</dd>
<dd>Otherwise: text that conforms to the requirements given in the prose.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
@@ -16269,14 +16266,14 @@
<p>When used in <a href=#html-documents>HTML documents</a>, the allowed content
model is as follows:</p>
- <dl><dt>In a <code><a href=#the-head-element-0>head</a></code> element, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
+ <dl><dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only
- <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#meta>meta</a></code>
+ <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-meta-element>meta</a></code>
elements.</dd>
- <dt>In a <code><a href=#the-head-element-0>head</a></code> element, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
+ <dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only text,
@@ -16284,10 +16281,10 @@
algorithm</a> <!-- (which disables <script> execution) --> with
the <code><a href=#the-noscript-element>noscript</a></code> element as the <var title="">context</var> element and the text contents as the <var title="">input</var> must result in a list of nodes that consists
only of <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and
- <code><a href=#meta>meta</a></code> elements that would be conforming if they were
+ <code><a href=#the-meta-element>meta</a></code> elements that would be conforming if they were
children of the <code><a href=#the-noscript-element>noscript</a></code> element, and no <a href=#parse-error title="parse error">parse errors</a>.</dd>
- <dt>Outside of <code><a href=#the-head-element-0>head</a></code> elements, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
+ <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element's content model is
@@ -16296,7 +16293,7 @@
element as an ancestor (that is, <code><a href=#the-noscript-element>noscript</a></code> can't be
nested).</dd>
- <dt>Outside of <code><a href=#the-head-element-0>head</a></code> elements, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
+ <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the
<code><a href=#the-noscript-element>noscript</a></code> element</dt>
<dd>
@@ -16304,11 +16301,11 @@
<p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only text,
except that the text must be such that running the following
algorithm results in a conforming document with no
- <code><a href=#the-noscript-element>noscript</a></code> elements and no <code><a href=#script>script</a></code>
+ <code><a href=#the-noscript-element>noscript</a></code> elements and no <code><a href=#the-script-element>script</a></code>
elements, and such that no step in the algorithm causes an
<a href=#html-parser>HTML parser</a> to flag a <a href=#parse-error>parse error</a>:</p>
- <ol><li>Remove every <code><a href=#script>script</a></code> element from the
+ <ol><li>Remove every <code><a href=#the-script-element>script</a></code> element from the
document.</li>
<li>Make a list of every <code><a href=#the-noscript-element>noscript</a></code> element in the
@@ -16444,7 +16441,7 @@
<dl class=element><dt>Categories</dt>
<dd><a href=#sectioning-root>Sectioning root</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
- <dd>As the second element in an <code><a href=#the-html-element-0>html</a></code> element.</dd>
+ <dd>As the second element in an <code><a href=#the-html-element>html</a></code> element.</dd>
<dt>Content model:</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
<dt>Content attributes:</dt>
@@ -16527,11 +16524,11 @@
body element</a> of a <code><a href=#document>Document</a></code> would first trigger
the <code title=handler-onerror><a href=#handler-onerror>onerror</a></code> <a href=#event-handler-content-attributes>event handler
content attributes</a> of that element, then that of the root
- <code><a href=#the-html-element-0>html</a></code> element, and only <em>then</em> would it trigger
+ <code><a href=#the-html-element>html</a></code> element, and only <em>then</em> would it trigger
the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> <a href=#event-handler-content-attributes title="event handler content attributes">event handler content
attribute</a> on the <code><a href=#the-body-element-0>body</a></code> element. This is because
the event would bubble from the target, to the <code><a href=#the-body-element-0>body</a></code>, to
- the <code><a href=#the-html-element-0>html</a></code>, to the <code><a href=#document>Document</a></code>, to the
+ the <code><a href=#the-html-element>html</a></code>, to the <code><a href=#document>Document</a></code>, to the
<code><a href=#window>Window</a></code>, and the <a href=#event-handlers title="event handlers">event
handler</a> on the <code><a href=#the-body-element-0>body</a></code> is watching the
<code><a href=#window>Window</a></code> not the <code><a href=#the-body-element-0>body</a></code>. A regular event
@@ -17097,10 +17094,7 @@
- <h4 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <dfn><code>h1</code></dfn>, <dfn><code>h2</code></dfn>,
- <dfn><code>h3</code></dfn>, <dfn><code>h4</code></dfn>,
- <dfn><code>h5</code></dfn>, and <dfn><code>h6</code></dfn>
- elements</h4>
+ <h4 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <dfn id=the-h1-element><code>h1</code></dfn>, <dfn id=the-h2-element><code>h2</code></dfn>, <dfn id=the-h3-element><code>h3</code></dfn>, <dfn id=the-h4-element><code>h4</code></dfn>, <dfn id=the-h5-element><code>h5</code></dfn>, and <dfn id=the-h6-element><code>h6</code></dfn> elements</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -18703,7 +18697,7 @@
<dt>Contexts in which this element can be used:</dt>
<dd>Inside <code><a href=#the-ol-element>ol</a></code> elements.</dd>
<dd>Inside <code><a href=#the-ul-element>ul</a></code> elements.</dd>
- <dd>Inside <code><a href=#menus>menu</a></code> elements.</dd>
+ <dd>Inside <code><a href=#the-menu-element>menu</a></code> elements.</dd>
<dt>Content model:</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
<dt>Content attributes:</dt>
@@ -18717,7 +18711,7 @@
</dd>
</dl><p>The <code><a href=#the-li-element>li</a></code> element <a href=#represents>represents</a> a list
item. If its parent element is an <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-ul-element>ul</a></code>,
- or <code><a href=#menus>menu</a></code> element, then the element is an item of the
+ or <code><a href=#the-menu-element>menu</a></code> element, then the element is an item of the
parent element's list, as defined for those elements. Otherwise, the
list item has no defined list-related relationship to any other
<code><a href=#the-li-element>li</a></code> element.</p>
@@ -18790,7 +18784,7 @@
</div>
<p class=note>If the <code><a href=#the-li-element>li</a></code> element is the child of a
- <code><a href=#menus>menu</a></code> element and itself has a child that defines a
+ <code><a href=#the-menu-element>menu</a></code> element and itself has a child that defines a
<a href=#concept-command title=concept-command>command</a>, then the
<code><a href=#the-li-element>li</a></code> element will match the <code title=selector-enabled><a href=#selector-enabled>:enabled</a></code> and <code title=selector-disabled><a href=#selector-disabled>:disabled</a></code> pseudo-classes in the
same way as the first such child element does.</p>
@@ -20606,7 +20600,7 @@
</div>
- <h4 id=the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <dfn><code>sub</code></dfn> and <dfn><code>sup</code></dfn> elements</h4>
+ <h4 id=the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <dfn id=the-sub-element><code>sub</code></dfn> and <dfn id=the-sup-element><code>sup</code></dfn> elements</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -23316,7 +23310,7 @@
who is known to be able to view images.</li>
<!--FORK-->
- <li>The document has a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is an
+ <li>The document has a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is an
<a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=meta-generator><a href=#meta-generator>generator</a></code>". (This case does not
represent a case where the document is conforming, only that the
generator could not determine appropriate alternative text —
@@ -23389,7 +23383,7 @@
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
- <li>The root element, in the form of an <code><a href=#the-html-element-0>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
+ <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
@@ -24120,7 +24114,7 @@
<var title="">input</var> must result in a list of nodes that are
all <a href=#phrasing-content>phrasing content</a>, with no <a href=#parse-error title="parse
error">parse errors</a> having occurred, with no
- <code><a href=#script>script</a></code> elements being anywhere in the list or as
+ <code><a href=#the-script-element>script</a></code> elements being anywhere in the list or as
descendants of elements in the list, and with all the elements in
the list (including their descendants) being themselves
conforming.</p>
@@ -25167,10 +25161,10 @@
<p>The following example shows how a plugin can be used in HTML (in
this case the Flash plugin, to show a video file). Fallback is
provided for users who do not have Flash enabled, in this case
- using the <code><a href=#video>video</a></code> element to show the video for those
- using user agents that support <code><a href=#video>video</a></code>, and finally
+ using the <code><a href=#the-video-element>video</a></code> element to show the video for those
+ using user agents that support <code><a href=#the-video-element>video</a></code>, and finally
providing a link to the video for those who have neither Flash nor
- a <code><a href=#video>video</a></code>-capable browser.</p>
+ a <code><a href=#the-video-element>video</a></code>-capable browser.</p>
<pre><p>Look at my video:
<object type="application/x-shockwave-flash">
@@ -25273,7 +25267,7 @@
</div>
- <h4 id=video><span class=secno>4.8.6 </span>The <dfn><code>video</code></dfn> element</h4>
+ <h4 id=the-video-element><span class=secno>4.8.6 </span>The <dfn id=video><code>video</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -25311,13 +25305,13 @@
attribute DOMString <a href=#dom-video-poster title=dom-video-poster>poster</a>;
};</pre>
</dd>
- </dl><p>A <code><a href=#video>video</a></code> element is used for playing videos or
+ </dl><p>A <code><a href=#the-video-element>video</a></code> element is used for playing videos or
movies, and audio files with captions.</p>
- <p>Content may be provided inside the <code><a href=#video>video</a></code>
+ <p>Content may be provided inside the <code><a href=#the-video-element>video</a></code>
element<span class=impl>. User agents should not show this content
to the user</span>; it is intended for older Web browsers which do
- not support <code><a href=#video>video</a></code>, so that legacy video plugins can be
+ not support <code><a href=#the-video-element>video</a></code>, so that legacy video plugins can be
tried, or to show text to the users of these older browsers informing
them of how to access the video contents.</p>
@@ -25329,7 +25323,7 @@
subtitle tracks, audio description tracks, or sign-language
overlays) into their media streams.</p>
- <p>The <code><a href=#video>video</a></code> element is a <a href=#media-element>media element</a>
+ <p>The <code><a href=#the-video-element>video</a></code> element is a <a href=#media-element>media element</a>
whose <a href=#media-data>media data</a> is ostensibly video data, possibly
with associated audio data.</p>
@@ -25355,7 +25349,7 @@
URL. -->
<ol><li><p>If there is an existing instance of this algorithm running
- for this <code><a href=#video>video</a></code> element, abort that instance of this
+ for this <code><a href=#the-video-element>video</a></code> element, abort that instance of this
algorithm without changing the <a href=#poster-frame>poster frame</a>.</li>
<li><p>If the <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code>
@@ -25390,11 +25384,11 @@
<code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, or <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> but no video
data has yet been obtained at all, or the element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is any
subsequent value but the <a href=#media-resource>media resource</a> does not have a
- video channel), the <code><a href=#video>video</a></code> element
+ video channel), the <code><a href=#the-video-element>video</a></code> element
<a href=#represents>represents</a> either the <a href=#poster-frame>poster frame</a>, or
nothing.</p>
- <p>When a <code><a href=#video>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> and the <a href=#current-playback-position title="current
+ <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> and the <a href=#current-playback-position title="current
playback position">current playback position</a> is the first
frame of video, the element <a href=#represents>represents</a> either the frame
of video corresponding to the <a href=#current-playback-position title="current playback
@@ -25405,7 +25399,7 @@
be preferred over nothing, but the <a href=#poster-frame>poster frame</a> should
not be shown again after a frame of video has been shown.</p>
- <p>When a <code><a href=#video>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> at any other position, and
+ <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> at any other position, and
the <a href=#media-resource>media resource</a> has a video channel, the element
<a href=#represents>represents</a> the frame of video corresponding to the
<a href=#current-playback-position title="current playback position">current playback
@@ -25413,7 +25407,7 @@
video is seeking or buffering), the last frame of the video to have
been rendered.</p>
- <p>When a <code><a href=#video>video</a></code> element whose <a href=#media-resource>media
+ <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media
resource</a> has a video channel is <a href=#potentially-playing>potentially
playing</a>, it <a href=#represents>represents</a> the frame of video at the
continuously increasing <a href=#current-playback-position title="current playback
@@ -25427,7 +25421,7 @@
playback position</a>, at the element's <a href=#effective-media-volume>effective media
volume</a>.</p>
- <p>When a <code><a href=#video>video</a></code> element whose <a href=#media-resource>media
+ <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media
resource</a> has a video channel is neither <a href=#potentially-playing>potentially
playing</a> nor <a href=#dom-media-paused title=dom-media-paused>paused</a>
(e.g. when seeking or stalled), the element <a href=#represents>represents</a>
@@ -25437,7 +25431,7 @@
particular playback position is defined by the video stream's
format.</p>
- <p>The <code><a href=#video>video</a></code> element also <a href=#represents>represents</a> any
+ <p>The <code><a href=#the-video-element>video</a></code> element also <a href=#represents>represents</a> any
<a href=#text-track-cue title="text track cue">text track cues</a> whose
<a href=#text-track-cue-active-flag>text track cue active flag</a> is set and whose
<a href=#text-track>text track</a> is in the <a href=#text-track-showing title="text track
@@ -25488,7 +25482,7 @@
</div>
- <p>The <code><a href=#video>video</a></code> element supports <a href=#dimension-attributes>dimension
+ <p>The <code><a href=#the-video-element>video</a></code> element supports <a href=#dimension-attributes>dimension
attributes</a>.</p>
<div class=impl>
@@ -25507,13 +25501,13 @@
requirement can be implemented by using the <a href=#video-object-fit>style rule suggested in the rendering
section</a>.</p>
- <p>The intrinsic width of a <code><a href=#video>video</a></code> element's playback
+ <p>The intrinsic width of a <code><a href=#the-video-element>video</a></code> element's playback
area is the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic
width</a> of the video resource, if that is available; otherwise
it is the intrinsic width of the <a href=#poster-frame>poster frame</a>, if that
is available; otherwise it is 300 CSS pixels.</p>
- <p>The intrinsic height of a <code><a href=#video>video</a></code> element's playback
+ <p>The intrinsic height of a <code><a href=#the-video-element>video</a></code> element's playback
area is the <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic
height</a> of the video resource, if that is available; otherwise
it is the intrinsic height of the <a href=#poster-frame>poster frame</a>, if that
@@ -25606,7 +25600,7 @@
- <h4 id=audio><span class=secno>4.8.7 </span>The <dfn><code>audio</code></dfn> element</h4>
+ <h4 id=the-audio-element><span class=secno>4.8.7 </span>The <dfn id=audio><code>audio</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -25637,7 +25631,7 @@
NamedConstructor=<a href=#dom-audio-s title=dom-Audio-s>Audio</a>(in DOMString src)]
interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediaelement>HTMLMediaElement</a> {};</pre>
</dd>
- </dl><p>An <code><a href=#audio>audio</a></code> element <a href=#represents>represents</a> a sound or
+ </dl><p>An <code><a href=#the-audio-element>audio</a></code> element <a href=#represents>represents</a> a sound or
audio stream.</p>
<!-- v2 (actually v3) suggestions:
@@ -25657,10 +25651,10 @@
> Support very simple audio codecs, and programmable synthesizers.
-->
- <p>Content may be provided inside the <code><a href=#audio>audio</a></code>
+ <p>Content may be provided inside the <code><a href=#the-audio-element>audio</a></code>
element<span class=impl>. User agents should not show this content
to the user</span>; it is intended for older Web browsers which do
- not support <code><a href=#audio>audio</a></code>, so that legacy audio plugins can be
+ not support <code><a href=#the-audio-element>audio</a></code>, so that legacy audio plugins can be
tried, or to show text to the users of these older browsers informing
them of how to access the audio contents.</p>
@@ -25671,7 +25665,7 @@
embed accessibility aids (such as transcriptions) into their media
streams.</p>
- <p>The <code><a href=#audio>audio</a></code> element is a <a href=#media-element>media element</a>
+ <p>The <code><a href=#the-audio-element>audio</a></code> element is a <a href=#media-element>media element</a>
whose <a href=#media-data>media data</a> is ostensibly audio data.</p>
<p>The <code title=attr-media-src><a href=#attr-media-src>src</a></code>, <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>, <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>,
@@ -25682,12 +25676,12 @@
<div class=impl>
- <p>When an <code><a href=#audio>audio</a></code> element is <a href=#potentially-playing>potentially
+ <p>When an <code><a href=#the-audio-element>audio</a></code> element is <a href=#potentially-playing>potentially
playing</a>, it must have its audio data played synchronized with
the <a href=#current-playback-position>current playback position</a>, at the element's
<a href=#effective-media-volume>effective media volume</a>.</p>
- <p>When an <code><a href=#audio>audio</a></code> element is not <a href=#potentially-playing>potentially
+ <p>When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#potentially-playing>potentially
playing</a>, audio must not play for the element.</p>
</div>
@@ -25696,7 +25690,7 @@
<dd>
- <p>Returns a new <code><a href=#audio>audio</a></code> element, with the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute set to the value
+ <p>Returns a new <code><a href=#the-audio-element>audio</a></code> element, with the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute set to the value
passed in the argument, if applicable.</p>
</dd>
@@ -25707,7 +25701,7 @@
<code><a href=#htmlaudioelement>HTMLAudioElement</a></code> objects (in addition to the factory
methods from DOM Core such as <code title="">createElement()</code>): <dfn id=dom-audio title=dom-Audio><code>Audio()</code></dfn> and <dfn id=dom-audio-s title=dom-Audio-s><code>Audio(<var title="">src</var>)</code></dfn>. When invoked as constructors,
these must return a new <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> object (a new
- <code><a href=#audio>audio</a></code> element). The element must have its <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute set to the
+ <code><a href=#the-audio-element>audio</a></code> element). The element must have its <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute set to the
literal value "<code title=attr-media-preload-auto><a href=#attr-media-preload-auto>auto</a></code>". If the <var title="">src</var> argument is present, the object created must have
its <code title=attr-media-src><a href=#attr-media-src>src</a></code> content attribute set to
the provided value, and the user agent must invoke the object's
@@ -25786,7 +25780,7 @@
<p class=note>Dynamically modifying a <code><a href=#the-source-element>source</a></code> element
and its attribute when the element is already inserted in a
- <code><a href=#video>video</a></code> or <code><a href=#audio>audio</a></code> element will have no
+ <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code> element will have no
effect. To change what is playing, either just use the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute on the <a href=#media-element>media
element</a> directly, or call the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method on the <a href=#media-element>media
element</a> after manipulating the <code><a href=#the-source-element>source</a></code>
@@ -26120,7 +26114,7 @@
<h4 id=media-elements><span class=secno>4.8.10 </span>Media elements</h4>
<p><dfn id=media-element title="media element">Media elements</dfn>
- (<code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code>, in this specification)
+ (<code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code>, in this specification)
implement the following interface:</p>
<pre class=idl>interface <dfn id=htmlmediaelement>HTMLMediaElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
@@ -26242,11 +26236,11 @@
element's <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code>
attribute.</p>
- <p class=note>Both <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code>
+ <p class=note>Both <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code>
elements can be used for both audio and video. The main difference
- between the two is simply that the <code><a href=#audio>audio</a></code> element has no
+ between the two is simply that the <code><a href=#the-audio-element>audio</a></code> element has no
playback area for visual content (such as video or captions),
- whereas the <code><a href=#video>video</a></code> element does.</p>
+ whereas the <code><a href=#the-video-element>video</a></code> element does.</p>
<div class=impl>
@@ -26445,7 +26439,7 @@
agent knows it cannot render</a> or is the type
"<code>application/octet-stream</code>"; it must return "<code title="">probably</code>" if the user agent is confident that the
type represents a <a href=#media-resource>media resource</a> that it can render if
- used in with this <code><a href=#audio>audio</a></code> or <code><a href=#video>video</a></code> element;
+ used in with this <code><a href=#the-audio-element>audio</a></code> or <code><a href=#the-video-element>video</a></code> element;
and it must return "<code title="">maybe</code>" otherwise.
Implementors are encouraged to return "<code title="">maybe</code>"
unless the type can be confidently established as being supported or
@@ -26458,7 +26452,7 @@
<p>This script tests to see if the user agent supports a
(fictional) new format to dynamically decide whether to use a
- <code><a href=#video>video</a></code> element or a plugin:</p>
+ <code><a href=#the-video-element>video</a></code> element or a plugin:</p>
<pre><section id="video">
<p><a href="playing-cats.nfv">Download video</a></p>
@@ -27089,7 +27083,7 @@
</li>
- <li><p>For <code><a href=#video>video</a></code> elements, set the <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code> and <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code>
+ <li><p>For <code><a href=#the-video-element>video</a></code> elements, set the <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code> and <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code>
attributes.</li>
<li>
@@ -27753,7 +27747,7 @@
<dt><dfn id=dom-media-have_metadata title=dom-media-HAVE_METADATA><code>HAVE_METADATA</code></dfn> (numeric value 1)</dt>
<dd>Enough of the resource has been obtained that the duration of
- the resource is available. In the case of a <code><a href=#video>video</a></code>
+ the resource is available. In the case of a <code><a href=#the-video-element>video</a></code>
element, the dimensions of the video are also available. The API
will no longer raise an exception when seeking. No <a href=#media-data>media
data</a> is available for the immediate <a href=#current-playback-position>current playback
@@ -27819,7 +27813,7 @@
<p class=note>Before this task is run, as part of the event
loop mechanism, the rendering will have been updated to resize
- the <code><a href=#video>video</a></code> element if appropriate.</p>
+ the <code><a href=#the-video-element>video</a></code> element if appropriate.</p>
</dd>
@@ -29774,7 +29768,7 @@
<p>In this example, a sign-languge interpreter track from a movie
file is overlaid on the primary video track of that same video file
- using two <code><a href=#video>video</a></code> elements, some CSS, and an implicit
+ using two <code><a href=#the-video-element>video</a></code> elements, some CSS, and an implicit
<code><a href=#mediacontroller>MediaController</a></code>:</p>
<pre><article>
@@ -31014,7 +31008,7 @@
<div class=example>
- <p>In this example, an <code><a href=#audio>audio</a></code> element is used to play a
+ <p>In this example, an <code><a href=#the-audio-element>audio</a></code> element is used to play a
specific sound-effect from a sound file containing many sound
effects. A cue is used to pause the audio, so that it ends exactly
at the end of the clip, even if the browser is busy running some
@@ -33268,7 +33262,7 @@
</ol></div>
<p>The <dfn id=attr-media-muted title=attr-media-muted><code>muted</code></dfn>
- attribute on the <code><a href=#video>video</a></code> element controls the default
+ attribute on the <code><a href=#the-video-element>video</a></code> element controls the default
state of the audio channel of the <a href=#media-resource>media resource</a>,
potentially overriding user preferences.</p>
@@ -33540,7 +33534,7 @@
<h5 id=security-and-privacy-considerations><span class=secno>4.8.10.17 </span>Security and privacy considerations</h5>
<p>The main security and privacy implications of the
- <code><a href=#video>video</a></code> and <code><a href=#audio>audio</a></code> elements come from the
+ <code><a href=#the-video-element>video</a></code> and <code><a href=#the-audio-element>audio</a></code> elements come from the
ability to embed media cross-origin. There are two directions that
threats can flow: from hostile content to a victim page, and from a
hostile page to victim content.</p>
@@ -33554,7 +33548,7 @@
own unrelated <a href=#top-level-browsing-context>top-level browsing context</a>.</p>
<p class=example>For instance, if an SVG animation was embedded in
- a <code><a href=#video>video</a></code> element, the user agent would not give it
+ a <code><a href=#the-video-element>video</a></code> element, the user agent would not give it
access to the DOM of the outer page. From the perspective of scripts
in the SVG resource, the SVG file would appear to be in a lone
top-level browsing context with no parent.</p>
@@ -34839,7 +34833,7 @@
<code title="">repeat</code> is used.</p>
<p>If the first argument isn't an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#video>video</a></code> element, throws a
+ <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#the-video-element>video</a></code> element, throws a
<code><a href=#type_mismatch_err>TYPE_MISMATCH_ERR</a></code> exception. If the image has no
image data, throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception. If
the second argument isn't one of the allowed values, throws a
@@ -36340,7 +36334,7 @@
<p><img alt="The sx and sy parameters give the x and y coordinates of the source rectangle; the sw and sh arguments give the width and height of the source rectangle; the dx and dy give the x and y coordinates of the destination rectangle; and the dw and dh arguments give the width and height of the destination rectangle." height=356 src=<A HREF="http://images.whatwg.org/drawImage.png">http://images.whatwg.org/drawImage.png</A> width=356></p>
<p>If the first argument isn't an <code><a href=#the-img-element>img</a></code>,
- <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#video>video</a></code> element, throws a
+ <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#the-video-element>video</a></code> element, throws a
<code><a href=#type_mismatch_err>TYPE_MISMATCH_ERR</a></code> exception. If the image has no
image data, throws an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception. If
the numeric arguments don't make sense (e.g. the destination is a
@@ -37733,7 +37727,7 @@
<p><span class=impl><strong>Author requirements</strong>:</span>
The <dfn id=attr-dim-width title=attr-dim-width><code>width</code></dfn> and <dfn id=attr-dim-height title=attr-dim-height><code>height</code></dfn> attributes on
<code><a href=#the-img-element>img</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>,
- <code><a href=#the-object-element>object</a></code>, <code><a href=#video>video</a></code>, and, when their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state,
+ <code><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, and, when their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state,
<code><a href=#the-input-element>input</a></code> elements may be specified to give the dimensions
of the visual content of the element (the width and height
respectively, relative to the nominal direction of the output
@@ -37780,12 +37774,12 @@
<p>The <dfn id=dom-dim-width title=dom-dim-width><code>width</code></dfn> and <dfn id=dom-dim-height title=dom-dim-height><code>height</code></dfn> IDL attributes on
the <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-object-element>object</a></code>,
- and <code><a href=#video>video</a></code> elements must <a href=#reflect>reflect</a> the
+ and <code><a href=#the-video-element>video</a></code> elements must <a href=#reflect>reflect</a> the
respective content attributes of the same name.</p>
<p class=note>For <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, and
<code><a href=#the-object-element>object</a></code> the IDL attributes are <code>DOMString</code>;
- for <code><a href=#video>video</a></code> the IDL attributes are <code>unsigned
+ for <code><a href=#the-video-element>video</a></code> the IDL attributes are <code>unsigned
long</code>.</p>
</div>
@@ -46567,9 +46561,9 @@
something like <samp>The text you have entered does not match the
required pattern. Birthday</samp>, which is not useful.</p>
- <p>UAs may still show the <code><a href=#the-title-element-0>title</a></code> in non-error situations
+ <p>UAs may still show the <code><a href=#the-title-element>title</a></code> in non-error situations
(for example, as a tooltip when hovering over the control), so
- authors should be careful not to word <code><a href=#the-title-element-0>title</a></code>s as if an
+ authors should be careful not to word <code><a href=#the-title-element>title</a></code>s as if an
error has necessarily occurred.</p>
@@ -51550,7 +51544,7 @@
- <h4 id=the-command><span class=secno>4.11.3 </span>The <dfn><code>command</code></dfn> element</h4>
+ <h4 id=the-command-element><span class=secno>4.11.3 </span>The <dfn id=the-command><code>command</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#metadata-content>Metadata content</a>.</dd>
@@ -51583,11 +51577,11 @@
attribute boolean <span title="dom-command-default">default</span>;-->
};</pre>
</dd>
- </dl><p>The <code><a href=#the-command>command</a></code> element represents a command that the user
+ </dl><p>The <code><a href=#the-command-element>command</a></code> element represents a command that the user
can invoke.</p>
<p>A command can be part of a context menu or toolbar, using the
- <code><a href=#menus>menu</a></code> element, or can be put anywhere else in the page,
+ <code><a href=#the-menu-element>menu</a></code> element, or can be put anywhere else in the page,
to define a keyboard shortcut.</p> <!-- in the future we'll also add
a command="" attribute to refer to a command, which can then be
defined anywhere -->
@@ -51721,7 +51715,7 @@
<dd><p>If the element has a parent, then the UA must walk the list
of child nodes of that parent element, and for each node that is a
- <code><a href=#the-command>command</a></code> element, if that element has a <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attribute whose
+ <code><a href=#the-command-element>command</a></code> element, if that element has a <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attribute whose
value exactly matches the current element's (treating missing <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attributes as if
they were the empty string), and has a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, must remove
that attribute.</p>
@@ -51747,8 +51741,8 @@
</div>
- <p class=note><code><a href=#the-command>command</a></code> elements are not rendered
- unless they <a href=#menus title=menu>form part of a menu</a>.</p>
+ <p class=note><code><a href=#the-command-element>command</a></code> elements are not rendered
+ unless they <a href=#the-menu-element title=menu>form part of a menu</a>.</p>
<div class=example>
@@ -51774,7 +51768,7 @@
- <h4 id=menus><span class=secno>4.11.4 </span>The <dfn><code>menu</code></dfn> element</h4>
+ <h4 id=the-menu-element><span class=secno>4.11.4 </span>The <dfn id=menus><code>menu</code></dfn> element</h4>
<dl class=element><dt>Categories</dt>
<dd><a href=#flow-content>Flow content</a>.</dd>
@@ -51794,7 +51788,7 @@
attribute DOMString <a href=#dom-menu-type title=dom-menu-type>type</a>;
attribute DOMString <a href=#dom-menu-label title=dom-menu-label>label</a>;
};</pre>
- </dl><p>The <code><a href=#menus>menu</a></code> element represents a list of commands.</p>
+ </dl><p>The <code><a href=#the-menu-element>menu</a></code> element represents a list of commands.</p>
<!-- v2 idea: <menu> should get an icon, like <command> -->
@@ -51810,16 +51804,16 @@
a list of commands that is neither declaring a context menu nor
defining a toolbar.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#context-menu-state title="context menu state">context menu</a> state, then the
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#context-menu-state title="context menu state">context menu</a> state, then the
element <a href=#represents>represents</a> the commands of a context menu, and
the user can only interact with the commands if that context menu is
activated.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the element
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the element
<a href=#represents>represents</a> a list of active commands that the user can
immediately interact with.</p>
- <p>If a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#list-state title="list state">list</a> state, then the element either
+ <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#list-state title="list state">list</a> state, then the element either
<a href=#represents>represents</a> an unordered list of items (each represented
by an <code><a href=#the-li-element>li</a></code> element), each of which represents a command
that the user can perform or activate, or, if the element has no
@@ -51846,7 +51840,7 @@
<p><i>This section is non-normative.</i></p>
- <p>The <code><a href=#menus>menu</a></code> element is used to define context menus and
+ <p>The <code><a href=#the-menu-element>menu</a></code> element is used to define context menus and
toolbars.</p>
<p>For example, the following represents a toolbar with three menu
@@ -51910,7 +51904,7 @@
above, but here the legacy behavior consists of a single
<code><a href=#the-select-element>select</a></code> element with a submit button. The submit button
doesn't appear in the toolbar, because it is not a direct child of
- the <code><a href=#menus>menu</a></code> element or of its <code><a href=#the-li-element>li</a></code>
+ the <code><a href=#the-menu-element>menu</a></code> element or of its <code><a href=#the-li-element>li</a></code>
children.</p>
@@ -51925,7 +51919,7 @@
<ul class=brief><li><a href=#concept-command title=concept-command>Commands</a>, which can be marked as default commands</li>
<li>Separators</li>
<li>Other menus (which allows the list to be nested)</li>
- </ul><p>The list corresponding to a particular <code><a href=#menus>menu</a></code> element
+ </ul><p>The list corresponding to a particular <code><a href=#the-menu-element>menu</a></code> element
is built by iterating over its child nodes. For each child node in
<a href=#tree-order>tree order</a>, the required behavior depends on what the
node is, as follows:</p>
@@ -51961,17 +51955,17 @@
<dd>Iterate over the children of the element.</dd>
- <dt>A <code><a href=#menus>menu</a></code> element with no <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
+ <dt>A <code><a href=#the-menu-element>menu</a></code> element with no <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dt>A <code><a href=#the-select-element>select</a></code> element</dt>
<dd>Append a separator to the menu, then iterate over the children
- of the <code><a href=#menus>menu</a></code> or <code><a href=#the-select-element>select</a></code> element, then
+ of the <code><a href=#the-menu-element>menu</a></code> or <code><a href=#the-select-element>select</a></code> element, then
append another separator.</dd>
<!-- v2: we might want to support <select> in <label> as giving a named submenu -->
- <dt>A <code><a href=#menus>menu</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
+ <dt>A <code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dt>An <code><a href=#the-optgroup-element>optgroup</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt>
<dd>Append a submenu to the menu, using the value of the element's
@@ -52006,11 +52000,11 @@
<p>The <dfn id=attr-contextmenu title=attr-contextmenu><code>contextmenu</code></dfn>
attribute gives the element's <a href=#context-menus title="context menus">context
- menu</a>. The value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#menus>menu</a></code> element
+ menu</a>. The value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#the-menu-element>menu</a></code> element
in the DOM. <span class=impl>If the node that would be obtained by
the invoking the <code title=dom-Document-getElementById><a href=#dom-document-getelementbyid>getElementById()</a></code> method
using the attribute's value as the only argument is null or not a
- <code><a href=#menus>menu</a></code> element, then the element has no assigned context
+ <code><a href=#the-menu-element>menu</a></code> element, then the element has no assigned context
menu. Otherwise, the element's assigned context menu is the element
so identified.</span></p>
@@ -52051,13 +52045,13 @@
<p>If the element or one of its ancestors <em>does</em> have a
context menu assigned, then the user agent must <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-show>show</code> at the
- <code><a href=#menus>menu</a></code> element of the context menu of the nearest
+ <code><a href=#the-menu-element>menu</a></code> element of the context menu of the nearest
ancestor (including the element itself) with one assigned.</p>
<!-- v2: include modifier key information -->
<p>The default action of <em>this</em> event is that the user agent
must show a context menu <a href=#building-menus-and-toolbars title="building menus and
- toolbars">built</a> from the <code><a href=#menus>menu</a></code> element.</p>
+ toolbars">built</a> from the <code><a href=#the-menu-element>menu</a></code> element.</p>
<p>The user agent may also provide access to its default context
menu, if any, with the context menu shown. For example, it could
@@ -52111,13 +52105,13 @@
<h5 id=toolbars><span class=secno>4.11.4.4 </span><dfn>Toolbars</dfn></h5>
- <p>When a <code><a href=#menus>menu</a></code> element has a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the user agent
+ <p>When a <code><a href=#the-menu-element>menu</a></code> element has a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the user agent
must <a href=#building-menus-and-toolbars title="building menus and toolbars">build</a> the
- menu for that <code><a href=#menus>menu</a></code> element, and use the result in the
+ menu for that <code><a href=#the-menu-element>menu</a></code> element, and use the result in the
rendering.</p>
<p>The user agent must reflect changes made to the
- <code><a href=#menus>menu</a></code>'s DOM, by immediately <a href=#building-menus-and-toolbars title="building menus
+ <code><a href=#the-menu-element>menu</a></code>'s DOM, by immediately <a href=#building-menus-and-toolbars title="building menus
and toolbars">rebuilding</a> the menu.</p>
</div>
@@ -52317,7 +52311,7 @@
not specify an icon, or if the element does not define a command,
then the attribute must return null. This attribute will be shadowed
by the <code title=dom-command-icon><a href=#dom-command-icon>icon</a></code> IDL attribute on
- <code><a href=#the-command>command</a></code> elements.</p>
+ <code><a href=#the-command-element>command</a></code> elements.</p>
<p>The <dfn id=dom-command-ro-disabled title=dom-command-ro-disabled><code>disabled</code></dfn>
attribute must return true if the command's <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> is that
@@ -52331,7 +52325,7 @@
command is checked, and false if it is that the command is not
checked. If the element does not define a command, the attribute
must return false. This attribute will be shadowed by the <code title="">checked</code> IDL attribute on <code><a href=#the-input-element>input</a></code> and
- <code><a href=#the-command>command</a></code> elements.</p>
+ <code><a href=#the-command-element>command</a></code> elements.</p>
<!--v2COMMAND
<p>The <dfn
@@ -52561,10 +52555,10 @@
<h5 id=using-the-command-element-to-define-a-command><span class=secno>4.11.5.5 </span>Using the <dfn title=command-element><code>command</code></dfn> element to define
a command</h5>
- <p>A <code><a href=#the-command>command</a></code> element <a href=#concept-command title=concept-command>defines a command</a>.</p>
+ <p>A <code><a href=#the-command-element>command</a></code> element <a href=#concept-command title=concept-command>defines a command</a>.</p>
<p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command
- is "radio" if the <code><a href=#the-command>command</a></code>'s <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is
+ is "radio" if the <code><a href=#the-command-element>command</a></code>'s <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is
"<code>radio</code>", "checkbox" if the attribute's value is
"<code>checkbox</code>", and "command" otherwise.</p>
@@ -54546,7 +54540,7 @@
<li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a>, <a href=#image-button-state title=attr-input-type-image>Image Button</a>, <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>, or <a href=#button-state title=attr-input-type-button>Button</a> state</li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li>elements that are <a href=#specially-focusable>specially focusable</a></li>
@@ -54605,10 +54599,10 @@
<li><code><a href=#the-option-element>option</a></code> elements that are not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li><code><a href=#the-li-element>li</a></code> elements that are children of
- <code><a href=#menus>menu</a></code> elements, and that have a child element that
+ <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that
defines a <a href=#concept-command title=concept-command>command</a>, if the
first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet
is false (not disabled)</li>
@@ -54638,10 +54632,10 @@
<li><code><a href=#the-option-element>option</a></code> elements that are <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li><code><a href=#the-li-element>li</a></code> elements that are children of
- <code><a href=#menus>menu</a></code> elements, and that have a child element that
+ <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that
defines a <a href=#concept-command title=concept-command>command</a>, if the
first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet
is true (disabled)</li>
@@ -54670,11 +54664,11 @@
<li><code><a href=#the-option-element>option</a></code> elements whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is
true</li>
- <li><code><a href=#the-command>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state
+ <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state
and that have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code>
attribute</li>
- <li><code><a href=#the-command>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state and that
+ <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state and that
have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code>
attribute</li>
@@ -55649,15 +55643,15 @@
created by the element.</dd>
- <dt>If the element is a <code><a href=#meta>meta</a></code> element</dt>
+ <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt>
<dd><p>The value is the value of the element's <code title=attr-content>content</code> attribute, if any, or the empty
string if there is no such attribute.</dd>
- <dt>If the element is an <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>,
- <code><a href=#the-track-element>track</a></code>, or <code><a href=#video>video</a></code> element</dt>
+ <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt>
<dd><p>The value is the <a href=#absolute-url>absolute URL</a> that results from
<a href=#resolve-a-url title="resolve a url">resolving</a> the value of the
@@ -55699,10 +55693,10 @@
<code><a href=#textcontent>textContent</a></code>.</dd>
</dl><p>The <dfn id=url-property-elements>URL property elements</dfn> are the <code><a href=#the-a-element>a</a></code>,
- <code><a href=#the-area-element>area</a></code>, <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <code><a href=#the-area-element>area</a></code>, <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-link-element>link</a></code>,
<code><a href=#the-object-element>object</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, and
- <code><a href=#video>video</a></code> elements.</p>
+ <code><a href=#the-video-element>video</a></code> elements.</p>
<p>If a property's <a href=#concept-property-value title=concept-property-value>value</a>
is an <a href=#absolute-url>absolute URL</a>, the property must be specified
@@ -55960,15 +55954,15 @@
setting.</p>
- <dt>If the element is a <code><a href=#meta>meta</a></code> element</dt>
+ <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt>
<dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> content
attribute.</dd>
- <dt>If the element is an <code><a href=#audio>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>,
- <code><a href=#the-track-element>track</a></code>, or <code><a href=#video>video</a></code> element</dt>
+ <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt>
<dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title="">src</code> content attribute.</dd>
@@ -57144,10 +57138,10 @@
text string</a> that is <a href="#the-document's-current-address">the document's current
address</a> as the value to <var title="">output</var>.</li>
- <li><p>If <a href=#the-title-element>the <code>title</code> element</a> is not null,
+ <li><p>If <a href=#the-title-element-0>the <code>title</code> element</a> is not null,
<a href=#add-a-vcard-line>add a vCard line</a> with the type "<code title="">NAME</code>" and with the result of <a href=#escaping-the-vcard-text-string>escaping the
vCard text string</a> obtained from the <code><a href=#textcontent>textContent</a></code>
- of <a href=#the-title-element>the <code>title</code> element</a> as the value to <var title="">output</var>.</li>
+ of <a href=#the-title-element-0>the <code>title</code> element</a> as the value to <var title="">output</var>.</li>
<li><p>If <var title="">node</var> has a <a href=#global-identifier>global
identifier</a>, <a href=#add-a-vcard-line>add a vCard line</a> with the type
@@ -58660,12 +58654,12 @@
<ol><li>
- <p>If <a href=#the-title-element>the <code>title</code> element</a> is not null,
+ <p>If <a href=#the-title-element-0>the <code>title</code> element</a> is not null,
then generate the following triple:</p>
<dl class=triple><dt>subject <dd> <a href="#the-document's-current-address">the document's current address</a>
<dt>predicate <dd> <code title=""><A HREF="http://purl.org/dc/terms/title</code">http://purl.org/dc/terms/title</code</A>>
- <dt>object <dd> the concatenation of the data of all the child <a href=#text-node title="text node">text nodes</a> of <a href=#the-title-element>the <code>title</code> element</a>, in <a href=#tree-order>tree order</a>, as a plain literal, with the language information set from the <a href=#language>language</a> of <a href=#the-title-element>the <code>title</code> element</a>, if it is not unknown.
+ <dt>object <dd> the concatenation of the data of all the child <a href=#text-node title="text node">text nodes</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, in <a href=#tree-order>tree order</a>, as a plain literal, with the language information set from the <a href=#language>language</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, if it is not unknown.
</dl></li>
@@ -58720,7 +58714,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element in the <code><a href=#document>Document</a></code>
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element in the <code><a href=#document>Document</a></code>
that has a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and
a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, if the
value of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute
@@ -58730,7 +58724,7 @@
<dl class=triple><dt>subject <dd> <a href="#the-document's-current-address">the document's current address</a>
<dt>predicate <dd> the concatenation of the string "<code title=""><A HREF="http://www.w3.org/1999/xhtml/vocab#</code">http://www.w3.org/1999/xhtml/vocab#</code</A>>" and the value of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, with any characters in the value that are not valid in the <ifragment> production of the IRI syntax being %-escaped <a href=#refsRFC3987>[RFC3987]</a>
<dt>object <dd> the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, as a plain literal, with the language information set from the <a href=#language>language</a> of the element, if it is not unknown
- </dl><p>For each <code><a href=#meta>meta</a></code> element in the <code><a href=#document>Document</a></code>
+ </dl><p>For each <code><a href=#the-meta-element>meta</a></code> element in the <code><a href=#document>Document</a></code>
that has a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and
a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, if the
value of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute is
@@ -59080,7 +59074,7 @@
<li>
- <p>For each <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is <code title=meta-author><a href=#meta-author>author</a></code>, run the following substeps:</p>
+ <p>For each <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is <code title=meta-author><a href=#meta-author>author</a></code>, run the following substeps:</p>
<ol><li><p>Append an <code title="">author</code> element in the
<a href=#atom-namespace>Atom namespace</a> to the root element of <var title="">R</var>.</li>
@@ -59090,7 +59084,7 @@
previous step.</p>
<li><p>Append a text node whose data is the value of the
- <code><a href=#meta>meta</a></code> element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute to the element
+ <code><a href=#the-meta-element>meta</a></code> element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute to the element
created in the previous step.</li>
</ol><!-- could use vCards instead, and get <atom:email> and <atom:uri>
@@ -59173,7 +59167,7 @@
<dd>
<p>Let <var title="">heading content</var> be the descendants of
- <a href=#the-title-element>the <code>title</code> element</a>, if there is one, or
+ <a href=#the-title-element-0>the <code>title</code> element</a>, if there is one, or
an empty list otherwise.</p>
</dd>
@@ -59709,7 +59703,7 @@
whose <a href="#the-document's-address" title="the document's address">address</a> is
<code><a href=#about:blank>about:blank</a></code>, which is marked as being an <a href=#html-documents title="HTML documents">HTML document</a>, and whose <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> is
UTF-8. The <code><a href=#document>Document</a></code> must have a single child
- <code><a href=#the-html-element-0>html</a></code> node, which itself has a single child
+ <code><a href=#the-html-element>html</a></code> node, which itself has a single child
<code><a href=#the-body-element-0>body</a></code> node.</p>
<p class=note>If the <a href=#browsing-context>browsing context</a> is created
@@ -61019,10 +61013,10 @@
origin</a> of a script are determined from another resource,
called the <i>owner</i>:</p>
- <dl class=switch><dt>If a script is in a <code><a href=#script>script</a></code> element</dt>
+ <dl class=switch><dt>If a script is in a <code><a href=#the-script-element>script</a></code> element</dt>
<dd>The owner is the <code><a href=#document>Document</a></code> to which the
- <code><a href=#script>script</a></code> element belongs.</dd>
+ <code><a href=#the-script-element>script</a></code> element belongs.</dd>
<dt>If a script is in an <a href=#event-handler-content-attributes title="event handler content
@@ -61176,7 +61170,7 @@
</dd>
- <dt>For <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code> elements</dt>
+ <dt>For <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements</dt>
<dd>
@@ -61491,7 +61485,7 @@
<p class=note>Titles associated with <a href=#session-history-entry title="session history
entry">session history entries</a> need not have any relation
- with the current <code><a href=#the-title-element-0>title</a></code> of the
+ with the current <code><a href=#the-title-element>title</a></code> of the
<code><a href=#document>Document</a></code>. The title of a <a href=#session-history-entry>session history
entry</a> is intended to explain the state of the document at
that point, so that the user can navigate the document's
@@ -61949,8 +61943,8 @@
<p>Applications might not use the same title for a <a href=#session-history-entry>session
history entry</a> as the value of the document's
- <code><a href=#the-title-element-0>title</a></code> element at that time. For example, here is a
- simple page that shows a block in the <code><a href=#the-title-element-0>title</a></code> element.
+ <code><a href=#the-title-element>title</a></code> element at that time. For example, here is a
+ simple page that shows a block in the <code><a href=#the-title-element>title</a></code> element.
Clearly, when navigating backwards to a previous state the user
does not go back in time, and therefore it would be inappropriate
to put the time in the session history title.</p>
@@ -62828,7 +62822,7 @@
character encoding.</p>
<p>If the root element, as parsed according to the XML
- specifications cited above, is found to be an <code><a href=#the-html-element-0>html</a></code>
+ specifications cited above, is found to be an <code><a href=#the-html-element>html</a></code>
element with an attribute <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> whose value is not the
empty string, then, as soon as the element is <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into the document</a>, the user
@@ -62915,9 +62909,9 @@
before the page has finished parsing, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, e.g. linking to a style sheet or an XBL
- binding, providing script, giving the document a <code><a href=#the-title-element-0>title</a></code>,
+ binding, providing script, giving the document a <code><a href=#the-title-element>title</a></code>,
etc.</p>
<p class=note>In particular, if the user agent supports the <code title="">Format=Flowed</code> feature of RFC 3676 then the user
@@ -62934,9 +62928,9 @@
<p>When an image resource is to be loaded in a <a href=#browsing-context>browsing
context</a>, the user agent should <a href=#create-a-document-object>create a
<code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, append an
- <code><a href=#the-html-element-0>html</a></code> element to the <code><a href=#document>Document</a></code>, append a
- <code><a href=#the-head-element-0>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element to the
- <code><a href=#the-html-element-0>html</a></code> element, append an <code><a href=#the-img-element>img</a></code> to the
+ <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>, append a
+ <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element to the
+ <code><a href=#the-html-element>html</a></code> element, append an <code><a href=#the-img-element>img</a></code> to the
<code><a href=#the-body-element-0>body</a></code> element, and set the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of the <code><a href=#the-img-element>img</a></code>
element to the address of the image.</p>
@@ -62955,10 +62949,10 @@
before the page has finished fully loading, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, or attributes to the <code><a href=#the-img-element>img</a></code>
element, e.g. to link to a style sheet or an XBL binding, to provide
- a script, to give the document a <code><a href=#the-title-element-0>title</a></code>, etc.</p>
+ a script, to give the document a <code><a href=#the-title-element>title</a></code>, etc.</p>
<h4 id=read-plugin><span class=secno>6.5.6 </span><dfn title=navigate-plugin>Page load processing model for content that uses plugins</dfn></h4>
@@ -62967,9 +62961,9 @@
is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent
should <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it
as being an <a href=#html-documents title="HTML documents">HTML document</a>,
- append an <code><a href=#the-html-element-0>html</a></code> element to the <code><a href=#document>Document</a></code>,
- append a <code><a href=#the-head-element-0>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element
- to the <code><a href=#the-html-element-0>html</a></code> element, append an <code><a href=#the-embed-element>embed</a></code> to
+ append an <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>,
+ append a <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element-0>body</a></code> element
+ to the <code><a href=#the-html-element>html</a></code> element, append an <code><a href=#the-embed-element>embed</a></code> to
the <code><a href=#the-body-element-0>body</a></code> element, and set the <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute of the
<code><a href=#the-embed-element>embed</a></code> element to the address of the resource.</p>
@@ -62988,10 +62982,10 @@
before the page has finished fully loading, the user agent must
<a href=#update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>
- <p>User agents may add content to the <code><a href=#the-head-element-0>head</a></code> element of
+ <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of
the <code><a href=#document>Document</a></code>, or attributes to the <code><a href=#the-embed-element>embed</a></code>
element, e.g. to link to a style sheet or an XBL binding, or to give
- the document a <code><a href=#the-title-element-0>title</a></code>.</p>
+ the document a <code><a href=#the-title-element>title</a></code>.</p>
<p class=note id=sandboxPluginNavigate>If the <a href=#sandboxed-plugins-browsing-context-flag>sandboxed
plugins browsing context flag</a> was set on the <a href=#browsing-context>browsing
@@ -63837,7 +63831,7 @@
<dt><dfn id=concept-appcache-manifest title=concept-appcache-manifest>The manifest</dfn>
<dd><p class=note>This is the resource corresponding to the URL
- that was given in a master entry's <code><a href=#the-html-element-0>html</a></code> element's
+ that was given in a master entry's <code><a href=#the-html-element>html</a></code> element's
<code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute. The
manifest is fetched and processed during the <a href=#application-cache-download-process>application
cache download process</a>. All the <a href=#concept-appcache-master title=concept-appcache-master>master entries</a> have the
@@ -65052,7 +65046,7 @@
entry</a>.</li>
<li><p>As an optimization, if the resource is an HTML or XML file
- whose root element is an <code><a href=#the-html-element-0>html</a></code> element with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value
+ whose root element is an <code><a href=#the-html-element>html</a></code> element with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value
doesn't match the manifest URL of the application cache being
processed, then the user agent should mark the entry as being
<a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>.</p>
@@ -65813,7 +65807,7 @@
run in the context of a document. These mechanisms include, but are
probably not limited to:</p>
- <ul><li>Processing of <code><a href=#script>script</a></code> elements.</li>
+ <ul><li>Processing of <code><a href=#the-script-element>script</a></code> elements.</li>
<li>Processing of inline <code title="javascript
protocol"><a href=#javascript-protocol>javascript:</a></code> URLs (e.g. the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of <code><a href=#the-img-element>img</a></code>
@@ -68856,7 +68850,7 @@
<li><code><a href=#the-textarea-element>textarea</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li>
- <li><code><a href=#the-command>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
+ <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li>
<li>Elements with a <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code>
attribute set, if that would enable the user agent to allow the
@@ -73037,8 +73031,8 @@
receiving streams from remote peers.</li>
<li>Displaying such streams (both the locally-produced ones and the
- remotely-obtained ones) locally using the <code><a href=#video>video</a></code> or
- <code><a href=#audio>audio</a></code> elements.</li>
+ remotely-obtained ones) locally using the <code><a href=#the-video-element>video</a></code> or
+ <code><a href=#the-audio-element>audio</a></code> elements.</li>
<li>Sending arbitrary data to remote peers.</li>
@@ -73589,8 +73583,8 @@
<li><p>Return, and run the remaining steps asynchronously.</li>
<li><p>Generate a file that containing <var title="">data</var> in
- a format supported by the user agent for use in <code><a href=#audio>audio</a></code>
- and <code><a href=#video>video</a></code> elements.</li>
+ a format supported by the user agent for use in <code><a href=#the-audio-element>audio</a></code>
+ and <code><a href=#the-video-element>video</a></code> elements.</li>
<li><p>Let <var title="">blob</var> be a <code>Blob</code> object
representing the contents of the file generated in the previous
@@ -73688,7 +73682,7 @@
<p>For audio and video streams, the data exposed on that stream must
be in a format supported by the user agent for use in
- <code><a href=#audio>audio</a></code> and <code><a href=#video>video</a></code> elements.</p>
+ <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements.</p>
<p class=bookkeeping>A <dfn id=blob-url>Blob URL</dfn> is the same as what the
File API specification calls a <span>Blob URI</span>, except that
@@ -74140,13 +74134,13 @@
<p>User agents may negotiate any codec and any resolution, bitrate,
or other quality metric. User agents are encouraged to initially
negotiate for the native resolution of the stream. For streams that
- are then rendered (using a <code><a href=#video>video</a></code> element), user agents
+ are then rendered (using a <code><a href=#the-video-element>video</a></code> element), user agents
are encouraged to renegotiate for a resolution that matches the
rendered display size.</p>
<p class=note>Starting with the native resolution means that if
the Web application notifies its peer of the native resolution as it
- starts sending data, and the peer prepares its <code><a href=#video>video</a></code>
+ starts sending data, and the peer prepares its <code><a href=#the-video-element>video</a></code>
element accordingly, there will be no need for a renegotiation once
the stream is flowing.</p>
@@ -75611,7 +75605,7 @@
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
- <li>The root element, in the form of an <code><a href=#the-html-element-0>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
+ <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li>
<li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and
<a href=#space-character title="space character">space characters</a>.</li>
@@ -75625,19 +75619,19 @@
<div class=note>
- <p>Space characters before the root <code><a href=#the-html-element-0>html</a></code> element, and
- space characters at the start of the <code><a href=#the-html-element-0>html</a></code> element and
- before the <code><a href=#the-head-element-0>head</a></code> element, will be dropped when the
+ <p>Space characters before the root <code><a href=#the-html-element>html</a></code> element, and
+ space characters at the start of the <code><a href=#the-html-element>html</a></code> element and
+ before the <code><a href=#the-head-element>head</a></code> element, will be dropped when the
document is parsed; space characters <em>after</em> the root
- <code><a href=#the-html-element-0>html</a></code> element will be parsed as if they were at the end
+ <code><a href=#the-html-element>html</a></code> element will be parsed as if they were at the end
of the <code><a href=#the-body-element-0>body</a></code> element. Thus, space characters around the
root element do not round-trip.</p>
<p>It is suggested that newlines be inserted after the DOCTYPE,
after any comments that are before the root element, after the
- <code><a href=#the-html-element-0>html</a></code> element's start tag (if it is not <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>), and after any comments
- that are inside the <code><a href=#the-html-element-0>html</a></code> element but before the
- <code><a href=#the-head-element-0>head</a></code> element.</p>
+ <code><a href=#the-html-element>html</a></code> element's start tag (if it is not <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>), and after any comments
+ that are inside the <code><a href=#the-html-element>html</a></code> element but before the
+ <code><a href=#the-head-element>head</a></code> element.</p>
</div>
@@ -75742,21 +75736,21 @@
<dl><dt><dfn id=void-elements>Void elements</dfn></dt>
<dd><code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-br-element>br</a></code>,
- <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command>command</a></code>, <code><a href=#the-embed-element>embed</a></code>,
+ <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>,
<code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
- <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#meta>meta</a></code>,
+ <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>,
<code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>,
<code><a href=#the-wbr-element>wbr</a></code></dd>
<!-- see also other places that say VOIDLIST -->
<dt><dfn id=raw-text-elements>Raw text elements</dfn></dt>
- <dd><code><a href=#script>script</a></code>, <code><a href=#the-style-element>style</a></code></dd> <!-- iframe and
+ <dd><code><a href=#the-script-element>script</a></code>, <code><a href=#the-style-element>style</a></code></dd> <!-- iframe and
noscript don't count as raw text for syntax purposes -->
<dt><dfn id=rcdata-elements>RCDATA elements</dfn></dt>
- <dd><code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-title-element-0>title</a></code></dd>
+ <dd><code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-title-element>title</a></code></dd>
<dt><dfn id=foreign-elements>Foreign elements</dfn></dt>
@@ -76110,34 +76104,34 @@
<p class=note>Omitting an element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> does not mean the element
is not present; it is implied, but it is still there. An HTML
- document always has a root <code><a href=#the-html-element-0>html</a></code> element, even if the
+ document always has a root <code><a href=#the-html-element>html</a></code> element, even if the
string <code title=""><html></code> doesn't appear anywhere in
the markup.</p>
<!-- <html> -->
- <p>An <code><a href=#the-html-element-0>html</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
- first thing inside the <code><a href=#the-html-element-0>html</a></code> element is not a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
+ <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
+ first thing inside the <code><a href=#the-html-element>html</a></code> element is not a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- </html> -->
- <p>An <code><a href=#the-html-element-0>html</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
- tag</a> may be omitted if the <code><a href=#the-html-element-0>html</a></code> element is not
+ <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
+ tag</a> may be omitted if the <code><a href=#the-html-element>html</a></code> element is not
immediately followed by a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- <head> -->
- <p>A <code><a href=#the-head-element-0>head</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
+ <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
element is empty, or if the first thing inside the
- <code><a href=#the-head-element-0>head</a></code> element is an element.</p>
+ <code><a href=#the-head-element>head</a></code> element is an element.</p>
<!-- </head> -->
- <p>A <code><a href=#the-head-element-0>head</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
- tag</a> may be omitted if the <code><a href=#the-head-element-0>head</a></code> element is not
+ <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
+ tag</a> may be omitted if the <code><a href=#the-head-element>head</a></code> element is not
immediately followed by a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>.</p>
<!-- <body> -->
<p>A <code><a href=#the-body-element-0>body</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the
element is empty, or if the first thing inside the <code><a href=#the-body-element-0>body</a></code>
element is not a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>, except if the first thing
- inside the <code><a href=#the-body-element-0>body</a></code> element is a <code><a href=#script>script</a></code> or
+ inside the <code><a href=#the-body-element-0>body</a></code> element is a <code><a href=#the-script-element>script</a></code> or
<code><a href=#the-style-element>style</a></code> element. <!-- Note that even if the </head> end
tag is present, the parser makes <style> and <script> elements
between </head> and <body> end up in the <head> instead of implying
@@ -76176,7 +76170,7 @@
<code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-header-element>header</a></code>,
- <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#menus>menu</a></code>,
+ <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-menu-element>menu</a></code>,
<code><a href=#the-nav-element>nav</a></code>, <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-pre-element>pre</a></code>,
<code><a href=#the-section-element>section</a></code>, <code><a href=#the-table-element>table</a></code>, or <code><a href=#the-ul-element>ul</a></code>,
element, or if there is no more content in the parent element and
@@ -77460,7 +77454,7 @@
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" and abort these
steps.</li>
- <li>If <var title="">node</var> is a <code><a href=#the-head-element-0>head</a></code> element,
+ <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element,
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" ("<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"! <em> not "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>"</em>!) and abort
these steps. (<a href=#fragment-case>fragment case</a>)</li> <!-- This is only
here for now in case people think that the spec accidentally
@@ -77482,7 +77476,7 @@
then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" and abort
these steps. (<a href=#fragment-case>fragment case</a>)</li>
- <li>If <var title="">node</var> is an <code><a href=#the-html-element-0>html</a></code> element,
+ <li>If <var title="">node</var> is an <code><a href=#the-html-element>html</a></code> element,
then <!--: if the <span><code title="">head</code> element
pointer</span> is null,--> switch the <a href=#insertion-mode>insertion mode</a>
to "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before
@@ -77513,17 +77507,17 @@
<p>The "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before
html</a>" <a href=#insertion-mode>insertion mode</a> creates the
- <code><a href=#the-html-element-0>html</a></code> root element node, which is then added to the
+ <code><a href=#the-html-element>html</a></code> root element node, which is then added to the
stack.</p>
<p>In the <a href=#fragment-case>fragment case</a>, the <a href=#stack-of-open-elements>stack of open
- elements</a> is initialized to contain an <code><a href=#the-html-element-0>html</a></code>
+ elements</a> is initialized to contain an <code><a href=#the-html-element>html</a></code>
element that is created as part of <a href=#html-fragment-parsing-algorithm title="html fragment
parsing algorithm">that algorithm</a>. (The <a href=#fragment-case>fragment
case</a> skips the "<a href=#the-before-html-insertion-mode title="insertion mode: before
html">before html</a>" <a href=#insertion-mode>insertion mode</a>.)</p>
- <p>The <code><a href=#the-html-element-0>html</a></code> node, however it is created, is the topmost
+ <p>The <code><a href=#the-html-element>html</a></code> node, however it is created, is the topmost
node of the stack. It only gets popped off the stack when the parser
<a href=#stop-parsing title="stop parsing">finishes</a>.</p>
@@ -77535,7 +77529,7 @@
one. If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
open elements</a> (<a href=#fragment-case>fragment case</a>), then the
<a href=#current-table>current table</a> is the first element in the <a href=#stack-of-open-elements>stack
- of open elements</a> (the <code><a href=#the-html-element-0>html</a></code> element).</p>
+ of open elements</a> (the <code><a href=#the-html-element>html</a></code> element).</p>
<p>Elements in the stack fall into the following categories:</p>
@@ -77546,28 +77540,28 @@
<code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>,
<code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-br-element>br</a></code>,
<code><a href=#the-button-element>button</a></code>, <code><a href=#the-caption-element>caption</a></code>, <code><a href=#center>center</a></code>,
- <code><a href=#the-col-element>col</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-command>command</a></code>,
+ <code><a href=#the-col-element>col</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-command-element>command</a></code>,
<code><a href=#the-dd-element>dd</a></code>, <code><a href=#the-details-element>details</a></code>, <code><a href=#dir>dir</a></code>,
<code><a href=#the-div-element>div</a></code>, <code><a href=#the-dl-element>dl</a></code>, <code><a href=#the-dt-element>dt</a></code>,
<code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-figcaption-element>figcaption</a></code>,
<code><a href=#the-figure-element>figure</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>,
<code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>,
<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>,
- <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-head-element-0>head</a></code>, <code><a href=#the-header-element>header</a></code>,
- <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-html-element-0>html</a></code>,
+ <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-head-element>head</a></code>, <code><a href=#the-header-element>header</a></code>,
+ <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <!-- <code>image</code>, (commented out
because this isn't an element that can end up on the stack, so it
doesn't matter) --> <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
<code><a href=#isindex-0>isindex</a></code>, <code><a href=#the-li-element>li</a></code>, <code><a href=#the-link-element>link</a></code>,
- <code><a href=#listing>listing</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#menus>menu</a></code>,
- <code><a href=#meta>meta</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#noembed>noembed</a></code>,
+ <code><a href=#listing>listing</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-menu-element>menu</a></code>,
+ <code><a href=#the-meta-element>meta</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#noembed>noembed</a></code>,
<code><a href=#noframes>noframes</a></code>, <code><a href=#the-noscript-element>noscript</a></code>, <code><a href=#the-object-element>object</a></code>,
<code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-param-element>param</a></code>,
- <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#script>script</a></code>,
+ <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#the-script-element>script</a></code>,
<code><a href=#the-section-element>section</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-style-element>style</a></code>,
<code><a href=#the-summary-element>summary</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>,
<code><a href=#the-td-element>td</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
- <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-title-element-0>title</a></code>,
+ <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-title-element>title</a></code>,
<code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-ul-element>ul</a></code>, <code><a href=#the-wbr-element>wbr</a></code>, and
<code><a href=#xmp>xmp</a></code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code title="">annotation-xml</code>; and SVG's <code title="">foreignObject</code>, <code title="">desc</code>, and
<code title="">title</code>.</dd> <!-- we could actually put
@@ -77604,7 +77598,7 @@
entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to step
2. (This will never fail, since the loop will always terminate in
the previous step if the top of the stack — an
- <code><a href=#the-html-element-0>html</a></code> element — is reached.)</li>
+ <code><a href=#the-html-element>html</a></code> element — is reached.)</li>
</ol><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-scope title="has an element in scope">have an element in scope</dfn> when
it <a href=#has-an-element-in-the-specific-scope>has an element in the specific scope</a> consisting
@@ -77612,7 +77606,7 @@
<ul class=brief><li><code><a href=#the-applet-element>applet</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-caption-element>caption</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
- <li><code><a href=#the-html-element-0>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
+ <li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
<li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-td-element>td</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
<li><code><a href=#the-th-element>th</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
@@ -77646,7 +77640,7 @@
scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
scope</a> consisting of the following element types:</p>
- <ul class=brief><li><code><a href=#the-html-element-0>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
+ <ul class=brief><li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
<li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
</ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope title="has an element in select scope">have an element in select
scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
@@ -77790,7 +77784,7 @@
pointer</dfn> and the <dfn id=form-element-pointer><code title="">form</code> element
pointer</dfn> are both null.</p>
- <p>Once a <code><a href=#the-head-element-0>head</a></code> element has been parsed (whether
+ <p>Once a <code><a href=#the-head-element>head</a></code> element has been parsed (whether
implicitly or explicitly) the <a href=#head-element-pointer><code title="">head</code>
element pointer</a> gets set to point to this node.</p>
@@ -77809,7 +77803,7 @@
<p class=note>The <a href=#scripting-flag>scripting flag</a> can be enabled even
when the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML fragment
- parsing algorithm</a>, even though <code><a href=#script>script</a></code> elements
+ parsing algorithm</a>, even though <code><a href=#the-script-element>script</a></code> elements
don't execute in that case.</p>
<p>The <dfn id=frameset-ok-flag>frameset-ok flag</dfn> is set to "ok" when the parser is
@@ -77857,7 +77851,7 @@
<a href=#tree-construction>tree construction</a> stage. The tree construction stage
can affect the state of the tokenization stage, and can insert
additional characters into the stream. (For example, the
- <code><a href=#script>script</a></code> element can result in scripts executing and
+ <code><a href=#the-script-element>script</a></code> element can result in scripts executing and
using the <a href=#dynamic-markup-insertion>dynamic markup insertion</a> APIs to insert
characters into the stream being tokenized.)</p>
@@ -80316,7 +80310,7 @@
<p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
open elements</a> (<a href=#fragment-case>fragment case</a>), then the
<i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the <a href=#stack-of-open-elements>stack
- of open elements</a> (the <code><a href=#the-html-element-0>html</a></code> element). Otherwise,
+ of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise,
if there is a <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
elements</a>, but the last <code><a href=#the-table-element>table</a></code> element in the
<a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its parent
@@ -80593,7 +80587,7 @@
<dt>Anything else</dt>
<dd>
- <p>Create an <code><a href=#the-html-element-0>html</a></code> element. Append it to the
+ <p>Create an <code><a href=#the-html-element>html</a></code> element. Append it to the
<code><a href=#document>Document</a></code> object. Put this element in the <a href=#stack-of-open-elements>stack
of open elements</a>.</p>
@@ -80648,7 +80642,7 @@
<p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
<p>Set the <a href=#head-element-pointer><code title="">head</code> element pointer</a>
- to the newly created <code><a href=#the-head-element-0>head</a></code> element.</p>
+ to the newly created <code><a href=#the-head-element>head</a></code> element.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
@@ -80795,7 +80789,7 @@
<li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML
fragment parsing algorithm</a>, then mark the
- <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
<li><p>Append the new element to the <a href=#current-node>current node</a>
@@ -80816,7 +80810,7 @@
<dd>
<p>Pop the <a href=#current-node>current node</a> (which will be the
- <code><a href=#the-head-element-0>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
+ <code><a href=#the-head-element>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>".</p>
@@ -80865,7 +80859,7 @@
<p>Pop the <a href=#current-node>current node</a> (which will be a
<code><a href=#the-noscript-element>noscript</a></code> element) from the <a href=#stack-of-open-elements>stack of open
elements</a>; the new <a href=#current-node>current node</a> will be a
- <code><a href=#the-head-element-0>head</a></code> element.</p>
+ <code><a href=#the-head-element>head</a></code> element.</p>
<p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
@@ -81105,7 +81099,7 @@
<li><p>Pop all the nodes from the bottom of the <a href=#stack-of-open-elements>stack of
open elements</a>, from the <a href=#current-node>current node</a> up to,
- but not including, the root <code><a href=#the-html-element-0>html</a></code> element.</p>
+ but not including, the root <code><a href=#the-html-element>html</a></code> element.</p>
<li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the
token.</li>
@@ -81123,7 +81117,7 @@
<code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a
<code><a href=#the-tfoot-element>tfoot</a></code> element, a <code><a href=#the-th-element>th</a></code> element, a
<code><a href=#the-thead-element>thead</a></code> element, a <code><a href=#the-tr-element>tr</a></code> element, the
- <code><a href=#the-body-element-0>body</a></code> element, or the <code><a href=#the-html-element-0>html</a></code> element, then
+ <code><a href=#the-body-element-0>body</a></code> element, or the <code><a href=#the-html-element>html</a></code> element, then
this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are
fragment cases) -->
@@ -81150,7 +81144,7 @@
<code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
<code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a
<code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element-0>body</a></code> element, or the
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p> <!-- (some of those are fragment cases, e.g. for
<tbody> you'd have hit the first paragraph since the <body>
wouldn't be in scope, unless it was a fragment case) -->
@@ -82278,8 +82272,8 @@
<!-- can't be the fragment case -->
<p><a href=#parse-error>Parse error</a>.</p>
- <p>If the <a href=#current-node>current node</a> is a <code><a href=#script>script</a></code>
- element, mark the <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ <p>If the <a href=#current-node>current node</a> is a <code><a href=#the-script-element>script</a></code>
+ element, mark the <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
started"</a>.</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
@@ -82296,7 +82290,7 @@
<p><a href=#provide-a-stable-state>Provide a stable state</a>.</p>
<p>Let <var title="">script</var> be the <a href=#current-node>current node</a>
- (which will be a <code><a href=#script>script</a></code> element).</p>
+ (which will be a <code><a href=#the-script-element>script</a></code> element).</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
@@ -82576,7 +82570,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -82602,11 +82596,11 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-context>clear the stack
back to a table context</dfn>, it means that the UA must, while
the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>
- element or an <code><a href=#the-html-element-0>html</a></code> element, pop elements from the
+ element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
<a href=#stack-of-open-elements>stack of open elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -82755,7 +82749,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>; ignore the token. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -82774,7 +82768,7 @@
<dt>An end-of-file token</dt>
<dd>
- <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element-0>html</a></code>
+ <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code>
element, then <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -82874,12 +82868,12 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-body-context>clear the stack
back to a table body context</dfn>, it means that the UA must,
while the <a href=#current-node>current node</a> is not a <code><a href=#the-tbody-element>tbody</a></code>,
- <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element-0>html</a></code>
+ <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element>html</a></code>
element, pop elements from the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -82965,11 +82959,11 @@
</dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-row-context>clear the stack
back to a table row context</dfn>, it means that the UA must,
while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>
- element or an <code><a href=#the-html-element-0>html</a></code> element, pop elements from the
+ element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
<a href=#stack-of-open-elements>stack of open elements</a>.</p>
<p class=note>The <a href=#current-node>current node</a> being an
- <code><a href=#the-html-element-0>html</a></code> element after this process is a <a href=#fragment-case>fragment
+ <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment
case</a>.</p>
@@ -83201,7 +83195,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -83262,7 +83256,7 @@
<dt>A comment token</dt>
<dd>
<p>Append a <code><a href=#comment-0>Comment</a></code> node to the first element in
- the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element-0>html</a></code>
+ the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code>
element), with the <code title="">data</code> attribute set to
the data given in the comment token.</p>
</dd>
@@ -83343,7 +83337,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>; ignore the token. (<a href=#fragment-case>fragment
case</a>)</p>
@@ -83381,7 +83375,7 @@
<dd>
<p>If the <a href=#current-node>current node</a> is not the root
- <code><a href=#the-html-element-0>html</a></code> element, then this is a <a href=#parse-error>parse
+ <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
error</a>.</p>
<p class=note>It can only be the <a href=#current-node>current node</a> in
@@ -83758,17 +83752,17 @@
substeps:</p>
<ol><li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the first
- <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ <code><a href=#the-script-element>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
execute when the document has finished parsing</a> has its
<a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag set <em>and</em>
the parser's <code><a href=#document>Document</a></code> <a href=#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that
is blocking scripts</a>.</li>
<li><p><a href=#execute-the-script-block title="execute the script block">Execute</a> the
- first <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ first <code><a href=#the-script-element>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
execute when the document has finished parsing</a>.</li>
- <li><p>Remove the first <code><a href=#script>script</a></code> element from the
+ <li><p>Remove the first <code><a href=#the-script-element>script</a></code> element from the
<a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has
finished parsing</a> (i.e. shift out the first entry in the
list).</li>
@@ -83968,8 +83962,8 @@
<p>The parsing of this markup is straightforward up to the "3". At
this point, the DOM looks like this:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has five elements
- on it: <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-p-element>p</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has five elements
+ on it: <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-p-element>p</a></code>,
<code><a href=#the-b-element>b</a></code>, and <code><a href=#the-i-element>i</a></code>. The <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> just has two: <code><a href=#the-b-element>b</a></code> and
<code><a href=#the-i-element>i</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
@@ -83978,7 +83972,7 @@
invoked. This is a simple case, in that the <var title="">formatting
element</var> is the <code><a href=#the-b-element>b</a></code> element, and there is no
<var title="">furthest block</var>. Thus, the <a href=#stack-of-open-elements>stack of open
- elements</a> ends up with just three elements: <code><a href=#the-html-element-0>html</a></code>,
+ elements</a> ends up with just three elements: <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-body-element-0>body</a></code>, and <code><a href=#the-p-element>p</a></code>, while the <a href=#list-of-active-formatting-elements>list of
active formatting elements</a> has just one: <code><a href=#the-i-element>i</a></code>. The
DOM tree is unmodified at this point.</p>
@@ -83990,7 +83984,7 @@
received, and the "5" text node is inserted, the DOM looks as
follows:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>11.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>11.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
<p><i>This section is non-normative.</i></p>
@@ -84000,11 +83994,11 @@
<p>Up to the "2" the parsing here is straightforward:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The interesting part is when the end tag token with the tag name
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The interesting part is when the end tag token with the tag name
"b" is parsed.</p>
<p>Before that token is seen, the <a href=#stack-of-open-elements>stack of open
- elements</a> has four elements on it: <code><a href=#the-html-element-0>html</a></code>,
+ elements</a> has four elements on it: <code><a href=#the-html-element>html</a></code>,
<code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-b-element>b</a></code>, and <code><a href=#the-p-element>p</a></code>. The
<a href=#list-of-active-formatting-elements>list of active formatting elements</a> just has the one:
<code><a href=#the-b-element>b</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
@@ -84028,18 +84022,18 @@
<p>The <var title="">last node</var> gets appended (moved) to the
<var title="">common ancestor</var>, so that the DOM looks like:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul><p>A new <code><a href=#the-b-element>b</a></code> element is created, and the children of the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul><p>A new <code><a href=#the-b-element>b</a></code> element is created, and the children of the
<code><a href=#the-p-element>p</a></code> element are moved to it:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code></ul></ul></ul><ul class=domTree><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul><p>Finally, the new <code><a href=#the-b-element>b</a></code> element is appended to the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code></ul></ul></ul><ul class=domTree><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul><p>Finally, the new <code><a href=#the-b-element>b</a></code> element is appended to the
<code><a href=#the-p-element>p</a></code> element, so that the DOM looks like:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The <code><a href=#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements>list of
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The <code><a href=#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements>list of
active formatting elements</a> and the <a href=#stack-of-open-elements>stack of open
elements</a>, so that when the "3" is parsed, it is appended to
the <code><a href=#the-p-element>p</a></code> element:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>11.2.8.3 </span>Unexpected markup in tables</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>11.2.8.3 </span>Unexpected markup in tables</h5>
<p><i>This section is non-normative.</i></p>
@@ -84054,11 +84048,11 @@
examining the DOM tree as it stands just after the
<code><a href=#the-table-element>table</a></code> element's start tag has been seen:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>...and then immediately after the <code><a href=#the-b-element>b</a></code> element start
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>...and then immediately after the <code><a href=#the-b-element>b</a></code> element start
tag has been seen:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>At this point, the <a href=#stack-of-open-elements>stack of open elements</a> has on it
- the elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>At this point, the <a href=#stack-of-open-elements>stack of open elements</a> has on it
+ the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>,
<code><a href=#the-table-element>table</a></code>, and <code><a href=#the-b-element>b</a></code> (in that order, despite the
resulting DOM tree); the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> just has the <code><a href=#the-b-element>b</a></code> element in it; and the
@@ -84074,8 +84068,8 @@
row</a>" insertion modes, after which the DOM looks as
follows:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
- elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
+ elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
<code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tr-element>tr</a></code>; the <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> still has the <code><a href=#the-b-element>b</a></code> element in
it; and the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intr title="insertion
@@ -84086,13 +84080,13 @@
of active formatting elements</a> (it also switches to the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion
mode</a>).</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul><p>The marker means that when the "aaa" character tokens are seen,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul><p>The marker means that when the "aaa" character tokens are seen,
no <code><a href=#the-b-element>b</a></code> element is created to hold the resulting text
node:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The end tags are handled in a straight-forward manner; after
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The end tags are handled in a straight-forward manner; after
handling them, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the
- elements <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
and <code><a href=#the-tbody-element>tbody</a></code>; the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> still has the <code><a href=#the-b-element>b</a></code> element in it (the
marker having been removed by the "td" end tag token); and the
@@ -84117,8 +84111,8 @@
parent">foster parented</a>, and then the "bbb" text node is
appended to it:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements
- <code><a href=#the-html-element-0>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements
+ <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element-0>body</a></code>, <code><a href=#the-table-element>table</a></code>,
<code><a href=#the-tbody-element>tbody</a></code>, and the new <code><a href=#the-b-element>b</a></code> (again, note that
this doesn't match the resulting tree!); the <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> has the new <code><a href=#the-b-element>b</a></code> element in it;
@@ -84138,7 +84132,7 @@
result in yet another <code><a href=#the-b-element>b</a></code> element being created, this
time after the table:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>11.2.8.4 </span>Scripts that modify the page as it is bein
g parsed</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>11.2.8.4 </span>Scripts that modify the page as it is being pa
rsed</h5>
<p><i>This section is non-normative.</i></p>
@@ -84163,16 +84157,16 @@
<p>Up to the first "script" end tag, before the script is parsed,
the result is relatively straightforward:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-div-element>div</a></code> <span class=t2 title=""><code class="attribute name">id</code>="<code class="attribute value"><a href=#the-a-element>a</a></code>"</span><ul><li class=t3><code>#text</code>: <span title="">
- </span><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></ul></ul></ul></ul></ul><p>After the script is parsed, though, the <code><a href=#the-div-element>div</a></code> element
- and its child <code><a href=#script>script</a></code> element are gone:</p>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-div-element>div</a></code> <span class=t2 title=""><code class="attribute name">id</code>="<code class="attribute value"><a href=#the-a-element>a</a></code>"</span><ul><li class=t3><code>#text</code>: <span title="">
+ </span><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></ul></ul></ul></ul></ul><p>After the script is parsed, though, the <code><a href=#the-div-element>div</a></code> element
+ and its child <code><a href=#the-script-element>script</a></code> element are gone:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code></ul></ul><p>They are, at this point, in the <code><a href=#document>Document</a></code> of the
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code></ul></ul><p>They are, at this point, in the <code><a href=#document>Document</a></code> of the
aforementioned outer <a href=#browsing-context>browsing context</a>. However, the
<a href=#stack-of-open-elements>stack of open elements</a> <em>still contains the
<code><a href=#the-div-element>div</a></code> element</em>.</p>
- <p>Thus, when the second <code><a href=#script>script</a></code> element is parsed, it
+ <p>Thus, when the second <code><a href=#the-script-element>script</a></code> element is parsed, it
is inserted <em>into the outer <code><a href=#document>Document</a></code>
object</em>.</p>
@@ -84190,9 +84184,9 @@
<p>Once the <code><a href=#the-div-element>div</a></code> element's end tag is parsed, the
<code><a href=#the-div-element>div</a></code> element is popped off the stack, and so the next
- <code><a href=#script>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>
+ <code><a href=#the-script-element>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#script>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "<A HREF="http://example.com/inner">http://example.com/inner</A>".</p>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This second alert will say "<A HREF="http://example.com/inner">http://example.com/inner</A>".</p>
<h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>11.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>
@@ -84200,7 +84194,7 @@
<p><i>This section is non-normative.</i></p>
<p>Elaborating on the example in the previous section, consider a
- case where a <code><a href=#script>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
+ case where a <code><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed, but while
the external script is being downloaded, the element is moved to
another document.</p>
@@ -84228,7 +84222,7 @@
<p>The resulting DOM tree is as follows:</p>
- <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element-0>html</a></code><li class=t1><code><a href=#the-html-element-0>html</a></code><ul><li class=t1><code><a href=#the-head-element-0>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 t
itle=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span tit
le="">X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code
><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
+ <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element>html</a></code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element-0>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title="
"><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">
X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a hr
ef=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no
explicit <code><a href=#the-b-element>b</a></code> elements, but in the resulting DOM, up to
three of each kind of formatting element (in this case three
<code><a href=#the-b-element>b</a></code> elements with the class attribute, and two unadorned
@@ -84351,9 +84345,9 @@
<p>If <var title="">current node</var> is an
<code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>,
<code><a href=#bgsound>bgsound</a></code>, <code><a href=#the-br-element>br</a></code>, <code><a href=#the-col-element>col</a></code>,
- <code><a href=#the-command>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#frame>frame</a></code>,
+ <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#frame>frame</a></code>,
<code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>,
- <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#meta>meta</a></code>,
+ <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>,
<code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code> or
<code><a href=#the-wbr-element>wbr</a></code> element, then continue on to the next child
node at this point.</p> <!-- VOIDLIST superset -->
@@ -84381,7 +84375,7 @@
<dd>
<p>If the parent of <var title="">current node</var> is a
- <code><a href=#the-style-element>style</a></code>, <code><a href=#script>script</a></code>, <code><a href=#xmp>xmp</a></code>,
+ <code><a href=#the-style-element>style</a></code>, <code><a href=#the-script-element>script</a></code>, <code><a href=#xmp>xmp</a></code>,
<code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#noembed>noembed</a></code>,
<code><a href=#noframes>noframes</a></code>, or <code><a href=#plaintext>plaintext</a></code> element, or
if the parent of <var title="">current node</var> is
@@ -84469,7 +84463,7 @@
literal string "<code title="">--></code>", then when the result
of serializing the element is parsed, the comment will be truncated
at that point and the rest of the comment will be interpreted as
- markup. More examples would be making a <code><a href=#script>script</a></code> element
+ markup. More examples would be making a <code><a href=#the-script-element>script</a></code> element
contain a text node with the text string
"<code></script></code>", or having a <code><a href=#the-p-element>p</a></code> element
that contains a <code><a href=#the-ul-element>ul</a></code> element (as the <code><a href=#the-ul-element>ul</a></code>
@@ -84485,7 +84479,7 @@
"<code></style><script>attack</script></code>" as a font
name, <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> will return
markup that, if parsed in a different context, would contain a
- <code><a href=#script>script</a></code> node, even though no <code><a href=#script>script</a></code> node
+ <code><a href=#the-script-element>script</a></code> node, even though no <code><a href=#the-script-element>script</a></code> node
existed in the original DOM.</p>
</div>
@@ -84561,7 +84555,7 @@
<p>Set the state of the <a href=#html-parser>HTML parser</a>'s
<a href=#tokenization>tokenization</a> stage as follows:</p>
- <dl class=switch><dt>If it is a <code><a href=#the-title-element-0>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
+ <dl class=switch><dt>If it is a <code><a href=#the-title-element>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
element</dt>
<dd>Switch the tokenizer to the <a href=#rcdata-state>RCDATA state</a>.</dd>
@@ -84574,7 +84568,7 @@
<dd>Switch the tokenizer to the <a href=#rawtext-state>RAWTEXT state</a>.</dd>
- <dt>If it is a <code><a href=#script>script</a></code> element</dt>
+ <dt>If it is a <code><a href=#the-script-element>script</a></code> element</dt>
<dd>Switch the tokenizer to the <a href=#script-data-state>script data state</a>.</dd>
@@ -84609,7 +84603,7 @@
<li>
- <p>Let <var title="">root</var> be a new <code><a href=#the-html-element-0>html</a></code> element
+ <p>Let <var title="">root</var> be a new <code><a href=#the-html-element>html</a></code> element
with no attributes.</p>
</li>
@@ -84798,14 +84792,14 @@
handling external subsets. <a href=#refsXML>[XML]</a></p>
<p id=scriptTagXML>When an <a href=#xml-parser>XML parser</a> creates a
- <code><a href=#script>script</a></code> element, it must be marked as being
+ <code><a href=#the-script-element>script</a></code> element, it must be marked as being
<a href=#parser-inserted>"parser-inserted"</a> and its <a href=#force-async>"force-async"</a>
flag must be unset. If the parser was originally created for the
<a href=#xml-fragment-parsing-algorithm>XML fragment parsing algorithm</a>, then the element must
be marked as <a href=#already-started>"already started"</a> also. When the element's
end tag is parsed, the user agent must <a href=#provide-a-stable-state>provide a stable
state</a>, and then <a href=#prepare-a-script title="prepare a script">prepare</a>
- the <code><a href=#script>script</a></code> element. If this causes there to be a
+ the <code><a href=#the-script-element>script</a></code> element. If this causes there to be a
<a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the user agent
must run the following steps:</p>
@@ -86076,7 +86070,7 @@
<h4 id=embedded-content-2><span class=secno>13.3.1 </span>Embedded content</h4>
<p>The <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, and
- <code><a href=#video>video</a></code> elements are expected to be treated as replaced
+ <code><a href=#the-video-element>video</a></code> elements are expected to be treated as replaced
elements.</p>
<p>A <code><a href=#the-canvas-element>canvas</a></code> element that <a href=#represents>represents</a>
@@ -86095,43 +86089,43 @@
element. Other <code><a href=#the-applet-element>applet</a></code> elements are expected to be
treated as ordinary elements in the rendering model.</p>
- <p>The <code><a href=#audio>audio</a></code> element, when it is <a href=#expose-a-user-interface-to-the-user title="expose a
+ <p>The <code><a href=#the-audio-element>audio</a></code> element, when it is <a href=#expose-a-user-interface-to-the-user title="expose a
user interface to the user">exposing a user interface</a>, is
expected to be treated as a replaced element about one line high, as
wide as is necessary to expose the user agent's user interface
- features. When an <code><a href=#audio>audio</a></code> element is not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user
+ features. When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user
interface</a>, the user agent is expected to hide it,
irrespective of CSS rules.</p>
- <p>Whether a <code><a href=#video>video</a></code> element is <a href=#expose-a-user-interface-to-the-user title="expose a
+ <p>Whether a <code><a href=#the-video-element>video</a></code> element is <a href=#expose-a-user-interface-to-the-user title="expose a
user interface to the user">exposing a user interface</a> is not
expected to affect the size of the rendering; controls are expected
to be overlaid with the page content without causing any layout
changes, and are expected to disappear when the user does not need
them.</p>
- <p>When a <code><a href=#video>video</a></code> element represents a poster frame or
+ <p>When a <code><a href=#the-video-element>video</a></code> element represents a poster frame or
frame of video, the poster frame or frame of video is expected to be
rendered at the largest size that maintains the aspect ratio of that
poster frame or frame of video without being taller or wider than
- the <code><a href=#video>video</a></code> element itself, and is expected to be
- centered in the <code><a href=#video>video</a></code> element.</p>
+ the <code><a href=#the-video-element>video</a></code> element itself, and is expected to be
+ centered in the <code><a href=#the-video-element>video</a></code> element.</p>
<p>Any subtitles or captions are expected to be overlayed directly
- on top of their <code><a href=#video>video</a></code> element, as defined by the
+ on top of their <code><a href=#the-video-element>video</a></code> element, as defined by the
relevant rendering rules; for <a href=#webvtt>WebVTT</a>, those are the
<a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a> defined below.</p>
<p>When the user agent starts <a href=#expose-a-user-interface-to-the-user title="expose a user interface
to the user">exposing a user interface</a> for a
- <code><a href=#video>video</a></code> element, the user agent should run the <a href=#rules-for-updating-the-text-track-rendering>rules
- for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in the <code><a href=#video>video</a></code>
+ <code><a href=#the-video-element>video</a></code> element, the user agent should run the <a href=#rules-for-updating-the-text-track-rendering>rules
+ for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in the <code><a href=#the-video-element>video</a></code>
element's <a href=#list-of-text-tracks>list of text tracks</a> that are <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text
track showing by default">showing by default</a> (e.g., for <a href=#text-track title="text track">text tracks</a> based on
<a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of
WebVTT text tracks</a>).</p>
- <p class=note>Resizing <code><a href=#video>video</a></code> and <code><a href=#the-canvas-element>canvas</a></code>
+ <p class=note>Resizing <code><a href=#the-video-element>video</a></code> and <code><a href=#the-canvas-element>canvas</a></code>
elements does not interrupt video playback or clear the canvas.</p>
<hr><p>The following CSS rules are expected to apply:</p>
@@ -86158,7 +86152,7 @@
<p>The <dfn id=rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text
tracks</dfn> render the <a href=#text-track title="text track">text
tracks</a> of a <a href=#media-element>media element</a> (specifically, a
- <code><a href=#video>video</a></code> element), or of another playback mechanism, by
+ <code><a href=#the-video-element>video</a></code> element), or of another playback mechanism, by
applying the steps below. All the <a href=#text-track title="text track">text
tracks</a> that use these rules for a given <a href=#media-element>media
element</a>, or other playback mechanism, are rendered together,
@@ -86171,7 +86165,7 @@
<p>The rules are as follows:</p>
- <ol><li><p>If the <a href=#media-element>media element</a> is an <code><a href=#audio>audio</a></code>
+ <ol><li><p>If the <a href=#media-element>media element</a> is an <code><a href=#the-audio-element>audio</a></code>
element, or is another playback mechanism with no rendering area,
abort these steps. There is nothing to render.</li>
@@ -86784,7 +86778,7 @@
<i>matched element</i>.</p>
<p class=note>If the <i>matched element</i> is not a
- <code><a href=#video>video</a></code> element, the pseudo-elements defined below won't
+ <code><a href=#the-video-element>video</a></code> element, the pseudo-elements defined below won't
have any effect according to this specification.</p>
<p>A CSS user agent that implements the <a href=#text-track title="text
@@ -87134,7 +87128,7 @@
<p id=dimRendering>The <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>
and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes on
<code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>,
- <code><a href=#the-img-element>img</a></code>, <code><a href=#the-object-element>object</a></code> or <code><a href=#video>video</a></code>
+ <code><a href=#the-img-element>img</a></code>, <code><a href=#the-object-element>object</a></code> or <code><a href=#the-video-element>video</a></code>
elements, and <code><a href=#the-input-element>input</a></code> elements with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension
properties</a> 'width' and 'height' on the element
respectively.</p>
@@ -87174,7 +87168,7 @@
<h4 id=toolbars-0><span class=secno>13.3.6 </span>Toolbars</h4>
- <p>When a <code><a href=#menus>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is
+ <p>When a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is
expected to be treated as a replaced element with a height about two
lines high and a width derived from the contents of the element.</p>
@@ -87868,7 +87862,7 @@
<h3 id=frames-and-framesets><span class=secno>13.5 </span>Frames and framesets</h3>
- <p>When an <code><a href=#the-html-element-0>html</a></code> element's second child element is a
+ <p>When an <code><a href=#the-html-element>html</a></code> element's second child element is a
<code><a href=#frameset>frameset</a></code> element, the user agent is expected to render
the <code><a href=#frameset>frameset</a></code> element as described below across the
surface of the viewport, instead of applying the usual CSS rendering
@@ -88366,7 +88360,7 @@
instead.</p>
<p>Authors should not specify a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a
- <code><a href=#script>script</a></code> element. If the attribute is present, its value
+ <code><a href=#the-script-element>script</a></code> element. If the attribute is present, its value
must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string
"<code title="">JavaScript</code>" and either the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must be omitted or
its value must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for
@@ -88416,7 +88410,7 @@
<code><a href=#the-img-element>img</a></code> element if its value is the string "<code title="">0</code>".</li>
<li><p>The presence of a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a
- <code><a href=#script>script</a></code> element if its value is an <a href=#ascii-case-insensitive>ASCII
+ <code><a href=#the-script-element>script</a></code> element if its value is an <a href=#ascii-case-insensitive>ASCII
case-insensitive</a> match for the string "<code title="">JavaScript</code>" and if there is no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute or there is and its
value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the
string "<code title="">text/javascript</code>".</li>
@@ -88448,7 +88442,7 @@
<dd><p>Use <code><a href=#the-abbr-element>abbr</a></code> instead.</dd>
<dt><dfn id=bgsound><code>bgsound</code></dfn></dt>
- <dd><p>Use <code><a href=#audio>audio</a></code> instead.</dd>
+ <dd><p>Use <code><a href=#the-audio-element>audio</a></code> instead.</dd>
<dt><dfn id=dir><code>dir</code></dfn></dt>
<dd><p>Use <code><a href=#the-ul-element>ul</a></code> instead.</dd>
@@ -88549,13 +88543,13 @@
attribute is sufficient; the <code title=attr-area-nohref><a href=#attr-area-nohref>nohref</a></code> attribute is
unnecessary. Omit it altogether.</dd>
- <dt><dfn id=attr-head-profile title=attr-head-profile><code>profile</code></dfn> on <code><a href=#the-head-element-0>head</a></code> elements</dt>
- <dd><p>When used for declaring which <code><a href=#meta>meta</a></code> terms are
+ <dt><dfn id=attr-head-profile title=attr-head-profile><code>profile</code></dfn> on <code><a href=#the-head-element>head</a></code> elements</dt>
+ <dd><p>When used for declaring which <code><a href=#the-meta-element>meta</a></code> terms are
used in the document, unnecessary; omit it altogether, and <a href=#concept-meta-extensions title=concept-meta-extensions>register the names</a>.</dd>
<dd><p>When used for triggering specific user agent behaviors: use
a <code><a href=#the-link-element>link</a></code> element instead.</dd>
- <dt><dfn id=attr-html-version title=attr-html-version><code>version</code></dfn> on <code><a href=#the-html-element-0>html</a></code> elements</dt>
+ <dt><dfn id=attr-html-version title=attr-html-version><code>version</code></dfn> on <code><a href=#the-html-element>html</a></code> elements</dt>
<dd><p>Unnecessary. Omit it altogether.</dd>
<dt><dfn id=attr-input-usemap title=attr-input-usemap><code>usemap</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt>
@@ -88575,7 +88569,7 @@
<dt><dfn id=attr-link-target title=attr-link-target><code>target</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt>
<dd><p>Unnecessary. Omit it altogether.</dd>
- <dt><dfn id=attr-meta-scheme title=attr-meta-scheme><code>scheme</code></dfn> on <code><a href=#meta>meta</a></code> elements</dt>
+ <dt><dfn id=attr-meta-scheme title=attr-meta-scheme><code>scheme</code></dfn> on <code><a href=#the-meta-element>meta</a></code> elements</dt>
<dd><p>Use only one scheme per field, or make the scheme declaration part of the value.</dd>
<dt><dfn id=attr-object-archive title=attr-object-archive><code>archive</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
@@ -88597,12 +88591,12 @@
<dd><p>Use the <code title=attr-param-name><a href=#attr-param-name>name</a></code> and <code title=attr-param-value><a href=#attr-param-value>value</a></code> attributes without declaring
value types.</dd>
- <dt><dfn id=attr-script-language title=attr-script-language><code>language</code></dfn> on <code><a href=#script>script</a></code> elements (except as noted in the previous section)</dt>
+ <dt><dfn id=attr-script-language title=attr-script-language><code>language</code></dfn> on <code><a href=#the-script-element>script</a></code> elements (except as noted in the previous section)</dt>
<dd><p>Use the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute
instead.</dd>
- <dt><dfn id=attr-script-event title=attr-script-event><code>event</code></dfn> on <code><a href=#script>script</a></code> elements</dt>
- <dt><dfn id=attr-script-for title=attr-script-for><code>for</code></dfn> on <code><a href=#script>script</a></code> elements</dt>
+ <dt><dfn id=attr-script-event title=attr-script-event><code>event</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt>
+ <dt><dfn id=attr-script-for title=attr-script-for><code>for</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt>
<dd><p>Use DOM Events mechanisms to register event listeners. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></dd>
<dt><dfn id=attr-table-datapagesize title=attr-table-datapagesize><code>datapagesize</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt>
@@ -88670,7 +88664,7 @@
<dt><dfn id=attr-img-vspace title=attr-img-vspace><code>vspace</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt>
<dt><dfn id=attr-legend-align title=attr-legend-align><code>align</code></dfn> on <code><a href=#the-legend-element>legend</a></code> elements</dt>
<dt><dfn id=attr-li-type title=attr-li-type><code>type</code></dfn> on <code><a href=#the-li-element>li</a></code> elements</dt>
- <dt><dfn id=attr-menu-compact title=attr-menu-compact><code>compact</code></dfn> on <code><a href=#menus>menu</a></code> elements</dt>
+ <dt><dfn id=attr-menu-compact title=attr-menu-compact><code>compact</code></dfn> on <code><a href=#the-menu-element>menu</a></code> elements</dt>
<dt><dfn id=attr-object-align title=attr-object-align><code>align</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
<dt><dfn id=attr-object-border title=attr-object-border><code>border</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
<dt><dfn id=attr-object-hspace title=attr-object-hspace><code>hspace</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt>
@@ -89352,7 +89346,7 @@
<a href=#reflect>reflect</a> the content attribute of the same name.</p>
<hr><p class=note>The <dfn id=dom-head-profile title=dom-head-profile><code>profile</code></dfn> IDL attribute on
- <code><a href=#the-head-element-0>head</a></code> elements (with the <code><a href=#htmlheadelement>HTMLHeadElement</a></code>
+ <code><a href=#the-head-element>head</a></code> elements (with the <code><a href=#htmlheadelement>HTMLHeadElement</a></code>
interface) is intentionally omitted. Unless so required by <a href=#other-applicable-specifications title="other applicable specifications">another applicable
specification</a>, implementations would therefore not support
this attribute. (It is mentioned here as it was defined in a
@@ -89382,7 +89376,7 @@
};</pre>
<p>The <dfn id=dom-html-version title=dom-html-version><code>version</code></dfn> IDL
- attribute of the <code><a href=#the-html-element-0>html</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-html-element>html</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -89498,7 +89492,7 @@
};</pre>
<p>The <dfn id=dom-menu-compact title=dom-menu-compact><code>compact</code></dfn> IDL
- attribute of the <code><a href=#menus>menu</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-menu-element>menu</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -89507,8 +89501,8 @@
};</pre>
<p>User agents may treat the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> content attribute on the
- <code><a href=#meta>meta</a></code> element as an extension of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> content attribute when processing
- a <code><a href=#meta>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is one that
+ <code><a href=#the-meta-element>meta</a></code> element as an extension of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> content attribute when processing
+ a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is one that
the user agent recognizes as supporting the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute.</p>
<p>User agents are encouraged to ignore the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute and instead process
@@ -89517,12 +89511,12 @@
<div class=example>
- <p>For example, if the user agent acts on <code><a href=#meta>meta</a></code>
+ <p>For example, if the user agent acts on <code><a href=#the-meta-element>meta</a></code>
elements with <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attributes
having the value "eGMS.subject.keyword", and knows that the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute is used with this
metadata name, then it could take the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute into account,
acting as if it was an extension of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute. Thus the following
- two <code><a href=#meta>meta</a></code> elements could be treated as two elements
+ two <code><a href=#the-meta-element>meta</a></code> elements could be treated as two elements
giving values for two different metadata names, one consisting of a
combination of "eGMS.subject.keyword" and "LGCL", and the other
consisting of a combination of "eGMS.subject.keyword" and
@@ -89541,7 +89535,7 @@
</div>
<p>The <dfn id=dom-meta-scheme title=dom-meta-scheme><code>scheme</code></dfn> IDL
- attribute of the <code><a href=#meta>meta</a></code> element must <a href=#reflect>reflect</a>
+ attribute of the <code><a href=#the-meta-element>meta</a></code> element must <a href=#reflect>reflect</a>
the content attribute of the same name.</p>
<hr><pre class=idl>[Supplemental]
@@ -89626,7 +89620,7 @@
<p>The <dfn id=dom-script-event title=dom-script-event><code>event</code></dfn> and
<dfn id=dom-script-htmlfor title=dom-script-htmlFor><code>htmlFor</code></dfn> IDL
- attributes of the <code><a href=#script>script</a></code> element must return the empty
+ attributes of the <code><a href=#the-script-element>script</a></code> element must return the empty
string on getting, and do nothing on setting.</p>
<hr><pre class=idl>[Supplemental]
@@ -90648,7 +90642,7 @@
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#audio>audio</a></code></th>
+ <tr><th><code><a href=#the-audio-element>audio</a></code></th>
<td>Audio player</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a>;
@@ -90676,7 +90670,7 @@
<tr><th><code><a href=#the-base-element>base</a></code></th>
<td>Base URL and default target <a href=#browsing-context>browsing context</a> for <a href=#attr-hyperlink-target title=attr-hyperlink-target>hyperlinks</a> and <a href=#attr-fs-target title=attr-fs-target>forms</a></td>
<td><a href=#metadata-content title="Metadata content">metadata</a></td>
- <td><code><a href=#the-head-element-0>head</a></code></td>
+ <td><code><a href=#the-head-element>head</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-base-href><a href=#attr-base-href>href</a></code>;
@@ -90711,7 +90705,7 @@
<tr><th><code><a href=#the-body-element-0>body</a></code></th>
<td>Document body</td>
<td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
- <td><code><a href=#the-html-element-0>html</a></code></td>
+ <td><code><a href=#the-html-element>html</a></code></td>
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code>;
@@ -90817,12 +90811,12 @@
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></td>
<td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td>
- <tr><th><code><a href=#the-command>command</a></code></th>
+ <tr><th><code><a href=#the-command-element>command</a></code></th>
<td>Menu command</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
@@ -90987,10 +90981,10 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlheadingelement>HTMLHeadingElement</a></code></td>
- <tr><th><code><a href=#the-head-element-0>head</a></code></th>
+ <tr><th><code><a href=#the-head-element>head</a></code></th>
<td>Container for document metadata</td>
<td>none</td>
- <td><code><a href=#the-html-element-0>html</a></code></td>
+ <td><code><a href=#the-html-element>html</a></code></td>
<td><a href=#metadata-content title="Metadata content">metadata content</a>*</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlheadelement>HTMLHeadElement</a></code></td>
@@ -91018,11 +91012,11 @@
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlhrelement>HTMLHRElement</a></code></td>
- <tr><th><code><a href=#the-html-element-0>html</a></code></th>
+ <tr><th><code><a href=#the-html-element>html</a></code></th>
<td>Root element</td>
<td>none</td>
<td>none*</td>
- <td><code><a href=#the-head-element-0>head</a></code>*;
+ <td><code><a href=#the-head-element>head</a></code>*;
<code><a href=#the-body-element-0>body</a></code>*</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></td>
@@ -91172,7 +91166,7 @@
<tr><th><code><a href=#the-li-element>li</a></code></th>
<td>List item</td>
<td>none</td>
- <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#menus>menu</a></code></td>
+ <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-menu-element>menu</a></code></td>
<td><a href=#flow-content title="Flow content">flow</a></td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-li-value><a href=#attr-li-value>value</a></code>*</td>
@@ -91182,7 +91176,7 @@
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
<td>empty</td>
@@ -91212,7 +91206,7 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#menus>menu</a></code></th>
+ <tr><th><code><a href=#the-menu-element>menu</a></code></th>
<td>Menu of commands</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#interactive-content title="Interactive content">interactive</a>*</td>
@@ -91223,12 +91217,12 @@
<code title=attr-menu-type><a href=#attr-menu-type>type</a></code>;
<code title=attr-menu-label><a href=#attr-menu-label>label</a></code></td>
<td><code><a href=#htmlmenuelement>HTMLMenuElement</a></code></td>
- <tr><th><code><a href=#meta>meta</a></code></th>
+ <tr><th><code><a href=#the-meta-element>meta</a></code></th>
<td>Text metadata</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
<td>empty</td>
@@ -91269,7 +91263,7 @@
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>*;
+ <td><code><a href=#the-head-element>head</a></code>*;
<a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
<td>varies*</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
@@ -91428,12 +91422,12 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#script>script</a></code></th>
+ <tr><th><code><a href=#the-script-element>script</a></code></th>
<td>Embedded script</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td>script, data, or script documentation*</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
@@ -91482,10 +91476,10 @@
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
<tr><th><code><a href=#the-source-element>source</a></code></th>
- <td>Media source for <code><a href=#video>video</a></code> or <code><a href=#audio>audio</a></code></td>
+ <td>Media source for <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code></td>
<td>none</td>
- <td><code><a href=#video>video</a></code>;
- <code><a href=#audio>audio</a></code></td>
+ <td><code><a href=#the-video-element>video</a></code>;
+ <code><a href=#the-audio-element>audio</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-source-src><a href=#attr-source-src>src</a></code>;
@@ -91512,7 +91506,7 @@
<td>Embedded styling information</td>
<td><a href=#metadata-content title="Metadata content">metadata</a>;
<a href=#flow-content title="Flow content">flow</a></td>
- <td><code><a href=#the-head-element-0>head</a></code>;
+ <td><code><a href=#the-head-element>head</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>*;
<a href=#flow-content title="flow content">flow</a>*</td>
<td>varies*</td>
@@ -91634,10 +91628,10 @@
<code title=attr-time-datetime><a href=#attr-time-datetime>datetime</a></code>;
<code title=attr-time-pubdate><a href=#attr-time-pubdate>pubdate</a></code></td>
<td><code><a href=#htmltimeelement>HTMLTimeElement</a></code></td>
- <tr><th><code><a href=#the-title-element-0>title</a></code></th>
+ <tr><th><code><a href=#the-title-element>title</a></code></th>
<td>Document title</td>
<td><a href=#metadata-content title="Metadata content">metadata</a></td>
- <td><code><a href=#the-head-element-0>head</a></code></td>
+ <td><code><a href=#the-head-element>head</a></code></td>
<td><a href=#text-content title="text content">text</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmltitleelement>HTMLTitleElement</a></code></td>
@@ -91655,8 +91649,8 @@
<tr><th><code><a href=#the-track-element>track</a></code></th>
<td>Timed text track</td>
<td>none</td>
- <td><code><a href=#audio>audio</a></code>;
- <code><a href=#video>video</a></code></td>
+ <td><code><a href=#the-audio-element>audio</a></code>;
+ <code><a href=#the-video-element>video</a></code></td>
<td>empty</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-track-default><a href=#attr-track-default>default</a></code>;
@@ -91688,7 +91682,7 @@
<td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
- <tr><th><code><a href=#video>video</a></code></th>
+ <tr><th><code><a href=#the-video-element>video</a></code></th>
<td>Video player</td>
<td><a href=#flow-content title="Flow content">flow</a>;
<a href=#phrasing-content title="Phrasing content">phrasing</a>;
@@ -91734,13 +91728,13 @@
<tbody><tr><td> <a href=#metadata-content>Metadata content</a>
<td>
<code><a href=#the-base-element>base</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-link-element>link</a></code>;
- <code><a href=#meta>meta</a></code>;
+ <code><a href=#the-meta-element>meta</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-style-element>style</a></code>;
- <code><a href=#the-title-element-0>title</a></code>
+ <code><a href=#the-title-element>title</a></code>
<td>
—
@@ -91751,7 +91745,7 @@
<code><a href=#the-address-element>address</a></code>;
<code><a href=#the-article-element>article</a></code>;
<code><a href=#the-aside-element>aside</a></code>;
- <code><a href=#audio>audio</a></code>;
+ <code><a href=#the-audio-element>audio</a></code>;
<code><a href=#the-b-element>b</a></code>;
<code><a href=#the-bdi-element>bdi</a></code>;
<code><a href=#the-bdo-element>bdo</a></code>;
@@ -91761,7 +91755,7 @@
<code><a href=#the-canvas-element>canvas</a></code>;
<code><a href=#the-cite-element>cite</a></code>;
<code><a href=#the-code-element>code</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-datalist-element>datalist</a></code>;
<code><a href=#the-del-element>del</a></code>;
<code><a href=#the-details-element>details</a></code>;
@@ -91794,7 +91788,7 @@
<code><a href=#the-map-element>map</a></code>;
<code><a href=#the-mark-element>mark</a></code>;
<code><a href=#math>math</a></code>;
- <code><a href=#menus>menu</a></code>;
+ <code><a href=#the-menu-element>menu</a></code>;
<code><a href=#the-meter-element>meter</a></code>;
<code><a href=#the-nav-element>nav</a></code>;
<code><a href=#the-noscript-element>noscript</a></code>;
@@ -91808,7 +91802,7 @@
<code><a href=#the-ruby-element>ruby</a></code>;
<code><a href=#the-s-element>s</a></code>;
<code><a href=#the-samp-element>samp</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-section-element>section</a></code>;
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-small-element>small</a></code>;
@@ -91823,14 +91817,14 @@
<code><a href=#the-u-element>u</a></code>;
<code><a href=#the-ul-element>ul</a></code>;
<code><a href=#the-var-element>var</a></code>;
- <code><a href=#video>video</a></code>;
+ <code><a href=#the-video-element>video</a></code>;
<code><a href=#the-wbr-element>wbr</a></code>;
<a href=#text-content title="text content">Text</a>
<td>
<code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element);
<!--MD-->
<code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
- <code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
+ <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present);
<!--MD-->
<code><a href=#the-style-element>style</a></code> (if the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present)
@@ -91858,7 +91852,7 @@
<tr><td> <a href=#phrasing-content>Phrasing content</a>
<td>
<code><a href=#the-abbr-element>abbr</a></code>;
- <code><a href=#audio>audio</a></code>;
+ <code><a href=#the-audio-element>audio</a></code>;
<code><a href=#the-b-element>b</a></code>;
<code><a href=#the-bdi-element>bdi</a></code>;
<code><a href=#the-bdo-element>bdo</a></code>;
@@ -91867,7 +91861,7 @@
<code><a href=#the-canvas-element>canvas</a></code>;
<code><a href=#the-cite-element>cite</a></code>;
<code><a href=#the-code-element>code</a></code>;
- <code><a href=#the-command>command</a></code>;
+ <code><a href=#the-command-element>command</a></code>;
<code><a href=#the-datalist-element>datalist</a></code>;
<code><a href=#the-dfn-element>dfn</a></code>;
<code><a href=#the-em-element>em</a></code>;
@@ -91890,7 +91884,7 @@
<code><a href=#the-ruby-element>ruby</a></code>;
<code><a href=#the-s-element>s</a></code>;
<code><a href=#the-samp-element>samp</a></code>;
- <code><a href=#script>script</a></code>;
+ <code><a href=#the-script-element>script</a></code>;
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-small-element>small</a></code>;
<code><a href=#the-span-element>span</a></code>;
@@ -91902,7 +91896,7 @@
<code><a href=#the-time-element>time</a></code>;
<code><a href=#the-u-element>u</a></code>;
<code><a href=#the-var-element>var</a></code>;
- <code><a href=#video>video</a></code>;
+ <code><a href=#the-video-element>video</a></code>;
<code><a href=#the-wbr-element>wbr</a></code>;
<a href=#text-content title="text content">Text</a>
<td>
@@ -91915,13 +91909,13 @@
<!--MD-->
<code><a href=#the-map-element>map</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)<!--
--><!--MD--><!--
- -->; <code><a href=#meta>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)<!--
+ -->; <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)<!--
--><!--MD--><!--
-->
<tr><td> <a href=#embedded-content>Embedded content</a>
<td>
- <code><a href=#audio>audio</a></code>
+ <code><a href=#the-audio-element>audio</a></code>
<code><a href=#the-canvas-element>canvas</a></code>
<code><a href=#the-embed-element>embed</a></code>
<code><a href=#the-iframe-element>iframe</a></code>
@@ -91929,7 +91923,7 @@
<code><a href=#math>math</a></code>
<code><a href=#the-object-element>object</a></code>
<code><a href=#svg>svg</a></code>
- <code><a href=#video>video</a></code>
+ <code><a href=#the-video-element>video</a></code>
<td>
—
@@ -91945,12 +91939,12 @@
<code><a href=#the-select-element>select</a></code>;
<code><a href=#the-textarea-element>textarea</a></code>;
<td>
- <code><a href=#audio>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present);
+ <code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present);
<code><a href=#the-img-element>img</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present);
<code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state);
- <code><a href=#menus>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state);
+ <code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state);
<code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section -->;
- <code><a href=#video>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)
+ <code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)
<tr><td> <a href=#sectioning-root title="sectioning root">Sectioning roots</a>
<td>
@@ -93166,7 +93160,7 @@
<tr><td> <code><a href=#the-aside-element>aside</a></code>
<td> <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#audio>audio</a></code>
+ <tr><td> <code><a href=#the-audio-element>audio</a></code>
<td> <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-b-element>b</a></code>
@@ -93211,7 +93205,7 @@
<tr><td> <code><a href=#the-colgroup-element>colgroup</a></code>
<td> <code><a href=#htmltablecolelement>HTMLTableColElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-command>command</a></code>
+ <tr><td> <code><a href=#the-command-element>command</a></code>
<td> <code><a href=#htmlcommandelement>HTMLCommandElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-datalist-element>datalist</a></code>
@@ -93256,7 +93250,7 @@
<tr><td> <code><a href=#the-form-element>form</a></code>
<td> <code><a href=#htmlformelement>HTMLFormElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-head-element-0>head</a></code>
+ <tr><td> <code><a href=#the-head-element>head</a></code>
<td> <code><a href=#htmlheadelement>HTMLHeadElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>
@@ -93286,7 +93280,7 @@
<tr><td> <code><a href=#the-hr-element>hr</a></code>
<td> <code><a href=#htmlhrelement>HTMLHRElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-html-element-0>html</a></code>
+ <tr><td> <code><a href=#the-html-element>html</a></code>
<td> <code><a href=#htmlhtmlelement>HTMLHtmlElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-i-element>i</a></code>
@@ -93436,7 +93430,7 @@
<tr><td> <code><a href=#the-time-element>time</a></code>
<td> <code><a href=#htmltimeelement>HTMLTimeElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#the-title-element-0>title</a></code>
+ <tr><td> <code><a href=#the-title-element>title</a></code>
<td> <code><a href=#htmltitleelement>HTMLTitleElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-tr-element>tr</a></code>
@@ -93454,7 +93448,7 @@
<tr><td> <code><a href=#the-var-element>var</a></code>
<td> <code><a href=#htmlelement>HTMLElement</a></code>
- <tr><td> <code><a href=#video>video</a></code>
+ <tr><td> <code><a href=#the-video-element>video</a></code>
<td> <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
<tr><td> <code><a href=#the-wbr-element>wbr</a></code>
@@ -93568,7 +93562,7 @@
<tr><td> <code title=event-show>show</code>
<td> <code><a href=#event>Event</a></code>
- <td> Fired at a <code><a href=#menus>menu</a></code> element when it is shown as a context menu
+ <td> Fired at a <code><a href=#the-menu-element>menu</a></code> element when it is shown as a context menu
<tr><td> <code title=event-submit>submit</code>
<td> <code><a href=#event>Event</a></code>
Modified: source
===================================================================
--- source 2011-05-03 01:10:20 UTC (rev 6049)
+++ source 2011-05-03 19:18:56 UTC (rev 6050)
@@ -13864,7 +13864,7 @@
<h3>The root element</h3>
- <h4>The <dfn><code>html</code></dfn> element</h4>
+ <h4 id="the-html-element">The <dfn><code>html</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -13936,7 +13936,7 @@
<h3>Document metadata</h3>
- <h4>The <dfn><code>head</code></dfn> element</h4>
+ <h4 id="the-head-element">The <dfn><code>head</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -13996,7 +13996,7 @@
- <h4>The <dfn><code>title</code></dfn> element</h4>
+ <h4 id="the-title-element">The <dfn><code>title</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -14643,7 +14643,7 @@
- <h4 id="meta">The <dfn><code>meta</code></dfn> element</h4>
+ <h4 id="the-meta-element">The <dfn id="meta"><code>meta</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -16175,7 +16175,7 @@
</div>
- <h4 id="script">The <dfn><code>script</code></dfn> element</h4>
+ <h4 id="the-script-element">The <dfn id="script"><code>script</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -18299,10 +18299,12 @@
- <h4>The <dfn><code>h1</code></dfn>, <dfn><code>h2</code></dfn>,
- <dfn><code>h3</code></dfn>, <dfn><code>h4</code></dfn>,
- <dfn><code>h5</code></dfn>, and <dfn><code>h6</code></dfn>
- elements</h4>
+ <h4>The <dfn id="the-h1-element"><code>h1</code></dfn>, <dfn
+ id="the-h2-element"><code>h2</code></dfn>, <dfn
+ id="the-h3-element"><code>h3</code></dfn>, <dfn
+ id="the-h4-element"><code>h4</code></dfn>, <dfn
+ id="the-h5-element"><code>h5</code></dfn>, and <dfn
+ id="the-h6-element"><code>h6</code></dfn> elements</h4>
<dl class="element">
<dt>Categories</dt>
@@ -22105,7 +22107,7 @@
</div>
- <h4>The <dfn><code>sub</code></dfn> and <dfn><code>sup</code></dfn> elements</h4>
+ <h4>The <dfn id="the-sub-element"><code>sub</code></dfn> and <dfn id="the-sup-element"><code>sup</code></dfn> elements</h4>
<dl class="element">
<dt>Categories</dt>
@@ -27254,7 +27256,7 @@
</div>
- <h4 id="video">The <dfn><code>video</code></dfn> element</h4>
+ <h4 id="the-video-element">The <dfn id="video"><code>video</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -27627,7 +27629,7 @@
- <h4 id="audio">The <dfn><code>audio</code></dfn> element</h4>
+ <h4 id="the-audio-element">The <dfn id="audio"><code>audio</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -58128,7 +58130,7 @@
- <h4 id="the-command">The <dfn><code>command</code></dfn> element</h4>
+ <h4 id="the-command-element">The <dfn id="the-command"><code>command</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
@@ -58392,7 +58394,7 @@
- <h4 id="menus">The <dfn><code>menu</code></dfn> element</h4>
+ <h4 id="the-menu-element">The <dfn id="menus"><code>menu</code></dfn> element</h4>
<dl class="element">
<dt>Categories</dt>
</PRE>
<!--endarticle-->
<!--htdig_noindex-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="012916.html">[html5] r6049 - [e] (0) Try to warn implementors about XSLT. Fixing http://www.w3.org/Bugs/Publi [...]
</A></li>
<LI>Next message: <A HREF="012917.html">[html5] r6051 - [e] (0) add a note to clarify interaction with rfc 2388 Fixing http://www.w3.org [...]
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#12918">[ date ]</a>
<a href="thread.html#12918">[ thread ]</a>
<a href="subject.html#12918">[ subject ]</a>
<a href="author.html#12918">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">More information about the Commit-Watchers
mailing list</a><br>
<!--/htdig_noindex-->
</body></html>
| 103.031243 | 1,660 | 0.672638 |
20f2843669d92bffda5466d51b601f23c7135bcb | 681 | sql | SQL | data/seed.sql | brendanwelzien/bookApp | 95571630992d50bd7a176971e258620439fd006d | [
"MIT"
] | null | null | null | data/seed.sql | brendanwelzien/bookApp | 95571630992d50bd7a176971e258620439fd006d | [
"MIT"
] | null | null | null | data/seed.sql | brendanwelzien/bookApp | 95571630992d50bd7a176971e258620439fd006d | [
"MIT"
] | 1 | 2020-11-03T00:26:34.000Z | 2020-11-03T00:26:34.000Z | INSERT INTO book (title, author, description, image_url, isbn)
VALUES ('Arrows of the Night', 'Richard Bonin','Controversial efforts of US helping remove Saddem Hussein from power.', 'https://picsum.photos/200/300', '555555');
INSERT INTO book (title, author, description, image_url, isbn)
VALUES ('Arrows of the Night', 'Richard Bonin','Controversial efforts of US helping remove Saddem Hussein from power.', 'https://picsum.photos/200/300', '555555');
INSERT INTO book (title, author, description, image_url, isbn)
VALUES ('Arrows of the Night', 'Richard Bonin','Controversial efforts of US helping remove Saddem Hussein from power.', 'https://picsum.photos/200/300', '555555');
| 97.285714 | 163 | 0.753304 |
e90e9c088e7aa211913ae360841ed85fa82f0769 | 41,820 | cxx | C++ | extras/COMMIT_debugger/OPENGL_callbacks.cxx | ilariagabusi/COMMIT | a9e57eac8bca5ffb99b26b5fc9d255003d408410 | [
"BSD-3-Clause"
] | 36 | 2015-02-10T21:36:31.000Z | 2022-02-16T07:33:06.000Z | extras/COMMIT_debugger/OPENGL_callbacks.cxx | ilariagabusi/COMMIT | a9e57eac8bca5ffb99b26b5fc9d255003d408410 | [
"BSD-3-Clause"
] | 61 | 2015-05-27T15:20:33.000Z | 2022-03-05T13:51:26.000Z | extras/COMMIT_debugger/OPENGL_callbacks.cxx | ilariagabusi/COMMIT | a9e57eac8bca5ffb99b26b5fc9d255003d408410 | [
"BSD-3-Clause"
] | 31 | 2015-03-10T16:19:15.000Z | 2022-03-16T10:57:26.000Z | #define GL_GLEXT_PROTOTYPES 1
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glut.h>
#endif
#include "OPENGL_utils.h"
using namespace OPENGL_utils;
/* global variables */
GLfloat id[16], rot[16], rot1[16], rot2[16], rot3[16];
Vec3Df translation;
Vec3Di start;
GLint moving;
GLfloat zoom;
float ScreenX, ScreenY;
void drawString( const char *string )
{
static int y = glutGet( GLUT_WINDOW_HEIGHT ) - 50;
if ( string=="" )
y = glutGet( GLUT_WINDOW_HEIGHT ) - 50;
else
{
glRasterPos2i(10, y);
for (const char* c=string; *c != '\0'; c++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *c);
y -= 18;
}
}
void PrintConfig()
{
if ( !showConfig )
return;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode( GL_MODELVIEW ) ;
glPushMatrix() ;
glLoadIdentity() ;
int w = glutGet( GLUT_WINDOW_WIDTH );
int h = glutGet( GLUT_WINDOW_HEIGHT );
glOrtho( 0, w, 0, h, -1, 1 );
glDisable( GL_DEPTH_TEST );
char s[1024];
glColor3f(1, 1, 0);
drawString( "" ); // reset initial position
drawString( "MAP" );
sprintf( s, " - value(%d,%d,%d) = %.2f", VOXEL.x, VOXEL.y, VOXEL.z, MAP(VOXEL.x, VOXEL.y, VOXEL.z) );
drawString( s );
sprintf( s, " - range = [ %.1f ... %.1f ]", MAP_min_view, MAP_max_view );
drawString( s );
sprintf( s, " - opacity = %.1f", MAP_opacity );
drawString( s );
drawString( "SIGNAL" );
sprintf( s, " - shell = %d/%d (b=%.1f)", GLYPHS_shell+1, SCHEME_shells_b.size(), SCHEME_shells_b[GLYPHS_shell] );
drawString( s );
sprintf( s, " - use affine = %s", GLYPHS_use_affine?"true":"false" );
drawString( s );
sprintf( s, " - flip = [ %d, %d, %d ]", GLYPHS_flip[0], GLYPHS_flip[1], GLYPHS_flip[2] );
drawString( s );
sprintf( s, " - b0 thr = %.1f", GLYPHS_b0_thr );
drawString( s );
if ( PEAKS_n>0 )
{
drawString( "PEAKS" );
sprintf( s, " - use affine = %s", PEAKS_use_affine?"true":"false" );
drawString( s );
sprintf( s, " - flip = [ %d, %d, %d ]", PEAKS_flip[0], PEAKS_flip[1], PEAKS_flip[2] );
drawString( s );
sprintf( s, " - thr = %.1f", PEAKS_thr );
drawString( s );
sprintf( s, " - normalize = %s", PEAKS_doNormalize?"true":"false" );
drawString( s );
}
if ( TRK_nTractsPlotted>0 )
{
drawString( "FIBERS" );
sprintf( s, " - shift = [ %.1f %.1f %.1f ] (voxels)", TRK_offset.x, TRK_offset.y, TRK_offset.z );
drawString( s );
sprintf( s, " - slab thickness = %.1f (voxels)", TRK_crop );
drawString( s );
}
glEnable (GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
// KEYBOARD callback
// -----------------
void GLUT__keyboard( unsigned char key, GLint x=0, GLint y=0 )
{
bool doRedraw = true;
switch( key )
{
case 'l': showConfig = 1 - showConfig; break;
case '1': showPlane[0] = 1 - showPlane[0]; break;
case '2': showPlane[1] = 1 - showPlane[1]; break;
case '3': showPlane[2] = 1 - showPlane[2]; break;
case '4':
showPlane[0] = 1;
showPlane[1] = 0;
showPlane[2] = 0;
translation.x = translation.y = 0;
OPENGL_utils::identity(rot1);
OPENGL_utils::rotateX(rot1, 90.0, rot2);
OPENGL_utils::rotateZ(rot2, 90.0, rot);
break;
case '5':
showPlane[0] = 0;
showPlane[1] = 1;
showPlane[2] = 0;
translation.x = translation.y = 0;
OPENGL_utils::identity(rot1);
OPENGL_utils::rotateX(rot1, 90.0, rot);
break;
case '6':
showPlane[0] = 0;
showPlane[1] = 0;
showPlane[2] = 1;
translation.x = translation.y = 0;
OPENGL_utils::identity( rot );
break;
case '0': showAxes = 1 - showAxes; break;
case '-': zoom += 10.0; break;
case '+': zoom -= 10.0; break;
case 'm': MAP_max_view = fmaxf(0.0,MAP_max_view-MAP_max*0.05); break;
case 'M': MAP_max_view = fminf(MAP_max,MAP_max_view+MAP_max*0.05); break;
case 'o': MAP_opacity = fmaxf(0.0,MAP_opacity-0.1); break;
case 'O': MAP_opacity = fminf(1.0,MAP_opacity+0.1); break;
case 'w': LINE_width = fmaxf( 1,LINE_width-1); break;
case 'W': LINE_width = fminf(10,LINE_width+1); break;
case 'r':
showPlane[0] = showPlane[1] = showPlane[2] = 1;
translation.x = translation.y = 0;
zoom = 0;
OPENGL_utils::identity( rot );
break;
case 's': GLYPHS_show = 1 - GLYPHS_show; break;
case 'S': GLYPHS_shell = (GLYPHS_shell+1) % SCHEME_shells_idx.size(); break;
case 'a': GLYPHS_use_affine = 1 - GLYPHS_use_affine; break;
case 'x': GLYPHS_flip[0] = 1 - GLYPHS_flip[0]; for(int d=0; d < SCHEME_dirs.size() ;d++) SCHEME_dirs[d].x *= -1; break;
case 'y': GLYPHS_flip[1] = 1 - GLYPHS_flip[1]; for(int d=0; d < SCHEME_dirs.size() ;d++) SCHEME_dirs[d].y *= -1; break;
case 'z': GLYPHS_flip[2] = 1 - GLYPHS_flip[2]; for(int d=0; d < SCHEME_dirs.size() ;d++) SCHEME_dirs[d].z *= -1; break;
case 'b': GLYPHS_b0_thr = fmaxf(0.0,GLYPHS_b0_thr-10.0); break;
case 'B': GLYPHS_b0_thr = fminf(MAP_max,GLYPHS_b0_thr+10.0); break;
case 'p': if ( PEAKS_n>0 ) PEAKS_show = 1 - PEAKS_show; break;
case 'A': PEAKS_use_affine = 1 - PEAKS_use_affine; break;
case 'X': PEAKS_flip[0] = 1 - PEAKS_flip[0]; break;
case 'Y': PEAKS_flip[1] = 1 - PEAKS_flip[1]; break;
case 'Z': PEAKS_flip[2] = 1 - PEAKS_flip[2]; break;
case 't': PEAKS_thr = fmaxf(PEAKS_thr - 0.1, 0.0); break;
case 'T': PEAKS_thr = fminf(PEAKS_thr + 0.1, 1.0); break;
case 'n': PEAKS_doNormalize = 1 - PEAKS_doNormalize; break;
case 'f': if ( TRK_nTractsPlotted>0 ) TRK_show = 1 - TRK_show; break;
case 'c': TRK_crop = fmaxf( 0.0,TRK_crop-0.5); break;
case 'C': TRK_crop = fminf(max(dim.x,max(dim.y,dim.z)),TRK_crop+0.5); break;
case ' ': TRK_crop_mode = 1 - TRK_crop_mode; break;
case 'q':
case 27 : exit(0); break;
default: doRedraw = false;
}
if ( doRedraw )
glutPostRedisplay();
}
// MENU callback
// -------------
void GLUT__menu( int id )
{
switch( id )
{
case 0: GLUT__keyboard('q'); break;
case 101: GLUT__keyboard('s'); break;
case 102: GLUT__keyboard('S'); break;
case 103: GLUT__keyboard('a'); break;
case 104: GLUT__keyboard('x'); break;
case 105: GLUT__keyboard('y'); break;
case 106: GLUT__keyboard('z'); break;
case 107: GLUT__keyboard('b'); break;
case 108: GLUT__keyboard('B'); break;
case 201: GLUT__keyboard('p'); break;
case 202: GLUT__keyboard('A'); break;
case 203: GLUT__keyboard('X'); break;
case 204: GLUT__keyboard('Y'); break;
case 205: GLUT__keyboard('Z'); break;
case 206: GLUT__keyboard('t'); break;
case 207: GLUT__keyboard('T'); break;
case 208: GLUT__keyboard('n'); break;
case 301: GLUT__keyboard('f'); break;
case 302: GLUT__keyboard('c'); break;
case 303: GLUT__keyboard('C'); break;
case 304: GLUT__keyboard(' '); break;
case 401: GLUT__keyboard('1'); break;
case 402: GLUT__keyboard('2'); break;
case 403: GLUT__keyboard('3'); break;
case 404: GLUT__keyboard('4'); break;
case 405: GLUT__keyboard('5'); break;
case 406: GLUT__keyboard('6'); break;
case 407: GLUT__keyboard('0'); break;
case 408: GLUT__keyboard('-'); break;
case 409: GLUT__keyboard('+'); break;
case 410: GLUT__keyboard('m'); break;
case 411: GLUT__keyboard('M'); break;
case 412: GLUT__keyboard('o'); break;
case 413: GLUT__keyboard('O'); break;
case 414: GLUT__keyboard('w'); break;
case 415: GLUT__keyboard('W'); break;
case 416: GLUT__keyboard('r'); break;
case 417: GLUT__keyboard('l'); break;
}
}
// Create the dropdown MENU
// ------------------------
void GLUT__createMenu()
{
int submenu_SIGNAL_id, submenu_PEAKS_id, submenu_FIBERS_id, submenu_VIEW_id;
submenu_SIGNAL_id = glutCreateMenu( GLUT__menu );
glutAddMenuEntry("[s] Show/hide", 101);
glutAddMenuEntry("[S] Change shell", 102);
glutAddMenuEntry("[a] Use affine", 103);
glutAddMenuEntry("[x] Flip X axis", 104);
glutAddMenuEntry("[y] Flip Y axis", 105);
glutAddMenuEntry("[z] Flip Z axis", 106);
glutAddMenuEntry("[b] Decrease b0 thr", 107);
glutAddMenuEntry("[B] Increase b0 thr", 108);
if ( PEAKS_n>0 )
{
submenu_PEAKS_id = glutCreateMenu( GLUT__menu );
glutAddMenuEntry("[p] Show/hide", 201);
glutAddMenuEntry("[A] Use affine", 202);
glutAddMenuEntry("[X] Flip X axis", 203);
glutAddMenuEntry("[Y] Flip Y axis", 204);
glutAddMenuEntry("[Z] Flip Z axis", 205);
glutAddMenuEntry("[t] Decrease threshold",206);
glutAddMenuEntry("[T] Increase threshold",207);
glutAddMenuEntry("[n] Normalize length", 208);
}
if ( TRK_nTractsPlotted>0 )
{
submenu_FIBERS_id = glutCreateMenu( GLUT__menu );
glutAddMenuEntry("[f] Show/hide", 301);
glutAddMenuEntry("[c] Decrease crop size",302);
glutAddMenuEntry("[C] Increase crop size",303);
glutAddMenuEntry("[ ] Change crop mode", 304);
}
submenu_VIEW_id = glutCreateMenu( GLUT__menu );
glutAddMenuEntry("[1] Show/hide YZ plane", 401);
glutAddMenuEntry("[2] Show/hide XZ plane", 402);
glutAddMenuEntry("[3] Show/hide XY plane", 403);
glutAddMenuEntry("[4] Reset to YZ plane", 404);
glutAddMenuEntry("[5] Reset to XZ plane", 405);
glutAddMenuEntry("[6] Reset to XY plane", 406);
glutAddMenuEntry("[0] Show/hide axes", 407);
glutAddMenuEntry("[-] Decrease zoom", 408);
glutAddMenuEntry("[+] Increase zoom", 409);
glutAddMenuEntry("[m] Decrease max value", 410);
glutAddMenuEntry("[M] Increase max value", 411);
glutAddMenuEntry("[o] Decrease opacity", 412);
glutAddMenuEntry("[O] Increase opacity", 413);
glutAddMenuEntry("[t] Decrease line width",414);
glutAddMenuEntry("[T] Increase line width",415);
glutAddMenuEntry("[r] Reset view", 416);
glutAddMenuEntry("[l] Show/hide log", 417);
int menu_id = glutCreateMenu( GLUT__menu );
glutAddSubMenu("Signal", submenu_SIGNAL_id);
if ( PEAKS_n>0 )
glutAddSubMenu("Peaks", submenu_PEAKS_id);
if ( TRK_nTractsPlotted>0 )
glutAddSubMenu("Fibers", submenu_FIBERS_id);
glutAddSubMenu("View options", submenu_VIEW_id);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
// RESHAPE callback
// ----------------
void GLUT__reshape( GLint w, GLint h )
{
ScreenX = w;
ScreenY = h;
glViewport( 0, 0, w, h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 45.0f, ScreenX/ScreenY, 1.0f, 5000.0f );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt(
0.0, 0.0, 2.0 * max(pixdim.x*dim.x,pixdim.y*dim.y) * ScreenY/ScreenX, // eye point
0.0, 0.0, 0.0, // reference point
0.0, 1.0, 0.0 // up vector
);
}
// SPECIALKEY callback
// -------------------
void GLUT__specialkey( GLint key, GLint x, GLint y )
{
bool doRedraw = true;
GLint modif = glutGetModifiers();
GLint ALT = modif & GLUT_ACTIVE_ALT;
GLint CTRL = modif & GLUT_ACTIVE_CTRL;
switch( key )
{
case GLUT_KEY_LEFT:
if ( ALT )
TRK_offset.x -= 0.5;
else if ( CTRL )
translation.x -= 2.0;
else
VOXEL.x--;
break;
case GLUT_KEY_RIGHT:
if ( ALT )
TRK_offset.x += 0.5;
else if ( CTRL )
translation.x += 2.0;
else
VOXEL.x++;
break;
case GLUT_KEY_DOWN:
if ( ALT )
TRK_offset.y -= 0.5;
else if ( CTRL )
translation.y -= 2.0;
else
VOXEL.y--;
break;
case GLUT_KEY_UP:
if ( ALT )
TRK_offset.y += 0.5;
else if ( CTRL )
translation.y += 2.0;
else
VOXEL.y++;
break;
case GLUT_KEY_PAGE_DOWN:
if ( ALT )
TRK_offset.z -= 0.5;
else
VOXEL.z--;
break;
case GLUT_KEY_PAGE_UP:
if ( ALT )
TRK_offset.z += 0.5;
else
VOXEL.z++;
break;
default:
doRedraw = false;
}
// check the bounds
VOXEL.x = max( VOXEL.x, 0 );
VOXEL.y = max( VOXEL.y, 0 );
VOXEL.z = max( VOXEL.z, 0 );
VOXEL.x = min( VOXEL.x, dim.x-1 );
VOXEL.y = min( VOXEL.y, dim.y-1 );
VOXEL.z = min( VOXEL.z, dim.z-1 );
if ( doRedraw )
glutPostRedisplay();
}
// MOUSE callback
// --------------
void GLUT__mouse( GLint button, GLint state, GLint x, GLint y )
{
if (state == GLUT_DOWN)
{
if ( button == GLUT_LEFT_BUTTON && glutGetModifiers() != GLUT_ACTIVE_CTRL )
{
moving = 1;
start.x = x;
start.y = y;
}
// NOTE: does not work, issue with glutGetModifiers not getting CTRL
// else if ( button == GLUT_LEFT_BUTTON && glutGetModifiers() == GLUT_ACTIVE_CTRL )
// {
// moving = 2;
// start.x = x;
// start.y = y;
// }
else if ( (button == GLUT_MIDDLE_BUTTON) || (button == GLUT_LEFT_BUTTON && glutGetModifiers() == GLUT_ACTIVE_ALT) )
{
moving = 3;
start.x = x;
start.y = y;
}
}
else if (state == GLUT_UP)
{
moving = 0;
}
}
// MOTION callback
// ---------------
void GLUT__motion( GLint x, GLint y )
{
if (moving==1)
{
OPENGL_utils::translate(id, 0,0,0, rot1);
OPENGL_utils::rotateY(id,start.x-x,rot3);
OPENGL_utils::matXMat(rot,rot1,rot2);
OPENGL_utils::rotateX(id,start.y-y,rot1);
OPENGL_utils::matXMat(rot2,rot1,rot);
OPENGL_utils::matXMat(rot,rot3,rot2);
OPENGL_utils::translate(id, 0,0,0, rot1);
OPENGL_utils::matXMat(rot2,rot1,rot);
start.x = x;
start.y = y;
}
else if (moving==2)
{
zoom = zoom + (y-start.y)/2.0;
start.y = y;
}
else if (moving==3)
{
translation.x = translation.x - (start.x-x)/3.0;
translation.y = translation.y + (start.y-y)/3.0;
start.x = x;
start.y = y;
}
glutPostRedisplay();
}
// DISPLAY callback
// ----------------
void GLUT__display( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
glTranslatef(translation.x, translation.y, -zoom); // mouse translation + zoom
glMultMatrixf(rot); // mouse rotation
glTranslatef( -pixdim.x*dim.x/2.0, -pixdim.y*dim.y/2.0, -pixdim.z*dim.z/2.0 ); // center the FOV
glScalef( pixdim.x, pixdim.y, pixdim.z ); // account for voxel size
glEnable(GL_MULTISAMPLE_ARB);
/* ============= */
/* Draw the AXES */
/* ============= */
if ( showAxes )
{
glLineWidth(2);
glBegin(GL_LINES);
glColor4f( 1,0,0,1); glVertex3f( 0,0,0 ); glVertex3f( 10, 0, 0 );
glColor4f( 0,1,0,1); glVertex3f( 0,0,0 ); glVertex3f( 0, 10, 0 );
glColor4f( 0,0,1,1); glVertex3f( 0,0,0 ); glVertex3f( 0, 0, 10 );
glEnd();
}
/* =============== */
/* Draw the TRACTS */
/* =============== */
if ( TRK_show )
{
glPushMatrix();
glTranslatef(TRK_offset.x, TRK_offset.y, TRK_offset.z);
glLineWidth(1.0f);
float *ptr = TRK_coords, *ptrc = TRK_colors;
VECTOR<float> Vc( VOXEL.x+0.5, VOXEL.y+0.5, VOXEL.z+0.5 ); // voxel center
float thr = 0.5*TRK_crop;
for(int f=0; f < TRK_nTractsPlotted; f++)
{
glBegin(GL_LINE_STRIP);
for(int i=0; i < TRK_nPoints[f]; i++)
{
// plot segment only if it's close to center of VOXEL
if (
(
TRK_crop_mode && (
( showPlane[0] && abs( (ptr[0]+TRK_offset.x) - Vc.x ) <= thr ) ||
( showPlane[1] && abs( (ptr[1]+TRK_offset.y) - Vc.y ) <= thr ) ||
( showPlane[2] && abs( (ptr[2]+TRK_offset.z) - Vc.z ) <= thr ) )
)
||
(
!TRK_crop_mode && (
( abs( (ptr[0]+TRK_offset.x) - Vc.x ) <= thr ) &&
( abs( (ptr[1]+TRK_offset.y) - Vc.y ) <= thr ) &&
( abs( (ptr[2]+TRK_offset.z) - Vc.z ) <= thr ) )
)
)
{
glColor3f( ptrc[0], ptrc[1], ptrc[2] );
glVertex3f( ptr[0], ptr[1], ptr[2] );
}
else
{
glEnd();
glBegin(GL_LINE_STRIP);
}
ptr += 3;
ptrc += 3;
}
glEnd();
}
glPopMatrix();
}
/* ============== */
/* Draw the PEAKS */
/* ============== */
if ( PEAKS_show || GLYPHS_show )
{
glDisable( GL_BLEND );
glLineWidth( LINE_width );
glPointSize( LINE_width );
glPushMatrix();
glTranslatef(.5,.5,.5);
Vec3Df dir, col;
int x,y,z,d,idx;
float norms[PEAKS_n], normMax, b0, w;
// plane YZ
if ( showPlane[0] )
{
x = (int)VOXEL.x;
for(y=0; y<dim.y ;y++)
for(z=0; z<dim.z ;z++)
{
if ( PEAKS_show )
{
normMax = 0;
for(d=0; d<PEAKS_n; d++)
{
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
norms[d] = dir.norm();
if ( norms[d] > normMax )
normMax = norms[d];
}
for(d=0; d<PEAKS_n; d++)
{
if ( norms[d] < PEAKS_thr*normMax )
continue;
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
col.x = 0.5 * (PEAKS_flip[0]?-1:1) * dir.x / norms[d];
col.y = 0.5 * (PEAKS_flip[1]?-1:1) * dir.y / norms[d];
col.z = 0.5 * (PEAKS_flip[2]?-1:1) * dir.z / norms[d];
if ( PEAKS_doNormalize )
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
else
{
dir.x = col.x * norms[d] / normMax;
dir.y = col.y * norms[d] / normMax;
dir.z = col.z * norms[d] / normMax;
}
glColor3f( fabs(2.0*col.x), fabs(2.0*col.y), fabs(2.0*col.z) );
glBegin(GL_LINES);
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glEnd();
}
}
if ( GLYPHS_show )
{
b0 = (*niiDWI->img)(x,y,z,SCHEME_idxB0[0]);
if ( b0 > GLYPHS_b0_thr )
{
glBegin(GL_POINTS);
for(d=0; d < SCHEME_shells_idx[GLYPHS_shell].size() ;d++)
{
idx = SCHEME_shells_idx[GLYPHS_shell][d];
w = 0.5 * (float)(*niiDWI->img)(x,y,z,idx) / b0;
if ( GLYPHS_use_affine )
{
dir.x = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[0] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[1] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[2];
dir.y = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[3] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[4] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[5];
dir.z = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[6] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[7] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[8];
normMax = dir.norm();
dir.x *= w / normMax;
dir.y *= w / normMax;
dir.z *= w / normMax;
}
else
{
dir.x = w * SCHEME_dirs[idx].x;
dir.y = w * SCHEME_dirs[idx].y;
dir.z = w * SCHEME_dirs[idx].z;
}
normMax = dir.norm();
glColor3f( fabs(dir.x)/normMax, fabs(dir.y)/normMax, fabs(dir.z)/normMax );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
}
glEnd();
}
}
}
}
// plane XZ
if ( showPlane[1] )
{
y = (int)VOXEL.y;
for(x=0; x<dim.x ;x++)
for(z=0; z<dim.z ;z++)
{
if ( PEAKS_show )
{
normMax = 0;
for(d=0; d<PEAKS_n; d++)
{
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
norms[d] = dir.norm();
if ( norms[d] > normMax )
normMax = norms[d];
}
for(d=0; d<PEAKS_n; d++)
{
if ( norms[d] < normMax*PEAKS_thr )
continue;
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
col.x = 0.5 * (PEAKS_flip[0]?-1:1) * dir.x / norms[d];
col.y = 0.5 * (PEAKS_flip[1]?-1:1) * dir.y / norms[d];
col.z = 0.5 * (PEAKS_flip[2]?-1:1) * dir.z / norms[d];
if ( PEAKS_doNormalize )
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
else
{
dir.x = col.x * norms[d] / normMax;
dir.y = col.y * norms[d] / normMax;
dir.z = col.z * norms[d] / normMax;
}
glColor3f( fabs(2.0*col.x), fabs(2.0*col.y), fabs(2.0*col.z) );
glBegin(GL_LINES);
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glEnd();
}
}
if ( GLYPHS_show )
{
b0 = (*niiDWI->img)(x,y,z,SCHEME_idxB0[0]);
if ( b0 > GLYPHS_b0_thr )
{
glBegin(GL_POINTS);
for(d=0; d < SCHEME_shells_idx[GLYPHS_shell].size() ;d++)
{
idx = SCHEME_shells_idx[GLYPHS_shell][d];
w = 0.5 * (float)(*niiDWI->img)(x,y,z,idx) / b0;
if ( GLYPHS_use_affine )
{
dir.x = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[0] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[1] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[2];
dir.y = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[3] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[4] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[5];
dir.z = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[6] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[7] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[8];
normMax = dir.norm();
dir.x *= w / normMax;
dir.y *= w / normMax;
dir.z *= w / normMax;
}
else
{
dir.x = w * SCHEME_dirs[idx].x;
dir.y = w * SCHEME_dirs[idx].y;
dir.z = w * SCHEME_dirs[idx].z;
}
normMax = dir.norm();
glColor3f( fabs(dir.x)/normMax, fabs(dir.y)/normMax, fabs(dir.z)/normMax );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
}
glEnd();
}
}
}
}
// plane XY
if ( showPlane[2] )
{
z = (int)VOXEL.z;
for(y=0; y<dim.y ;y++)
for(x=0; x<dim.x ;x++)
{
if ( PEAKS_show )
{
normMax = 0;
for(d=0; d<PEAKS_n; d++)
{
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
norms[d] = dir.norm();
if ( norms[d] > normMax )
normMax = norms[d];
}
for(d=0; d<PEAKS_n; d++)
{
if ( norms[d] < normMax*PEAKS_thr )
continue;
col.x = (*niiPEAKS->img)(x,y,z,3*d+0); // use "col" as tmp variable
col.y = (*niiPEAKS->img)(x,y,z,3*d+1);
col.z = (*niiPEAKS->img)(x,y,z,3*d+2);
if ( PEAKS_use_affine )
{
dir.x = col.x * ((float*)PEAKS_affine)[0] + col.y * ((float*)PEAKS_affine)[1] + col.z * ((float*)PEAKS_affine)[2];
dir.y = col.x * ((float*)PEAKS_affine)[3] + col.y * ((float*)PEAKS_affine)[4] + col.z * ((float*)PEAKS_affine)[5];
dir.z = col.x * ((float*)PEAKS_affine)[6] + col.y * ((float*)PEAKS_affine)[7] + col.z * ((float*)PEAKS_affine)[8];
}
else
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
col.x = 0.5 * (PEAKS_flip[0]?-1:1) * dir.x / norms[d];
col.y = 0.5 * (PEAKS_flip[1]?-1:1) * dir.y / norms[d];
col.z = 0.5 * (PEAKS_flip[2]?-1:1) * dir.z / norms[d];
if ( PEAKS_doNormalize )
{
dir.x = col.x;
dir.y = col.y;
dir.z = col.z;
}
else
{
dir.x = col.x * norms[d] / normMax;
dir.y = col.y * norms[d] / normMax;
dir.z = col.z * norms[d] / normMax;
}
glColor3f( fabs(2.0*col.x), fabs(2.0*col.y), fabs(2.0*col.z) );
glBegin(GL_LINES);
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glEnd();
}
}
if( GLYPHS_show)
{
b0 = (*niiDWI->img)(x,y,z,SCHEME_idxB0[0]);
if ( b0 > GLYPHS_b0_thr )
{
glBegin(GL_POINTS);
for(d=0; d < SCHEME_shells_idx[GLYPHS_shell].size() ;d++)
{
idx = SCHEME_shells_idx[GLYPHS_shell][d];
w = 0.5 * (float)(*niiDWI->img)(x,y,z,idx) / b0;
if ( GLYPHS_use_affine )
{
dir.x = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[0] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[1] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[2];
dir.y = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[3] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[4] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[5];
dir.z = SCHEME_dirs[idx].x * ((float*)GLYPHS_affine)[6] + SCHEME_dirs[idx].y * ((float*)GLYPHS_affine)[7] + SCHEME_dirs[idx].z * ((float*)GLYPHS_affine)[8];
normMax = dir.norm();
dir.x *= w / normMax;
dir.y *= w / normMax;
dir.z *= w / normMax;
}
else
{
dir.x = w * SCHEME_dirs[idx].x;
dir.y = w * SCHEME_dirs[idx].y;
dir.z = w * SCHEME_dirs[idx].z;
}
normMax = dir.norm();
glColor3f( fabs(dir.x)/normMax, fabs(dir.y)/normMax, fabs(dir.z)/normMax );
glVertex3f( x+dir.x, y+dir.y, z+dir.z );
glVertex3f( x-dir.x, y-dir.y, z-dir.z );
}
glEnd();
}
}
}
}
glPopMatrix();
}
/* =================== */
/* Draw the SCALAR MAP */
/* =================== */
if ( showPlane[0] || showPlane[1] || showPlane[2] )
{
glDisable( GL_CULL_FACE );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// to avoid z-fighting
glPolygonOffset( 1.0, 1.0 );
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth( 3 );
int x, y, z; // voxel coordinates NB: (0,0,0) -> corner of voxel
float color;
// plane YZ
if ( showPlane[0] )
{
glPushMatrix();
glTranslatef(0.5,0,0);
x = (int)VOXEL.x;
for(y=0; y<dim.y ;y++)
for(z=0; z<dim.z ;z++)
{
color = ( MAP(x,y,z) - MAP_min_view) / ( MAP_max_view - MAP_min_view );
glColor4f(color,color,color,MAP_opacity);
glBegin(GL_QUADS);
glVertex3f(x, y, z);
glVertex3f(x, y, z+1);
glVertex3f(x, y+1, z+1);
glVertex3f(x, y+1, z);
glEnd();
}
// colored frame
if ( showAxes )
{
glColor3f(1,0,0);
glBegin(GL_LINE_STRIP);
glVertex3f(x,0,0);
glVertex3f(x,dim.y,0);
glVertex3f(x,dim.y,dim.z);
glVertex3f(x,0,dim.z);
glVertex3f(x,0,0);
glEnd();
}
glPopMatrix();
}
// plane XZ
if ( showPlane[1] )
{
glPushMatrix();
glTranslatef(0,0.5,0);
y = (int)VOXEL.y;
for(x=0; x<dim.x ;x++)
for(z=0; z<dim.z ;z++)
{
color = ( MAP(x,y,z) - MAP_min_view) / ( MAP_max_view - MAP_min_view );
glColor4f(color,color,color,MAP_opacity);
glBegin(GL_QUADS);
glVertex3f(x, y, z);
glVertex3f(x, y, z+1);
glVertex3f(x+1, y, z+1);
glVertex3f(x+1, y, z);
glEnd();
}
// colored frame
if ( showAxes )
{
glColor3f(0,1,0);
glBegin(GL_LINE_STRIP);
glVertex3f(0,y,0);
glVertex3f(dim.x,y,0);
glVertex3f(dim.x,y,dim.z);
glVertex3f(0,y,dim.z);
glVertex3f(0,y,0);
glEnd();
}
glPopMatrix();
}
// plane XY
if ( showPlane[2] )
{
glPushMatrix();
glTranslatef(0,0,0.5);
z = (int)VOXEL.z;
for(y=0; y<dim.y ;y++)
for(x=0; x<dim.x ;x++)
{
color = ( MAP(x,y,z) - MAP_min_view) / ( MAP_max_view - MAP_min_view );
glColor4f(color,color,color,MAP_opacity);
glBegin(GL_QUADS);
glVertex3f(x, y, z);
glVertex3f(x+1, y, z);
glVertex3f(x+1, y+1, z);
glVertex3f(x, y+1, z);
glEnd();
}
// colored frame
if ( showAxes )
{
glColor3f(0,0,1);
glBegin(GL_LINE_STRIP);
glVertex3f(0,0,z);
glVertex3f(dim.x,0,z);
glVertex3f(dim.x,dim.y,z);
glVertex3f(0,dim.y,z);
glVertex3f(0,0,z);
glEnd();
}
glPopMatrix();
}
glEnable(GL_CULL_FACE);
glDisable( GL_BLEND );
glDisable(GL_POLYGON_OFFSET_FILL);
}
/* ====================== */
/* Draw the CURRENT VOXEL */
/* ====================== */
if ( showAxes )
{
glPushMatrix();
glTranslatef( VOXEL.x+0.5, VOXEL.y+0.5, VOXEL.z+0.5 );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glLineWidth(1);
glColor4f( 1,1,0,1 );
glutWireCube( 1 );
glColor4f( 1,1,0,0.25 );
glutSolidCube( 1 );
glDisable( GL_BLEND );
glPopMatrix();
}
glPopMatrix();
PrintConfig();
glutSwapBuffers();
}
// INITIALIZATION
// --------------
void OpenGL_init( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA | GLUT_MULTISAMPLE );
ScreenX = 0.7*glutGet(GLUT_SCREEN_WIDTH); if (ScreenX==0) ScreenX = 800;
ScreenY = 0.7*glutGet(GLUT_SCREEN_HEIGHT); if (ScreenY==0) ScreenY = 600;
glutInitWindowSize( ScreenX, ScreenY );
glutInitWindowPosition( 0.15*glutGet(GLUT_SCREEN_WIDTH), 0.15*glutGet(GLUT_SCREEN_HEIGHT) );
glutCreateWindow( "COMMIT debugger" );
// Projection and model matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
translation.x = translation.y = 0;
zoom = 0;
OPENGL_utils::identity( rot );
OPENGL_utils::identity( id );
glEnable( GL_DEPTH_TEST );
glClearColor( 0.1, 0.1, 0.1, 0.0 );
// lighting
glShadeModel( GL_SMOOTH );
glEnable( GL_NORMALIZE );
GLfloat white[] = {.5f, .5f, .5f, 1.0f};
glMaterialfv(GL_FRONT, GL_SPECULAR, white);
GLfloat shininess[] = {32};
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
GLfloat global_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
glEnable ( GL_COLOR_MATERIAL );
// register CALLBACKS and open window
glutKeyboardFunc( GLUT__keyboard );
glutSpecialFunc( GLUT__specialkey );
glutDisplayFunc( GLUT__display );
glutReshapeFunc( GLUT__reshape );
glutMouseFunc( GLUT__mouse );
glutMotionFunc( GLUT__motion );
GLUT__createMenu();
glutMainLoop();
}
| 36.910856 | 188 | 0.437279 |
fb472ad16367fad95a64a4dd1d18491068181fe8 | 1,672 | java | Java | maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/InMemoryRemeberMeService.java | szj-coder/MaxKey | b56496a6df16de37f62db0064caf260e181365a1 | [
"Apache-2.0"
] | 1 | 2022-01-24T07:45:15.000Z | 2022-01-24T07:45:15.000Z | maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/InMemoryRemeberMeService.java | szj-coder/MaxKey | b56496a6df16de37f62db0064caf260e181365a1 | [
"Apache-2.0"
] | null | null | null | maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/InMemoryRemeberMeService.java | szj-coder/MaxKey | b56496a6df16de37f62db0064caf260e181365a1 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.authn.support.rememberme;
import java.util.concurrent.TimeUnit;
import org.maxkey.constants.ConstsTimeInterval;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
public class InMemoryRemeberMeService extends AbstractRemeberMeService {
protected static final Cache<String, RemeberMe> remeberMeStore =
Caffeine.newBuilder()
.expireAfterWrite(ConstsTimeInterval.TWO_WEEK, TimeUnit.MINUTES)
.build();
@Override
public void save(RemeberMe remeberMe) {
remeberMeStore.put(remeberMe.getUsername(), remeberMe);
}
@Override
public void update(RemeberMe remeberMe) {
remeberMeStore.put(remeberMe.getUsername(), remeberMe);
}
@Override
public RemeberMe read(RemeberMe remeberMe) {
return remeberMeStore.getIfPresent(remeberMe.getUsername());
}
@Override
public void remove(String username) {
remeberMeStore.invalidate(username);
}
}
| 30.4 | 80 | 0.717703 |
f544083db56648fca3a9b160b4c0ed76adfa9776 | 2,521 | cxx | C++ | src/Cxx/Widgets/BoxWidget.cxx | cvandijck/VTKExamples | b6bb89414522afc1467be8a1f0089a37d0c16883 | [
"Apache-2.0"
] | 309 | 2017-05-21T09:07:19.000Z | 2022-03-15T09:18:55.000Z | src/Cxx/Widgets/BoxWidget.cxx | yijianmingliu/VTKExamples | dc8aac47c4384f9a2de9facbdd1ab3249f62ec99 | [
"Apache-2.0"
] | 379 | 2017-05-21T09:06:43.000Z | 2021-03-29T20:30:50.000Z | src/Cxx/Widgets/BoxWidget.cxx | yijianmingliu/VTKExamples | dc8aac47c4384f9a2de9facbdd1ab3249f62ec99 | [
"Apache-2.0"
] | 170 | 2017-05-17T14:47:41.000Z | 2022-03-31T13:16:26.000Z | #include <vtkSmartPointer.h>
// For the rendering pipeline setup:
#include <vtkConeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
// For vtkBoxWidget:
#include <vtkBoxWidget.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
class vtkMyCallback : public vtkCommand
{
public:
static vtkMyCallback *New()
{
return new vtkMyCallback;
}
virtual void Execute( vtkObject *caller, unsigned long, void* )
{
// Here we use the vtkBoxWidget to transform the underlying coneActor
// (by manipulating its transformation matrix).
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
widget->GetTransform( t );
widget->GetProp3D()->SetUserTransform( t );
}
};
int main( int vtkNotUsed( argc ), char* vtkNotUsed( argv )[] )
{
vtkSmartPointer<vtkConeSource> cone =
vtkSmartPointer<vtkConeSource>::New();
vtkSmartPointer<vtkPolyDataMapper> coneMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkSmartPointer<vtkActor> coneActor =
vtkSmartPointer<vtkActor>::New();
coneActor->SetMapper( coneMapper );
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor( coneActor );
renderer->SetBackground( 0.1, 0.2, 0.4 );
vtkSmartPointer<vtkRenderWindow> window =
vtkSmartPointer<vtkRenderWindow>::New();
window->AddRenderer( renderer );
window->SetSize( 300, 300 );
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow( window );
vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
interactor->SetInteractorStyle( style );
vtkSmartPointer<vtkBoxWidget> boxWidget =
vtkSmartPointer<vtkBoxWidget>::New();
boxWidget->SetInteractor( interactor );
boxWidget->SetProp3D( coneActor );
boxWidget->SetPlaceFactor( 1.25 ); // Make the box 1.25x larger than the actor
boxWidget->PlaceWidget();
vtkSmartPointer<vtkMyCallback> callback =
vtkSmartPointer<vtkMyCallback>::New();
boxWidget->AddObserver( vtkCommand::InteractionEvent, callback );
boxWidget->On();
window->Render();
interactor->Start();
return EXIT_SUCCESS;
}
| 30.011905 | 80 | 0.742562 |
b454e22a7b72ef8fea543fa3189f3418d9217a67 | 3,107 | sql | SQL | script/e6_migration/12_tags.sql | hahaluckyme/e621ng | 7c667897ce3a9bfecea073222aa02000e5f9b933 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2020-04-05T20:13:02.000Z | 2020-04-05T20:13:02.000Z | script/e6_migration/12_tags.sql | hahaluckyme/e621ng | 7c667897ce3a9bfecea073222aa02000e5f9b933 | [
"BSD-2-Clause-FreeBSD"
] | 2 | 2020-09-03T17:08:14.000Z | 2020-09-12T17:46:06.000Z | script/e6_migration/12_tags.sql | hahaluckyme/e621ng | 7c667897ce3a9bfecea073222aa02000e5f9b933 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | begin;
alter table tags rename column tag_type to category;
alter table tags rename column type_locked to is_locked;
alter table tags rename column cached_related to related_tags;
alter table tags rename column cached_related_expires_on to related_tags_updated_at;
update tags set is_locked = false where is_locked is null;
alter table tags alter column is_locked set not null;
alter table tags add column created_at timestamp not null default now(),
add column updated_at timestamp not null default now();
alter table tags alter column related_tags drop not null,
alter column related_tags_updated_at drop not null;
alter table tags add primary key (id);
alter table tag_aliases rename column name to antecedent_name;
alter table tag_aliases add column updated_at timestamp,
add column forum_topic_id integer,
add column creator_ip_addr inet not null default '127.0.0.1',
add column consequent_name varchar,
add column status varchar not null default 'pending',
add column post_count int not null default 0,
add column approver_id integer;
update tag_aliases set status = 'active' where is_pending = false;
alter table tag_aliases drop column is_pending;
update tag_aliases set consequent_name = (select _.name from tags _ where _.id = tag_aliases.alias_id);
alter table tag_aliases drop column alias_id;
update tag_aliases set creator_id = 1 where creator_id is null;
alter table tag_aliases alter column creator_id set not null,
alter column consequent_name set not null;
alter table forum_posts add primary key (id);
update tag_aliases set forum_topic_id = (select _.topic_id from forum_posts _ where _.id = tag_aliases.forum_post_id);
alter table tag_implications add column antecedent_name varchar,
add column consequent_name varchar,
add column status varchar not null default 'pending',
add column creator_ip_addr inet not null default '127.0.0.1',
add column forum_topic_id int,
add column updated_at timestamp,
add column descendant_names text[] default '{}'::text[],
add column approver_id integer;
update tag_implications set status = 'active' where is_pending = false;
alter table tag_implications drop column is_pending;
update tag_implications set antecedent_name = (select _.name from tags _ where _.id = tag_implications.predicate_id), consequent_name = (select _.name from tags _ where _.id = tag_implications.consequent_id);
alter table tag_implications alter column antecedent_name set not null, alter column consequent_name set not null;
update tag_implications set forum_topic_id = (select _.topic_id from forum_posts _ where _.id = tag_implications.forum_post_id);
update tag_implications set creator_id = 1 where creator_id is null;
alter table tag_implications alter column creator_id set not null;
alter table tag_implications drop column consequent_id, drop column predicate_id;
alter table forum_posts drop constraint forum_posts_pkey;
alter table tags drop constraint tags_pkey;
alter table tag_type_histories rename to tag_type_versions;
alter table tag_type_versions rename column user_id to creator_id;
commit;
| 53.568966 | 209 | 0.809784 |
4ea995bed2f2b93dc05fd1ad31a0014a71c10c25 | 7,917 | dart | Dart | lib/src/bloc/bloc.dart | zaolab/flutter_rebloc | 1afacb5554696f38aa3fed07b2961cb1f28b3f9a | [
"MIT"
] | 1 | 2020-01-09T01:33:20.000Z | 2020-01-09T01:33:20.000Z | lib/src/bloc/bloc.dart | zaolab/flutter_rebloc | 1afacb5554696f38aa3fed07b2961cb1f28b3f9a | [
"MIT"
] | null | null | null | lib/src/bloc/bloc.dart | zaolab/flutter_rebloc | 1afacb5554696f38aa3fed07b2961cb1f28b3f9a | [
"MIT"
] | null | null | null | import 'dart:async';
import 'dart:developer';
import 'package:flutter/widgets.dart';
import 'package:flutter_rebloc/src/event/event.dart';
import 'package:flutter_rebloc/src/state/state.dart';
import 'package:flutter_rebloc/src/state/state_provider.dart';
/// A layer that processes business logic by consuming action events and
/// streaming output state.
///
/// The BLOC consumes an incoming action event through the add method and
/// streams the output through the [stream] property.
/// The action event will be consumed by the runEvent method which all BLOCs
/// must override. The yielded value of the runEvent can contain an event
/// and/or state. The event will be passed to the event listeners and state
/// to the output stream. The output event signifies the internal state of the
/// BLOC and what it is currently doing. Event and/or state can be null.
/// When the state is null, the previous state will be kept as if.
///
/// e.g.
/// ```dart
/// enum CounterAction {
/// increment,
/// decrement,
/// }
///
/// CounterState extends ReBlocState {
/// final int counter;
/// CounterState(this.counter);
/// }
///
/// CounterBloc extends ReBloc<CounterState> {
/// CounterState initState() => CounterState(0);
///
/// Stream<StateEvent<CounterState>> runEvent(Object action, CounterState state) async* {
/// yield(StateEvent(event: 'Working...'));
///
/// switch (action) {
/// case CounterAction.increment:
/// yield(StateEvent(event: 'Incremented', state: CounterState(state.count+1)));
/// break;
/// case CounterAction.decrement:
/// yield(StateEvent(event: 'Decremented', state: CounterState(state.count-1)));
/// break;
/// default:
/// yield(StateEvent(event: ErrorEvent(message: 'Not implemented')));
/// }
/// }
/// }
/// ```
abstract class ReBloc<S extends ReBlocState> {
/// The last event that occured in the Bloc.
///
/// This is not the action event that is sunk into the BlOC.
/// It is the event that signals the situation the BLOC faced itself.
Object get lastEvent => _lastEvent;
/// The output stream containing the state.
Stream get stream => _output.stream;
/// The type of the state.
Type get stateType => S;
/// The last state output by the BLOC.
S get state => _state;
/// Creates a new BLOC with [context] that the BLOC can use to get
/// access to state values provided by an ancestor StateProvider.
ReBloc({BuildContext context}) {
_state = initState();
if (context != null) {
withContext(context);
}
_eventStream.stream.listen((event) {
runEvent(event, state)?.listen((stateEvent) {
_lastEvent = stateEvent.event ?? _lastEvent;
if (stateEvent.state != null && _state != stateEvent.state) {
state = stateEvent.state;
_output.add(stateEvent.state);
}
if (stateEvent.event != null) {
if (stateEvent.event is ErrorEvent) {
for (var f in _errorListeners) {
f(stateEvent.event);
}
} else {
for (var f in _successListeners) {
f(stateEvent.event);
}
}
for (var f in _listeners) {
f(stateEvent.event);
}
}
});
}, onError: handleError);
}
/// Creates a default initial state.
@protected
S initState();
/// Consumes and run the [action] added to the sink and yield an output stream
/// containing the BLOC event and output state.
@protected
Stream<StateEvent<S>> runEvent(Object action, S state);
/// Closes and cleanup the BLOC.
@mustCallSuper
void close() {
_stateSub?.cancel();
_stateSub = null;
_context = null;
_eventStream.close();
_output.close();
_listeners.clear();
_errorListeners.clear();
_successListeners.clear();
}
/// Adds an action event to be run by the BLOC.
void add(Object action) {
_eventStream.add(action);
}
/// Subscribe callback function to the [eventType] events yielded by runEvent.
///
/// There are three event types to subscribe to:
/// 1. [ReBlocEvent.error] - Events that extend the ErrorEvent class.
/// 2. [ReBlocEvent.success] - Events that _do not_ extend the ErrorEvent class.
/// 3. [ReBlocEvent.all] - All events.
void subscribe(ReBlocEvent eventType, dynamic f) {
switch (eventType) {
case ReBlocEvent.all:
_listeners.add(f);
break;
case ReBlocEvent.success:
_successListeners.add(f);
break;
case ReBlocEvent.error:
_errorListeners.add(f);
break;
}
}
/// Unsubscribe callback function from the [eventType] events.
void unsubscribe(ReBlocEvent eventType, dynamic f) {
switch (eventType) {
case ReBlocEvent.all:
_listeners.remove(f);
break;
case ReBlocEvent.success:
_successListeners.remove(f);
break;
case ReBlocEvent.error:
_errorListeners.remove(f);
break;
}
}
/// Sets the BLOC with [context] to be used to get state values from the
/// context tree.
void withContext(BuildContext context) {
if (context != null && _context != context) {
_context = context;
final p = StateProvider.of<S>(context);
if (p != null) {
_state = p.state;
_sharedState = true;
_stateSub?.cancel();
_stateSub = p.stream.listen(updateStateFromStream);
} else if (_sharedState) {
_sharedState = false;
_stateSub?.cancel();
_stateSub = null;
}
} else if (_context != context) {
_sharedState = false;
_context = context;
_stateSub?.cancel();
_stateSub = null;
}
}
/// Gets a state value from an ancestor StateProvider.
/// There must be a context set in the BLOC either from the constructor
/// or the withContext method.
T getSharedStateOfType<T extends ReBlocState>() {
if (_context != null) {
return StateProvider.of<T>(_context)?.state;
}
return null;
}
/// Handles any unhandled streaming error that happened in runEvent method.
void handleError(dynamic err) {
log(err.toString(), error: err);
}
final StreamController<Object> _eventStream = StreamController<Object>();
final StreamController<S> _output = StreamController<S>.broadcast();
S _state;
final Set<ValueChanged<Object>> _listeners = {};
final Set<ValueChanged<ErrorEvent>> _errorListeners = {};
final Set<ValueChanged<Object>> _successListeners = {};
Object _lastEvent;
BuildContext _context;
bool _sharedState = false;
// ignore: cancel_subscriptions
StreamSubscription<S> _stateSub;
@protected
set state(S s) {
if (_sharedState) {
final ss = StateProvider.of<S>(_context);
if (ss != null) {
ss.add(s);
} else {
_sharedState = false;
}
}
_state = s;
}
/// Updates the state coming from external events and pushing it to the stream.
@protected
void updateStateFromStream(S s) {
if (_state != s) {
_state = s;
_output.add(s);
}
}
}
typedef ReBlocCreator<S extends ReBlocState> = ReBloc<S> Function(BuildContext);
/// An object that contains the BLOC event and output state.
class StateEvent<S extends ReBlocState> {
/// The state value to push into the BLOC stream.
final S state;
/// The BLOC event to trigger to listeners.
final Object event;
/// Creates an immutable StateEvent to push to BLOC stream.
StateEvent({this.state, this.event});
}
/// The different types of events the BLOC can yield.
enum ReBlocEvent {
/// An events that extend the ErrorEvent class and indicating
/// an error happening in the BLOC.
error,
/// An event that is not an error indicating the BLOC has
/// successfully performed its job.
success,
/// Both error and non error events.
all,
}
| 28.789091 | 91 | 0.643931 |
eb4569c9c9df5764e8c54d7483b6d99a12dbd99a | 6,823 | swift | Swift | PQKit/Base/Services/PQSkip.swift | PQKit/PQKit | af1074a959328c4068c99487347f93084e796492 | [
"Apache-2.0"
] | null | null | null | PQKit/Base/Services/PQSkip.swift | PQKit/PQKit | af1074a959328c4068c99487347f93084e796492 | [
"Apache-2.0"
] | null | null | null | PQKit/Base/Services/PQSkip.swift | PQKit/PQKit | af1074a959328c4068c99487347f93084e796492 | [
"Apache-2.0"
] | null | null | null | //
// PQSkip.swift
// PQKit
//
// Created by 盘国权 on 2019/6/10.
// Copyright © 2019 pgq. All rights reserved.
//
import Foundation
import PQTools
public extension String {
/// suport rgb rgba
var spColor: UIColor? {
var str = self
if !str.contains("0x") && !str.contains("0X") {
str = "0x" + str
}
let scanner = Scanner(string: self)
var hex: UInt64 = 0
scanner.scanHexInt64(&hex)
var alpha: CGFloat = 1
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
if str.count == 8 {
red = CGFloat(hex >> 16 & 0xff) / 255.0
green = CGFloat(hex >> 8 & 0xff) / 255.0
blue = CGFloat(hex & 0xff) / 255.0
}else if str.count == 10 {
red = CGFloat(hex >> 32 & 0xff) / 255.0
green = CGFloat(hex >> 16 & 0xff) / 255.0
blue = CGFloat(hex >> 8 & 0xff) / 255.0
alpha = CGFloat(hex & 0xff)
} else {
PQPrint("读取颜色失败了,请检查输入是否正确: str - \(self)")
return nil
}
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
}
}
public struct PQSkipFont: Codable {
public var size: CGFloat
public var color: String
public var family: String?
public var bold: Bool
public var font: UIFont {
if let family = family {
if let font = UIFont(name: family, size: size) {
return font
}
return UIFont.systemFont(ofSize: size)
}
if bold {
return UIFont.boldSystemFont(ofSize: size)
}
return UIFont.systemFont(ofSize: size)
}
public static var largeTitle = PQSkipFont(size: 26, color: "0x000000ff", family: nil, bold: false)
public static var midTitle = PQSkipFont(size: 23, color: "0x000000ff", family: nil, bold: false)
public static var smallTitle = PQSkipFont(size: 20, color: "0x000000ff", family: nil, bold: false)
public static var context = PQSkipFont(size: 17, color: "0x000000ff", family: nil, bold: false)
public static var hint = PQSkipFont(size: 13, color: "0x000000ff", family: nil, bold: false)
public static var selectedTitle = PQSkipFont(size: 15, color: "0x000000ff", family: nil, bold: false)
public static var normalTitle = PQSkipFont(size: 15, color: "0x000000ff", family: nil, bold: false)
public static var textField = PQSkipFont(size: 15, color: "0x000000ff", family: nil, bold: false)
public static var textView = PQSkipFont(size: 15, color: "0x000000ff", family: nil, bold: false)
}
public struct PQSkipNavigationBar: Codable {
public var isHidden: Bool
public var barTintColor: String?
public var isTranslucent: Bool
public var tintColor: String?
public var font: PQSkipFont
public static let `default` = PQSkipNavigationBar(isHidden: false, barTintColor: "0xffffffff", isTranslucent: false, tintColor: "0xffffffff", font: PQSkipFont(size: 17, color: "0xffffffff", family: nil, bold: false))
}
public struct PQSkipController: Codable {
public var backgroundColor: String?
public static let `default` = PQSkipController(backgroundColor: "0xffffffff")
}
public struct PQSkipTBCell: Codable {
public var backgroundColor: String?
public var lineColor: String?
public var lineHeight: CGFloat
public var lineMargin: [CGFloat]
public static let `default` = PQSkipTBCell(backgroundColor: "0xffffffff", lineColor: "0xffffffff", lineHeight: 1, lineMargin: [0,0])
}
public struct PQSkipCVCell: Codable {
public var backgroundColor: String?
public static let `default` = PQSkipCVCell(backgroundColor: "0xffffffff")
}
public struct PQSkipLabel: Codable {
public var largeTitle: PQSkipFont
public var midTitle: PQSkipFont
public var smallTitle: PQSkipFont
public var context: PQSkipFont
public var hint: PQSkipFont
public static var `default` = PQSkipLabel(largeTitle: .largeTitle, midTitle: .midTitle, smallTitle: .smallTitle, context: .context, hint: .hint)
}
public struct PQSkipButton: Codable {
public var normalTitle: PQSkipFont
public var selectedTitle: PQSkipFont
public static var `default` = PQSkipButton(normalTitle: .normalTitle, selectedTitle: .selectedTitle)
}
public struct PQSkipTextField: Codable {
public var placehodloerColor: String?
public var cursorColor: String?
public var textColor: String?
public var font: PQSkipFont
public static var `default` = PQSkipTextField(placehodloerColor: "0x000000ff", cursorColor: "0x000000ff", textColor: "0x000000ff", font: .textField)
}
public struct PQSkipTextView: Codable {
public var placehodloerColor: String?
public var cursorColor: String?
public var textColor: String?
public var font: PQSkipFont
public static var `default` = PQSkipTextView(placehodloerColor: "0x000000ff", cursorColor: "0x000000ff", textColor: "0x000000ff", font: .textField)
}
open class PQSkip: NSObject, Codable {
public static internal(set) var shared = PQSkip()
open var navigationBar: PQSkipNavigationBar = .default
open var controller: PQSkipController = .default
open var tbCell: PQSkipTBCell = .default
open var cvCell: PQSkipCVCell = .default
open var label: PQSkipLabel = .default
open var button: PQSkipButton = .default
open var textField: PQSkipTextField = .default
open var textView: PQSkipTextView = .default
public func readSkip(for url: URL, completion: @escaping (Error?) -> ()) {
DispatchQueue.global().async {
do {
let data = try Data(contentsOf: url)
self.readSkip(for: data, completion: completion)
} catch {
completion(error)
}
}
}
public func readSkip(for data: Data, completion: @escaping (Error?) -> ()) {
do {
let skip = try JSONDecoder().decode(PQSkip.self, from: data)
PQSkip.shared = skip
completion(nil)
} catch {
completion(error)
}
}
public func readSkip(for json: String, completion: @escaping (Error?) -> ()) {
guard let data = json.data(using: .utf8) else {
completion(NSError(domain: "Json str to data invalid", code: 0, userInfo: nil) as Error)
return
}
readSkip(for: data, completion: completion)
}
open override var description: String {
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
if let data = try? encoder.encode(self),
let jsonStr = String(data: data, encoding: .utf8) {
return jsonStr
}
return "\(self)"
}
}
| 35.170103 | 220 | 0.637403 |
2f3ebaf0c5329953b34039f2f3abe4a1277b7ac5 | 4,819 | java | Java | modules/nf-ga4gh/src/main/nextflow/ga4gh/tes/client/model/TesServiceInfo.java | noobsauce101/tarema-nextflow-extension | cac8d2ad7127a9272d09e640c526ff231d4173d1 | [
"Apache-2.0"
] | 2 | 2021-11-14T19:17:50.000Z | 2022-02-01T17:11:00.000Z | modules/nf-ga4gh/src/main/nextflow/ga4gh/tes/client/model/TesServiceInfo.java | noobsauce101/tarema-nextflow-extension | cac8d2ad7127a9272d09e640c526ff231d4173d1 | [
"Apache-2.0"
] | null | null | null | modules/nf-ga4gh/src/main/nextflow/ga4gh/tes/client/model/TesServiceInfo.java | noobsauce101/tarema-nextflow-extension | cac8d2ad7127a9272d09e640c526ff231d4173d1 | [
"Apache-2.0"
] | 2 | 2021-03-17T15:50:06.000Z | 2021-05-17T11:01:16.000Z | /*
* Copyright 2020, Seqera Labs
* Copyright 2013-2019, Centre for Genomic Regulation (CRG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* task_execution.proto
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: version not set
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nextflow.ga4gh.tes.client.model;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
/**
* ServiceInfo describes information about the service, such as storage details, resource availability, and other documentation.
*/
@ApiModel(description = "ServiceInfo describes information about the service, such as storage details, resource availability, and other documentation.")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-02-01T15:43:49.638Z")
public class TesServiceInfo {
@SerializedName("name")
private String name = null;
@SerializedName("doc")
private String doc = null;
@SerializedName("storage")
private List<String> storage = null;
public TesServiceInfo name(String name) {
this.name = name;
return this;
}
/**
* Returns the name of the service, e.g. \"ohsu-compbio-funnel\".
* @return name
**/
@ApiModelProperty(value = "Returns the name of the service, e.g. \"ohsu-compbio-funnel\".")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public TesServiceInfo doc(String doc) {
this.doc = doc;
return this;
}
/**
* Returns a documentation string, e.g. \"Hey, we're OHSU Comp. Bio!\".
* @return doc
**/
@ApiModelProperty(value = "Returns a documentation string, e.g. \"Hey, we're OHSU Comp. Bio!\".")
public String getDoc() {
return doc;
}
public void setDoc(String doc) {
this.doc = doc;
}
public TesServiceInfo storage(List<String> storage) {
this.storage = storage;
return this;
}
public TesServiceInfo addStorageItem(String storageItem) {
if (this.storage == null) {
this.storage = new ArrayList<String>();
}
this.storage.add(storageItem);
return this;
}
/**
* Lists some, but not necessarily all, storage locations supported by the service. Must be in a valid URL format. e.g. file:///path/to/local/funnel-storage s3://ohsu-compbio-funnel/storage etc.
* @return storage
**/
@ApiModelProperty(value = "Lists some, but not necessarily all, storage locations supported by the service. Must be in a valid URL format. e.g. file:///path/to/local/funnel-storage s3://ohsu-compbio-funnel/storage etc.")
public List<String> getStorage() {
return storage;
}
public void setStorage(List<String> storage) {
this.storage = storage;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TesServiceInfo tesServiceInfo = (TesServiceInfo) o;
return Objects.equals(this.name, tesServiceInfo.name) &&
Objects.equals(this.doc, tesServiceInfo.doc) &&
Objects.equals(this.storage, tesServiceInfo.storage);
}
@Override
public int hashCode() {
return Objects.hash(name, doc, storage);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TesServiceInfo {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" doc: ").append(toIndentedString(doc)).append("\n");
sb.append(" storage: ").append(toIndentedString(storage)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| 29.206061 | 224 | 0.684374 |
e9ba539ed9b8215db6a8631f13ad5074f1e340a8 | 462 | rb | Ruby | lib/migration_data/testing.rb | mpmenne/migration_data | e33293cfde2ed86977cf0dc15e890fe5c125bdd7 | [
"MIT"
] | null | null | null | lib/migration_data/testing.rb | mpmenne/migration_data | e33293cfde2ed86977cf0dc15e890fe5c125bdd7 | [
"MIT"
] | null | null | null | lib/migration_data/testing.rb | mpmenne/migration_data | e33293cfde2ed86977cf0dc15e890fe5c125bdd7 | [
"MIT"
] | null | null | null | require 'rails'
def require_migration(migration_name)
path = MigrationData::ActiveRecord::Migration.migration_dir
all_migrations = ActiveRecord::MigrationContext.new(path).migrations
migration_name += '.rb' unless migration_name.end_with?('.rb')
file = all_migrations.detect do |m|
m.filename.end_with?(migration_name)
end
raise LoadError, "cannot load such file -- #{migration_name}" unless file
require Rails.root.join(file.filename)
end
| 28.875 | 75 | 0.766234 |
1690675883b0339101239d5dd399c1a8c5c2442e | 86 | sql | SQL | microservicio/infraestructura/src/main/resources/sql/videogame/list.sql | Santizgt5/prueba-adn | aa1404529efdb77c0b558f6d0ac851d37ba8668e | [
"Apache-2.0"
] | null | null | null | microservicio/infraestructura/src/main/resources/sql/videogame/list.sql | Santizgt5/prueba-adn | aa1404529efdb77c0b558f6d0ac851d37ba8668e | [
"Apache-2.0"
] | null | null | null | microservicio/infraestructura/src/main/resources/sql/videogame/list.sql | Santizgt5/prueba-adn | aa1404529efdb77c0b558f6d0ac851d37ba8668e | [
"Apache-2.0"
] | null | null | null | select * from videogame inner join company on videogame.companyId = company.company_id | 86 | 86 | 0.837209 |
4574d6e087fa9d0f85aca5127b2f796b1d81011b | 216 | sql | SQL | database.sql | patchon/Pastebin | d961fd6952962aa2e3aea53c45afe4f1071994c8 | [
"MIT"
] | null | null | null | database.sql | patchon/Pastebin | d961fd6952962aa2e3aea53c45afe4f1071994c8 | [
"MIT"
] | null | null | null | database.sql | patchon/Pastebin | d961fd6952962aa2e3aea53c45afe4f1071994c8 | [
"MIT"
] | null | null | null | CREATE TABLE `pastebin` (
`id` varchar(30) NOT NULL,
`title` varchar(50) default NULL,
`hash` char(40) default NULL,
`data` longtext,
`delkey` char(40) default NULL,
`expiry` int,
PRIMARY KEY (`id`)
);
| 21.6 | 35 | 0.643519 |
64ee6bf1f30ce1a83c2705c9a87f13b73ac72bfe | 4,367 | java | Java | graphics/java/android/graphics/ComposeShader.java | rio-31/android_frameworks_base-1 | 091a068a3288d27d77636708679dde58b7b7fd25 | [
"Apache-2.0"
] | 164 | 2015-01-05T16:49:11.000Z | 2022-03-29T20:40:27.000Z | graphics/java/android/graphics/ComposeShader.java | rio-31/android_frameworks_base-1 | 091a068a3288d27d77636708679dde58b7b7fd25 | [
"Apache-2.0"
] | 127 | 2015-01-12T12:02:32.000Z | 2021-11-28T08:46:25.000Z | graphics/java/android/graphics/ComposeShader.java | rio-31/android_frameworks_base-1 | 091a068a3288d27d77636708679dde58b7b7fd25 | [
"Apache-2.0"
] | 1,141 | 2015-01-01T22:54:40.000Z | 2022-02-09T22:08:26.000Z | /*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.graphics;
import android.annotation.NonNull;
/** A subclass of shader that returns the composition of two other shaders, combined by
an {@link android.graphics.Xfermode} subclass.
*/
public class ComposeShader extends Shader {
Shader mShaderA;
private long mNativeInstanceShaderA;
Shader mShaderB;
private long mNativeInstanceShaderB;
private int mPorterDuffMode;
/**
* Create a new compose shader, given shaders A, B, and a combining mode.
* When the mode is applied, it will be given the result from shader A as its
* "dst", and the result from shader B as its "src".
*
* @param shaderA The colors from this shader are seen as the "dst" by the mode
* @param shaderB The colors from this shader are seen as the "src" by the mode
* @param mode The mode that combines the colors from the two shaders. If mode
* is null, then SRC_OVER is assumed.
*/
@Deprecated
public ComposeShader(@NonNull Shader shaderA, @NonNull Shader shaderB, @NonNull Xfermode mode) {
this(shaderA, shaderB, mode.porterDuffMode);
}
/**
* Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
* When the mode is applied, it will be given the result from shader A as its
* "dst", and the result from shader B as its "src".
*
* @param shaderA The colors from this shader are seen as the "dst" by the mode
* @param shaderB The colors from this shader are seen as the "src" by the mode
* @param mode The PorterDuff mode that combines the colors from the two shaders.
*
*/
public ComposeShader(@NonNull Shader shaderA, @NonNull Shader shaderB,
@NonNull PorterDuff.Mode mode) {
this(shaderA, shaderB, mode.nativeInt);
}
/**
* Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
* When the mode is applied, it will be given the result from shader A as its
* "dst", and the result from shader B as its "src".
*
* @param shaderA The colors from this shader are seen as the "dst" by the mode
* @param shaderB The colors from this shader are seen as the "src" by the mode
* @param blendMode The blend mode that combines the colors from the two shaders.
*/
public ComposeShader(@NonNull Shader shaderA, @NonNull Shader shaderB,
@NonNull BlendMode blendMode) {
this(shaderA, shaderB, blendMode.getXfermode().porterDuffMode);
}
private ComposeShader(Shader shaderA, Shader shaderB, int nativeMode) {
if (shaderA == null || shaderB == null) {
throw new IllegalArgumentException("Shader parameters must not be null");
}
mShaderA = shaderA;
mShaderB = shaderB;
mPorterDuffMode = nativeMode;
}
@Override
long createNativeInstance(long nativeMatrix) {
mNativeInstanceShaderA = mShaderA.getNativeInstance();
mNativeInstanceShaderB = mShaderB.getNativeInstance();
return nativeCreate(nativeMatrix,
mShaderA.getNativeInstance(), mShaderB.getNativeInstance(), mPorterDuffMode);
}
/** @hide */
@Override
protected void verifyNativeInstance() {
if (mShaderA.getNativeInstance() != mNativeInstanceShaderA
|| mShaderB.getNativeInstance() != mNativeInstanceShaderB) {
// Child shader native instance has been updated,
// so our cached native instance is no longer valid - discard it
discardNativeInstance();
}
}
private static native long nativeCreate(long nativeMatrix,
long nativeShaderA, long nativeShaderB, int porterDuffMode);
}
| 40.06422 | 100 | 0.67804 |
ca857228299cf7485c0fa3fccc4d6a032b20fe67 | 3,077 | asm | Assembly | lib/target/cpc/classic/loader.asm | ahjelm/z88dk | c4de367f39a76b41f6390ceeab77737e148178fa | [
"ClArtistic"
] | 4 | 2021-12-23T15:34:05.000Z | 2021-12-23T15:36:16.000Z | lib/target/cpc/classic/loader.asm | ahjelm/z88dk | c4de367f39a76b41f6390ceeab77737e148178fa | [
"ClArtistic"
] | 2 | 2022-03-20T22:17:35.000Z | 2022-03-24T16:10:00.000Z | lib/target/cpc/classic/loader.asm | ahjelm/z88dk | c4de367f39a76b41f6390ceeab77737e148178fa | [
"ClArtistic"
] | null | null | null | ;
; CPC bank loader, after @iratahack
;
EXTERN __DATA_END_tail
EXTERN __BANK_0_END_tail
EXTERN __BANK_1_END_tail
EXTERN __BANK_2_END_tail
EXTERN __BANK_3_END_tail
EXTERN __BANK_4_END_tail
EXTERN __BANK_5_END_tail
EXTERN __BANK_6_END_tail
EXTERN __BANK_7_END_tail
; Turn off tape messages
ld a,0
call cas_noisy
ld hl,__crt_loader_filename
find_ext:
ld a,(hl)
cp '.'
inc hl
jr nz,find_ext
inc hl
ld (extension),hl
; This may well contain the loading screen
ld hl,CRT_ORG_BANK_3
ld de,__BANK_3_END_tail - CRT_ORG_BANK_3
ld bc, $33c0 ;bank port, extension
call loadbank
; Probably part of the program as loaded, so not expected to be used
ld hl,CRT_ORG_BANK_0
ld de,__BANK_0_END_tail - CRT_ORG_BANK_0
ld bc,$30c0 ;Bank 0
call loadbank
ld hl,CRT_ORG_BANK_1
ld de,__BANK_1_END_tail - CRT_ORG_BANK_1
ld bc,$31c0 ;Bank 1
call loadbank
ld hl,CRT_ORG_BANK_4
ld de,__BANK_4_END_tail - CRT_ORG_BANK_4
ld bc,$34c4 ;Bank 4
call loadbank
ld hl,CRT_ORG_BANK_5
ld de,__BANK_5_END_tail - CRT_ORG_BANK_5
ld bc,$35c5 ;Bank 5
call loadbank
ld hl,CRT_ORG_BANK_6
ld de,__BANK_6_END_tail - CRT_ORG_BANK_6
ld bc,$36c6 ;Bank 6
call loadbank
ld hl,CRT_ORG_BANK_7
ld de,__BANK_7_END_tail - CRT_ORG_BANK_7
ld bc,$37c7 ;Bank 7
call loadbank
; Load bank2 into screen memory and copy across
; Loading into page2 will clobber ROM vectors
ld hl,49152
ld de,__BANK_2_END_tail - CRT_ORG_BANK_2
ld a,d
or e
ret z
ld bc,$32c0 ;Bank 2
call loadbank
di
ld hl,49152
ld de,$8000
ld bc,__BANK_2_END_tail - CRT_ORG_BANK_2
ldir
ret
; hl = address
; de = length
; c = bank page, b = extension character
loadbank:
ld a,d
or e
ret z
push hl
ld hl,(extension)
ld (hl),b
; Page in the bank
ld b,$7F ;gate array address
out (c),c
ld hl,__crt_loader_filename
call printit
pop de ;de = address to load
ld hl,__crt_loader_filename ;hl = filename
push hl
ld b,0
; Figure out length of filename
get_length:
ld a,(hl)
and a
jr z,length_found
inc hl
inc b
jr get_length
length_found:
pop hl
call cas_in_open ; Load address returned in DE
ex de, hl
call cas_in_direct
call cas_in_close
ld bc,$7fc0
out (c),c
ret
printit:
ld a, (hl)
inc hl
or a
ret z
call txt_output
jr printit
; Populated by appmake
PUBLIC __crt_loader_filename
extension:
defw 0
__crt_loader_filename:
defs 16
| 23.135338 | 72 | 0.570361 |
268922c050a27cabce6e93632815711b2a9df577 | 1,358 | java | Java | core/openapi/src/main/java/io/thorntail/openapi/impl/OpenApiConfigProducer.java | thumb-tack/ | d8f350066bd724de4d2779dcef0676e624f7d412 | [
"Apache-2.0"
] | 1 | 2019-09-23T13:39:49.000Z | 2019-09-23T13:39:49.000Z | core/openapi/src/main/java/io/thorntail/openapi/impl/OpenApiConfigProducer.java | thorntail/thorntail-poc | b123354fc85c4ed27838ff75227e3c1ef7cdc250 | [
"Apache-2.0"
] | 17 | 2019-03-24T05:50:42.000Z | 2022-01-21T23:24:08.000Z | core/openapi/src/main/java/io/thorntail/openapi/impl/OpenApiConfigProducer.java | thumb-tack/tt | d8f350066bd724de4d2779dcef0676e624f7d412 | [
"Apache-2.0"
] | 1 | 2021-08-12T09:23:24.000Z | 2021-08-12T09:23:24.000Z | /**
* Copyright 2018 Red Hat, Inc, and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.thorntail.openapi.impl;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import org.eclipse.microprofile.config.Config;
import io.smallrye.openapi.api.OpenApiConfig;
import io.smallrye.openapi.api.OpenApiConfigImpl;
/**
* @author eric.wittmann@gmail.com
*/
@ApplicationScoped
public class OpenApiConfigProducer {
@Inject
private Config config;
private transient OpenApiConfig oaiConfig;
@PostConstruct
public void init() {
oaiConfig = new OpenApiConfigImpl(config);
}
@Produces
public OpenApiConfig openApiConfig() {
return this.oaiConfig;
}
}
| 27.714286 | 75 | 0.743741 |