Switch exclusively to server-side Markdown rendering.

When we introduced Markdown support, we had two renderers:
Python-Markdown (for the server side), and marked.js (for the client
side). Due to a number of issues in the marked.js rendering, this
resulted in some unsatisfactory rendered output in certain situations,
and required invasive escaping to work around other issues.

We no longer use marked.js (which will be removed in a separate change).
Instead, Markdown is rendered as part of the page, and as part of any
API responses (by using the force-text-type options in API requests).
This improves the perceived load time of the page, gives us consistency
in rendering, and will allow us to be a lot smarter about how we escape
and process Markdown in the future.

Some behavior has changed along with this, which should help fix cases
reported by users:

* Code blocks without a language identifier are no longer highlighted by
  default, meaning that fenced or idented code blocks can now be used
  for any plain text.

  Unfortunately, this does mean that older text with code blocks will no
  longer be highlighted unless they use a language identifier on a
  fenced code block, but it's worth losing that to gain some
  consistency.

* Text in code blocks will no longer be turned into links, and will no
  longer be syntax-highlighted, making a plain fenced code block immune
  to formatting.

In order to have access to the raw data for the inlineEditors, builtin
fields now have their raw data stored in the reviewRequestData for the
page, and custom fields have their raw data stored as data-raw-value=
attributes (which are then stored in extraData and removed from the
DOM on load).

This change should let us resolve a lot of the issues people have hit,
and provides a stepping stone for proper support for disabling Markdown
for a field.

Reviewed at https://reviews.reviewboard.org/r/6423/
Merge branch 'release-2.0.x'
Add FileAttachmentHistory model and evolutions.

This change adds a model which is used to aggregate multiple FileAttachments
together into a single "history". This will be used by future changes for the
"Update" command, allowing users to replace attachments with new versions.

Testing done:
Ran evolutions.

Reviewed at https://reviews.reviewboard.org/r/6385/
Allow updating file attachments.

This change adds a new model, FileAttachmentHistory, which aggregates multiple
FileAttachments together into a single unit. Within a history, each file
attachment has a revision. Any "legacy" attachments will be associated with a
new FileAttachmentHistory when the review request page is shown. The history
also contains a "display_position" field, which may eventually be extended to
allow users to re-order the list of attachments on the page.

This also adds an "Update" button to file attachments in the "Actions"
drop-down menu. When clicking this, users will be presented with an upload
dialog allowing them to upload a new file. When a public attachment is updated,
it adds a new revision. When a draft attachment is updated, it is replaced with
the new file.

While I was adding tests and validation to the UploadFileForm, I did some
refactoring. The review request is now passed in as part of the constructor,
which aids in validation. Additionally, I've made it just use self.files (part
of the django Form class) instead of needing to pass in the file a second time
to the create() method.

Testing done:
- Loaded a review request with existing file attachments and saw that new
  FileAttachmentHistory entries were created for each one.
- Updated existing file attachments and saw that the new ones were created,
  visually replaced the ones that they updated, and that publishing the draft
  created the correct change description.
- Updated a file attachment multiple times without publishing the draft and saw
  that it replaced the new revision rather than creating multiple revisions.
- Checked a file attachment that had not yet been published and saw that it
  did not have the "Update" action.
- Ran unit tests.

Fixes bug 800.

Reviewed at https://reviews.reviewboard.org/r/6387/
Support copying text from columns in the diff viewer.

This adds support for selecting text within a column of the diff viewer
or the text file review UI and copying it to the clipboard.

Browsers do not have any sort of support for confining a selection
within a column of text in a table. The few UIs out there that implement
this instead have a div per column, and do tricks like turning off line
wrapping or cutting off text in order to keep rows lined up. Not good
enough for us.

