#include "mobilize_rewrite_filter.h"
|
| MobilizeRewriteFilter (RewriteDriver *rewrite_driver) |
|
virtual void | StartDocument () |
|
virtual void | EndDocument () |
|
virtual void | StartElement (HtmlElement *element) |
|
virtual void | EndElement (HtmlElement *element) |
|
virtual void | Characters (HtmlCharactersNode *characters) |
|
virtual const char * | Name () const |
|
|
static void | InitStats (Statistics *statistics) |
|
|
static const char | kPagesMobilized [] |
|
static const char | kKeeperBlocks [] |
|
static const char | kHeaderBlocks [] |
|
static const char | kNavigationalBlocks [] |
|
static const char | kContentBlocks [] |
|
static const char | kMarginalBlocks [] |
|
static const char | kDeletedElements [] |
|
Rewrite HTML to be mobile-friendly based on "data-mobile-role" attributes in the HTML tags. To reorganize the DOM, the filter puts containers at the end of the body into which we move tagged elements. The containers are later removed after the filter is done processing the document body. The filter applies the following transformations:
- Add mobile <style> and <meta name="viewport"...> tags to the head.
- Remove all table tags (but keep the content). Almost all tables in desktop HTML are for formatting, not displaying data, and they tend not to resize well for mobile. The easiest thing to do is to simply strip out the formatting and hope the content reflows properly.
- Reorder body of the HTML DOM elements based on mobile role. Any elements which don't have an important parent will get removed, except for a special set of "keeper" tags (like <script> or <style>). The keeper tags are retained because they are often necessary for the website to work properly, and because they have no visible appearance on the page.
- Remove all elements from inside data-mobile-role="navigational" elements except in a special set of nav tags (notably ). Nav sections often do not resize well due to fixed width formatting and drop-down menus, so it is often necessary to pull out what you want, instead of shuffling around what is there.
Remaining todos:
- Todo:
- TODO (stevensr): This script does not handle flush windows in the body.
The documentation for this class was generated from the following file: