Refactorcss
收藏资源简介:
Cascading Style Sheets (CSS) is a language used for describing the look and formatting of HTML documents. CSS has been widely adopted in web and mobile development practice, since it enables a clean separation of content from presentation. The language exhibits complex features, such as inheritance, cascading and specificity, which make CSS code hard to maintain. Therefore, it is important to find ways to improve the maintainability of CSS code. In this paper, we propose an automated approach to remove duplication in CSS code. More specifically, we have developed a technique that detects three types of CSS declaration duplication and recommends refactoring opportunities to eliminate those duplications. Our approach uses preconditions that ensure the application of a refactoring will preserve the original document styling. We evaluate our technique on 38 real-world web systems and 91 CSS files, in total. Our findings show that duplication in CSS code is widely prevalent. Additionally, there is a significant number of presentation-preserving refactoring opportunities that can reduce the size of the CSS files and increase the maintainability of the code.
层叠样式表(Cascading Style Sheets,CSS)是一种用于定义超文本标记语言(HyperText Markup Language,HTML)文档外观与排版格式的样式语言。由于其能够实现内容与表现的清晰分离,CSS已在Web与移动端开发实践中得到广泛应用。该语言具备继承、层叠与选择器特异性等复杂特性,这使得CSS代码的维护难度大幅提升。因此,探寻提升CSS代码可维护性的有效路径具有重要意义。本研究提出一种用于消除CSS代码重复的自动化方法。具体而言,我们开发了一项可检测三类CSS声明重复的技术,并会输出重构建议以消除此类重复。该方法通过前置条件约束,可确保重构操作不会改变原文档的样式效果。我们共在38个真实Web系统与91个CSS文件上对所提技术进行了评估。评估结果表明,CSS代码中的重复问题广泛存在。此外,存在大量可保持文档表现不变的重构契机,此类重构能够缩减CSS文件体积并提升代码的可维护性。



