Diff
Modified: trunk/LayoutTests/ChangeLog (101986 => 101987)
--- trunk/LayoutTests/ChangeLog 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/ChangeLog 2011-12-05 11:48:28 UTC (rev 101987)
@@ -1,3 +1,23 @@
+2011-12-05 Roland Steiner <[email protected]>
+
+ <style scoped>: Add 'scoped' attribute
+ https://bugs.webkit.org/show_bug.cgi?id=67718
+
+ Test setting/resetting of the 'scoped' attribute in various circumstances.
+ Disable test directory, since STYLE_SCOPED is not enabled by default.
+
+ Reviewed by Antti Koivisto.
+
+ * fast/css/style-scoped/basic-attribute-expected.txt: Added.
+ * fast/css/style-scoped/basic-attribute.html: Added.
+ * platform/chromium/test_expectations.txt:
+ * platform/efl/Skipped:
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+ * platform/wincairo/Skipped:
+
2011-12-05 Vsevolod Vlasov <[email protected]>
Unreviewed chromium tests rebaseline.
Added: trunk/LayoutTests/fast/css/style-scoped/basic-attribute-expected.txt (0 => 101987)
--- trunk/LayoutTests/fast/css/style-scoped/basic-attribute-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/style-scoped/basic-attribute-expected.txt 2011-12-05 11:48:28 UTC (rev 101987)
@@ -0,0 +1,62 @@
+Basic test for the <style scoped> attribute.
+
+--- Initial ---
+PASS global1.getAttribute('scoped') is null
+PASS global1.scoped is false
+PASS global2.getAttribute('scoped') is null
+PASS global2.scoped is false
+PASS testBooleanAttribute(scoped1, 'scoped') is true
+PASS scoped1.scoped is true
+PASS testBooleanAttribute(scoped2, 'scoped') is true
+PASS scoped2.scoped is true
+PASS testBooleanAttribute(scoped3, 'scoped') is true
+PASS scoped3.scoped is true
+--- After insertion into tree ---
+PASS global1.getAttribute('scoped') is null
+PASS global1.scoped is false
+PASS global2.getAttribute('scoped') is null
+PASS global2.scoped is false
+PASS testBooleanAttribute(scoped1, 'scoped') is true
+PASS scoped1.scoped is true
+PASS testBooleanAttribute(scoped2, 'scoped') is true
+PASS scoped2.scoped is true
+PASS testBooleanAttribute(scoped3, 'scoped') is true
+PASS scoped3.scoped is true
+--- Inverting 'scoped' attribute while in tree ---
+PASS testBooleanAttribute(global1, 'scoped') is true
+PASS global1.scoped is true
+PASS testBooleanAttribute(global2, 'scoped') is true
+PASS global2.scoped is true
+PASS scoped1.getAttribute('scoped') is null
+PASS scoped1.scoped is false
+PASS scoped2.getAttribute('scoped') is null
+PASS scoped2.scoped is false
+PASS scoped3.getAttribute('scoped') is null
+PASS scoped3.scoped is false
+--- After removal from tree (attribute is still inverted) ---
+PASS testBooleanAttribute(global1, 'scoped') is true
+PASS global1.scoped is true
+PASS testBooleanAttribute(global2, 'scoped') is true
+PASS global2.scoped is true
+PASS scoped1.getAttribute('scoped') is null
+PASS scoped1.scoped is false
+PASS scoped2.getAttribute('scoped') is null
+PASS scoped2.scoped is false
+PASS scoped3.getAttribute('scoped') is null
+PASS scoped3.scoped is false
+--- Inverting 'scoped' attribute again, while outside tree ---
+PASS global1.getAttribute('scoped') is null
+PASS global1.scoped is false
+PASS global2.getAttribute('scoped') is null
+PASS global2.scoped is false
+PASS testBooleanAttribute(scoped1, 'scoped') is true
+PASS scoped1.scoped is true
+PASS testBooleanAttribute(scoped2, 'scoped') is true
+PASS scoped2.scoped is true
+PASS testBooleanAttribute(scoped3, 'scoped') is true
+PASS scoped3.scoped is true
+--- DONE ---
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/style-scoped/basic-attribute.html (0 => 101987)
--- trunk/LayoutTests/fast/css/style-scoped/basic-attribute.html (rev 0)
+++ trunk/LayoutTests/fast/css/style-scoped/basic-attribute.html 2011-12-05 11:48:28 UTC (rev 101987)
@@ -0,0 +1,124 @@
+<html>
+<head>
+ <link rel="stylesheet" href=""
+ <script src=""
+</head>
+<body>
+ <p>Basic test for the <style scoped> attribute.</p>
+ <div id="scope">
+ <style id="global1"></style>
+ <style scoped='scoped' id="scoped1"></style>
+ </div>
+
+ <div id="console"></div>
+
+ <script>
+ function testBooleanAttribute(elem, attr)
+ {
+ var val = elem.getAttribute(attr);
+ if (val === null)
+ return false
+ if (val === '' || val === attr)
+ return true;
+ throw "Illegal value for boolean attribute!";
+ }
+
+ var scope = document.getElementById('scope');
+
+ var global1 = document.getElementById('global1');
+ var scoped1 = document.getElementById('scoped1');
+
+ var global2 = document.createElement('style');
+ var scoped2 = document.createElement('style');
+ scoped2.setAttribute('scoped', 'scoped');
+ var scoped3 = document.createElement('style');
+ scoped3.scoped = true;
+
+ debug("--- Initial ---");
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- After insertion into tree ---")
+ scope.appendChild(global2);
+ scope.appendChild(scoped2);
+ scope.appendChild(scoped3);
+
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- Inverting 'scoped' attribute while in tree ---");
+ scoped1.scoped = null;
+ scoped2.scoped = false;
+ scoped3.removeAttribute('scoped');
+ global1.scoped = true;
+ global2.setAttribute('scoped', 'scoped');
+
+ shouldBeTrue("testBooleanAttribute(global1, 'scoped')");
+ shouldBeTrue("global1.scoped");
+ shouldBeTrue("testBooleanAttribute(global2, 'scoped')");
+ shouldBeTrue("global2.scoped");
+ shouldBeNull("scoped1.getAttribute('scoped')");
+ shouldBeFalse("scoped1.scoped");
+ shouldBeNull("scoped2.getAttribute('scoped')");
+ shouldBeFalse("scoped2.scoped");
+ shouldBeNull("scoped3.getAttribute('scoped')");
+ shouldBeFalse("scoped3.scoped");
+
+ debug("--- After removal from tree (attribute is still inverted) ---");
+ scope.removeChild(global1);
+ scope.removeChild(global2);
+ scope.removeChild(scoped1);
+ scope.removeChild(scoped2);
+ scope.removeChild(scoped3);
+
+ shouldBeTrue("testBooleanAttribute(global1, 'scoped')");
+ shouldBeTrue("global1.scoped");
+ shouldBeTrue("testBooleanAttribute(global2, 'scoped')");
+ shouldBeTrue("global2.scoped");
+ shouldBeNull("scoped1.getAttribute('scoped')");
+ shouldBeFalse("scoped1.scoped");
+ shouldBeNull("scoped2.getAttribute('scoped')");
+ shouldBeFalse("scoped2.scoped");
+ shouldBeNull("scoped3.getAttribute('scoped')");
+ shouldBeFalse("scoped3.scoped");
+
+ debug("--- Inverting 'scoped' attribute again, while outside tree ---");
+ scoped1.scoped = true;
+ scoped2.scoped = true;
+ scoped3.setAttribute('scoped', 'scoped');
+ global1.scoped = false;
+ global2.removeAttribute('scoped');
+
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- DONE ---");
+ var successfullyParsed = true;
+ </script>
+ <script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (101986 => 101987)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-05 11:48:28 UTC (rev 101987)
@@ -3195,6 +3195,9 @@
// MutationObservers not yet enabled.
BUGWK68729 SKIP : fast/mutation = PASS
+// <style scoped> not yet enabled.
+BUGWK49142 SKIP: fast/css/style-scoped = PASS
+
BUGCR85755 : fast/js/exception-properties.html = TEXT
BUGWK62430 LINUX WIN : fast/dom/HTMLProgressElement/indeterminate-progress-001.html = FAIL
Modified: trunk/LayoutTests/platform/efl/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/efl/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/efl/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -1889,6 +1889,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# CSS Filters support not yet enabled (needs ENABLE_CSS_FILTERS).
# https://bugs.webkit.org/show_bug.cgi?id=68469
css3/filters
Modified: trunk/LayoutTests/platform/gtk/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/gtk/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/gtk/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -353,6 +353,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# CSS Regions support not yet enabled. http://webkit.org/b/57312
fast/regions
Modified: trunk/LayoutTests/platform/mac/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/mac/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/mac/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -419,6 +419,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# JSC does not support setIsolatedWorldSecurityOrigin (http://webkit.org/b/61540)
http/tests/security/isolatedWorld/cross-origin-xhr.html
Modified: trunk/LayoutTests/platform/qt/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/qt/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/qt/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -160,6 +160,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# CSS Regions support not yet enabled. http://webkit.org/b/57312
fast/regions
Modified: trunk/LayoutTests/platform/win/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/win/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/win/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -1399,6 +1399,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# CSS Regions support not yet enabled. http://webkit.org/b/57312
fast/regions
Modified: trunk/LayoutTests/platform/wincairo/Skipped (101986 => 101987)
--- trunk/LayoutTests/platform/wincairo/Skipped 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/LayoutTests/platform/wincairo/Skipped 2011-12-05 11:48:28 UTC (rev 101987)
@@ -1910,6 +1910,9 @@
# CSS Grid Layout is not yet enabled. http://webkit.org/b/60731
fast/css-grid-layout
+# <style scoped> is not yet enabled. http://webkit.org/b/49142
+fast/css/style-scoped
+
# CSS Regions support not yet enabled. http://webkit.org/b/57312
fast/regions
Modified: trunk/Source/WebCore/ChangeLog (101986 => 101987)
--- trunk/Source/WebCore/ChangeLog 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/Source/WebCore/ChangeLog 2011-12-05 11:48:28 UTC (rev 101987)
@@ -1,3 +1,23 @@
+2011-12-05 Roland Steiner <[email protected]>
+
+ <style scoped>: Add 'scoped' attribute
+ https://bugs.webkit.org/show_bug.cgi?id=67718
+
+ Add 'scoped' attribute to IDL and attribute list,
+ implement and test setting/resetting of the attribute.
+
+ Reviewed by Antti Koivisto.
+
+ Test: fast/css/style-scoped/basic-attribute.html
+
+ * html/HTMLAttributeNames.in:
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::scoped):
+ (WebCore::HTMLStyleElement::setScoped):
+ (WebCore::HTMLStyleElement::scopingElement):
+ * html/HTMLStyleElement.h:
+ * html/HTMLStyleElement.idl:
+
2011-12-05 Hajime Morrita <[email protected]>
[Refactoring] Accessing Node::m_document should be minimized.
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (101986 => 101987)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-12-05 11:48:28 UTC (rev 101987)
@@ -273,6 +273,7 @@
sandbox
scheme
scope
+scoped
scrollamount
scrolldelay
scrolling
Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (101986 => 101987)
--- trunk/Source/WebCore/html/HTMLStyleElement.cpp 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp 2011-12-05 11:48:28 UTC (rev 101987)
@@ -94,6 +94,33 @@
return getAttribute(typeAttr);
}
+#if ENABLE(STYLE_SCOPED)
+bool HTMLStyleElement::scoped() const
+{
+ return fastHasAttribute(scopedAttr);
+}
+
+void HTMLStyleElement::setScoped(bool scopedValue)
+{
+ setBooleanAttribute(scopedAttr, scopedValue);
+}
+
+Element* HTMLStyleElement::scopingElement() const
+{
+ if (!scoped())
+ return 0;
+
+ // FIXME: This probably needs to be refined for scoped stylesheets within shadow DOM.
+ // As written, such a stylesheet could style the host element, as well as children of the host.
+ // OTOH, this paves the way for a :bound-element implementation.
+ ContainerNode* parentOrHost = parentOrHostNode();
+ if (!parentOrHost || !parentOrHost->isElementNode())
+ return 0;
+
+ return toElement(parentOrHost);
+}
+#endif // ENABLE(STYLE_SCOPED)
+
void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
HTMLElement::addSubresourceAttributeURLs(urls);
Modified: trunk/Source/WebCore/html/HTMLStyleElement.h (101986 => 101987)
--- trunk/Source/WebCore/html/HTMLStyleElement.h 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/Source/WebCore/html/HTMLStyleElement.h 2011-12-05 11:48:28 UTC (rev 101987)
@@ -37,6 +37,12 @@
void setType(const AtomicString&);
+#if ENABLE(STYLE_SCOPED)
+ bool scoped() const;
+ void setScoped(bool);
+ Element* scopingElement() const;
+#endif
+
using StyleElement::sheet;
bool disabled() const;
Modified: trunk/Source/WebCore/html/HTMLStyleElement.idl (101986 => 101987)
--- trunk/Source/WebCore/html/HTMLStyleElement.idl 2011-12-05 11:38:44 UTC (rev 101986)
+++ trunk/Source/WebCore/html/HTMLStyleElement.idl 2011-12-05 11:48:28 UTC (rev 101987)
@@ -22,6 +22,7 @@
interface HTMLStyleElement : HTMLElement {
attribute boolean disabled;
+ attribute [Conditional=STYLE_SCOPED] boolean scoped;
attribute [Reflect] DOMString media;
attribute [Reflect] DOMString type;