summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/Layout/LayoutNode.cpp
AgeCommit message (Collapse)Author
2019-10-15LibHTML: Add is<T> and to<T> helpers for LayoutNode class familyAndreas Kling
2019-10-13LibHTML: Add some convenient geometry getters on LayoutNodeAndreas Kling
Add x(), y(), size() and position() and use them around the codebase.
2019-10-13LibHTML: Move layout root from HtmlView to DocumentAndreas Kling
The layout root is now kept alive via Document::m_layout_root. This will allow us to do more layout-related things inside the inner layer of LibHTML without reaching out to the HtmlView. I'd like to keep HtmlView at a slightly higher level, to prevent it from getting too complex. This patch also fixes accidental disconnection of the layout tree from the DOM after doing a layout tree rebuild. ~LayoutNode() now only unsets the DOM node's layout_node() if it's itself.
2019-10-09LibHTML: Implement the <blink> elementAndreas Kling
Just in time for Serenity's 1st birthday, here is the <blink> element! This patch adds a bunch of different mechanisms to enable partial repaints of the layout tree (LayoutNode::set_needs_display())) It also adds LayoutNode::is_visible(), which can be toggled to prevent a LayoutNode from rendering anything (it still takes up space though.)
2019-10-08LibHTML: Use an enum for CSS property ID'sAndreas Kling
Instead of using string everywhere, have the CSS parser produce enum values, since they are a lot nicer to work with. In the future we should generate most of this code based on a list of supported CSS properties.
2019-10-07LibHTML: Add LayoutNodeWithStyle class, make LayoutText style-lessAndreas Kling
Since LayoutText always inherits style, it shouldn't store any style of its own. This patch adds a LayoutNodeWithStyle class to sit between LayoutNode and everyone who wants to inherit from LayoutNode except LayoutText :^) Since LayoutText can never have children, we also know that the parent of any LayoutNode is always going to be a LayoutNodeWithStyle. So this patch makes LayoutNode::parent() return LayoutNodeWithStyle*.
2019-10-07LibHTML: Rename "style_properties" to "style" everywhereAndreas Kling
2019-10-06LibHTML: Respect the link color set via <body link>Andreas Kling
The default style for "a" tags now has { color: -libhtml-link; }. We implement this vendor-specific property by querying the containing document for the appropriate link color. Currently we only use the basic link color, but in the future this can be extended to remember visited links, etc.
2019-10-05LibHTML: Implement basic layout for inline <img alt>Andreas Kling
LayoutReplaced objects can now participate in inline layout. It's very hackish, but basically LayoutReplaced will just add itself to the last line in the containing block. This patch gets rid of the idea that only LayoutInline subclasses can be split into lines, by moving the split_into_lines() virtual up to LayoutNode and overriding it in LayoutReplaced.
2019-10-04LibHTML: Add support for <body bgcolor="#rrggbb" text="#rrggbb">Andreas Kling
This patch implements basic support for presentational hints, which are old-school HTML attributes that affect style. You add support for a presentational hint attribute by overriding Element::apply_presentational_hints(StyleProperties&) and setting all of the corresponding CSS properties as appropriate. To make the background color fill the entire document, not just the bounds of the <body> element's LayoutNode, we special-case it in the HtmlView::paint_event() code for now. I'm not entirely sure what the nicest solution would be, but I'm sure we'll discover it eventually.
2019-10-04LibHTML: Rename LayoutNode::style_properties() to LayoutNode::style()Andreas Kling
2019-10-04LibHTML: Rename ComputedStyle to BoxModelMetricsAndreas Kling
There was nothing left in ComputedStyle except the box model metrics, so this patch gives it a more representative name. Note that style information is fetched directly from StyleProperties, which is basically the CSS property name/value pairs that apply to an element.
2019-10-04LibHTML: LayoutText should always use parent's style propertiesAndreas Kling
This patch makes StyleProperties heap-allocated and ref-counted so that a LayoutNode can be without one. The ref-counting also allows anonymous blocks to share style with their parent block. LayoutText never needs a StyleProperties, since text always inherits style from its parent element. This is handled by style_properties().
2019-10-01LibHTML: Implement the <hr> elementAndreas Kling
This also meant I had to implement basic support for the border-styles "inset" and "outset". If it's neither of those, we default to "solid".
2019-10-01LibHTML: Implement basic border renderingAndreas Kling
We currently assume the border-style is solid, and simply draw a box around the padded LayoutNode rect. :^)
2019-10-01LibHTML: Include padding when rendering background colorsAndreas Kling
2019-09-29LibHTML: Implement basic support for background-colorAndreas Kling
2019-09-29LibHTML: Have Document track its hovered NodeAndreas Kling
This gets set from HtmlView::mousemove_event() at the moment.
2019-09-29LibHTML: Add LayoutNode::document() for easy accessAndreas Kling
Every LayoutNode indirectly belongs to some Document. For anonymous LayoutNodes, we simply traverse the parent chain until we find someone with a Node from which we can get a Document&.
2019-09-29LibHTML: Make hit testing work for LayoutTextAndreas Kling
LayoutText can't simply rely on its LayoutNode::rect() for hit testing. Instead, we have to iterate over the individual runs and see if we're hitting any of them. Also, LayoutNode::hit_test() now always recurses into children, since we can't trust the rect() to tell the truth (inline rects are wrong.)
2019-09-28LibHTML: Implement naive hit testingAndreas Kling
We don't have proper line boxes yet, so we can't easily hit test inline text.
2019-09-28LibHTML: Implement renderingSergey Bugaev
2019-09-28LibHTML: Get rid of the style treeSergey Bugaev
We now create a layout tree directly from the DOM tree. This way we don't actually lose text nodes ^)
2019-07-08LibHTML: Create anonymous blocks around inline children of blocks.Andreas Kling
2019-07-04Libraries: Create top level directory for libraries.Andreas Kling
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.