CSS does offer a way of turning off selection for an element, but all
browsers get it terribly wrong. Chrome will limit the visible selection,
but actually select all elements in-between (including other columns),
ignoring what's presented as the selection. Firefox does the inverse,
showing all as selected but only selecting the ones allowed to be
selected (with the added problem of selecting all whitespace that's in
the HTML, even if they're irrelevant to the output).

The good news is, with some cleverness, it turns out we can do
column-based selection sanely across platforms.

On MouseDown, we record the column, with the intent of limiting the
selection to that column. We then set a CSS class that contains the
column index. CSS rules unset selection for all other columns but the
active one, and turn off the selection background (for Firefox).

When the 'copy' event is fired (when the user triggers Copy), we have
the ability to manipulate the clipboard on modern browsers. We grab the
selection range, and extract the contents to a DocumentFragment. We can
then traverse the rows, extract the relevant columns, and build strings
ourselves, which are then set as the clipboard contents.

This gives us smart column-based copying on all modern versions of
Chrome, Firefox, and IE.

Fixes bug #1094
Reviewed at https://reviews.reviewboard.org/r/6435/
Prevent HTTP 500 errors when failing to generate a thumbnail.

If a file for a file attachment is not found when generating a
thumbnail, an exception is raised that bubbles up, resulting in a HTTP
500 error. Now, we catch that error as part of the other operations we
were sandboxing, log it, and return an empty string instead of bubbling
the error up.

Reviewed at https://reviews.reviewboard.org/r/6434/
Improve performance for MarkdownEditorView.

MarkdownEditorView was listening to some frequently-emitted signals on
CodeMirror, performing calculations, and then emitting its own signals.
This ended up taking enough time that it led to a slowdown of text
input, making the input feel sluggish.

We now throttle the events. Viewport changes are limited to one every
250ms, and change events are limited to one every 500ms.

The result is that the widget went from sometimes sluggish performance
to near-native (though this will likely still depend on how overloaded
the browser is and what the page is doing).

Reviewed at https://reviews.reviewboard.org/r/6427/
Merge branch 'release-2.0.x'
Preserve query args when redirecting from Review/Reply draft resources.

The Review/Reply Draft resources redirect to a resource with the
appropriate ID, but when doing so, they don't preserve any query string
arguments. This means that if something like ?api_format or
?force-text-type is used, it will be lost.

We now have a useful utility function for building a URL that preserves
all query string arguments that aren't automatically preserved by the
base WebAPIResource. These are used in all two resources that do a
redirect from a GET.

Reviewed at https://reviews.reviewboard.org/r/6437/
Support including raw text fields in the API when using force-text-type.

The force-text-type= parameter in requests is useful for returning text
in a different format, but there are times when the client would need
the raw text along with this.

Now, the client can also send an include-raw-text-fields=1 parameter,
which will embed a 'raw_text_fields' dictionary in the object's payload
containing an entry for each text field. Each entry provides the raw
version of the text. This is optional, in order to prevent the default
response from ballooning in size.

On an implementation level, this is done by removing all the custom
serializers, and instead adding some metadata to the resource's fields
list for each field that supports text types. MarkdownFieldsMixin's
serialize_object then handles embedding these raw fields in the payload
on request.

Reviewed at https://reviews.reviewboard.org/r/6436/
Merge branch 'release-2.0.x'
Remove marked.js and google-code-prettify.

Now that we no longer render Markdown client-side, we have no need for
either marked.js or google-code-prettify. This change removes them.
Fix some issues that were breaking javascript in firefox.

This fixes a regression introduced when marked.js was removed. Apparently
testing global names to see if they're defined doesn't work so well in firefox.
This broke pretty much all javascript everywhere. Fortunately, we don't care
about setting any marked.js options anymore, so this can just go away.

This also fixes a missing semicolon.

Testing done:
I can edit things on review requests again.

Reviewed at https://reviews.reviewboard.org/r/6440/
Fix a regression in the review request API.

The recent change to the close description fields to handle markdown caused a
regression in the case where the close_description field was null. In this
case, trying to normalize the text would fail, and the API endpoint would
return a 500 with a traceback.

This change makes it so that if a text field is null, we just pass that
through.

Testing done:
- Verified that I could once again update un-published review request drafts.
- Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6441/
Fix an occasional problem with the new CodeMirror optimizations.

We were throttling how often the 'change' event handler for CodeMirror
was getting invoked. However, this meant that there was a window of time
where CodeMirror could be closed/destroyed before the 'change' event
handler was called.

We now check for this and bail if CodeMirror is no longer with us.

Reviewed at https://reviews.reviewboard.org/r/6439/
Merge branch 'release-2.0.x'
Fix JavaScript unit tests for 2.0.x.

A lot of the optimizations made resulted in broken unit tests, due to
various tests not accounting for throttled results.

We now optimistically disable throttling where possible (for cases where
the _.throttle call isn't part of the object's prototype) and do proper
async testing in the other cases.

Reviewed at https://reviews.reviewboard.org/r/6443/
Merge branch 'release-2.0.x'
Revert "Make autocomplete less agressive."

This reverts commit 00bc85d6b82519f61e92b2b87e95cdf5b230a5d2.
Merge branch 'release-2.0.x'