mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb: Add CSSStyleSheet.{insert,delete,remove}Rule() APIs
Note that insertRule() is really just a big TODO right now.
This commit is contained in:
parent
3a4565beec
commit
30d710a0a2
5 changed files with 73 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -24,4 +25,28 @@ bool CSSRuleList::is_supported_property_index(u32 index) const
|
|||
return index < m_rules.size();
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#remove-a-css-rule
|
||||
DOM::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
|
||||
{
|
||||
// 1. Set length to the number of items in list.
|
||||
auto length = m_rules.size();
|
||||
|
||||
// 2. If index is greater than or equal to length, then throw an IndexSizeError exception.
|
||||
if (index >= length)
|
||||
return DOM::IndexSizeError::create("CSS rule index out of bounds.");
|
||||
|
||||
// 3. Set old rule to the indexth item in list.
|
||||
auto& old_rule = m_rules[index];
|
||||
|
||||
// FIXME: 4. If old rule is an @namespace at-rule, and list contains anything other than @import at-rules, and @namespace at-rules, throw an InvalidStateError exception.
|
||||
(void)old_rule;
|
||||
|
||||
// 5. Remove rule old rule from list at the zero-indexed position index.
|
||||
m_rules.remove(index);
|
||||
|
||||
// FIXME: 6. Set old rule’s parent CSS rule and parent CSS style sheet to null.
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue