Make LayoutBlockFlowRareData to hold NGOffsetMapping for legacy layout
This patch makes |LayoutBlockFlowRareData| to hold |NGOffsetMapping| for legacy layout to make |NGInlineNode::GetOffsetMapping()| can use |NGOffsetMapping| once it is computed until next layout for making repeated call of |Element#innerText| faster. Before this patch, |NGOffsetMapping| for legacy layout tree is hold by callers to avoid computing |NGOffsetMapping| in same |LayoutBlockFlow|. However, this simple cache doesn't work for |Element#innerText| when it is called for each element: document.body.innerHTML = '<span>a</span>'.repeat(3000); [...document.getElementByTagName('*')].forEach(e => e.innerText); Before this patch, above code fragment takes 4000ms, after this patch it takes 40ms on my local machine. This patch also movs |LayoutBlockFlowRareData| constructor to ".cc" file to avoid including "ng_offset_mapping.h" to instantiate |std::unique_ptr<NGOffsetMapping| in various places. Note: Following patch[1] will get rid of redundant parameter from |NGInlineNode::GetOffsetMapping()|. [1] http://crrev.com/c/1488400 Get rid of redundant parameter from NGInlineNode::GetOffsetMapping() Bug: 935237 Change-Id: I5990f53632b06e721cc17eca0c80aea8aac36675 Reviewed-on: https://chromium-review.googlesource.com/c/1488479 Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Reviewed-by:Koji Ishii <kojii@chromium.org> Auto-Submit: Yoshifumi Inoue <yosin@chromium.org> Cr-Commit-Position: refs/heads/master@{#636384}
Showing
Please register or sign in to comment