From 7f6f56f40ab4aab138621361ce90953b5f0ccbe4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 5 Dec 2016 17:37:51 +0100 Subject: [PATCH] Get rid of Inset::setDimCache This helper method is used to set the inset dimension cache at metrics time. However this is already done by the metrics code itself (MathRow::metrics, TextMetrics::redoParagraph), so that there is no need to do this same work again in a different place. Also, InsetPhantom::metrics is removed, since it does not do anything interesting. This commit comes with a mild risk attached (it might be that some of these calls were useful after all!), but all of this is fixable. --- src/insets/Inset.cpp | 6 ------ src/insets/Inset.h | 2 -- src/insets/InsetIPA.cpp | 2 -- src/insets/InsetIPAMacro.cpp | 4 ---- src/insets/InsetLine.cpp | 3 --- src/insets/InsetNewpage.cpp | 2 -- src/insets/InsetPhantom.cpp | 9 --------- src/insets/InsetPhantom.h | 2 -- src/insets/InsetPreview.cpp | 2 -- src/insets/InsetSpace.cpp | 2 -- src/insets/InsetSpecialChar.cpp | 2 -- src/insets/InsetVSpace.cpp | 2 -- src/mathed/CommandInset.cpp | 2 -- src/mathed/InsetMathGrid.cpp | 2 -- src/mathed/InsetMathHull.cpp | 5 ----- src/mathed/MathMacroTemplate.cpp | 2 -- 16 files changed, 49 deletions(-) diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index c00f27e28d..21d54e0bc9 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -625,12 +625,6 @@ ColorCode Inset::labelColor() const } -void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const -{ - mi.base.bv->coordCache().insets().add(this, dim); -} - - Buffer const * Inset::updateFrontend() const { //FIXME (Abdel 03/12/10): see bugs #6814 and #6949 diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 1b3f85ebc7..4f6db3af06 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -216,8 +216,6 @@ public: int xo(BufferView const & bv) const; /// last drawn position for 'important' insets int yo(BufferView const & bv) const; - /// - void setDimCache(MetricsInfo const &, Dimension const &) const; /// do we cover screen position x/y? bool covers(BufferView const & bv, int x, int y) const; /// get the screen positions of the cursor (see note in Cursor.cpp) diff --git a/src/insets/InsetIPA.cpp b/src/insets/InsetIPA.cpp index a574da86c5..29ed00037f 100644 --- a/src/insets/InsetIPA.cpp +++ b/src/insets/InsetIPA.cpp @@ -188,8 +188,6 @@ void InsetIPA::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += TEXT_TO_INSET_OFFSET; // insert a one pixel gap dim.wid += 1; - // Cache the inset dimension. - setDimCache(mi, dim); Dimension dim_dummy; MetricsInfo mi_dummy = mi; InsetText::metrics(mi_dummy, dim_dummy); diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index bf3cab5c3b..7852486b7d 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -173,9 +173,6 @@ void InsetIPADeco::metrics(MetricsInfo & mi, Dimension & dim) const theFontMetrics(font).rectText(label, w, a, d); dim.des += int(d * 1.5); } - - // cache the inset dimension - setDimCache(mi, dim); } @@ -413,7 +410,6 @@ void InsetIPAChar::metrics(MetricsInfo & mi, Dimension & dim) const } docstring ds(s.begin(), s.end()); dim.wid = fm.width(ds); - setDimCache(mi, dim); } diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp index 46e017f99b..dc75aa4251 100644 --- a/src/insets/InsetLine.cpp +++ b/src/insets/InsetLine.cpp @@ -132,9 +132,6 @@ void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = max(fm.maxAscent(), offset_ + height_); dim.des = max(fm.maxDescent(), - offset_); - - // Cache the inset dimension - setDimCache(mi, dim); } diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index b369ce1b7e..e83f56dc70 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -103,8 +103,6 @@ void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = defaultRowHeight(); dim.des = defaultRowHeight(); dim.wid = mi.base.textwidth; - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index 78bc55ed82..8a156ea2f1 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -135,15 +135,6 @@ docstring InsetPhantom::layoutName() const } -void InsetPhantom::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - - // cache the inset dimension - setDimCache(mi, dim); -} - - void InsetPhantom::draw(PainterInfo & pi, int x, int y) const { // draw the text diff --git a/src/insets/InsetPhantom.h b/src/insets/InsetPhantom.h index fad50637b2..42c3da1f26 100644 --- a/src/insets/InsetPhantom.h +++ b/src/insets/InsetPhantom.h @@ -62,8 +62,6 @@ private: /// docstring layoutName() const; /// - void metrics(MetricsInfo &, Dimension &) const; - /// void draw(PainterInfo & pi, int x, int y) const; /// void write(std::ostream &) const; diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp index 739322b9b0..c306ae91d2 100644 --- a/src/insets/InsetPreview.cpp +++ b/src/insets/InsetPreview.cpp @@ -174,8 +174,6 @@ void InsetPreview::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += TEXT_TO_INSET_OFFSET; // insert a one pixel gap dim.wid += 1; - // Cache the inset dimension. - setDimCache(mi, dim); Dimension dim_dummy; MetricsInfo mi_dummy = mi; InsetText::metrics(mi_dummy, dim_dummy); diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 7d76f3f62e..6593d045de 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -260,8 +260,6 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const // shut up compiler break; } - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp index b6bcb479c8..462620532b 100644 --- a/src/insets/InsetSpecialChar.cpp +++ b/src/insets/InsetSpecialChar.cpp @@ -129,8 +129,6 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const } if (dim.wid == 0) dim.wid = fm.width(s); - - setDimCache(mi, dim); } diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index 461933cb56..d4e1aaf4a8 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -150,8 +150,6 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = height / 2 + (a - d) / 2; // align cursor with the dim.des = height - dim.asc; // label text dim.wid = ADD_TO_VSPACE_WIDTH + 2 * vspace_arrow_size + 5 + w; - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/CommandInset.cpp b/src/mathed/CommandInset.cpp index 6b9466481c..0c9e585e1a 100644 --- a/src/mathed/CommandInset.cpp +++ b/src/mathed/CommandInset.cpp @@ -43,8 +43,6 @@ void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const button_.update(screenLabel(), true); } button_.metrics(mi, dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index fca8f380d2..72adce74a2 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -589,8 +589,6 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const */ dim.wid += leftMargin() + rightMargin(); metricsMarkers2(mi, dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 402770738b..807475e63a 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -515,8 +515,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const if (display()) dim.des += displayMargin(); } - // Cache the inset dimension. - setDimCache(mi, dim); return; } @@ -550,9 +548,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const math_font_max_dim(mi.base.font, asc, des); dim.asc = max(dim.asc, asc); dim.des = max(dim.des, des); - // Cache the inset dimension. - // FIXME: This will overwrite InsetMathGrid dimension, is that OK? - setDimCache(mi, dim); } diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 2a7dc774d6..2ac8703cb0 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -578,8 +578,6 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid += 6; dim.des += 2; dim.asc += 2; - - setDimCache(mi, dim); }