Diff
Modified: trunk/LayoutTests/ChangeLog (216425 => 216426)
--- trunk/LayoutTests/ChangeLog 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/LayoutTests/ChangeLog 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1,3 +1,25 @@
+2017-05-08 Chris Dumez <cdu...@apple.com>
+
+ Move 'style' from Element to HTMLElement / SVGElement and make it settable
+ https://bugs.webkit.org/show_bug.cgi?id=171795
+
+ Reviewed by Alex Christensen.
+
+ * accessibility/roles-exposed.html:
+ Add null check for element.style.
+
+ * fast/css/Element-style-expected.txt: Added.
+ * fast/css/Element-style.html: Added.
+ Add layout test coverage.
+
+ * fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt:
+ Rebaseline test that was setting HTMLElement.style which was a no-op until this patch. Now that it actually
+ does something, the input element actually looses its renderer. This found a bug which I fixed in this
+ patch.
+
+ * js/dom/dom-static-property-for-in-iteration-expected.txt:
+ Rebaseline as property enumeration order has changed.
+
2017-05-08 Joanmarie Diggs <jdi...@igalia.com>
AX: Propagate aria-readonly to grid descendants
Modified: trunk/LayoutTests/accessibility/roles-exposed.html (216425 => 216426)
--- trunk/LayoutTests/accessibility/roles-exposed.html 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/LayoutTests/accessibility/roles-exposed.html 2017-05-08 16:50:46 UTC (rev 216426)
@@ -431,7 +431,8 @@
examples = document.querySelectorAll('.ex');
for (var i = 0, c = examples.length; i < c; i++) {
el = examples[i];
- el.style.display = 'none';
+ if (el.style)
+ el.style.display = 'none';
}
}
</script>
Added: trunk/LayoutTests/fast/css/Element-style-expected.txt (0 => 216426)
--- trunk/LayoutTests/fast/css/Element-style-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/Element-style-expected.txt 2017-05-08 16:50:46 UTC (rev 216426)
@@ -0,0 +1,5 @@
+
+PASS 'style' property location
+PASS 'style' property type
+PASS style should be settable
+
Added: trunk/LayoutTests/fast/css/Element-style.html (0 => 216426)
--- trunk/LayoutTests/fast/css/Element-style.html (rev 0)
+++ trunk/LayoutTests/fast/css/Element-style.html 2017-05-08 16:50:46 UTC (rev 216426)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<div id="testDiv" style="background-color: red"></div>
+<svg id="testSVG" style="background-color: red"></div>
+<script>
+test(() => {
+ const testDiv = document.getElementById("testDiv");
+ assert_equals(testDiv.__proto__, HTMLDivElement.prototype, "testDiv is an HTMLDivElement");
+ assert_idl_attribute(testDiv, "style", "HTMLElement has 'style' attribute");
+ assert_own_property(HTMLElement.prototype, "style", "'style' is on HTMLElement prototype");
+
+ const testSVG = document.getElementById("testSVG");
+ assert_equals(testSVG.__proto__, SVGSVGElement.prototype, "testSVG is an SVGSVGElement");
+ assert_idl_attribute(testSVG, "style", "SVGElement has 'style' attribute");
+ assert_own_property(SVGElement.prototype, "style", "'style' is on SVGElement prototype");
+
+ assert_not_exists("Element.prototype", "style", "'style' is not on Element prototype");
+}, "'style' property location");
+
+test(() => {
+ const testDiv = document.getElementById("testDiv");
+ assert_equals(testDiv.style.__proto__, CSSStyleDeclaration.prototype, "HTMLElement.style type");
+
+ const testSVG = document.getElementById("testSVG");
+ assert_equals(testSVG.style.__proto__, CSSStyleDeclaration.prototype, "SVGElement.style type");
+}, "'style' property type");
+
+test(() => {
+ const testDiv = document.getElementById("testDiv");
+ assert_equals(testDiv.style.backgroundColor, "red", "HTMLElement.style getter");
+ assert_readonly(testDiv, "style", "HTMLElement.style is readonly");
+ testDiv.style = "background-color: green";
+ assert_equals(testDiv.style.backgroundColor, "green", "HTMLElement.style setter");
+
+ const testSVG = document.getElementById("testSVG");
+ assert_equals(testSVG.style.backgroundColor, "red", "SVGElement.style getter");
+ assert_readonly(testSVG, "style", "SVGElement.style is readonly");
+ testSVG.style = "background-color: green";
+ assert_equals(testSVG.style.backgroundColor, "green", "SVGElement.style setter");
+}, "style should be settable");
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt (216425 => 216426)
--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1,4 +1,3 @@
-
PASS e.width is 16
PASS e.height is 16
PASS successfullyParsed is true
Modified: trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt (216425 => 216426)
--- trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt 2017-05-08 16:50:46 UTC (rev 216426)
@@ -46,6 +46,7 @@
PASS a["isContentEditable"] is false
PASS a["spellcheck"] is true
PASS a["dataset"] is [object DOMStringMap]
+PASS a["style"] is [object CSSStyleDeclaration]
PASS a["onabort"] is null
PASS a["onblur"] is null
PASS a["oncanplay"] is null
@@ -114,7 +115,6 @@
PASS a["slot"] is
PASS a["attributes"] is [object NamedNodeMap]
PASS a["shadowRoot"] is null
-PASS a["style"] is [object CSSStyleDeclaration]
PASS a["scrollTop"] is 0
PASS a["scrollLeft"] is 0
PASS a["scrollWidth"] is 0
Modified: trunk/Source/WebCore/CMakeLists.txt (216425 => 216426)
--- trunk/Source/WebCore/CMakeLists.txt 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-05-08 16:50:46 UTC (rev 216426)
@@ -387,6 +387,7 @@
css/DeprecatedCSSOMValue.idl
css/DeprecatedCSSOMValueList.idl
css/DOMCSSNamespace.idl
+ css/ElementCSSInlineStyle.idl
css/FontFace.idl
css/FontFaceSet.idl
css/MediaList.idl
Modified: trunk/Source/WebCore/ChangeLog (216425 => 216426)
--- trunk/Source/WebCore/ChangeLog 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/ChangeLog 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1,3 +1,73 @@
+2017-05-08 Chris Dumez <cdu...@apple.com>
+
+ Move 'style' from Element to HTMLElement / SVGElement and make it settable
+ https://bugs.webkit.org/show_bug.cgi?id=171795
+
+ Reviewed by Alex Christensen.
+
+ Move 'style' from Element to HTMLElement / SVGElement and make it settable
+ as per:
+ - https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface
+
+ Both Firefox and Chrome already match the specification (both for the
+ property location and having it settable).
+
+ Test: fast/css/Element-style.html
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/ElementCSSInlineStyle.idl: Added.
+ * css/PropertySetCSSStyleDeclaration.h:
+ * css/StyleProperties.cpp:
+ (WebCore::MutableStyleProperties::ensureCSSStyleDeclaration):
+ (WebCore::MutableStyleProperties::ensureInlineCSSStyleDeclaration):
+ * css/StyleProperties.h:
+ * dom/Attr.cpp:
+ (WebCore::Attr::style):
+ * dom/Document.cpp:
+ (WebCore::Document::createCSSStyleDeclaration):
+ * dom/Element.cpp:
+ * dom/Element.h:
+ * dom/Element.idl:
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::cssomStyle):
+ * dom/StyledElement.h:
+ * editing/Editor.cpp:
+ (WebCore::Editor::applyEditingStyleToElement):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+ * html/HTMLElement.idl:
+
+ * html/ImageInputType.cpp:
+ (WebCore::ImageInputType::height):
+ (WebCore::ImageInputType::width):
+ Fix bug that was found by fast/forms/input-width-height-attributes-without-renderer-loaded-image.html.
+ That test relied on setting HTMLElement.style which did not work until now. Call updateLayout()
+ *before* doing the renderer check.
+
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::getMatchedStylesForNode):
+ (WebCore::InspectorCSSAgent::getInlineStylesForNode):
+ (WebCore::InspectorCSSAgent::getComputedStyleForNode):
+ (WebCore::InspectorCSSAgent::asInspectorStyleSheet):
+ (WebCore::InspectorCSSAgent::buildObjectForAttributesStyle):
+ * inspector/InspectorCSSAgent.h:
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyle::create):
+ (WebCore::InspectorStyle::InspectorStyle):
+ (WebCore::InspectorStyle::extractSourceData):
+ (WebCore::InspectorStyle::setText):
+ (WebCore::InspectorStyleSheet::inspectorStyleForId):
+ (WebCore::InspectorStyleSheetForInlineStyle::create):
+ (WebCore::InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle):
+ (WebCore::InspectorStyleSheetForInlineStyle::didModifyElementAttribute):
+ (WebCore::InspectorStyleSheetForInlineStyle::setStyleText):
+ (WebCore::InspectorStyleSheetForInlineStyle::ensureParsedDataReady):
+ (WebCore::InspectorStyleSheetForInlineStyle::inlineStyle):
+ * inspector/InspectorStyleSheet.h:
+ * svg/SVGElement.idl:
+
2017-05-08 Joanmarie Diggs <jdi...@igalia.com>
AX: Propagate aria-readonly to grid descendants
Modified: trunk/Source/WebCore/DerivedSources.make (216425 => 216426)
--- trunk/Source/WebCore/DerivedSources.make 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/DerivedSources.make 2017-05-08 16:50:46 UTC (rev 216426)
@@ -323,6 +323,7 @@
$(WebCore)/css/DeprecatedCSSOMValue.idl \
$(WebCore)/css/DeprecatedCSSOMValueList.idl \
$(WebCore)/css/DOMCSSNamespace.idl \
+ $(WebCore)/css/ElementCSSInlineStyle.idl \
$(WebCore)/css/FontFace.idl \
$(WebCore)/css/FontFaceSet.idl \
$(WebCore)/css/MediaList.idl \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (216425 => 216426)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-08 16:50:46 UTC (rev 216426)
@@ -11392,6 +11392,7 @@
83765F941DAC521800C06537 /* MouseEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventInit.h; sourceTree = "<group>"; };
837A80121E1E127300026B9F /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = English; path = English.lproj/Localizable.stringsdict; sourceTree = SOURCE_ROOT; };
837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleIOS.mm; sourceTree = "<group>"; };
+ 837DFB341EBFEA7000601385 /* ElementCSSInlineStyle.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ElementCSSInlineStyle.idl; sourceTree = "<group>"; };
8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilder.h; sourceTree = "<group>"; };
8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilder.cpp; sourceTree = "<group>"; };
838867341D13BA59003697D0 /* RenderObjectEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderObjectEnums.h; sourceTree = "<group>"; };
@@ -24996,6 +24997,7 @@
FD677735195CAB200072E0D3 /* DOMCSSNamespace.cpp */,
FC9A0F72164094CF003D6B8D /* DOMCSSNamespace.h */,
FC9A0F73164094CF003D6B8D /* DOMCSSNamespace.idl */,
+ 837DFB341EBFEA7000601385 /* ElementCSSInlineStyle.idl */,
FBDB619A16D6032A00BB3394 /* ElementRuleCollector.cpp */,
FBDB619E16D6036500BB3394 /* ElementRuleCollector.h */,
1C66260E1C6E7CA600AB527C /* FontFace.cpp */,
Added: trunk/Source/WebCore/css/ElementCSSInlineStyle.idl (0 => 216426)
--- trunk/Source/WebCore/css/ElementCSSInlineStyle.idl (rev 0)
+++ trunk/Source/WebCore/css/ElementCSSInlineStyle.idl 2017-05-08 16:50:46 UTC (rev 216426)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// CSSOM extensions to HTMLElement / SVGElement:
+// https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface
+[
+ NoInterfaceObject,
+] interface ElementCSSInlineStyle {
+ [ImplementedAs=cssomStyle, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; // FIXME: Should be [SameObject].
+};
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (216425 => 216426)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -346,7 +346,7 @@
}
StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStyleProperties& propertySet, CSSRule& parentRule)
- : PropertySetCSSStyleDeclaration(&propertySet)
+ : PropertySetCSSStyleDeclaration(propertySet)
, m_refCount(1)
, m_parentRule(&parentRule)
{
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h (216425 => 216426)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -43,7 +43,9 @@
class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
public:
- PropertySetCSSStyleDeclaration(MutableStyleProperties* propertySet) : m_propertySet(propertySet) { }
+ explicit PropertySetCSSStyleDeclaration(MutableStyleProperties& propertySet)
+ : m_propertySet(&propertySet)
+ { }
virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
@@ -117,9 +119,9 @@
class InlineCSSStyleDeclaration final : public PropertySetCSSStyleDeclaration {
public:
- InlineCSSStyleDeclaration(MutableStyleProperties* propertySet, StyledElement* parentElement)
+ InlineCSSStyleDeclaration(MutableStyleProperties& propertySet, StyledElement& parentElement)
: PropertySetCSSStyleDeclaration(propertySet)
- , m_parentElement(parentElement)
+ , m_parentElement(&parentElement)
{
}
Modified: trunk/Source/WebCore/css/StyleProperties.cpp (216425 => 216426)
--- trunk/Source/WebCore/css/StyleProperties.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/css/StyleProperties.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1325,25 +1325,25 @@
return m_cssomWrapper.get();
}
-CSSStyleDeclaration* MutableStyleProperties::ensureCSSStyleDeclaration()
+CSSStyleDeclaration& MutableStyleProperties::ensureCSSStyleDeclaration()
{
if (m_cssomWrapper) {
ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule());
ASSERT(!m_cssomWrapper->parentElement());
- return m_cssomWrapper.get();
+ return *m_cssomWrapper;
}
- m_cssomWrapper = std::make_unique<PropertySetCSSStyleDeclaration>(this);
- return m_cssomWrapper.get();
+ m_cssomWrapper = std::make_unique<PropertySetCSSStyleDeclaration>(*this);
+ return *m_cssomWrapper;
}
-CSSStyleDeclaration* MutableStyleProperties::ensureInlineCSSStyleDeclaration(StyledElement* parentElement)
+CSSStyleDeclaration& MutableStyleProperties::ensureInlineCSSStyleDeclaration(StyledElement& parentElement)
{
if (m_cssomWrapper) {
- ASSERT(m_cssomWrapper->parentElement() == parentElement);
- return m_cssomWrapper.get();
+ ASSERT(m_cssomWrapper->parentElement() == &parentElement);
+ return *m_cssomWrapper;
}
- m_cssomWrapper = std::make_unique<InlineCSSStyleDeclaration>(this, parentElement);
- return m_cssomWrapper.get();
+ m_cssomWrapper = std::make_unique<InlineCSSStyleDeclaration>(*this, parentElement);
+ return *m_cssomWrapper;
}
unsigned StyleProperties::averageSizeInBytes()
Modified: trunk/Source/WebCore/css/StyleProperties.h (216425 => 216426)
--- trunk/Source/WebCore/css/StyleProperties.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/css/StyleProperties.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -236,8 +236,8 @@
void clear();
bool parseDeclaration(const String& styleDeclaration, CSSParserContext);
- WEBCORE_EXPORT CSSStyleDeclaration* ensureCSSStyleDeclaration();
- CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(StyledElement* parentElement);
+ WEBCORE_EXPORT CSSStyleDeclaration& ensureCSSStyleDeclaration();
+ CSSStyleDeclaration& ensureInlineCSSStyleDeclaration(StyledElement& parentElement);
int findPropertyIndex(CSSPropertyID) const;
int findCustomPropertyIndex(const String& propertyName) const;
Modified: trunk/Source/WebCore/dom/Attr.cpp (216425 => 216426)
--- trunk/Source/WebCore/dom/Attr.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/Attr.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -123,7 +123,7 @@
return nullptr;
m_style = MutableStyleProperties::create();
downcast<StyledElement>(*m_element).collectStyleForPresentationAttribute(qualifiedName(), value(), *m_style);
- return m_style->ensureCSSStyleDeclaration();
+ return &m_style->ensureCSSStyleDeclaration();
}
const AtomicString& Attr::value() const
Modified: trunk/Source/WebCore/dom/Document.cpp (216425 => 216426)
--- trunk/Source/WebCore/dom/Document.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -927,7 +927,7 @@
Ref<CSSStyleDeclaration> Document::createCSSStyleDeclaration()
{
Ref<MutableStyleProperties> propertySet(MutableStyleProperties::create());
- return *propertySet->ensureCSSStyleDeclaration();
+ return propertySet->ensureCSSStyleDeclaration();
}
ExceptionOr<Ref<Node>> Document::importNode(Node& nodeToImport, bool deep)
Modified: trunk/Source/WebCore/dom/Element.cpp (216425 => 216426)
--- trunk/Source/WebCore/dom/Element.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/Element.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -2367,11 +2367,6 @@
return elementData()->findAttributeByName(qName);
}
-CSSStyleDeclaration* Element::cssomStyle()
-{
- return nullptr;
-}
-
void Element::focus(bool restorePreviousSelection, FocusDirection direction)
{
if (!isConnected())
Modified: trunk/Source/WebCore/dom/Element.h (216425 => 216426)
--- trunk/Source/WebCore/dom/Element.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/Element.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -197,8 +197,6 @@
const Vector<RefPtr<Attr>>& attrNodeList();
- virtual CSSStyleDeclaration* cssomStyle();
-
const QualifiedName& tagQName() const { return m_tagName; }
#if ENABLE(JIT)
static ptrdiff_t tagQNameMemoryOffset() { return OBJECT_OFFSETOF(Element, m_tagName); }
Modified: trunk/Source/WebCore/dom/Element.idl (216425 => 216426)
--- trunk/Source/WebCore/dom/Element.idl 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/Element.idl 2017-05-08 16:50:46 UTC (rev 216426)
@@ -66,10 +66,6 @@
[CEReactions, MayThrowException] Element? insertAdjacentElement(DOMString where, Element element); // Historical.
[MayThrowException] void insertAdjacentText(DOMString where, DOMString data); // Historical.
- // FIXME: Should be in a separate ElementCSSInlineStyle and implemented by HTMLElement / SVGElement.
- // https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface
- [ImplementedAs=cssomStyle] readonly attribute CSSStyleDeclaration style; // FIXME: Should be [SameObject, PutForwards=cssText].
-
// CSSOM-view extensions (https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface).
sequence<DOMRect> getClientRects();
[NewObject] DOMRect getBoundingClientRect();
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (216425 => 216426)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -61,9 +61,9 @@
cssomWrapper->clearParentElement();
}
-CSSStyleDeclaration* StyledElement::cssomStyle()
+CSSStyleDeclaration& StyledElement::cssomStyle()
{
- return ensureMutableInlineStyle().ensureInlineCSSStyleDeclaration(this);
+ return ensureMutableInlineStyle().ensureInlineCSSStyleDeclaration(*this);
}
MutableStyleProperties& StyledElement::ensureMutableInlineStyle()
Modified: trunk/Source/WebCore/dom/StyledElement.h (216425 => 216426)
--- trunk/Source/WebCore/dom/StyledElement.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/dom/StyledElement.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -55,7 +55,7 @@
static void synchronizeStyleAttributeInternal(StyledElement*);
void synchronizeStyleAttributeInternal() const { StyledElement::synchronizeStyleAttributeInternal(const_cast<StyledElement*>(this)); }
- CSSStyleDeclaration* cssomStyle() final;
+ WEBCORE_EXPORT CSSStyleDeclaration& cssomStyle();
const StyleProperties* presentationAttributeStyle() const;
virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) { }
Modified: trunk/Source/WebCore/editing/Editor.cpp (216425 => 216426)
--- trunk/Source/WebCore/editing/Editor.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/editing/Editor.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -3103,10 +3103,10 @@
return;
// Mutate using the CSSOM wrapper so we get the same event behavior as a script.
- CSSStyleDeclaration* style = downcast<StyledElement>(*element).cssomStyle();
- style->setPropertyInternal(CSSPropertyWordWrap, "break-word", false);
- style->setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false);
- style->setPropertyInternal(CSSPropertyLineBreak, "after-white-space", false);
+ auto& style = downcast<StyledElement>(*element).cssomStyle();
+ style.setPropertyInternal(CSSPropertyWordWrap, "break-word", false);
+ style.setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false);
+ style.setPropertyInternal(CSSPropertyLineBreak, "after-white-space", false);
}
bool Editor::findString(const String& target, FindOptions options)
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (216425 => 216426)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -556,9 +556,9 @@
// Mutate using the CSSOM wrapper so we get the same event behavior as a script.
if (isBlock(element))
- element->cssomStyle()->setPropertyInternal(CSSPropertyDisplay, "inline", false);
+ element->cssomStyle().setPropertyInternal(CSSPropertyDisplay, "inline", false);
if (element->renderer() && element->renderer()->style().isFloating())
- element->cssomStyle()->setPropertyInternal(CSSPropertyFloat, "none", false);
+ element->cssomStyle().setPropertyInternal(CSSPropertyFloat, "none", false);
}
}
}
Modified: trunk/Source/WebCore/html/HTMLElement.idl (216425 => 216426)
--- trunk/Source/WebCore/html/HTMLElement.idl 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/html/HTMLElement.idl 2017-05-08 16:50:46 UTC (rev 216426)
@@ -57,4 +57,5 @@
readonly attribute DOMStringMap dataset;
};
+HTMLElement implements ElementCSSInlineStyle;
HTMLElement implements GlobalEventHandlers;
Modified: trunk/Source/WebCore/html/ImageInputType.cpp (216425 => 216426)
--- trunk/Source/WebCore/html/ImageInputType.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/html/ImageInputType.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -177,6 +177,8 @@
{
Ref<HTMLInputElement> element(this->element());
+ element->document().updateLayout();
+
if (!element->renderer()) {
// Check the attribute first for an explicit pixel value.
if (auto optionalHeight = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(heightAttr)))
@@ -188,8 +190,6 @@
return imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).height().toUnsigned();
}
- element->document().updateLayout();
-
RenderBox* box = element->renderBox();
return box ? adjustForAbsoluteZoom(box->contentHeight(), *box) : 0;
}
@@ -198,6 +198,8 @@
{
Ref<HTMLInputElement> element(this->element());
+ element->document().updateLayout();
+
if (!element->renderer()) {
// Check the attribute first for an explicit pixel value.
if (auto optionalWidth = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(widthAttr)))
@@ -209,8 +211,6 @@
return imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).width().toUnsigned();
}
- element->document().updateLayout();
-
RenderBox* box = element->renderBox();
return box ? adjustForAbsoluteZoom(box->contentWidth(), *box) : 0;
}
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (216425 => 216426)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -606,9 +606,9 @@
auto entry = Inspector::Protocol::CSS::InheritedStyleEntry::create()
.setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRules, styleResolver, *parentElement, NOPSEUDO))
.release();
- if (parentElement->cssomStyle() && parentElement->cssomStyle()->length()) {
- if (InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(parentElement))
- entry->setInlineStyle(styleSheet->buildObjectForStyle(styleSheet->styleForId(InspectorCSSId(styleSheet->id(), 0))));
+ if (is<StyledElement>(*parentElement) && downcast<StyledElement>(*parentElement).cssomStyle().length()) {
+ auto& styleSheet = asInspectorStyleSheet(downcast<StyledElement>(*parentElement));
+ entry->setInlineStyle(styleSheet.buildObjectForStyle(styleSheet.styleForId(InspectorCSSId(styleSheet.id(), 0))));
}
entries->addItem(WTFMove(entry));
@@ -622,16 +622,14 @@
void InspectorCSSAgent::getInlineStylesForNode(ErrorString& errorString, int nodeId, RefPtr<Inspector::Protocol::CSS::CSSStyle>& inlineStyle, RefPtr<Inspector::Protocol::CSS::CSSStyle>& attributesStyle)
{
- Element* element = elementForId(errorString, nodeId);
- if (!element)
+ auto* element = elementForId(errorString, nodeId);
+ if (!is<StyledElement>(element))
return;
- InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(element);
- if (!styleSheet)
- return;
-
- inlineStyle = styleSheet->buildObjectForStyle(element->cssomStyle());
- if (auto attributes = buildObjectForAttributesStyle(element))
+ auto& styledElement = downcast<StyledElement>(*element);
+ auto& styleSheet = asInspectorStyleSheet(styledElement);
+ inlineStyle = styleSheet.buildObjectForStyle(&styledElement.cssomStyle());
+ if (auto attributes = buildObjectForAttributesStyle(styledElement))
attributesStyle = WTFMove(attributes);
else
attributesStyle = nullptr;
@@ -639,12 +637,12 @@
void InspectorCSSAgent::getComputedStyleForNode(ErrorString& errorString, int nodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSComputedStyleProperty>>& style)
{
- Element* element = elementForId(errorString, nodeId);
+ auto* element = elementForId(errorString, nodeId);
if (!element)
return;
- RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDeclaration::create(*element, true);
- Ref<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), computedStyleInfo, nullptr);
+ auto computedStyleInfo = CSSComputedStyleDeclaration::create(*element, true);
+ auto inspectorStyle = InspectorStyle::create(InspectorCSSId(), WTFMove(computedStyleInfo), nullptr);
style = inspectorStyle->buildArrayForComputedStyle();
}
@@ -920,22 +918,19 @@
result = WTFMove(namedFlows);
}
-InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Element* element)
+InspectorStyleSheetForInlineStyle& InspectorCSSAgent::asInspectorStyleSheet(StyledElement& element)
{
- NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(element);
+ auto it = m_nodeToInspectorStyleSheet.find(&element);
if (it == m_nodeToInspectorStyleSheet.end()) {
- CSSStyleDeclaration* style = element->cssomStyle();
- if (!style)
- return nullptr;
-
String newStyleSheetId = String::number(m_lastStyleSheetId++);
- RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorStyleSheetForInlineStyle::create(m_domAgent->pageAgent(), newStyleSheetId, element, Inspector::Protocol::CSS::StyleSheetOrigin::Regular, this);
- m_idToInspectorStyleSheet.set(newStyleSheetId, inspectorStyleSheet);
- m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet);
- return inspectorStyleSheet.get();
+ auto inspectorStyleSheet = InspectorStyleSheetForInlineStyle::create(m_domAgent->pageAgent(), newStyleSheetId, element, Inspector::Protocol::CSS::StyleSheetOrigin::Regular, this);
+ auto& inspectorStyleSheetRef = inspectorStyleSheet.get();
+ m_idToInspectorStyleSheet.set(newStyleSheetId, inspectorStyleSheet.copyRef());
+ m_nodeToInspectorStyleSheet.set(&element, WTFMove(inspectorStyleSheet));
+ return inspectorStyleSheetRef;
}
- return it->value.get();
+ return *it->value;
}
Element* InspectorCSSAgent::elementForId(ErrorString& errorString, int nodeId)
@@ -1085,21 +1080,15 @@
return WTFMove(result);
}
-RefPtr<Inspector::Protocol::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttributesStyle(Element* element)
+RefPtr<Inspector::Protocol::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttributesStyle(StyledElement& element)
{
- ASSERT(element);
- if (!is<StyledElement>(*element))
- return nullptr;
-
// FIXME: Ugliness below.
- StyleProperties* attributeStyle = const_cast<StyleProperties*>(downcast<StyledElement>(element)->presentationAttributeStyle());
+ auto* attributeStyle = const_cast<StyleProperties*>(element.presentationAttributeStyle());
if (!attributeStyle)
return nullptr;
- ASSERT_WITH_SECURITY_IMPLICATION(attributeStyle->isMutable());
- MutableStyleProperties* mutableAttributeStyle = static_cast<MutableStyleProperties*>(attributeStyle);
-
- Ref<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), mutableAttributeStyle->ensureCSSStyleDeclaration(), nullptr);
+ auto& mutableAttributeStyle = downcast<MutableStyleProperties>(*attributeStyle);
+ auto inspectorStyle = InspectorStyle::create(InspectorCSSId(), mutableAttributeStyle.ensureCSSStyleDeclaration(), nullptr);
return inspectorStyle->buildObjectForStyle();
}
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.h (216425 => 216426)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -135,7 +135,7 @@
typedef HashMap<int, unsigned> NodeIdToForcedPseudoState;
void resetNonPersistentData();
- InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element);
+ InspectorStyleSheetForInlineStyle& asInspectorStyleSheet(StyledElement&);
Element* elementForId(ErrorString&, int nodeId);
int documentNodeWithRequestedFlowsId(Document*);
@@ -153,7 +153,7 @@
RefPtr<Inspector::Protocol::CSS::CSSRule> buildObjectForRule(StyleRule*, StyleResolver&, Element&);
RefPtr<Inspector::Protocol::CSS::CSSRule> buildObjectForRule(CSSStyleRule*);
RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::RuleMatch>> buildArrayForMatchedRuleList(const Vector<RefPtr<StyleRule>>&, StyleResolver&, Element&, PseudoId);
- RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForAttributesStyle(Element*);
+ RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForAttributesStyle(StyledElement&);
RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::Region>> buildArrayForRegions(ErrorString&, RefPtr<NodeList>&&, int documentNodeId);
RefPtr<Inspector::Protocol::CSS::NamedFlow> buildObjectForNamedFlow(ErrorString&, WebKitNamedFlow*, int documentNodeId);
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (216425 => 216426)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -518,17 +518,16 @@
}
}
-Ref<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&& style, InspectorStyleSheet* parentStyleSheet)
+Ref<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, Ref<CSSStyleDeclaration>&& style, InspectorStyleSheet* parentStyleSheet)
{
return adoptRef(*new InspectorStyle(styleId, WTFMove(style), parentStyleSheet));
}
-InspectorStyle::InspectorStyle(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&& style, InspectorStyleSheet* parentStyleSheet)
+InspectorStyle::InspectorStyle(const InspectorCSSId& styleId, Ref<CSSStyleDeclaration>&& style, InspectorStyleSheet* parentStyleSheet)
: m_styleId(styleId)
- , m_style(style)
+ , m_style(WTFMove(style))
, m_parentStyleSheet(parentStyleSheet)
{
- ASSERT(m_style);
}
InspectorStyle::~InspectorStyle()
@@ -745,12 +744,12 @@
{
if (!m_parentStyleSheet || !m_parentStyleSheet->ensureParsedDataReady())
return nullptr;
- return m_parentStyleSheet->ruleSourceDataFor(m_style.get());
+ return m_parentStyleSheet->ruleSourceDataFor(m_style.ptr());
}
ExceptionOr<void> InspectorStyle::setText(const String& text)
{
- return m_parentStyleSheet->setStyleText(m_style.get(), text);
+ return m_parentStyleSheet->setStyleText(m_style.ptr(), text);
}
String InspectorStyle::shorthandValue(const String& shorthandProperty) const
@@ -1257,7 +1256,7 @@
if (!style)
return nullptr;
- return InspectorStyle::create(id, style, this);
+ return InspectorStyle::create(id, *style, this);
}
InspectorCSSId InspectorStyleSheet::ruleOrStyleId(CSSStyleDeclaration* style) const
@@ -1472,26 +1471,25 @@
}
}
-Ref<InspectorStyleSheetForInlineStyle> InspectorStyleSheetForInlineStyle::create(InspectorPageAgent* pageAgent, const String& id, RefPtr<Element>&& element, Inspector::Protocol::CSS::StyleSheetOrigin origin, Listener* listener)
+Ref<InspectorStyleSheetForInlineStyle> InspectorStyleSheetForInlineStyle::create(InspectorPageAgent* pageAgent, const String& id, Ref<StyledElement>&& element, Inspector::Protocol::CSS::StyleSheetOrigin origin, Listener* listener)
{
return adoptRef(*new InspectorStyleSheetForInlineStyle(pageAgent, id, WTFMove(element), origin, listener));
}
-InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(InspectorPageAgent* pageAgent, const String& id, RefPtr<Element>&& element, Inspector::Protocol::CSS::StyleSheetOrigin origin, Listener* listener)
+InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(InspectorPageAgent* pageAgent, const String& id, Ref<StyledElement>&& element, Inspector::Protocol::CSS::StyleSheetOrigin origin, Listener* listener)
: InspectorStyleSheet(pageAgent, id, nullptr, origin, String(), listener)
, m_element(WTFMove(element))
, m_ruleSourceData(nullptr)
, m_isStyleTextValid(false)
{
- ASSERT(m_element);
m_inspectorStyle = InspectorStyle::create(InspectorCSSId(id, 0), inlineStyle(), this);
- m_styleText = m_element->isStyledElement() ? m_element->getAttribute("style").string() : String();
+ m_styleText = m_element->getAttribute("style").string();
}
void InspectorStyleSheetForInlineStyle::didModifyElementAttribute()
{
m_isStyleTextValid = false;
- if (m_element->isStyledElement() && m_element->cssomStyle() != m_inspectorStyle->cssStyle())
+ if (&m_element->cssomStyle() != &m_inspectorStyle->cssStyle())
m_inspectorStyle = InspectorStyle::create(InspectorCSSId(id(), 0), inlineStyle(), this);
m_ruleSourceData = nullptr;
}
@@ -1507,7 +1505,7 @@
ExceptionOr<void> InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text)
{
- ASSERT_UNUSED(style, style == inlineStyle());
+ ASSERT_UNUSED(style, style == &inlineStyle());
{
InspectorCSSAgent::InlineStyleOverrideScope overrideScope(m_element->document());
@@ -1544,9 +1542,6 @@
if (m_ruleSourceData)
return true;
- if (!m_element->isStyledElement())
- return false;
-
m_ruleSourceData = ruleSourceData();
return true;
}
@@ -1557,7 +1552,7 @@
return m_inspectorStyle.copyRef();
}
-CSSStyleDeclaration* InspectorStyleSheetForInlineStyle::inlineStyle() const
+CSSStyleDeclaration& InspectorStyleSheetForInlineStyle::inlineStyle() const
{
return m_element->cssomStyle();
}
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.h (216425 => 216426)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.h 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.h 2017-05-08 16:50:46 UTC (rev 216426)
@@ -122,10 +122,10 @@
class InspectorStyle final : public RefCounted<InspectorStyle> {
public:
- static Ref<InspectorStyle> create(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&&, InspectorStyleSheet* parentStyleSheet);
+ static Ref<InspectorStyle> create(const InspectorCSSId& styleId, Ref<CSSStyleDeclaration>&&, InspectorStyleSheet* parentStyleSheet);
~InspectorStyle();
- CSSStyleDeclaration* cssStyle() const { return m_style.get(); }
+ CSSStyleDeclaration& cssStyle() const { return m_style.get(); }
RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForStyle() const;
Ref<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSComputedStyleProperty>> buildArrayForComputedStyle() const;
@@ -133,7 +133,7 @@
ExceptionOr<void> setText(const String&);
private:
- InspectorStyle(const InspectorCSSId& styleId, RefPtr<CSSStyleDeclaration>&&, InspectorStyleSheet* parentStyleSheet);
+ InspectorStyle(const InspectorCSSId& styleId, Ref<CSSStyleDeclaration>&&, InspectorStyleSheet* parentStyleSheet);
void populateAllProperties(Vector<InspectorStyleProperty>* result) const;
Ref<Inspector::Protocol::CSS::CSSStyle> styleWithProperties() const;
@@ -143,7 +143,7 @@
Vector<String> longhandProperties(const String& shorthandProperty) const;
InspectorCSSId m_styleId;
- RefPtr<CSSStyleDeclaration> m_style;
+ Ref<CSSStyleDeclaration> m_style;
InspectorStyleSheet* m_parentStyleSheet;
};
@@ -229,17 +229,17 @@
class InspectorStyleSheetForInlineStyle final : public InspectorStyleSheet {
public:
- static Ref<InspectorStyleSheetForInlineStyle> create(InspectorPageAgent*, const String& id, RefPtr<Element>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
+ static Ref<InspectorStyleSheetForInlineStyle> create(InspectorPageAgent*, const String& id, Ref<StyledElement>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
void didModifyElementAttribute();
ExceptionOr<String> text() const final;
- CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const final { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); }
+ CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const final { ASSERT_UNUSED(id, !id.ordinal()); return &inlineStyle(); }
protected:
- InspectorStyleSheetForInlineStyle(InspectorPageAgent*, const String& id, RefPtr<Element>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
+ InspectorStyleSheetForInlineStyle(InspectorPageAgent*, const String& id, Ref<StyledElement>&&, Inspector::Protocol::CSS::StyleSheetOrigin, Listener*);
Document* ownerDocument() const final;
- RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const final { ASSERT_UNUSED(style, style == inlineStyle()); return m_ruleSourceData; }
+ RefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const final { ASSERT_UNUSED(style, style == &inlineStyle()); return m_ruleSourceData; }
unsigned ruleIndexByStyle(CSSStyleDeclaration*) const final { return 0; }
bool ensureParsedDataReady() final;
RefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&) final;
@@ -249,11 +249,11 @@
std::unique_ptr<Vector<size_t>> lineEndings() const final;
private:
- CSSStyleDeclaration* inlineStyle() const;
+ CSSStyleDeclaration& inlineStyle() const;
const String& elementStyleText() const;
Ref<CSSRuleSourceData> ruleSourceData() const;
- RefPtr<Element> m_element;
+ Ref<StyledElement> m_element;
RefPtr<CSSRuleSourceData> m_ruleSourceData;
RefPtr<InspectorStyle> m_inspectorStyle;
Modified: trunk/Source/WebCore/svg/SVGElement.idl (216425 => 216426)
--- trunk/Source/WebCore/svg/SVGElement.idl 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebCore/svg/SVGElement.idl 2017-05-08 16:50:46 UTC (rev 216426)
@@ -30,7 +30,6 @@
attribute DOMString xmlspace;
readonly attribute SVGAnimatedString className;
- [ImplementedAs=cssomStyle] readonly attribute CSSStyleDeclaration style;
attribute long tabIndex;
@@ -44,4 +43,5 @@
readonly attribute DOMStringMap dataset;
};
+SVGElement implements ElementCSSInlineStyle;
SVGElement implements GlobalEventHandlers;
Modified: trunk/Source/WebKit/mac/ChangeLog (216425 => 216426)
--- trunk/Source/WebKit/mac/ChangeLog 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/mac/ChangeLog 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1,3 +1,19 @@
+2017-05-08 Chris Dumez <cdu...@apple.com>
+
+ Move 'style' from Element to HTMLElement / SVGElement and make it settable
+ https://bugs.webkit.org/show_bug.cgi?id=171795
+
+ Reviewed by Alex Christensen.
+
+ Build fix.
+
+ * DOM/DOMElement.mm:
+ (-[DOMElement style]):
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::shouldApplyStyle):
+ * WebView/WebFrame.mm:
+ (-[WebFrame _typingStyle]):
+
2017-05-06 Chris Dumez <cdu...@apple.com>
Align our IDL files with the latest DOM specification
Modified: trunk/Source/WebKit/mac/DOM/DOMElement.mm (216425 => 216426)
--- trunk/Source/WebKit/mac/DOM/DOMElement.mm 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/mac/DOM/DOMElement.mm 2017-05-08 16:50:46 UTC (rev 216426)
@@ -41,6 +41,7 @@
#import <WebCore/NameNodeList.h>
#import <WebCore/NodeList.h>
#import <WebCore/StyleProperties.h>
+#import <WebCore/StyledElement.h>
#import <WebCore/ThreadCheck.h>
#import <WebCore/WebScriptObjectPrivate.h>
@@ -72,7 +73,8 @@
- (DOMCSSStyleDeclaration *)style
{
WebCore::JSMainThreadNullState state;
- return kit(unwrap(*self).cssomStyle());
+ auto& element = unwrap(*self);
+ return is<WebCore::StyledElement>(element) ? kit(&downcast<WebCore::StyledElement>(element).cssomStyle()) : nullptr;
}
- (int)offsetLeft
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (216425 => 216426)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2017-05-08 16:50:46 UTC (rev 216426)
@@ -254,7 +254,7 @@
{
Ref<MutableStyleProperties> mutableStyle(style->isMutable() ? Ref<MutableStyleProperties>(static_cast<MutableStyleProperties&>(*style)) : style->mutableCopy());
return [[m_webView _editingDelegateForwarder] webView:m_webView
- shouldApplyStyle:kit(mutableStyle->ensureCSSStyleDeclaration()) toElementsInDOMRange:kit(range)];
+ shouldApplyStyle:kit(&mutableStyle->ensureCSSStyleDeclaration()) toElementsInDOMRange:kit(range)];
}
static void updateFontPanel(WebView *webView)
Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (216425 => 216426)
--- trunk/Source/WebKit/mac/WebView/WebFrame.mm 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm 2017-05-08 16:50:46 UTC (rev 216426)
@@ -921,7 +921,7 @@
RefPtr<MutableStyleProperties> typingStyle = _private->coreFrame->selection().copyTypingStyle();
if (!typingStyle)
return nil;
- return kit(typingStyle->ensureCSSStyleDeclaration());
+ return kit(&typingStyle->ensureCSSStyleDeclaration());
}
- (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (216425 => 216426)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2017-05-08 16:50:46 UTC (rev 216426)
@@ -2105,7 +2105,7 @@
auto* style = editingStyle->style();
if (!style)
return nil;
- return kit(style->ensureCSSStyleDeclaration());
+ return kit(&style->ensureCSSStyleDeclaration());
}
- (NSUInteger)_renderTreeSize
Modified: trunk/Source/WebKit/win/DOMCoreClasses.cpp (216425 => 216426)
--- trunk/Source/WebKit/win/DOMCoreClasses.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit/win/DOMCoreClasses.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -54,6 +54,7 @@
#include <WebCore/Range.h>
#include <WebCore/RenderElement.h>
#include <WebCore/RenderTreeAsText.h>
+#include <WebCore/StyledElement.h>
#include <initguid.h>
// {3B0C0EFF-478B-4b0b-8290-D2321E08E23E}
@@ -1350,14 +1351,10 @@
if (!result)
return E_POINTER;
*result = nullptr;
- if (!m_element)
+ if (!is<WebCore::StyledElement>(m_element))
return E_FAIL;
- WebCore::CSSStyleDeclaration* style = m_element->cssomStyle();
- if (!style)
- return E_FAIL;
-
- *result = DOMCSSStyleDeclaration::createInstance(style);
+ *result = DOMCSSStyleDeclaration::createInstance(&downcast<WebCore::StyledElement>(*m_element).cssomStyle());
return *result ? S_OK : E_FAIL;
}
Modified: trunk/Source/WebKit2/ChangeLog (216425 => 216426)
--- trunk/Source/WebKit2/ChangeLog 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit2/ChangeLog 2017-05-08 16:50:46 UTC (rev 216426)
@@ -1,3 +1,15 @@
+2017-05-08 Chris Dumez <cdu...@apple.com>
+
+ Move 'style' from Element to HTMLElement / SVGElement and make it settable
+ https://bugs.webkit.org/show_bug.cgi?id=171795
+
+ Reviewed by Alex Christensen.
+
+ Build fix.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::shouldApplyStyle):
+
2017-05-07 Simon Fraser <simon.fra...@apple.com>
[iOS] REGRESSION (r209409): getBoundingClientRect is wrong for fixed-position elements in resize/orientationchange
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp (216425 => 216426)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -29,6 +29,7 @@
#include "GObjectEventListener.h"
#include <WebCore/HTMLNames.h>
#include <WebCore/JSMainThreadExecState.h>
+#include <WebCore/StyledElement.h>
#include "WebKitDOMAttrPrivate.h"
#include "WebKitDOMCSSStyleDeclarationPrivate.h"
#include "WebKitDOMClientRectListPrivate.h"
@@ -1049,9 +1050,10 @@
{
WebCore::JSMainThreadNullState state;
g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
- WebCore::Element* item = WebKit::core(self);
- RefPtr<WebCore::CSSStyleDeclaration> gobjectResult = WTF::getPtr(item->cssomStyle());
- return WebKit::kit(gobjectResult.get());
+ auto& item = *WebKit::core(self);
+ if (!is<WebCore::StyledElement>(item))
+ return nullptr;
+ return WebKit::kit(&downcast<WebCore::StyledElement>(item).cssomStyle());
}
gchar* webkit_dom_element_get_id(WebKitDOMElement* self)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (216425 => 216426)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2017-05-08 16:43:07 UTC (rev 216425)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2017-05-08 16:50:46 UTC (rev 216426)
@@ -151,7 +151,7 @@
bool WebEditorClient::shouldApplyStyle(StyleProperties* style, Range* range)
{
Ref<MutableStyleProperties> mutableStyle(style->isMutable() ? Ref<MutableStyleProperties>(static_cast<MutableStyleProperties&>(*style)) : style->mutableCopy());
- bool result = m_page->injectedBundleEditorClient().shouldApplyStyle(*m_page, mutableStyle->ensureCSSStyleDeclaration(), range);
+ bool result = m_page->injectedBundleEditorClient().shouldApplyStyle(*m_page, &mutableStyle->ensureCSSStyleDeclaration(), range);
notImplemented();
return result;
}