Expose obscured insets to web content (as "safe area insets")
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Apr 2017 01:00:46 +0000 (01:00 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Apr 2017 01:00:46 +0000 (01:00 +0000)
commit5d95649bf18d314826be4d6981c20a94909e9a00
tree6ab907995d8d332cee6a7ad6e01d22080a0f979a
parent8997fe9e40d82fb0cdaecb4fd74f237c316518d7
Expose obscured insets to web content (as "safe area insets")
https://bugs.webkit.org/show_bug.cgi?id=171013
<rdar://problem/31564652>

Reviewed by Wenson Hsieh and Dave Hyatt.

Tests: fast/css/variables/constants/invalid-constant-name-fallback.html
       fast/css/variables/constants/ios/safe-area-inset-set.html
       fast/css/variables/constants/safe-area-inset-cannot-override.html
       fast/css/variables/constants/safe-area-inset-zero.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSValueKeywords.in:
* css/CSSVariableData.cpp:
(WebCore::CSSVariableData::checkVariablesForCyclesWithRange):
(WebCore::CSSVariableData::resolveTokenRange):
* css/parser/CSSVariableParser.cpp:
(WebCore::isValidConstantName):
(WebCore::classifyBlock):
(WebCore::isValidConstantReference):
Add a constant() function, which takes both custom properties and
arbitrary idents which are looked up in ConstantPropertyMap, allowing
fallback from the arbitrary, UA-defined idents to custom properties.

* dom/ConstantPropertyMap.cpp: Added.
(WebCore::ConstantPropertyMap::ConstantPropertyMap):
(WebCore::ConstantPropertyMap::values):
(WebCore::ConstantPropertyMap::nameForProperty):
(WebCore::ConstantPropertyMap::setValueForProperty):
(WebCore::ConstantPropertyMap::buildValues):
(WebCore::variableDataForSafeAreaInset):
(WebCore::ConstantPropertyMap::didChangeObscuredInsets):
* dom/ConstantPropertyMap.h: Added.
Keep a mapping of UA-defined "constants", which can be looked up
from CSS via the aforementioned function. For now, this mapping
includes only safe-area-inset-{top, right, bottom, left}, which
expose the obscured insets (now that they can be painted into via
the viewport parameter clip-to-safe-area-inset=no).

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::didChangeObscuredInsets):
* dom/Document.h:
(WebCore::Document::constantProperties):
* page/Page.cpp:
(WebCore::Page::setObscuredInsets):
* page/Page.h:
(WebCore::Page::setObscuredInsets): Deleted.
Make setObscuredInsets and related storage not iOS-specific, though
nothing from the other platforms yet calls this code.

* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
Grab the constant properties from ConstantPropertyMap and plop them into
the CustomPropertyValueMap. Constant properties aren't allowed to start
with --, and variable properties must, so there is no opportunity here
for exposing things to var() (or allowing custom properties to override
UA-defined constant properties).

* TestExpectations:
* fast/css/variables/constants/invalid-constant-name-fallback-expected.html: Added.
* fast/css/variables/constants/invalid-constant-name-fallback.html: Added.
* fast/css/variables/constants/ios/safe-area-inset-set-expected.html: Added.
* fast/css/variables/constants/ios/safe-area-inset-set.html: Added.
* fast/css/variables/constants/safe-area-inset-cannot-override-expected.html: Added.
* fast/css/variables/constants/safe-area-inset-cannot-override.html: Added.
* fast/css/variables/constants/safe-area-inset-zero-expected.html: Added.
* fast/css/variables/constants/safe-area-inset-zero.html: Added.
* platform/ios-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/css/variables/constants/invalid-constant-name-fallback-expected.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/invalid-constant-name-fallback.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/ios/safe-area-inset-set-expected.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/ios/safe-area-inset-set.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/safe-area-inset-cannot-override-expected.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/safe-area-inset-cannot-override.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/safe-area-inset-zero-expected.html [new file with mode: 0644]
LayoutTests/fast/css/variables/constants/safe-area-inset-zero.html [new file with mode: 0644]
LayoutTests/platform/ios-wk2/TestExpectations
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/CSSVariableData.cpp
Source/WebCore/css/parser/CSSVariableParser.cpp
Source/WebCore/dom/ConstantPropertyMap.cpp [new file with mode: 0644]
Source/WebCore/dom/ConstantPropertyMap.h [new file with mode: 0644]
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/style/StyleResolveForDocument.cpp