diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6621130..34b83115 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,8 +53,11 @@ jobs: - 'src/InputBox/MainForm*.cs' - 'src/InputBox/MainForm.resx' - 'src/InputBox/Core/Controls/**' + - 'src/InputBox/Core/Extensions/ButtonEyeTrackerExtensions.cs' + - 'src/InputBox/Core/Extensions/ControlExtensions.cs' - 'src/InputBox/Resources/**' - 'tests/InputBox.Tests/MainFormUiSmokeTests.cs' + - 'tests/InputBox.Tests/ButtonFeedbackRenderingTests.cs' - 'tests/InputBox.Tests/UiSmokeTestRequirements.cs' - 'tests/InputBox.Tests/UiVisualSnapshot.cs' - 'tests/InputBox.Tests/UiWindowDiscovery.cs' diff --git a/docs/engineering/a11y-safety.md b/docs/engineering/a11y-safety.md index 8a18854b..08e75ef8 100644 --- a/docs/engineering/a11y-safety.md +++ b/docs/engineering/a11y-safety.md @@ -23,6 +23,8 @@ - 按壓狀態:獨立於焦點的第三層級。深色模式使用飽和暖色 (琥珀色 `255,200,120`),亮度差 **ΔL*≥13**。 - **Tritanopia 調整亮度公式**:$L_{tritan} = (R_{lin} \times 0.2126 + G_{lin} \times 0.7152) / 0.9278$。 - **預設動作引導**:當焦點在輸入框時,`AcceptButton` 必須顯示與焦點框一致的情境感知邊框色;強視覺反轉情境使用 **Cyan / MediumBlue**,中性情境使用 **LightBlue / MediumBlue**。 + - 輸入框與預設動作提示須共用情境選色,並在輸入框底色/焦點變更時重繪。Latest 的強調色按鈕不得使提示對比下降;可在提示邊框緊鄰處繪製對比襯底,保留按鈕本體與原生主題外觀,不得改變尺寸、Margin 或 Padding。 + - 測試須量測實際渲染的邊框與相鄰背景,不得只比對顏色名稱;同時覆蓋反轉及中性情境、三種主題與進度條主填色的對比。文件中對比數值為四捨五入顯示,不取代未取整的最低門檻。 - **眼動儀優化與視覺穩定性**: - **視覺凍結 (Zero-Jitter)**:狀態變更嚴禁變動物理尺寸、Margin 或 Padding。 - **抗抖動鎖定 (Anti-Jitter Lock)**:初始化時預先計算 **Bold** 狀態最大寬度並鎖定為 `MinimumSize`。 diff --git a/docs/engineering/git-commit-safety.md b/docs/engineering/git-commit-safety.md index 8db9336c..07683180 100644 --- a/docs/engineering/git-commit-safety.md +++ b/docs/engineering/git-commit-safety.md @@ -33,12 +33,50 @@ - **若簽章失敗**,Agent 應回報錯誤並提醒使用者自行檢查或授權其簽章環境;**不得** 自動修改設定檔案作為修復手段。 - **不得** 為了繞過本機 pinentry、gpg-agent 或終端互動問題,而使用 `--no-gpg-sign`、`git -c commit.gpgsign=false` 等方式提交;除非維護者明確授權,否則應先由使用者調整其簽章環境後再提交。 -## 4. 分支策略與合併守門 -- **採用 main-first 工作流**:`main` 必須隨時保持為可發布版本;每次新功能、修補或熱修開始前,`dev` 必須先同步或重設到目前 `main` 的最新提交,確保兩者起點一致。 -- **合併路徑固定**:功能完成後,必須由 `dev` 提出 Pull Request 合併回 `main`;不得直接將應用程式變更推入 `main`。 -- **CI 為必要守門**:Pull Request 在合併前,必須先確認 `.github/workflows/ci.yml` 全部必要檢查為成功狀態,未通過不得合併。 -- **保留分支但每輪重對齊**:`dev` 分支可保留且 Pull Request 合併完成後**不得刪除**,但下一輪開發開始前必須重新對齊 `main`;不得讓 `dev` 長期累積與 `main` 不一致的未發布差異。 -- **發版來源限制**:建立正式版本標籤時,只能以 `main` 分支最新提交為基準;不得從 `dev`、舊提交或其他分支直接打 tag 發布。 +## 4. Trunk-based 分支策略與合併守門 + +### 4.1 分支角色與開始條件 + +- **`main` 是唯一主幹**,必須隨時保持為可發布版本;`dev` 是保留名稱、每輪重新對齊的開發分支,不是另一條長期整合主幹。 +- 開始工作前先執行 `git fetch origin`,確認工作區、`origin/dev` 與 `origin/main` 的最新狀態。未提交變更或其他人的新提交不得被覆蓋。 +- **`dev` 必須先 rebase 到最新 `origin/main`**:有待發布提交時使用 `git rebase --gpg-sign origin/main`,以使用者既有金鑰簽署重建的提交;沒有待發布差異時依 4.5 對齊。不得以 `git merge origin/main`、`git pull` 產生的 merge 或 GitHub 的 Update branch 合併操作代替。 +- PR 開啟期間若 `main` 前進,必須再次 fetch、簽章 rebase、驗證並更新 `dev`,重新等待最新 SHA 的 CI;不能因先前 CI 已通過便略過同步。 + +### 4.2 線性歷史與 GPG 簽章 + +- **禁止多餘的 merge commit**:不得為同步 `main` 到 `dev` 或將 `dev` 整合回 `main` 新增 merge commit;不得使用 `--no-ff`、GitHub Create a merge commit 或 `--rebase-merges` 保留本輪不必要的分叉。檢查範圍是本輪 `origin/main..dev`,不要求重寫既有主幹歷史。 +- **保留既有 GPG 簽章環境與簽章要求**:新提交使用 `git commit -S`;rebase 會改變提交物件,舊簽章不能原封不動移植,必須用既有金鑰重新簽署,而不是讓重建提交變成未簽章。 +- rebase 後逐筆執行 `git verify-commit `,驗證本輪所有提交;`git rev-list --merges origin/main..dev` 必須沒有輸出。任何簽章失敗都依第 3 節停止,不得修改 GPG 設定或關閉簽章。 +- 發布到 `main` 時必須保留已驗證的提交 SHA 與 GPG 簽章;僅有相同檔案樹、只在 `dev` 留下原簽章,或只看到 GitHub 的 Verified 標籤,均不足以證明符合使用者既有金鑰的簽章要求。 + +### 4.3 推送與 PR 守門 + +- 功能、修補與文件變更均由 `dev` 提出 PR 回到 `main`;不得繞過 PR、必要 CI 或分支保護直接推送主幹。 +- 首次正常推送不需強制;已推送的 `dev` 因 rebase 或對齊而改寫時,先記錄 fetch 後的遠端 SHA,經既有授權後使用 `git push --force-with-lease=refs/heads/dev:<已記錄的遠端 SHA> origin dev`。不得使用不帶保護的 `--force`,不得遇到 lease 失敗就改用新的預期值覆蓋遠端。 +- 合併前必須確認:`origin/main` 是 `dev` 的祖先、本輪無 merge commit、每筆簽章有效,且 PR 最新 head SHA 的全部必要檢查成功;不得使用舊 SHA、取消、仍執行中或僅工作流外層成功的結果代替實際測試通過。 +- `.github/workflows/ci.yml` 所要求的建置與測試均須通過。若某步驟允許 `continue-on-error`,仍須讀取實際日誌,確認測試失敗數為零;MSBuild 不得有警告或錯誤。 + +### 4.4 合併方法與遠端限制 + +- **預設整合語意是 fast-forward**:經 PR 審查與 CI 守門後,讓 `main` 前移到已驗證的 `dev` 提交,不建立額外提交、不改寫 SHA,也不丟失既有 GPG 簽章。 +- **不得直接選用 GitHub Rebase and merge**:GitHub 會重建提交,不能保留原提交的簽章驗證。Squash and merge 也會建立新的提交,不能視為保留原 GPG 簽章的等價方式。一般 Create a merge commit 則違反本節的線性歷史要求。 +- 執行前必須確認實際平台與 repository ruleset 是否提供同時滿足 PR 守門、fast-forward 與保留簽章的整合方式;不得假設 GitHub 標準合併按鈕提供 fast-forward-only。 +- 若現有遠端規則無法同時滿足上述要求,**停止合併並向維護者具體回報衝突**,取得對整合方式或規則調整的明確授權後才可繼續。不得自行改成 merge commit、丟棄簽章、繞過保護或直接推送 `main`。 +- 合併後確認 PR 已 merged、`main` 新增的提交沒有 merge commit、簽章仍有效,並核對合併內容與通過 CI 的版本一致。追蹤合併後實際觸發的所有必要檢查至完成;若建置僅由 PR 觸發,須如實說明,不能聲稱 main push 已重跑建置與測試。 + +### 4.5 合併後立即重新對齊 dev + +- **保留 `dev`,不得刪除;每次 PR 合併完成後就立即對齊 `main`**,不得延後到下一輪開發才處理。 +- 重新 fetch,確認 PR 已合併、工作區沒有未提交變更,且 `dev` 沒有其他尚未發布或他人新增的工作;如有則停止重設並回報,不能直接捨棄。 +- 在已授權重設與推送的範圍內,切到 `dev`,執行 `git reset --hard origin/main`,再以 4.3 的精確 `--force-with-lease` 更新遠端 `dev`。若尚無破壞性操作或外部寫入授權,先取得授權再執行。 +- 完成後驗證本機 `dev`、`origin/dev` 與最新遠端 `main` SHA 完全相同,且工作區乾淨;若主幹又前進或遠端 dev 已變動,重新檢查,不能盲目重設或重試強制推送。 + +### 4.6 發版來源 + +- 正式版本標籤只能從最新遠端 `main` 建立;不得從未整合的 `dev`、舊提交或其他分支打 tag 發布。 +- 標籤依第 3 節使用既有 GPG 環境簽署並驗證,推送後追蹤實際發佈結果;不得只看到 tag 已推送便聲稱 Release 成功。 + +參考:[Git rebase 簽章選項](https://git-scm.com/docs/git-rebase)、[GitHub rebase and merge 的簽章限制](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)、[GitHub 合併方法](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github)。 ## 5. 法律合規工作流 1. 若任務涉及「按鍵處理」、「剪貼簿自動化」或「控制器映射」。 diff --git a/src/InputBox/Core/Extensions/ButtonEyeTrackerExtensions.cs b/src/InputBox/Core/Extensions/ButtonEyeTrackerExtensions.cs index 0486514c..1f6cfd35 100644 --- a/src/InputBox/Core/Extensions/ButtonEyeTrackerExtensions.cs +++ b/src/InputBox/Core/Extensions/ButtonEyeTrackerExtensions.cs @@ -26,7 +26,13 @@ private sealed class ButtonVisualState /// /// 是否按壓按鈕(包含實際的鼠標按壓或鍵盤焦點狀態下的強視覺反饋) /// - public bool IsPressed { get; set; } + public bool IsPressed => IsPointerPressed || IsKeyboardPressed; + + /// 滑鼠按壓狀態,與鍵盤狀態獨立清理。 + public bool IsPointerPressed { get; set; } + + /// Space 按壓狀態,失焦時必須清理。 + public bool IsKeyboardPressed { get; set; } /// /// 凝視進度(Dwell Progress),表示使用者注視按鈕的時間比例 @@ -125,8 +131,48 @@ public static void AttachEyeTrackerFeedback( btn.MouseUp -= HandleButtonMouseUp; btn.MouseUp += HandleButtonMouseUp; + + btn.KeyDown -= HandleButtonKeyDown; + btn.KeyDown += HandleButtonKeyDown; + btn.KeyUp -= HandleButtonKeyUp; + btn.KeyUp += HandleButtonKeyUp; + + btn.SystemColorsChanged -= HandleButtonSystemColorsChanged; + btn.SystemColorsChanged += HandleButtonSystemColorsChanged; + } + + /// Space 按住時套用獨立按下視覺,不攔截原生鍵盤點擊。 + private static void HandleButtonKeyDown(object? sender, KeyEventArgs eventArgs) + { + if (eventArgs.KeyCode == Keys.Space && sender is Button { Enabled: true, Focused: true } button && + _buttonStates.TryGetValue(button, out ButtonVisualState? state) && !state.IsKeyboardPressed) + { + state.IsKeyboardPressed = true; + StartAnimationFeedback(button); + } } + /// Space 放開後還原目前焦點或懸停狀態。 + private static void HandleButtonKeyUp(object? sender, KeyEventArgs eventArgs) + { + if (eventArgs.KeyCode == Keys.Space && sender is Button button && + _buttonStates.TryGetValue(button, out ButtonVisualState? state)) + { + state.IsKeyboardPressed = false; + StopFeedback(button); + } + } + /// + /// 系統色或高對比改變時重新套用目前互動狀態,避免保留上一個配色。 + /// 深淺色模式仍由框架的啟動設定決定,不取代既有重啟提示。 + /// + private static void HandleButtonSystemColorsChanged(object? sender, EventArgs eventArgs) + { + if (sender is Button { IsDisposed: false } button) + { + StopFeedback(button); + } + } /// /// 點擊後重置進度, /// 並執行視線重新接合(Gaze Re-engagement), @@ -230,7 +276,8 @@ private static void HandleButtonLostFocus(object? sender, EventArgs eventArgs) { if (_buttonStates.TryGetValue(btn, out ButtonVisualState? state)) { - state.IsPressed = false; + state.IsPointerPressed = false; + state.IsKeyboardPressed = false; state.OnFocusStateChanged?.Invoke(state.IsHovered); } @@ -279,7 +326,8 @@ private static void HandleButtonMouseLeave(object? sender, EventArgs eventArgs) if (_buttonStates.TryGetValue(btn, out ButtonVisualState? state)) { state.IsHovered = false; - state.IsPressed = false; + state.IsPointerPressed = false; + state.IsKeyboardPressed = false; state.OnFocusStateChanged?.Invoke(btn.Focused); } @@ -299,7 +347,7 @@ private static void HandleButtonMouseDown(object? sender, MouseEventArgs eventAr { if (_buttonStates.TryGetValue(btn, out ButtonVisualState? state)) { - state.IsPressed = true; + state.IsPointerPressed = true; } StartAnimationFeedback(btn); @@ -318,7 +366,7 @@ private static void HandleButtonMouseUp(object? sender, MouseEventArgs eventArgs { if (_buttonStates.TryGetValue(btn, out ButtonVisualState? state)) { - state.IsPressed = false; + state.IsPointerPressed = false; } StartAnimationFeedback(btn); @@ -381,7 +429,6 @@ private static void ApplyStrongVisual(Button btn) $"{st.BaseDescription} ({Strings.A11y_State_Pressed})" : $"{st.BaseDescription} ({Strings.A11y_State_Focused})"; - btn.Padding = new Padding(0); btn.Invalidate(); } @@ -416,7 +463,7 @@ private static void StartAnimationFeedback(Button btn) if (SystemInformation.HighContrast) { - btn.BackColor = SystemColors.HotTrack; + btn.BackColor = SystemColors.Highlight; btn.ForeColor = SystemColors.HighlightText; } else @@ -441,7 +488,6 @@ private static void StartAnimationFeedback(Button btn) btn.AccessibleDescription = $"{st.BaseDescription} ({Strings.A11y_State_Hover})"; - btn.Padding = new Padding(0); btn.Invalidate(); btn.RunDwellAnimationAsync( @@ -468,16 +514,16 @@ private static void StopFeedback(Button btn) st.DwellProgress = 0f; - if (btn.Focused) + if (st.IsHovered || st.IsPressed) { - ApplyStrongVisual(btn); + StartAnimationFeedback(btn); return; } - if (st.IsHovered) + if (btn.Focused) { - StartAnimationFeedback(btn); + ApplyStrongVisual(btn); return; } @@ -499,6 +545,36 @@ private static void StopFeedback(Button btn) btn.Invalidate(); } + /// + /// 為現有文字按鈕繪製一致的互動配色,不受 Net11 預設動作強調色覆蓋。 + /// + /// 目前處於自訂回饋狀態的按鈕。 + /// 按鈕繪圖內容。 + private static void DrawFeedbackSurface(Button button, Graphics graphics) + { + using Brush background = new SolidBrush(button.BackColor); + graphics.FillRectangle(background, button.ClientRectangle); + + int inset = (int)Math.Ceiling(4 * button.DeviceDpi / AppSettings.BaseDpi); + Rectangle textBounds = Rectangle.FromLTRB( + inset + button.Padding.Left, inset + button.Padding.Top, + button.Width - inset - button.Padding.Right, button.Height - inset - button.Padding.Bottom); + TextFormatFlags flags = TextFormatFlags.HorizontalCenter | + TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak | + TextFormatFlags.PreserveGraphicsClipping; + if (!button.UseMnemonic) + { + flags |= TextFormatFlags.NoPrefix; + } + + if (button.RightToLeft == RightToLeft.Yes) + { + flags |= TextFormatFlags.RightToLeft; + } + + TextRenderer.DrawText(graphics, button.Text, button.Font, textBounds, button.ForeColor, flags); + } + /// /// 負責接管原生的 Paint 事件以繪製包含基礎邊框、 /// 互動邊框、對比色、與 Dwell 進度條的所有按鈕客製化視覺 @@ -530,6 +606,14 @@ private static void HandleButtonPaint(object? sender, PaintEventArgs e) return; } + // Net11 的預設按鈕強制使用強調色背景,但仍接受自訂文字色。 + // 自訂回饋期間成對繪製背景與文字,避免背景被覆寫而失去對比; + // 高對比的一般狀態也保留系統色配對;其他一般與停用狀態沿用原生渲染。 + if (st != null && (SystemInformation.HighContrast || st.IsPressed || isFocused || isHoveredOrDwell)) + { + DrawFeedbackSurface(btn, g); + } + Form? parentForm = btn.FindForm(); bool isDefault = parentForm != null && @@ -552,13 +636,28 @@ parentForm.ActiveControl is not Button && isDefault) { Color borderColor = btn.GetButtonInteractiveBorderColor(isStrongVisual, isDark); + Color? backingColor = null; + if (isDefault && !isFocused && !isHoveredOrDwell && !(st?.IsPressed ?? false)) + { + Control? context = parentForm?.ActiveControl; + while (context is ContainerControl { ActiveControl: not null } container) + { + context = container.ActiveControl; + } + + (Color Border, Color Backing) = ControlExtensions.GetContextualFocusColors( + context?.BackColor ?? Color.Empty, isDark); + borderColor = Border; + backingColor = Backing; + } btn.DrawButtonInteractiveBorder( g, borderColor, scale, out int inset, - out int borderThickness); + out int borderThickness, + backingColor); if (!SystemInformation.HighContrast && (st?.IsPressed ?? false)) diff --git a/src/InputBox/Core/Extensions/ControlExtensions.cs b/src/InputBox/Core/Extensions/ControlExtensions.cs index 374153ec..faa37e61 100644 --- a/src/InputBox/Core/Extensions/ControlExtensions.cs +++ b/src/InputBox/Core/Extensions/ControlExtensions.cs @@ -512,6 +512,33 @@ public static void DrawButtonBaseBorder( graphics.DrawRectangle(basePen, 0, 0, button.Width - 1, button.Height - 1); } + /// + /// 取得輸入焦點與預設動作共用的提示色及對比襯底,保留專案四種情境配色。 + /// + /// 焦點控制項實際背景。 + /// 目前深色模式。 + /// 提示邊框色與緊鄰邊框的對比襯底。 + internal static (Color Border, Color Backing) GetContextualFocusColors(Color background, bool isDark) + { + if (SystemInformation.HighContrast) + { + return (SystemColors.Highlight, SystemColors.HighlightText); + } + + if (background.ToArgb() == Color.Black.ToArgb()) + { + return (Color.Cyan, Color.Black); + } + + if (background.ToArgb() == Color.White.ToArgb()) + { + return (Color.MediumBlue, Color.White); + } + + return isDark ? + (Color.LightBlue, Color.FromArgb(60, 60, 60)) : + (Color.MediumBlue, Color.FromArgb(220, 220, 220)); + } /// /// 依互動情境取得焦點/懸停邊框色。 /// @@ -523,7 +550,8 @@ public static Color GetButtonInteractiveBorderColor(this Button button, bool isS { if (SystemInformation.HighContrast) { - return SystemColors.HighlightText; + return button.BackColor.ToArgb() == SystemColors.Highlight.ToArgb() ? + SystemColors.HighlightText : SystemColors.ControlText; } static bool IsSameColor(Color left, Color right) => left.ToArgb() == right.ToArgb(); @@ -557,17 +585,25 @@ public static Color GetButtonInteractiveBorderColor(this Button button, bool isS /// 目前 DPI 縮放比例。 /// 輸出的內縮像素數,供後續繪製疊層使用。 /// 輸出的邊框厚度,供後續繪製疊層使用。 + /// 預設動作提示的對比襯底;不改變控制項尺寸或內距。 public static void DrawButtonInteractiveBorder( this Button button, Graphics graphics, Color borderColor, float scale, out int inset, - out int borderThickness) + out int borderThickness, + Color? backingColor = null) { borderThickness = (int)Math.Max(3, 3 * scale); inset = (int)Math.Max(2, 2 * scale); + if (backingColor is Color backing) + { + using Pen backingPen = new(backing, borderThickness + 2 * Math.Max(1f, scale)); + graphics.DrawRectangle(backingPen, inset, inset, + button.Width - (inset * 2) - 1, button.Height - (inset * 2) - 1); + } using Pen borderPen = new(borderColor, borderThickness); graphics.DrawRectangle( diff --git a/src/InputBox/MainForm.Events.cs b/src/InputBox/MainForm.Events.cs index fab9a09f..2397aa10 100644 --- a/src/InputBox/MainForm.Events.cs +++ b/src/InputBox/MainForm.Events.cs @@ -1633,42 +1633,17 @@ private void UpdateBorderColor(bool isFocused) // 情境感知焦點邊框色(Context-Aware Focus Border Color): // 依據 TBInput.BackColor 實際值動態選取,確保在強視覺(反轉底色) // 與中性(懸停灰)兩種狀態下皆達 WCAG AA(≥ 4.5:1)以上。 - Color borderColor; - - if (SystemInformation.HighContrast) - { - borderColor = SystemColors.Highlight; - } - else if (TBInput.BackColor == Color.Black) - { - // 淺色強視覺(黑底)16.75:1 AAA。 - borderColor = Color.Cyan; - } - else if (TBInput.BackColor == Color.White) - { - // 深色強視覺(白底)11.16:1 AAA。 - borderColor = Color.MediumBlue; - } - else if (TBInput.IsDarkModeActive()) - { - // TBInput 尚未反轉,視為深色中性背景。 - // 深色中性 / 懸停 ≥ 7.2:1 AAA。 - borderColor = Color.LightBlue; - } - else - { - // TBInput 尚未反轉,視為淺色中性背景。 - // 淺色中性 / 懸停 8.14:1 AAA。 - borderColor = Color.MediumBlue; - } - - PInputHost.BackColor = borderColor; + PInputHost.BackColor = ControlExtensions.GetContextualFocusColors( + TBInput.BackColor, TBInput.IsDarkModeActive()).Border; } else { // 失去焦點:還原為透明/預設色。 PInputHost.BackColor = Color.Empty; } + + // 預設動作提示依輸入框實際底色同步,包含反轉與高對比變更。 + BtnCopy.Invalidate(); } /// diff --git a/tests/InputBox.Tests/ButtonFeedbackRenderingTests.cs b/tests/InputBox.Tests/ButtonFeedbackRenderingTests.cs new file mode 100644 index 00000000..753afc1d --- /dev/null +++ b/tests/InputBox.Tests/ButtonFeedbackRenderingTests.cs @@ -0,0 +1,487 @@ +using InputBox.Core.Extensions; +using System.Reflection; +using System.Runtime.ExceptionServices; +using Xunit; + +namespace InputBox.Tests; + +/// +/// 驗證 Latest 預設按鈕的實際像素與自訂互動配色一致,避免強調色覆寫背景。 +/// +[Collection(UiSmokeTestRequirements.CollectionName)] +[Trait("Category", "UI")] +public sealed class ButtonFeedbackRenderingTests +{ + /// + /// 在獨立測試程序中選擇淺色或深色,讓同一組像素檢查覆蓋兩種渲染路徑。 + /// + static ButtonFeedbackRenderingTests() + { + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); + Application.SetColorMode(Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_TEST_DARK") == "1" ? + SystemColorMode.Dark : SystemColorMode.Classic); + } + + /// + /// 預設與一般按鈕的焦點、懸停、按下背景及文字應成對呈現,且互動不改變尺寸或內距。 + /// + [Theory(Skip = "Requires explicit UI test opt-in.", + SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + [InlineData(true, "focus")] + [InlineData(true, "hover")] + [InlineData(true, "pressed")] + [InlineData(false, "focus")] + [InlineData(false, "hover")] + [InlineData(false, "pressed")] + [InlineData(true, "focus-hover")] + [InlineData(false, "focus-hover")] + [InlineData(true, "keyboard-pressed")] + [InlineData(false, "keyboard-pressed")] + [InlineData(true, "keyboard-release")] + [InlineData(false, "keyboard-release")] + [InlineData(true, "keyboard-cancel")] + [InlineData(false, "keyboard-cancel")] + public void Render_InteractiveState_PreservesCustomContrast(bool isDefault, string state) + { + RunSta(() => + { + using var form = new Form(); + using var input = new TextBox(); + using var bold = new Font(form.Font, FontStyle.Bold); + using var button = new FeedbackButton + { + Text = "Button text", + Bounds = new Rectangle(10, 50, 240, 90), + FlatStyle = FlatStyle.Flat, + VisualStylesMode = VisualStylesMode.Latest, + Padding = new Padding(7) + }; + using var lifetime = new CancellationTokenSource(); + form.Controls.AddRange([input, button]); + button.AttachEyeTrackerFeedback("Button", button.Font, bold, lifetime.Token); + if (isDefault) + { + form.AcceptButton = button; + } + + form.Show(); + form.Activate(); + Application.DoEvents(); + input.Focus(); + if (state == "focus") + { + Assert.True(button.Focus()); + } + else if (state == "hover") + { + button.Hover(); + Assert.NotEqual(form.BackColor, button.BackColor); + } + else + { + Assert.True(button.Focus()); + if (state == "focus-hover") + { + button.Hover(); + } + else if (state.StartsWith("keyboard", StringComparison.Ordinal)) + { + button.PressSpace(); + if (state == "keyboard-release") + { + button.ReleaseSpace(); + } + else if (state == "keyboard-cancel") + { + Assert.True(input.Focus()); + Assert.True(button.Focus()); + } + } + else + { + button.Press(); + } + } + bool hovered = state is "hover" or "focus-hover"; + bool pressed = state is "pressed" or "keyboard-pressed"; + + button.BackColor = Color.Magenta; + button.ForeColor = Color.Magenta; + button.RefreshSystemColors(); + Assert.NotEqual(Color.Magenta, button.BackColor); + if (!SystemInformation.HighContrast) + { + bool dark = button.IsDarkModeActive(); + Color expectedBackground = pressed ? (dark ? Color.FromArgb(255, 200, 120) : Color.FromArgb(28, 28, 28)) : + hovered ? (dark ? Color.FromArgb(60, 60, 60) : Color.FromArgb(220, 220, 220)) : + (dark ? Color.White : Color.Black); + Assert.Equal(expectedBackground, button.BackColor); + } + + using var bitmap = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(bitmap, button.ClientRectangle); + string? artifacts = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (artifacts != null) + { + Directory.CreateDirectory(artifacts); + bitmap.Save(Path.Combine(artifacts, $"{isDefault}-{state}.png")); + } + Assert.Equal(button.BackColor.ToArgb(), bitmap.GetPixel(25, 20).ToArgb()); + int textPixels = 0; + for (int y = 25; y < 65; y++) + { + for (int x = 35; x < 205; x++) + { + if (bitmap.GetPixel(x, y).ToArgb() == button.ForeColor.ToArgb()) + { + textPixels++; + } + } + } + + Color border = button.GetButtonInteractiveBorderColor(!hovered, button.IsDarkModeActive()); + Assert.Equal(border.ToArgb(), bitmap.GetPixel(2, 20).ToArgb()); + double borderMinimum = SystemInformation.HighContrast || pressed ? 3 : + !hovered ? (button.IsDarkModeActive() ? 11.16 : 16.75) : + (button.IsDarkModeActive() ? 7.2 : 8.14); + double borderContrast = Contrast(bitmap.GetPixel(2, 20), bitmap.GetPixel(0, 20)); + Assert.True(borderContrast >= 3 && borderContrast + 0.005 >= borderMinimum); + Assert.Equal(!hovered, button.Font.Bold); + if (pressed && button.IsDarkModeActive() && !SystemInformation.HighContrast) + { + double red = LinearComponent(button.BackColor.R); + double green = LinearComponent(button.BackColor.G); + double tritanLuminance = (red * 0.2126 + green * 0.7152) / 0.9278; + double lightness = 116 * Math.Cbrt(tritanLuminance) - 16; + Assert.True(100 - lightness >= 13); + } + Assert.True(Contrast(button.BackColor, button.ForeColor) >= 4.5); + Assert.True(textPixels > 10, "自訂文字色沒有實際繪製到按鈕。"); + Assert.Equal(new Padding(7), button.Padding); + Assert.Equal(new Size(240, 90), button.Size); + Assert.Equal(SystemInformation.HighContrast ? VisualStylesMode.Classic : VisualStylesMode.Latest, button.ResolvedMode); + lifetime.Cancel(); + }); + } + + /// + /// 回饋結束後必須還原環境配色,不得留下硬編碼顏色或破壞主題渲染。 + /// + [Theory(Skip = "Requires explicit UI test opt-in.", + SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + [InlineData(true)] + [InlineData(false)] + public void Render_AfterMouseLeave_RestoresAmbientColors(bool isDefault) + { + RunSta(() => + { + using var form = new Form(); + using var input = new TextBox(); + using var button = new FeedbackButton + { + Text = "Button text", Bounds = new Rectangle(10, 50, 240, 90), + FlatStyle = FlatStyle.Flat, VisualStylesMode = VisualStylesMode.Latest + }; + using var lifetime = new CancellationTokenSource(); + form.Controls.AddRange([input, button]); + button.AttachEyeTrackerFeedback("Button", null, null, lifetime.Token); + if (isDefault) + { + form.AcceptButton = button; + } + + form.Show(); + form.Activate(); + Application.DoEvents(); + input.Focus(); + button.Press(); + button.ExitHover(); + Assert.Equal(form.BackColor, button.BackColor); + Assert.Equal(form.ForeColor, button.ForeColor); + CheckNeutralRendering(button, isDefault); + button.Enabled = false; + CheckNeutralRendering(button, isDefault); + lifetime.Cancel(); + }); + } + + /// + /// 預設動作邊框須跟隨輸入框反轉/中性背景,並在實際相鄰襯底達到專案對比目標。 + /// + [Theory(Skip = "Requires explicit UI test opt-in.", + SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + [InlineData(true)] + [InlineData(false)] + public void Render_DefaultAction_MatchesInputContextWithContrast(bool strong) + { + RunSta(() => + { + bool dark = Application.IsDarkModeEnabled; + Color contextColor = strong ? (dark ? Color.White : Color.Black) : + (dark ? Color.FromArgb(60, 60, 60) : Color.FromArgb(220, 220, 220)); + using var form = new Form(); + using var input = new TextBox { BackColor = contextColor }; + using var button = new FeedbackButton + { + Text = "Button text", Bounds = new Rectangle(10, 50, 240, 90), + FlatStyle = FlatStyle.Flat, VisualStylesMode = VisualStylesMode.Latest + }; + using var lifetime = new CancellationTokenSource(); + form.Controls.AddRange([input, button]); + form.AcceptButton = button; + button.AttachEyeTrackerFeedback("Button", null, null, lifetime.Token); + form.Show(); + Assert.True(input.Focus()); + Assert.Same(input, form.ActiveControl); + Color expected = SystemInformation.HighContrast ? SystemColors.Highlight : + strong ? (dark ? Color.MediumBlue : Color.Cyan) : + (dark ? Color.LightBlue : Color.MediumBlue); + using var bitmap = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(bitmap, button.ClientRectangle); + Assert.Equal(expected.ToArgb(), bitmap.GetPixel(2, 20).ToArgb()); + double minimum = SystemInformation.HighContrast ? 3 : + strong ? (dark ? 11.16 : 16.75) : (dark ? 7.2 : 8.14); + double contrast = Contrast(bitmap.GetPixel(2, 20), bitmap.GetPixel(0, 20)); + Assert.True(contrast >= 3 && contrast + 0.005 >= minimum, $"預設動作邊框對比不足:{contrast:F3} < {minimum}"); + Assert.Equal(new Size(240, 90), button.Size); + string? artifacts = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (artifacts != null) + { + Directory.CreateDirectory(artifacts); + bitmap.Save(Path.Combine(artifacts, $"default-context-{strong}.png")); + File.AppendAllText(Path.Combine(artifacts, "contrast.txt"), $"default strong={strong}, dpi={button.DeviceDpi}: {contrast:F3}:1{Environment.NewLine}"); + } + lifetime.Cancel(); + }); + } + + /// + /// 凝視進度條須依實際底色選用 Green/LimeGreen,保留色覺紋理並達至少 3:1。 + /// + [Theory(Skip = "Requires explicit UI test opt-in.", + SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + [InlineData(0)] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + public void Render_Dwell_UsesActualBackgroundWithNonTextContrast(int palette) + { + RunSta(() => + { + Color[] backgrounds = [Color.White, Color.Black, Color.FromArgb(220, 220, 220), Color.FromArgb(60, 60, 60)]; + using var form = new Form(); + using var input = new TextBox(); + using var button = new FeedbackButton + { + Text = "Button text", Bounds = new Rectangle(10, 50, 240, 90), + FlatStyle = FlatStyle.Flat, VisualStylesMode = VisualStylesMode.Latest + }; + using var lifetime = new CancellationTokenSource(); + form.Controls.AddRange([input, button]); + button.AttachEyeTrackerFeedback("Button", null, null, lifetime.Token); + form.Show(); + input.Focus(); + button.Hover(); + button.CancelDwellAnimation(); + button.BackColor = SystemInformation.HighContrast ? SystemColors.Highlight : backgrounds[palette]; + button.SetProgress(0.5f); + using var bitmap = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(bitmap, button.ClientRectangle); + Color fill = SystemInformation.HighContrast ? SystemColors.HighlightText : + palette is 0 or 2 ? Color.Green : Color.LimeGreen; + Color texture = palette is 0 or 2 ? Color.PaleGreen : Color.DarkGreen; + int fillPixels = 0; + int texturePixels = 0; + for (int y = button.Height - 5; y < button.Height; y++) + { + for (int x = 10; x < 110; x++) + { + Color actual = bitmap.GetPixel(x, y); + int pixel = actual.ToArgb(); + if (pixel == fill.ToArgb()) + { + fillPixels++; + } + if (pixel != fill.ToArgb() && IsTextureBlend(actual, fill, texture)) + { + texturePixels++; + } + } + } + string? debugArtifacts = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (debugArtifacts != null) + { + Directory.CreateDirectory(debugArtifacts); + bitmap.Save(Path.Combine(debugArtifacts, $"dwell-{palette}.png")); + } + Assert.True(fillPixels > 100); + Assert.True(SystemInformation.HighContrast || texturePixels > 20); + double contrast = Contrast(fill, bitmap.GetPixel(25, 20)); + double[] targets = [5.14, 9.91, 3.75, 5.21]; + Assert.True(contrast >= 3 && contrast + 0.005 >= (SystemInformation.HighContrast ? 3 : targets[palette]), $"進度條對比不足:{contrast:F3}"); + string? artifacts = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (artifacts != null) + { + Directory.CreateDirectory(artifacts); + bitmap.Save(Path.Combine(artifacts, $"dwell-{palette}.png")); + File.AppendAllText(Path.Combine(artifacts, "contrast.txt"), $"dwell palette={palette}: {contrast:F3}:1{Environment.NewLine}"); + } + lifetime.Cancel(); + }); + } + /// + /// 沒有文字的停用按鈕即使保有斜線裝飾,也必須被文字檢查拒絕。 + /// + [Fact(Skip = "Requires explicit UI test opt-in.", + SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + public void Render_DisabledWithoutText_DoesNotPassTextCheck() + { + RunSta(() => + { + using var form = new Form(); + using var button = new FeedbackButton + { + Text = string.Empty, Bounds = new Rectangle(10, 50, 240, 90), + Enabled = false, FlatStyle = FlatStyle.Flat, VisualStylesMode = VisualStylesMode.Latest + }; + using var lifetime = new CancellationTokenSource(); + form.Controls.Add(button); + button.AttachEyeTrackerFeedback("Button", null, null, lifetime.Token); + form.Show(); + Assert.Throws(() => CheckNeutralRendering(button, false)); + lifetime.Cancel(); + }); + } + /// + /// 確認一般及停用狀態仍由 Latest 繪製可辨識文字,並保留實際像素供人工檢視。 + /// + private static void CheckNeutralRendering(Button button, bool isDefault) + { + string caption = button.Text; + button.Text = string.Empty; + using var baseline = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(baseline, button.ClientRectangle); + button.Text = caption; + using var bitmap = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(bitmap, button.ClientRectangle); + button.Text = string.Empty; + using var after = new Bitmap(button.Width, button.Height); + button.DrawToBitmap(after, button.ClientRectangle); + button.Text = caption; + int textPixels = 0; + Color background = bitmap.GetPixel(25, 20); + double contrast = 1; + for (int y = 30; y < 60; y++) + { + for (int x = 35; x < 205; x++) + { + Color pixel = bitmap.GetPixel(x, y); + if (baseline.GetPixel(x, y).ToArgb() == after.GetPixel(x, y).ToArgb() && + pixel.ToArgb() != baseline.GetPixel(x, y).ToArgb()) + { + textPixels++; + contrast = Math.Max(contrast, Contrast(background, pixel)); + } + } + } + + Assert.True(textPixels > 10, "排除裝飾後未找到文字像素。"); + Assert.True(contrast >= (button.Enabled ? 4.5 : 1.5), $"按鈕文字無法辨識:contrast={contrast}"); + string? artifacts = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (artifacts != null) + { + Directory.CreateDirectory(artifacts); + bitmap.Save(Path.Combine(artifacts, $"{isDefault}-enabled-{button.Enabled}.png")); + } + } + /// + /// HatchBrush 在 DPI 縮放時會混合紋理與填色,檢查實際像素仍落於指定色對的範圍。 + /// + private static bool IsTextureBlend(Color pixel, Color fill, Color texture) + { + static bool Between(byte value, byte first, byte second) => + value >= Math.Min(first, second) && value <= Math.Max(first, second); + return Between(pixel.R, fill.R, texture.R) && + Between(pixel.G, fill.G, texture.G) && Between(pixel.B, fill.B, texture.B); + } + /// + /// 取得 sRGB 分量的線性值,供色覺友善的按下亮度差驗證使用。 + /// + private static double LinearComponent(byte component) + { + double value = component / 255.0; + return value <= 0.04045 ? value / 12.92 : Math.Pow((value + 0.055) / 1.055, 2.4); + } + /// + /// 以 WCAG 相對亮度檢查實際文字與背景的對比,不以色彩名稱推測可讀性。 + /// + private static double Contrast(Color background, Color foreground) + { + static double Linear(byte component) + { + double value = component / 255.0; + return value <= 0.04045 ? value / 12.92 : Math.Pow((value + 0.055) / 1.055, 2.4); + } + + static double Luminance(Color color) => + 0.2126 * Linear(color.R) + 0.7152 * Linear(color.G) + 0.0722 * Linear(color.B); + double back = Luminance(background); + double fore = Luminance(foreground); + return (Math.Max(back, fore) + 0.05) / (Math.Min(back, fore) + 0.05); + } + /// + /// 將 WinForms 驗證隔離於 STA,並將背景執行緒的實際失敗傳回測試執行緒。 + /// + private static void RunSta(Action action) + { + Exception? failure = null; + var thread = new Thread(() => + { + try + { + action(); + } + catch (Exception ex) + { + failure = ex; + } + }); + thread.SetApartmentState(ApartmentState.STA); + thread.Start(); + thread.Join(); + if (failure != null) + { + ExceptionDispatchInfo.Capture(failure).Throw(); + } + } + + /// + /// 僅在測試控制項本身觸發事件,不向任何其他視窗模擬輸入。 + /// + private sealed class FeedbackButton : Button + { + public VisualStylesMode ResolvedMode => EffectiveVisualStylesMode; + public void Hover() + { + // 僅驗證繪製:不依賴 Windows 是否允許測試主機搶到前景。 + object table = typeof(ButtonEyeTrackerExtensions).GetField("_buttonStates", BindingFlags.Static | BindingFlags.NonPublic)!.GetValue(null)!; + object?[] args = [this, null]; + table.GetType().GetMethod("TryGetValue")!.Invoke(table, args); + object state = args[1]!; + state.GetType().GetProperty("IsHovered")!.SetValue(state, true); + typeof(ButtonEyeTrackerExtensions).GetMethod("StartAnimationFeedback", BindingFlags.Static | BindingFlags.NonPublic)!.Invoke(null, [this]); + } + public void SetProgress(float progress) + { + object table = typeof(ButtonEyeTrackerExtensions).GetField("_buttonStates", BindingFlags.Static | BindingFlags.NonPublic)!.GetValue(null)!; + object?[] args = [this, null]; + table.GetType().GetMethod("TryGetValue")!.Invoke(table, args); + args[1]!.GetType().GetProperty("DwellProgress")!.SetValue(args[1], progress); + } + public void PressSpace() => OnKeyDown(new KeyEventArgs(Keys.Space)); + public void ReleaseSpace() => OnKeyUp(new KeyEventArgs(Keys.Space)); + public void RefreshSystemColors() => OnSystemColorsChanged(EventArgs.Empty); + public void Press() => OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + public void ExitHover() => OnMouseLeave(EventArgs.Empty); + } +} \ No newline at end of file diff --git a/tests/InputBox.Tests/README.md b/tests/InputBox.Tests/README.md index 5bc07029..fde2ea79 100644 --- a/tests/InputBox.Tests/README.md +++ b/tests/InputBox.Tests/README.md @@ -50,7 +50,8 @@ | `TextBoxSelectionExtensionsTests` | 右搖桿延伸選取共用的 `ResolveSelectionAnchor` 錨點解析(無選取、正向、反向、錨點失效)與 `GetWordJumpTarget` 單字跳轉目標(不改變目前選取、方向與邊界);原本三處複本集中後的一致性保護 | 6 | | `VibrationPatternsTests` | `VibrationPatterns` 與方向性震動設定、語意情境解析、能力感知的多段式微震動序列,以及歷程滾輪阻尼感、字數上限硬牆、震動強度預覽、右搖桿選取粒度、組合鍵進入提示與喚起握手回饋的回歸保護 | 37 | | `VibrationSafetyLimiterTests` | `VibrationSafetyLimiter` 熱保護、Duty Cycle 限制器與極端邊界保護;馬達數量熱成本倍率正規化,以及所有內建震動模式在冷啟動下不得被拒絕、單次超出預算改為降強度,以及Critical 自動連發(含不同模式交錯)降級、熱負載不失控,以及冷啟動短序列仍完整送出的回歸保護 | 20 | -| **合計** | | **467** | +| `ButtonFeedbackRenderingTests` | Latest 預設/一般按鈕實際文字與背景、焦點/預設動作同步及對比襯底、四種底色進度條與色覺紋理、粗體、按下亮度差、零抖動與配色還原、焦點懸停組合、Space 按放/失焦及空文字反例 | 23 | +| **合計** | | **490** | ## 二、執行方式 🚀 @@ -176,3 +177,28 @@ UI 測試宿主在啟動 UIA 前使用 Application.SetHighDpiMode(PerMonitorV2) 最終 dev 正式 System + Latest + Deferred 路徑於 125%/120 DPI 為 11/11,非 UI 回歸為 456/456,行覆蓋率 32.58%。Release 建置使用 -warnaserror 為 0 警告/0 錯誤;完整 style 與 analyzers 的 severity info 檢查報告皆為空清單。七語系資源的鍵名與格式預留位置一致;Xbox 使用模式術語已對齊文件與網站,應用程式資源未發現舊稱,控制器 Xbox 配置名稱維持既有語意。 合規查核(2026-11-14):以可執行 JavaScript 的官方頁面確認 FFXIV 使用者合約、USERJOY 使用條款與隱私政策,並讀取第三方授權及免責聲明。此次輸入相關來源僅清理多餘初值、索引與必要回呼參數名稱,保持既有剪貼簿輸出邊界與控制器行為。 + +## .NET 11 Latest 按鈕配色回歸(2026-11-14) + +`ButtonFeedbackRenderingTests` 是需 `INPUTBOX_RUN_UI_TESTS=1` 才執行的 23 項 UI 測試。它以實際點陣圖檢查預設/一般按鈕的焦點、懸停、按下背景、文字及焦點邊框,並檢查文字對比至少 4.5:1、尺寸/內距不變,以及回饋結束後的一般/停用外觀。停用狀態只檢查文字仍可辨識,不套用一般可操作文字的 4.5:1 門檻。 + +以獨立測試程序分別執行淺色與深色(測試主機設定 `INPUTBOX_BUTTON_TEST_DARK=1`);高對比必須實際啟用 Windows 高對比,並在驗證後還原。`Latest` 在高對比下由框架解析為 `Classic`,測試保留此無障礙行為。這些測試只改變測試控制項的狀態,不向其他視窗送出模擬輸入。`INPUTBOX_BUTTON_ARTIFACTS` 可指定點陣圖輸出目錄。 + +缺陷來源是 Net11 的預設按鈕強調色會優先於自訂背景,但自訂文字色仍生效;回饋期間改為成對繪製既有背景與文字,再疊加既有焦點/按下提示。高對比使用配對的系統色,一般非高對比及停用狀態保留原生渲染。全域 Latest、System 色彩模式、Deferred 首次顯示與必要的主題重啟提示均保留。 + +參考:[.NET 11.0.0 ButtonDarkModeAdapter](https://github.com/dotnet/winforms/blob/v11.0.0/src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/ButtonInternal/DarkMode/ButtonDarkModeAdapter.cs)。 + +前一輪配色修正驗證:淺色、深色與實際 Windows 高對比各 8/8;完整 UI 19/19、非 UI 456/456;Release -warnaserror 建置 0 警告/0 錯誤。修改 C# 的 style/analyzers severity info 報告均為空;高對比設定已還原。暫時略過配色修正時,像素測試有 6 項失敗,確認可偵測原本缺陷。系統色變更會重套目前回饋;主題重啟提示相關程式碼未移除,既有回歸測試通過。 + +預設動作提示補強:輸入框與 AcceptButton 共用情境選色。Latest 按鈕本體保留原生強調色,提示邊框加入固定像素的對比襯底;不改變尺寸、Margin 或 Padding。回歸測試以實際邊框及緊鄰襯底像素驗證反轉 16.75/11.16:1、中性 8.14/至少 7.2:1;四種底色進度條主填色對比為 5.14/9.91/3.75/5.21:1,另檢查色覺紋理仍有實際像素。HatchBrush 的縮放抗鋸齒像素允許落在指定填色與紋理色的混色範圍;不將裝飾紋理每個像素誤當成主填色對比門檻。 + +測試另外驗證焦點粗體、按下第三層視覺及深色琥珀色 Tritanopia ΔL*≥13。文件比值顯示到小數兩位,數值斷言僅容許四捨五入的 0.005 差距;4.5:1 文字及 3:1 非文字最低門檻不因顯示取整而降低。 + +補強後最終驗證(實際 125%/120 DPI):淺色、深色及 Windows 高對比各 14/14;完整 UI 25/25、非 UI 456/456;Release -warnaserror 建置 0 警告/0 錯誤;四個修改 C# 的 severity info style/analyzers 報告均為空。預設動作提示實測:淺色反轉 16.748:1/中性 8.139:1,深色反轉 11.161:1/中性 7.218:1,高對比 7.893:1。進度條四種底色實測 5.137/9.914/3.746/5.208:1,高對比 7.893:1。已還原 Windows 高對比狀態;必要重啟提示與其既有回歸測試保留。 + + +PR #92 審查補強:重新套色時保留焦點與懸停組合,Space 與滑鼠按壓狀態獨立追蹤、放開與失焦時清理,不攔截原生點擊。停用文字改以繪製前後的空文字基準排除裝飾及動畫像素,並加入空文字必須被拒絕的反例。 + +即時安全邊界檢查:本次 Space 事件僅更新 InputBox 自己按鈕的視覺狀態,不模擬輸入、不攔截外部輸入、不改變剪貼簿或第三方程式行為。已抓取工程規範列出的五個官方網址;FFXIV 合約與 USERJOY 隱私/使用條款僅取得頁面框架,未能擷取完整本文,因此不宣稱完整條款審查通過,亦不進行高風險核心輸入/輸出異動。 + +審查修正驗證:按鈕三種主題各 23 項(淺色包含於完整 UI 執行),完整 UI 34/34、非 UI 456/456;Release -warnaserror 為 0 警告/0 錯誤。高對比已還原,未改變原生 Space 點擊及輸出邊界。