In an interview at Collider.com The Farrelly Brothers talked about when comedy goes over the line, and gave this example:
"In There’s Something About Mary, in the snowball fight where Jeff Daniels throws a snowball at Lauren Holly, and it gets a huge laugh, originally, when she had been hit in the face, we had her come up and she had blood under her nose. We had put blood there, and she came up and there was a little blood dripping. Well, we test screened that and the audience howled when she got hit in the face with the snow, but when they saw that blood, there were no more laughs. It was not funny to them anymore. We had to go in and digitally take the blood out of the movie, and then the laughs continued."
Screenwriter William Goldman tells the story of how he wanted to keep the amputation scene from Stephen King's novel, "Misery." But director Rob Reiner felt this would gross out the audience so much that they wouldn't want to see the rest of the film. He changed the script so that the Kathy Bates character breaks the writer's ankles with a sledgehammer. It was only when the saw the completed film that Goldman admitted he'd been wrong.
Sometimes you don't know for sure whether you're crossing the line--but if you think you might be, probably you are.