When there are no more stylesheets schedule the recalc async

Document::didRemoveAllPendingStylesheet gets called whenever the
pending stylesheet counter goes to zero. This can happen many times
in a document if it's inserting inline stylesheets dynamically which
then causes many recalcStyle(Force) to happen.

This patch switches didRemoveAllPendingStylesheet to instead schedule
an async recalc style. This prevents the "waterfall of recalc styles"
you can see in apps that append many <style> elements while they're
loading.

I also removed code that scheduled a relayout when adding or removing
stylesheets since it doesn't appear needed or make sense to do this
outside the normal recalc style flow. In addition making this change
appears to fix the fast/regions/ writing mode tests that were broken
by r157174 where ojan and I fixed writing modes for lazy attach.

BUG=236063,282708

Review URL: https://chromiumcodereview.appspot.com/14604003

git-svn-id: svn://svn.chromium.org/blink/trunk@157497 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Add an option to nextLinePosition to keep going and avoid getting stuck.

(Same to prevLinePosition.)
Sometimes the logic used in nextLinePosition failed and it got stuck.
One cause seemed to be when the next position it found ended up snapping
back to the same visible position, depending on affinity. Explicitly
overriding the affinity masked the problem in many cases, but didn't
solve all cases and just caused other tests to break.

BUG=264769

Review URL: https://chromiumcodereview.appspot.com/20775002

git-svn-id: svn://svn.chromium.org/blink/trunk@157498 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Clean up logic to search for the previous keyframe in a CSS animation

The loop should continue until the index reaches zero. The current code is
correct, but relies on the fact that the loop index will underflow at zero,
which is confusing. This change makes the condition more explicit.

No functional change.

R=dstockwell

Review URL: https://chromiumcodereview.appspot.com/23636016

git-svn-id: svn://svn.chromium.org/blink/trunk@157499 bbb929c8-8fbe-4397-9dbb-9b2b20218538