Unreviewed, rolling out r251081.

Broke macOS and iOS builds.

Reverted changeset:

"transform-box: content-box, stroke-box missing"
https://bugs.webkit.org/show_bug.cgi?id=201892
https://trac.webkit.org/changeset/251081

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5e56fc0..790234e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-14  Russell Epstein  <russell_e@apple.com>
+
+        Unreviewed, rolling out r251081.
+
+        Broke macOS and iOS builds.
+
+        Reverted changeset:
+
+        "transform-box: content-box, stroke-box missing"
+        https://bugs.webkit.org/show_bug.cgi?id=201892
+        https://trac.webkit.org/changeset/251081
+
 2019-10-14  Eric Carlson  <eric.carlson@apple.com>
 
         [ Mac ] REGRESSION (r243033) Assertion failed: m_logger Layout Test imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint.html is a flaky crash
diff --git a/LayoutTests/fast/css/transform-box-parsing-expected.txt b/LayoutTests/fast/css/transform-box-parsing-expected.txt
index 1b98c81..795ff69 100644
--- a/LayoutTests/fast/css/transform-box-parsing-expected.txt
+++ b/LayoutTests/fast/css/transform-box-parsing-expected.txt
@@ -6,20 +6,14 @@
 PASS testPropertyValue("transform-box: border-box", "transform-box") is "border-box"
 PASS testPropertyValue("transform-box: fill-box", "transform-box") is "fill-box"
 PASS testPropertyValue("transform-box: view-box", "transform-box") is "view-box"
-PASS testPropertyValue("transform-box: content-box", "transform-box") is "content-box"
-PASS testPropertyValue("transform-box: stroke-box", "transform-box") is "stroke-box"
 
 PASS testComputedStyle("", "transform-box") is "border-box"
 PASS testComputedStyle("transform-box: fill-box", "transform-box") is "fill-box"
 PASS testComputedStyle("transform-box: view-box", "transform-box") is "view-box"
-PASS testComputedStyle("transform-box: content-box", "transform-box") is "content-box"
-PASS testComputedStyle("transform-box: stroke-box", "transform-box") is "stroke-box"
 
 PASS testSVGComputedStyle("", "transform-box") is "view-box"
 PASS testSVGComputedStyle("transform-box: fill-box", "transform-box") is "fill-box"
 PASS testSVGComputedStyle("transform-box: border-box", "transform-box") is "border-box"
-PASS testSVGComputedStyle("transform-box: content-box", "transform-box") is "content-box"
-PASS testSVGComputedStyle("transform-box: stroke-box", "transform-box") is "stroke-box"
 
 PASS testComputedStyleOnElementWithId("foreignObject") is "view-box"
 
diff --git a/LayoutTests/fast/css/transform-box-parsing.html b/LayoutTests/fast/css/transform-box-parsing.html
index 63d84fa..52918b5 100644
--- a/LayoutTests/fast/css/transform-box-parsing.html
+++ b/LayoutTests/fast/css/transform-box-parsing.html
@@ -62,22 +62,16 @@
         shouldBeEqualToString('testPropertyValue("transform-box: border-box", "transform-box")', 'border-box');
         shouldBeEqualToString('testPropertyValue("transform-box: fill-box", "transform-box")', 'fill-box');
         shouldBeEqualToString('testPropertyValue("transform-box: view-box", "transform-box")', 'view-box');
-        shouldBeEqualToString('testPropertyValue("transform-box: content-box", "transform-box")', 'content-box');
-        shouldBeEqualToString('testPropertyValue("transform-box: stroke-box", "transform-box")', 'stroke-box');
 
         debug('');
         shouldBeEqualToString('testComputedStyle("", "transform-box")', 'border-box');
         shouldBeEqualToString('testComputedStyle("transform-box: fill-box", "transform-box")', 'fill-box');
         shouldBeEqualToString('testComputedStyle("transform-box: view-box", "transform-box")', 'view-box');
-        shouldBeEqualToString('testComputedStyle("transform-box: content-box", "transform-box")', 'content-box');
-        shouldBeEqualToString('testComputedStyle("transform-box: stroke-box", "transform-box")', 'stroke-box');
 
         debug('');
         shouldBeEqualToString('testSVGComputedStyle("", "transform-box")', 'view-box');
         shouldBeEqualToString('testSVGComputedStyle("transform-box: fill-box", "transform-box")', 'fill-box');
         shouldBeEqualToString('testSVGComputedStyle("transform-box: border-box", "transform-box")', 'border-box');
