1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

Workaround bugs of blink/webkit: (negative) word-spacing, leading spaces, inline/inline-block elements.

This commit is contained in:
Duan Yao 2015-03-16 02:44:38 +08:00
parent 0b873f62b2
commit ebbdbef47e
2 changed files with 14 additions and 8 deletions

View File

@ -161,13 +161,19 @@
/* Workaround for https://bugs.webkit.org/show_bug.cgi?id=35443 */ /* Workaround for https://bugs.webkit.org/show_bug.cgi?id=35443 */
content: ''; content: '';
} }
.@CSS_LINE_CN@ span { /* text blocks within a line */ .@CSS_LINE_CN@:before {
position:relative; /* Workaround Blink(up to 41)/Webkit bug of word-spacing with leading spaces (chromium #404444 and pdf2htmlEX #412) */
/* _<id> for spaces may need display:inline, which will override this */ content: '';
display: inline-block; display: inline-block;
}
.@CSS_LINE_CN@ span { /* text blocks within a line */
/* Blink(up to 41)/Webkit have bug with negative word-spacing and inline-block (pdf2htmlEX #416), so keep normal span inline. */
position:relative;
unicode-bidi:bidi-override; /* For rtl languages, e.g. Hebrew, we don't want the default Unicode behaviour */ unicode-bidi:bidi-override; /* For rtl languages, e.g. Hebrew, we don't want the default Unicode behaviour */
} }
.@CSS_WHITESPACE_CN@ { /* text shift */ .@CSS_WHITESPACE_CN@ { /* text shift */
/* Blink(up to 41)/Webkit have bug with inline element, continuous spaces and word-spacing. Workaround by inline-block. */
display: inline-block;
color: transparent; color: transparent;
z-index: -1; z-index: -1;
} }

View File

@ -245,15 +245,15 @@ public:
static const char * get_css_class_name (void) { return CSS::WHITESPACE_CN; } static const char * get_css_class_name (void) { return CSS::WHITESPACE_CN; }
double default_value(void) { return 0; } double default_value(void) { return 0; }
void dump_value(std::ostream & out, double value) { void dump_value(std::ostream & out, double value) {
out << ((value > 0) ? "display:inline-block;width:" out << ((value > 0) ? "width:"
: "display:inline;margin-left:") : "margin-left:")
<< round(value) << "px;"; << round(value) << "px;";
} }
void dump_print_value(std::ostream & out, double value, double scale) void dump_print_value(std::ostream & out, double value, double scale)
{ {
value *= scale; value *= scale;
out << ((value > 0) ? "display:inline-block;width:" out << ((value > 0) ? "width:"
: "display:inline;margin-left:") : "margin-left:")
<< round(value) << "pt;"; << round(value) << "pt;";
} }
}; };