mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 04:34:59 +00:00
parent
fb4a20ade5
commit
b13fe9397d
8 changed files with 105 additions and 1 deletions
|
@ -10,8 +10,10 @@
|
|||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLTableCellElement.h>
|
||||
#include <LibWeb/HTML/HTMLTableElement.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -29,6 +31,16 @@ void HTMLTableCellElement::initialize(JS::Realm& realm)
|
|||
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableCellElementPrototype>(realm, "HTMLTableCellElement"));
|
||||
}
|
||||
|
||||
static const HTML::HTMLTableElement* table_containing_cell(const DOM::Node* node)
|
||||
{
|
||||
if (!is<const HTML::HTMLTableCellElement>(node))
|
||||
return nullptr;
|
||||
auto parent_node = node->parent();
|
||||
while (!is<HTML::HTMLTableElement>(parent_node))
|
||||
parent_node = parent_node->parent();
|
||||
return static_cast<const HTML::HTMLTableElement*>(parent_node);
|
||||
}
|
||||
|
||||
void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||
{
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
|
@ -67,6 +79,19 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
|||
return;
|
||||
}
|
||||
});
|
||||
auto table_element = table_containing_cell(this);
|
||||
auto border = table_element->border();
|
||||
if (!border)
|
||||
return;
|
||||
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
|
||||
style.set_property(style_property, CSS::IdentifierStyleValue::create(CSS::ValueID::Inset));
|
||||
style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1)));
|
||||
style.set_property(color_property, table_element->computed_css_values()->property(color_property));
|
||||
};
|
||||
apply_border_style(CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor);
|
||||
apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor);
|
||||
apply_border_style(CSS::PropertyID::BorderRightStyle, CSS::PropertyID::BorderRightWidth, CSS::PropertyID::BorderRightColor);
|
||||
apply_border_style(CSS::PropertyID::BorderBottomStyle, CSS::PropertyID::BorderBottomWidth, CSS::PropertyID::BorderBottomColor);
|
||||
}
|
||||
|
||||
unsigned int HTMLTableCellElement::col_span() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue