File tree Expand file tree Collapse file tree 2 files changed +40
-9
lines changed Expand file tree Collapse file tree 2 files changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ pub const Element = struct {
4343 y : f64 ,
4444 width : f64 ,
4545 height : f64 ,
46+ bottom : f64 ,
47+ right : f64 ,
48+ top : f64 ,
49+ left : f64 ,
4650 };
4751
4852 pub fn toInterface (e : * parser.Element ) ! Union {
@@ -369,7 +373,16 @@ pub const Element = struct {
369373 pub fn _getBoundingClientRect (self : * parser.Element , page : * Page ) ! DOMRect {
370374 // Since we are lazy rendering we need to do this check. We could store the renderer in a viewport such that it could cache these, but it would require tracking changes.
371375 if (! try page .isNodeAttached (parser .elementToNode (self ))) {
372- return DOMRect { .x = 0 , .y = 0 , .width = 0 , .height = 0 };
376+ return DOMRect {
377+ .x = 0 ,
378+ .y = 0 ,
379+ .width = 0 ,
380+ .height = 0 ,
381+ .bottom = 0 ,
382+ .right = 0 ,
383+ .top = 0 ,
384+ .left = 0 ,
385+ };
373386 }
374387 return page .renderer .getRect (self );
375388 }
Original file line number Diff line number Diff line change @@ -62,20 +62,38 @@ const FlatRenderer = struct {
6262 gop .value_ptr .* = x ;
6363 }
6464
65+ const _x : f64 = @floatFromInt (x );
66+ const y : f64 = 0.0 ;
67+ const w : f64 = 1.0 ;
68+ const h : f64 = 1.0 ;
69+
6570 return .{
66- .x = @floatFromInt (x ),
67- .y = 0.0 ,
68- .width = 1.0 ,
69- .height = 1.0 ,
71+ .x = _x ,
72+ .y = y ,
73+ .width = w ,
74+ .height = h ,
75+ .left = _x ,
76+ .top = y ,
77+ .right = _x + w ,
78+ .bottom = y + h ,
7079 };
7180 }
7281
7382 pub fn boundingRect (self : * const FlatRenderer ) Element.DOMRect {
83+ const x : f64 = 0.0 ;
84+ const y : f64 = 0.0 ;
85+ const w : f64 = @floatFromInt (self .width ());
86+ const h : f64 = @floatFromInt (self .width ());
87+
7488 return .{
75- .x = 0.0 ,
76- .y = 0.0 ,
77- .width = @floatFromInt (self .width ()),
78- .height = @floatFromInt (self .height ()),
89+ .x = x ,
90+ .y = y ,
91+ .width = w ,
92+ .height = h ,
93+ .left = x ,
94+ .top = y ,
95+ .right = x + w ,
96+ .bottom = y + h ,
7997 };
8098 }
8199
You can’t perform that action at this time.
0 commit comments