Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Unified Diff: Source/core/layout/line/GlyphOverflow.h

Issue 1179723002: Store glyph bounds in WordMeasurement to avoid slow path width calc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/line/BreakingContextInlineHeaders.h ('k') | Source/core/layout/line/InlineFlowBox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/line/GlyphOverflow.h
diff --git a/Source/core/layout/line/GlyphOverflow.h b/Source/core/layout/line/GlyphOverflow.h
new file mode 100644
index 0000000000000000000000000000000000000000..418391000032009fda3a54d40064c83a8623c6d7
--- /dev/null
+++ b/Source/core/layout/line/GlyphOverflow.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GlyphOverflow_h
+#define GlyphOverflow_h
+
+#include "platform/geometry/FloatRect.h"
+#include <math.h>
+
+namespace blink {
+
+struct GlyphOverflow {
+ GlyphOverflow()
+ : left(0)
+ , right(0)
+ , top(0)
+ , bottom(0)
+ , computeBounds(false)
+ {
+ }
+
+ bool isZero() const
+ {
+ return !left && !right && !top && !bottom;
+ }
+
+ void setFromBounds(const FloatRect& bounds, float ascent, float descent, float textWidth)
+ {
+ top = ceilf(computeBounds ? -bounds.y() : std::max(0.0f, -bounds.y() - ascent));
+ bottom = ceilf(computeBounds ? bounds.maxY() : std::max(0.0f, bounds.maxY() - descent));
+ left = ceilf(std::max(0.0f, -bounds.x()));
+ right = ceilf(std::max(0.0f, bounds.maxX() - textWidth));
+ }
+
+ // If computeBounds, top and bottom are the maximum heights of the glyphs above and below the baseline, respectively.
+ // Otherwise they are the amounts of glyph overflows exceeding the font metrics' ascent and descent, respectively.
+ // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively.
+ // All fields are in absolute number of pixels rounded up to the nearest integer.
+ int left;
+ int right;
+ int top;
+ int bottom;
+ bool computeBounds;
+};
+
+} // namespace blink
+
+#endif // GlyphOverflow_h
« no previous file with comments | « Source/core/layout/line/BreakingContextInlineHeaders.h ('k') | Source/core/layout/line/InlineFlowBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698