ComputedCSSStyleDeclaration.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/CSS/ComputedCSSStyleDeclaration.h>
  8. #include <LibWeb/CSS/StyleResolver.h>
  9. #include <LibWeb/DOM/Document.h>
  10. #include <LibWeb/DOM/Element.h>
  11. namespace Web::CSS {
  12. ComputedCSSStyleDeclaration::ComputedCSSStyleDeclaration(DOM::Element& element)
  13. : m_element(element)
  14. {
  15. }
  16. ComputedCSSStyleDeclaration::~ComputedCSSStyleDeclaration()
  17. {
  18. }
  19. size_t ComputedCSSStyleDeclaration::length() const
  20. {
  21. return 0;
  22. }
  23. String ComputedCSSStyleDeclaration::item(size_t index) const
  24. {
  25. (void)index;
  26. return {};
  27. }
  28. static CSS::ValueID to_css_value_id(CSS::Display value)
  29. {
  30. switch (value) {
  31. case CSS::Display::None:
  32. return CSS::ValueID::None;
  33. case CSS::Display::Block:
  34. return CSS::ValueID::Block;
  35. case CSS::Display::Inline:
  36. return CSS::ValueID::Inline;
  37. case CSS::Display::InlineBlock:
  38. return CSS::ValueID::InlineBlock;
  39. case CSS::Display::ListItem:
  40. return CSS::ValueID::ListItem;
  41. case CSS::Display::Table:
  42. return CSS::ValueID::Table;
  43. case CSS::Display::TableRow:
  44. return CSS::ValueID::TableRow;
  45. case CSS::Display::TableCell:
  46. return CSS::ValueID::TableCell;
  47. case CSS::Display::TableHeaderGroup:
  48. return CSS::ValueID::TableHeaderGroup;
  49. case CSS::Display::TableRowGroup:
  50. return CSS::ValueID::TableRowGroup;
  51. case CSS::Display::TableFooterGroup:
  52. return CSS::ValueID::TableFooterGroup;
  53. case CSS::Display::TableColumn:
  54. return CSS::ValueID::TableColumn;
  55. case CSS::Display::TableColumnGroup:
  56. return CSS::ValueID::TableColumnGroup;
  57. case CSS::Display::TableCaption:
  58. return CSS::ValueID::TableCaption;
  59. case CSS::Display::Flex:
  60. return CSS::ValueID::Flex;
  61. }
  62. VERIFY_NOT_REACHED();
  63. }
  64. static CSS::ValueID to_css_value_id(CSS::Float value)
  65. {
  66. switch (value) {
  67. case Float::None:
  68. return CSS::ValueID::None;
  69. case Float::Left:
  70. return CSS::ValueID::Left;
  71. case Float::Right:
  72. return CSS::ValueID::Right;
  73. }
  74. VERIFY_NOT_REACHED();
  75. }
  76. static CSS::ValueID to_css_value_id(CSS::Clear value)
  77. {
  78. switch (value) {
  79. case Clear::None:
  80. return CSS::ValueID::None;
  81. case Clear::Left:
  82. return CSS::ValueID::Left;
  83. case Clear::Right:
  84. return CSS::ValueID::Right;
  85. case Clear::Both:
  86. return CSS::ValueID::Both;
  87. }
  88. VERIFY_NOT_REACHED();
  89. }
  90. static CSS::ValueID to_css_value_id(CSS::TextDecorationLine value)
  91. {
  92. switch (value) {
  93. case TextDecorationLine::None:
  94. return CSS::ValueID::None;
  95. case TextDecorationLine::Underline:
  96. return CSS::ValueID::Underline;
  97. case TextDecorationLine::Overline:
  98. return CSS::ValueID::Overline;
  99. case TextDecorationLine::LineThrough:
  100. return CSS::ValueID::LineThrough;
  101. case TextDecorationLine::Blink:
  102. return CSS::ValueID::Blink;
  103. }
  104. VERIFY_NOT_REACHED();
  105. }
  106. static CSS::ValueID to_css_value_id(CSS::Cursor value)
  107. {
  108. switch (value) {
  109. case Cursor::Auto:
  110. return CSS::ValueID::Auto;
  111. case Cursor::Default:
  112. return CSS::ValueID::Default;
  113. case Cursor::None:
  114. return CSS::ValueID::None;
  115. case Cursor::ContextMenu:
  116. return CSS::ValueID::ContextMenu;
  117. case Cursor::Help:
  118. return CSS::ValueID::Help;
  119. case Cursor::Pointer:
  120. return CSS::ValueID::Pointer;
  121. case Cursor::Progress:
  122. return CSS::ValueID::Progress;
  123. case Cursor::Wait:
  124. return CSS::ValueID::Wait;
  125. case Cursor::Cell:
  126. return CSS::ValueID::Cell;
  127. case Cursor::Crosshair:
  128. return CSS::ValueID::Crosshair;
  129. case Cursor::Text:
  130. return CSS::ValueID::Text;
  131. case Cursor::VerticalText:
  132. return CSS::ValueID::VerticalText;
  133. case Cursor::Alias:
  134. return CSS::ValueID::Alias;
  135. case Cursor::Copy:
  136. return CSS::ValueID::Copy;
  137. case Cursor::Move:
  138. return CSS::ValueID::Move;
  139. case Cursor::NoDrop:
  140. return CSS::ValueID::NoDrop;
  141. case Cursor::NotAllowed:
  142. return CSS::ValueID::NotAllowed;
  143. case Cursor::Grab:
  144. return CSS::ValueID::Grab;
  145. case Cursor::Grabbing:
  146. return CSS::ValueID::Grabbing;
  147. case Cursor::EResize:
  148. return CSS::ValueID::EResize;
  149. case Cursor::NResize:
  150. return CSS::ValueID::NResize;
  151. case Cursor::NeResize:
  152. return CSS::ValueID::NeResize;
  153. case Cursor::NwResize:
  154. return CSS::ValueID::NwResize;
  155. case Cursor::SResize:
  156. return CSS::ValueID::SResize;
  157. case Cursor::SeResize:
  158. return CSS::ValueID::SeResize;
  159. case Cursor::SwResize:
  160. return CSS::ValueID::SwResize;
  161. case Cursor::WResize:
  162. return CSS::ValueID::WResize;
  163. case Cursor::EwResize:
  164. return CSS::ValueID::EwResize;
  165. case Cursor::NsResize:
  166. return CSS::ValueID::NsResize;
  167. case Cursor::NeswResize:
  168. return CSS::ValueID::NeswResize;
  169. case Cursor::NwseResize:
  170. return CSS::ValueID::NwseResize;
  171. case Cursor::ColResize:
  172. return CSS::ValueID::ColResize;
  173. case Cursor::RowResize:
  174. return CSS::ValueID::RowResize;
  175. case Cursor::AllScroll:
  176. return CSS::ValueID::AllScroll;
  177. case Cursor::ZoomIn:
  178. return CSS::ValueID::ZoomIn;
  179. case Cursor::ZoomOut:
  180. return CSS::ValueID::ZoomOut;
  181. }
  182. VERIFY_NOT_REACHED();
  183. }
  184. static CSS::ValueID to_css_value_id(CSS::TextAlign value)
  185. {
  186. switch (value) {
  187. case TextAlign::Left:
  188. return CSS::ValueID::Left;
  189. case TextAlign::Center:
  190. return CSS::ValueID::Center;
  191. case TextAlign::Right:
  192. return CSS::ValueID::Right;
  193. case TextAlign::Justify:
  194. return CSS::ValueID::Justify;
  195. case TextAlign::LibwebCenter:
  196. return CSS::ValueID::LibwebCenter;
  197. }
  198. VERIFY_NOT_REACHED();
  199. }
  200. static CSS::ValueID to_css_value_id(CSS::TextTransform value)
  201. {
  202. switch (value) {
  203. case TextTransform::None:
  204. return CSS::ValueID::None;
  205. case TextTransform::Capitalize:
  206. return CSS::ValueID::Capitalize;
  207. case TextTransform::Uppercase:
  208. return CSS::ValueID::Uppercase;
  209. case TextTransform::Lowercase:
  210. return CSS::ValueID::Lowercase;
  211. case TextTransform::FullWidth:
  212. return CSS::ValueID::FullWidth;
  213. case TextTransform::FullSizeKana:
  214. return CSS::ValueID::FullSizeKana;
  215. }
  216. VERIFY_NOT_REACHED();
  217. }
  218. static CSS::ValueID to_css_value_id(CSS::Position value)
  219. {
  220. switch (value) {
  221. case Position::Static:
  222. return CSS::ValueID::Static;
  223. case Position::Relative:
  224. return CSS::ValueID::Relative;
  225. case Position::Absolute:
  226. return CSS::ValueID::Absolute;
  227. case Position::Fixed:
  228. return CSS::ValueID::Fixed;
  229. case Position::Sticky:
  230. return CSS::ValueID::Sticky;
  231. }
  232. VERIFY_NOT_REACHED();
  233. }
  234. static CSS::ValueID to_css_value_id(CSS::WhiteSpace value)
  235. {
  236. switch (value) {
  237. case WhiteSpace::Normal:
  238. return CSS::ValueID::Normal;
  239. case WhiteSpace::Pre:
  240. return CSS::ValueID::Pre;
  241. case WhiteSpace::Nowrap:
  242. return CSS::ValueID::Nowrap;
  243. case WhiteSpace::PreLine:
  244. return CSS::ValueID::PreLine;
  245. case WhiteSpace::PreWrap:
  246. return CSS::ValueID::PreWrap;
  247. }
  248. VERIFY_NOT_REACHED();
  249. }
  250. static CSS::ValueID to_css_value_id(CSS::FlexDirection value)
  251. {
  252. switch (value) {
  253. case FlexDirection::Row:
  254. return CSS::ValueID::Row;
  255. case FlexDirection::RowReverse:
  256. return CSS::ValueID::RowReverse;
  257. case FlexDirection::Column:
  258. return CSS::ValueID::Column;
  259. case FlexDirection::ColumnReverse:
  260. return CSS::ValueID::ColumnReverse;
  261. }
  262. VERIFY_NOT_REACHED();
  263. }
  264. static CSS::ValueID to_css_value_id(CSS::FlexWrap value)
  265. {
  266. switch (value) {
  267. case FlexWrap::Nowrap:
  268. return CSS::ValueID::Nowrap;
  269. case FlexWrap::Wrap:
  270. return CSS::ValueID::Wrap;
  271. case FlexWrap::WrapReverse:
  272. return CSS::ValueID::WrapReverse;
  273. }
  274. VERIFY_NOT_REACHED();
  275. }
  276. static CSS::ValueID to_css_value_id(CSS::JustifyContent value)
  277. {
  278. switch (value) {
  279. case JustifyContent::FlexStart:
  280. return CSS::ValueID::FlexStart;
  281. case JustifyContent::FlexEnd:
  282. return CSS::ValueID::FlexEnd;
  283. case JustifyContent::Center:
  284. return CSS::ValueID::Center;
  285. case JustifyContent::SpaceBetween:
  286. return CSS::ValueID::SpaceBetween;
  287. case JustifyContent::SpaceAround:
  288. return CSS::ValueID::SpaceAround;
  289. }
  290. VERIFY_NOT_REACHED();
  291. }
  292. static CSS::ValueID to_css_value_id(CSS::Overflow value)
  293. {
  294. switch (value) {
  295. case Overflow::Auto:
  296. return CSS::ValueID::Auto;
  297. case Overflow::Clip:
  298. return CSS::ValueID::Clip;
  299. case Overflow::Hidden:
  300. return CSS::ValueID::Hidden;
  301. case Overflow::Scroll:
  302. return CSS::ValueID::Scroll;
  303. case Overflow::Visible:
  304. return CSS::ValueID::Visible;
  305. }
  306. VERIFY_NOT_REACHED();
  307. }
  308. static CSS::ValueID to_css_value_id(CSS::Repeat value)
  309. {
  310. switch (value) {
  311. case Repeat::NoRepeat:
  312. return CSS::ValueID::NoRepeat;
  313. case Repeat::Repeat:
  314. return CSS::ValueID::Repeat;
  315. case Repeat::Round:
  316. return CSS::ValueID::Round;
  317. case Repeat::Space:
  318. return CSS::ValueID::Space;
  319. }
  320. VERIFY_NOT_REACHED();
  321. }
  322. static CSS::ValueID to_css_value_id(CSS::ListStyleType value)
  323. {
  324. switch (value) {
  325. case ListStyleType::None:
  326. return CSS::ValueID::None;
  327. case ListStyleType::Disc:
  328. return CSS::ValueID::Disc;
  329. case ListStyleType::Circle:
  330. return CSS::ValueID::Circle;
  331. case ListStyleType::Square:
  332. return CSS::ValueID::Square;
  333. case ListStyleType::Decimal:
  334. return CSS::ValueID::Decimal;
  335. case ListStyleType::DecimalLeadingZero:
  336. return CSS::ValueID::DecimalLeadingZero;
  337. case ListStyleType::LowerAlpha:
  338. return CSS::ValueID::LowerAlpha;
  339. case ListStyleType::LowerLatin:
  340. return CSS::ValueID::LowerLatin;
  341. case ListStyleType::LowerRoman:
  342. return CSS::ValueID::LowerRoman;
  343. case ListStyleType::UpperAlpha:
  344. return CSS::ValueID::UpperAlpha;
  345. case ListStyleType::UpperLatin:
  346. return CSS::ValueID::UpperLatin;
  347. case ListStyleType::UpperRoman:
  348. return CSS::ValueID::UpperRoman;
  349. }
  350. VERIFY_NOT_REACHED();
  351. }
  352. Optional<StyleProperty> ComputedCSSStyleDeclaration::property(PropertyID property_id) const
  353. {
  354. const_cast<DOM::Document&>(m_element->document()).force_layout();
  355. if (!m_element->layout_node()) {
  356. auto style = m_element->document().style_resolver().resolve_style(const_cast<DOM::Element&>(*m_element));
  357. if (auto maybe_property = style->property(property_id); maybe_property.has_value()) {
  358. return StyleProperty {
  359. .property_id = property_id,
  360. .value = maybe_property.release_value(),
  361. };
  362. }
  363. return {};
  364. }
  365. auto& layout_node = *m_element->layout_node();
  366. switch (property_id) {
  367. case CSS::PropertyID::Float:
  368. return StyleProperty {
  369. .property_id = property_id,
  370. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().float_())),
  371. };
  372. case CSS::PropertyID::Clear:
  373. return StyleProperty {
  374. .property_id = property_id,
  375. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().clear())),
  376. };
  377. case CSS::PropertyID::Cursor:
  378. return StyleProperty {
  379. .property_id = property_id,
  380. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().cursor())),
  381. };
  382. case CSS::PropertyID::Display:
  383. return StyleProperty {
  384. .property_id = property_id,
  385. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().display())),
  386. };
  387. case CSS::PropertyID::ZIndex: {
  388. auto maybe_z_index = layout_node.computed_values().z_index();
  389. if (!maybe_z_index.has_value())
  390. return {};
  391. return StyleProperty {
  392. .property_id = property_id,
  393. .value = NumericStyleValue::create(maybe_z_index.release_value()),
  394. };
  395. }
  396. case CSS::PropertyID::TextAlign:
  397. return StyleProperty {
  398. .property_id = property_id,
  399. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_align())),
  400. };
  401. case CSS::PropertyID::TextDecorationLine:
  402. return StyleProperty {
  403. .property_id = property_id,
  404. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_decoration_line())),
  405. };
  406. case CSS::PropertyID::TextTransform:
  407. return StyleProperty {
  408. .property_id = property_id,
  409. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_transform())),
  410. };
  411. case CSS::PropertyID::Position:
  412. return StyleProperty {
  413. .property_id = property_id,
  414. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().position())),
  415. };
  416. case CSS::PropertyID::WhiteSpace:
  417. return StyleProperty {
  418. .property_id = property_id,
  419. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().white_space())),
  420. };
  421. case CSS::PropertyID::FlexDirection:
  422. return StyleProperty {
  423. .property_id = property_id,
  424. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().flex_direction())),
  425. };
  426. case CSS::PropertyID::FlexWrap:
  427. return StyleProperty {
  428. .property_id = property_id,
  429. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().flex_wrap())),
  430. };
  431. case CSS::PropertyID::FlexBasis: {
  432. switch (layout_node.computed_values().flex_basis().type) {
  433. case FlexBasis::Content:
  434. return StyleProperty {
  435. .property_id = property_id,
  436. .value = IdentifierStyleValue::create(CSS::ValueID::Content),
  437. };
  438. case FlexBasis::Length:
  439. return StyleProperty {
  440. .property_id = property_id,
  441. .value = LengthStyleValue::create(layout_node.computed_values().flex_basis().length),
  442. };
  443. case FlexBasis::Auto:
  444. return StyleProperty {
  445. .property_id = property_id,
  446. .value = IdentifierStyleValue::create(CSS::ValueID::Auto),
  447. };
  448. }
  449. VERIFY_NOT_REACHED();
  450. }
  451. case CSS::PropertyID::FlexGrow: {
  452. auto maybe_grow_factor = layout_node.computed_values().flex_grow_factor();
  453. if (!maybe_grow_factor.has_value())
  454. return {};
  455. return StyleProperty {
  456. .property_id = property_id,
  457. .value = NumericStyleValue::create(maybe_grow_factor.release_value()),
  458. };
  459. }
  460. case CSS::PropertyID::FlexShrink: {
  461. auto maybe_shrink_factor = layout_node.computed_values().flex_shrink_factor();
  462. if (!maybe_shrink_factor.has_value())
  463. return {};
  464. return StyleProperty {
  465. .property_id = property_id,
  466. .value = NumericStyleValue::create(maybe_shrink_factor.release_value()),
  467. };
  468. }
  469. case CSS::PropertyID::Opacity: {
  470. auto maybe_opacity = layout_node.computed_values().flex_grow_factor();
  471. if (!maybe_opacity.has_value())
  472. return {};
  473. return StyleProperty {
  474. .property_id = property_id,
  475. .value = NumericStyleValue::create(maybe_opacity.release_value()),
  476. };
  477. }
  478. case CSS::PropertyID::JustifyContent:
  479. return StyleProperty {
  480. .property_id = property_id,
  481. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().justify_content())),
  482. };
  483. case CSS::PropertyID::BoxShadow: {
  484. auto maybe_box_shadow = layout_node.computed_values().box_shadow();
  485. if (!maybe_box_shadow.has_value())
  486. return {};
  487. auto box_shadow_data = maybe_box_shadow.release_value();
  488. return StyleProperty {
  489. .property_id = property_id,
  490. .value = BoxShadowStyleValue::create(box_shadow_data.offset_x, box_shadow_data.offset_y, box_shadow_data.blur_radius, box_shadow_data.color),
  491. };
  492. }
  493. case CSS::PropertyID::Width:
  494. return StyleProperty {
  495. .property_id = property_id,
  496. .value = LengthStyleValue::create(layout_node.computed_values().width()),
  497. };
  498. case CSS::PropertyID::MinWidth:
  499. return StyleProperty {
  500. .property_id = property_id,
  501. .value = LengthStyleValue::create(layout_node.computed_values().min_width()),
  502. };
  503. case CSS::PropertyID::MaxWidth:
  504. return StyleProperty {
  505. .property_id = property_id,
  506. .value = LengthStyleValue::create(layout_node.computed_values().max_width()),
  507. };
  508. case CSS::PropertyID::Height:
  509. return StyleProperty {
  510. .property_id = property_id,
  511. .value = LengthStyleValue::create(layout_node.computed_values().height()),
  512. };
  513. case CSS::PropertyID::MinHeight:
  514. return StyleProperty {
  515. .property_id = property_id,
  516. .value = LengthStyleValue::create(layout_node.computed_values().min_height()),
  517. };
  518. case CSS::PropertyID::MaxHeight:
  519. return StyleProperty {
  520. .property_id = property_id,
  521. .value = LengthStyleValue::create(layout_node.computed_values().max_height()),
  522. };
  523. case CSS::PropertyID::MarginTop:
  524. return StyleProperty {
  525. .property_id = property_id,
  526. .value = LengthStyleValue::create(layout_node.computed_values().margin().top),
  527. };
  528. case CSS::PropertyID::MarginRight:
  529. return StyleProperty {
  530. .property_id = property_id,
  531. .value = LengthStyleValue::create(layout_node.computed_values().margin().right),
  532. };
  533. case CSS::PropertyID::MarginBottom:
  534. return StyleProperty {
  535. .property_id = property_id,
  536. .value = LengthStyleValue::create(layout_node.computed_values().margin().bottom),
  537. };
  538. case CSS::PropertyID::MarginLeft:
  539. return StyleProperty {
  540. .property_id = property_id,
  541. .value = LengthStyleValue::create(layout_node.computed_values().margin().left),
  542. };
  543. case CSS::PropertyID::PaddingTop:
  544. return StyleProperty {
  545. .property_id = property_id,
  546. .value = LengthStyleValue::create(layout_node.computed_values().padding().top),
  547. };
  548. case CSS::PropertyID::PaddingRight:
  549. return StyleProperty {
  550. .property_id = property_id,
  551. .value = LengthStyleValue::create(layout_node.computed_values().padding().right),
  552. };
  553. case CSS::PropertyID::PaddingBottom:
  554. return StyleProperty {
  555. .property_id = property_id,
  556. .value = LengthStyleValue::create(layout_node.computed_values().padding().bottom),
  557. };
  558. case CSS::PropertyID::PaddingLeft:
  559. return StyleProperty {
  560. .property_id = property_id,
  561. .value = LengthStyleValue::create(layout_node.computed_values().padding().left),
  562. };
  563. case CSS::PropertyID::BorderBottomLeftRadius:
  564. return StyleProperty {
  565. .property_id = property_id,
  566. .value = LengthStyleValue::create(layout_node.computed_values().border_bottom_left_radius()),
  567. };
  568. case CSS::PropertyID::BorderBottomRightRadius:
  569. return StyleProperty {
  570. .property_id = property_id,
  571. .value = LengthStyleValue::create(layout_node.computed_values().border_bottom_right_radius()),
  572. };
  573. case CSS::PropertyID::BorderTopLeftRadius:
  574. return StyleProperty {
  575. .property_id = property_id,
  576. .value = LengthStyleValue::create(layout_node.computed_values().border_top_left_radius()),
  577. };
  578. case CSS::PropertyID::BorderTopRightRadius:
  579. return StyleProperty {
  580. .property_id = property_id,
  581. .value = LengthStyleValue::create(layout_node.computed_values().border_top_right_radius()),
  582. };
  583. case CSS::PropertyID::OverflowX:
  584. return StyleProperty {
  585. .property_id = property_id,
  586. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().overflow_x())),
  587. };
  588. case CSS::PropertyID::OverflowY:
  589. return StyleProperty {
  590. .property_id = property_id,
  591. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().overflow_y())),
  592. };
  593. case CSS::PropertyID::Color:
  594. return StyleProperty {
  595. .property_id = property_id,
  596. .value = ColorStyleValue::create(layout_node.computed_values().color()),
  597. };
  598. case PropertyID::BackgroundColor:
  599. return StyleProperty {
  600. .property_id = property_id,
  601. .value = ColorStyleValue::create(layout_node.computed_values().background_color()),
  602. };
  603. case CSS::PropertyID::BackgroundRepeatX:
  604. return StyleProperty {
  605. .property_id = property_id,
  606. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().background_repeat_x())),
  607. };
  608. case CSS::PropertyID::BackgroundRepeatY:
  609. return StyleProperty {
  610. .property_id = property_id,
  611. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().background_repeat_y())),
  612. };
  613. case CSS::PropertyID::ListStyleType:
  614. return StyleProperty {
  615. .property_id = property_id,
  616. .value = IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().list_style_type())),
  617. };
  618. default:
  619. dbgln("FIXME: Computed style for the '{}' property was requested", string_from_property_id(property_id));
  620. return {};
  621. }
  622. }
  623. bool ComputedCSSStyleDeclaration::set_property(PropertyID, StringView)
  624. {
  625. return false;
  626. }
  627. }