-        shouldBeEqualToString('testSVGComputedStyle("transform-box: content-box", "transform-box")', 'content-box');
-        shouldBeEqualToString('testSVGComputedStyle("transform-box: stroke-box", "transform-box")', 'stroke-box');
 
         debug('');
         shouldBeEqualToString('testComputedStyleOnElementWithId("foreignObject")', 'view-box');
diff --git a/LayoutTests/svg/transforms/svg-transform-box-expected.html b/LayoutTests/svg/transforms/svg-transform-box-expected.html
index f479460..90c617f 100644
--- a/LayoutTests/svg/transforms/svg-transform-box-expected.html
+++ b/LayoutTests/svg/transforms/svg-transform-box-expected.html
@@ -1,21 +1,28 @@
 <!DOCTYPE html>
+
 <html>
 <head>
   <style>
-    * {
-      margin: 0;
-      padding: 0;
+    svg {
+        border: 1px solid black;
     }
   </style>
 </head>
+
 <body>
-  <p>You should see no red boxes below</p>
-  <svg width="600" height="300" viewBox="0 0 600 300">
-    <rect width="120" height="60" fill="green" />
-    <rect x="150" y="0" width="120" height="60" fill="green" />
-    <rect x="300" y="0" width="120" height="60" fill="green" />
-    <rect y="90" width="120" height="60" fill="green" />
-    <rect x="150" y="90" width="120" height="60" fill="green" />
-  </svg>
+
+    <div class="container">
+        <p>You should see no red boxes below</p>
+        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 600 400" style=" width: 600px; height: 400px;">
+            <!-- transform-box: view-box -->
+            <rect x="20" y="10" width="100" height="50" fill="green" />
+            <rect x="480" y="40" width="50" height="50" fill="green" />
+            <rect x="120" y="120" width="50" height="50" fill="green" />
+            <rect x="20" y="200" width="100" height="50" fill="green" />
+            <rect x="480" y="260" width="50" height="50" fill="green" />
+            <rect x="120" y="320" width="50" height="50" fill="green" />
+        </svg>
+    </div>
+
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/LayoutTests/svg/transforms/svg-transform-box.html b/LayoutTests/svg/transforms/svg-transform-box.html
index d07d40d..2506f53 100644
--- a/LayoutTests/svg/transforms/svg-transform-box.html
+++ b/LayoutTests/svg/transforms/svg-transform-box.html
@@ -1,41 +1,42 @@
 <!DOCTYPE html>
+
 <html>
 <head>
   <style>
-    * {
-      margin: 0;
-      padding: 0;
+    svg {
+        border: 1px solid black;
     }
   </style>
 </head>
+
 <body>
-  <p>You should see no red boxes below</p>
-  <svg width="600" height="300" viewBox="0 0 600 300">
-    <g style="transform: translate(20px, 20px)">
-        <!-- transform-box: border-box -->
-        <rect x="-19" y="-19" width="118" height="58" fill="red" />
-        <rect style="transform-box: border-box; transform: rotate(90deg) scale(1, 2) translate(30px, -75%); transform-origin: 50% 0;" width="20" height="20" stroke="green" stroke-width="40" fill="green" />
-      </g>
-      <g style="transform: translate(160px, 10px)">
-        <!-- transform-box: view-box -->
-        <rect x="-9" y="-9" width="118" height="58" fill="red" />
-        <rect style="transform-box: view-box; transform: rotate(90deg) scale(1,2) translate(310px, calc(50% - 35px)); transform-origin: 50% 0;" width="20" height="20" stroke="green" stroke-width="40" fill="green" />
-      </g>
-      <g style="transform: translate(320px, 20px)">
-        <!-- transform-box: stroke-box -->
-        <rect x="-19" y="-19" width="118" height="58" fill="red" />
-        <rect style="transform-box: stroke-box; transform: rotate(90deg) scale(1, 2) translate(30px, -75%); transform-origin: 50% 0;" width="20" height="20" stroke="green" stroke-width="40" fill="green" />
-      </g>
-      <g style="transform: translate(10px, 100px)">
-        <!-- transform-box: content-box -->
-        <rect x="-9" y="-9" width="118" height="58" fill="red" />
-        <rect style="transform-box: content-box; transform: rotate(90deg) scale(1, 2) translate(20px, -87.5%); transform-origin: 50% 0;" width="40" height="40" stroke="green" stroke-width="20" fill="green" />
-      </g>
-      <g style="transform: translate(160px, 100px)">
-        <!-- transform-box: fill-box -->
-        <rect x="-9" y="-9" width="118" height="58" fill="red" />
-        <rect style="transform-box: fill-box; transform: rotate(90deg) scale(1, 2) translate(20px, -87.5%); transform-origin: 50% 0;" width="40" height="40" stroke="green" stroke-width="20" fill="green" />
-      </g>
-  </svg>
+
+    <div class="container">
+        <p>You should see no red boxes below</p>
+        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 600 400" style=" width: 600px; height: 400px;">
+            <!-- transform-box: view-box -->
+            <rect x="20" y="10" width="100" height="50" fill="red" />
+            <rect x="20" y="5" width="50" height="25" fill="green" style="transform: scale(2, 2); transform-origin: 20px 0; transform-box: view-box;" />
+
+            <rect x="480" y="40" width="50" height="50" fill="red" />
+            <rect x="0" y="0" width="50" height="50" fill="green" style="transform: translate(80%, 10%); transform-box: view-box;" />
+
+            <rect x="120" y="120" width="50" height="50" fill="red" />
+            <rect x="180" y="10" width="50" height="50" fill="green" style="transform: rotate(90deg); transform-origin: 120px 60px; transform-box: view-box;" />
+            <rect x="180" y="10" width="50" height="50" fill="green" style="transform: rotate(90deg); transform-origin: 20% 15%; transform-box: view-box;" />
+
+            <!-- transform-box: fill-box -->
+            <rect x="20" y="200" width="100" height="50" fill="red" />
+            <rect x="20" y="200" width="50" height="25" fill="green" style="transform: scale(2, 2); transform-box: fill-box;" />
+
+            <rect x="480" y="260" width="50" height="50" fill="red" />
+            <rect x="430" y="310" width="50" height="50" fill="green" style="transform: translate(100%, -100%); transform-box: fill-box;" />
+
+            <rect x="120" y="320" width="50" height="50" fill="red" />
+            <rect x="70" y="270" width="50" height="50" fill="green" style="transform: rotate(180deg); transform-origin: 50px 50px; transform-box: fill-box;" />
+            <rect x="95" y="345" width="50" height="50" fill="green" style="transform: rotate(90deg); transform-origin: 100% 50%; transform-box: fill-box;" />
+        </svg>
+    </div>
+
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/LayoutTests/transforms/transform-box-expected.html b/LayoutTests/transforms/transform-box-expected.html
deleted file mode 100644
index 2546a0f..0000000
--- a/LayoutTests/transforms/transform-box-expected.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE html>
-<html>
-
-<head>
-    <style>
-        * {
-            margin: 0;
-            padding: 0;
-        }
-
-        div {
-            width: 120px;
-            height: 60px;
-            background-color: green;
-            position: absolute;
-        }
-    </style>
-</head>
-
-<body>
-    <p>You should see no red boxes below</p>
-    <div>
-    </div>
-    <div style="transform: translateX(150px)">
-    </div>
-    <div style="transform: translateX(300px)">
-    </div>
-    <div style="transform: translate(0, 90px)">
-    </div>
-    <div style="transform: translate(150px, 90px)">
-    </div>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/LayoutTests/transforms/transform-box.html b/LayoutTests/transforms/transform-box.html
deleted file mode 100644
index a6d084d..0000000
--- a/LayoutTests/transforms/transform-box.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <style>
-    * {
-        margin: 0;
-        padding: 0;
-    }
-    .container {
-        width: 500px;
-        height: 400px;
-        overflow: hidden;
-    }
-    .fail {
-        margin: 1px;
-        width: 118px;
-        height: 58px;
-        background-color: red;
-        position: absolute;
-    }
-    .pass {
-        width: 40px;
-        height: 40px;
-        border: solid green 10px;
-        background-color: green;
-        position: absolute;
-        transform-origin: 50% 0;
-    }
-  </style>
-</head>
-<body>
-<div class="container">
-    <p>You should see no red boxes below</p>
-    <div>
-        <div class="fail"></div>
-        <div class="pass" style="transform-box: border-box; transform: rotate(90deg) scale(1, 2) translate(30px, -75%)"></div>
-    </div>
-    <div style="transform: translateX(150px)">
-        <div class="fail"></div>
-        <div class="pass" style="transform-box: view-box; transform: rotate(90deg) scale(1, 2) translate(30px, -75%)"></div>
-    </div>
-    <div style="transform: translateX(300px)">
-        <div class="fail" style="width: 50px; height: 50px;"></div>
-        <div class="pass" style="transform-box: stroke-box; transform: rotate(90deg) scale(1, 2) translate(30px, -75%)"></div>
-    </div>
-    <div style="transform: translate(0, 90px)">
-        <div class="fail"></div>
-        <div class="pass" style="transform-box: content-box; transform: rotate(90deg) scale(1, 2) translate(20px, -87.5%);"></div>
-    </div>
-    <div style="transform: translate(150px, 90px)">
-        <div class="fail"></div>
-        <div class="pass" style="transform-box: fill-box; transform: rotate(90deg) scale(1, 2) translate(20px, -87.5%);"></div>
-    </div>
-</div>
-</body>
-</html>
\ No newline at end of file
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index aefcd71..c1f3eb1 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-14  Russell Epstein  <russell_e@apple.com>
+
+        Unreviewed, rolling out r251081.
+
+        Broke macOS and iOS builds.
+
+        Reverted changeset:
+
+        "transform-box: content-box, stroke-box missing"
+        https://bugs.webkit.org/show_bug.cgi?id=201892
+        https://trac.webkit.org/changeset/251081
+
 2019-10-14  Dirk Schulze  <krit@webkit.org>
 
         transform-box: content-box, stroke-box missing
diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h
index 4631d94..53cbd96 100644
--- a/Source/WebCore/css/CSSPrimitiveValueMappings.h
+++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h
@@ -4391,12 +4391,6 @@
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (box) {
-    case TransformBox::StrokeBox:
-        m_value.valueID = CSSValueStrokeBox;
-        break;
-    case TransformBox::ContentBox:
-        m_value.valueID = CSSValueContentBox;
-        break;
     case TransformBox::BorderBox:
         m_value.valueID = CSSValueBorderBox;
         break;
@@ -4414,10 +4408,6 @@
     ASSERT(isValueID());
 
     switch (m_value.valueID) {
-    case CSSValueStrokeBox:
-        return TransformBox::StrokeBox;
-    case CSSValueContentBox:
-        return TransformBox::ContentBox;
     case CSSValueBorderBox:
         return TransformBox::BorderBox;
     case CSSValueFillBox:
diff --git a/Source/WebCore/css/CSSProperties.json b/Source/WebCore/css/CSSProperties.json
index 4bdb4ff..306aaca 100644
--- a/Source/WebCore/css/CSSProperties.json
+++ b/Source/WebCore/css/CSSProperties.json
@@ -6378,9 +6378,7 @@
             "values" : [
                 "border-box",
                 "fill-box",
-                "view-box",
-                "stroke-box",
-                "content-box"
+                "view-box"
             ],
             "codegen-properties": {
             },
diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in
index cf74a68..c4767f5 100644
--- a/Source/WebCore/css/CSSValueKeywords.in
+++ b/Source/WebCore/css/CSSValueKeywords.in
@@ -1297,8 +1297,6 @@
 // transform-box
 // border-box
 // view-box
-// stroke-box
-// content-box
 fill-box
 
 // motion path
diff --git a/Source/WebCore/css/parser/CSSPropertyParser.cpp b/Source/WebCore/css/parser/CSSPropertyParser.cpp
index cc05ef0..8ca4a56 100644
--- a/Source/WebCore/css/parser/CSSPropertyParser.cpp
+++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp
@@ -4054,7 +4054,7 @@
     case CSSPropertyTransform:
         return consumeTransform(m_range, m_context.mode);
     case CSSPropertyTransformBox:
-        return consumeIdent<CSSValueBorderBox, CSSValueViewBox, CSSValueFillBox, CSSValueStrokeBox, CSSValueContentBox>(m_range);
+        return consumeIdent<CSSValueBorderBox, CSSValueViewBox, CSSValueFillBox>(m_range);
     case CSSPropertyTransformOriginX:
     case CSSPropertyPerspectiveOriginX:
         return consumePositionX(m_range, m_context.mode);
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index 3569907..65b3f33 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -1,6 +1,5 @@
 /*
  * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
- * Copyright (C) 2019 Adobe. All rights reserved.
  *
  * Portions are Copyright (C) 1998 Netscape Communications Corporation.
  *
@@ -1244,65 +1243,6 @@
 }
 #endif
 
-static inline LayoutRect computeReferenceRectFromBox(const RenderBox& box, const CSSBoxType& boxType, const LayoutSize& offsetFromRoot)
-{
-    LayoutRect referenceBox;
-    switch (boxType) {
-    case CSSBoxType::ContentBox:
-    case CSSBoxType::FillBox:
-        referenceBox = box.contentBoxRect();
-        referenceBox.move(offsetFromRoot);
-        break;
-    case CSSBoxType::PaddingBox:
-        referenceBox = box.paddingBoxRect();
-        referenceBox.move(offsetFromRoot);
-        break;
-    case CSSBoxType::MarginBox:
-        referenceBox = box.marginBoxRect();
-        referenceBox.move(offsetFromRoot);
-        break;
-    // stroke-box, view-box compute to border-box for HTML elements.
-    case CSSBoxType::StrokeBox:
-    case CSSBoxType::ViewBox:
-    case CSSBoxType::BorderBox:
-    case CSSBoxType::BoxMissing:
-        referenceBox = box.borderBoxRect();
-        referenceBox.move(offsetFromRoot);
-        break;
-    }
-
-    return referenceBox;
-}
-
-static inline LayoutRect computeReferenceBox(const RenderObject& renderer, const CSSBoxType& boxType, const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBounds)
-{
-    // FIXME: Support different reference boxes for inline content.
-    // https://bugs.webkit.org/show_bug.cgi?id=129047
-    if (!renderer.isBox())
-        return rootRelativeBounds;
-    
-    return computeReferenceRectFromBox(downcast<RenderBox>(renderer), boxType, offsetFromRoot);
-}
-
-static inline CSSBoxType transformBoxToCSSBoxType(TransformBox transformBox)
-{
-    switch (transformBox) {
-    case TransformBox::StrokeBox:
-        return CSSBoxType::StrokeBox;
-    case TransformBox::ContentBox:
-        return CSSBoxType::ContentBox;
-    case TransformBox::BorderBox:
-        return CSSBoxType::BorderBox;
-    case TransformBox::FillBox:
-        return CSSBoxType::FillBox;
-    case TransformBox::ViewBox:
-        return CSSBoxType::ViewBox;
-    default:
-        ASSERT_NOT_REACHED();
-        return CSSBoxType::BorderBox;
-    }
-}
-
 void RenderLayer::updateTransform()
 {
     bool hasTransform = renderer().hasTransform();
@@ -1323,9 +1263,7 @@
         RenderBox* box = renderBox();
         ASSERT(box);
         m_transform->makeIdentity();
-        LayoutSize offsetFromRoot;
-        auto computedReferenceBox = computeReferenceRectFromBox(*box, transformBoxToCSSBoxType(box->style().transformBox()), offsetFromRoot);
-        box->style().applyTransform(*m_transform, snapRectToDevicePixels(computedReferenceBox, box->document().deviceScaleFactor()), RenderStyle::IncludeTransformOrigin);
+        box->style().applyTransform(*m_transform, snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor()), RenderStyle::IncludeTransformOrigin);
         makeMatrixRenderable(*m_transform, canRender3DTransforms());
     }
 
@@ -1347,10 +1285,8 @@
         if (auto* timeline = renderer().documentTimeline()) {
             if (timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform)) {
                 TransformationMatrix currTransform;
-                LayoutSize offsetFromRoot;
+                FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
                 std::unique_ptr<RenderStyle> style = timeline->animatedStyleForRenderer(renderer());
-                auto computedReferenceBox = computeReferenceBox(renderer(), transformBoxToCSSBoxType(style->transformBox()), offsetFromRoot, box->borderBoxRect());
-                FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(computedReferenceBox, box->document().deviceScaleFactor());
                 style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
                 makeMatrixRenderable(currTransform, canRender3DTransforms());
                 return currTransform;
@@ -1359,10 +1295,8 @@
     } else {
         if (renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform)) {
             TransformationMatrix currTransform;
+            FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
             std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer());
-            LayoutSize offsetFromRoot;
-            auto computedReferenceBox = computeReferenceBox(renderer(), transformBoxToCSSBoxType(style->transformBox()), offsetFromRoot, box->borderBoxRect());
-            FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(computedReferenceBox, box->document().deviceScaleFactor());
             style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
             makeMatrixRenderable(currTransform, canRender3DTransforms());
             return currTransform;
@@ -1373,10 +1307,7 @@
     // m_transform includes transform-origin, so we need to recompute the transform here.
     if (applyOrigin == RenderStyle::ExcludeTransformOrigin) {
         TransformationMatrix currTransform;
-        LayoutSize offsetFromRoot;
-        std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer());
-        auto computedReferenceBox = computeReferenceBox(renderer(), transformBoxToCSSBoxType(style->transformBox()), offsetFromRoot, box->borderBoxRect());
-        FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(computedReferenceBox, box->document().deviceScaleFactor());
+        FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
         box->style().applyTransform(currTransform, pixelSnappedBorderRect, RenderStyle::ExcludeTransformOrigin);
         makeMatrixRenderable(currTransform, canRender3DTransforms());
         return currTransform;
@@ -4342,6 +4273,42 @@
     return false;
 }
 
+static inline LayoutRect computeReferenceBox(const RenderObject& renderer, const CSSBoxType& boxType, const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBounds)
+{
+    // FIXME: Support different reference boxes for inline content.
+    // https://bugs.webkit.org/show_bug.cgi?id=129047
+    if (!renderer.isBox())
+        return rootRelativeBounds;
+
+    LayoutRect referenceBox;
+    const auto& box = downcast<RenderBox>(renderer);
+    switch (boxType) {
+    case CSSBoxType::ContentBox:
+    case CSSBoxType::FillBox:
+        referenceBox = box.contentBoxRect();
+        referenceBox.move(offsetFromRoot);
+        break;
+    case CSSBoxType::PaddingBox:
+        referenceBox = box.paddingBoxRect();
+        referenceBox.move(offsetFromRoot);
+        break;
+    case CSSBoxType::MarginBox:
+        referenceBox = box.marginBoxRect();
+        referenceBox.move(offsetFromRoot);
+        break;
+    // stroke-box, view-box compute to border-box for HTML elements.
+    case CSSBoxType::StrokeBox:
+    case CSSBoxType::ViewBox:
+    case CSSBoxType::BorderBox:
+    case CSSBoxType::BoxMissing:
+        referenceBox = box.borderBoxRect();
+        referenceBox.move(offsetFromRoot);
+        break;
+    }
+
+    return referenceBox;
+}
+
 Path RenderLayer::computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule& windRule) const
 {
     const RenderStyle& style = renderer().style();
diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h
index 5d869b1d..9b6cfeb 100644
--- a/Source/WebCore/rendering/style/RenderStyleConstants.h
+++ b/Source/WebCore/rendering/style/RenderStyleConstants.h
@@ -915,8 +915,6 @@
 };
 
 enum class TransformBox : uint8_t {
-    StrokeBox,
-    ContentBox,
     BorderBox,
     FillBox,
     ViewBox
diff --git a/Source/WebCore/svg/SVGGraphicsElement.cpp b/Source/WebCore/svg/SVGGraphicsElement.cpp
index 19f037e..80ec7fc 100644
--- a/Source/WebCore/svg/SVGGraphicsElement.cpp
+++ b/Source/WebCore/svg/SVGGraphicsElement.cpp
@@ -80,16 +80,11 @@
         
         FloatRect boundingBox;
         switch (style->transformBox()) {
-        case TransformBox::BorderBox:
-            // For SVG elements without an associated CSS layout box, the used value for border-box is stroke-box.
-        case TransformBox::StrokeBox:
-            boundingBox = renderer()->strokeBoundingBox();
-            break;
-        case TransformBox::ContentBox:
-            // For SVG elements without an associated CSS layout box, the used value for content-box is fill-box.
         case TransformBox::FillBox:
             boundingBox = renderer()->objectBoundingBox();
             break;
+        case TransformBox::BorderBox:
+            // For SVG elements without an associated CSS layout box, the used value for border-box is view-box.
         case TransformBox::ViewBox: {
             FloatSize viewportSize;
             SVGLengthContext(this).determineViewport(viewportSize);